This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

120
pop/old/Header.cpp Normal file
View File

@@ -0,0 +1,120 @@
#include <pop/header.hpp>
#include <common/openfile.hpp>
#include <common/filemap.hpp>
#include <common/pview.hpp>
#include <common/block.hpp>
Header &Header::operator=(const Header &someHeader)
{
path(someHeader.path());
from(someHeader.from());
newsGroups(someHeader.newsGroups());
subject(someHeader.subject());
date(someHeader.date());
organization(someHeader.organization());
lines(someHeader.lines());
messageID(someHeader.messageID());
replyTo(someHeader.replyTo());
postingHost(someHeader.postingHost());
newsReader(someHeader.newsReader());
crossReference(someHeader.crossReference());
contentType(someHeader.contentType());
xMailer(someHeader.xMailer());
return *this;
}
Header &Header::operator=(Block<String> &headerLines)
{
UINT lineCount(headerLines.size());
for(int lineIndex=0;lineIndex<lineCount;lineIndex++)
{
String lineItem(headerLines[lineIndex].betweenString(' ',0));
String &headerLine=headerLines[lineIndex];
if(headerLine.isNull())continue;
if(isPath(headerLine))path(lineItem);
else if(isFrom(headerLine))from(lineItem);
else if(isNewsGroups(headerLine))newsGroups(lineItem);
else if(isSubject(headerLine))subject(lineItem);
else if(isDate(headerLine))date(lineItem);
else if(isOrganization(headerLine))organization(lineItem);
else if(isLines(headerLine))lines(lineItem);
else if(isMessageID(headerLine))messageID(lineItem);
else if(isReplyTo(headerLine))replyTo(lineItem);
else if(isNNTPPostingHost(headerLine))postingHost(lineItem);
else if(isNewsReader(headerLine))newsReader(lineItem);
else if(isCrossReference(headerLine))crossReference(lineItem);
else if(isContentType(headerLine))contentType(lineItem);
else if(isMailer(headerLine))xMailer(lineItem);
}
if(replyTo().isNull())replyTo(from());
return *this;
}
Header &Header::operator=(const String &pathFileName)
{
FileHandle headerFile(pathFileName,FileHandle::Read,FileHandle::ShareRead);
FileMap headerMap(headerFile);
PureViewOfFile headerView(headerMap);
String headerLine;
String lineItem;
if(!headerFile.isOkay())return *this;
while(headerView.getLine(headerLine))
{
if(headerLine.isNull()||!headerLine.length())break;
lineItem=(headerLine.betweenString(' ',0));
if(isPath(headerLine))path(lineItem);
else if(isFrom(headerLine))from(lineItem);
else if(isNewsGroups(headerLine))newsGroups(lineItem);
else if(isSubject(headerLine))subject(lineItem);
else if(isDate(headerLine))date(lineItem);
else if(isOrganization(headerLine))organization(lineItem);
else if(isLines(headerLine))lines(lineItem);
else if(isMessageID(headerLine))messageID(lineItem);
else if(isReplyTo(headerLine))replyTo(lineItem);
else if(isNNTPPostingHost(headerLine))postingHost(lineItem);
else if(isNewsReader(headerLine))newsReader(lineItem);
else if(isCrossReference(headerLine))crossReference(lineItem);
else if(isContentType(headerLine))contentType(lineItem);
else if(isMailer(headerLine))xMailer(lineItem);
}
if(replyTo().isNull())replyTo(from());
return *this;
}
SystemTime Header::systemTime(void)
{
SystemTime systemTime;
char *ptrString;
if(mDate.isNull())return systemTime;
String tmpDate(mDate.betweenString(',',0));
if(tmpDate.isNull())return systemTime;
ptrString=(LPSTR)tmpDate;
ptrString=::strtok(ptrString," ");
if(!ptrString)return systemTime;
systemTime.day(::atoi(ptrString));
ptrString=::strtok(0," ");
if(!ptrString)return systemTime;
if(!::strcmp(ptrString,"Jan"))systemTime.month(SystemTime::January);
else if(!::strcmp(ptrString,"Feb"))systemTime.month(SystemTime::February);
else if(!::strcmp(ptrString,"Mar"))systemTime.month(SystemTime::March);
else if(!::strcmp(ptrString,"Apr"))systemTime.month(SystemTime::April);
else if(!::strcmp(ptrString,"May"))systemTime.month(SystemTime::May);
else if(!::strcmp(ptrString,"Jun"))systemTime.month(SystemTime::June);
else if(!::strcmp(ptrString,"Jul"))systemTime.month(SystemTime::July);
else if(!::strcmp(ptrString,"Aug"))systemTime.month(SystemTime::August);
else if(!::strcmp(ptrString,"Sep"))systemTime.month(SystemTime::September);
else if(!::strcmp(ptrString,"Oct"))systemTime.month(SystemTime::October);
else if(!::strcmp(ptrString,"Nov"))systemTime.month(SystemTime::November);
else if(!::strcmp(ptrString,"Dec"))systemTime.month(SystemTime::December);
else systemTime.month(SystemTime::None);
ptrString=::strtok(0," ");
if(!ptrString)return systemTime;
systemTime.year(::atoi(ptrString));
systemTime.hour(0);
systemTime.minute(0);
systemTime.second(0);
systemTime.milliseconds(0);
return systemTime;
}

366
pop/old/Header.hpp Normal file
View File

@@ -0,0 +1,366 @@
#ifndef _POP_HEADER_HPP_
#define _POP_HEADER_HPP_
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_SYSTEMTIME_HPP_
#include <common/systime.hpp>
#endif
template <class T>
class Block;
class Header
{
public:
Header(void);
Header(Block<String> &headerLines);
Header(const Header &someHeader);
Header(const String &pathFileName);
virtual ~Header();
Header &operator=(const Header &someHeader);
Header &operator=(Block<String> &headerLines);
Header &operator=(const String &pathFileName);
const String &path(void)const;
const String &from(void)const;
const String &newsGroups(void)const;
const String &subject(void)const;
const String &date(void)const;
SystemTime systemTime(void);
const String &organization(void)const;
const String &lines(void)const;
const String &messageID(void)const;
const String &replyTo(void)const;
const String &postingHost(void)const;
const String &newsReader(void)const;
const String &crossReference(void)const;
const String &contentType(void)const;
const String &xMailer(void)const;
private:
void path(const String &path);
void from(const String &from);
void newsGroups(const String &newsGroups);
void subject(const String &subject);
void date(const String &date);
void organization(const String &organization);
void lines(const String &lines);
void messageID(const String &messageID);
void replyTo(const String &replyTo);
void postingHost(const String &postingHost);
void newsReader(const String &newsReader);
void crossReference(const String &crossReference);
void contentType(const String &contentType);
void xMailer(const String &xMailer);
WORD isPath(const String &stringLine)const;
WORD isFrom(const String &stringLine)const;
WORD isNewsGroups(const String &stringLine)const;
WORD isSubject(const String &stringLine)const;
WORD isDate(const String &stringLine)const;
WORD isOrganization(const String &stringLine)const;
WORD isLines(const String &stringLine)const;
WORD isMessageID(const String &stringLine)const;
WORD isReplyTo(const String &stringLine)const;
WORD isNNTPPostingHost(const String &stringLine)const;
WORD isNewsReader(const String &stringLine)const;
WORD isCrossReference(const String &stringLine)const;
WORD isContentType(const String &stringLine)const;
WORD isMailer(const String &stringLine)const;
String mPath;
String mFrom;
String mNewsGroups;
String mSubject;
String mDate;
String mOrganization;
String mLines;
String mMessageID;
String mReplyTo;
String mPostingHost;
String mContentType;
String mXMailer;
String mNewsReader;
String mCrossReference;
};
inline
Header::Header(void)
{
}
inline
Header::Header(Block<String> &headerLines)
{
*this=headerLines;
}
inline
Header::Header(const Header &someHeader)
{
*this=someHeader;
}
inline
Header::Header(const String &pathFileName)
{
*this=pathFileName;
}
inline
Header::~Header()
{
}
inline
const String &Header::path(void)const
{
return mPath;
}
inline
void Header::path(const String &path)
{
mPath=path;
}
inline
const String &Header::from(void)const
{
return mFrom;
}
inline
void Header::from(const String &from)
{
mFrom=from;
}
inline
const String &Header::newsGroups(void)const
{
return mNewsGroups;
}
inline
void Header::newsGroups(const String &newsGroups)
{
mNewsGroups=newsGroups;
}
inline
const String &Header::subject(void)const
{
return mSubject;
}
inline
void Header::subject(const String &subject)
{
mSubject=subject;
}
inline
const String &Header::date(void)const
{
return mDate;
}
inline
void Header::date(const String &date)
{
mDate=date;
}
inline
const String &Header::organization(void)const
{
return mOrganization;
}
inline
void Header::organization(const String &organization)
{
mOrganization=organization;
}
inline
const String &Header::lines(void)const
{
return mLines;
}
inline
void Header::lines(const String &lines)
{
mLines=lines;
}
inline
const String &Header::messageID(void)const
{
return mMessageID;
}
inline
void Header::messageID(const String &messageID)
{
mMessageID=messageID;
}
inline
const String &Header::replyTo(void)const
{
return mReplyTo;
}
inline
void Header::replyTo(const String &replyTo)
{
mReplyTo=replyTo;
}
inline
const String &Header::postingHost(void)const
{
return mPostingHost;
}
inline
void Header::postingHost(const String &postingHost)
{
mPostingHost=postingHost;
}
inline
const String &Header::newsReader(void)const
{
return mNewsReader;
}
inline
void Header::newsReader(const String &newsReader)
{
mNewsReader=newsReader;
}
inline
const String &Header::crossReference(void)const
{
return mCrossReference;
}
inline
void Header::crossReference(const String &crossReference)
{
mCrossReference=crossReference;
}
inline
const String &Header::contentType(void)const
{
return mContentType;
}
inline
void Header::contentType(const String &contentType)
{
mContentType=contentType;
}
inline
const String &Header::xMailer(void)const
{
return mXMailer;
}
inline
void Header::xMailer(const String &xMailer)
{
mXMailer=xMailer;
}
inline
WORD Header::isPath(const String &stringLine)const
{
return (!::strncmp(stringLine,"Path: ",6)?TRUE:FALSE);
}
inline
WORD Header::isFrom(const String &stringLine)const
{
return (!::strncmp(stringLine,"From: ",6)?TRUE:FALSE);
}
inline
WORD Header::isNewsGroups(const String &stringLine)const
{
return (!::strncmp(stringLine,"Newsgroups: ",12)?TRUE:FALSE);
}
inline
WORD Header::isSubject(const String &stringLine)const
{
return (!::strncmp(stringLine,"Subject: ",9)?TRUE:FALSE);
}
inline
WORD Header::isDate(const String &stringLine)const
{
return (!::strncmp(stringLine,"Date: ",6)?TRUE:FALSE);
}
inline
WORD Header::isOrganization(const String &stringLine)const
{
return (!::strncmp(stringLine,"Organization: ",14)?TRUE:FALSE);
}
inline
WORD Header::isLines(const String &stringLine)const
{
return (!::strncmp(stringLine,"Lines: ",7)?TRUE:FALSE);
}
inline
WORD Header::isMessageID(const String &stringLine)const
{
return (!::strncmp(stringLine,"Message-ID: ",12)?TRUE:FALSE);
}
inline
WORD Header::isReplyTo(const String &stringLine)const
{
return (!::strncmp(stringLine,"Reply-To: ",10)?TRUE:FALSE);
}
inline
WORD Header::isNNTPPostingHost(const String &stringLine)const
{
return (!::strncmp(stringLine,"NNTP-Posting-Host",17)?TRUE:FALSE);
}
inline
WORD Header::isNewsReader(const String &stringLine)const
{
return (!::strncmp(stringLine,"X-Newsreader: ",14)?TRUE:FALSE);
}
inline
WORD Header::isCrossReference(const String &stringLine)const
{
return (!::strncmp(stringLine,"Xref: ",6)?TRUE:FALSE);
}
inline
WORD Header::isContentType(const String &stringLine)const
{
return (!::strncmp(stringLine,"Content-Type: ",14)?TRUE:FALSE);
}
inline
WORD Header::isMailer(const String &stringLine)const
{
return (!::strncmp(stringLine,"X-Mailer: ",10)?TRUE:FALSE);
}
#endif

77
pop/old/LOGINDLG.CPP Normal file
View File

@@ -0,0 +1,77 @@
#include <pop/logindlg.hpp>
WORD LoginDialog::performLogin(void)
{
DialogTemplate dlgTemplate;
DialogItemTemplate userEdit;
DialogItemTemplate passEdit;
DialogItemTemplate userStatic;
DialogItemTemplate passStatic;
dlgTemplate.titleText("Login to host...");
dlgTemplate.posRect(Rect(8,19,197,76));
dlgTemplate.pointSize(8);
dlgTemplate.typeFace("Helv");
dlgTemplate.style(DS_MODALFRAME|WS_TABSTOP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_3DLOOK|DS_SETFONT|WS_POPUP);
userEdit.className("EDIT");
userEdit.titleText("");
userEdit.style(WS_BORDER|WS_TABSTOP|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL);
userEdit.posRect(Rect(56,19,98,12));
userEdit.itemID(UserNameID);
passEdit.className("EDIT");
passEdit.style(WS_BORDER|WS_TABSTOP|ES_PASSWORD|WS_CHILD|WS_VISIBLE);
passEdit.posRect(Rect(56,35,98,12));
passEdit.itemID(PasswordID);
userStatic.className("STATIC");
userStatic.titleText("User Name :");
userStatic.style(WS_CHILD|WS_VISIBLE);
userStatic.posRect(Rect(2,20,39,8));
userStatic.itemID(-1);
passStatic.className("STATIC");
passStatic.titleText("Password :");
passStatic.style(WS_CHILD|WS_VISIBLE);
passStatic.posRect(Rect(2,36,39,8));
passStatic.itemID(-1);
dlgTemplate+=userEdit;
dlgTemplate+=passEdit;
dlgTemplate+=userStatic;
dlgTemplate+=passStatic;
createDialog(::GetTopWindow((HWND)0),dlgTemplate);
if(userName().isNull()&&password().isNull())return FALSE;
return TRUE;
}
WORD LoginDialog::dlgCommand(DWORD commandID,CallbackData &/*someCallbackData*/)
{
switch(commandID)
{
case IDOK :
getText(UserNameID,mUserName);
getText(PasswordID,mPassword);
if(mUserName.isNull()||mPassword.isNull()){::MessageBeep(0);return TRUE;}
break;
case IDCANCEL :
mUserName.reserve(String::MaxString);
mPassword.reserve(String::MaxString);
break;
}
return FALSE;
}
void LoginDialog::dlgInitDialog(CallbackData &/*someCallbackData*/)
{
if(!userName().isNull())setText(UserNameID,userName());
if(!password().isNull())setText(PasswordID,password());
setFocus();
}
void LoginDialog::dlgDestroyDialog(CallbackData &/*someCallbackData*/)
{
}

69
pop/old/LOGINDLG.HPP Normal file
View File

@@ -0,0 +1,69 @@
#ifndef _POP_LOGINDIALOG_HPP_
#define _POP_LOGINDIALOG_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _DIALOG_DYNAMICDIALOG_HPP_
#include <dialog/dyndlg.hpp>
#endif
class LoginDialog : public DynamicDialog
{
public:
LoginDialog(void);
virtual ~LoginDialog();
WORD performLogin(void);
String userName(void)const;
void userName(const String &userName);
String password(void)const;
void password(const String &password);
private:
enum {UserNameID=101,PasswordID=102};
LoginDialog(const LoginDialog &loginDialog);
WORD dlgCommand(DWORD commandID,CallbackData &someCallbackData);
void dlgInitDialog(CallbackData &someCallbackData);
void dlgDestroyDialog(CallbackData &someCallbackData);
String mUserName;
String mPassword;
};
inline
LoginDialog::LoginDialog(void)
{
}
inline
LoginDialog::LoginDialog(const LoginDialog &/*loginDialog*/)
{
}
inline
LoginDialog::~LoginDialog()
{
}
inline
String LoginDialog::userName(void)const
{
return mUserName;
}
inline
void LoginDialog::userName(const String &userName)
{
mUserName=userName;
}
inline
String LoginDialog::password(void)const
{
return mPassword;
}
inline
void LoginDialog::password(const String &password)
{
mPassword=password;
}
#endif

48
pop/old/Main.cpp Normal file
View File

@@ -0,0 +1,48 @@
#include <pop/main.hpp>
#include <pop/popdlg.hpp>
HINSTANCE Main::smhInstance=0;
HINSTANCE Main::smhPrevInstance=0;
int Main::smnCmdShow=0;
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR /*lpszCmdLine*/,int nCmdShow)
{
Main::processInstance(hInstance);
Main::previousProcessInstance(hPrevInstance);
Main::cmdShow(nCmdShow);
POPDlg popDialog;
return popDialog.perform();
}
#if 0
#include <common/string.hpp>
#include <pop/main.hpp>
#include <pop/mainwnd.hpp>
HINSTANCE Main::smhInstance=0;
HINSTANCE Main::smhPrevInstance=0;
int Main::smnCmdShow=0;
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR /*lpszCmdLine*/,int nCmdShow)
{
Main::processInstance(hInstance);
Main::previousProcessInstance(hPrevInstance);
Main::cmdShow(nCmdShow);
if(Main::previousProcessInstance())
{
HWND hWnd=::FindWindow(MainWindow::className(),MainWindow::className());
if(!hWnd)
{
::MessageBox(::GetFocus(),(LPSTR)"Failed to maximize previous instance",(LPSTR)"Error",MB_ICONSTOP|MB_SYSTEMMODAL);
return FALSE;
}
::PostMessage(hWnd,WM_REACTIVATE,0,0L);
return FALSE;
}
MainWindow applicationWindow(Main::processInstance());
return applicationWindow.messageLoop();
}
#endif

68
pop/old/Main.hpp Normal file
View File

@@ -0,0 +1,68 @@
#ifndef _POP_MAIN_HPP_
#define _POP_MAIN_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
class Main
{
public:
static HINSTANCE processInstance(HWND hWnd);
static HINSTANCE processInstance(void);
static HINSTANCE previousProcessInstance(void);
static void processInstance(HINSTANCE processInstance);
static void previousProcessInstance(HINSTANCE previousProcessInstance);
static void cmdShow(int nCmdShow);
private:
static HINSTANCE smhInstance;
static HINSTANCE smhPrevInstance;
static int smnCmdShow;
};
inline
void Main::processInstance(HINSTANCE hProcessInstance)
{
smhInstance=hProcessInstance;
}
inline
void Main::previousProcessInstance(HINSTANCE previousProcessInstance)
{
smhPrevInstance=previousProcessInstance;
}
inline
void Main::cmdShow(int nCmdShow)
{
}
inline
HINSTANCE Main::processInstance(void)
{
return smhInstance;
}
inline
HINSTANCE Main::previousProcessInstance(void)
{
return smhPrevInstance;
}
#if defined(__FLAT__)
inline
HINSTANCE Main::processInstance(HWND hWnd)
{
return (HINSTANCE)::GetWindowLong(hWnd,GWL_HINSTANCE);
}
#else
inline
HINSTANCE Main::processInstance(HWND hWnd)
{
return (HINSTANCE)::GetWindowWord(hWnd,GWW_HINSTANCE);
}
#endif
#define WM_REACTIVATE WM_USER+1
#endif


140
pop/old/Mainwnd.cpp Normal file
View File

@@ -0,0 +1,140 @@
#include <pop/mainwnd.hpp>
#include <pop/pop.hpp>
char MainWindow::szClassName[]="POP3 client v1.00";
char MainWindow::szMenuName[]="POP3";
MainWindow::MainWindow(HINSTANCE hInstance)
: mPaintHandler(this,&MainWindow::paintHandler),
mDestroyHandler(this,&MainWindow::destroyHandler),
mCommandHandler(this,&MainWindow::commandHandler),
mKeyDownHandler(this,&MainWindow::keyDownHandler),
mSizeHandler(this,&MainWindow::sizeHandler),
mCreateHandler(this,&MainWindow::createHandler),
mTimerHandler(this,&MainWindow::timerHandler),
mSetFocusHandler(this,&MainWindow::setFocusHandler),
mhInstance(hInstance)
{
insertHandlers();
registerClass();
::CreateWindow(szClassName,szClassName,
WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_DLGFRAME|WS_CLIPCHILDREN,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,mhInstance,(LPSTR)this);
show(SW_SHOW);
update();
Block<String> msgLines;
WORD messages;
WORD octets;
POPClient popClient;
popClient.open("mailhost.li.net");
if(!popClient.authenticate("europa","cygnus-x1"))
{
popClient.quit();
popClient.close();
return;
}
popClient.stat(messages,octets);
popClient.top(msgLines,1);
// for(int msgIndex=1;msgIndex<=messages;msgIndex++)popClient.retrieve(msgIndex,msgLines);
popClient.quit();
popClient.close();
}
MainWindow::~MainWindow()
{
destroy();
}
void MainWindow::insertHandlers(void)
{
insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
insertHandler(VectorHandler::PaintHandler,&mPaintHandler);
insertHandler(VectorHandler::CommandHandler,&mCommandHandler);
insertHandler(VectorHandler::SizeHandler,&mSizeHandler);
insertHandler(VectorHandler::KeyDownHandler,&mKeyDownHandler);
insertHandler(VectorHandler::CreateHandler,&mCreateHandler);
insertHandler(VectorHandler::TimerHandler,&mTimerHandler);
insertHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler);
}
void MainWindow::removeHandlers(void)
{
removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
removeHandler(VectorHandler::PaintHandler,&mPaintHandler);
removeHandler(VectorHandler::CommandHandler,&mCommandHandler);
removeHandler(VectorHandler::SizeHandler,&mSizeHandler);
removeHandler(VectorHandler::KeyDownHandler,&mKeyDownHandler);
removeHandler(VectorHandler::CreateHandler,&mCreateHandler);
removeHandler(VectorHandler::TimerHandler,&mTimerHandler);
removeHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler);
}
void MainWindow::registerClass(void)const
{
WNDCLASS wndClass;
if(::GetClassInfo(mhInstance,className(),(WNDCLASS FAR*)&wndClass))return;
wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|CS_OWNDC;
wndClass.lpfnWndProc =(WNDPROC)Window::WndProc;
wndClass.cbClsExtra =0;
wndClass.cbWndExtra =sizeof(MainWindow*);
wndClass.hInstance =mhInstance;
wndClass.hIcon =::LoadIcon(NULL,IDI_APPLICATION);
wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW);
wndClass.hbrBackground =(HBRUSH)::GetStockObject(BLACK_BRUSH);
wndClass.lpszMenuName =szMenuName;
wndClass.lpszClassName =szClassName;
::RegisterClass(&wndClass);
assert(0!=::GetClassInfo(mhInstance,className(),(WNDCLASS FAR*)&wndClass));
}
CallbackData::ReturnType MainWindow::destroyHandler(CallbackData &/*someCallbackData*/)
{
removeHandlers();
::PostQuitMessage(0);
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainWindow::sizeHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainWindow::commandHandler(CallbackData &someCallbackData)
{
switch(someCallbackData.wParam())
{
default :
break;
}
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainWindow::keyDownHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainWindow::paintHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainWindow::createHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainWindow::timerHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType MainWindow::setFocusHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}

56
pop/old/Mainwnd.hpp Normal file
View File

@@ -0,0 +1,56 @@
#ifndef _POP_MAINWINDOW_HPP_
#define _POP_MAINWINDOW_HPP_
#ifndef _COMMON_WINDOW_HPP_
#include <common/window.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _SOCKET_WSADATA_HPP_
#include <socket/wsadata.hpp>
#endif
class MainWindow : public Window
{
public:
MainWindow(HINSTANCE hInstance);
virtual ~MainWindow();
static String className(void);
private:
enum{TimerID=0};
void registerClass(void)const;
void insertHandlers(void);
void removeHandlers(void);
void message(const String &messageString);
void message(Block<String> &messageStrings);
CallbackData::ReturnType paintHandler(CallbackData &someCallbackData);
CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData);
CallbackData::ReturnType commandHandler(CallbackData &someCallbackData);
CallbackData::ReturnType keyDownHandler(CallbackData &someCallbackData);
CallbackData::ReturnType sizeHandler(CallbackData &someCallbackData);
CallbackData::ReturnType createHandler(CallbackData &someCallbackData);
CallbackData::ReturnType timerHandler(CallbackData &someCallbackData);
CallbackData::ReturnType setFocusHandler(CallbackData &someCallbackData);
CallbackData::ReturnType lineHandler(CallbackData &someCallbackData);
CallbackData::ReturnType completionHandler(CallbackData &someCallbackData);
Callback<MainWindow> mPaintHandler;
Callback<MainWindow> mDestroyHandler;
Callback<MainWindow> mCommandHandler;
Callback<MainWindow> mKeyDownHandler;
Callback<MainWindow> mSizeHandler;
Callback<MainWindow> mCreateHandler;
Callback<MainWindow> mTimerHandler;
Callback<MainWindow> mSetFocusHandler;
static char szClassName[];
static char szMenuName[];
HINSTANCE mhInstance;
WSASystem mWSASystem;
};
inline
String MainWindow::className(void)
{
return String(szClassName);
}
#endif

188
pop/old/POP.CPP Normal file
View File

@@ -0,0 +1,188 @@
#include <pop/pop.hpp>
#include <socket/hostent.hpp>
#include <socket/servent.hpp>
POPClient::POPClient(void)
: mSpace(" "), mIsLoggedIn(FALSE)
{
createCmds();
createStats();
}
POPClient::~POPClient()
{
}
BOOL POPClient::open(const String &hostName)
{
HostEnt hostEntry;
ServEnt serverEntry;
Block<String> responseLines;
INETSocketAddress internetSocketAddress;
if(hostName.isNull())return FALSE;
if(mPOPControl.isConnected())mPOPControl.closeSocket();
message(String("trying ")+hostName+String("..."));
if(!mWSASystem.isInitialized()){message("WINSOCK initialization failure.");return FALSE;}
InternetAddress internetAddress(hostName);
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){return FALSE;}}
else if(!hostEntry.hostByName(hostName)){return FALSE;}
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){message(String("no DNS entry for ")+hostName);return FALSE;}}
else if(!hostEntry.hostByName(hostName)){message(String("no DNS entry for ")+hostName);return FALSE;}
message(String("connect...")+String("'")+hostEntry.hostName()+String("' (")+(String)(hostEntry.addresses())[0]+String(")"));
internetSocketAddress.internetAddress((hostEntry.addresses())[0]);
if(serverEntry.serviceByName("pop3","tcp"))
{
if(!mPOPControl.openSocket()){message("unable to create socket.");return FALSE;}
internetSocketAddress.family(PF_INET);
internetSocketAddress.port(serverEntry.port());
}
else
{
if(!mPOPControl.openSocket()){message("unable to create socket.");return FALSE;}
internetSocketAddress.family(PF_INET);
internetSocketAddress.port(htons(POPPort));
}
if(!mPOPControl.connect(internetSocketAddress)){message("unable to connect to pop3 server");return FALSE;}
mPOPControl.getSocketName(internetSocketAddress);
if(!mPOPControl.isConnected())return FALSE;
// if(!mPOPControl.receive(responseLines)) //||!responseLines.size()||!
if(!mPOPControl.receive(responseLines)||!isInAckResponse(responseLines))
{
mPOPControl.closeSocket();
return FALSE;
}
return TRUE;
}
BOOL POPClient::quit(void)
{
Block<String> responseLines;
if(!isConnected())return FALSE;
isLoggedIn(FALSE);
if(!putControlData(mPOPCmds[Quit],FALSE))return FALSE;
mPOPControl.receive(responseLines);
mPOPControl.closeSocket();
return TRUE;
}
BOOL POPClient::authenticate(const String &user,const String &password)
{
Block<String> responseLines;
if(!isConnected())return FALSE;
if(!putControlData(mPOPCmds[User]+String(" ")+user,FALSE))return FALSE;
if(!mPOPControl.receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
if(!putControlData(mPOPCmds[Pass]+String(" ")+password,FALSE))return FALSE;
if(!mPOPControl.receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
isLoggedIn(TRUE);
return TRUE;
}
BOOL POPClient::stat(WORD &messages,WORD &octets)
{
Block<String> responseLines;
String strItem;
if(!isConnected()||!isLoggedIn())return FALSE;
if(!putControlData(mPOPCmds[Stat],FALSE))return FALSE;
if(!mPOPControl.receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
strItem=responseLines[0].betweenString(' ',' ');
messages=::atoi((char*)strItem);
strItem=responseLines[0].betweenString(' ',0);
strItem=strItem.betweenString(' ',0);
octets=::atoi((char*)strItem);
return TRUE;
}
BOOL POPClient::retrieve(WORD msgNum,Block<String> &messageLines)
{
Block<String> responseLines;
String strMsg;
if(!isConnected()||!isLoggedIn())return FALSE;
::sprintf(strMsg,"%d",msgNum);
if(!putControlData(mPOPCmds[Retr]+String(" ")+strMsg,FALSE))return FALSE;
if(!mPOPControl.receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
return TRUE;
}
void POPClient::createStats(void)
{
mPOPStatus.insert(&String("+OK"));
mPOPStatus.insert(&String("-ERR"));
}
void POPClient::createCmds(void)
{
mPOPCmds.remove();
mPOPCmds.insert(&String("QUIT"));
mPOPCmds.insert(&String("USER"));
mPOPCmds.insert(&String("PASS"));
mPOPCmds.insert(&String("STAT"));
mPOPCmds.insert(&String("RETR"));
}
WORD POPClient::putControlData(const String &stringData,WORD waitForResponse)
{
if(!mPOPControl.isConnected())return FALSE;
if(!mPOPControl.send(stringData))
{
mPOPControl.closeSocket();
String errorString(String("error sending '")+stringData+String("' to POP server."));
message(errorString);
errorString+="\n";
::OutputDebugString(errorString);
return FALSE;
}
if(waitForResponse&&!getControlData())
{
mPOPControl.closeSocket();
String errorString(String("error reading result of '")+stringData+String("' command from NNTP server."));
message(errorString);
errorString+="\n";
::OutputDebugString(errorString);
return FALSE;
}
return TRUE;
}
WORD POPClient::getControlData(void)
{
Block<String> responseStrings;
mPOPControl.receive(responseStrings);
return responseStrings.size();
}
BOOL POPClient::isInAckResponse(Block<String> &responseLines)
{
if(!responseLines.size())return FALSE;
if(responseLines[0].substr(0,2)==mPOPStatus[Ok])return TRUE;
return FALSE;
}
BOOL POPClient::isInNakResponse(Block<String> &responseLines)
{
if(!responseLines.size())return FALSE;
if(responseLines[0].substr(0,3)==mPOPStatus[Error])return TRUE;
return FALSE;
}
// virtuals
void POPClient::message(const String &messageString)
{
::OutputDebugString(messageString+String("\n"));
}
void POPClient::message(Block<String> &messageStrings)
{
for(int itemIndex=0;itemIndex<messageStrings.size();itemIndex++)
::OutputDebugString(messageStrings[itemIndex]+String("\n"));
}

38
pop/old/SRVRDLG.CPP Normal file
View File

@@ -0,0 +1,38 @@
#include <pop/srvrdlg.hpp>
#include <common/regkey.hpp>
WORD ServerDialog::performDialog(void)
{
::DialogBoxParam(processInstance(),(LPSTR)"ServerDialog",mhParent,(DLGPROC)DWindow::DlgProc,(LONG)((DWindow*)this));
return FALSE;
}
CallbackData::ReturnType ServerDialog::initDialogHandler(CallbackData &someCallbackData)
{
if(!mServerReg.serverName().isNull())setText(ServerName,mServerReg.serverName());
return (CallbackData::ReturnType)FALSE;
}
void ServerDialog::getServerName(void)
{
String serverName;
getText(ServerName,serverName);
if(serverName.isNull())return;
mServerReg.serverName(serverName);
}
CallbackData::ReturnType ServerDialog::commandHandler(CallbackData &someCallbackData)
{
switch(someCallbackData.wmCommandID())
{
case IDOK :
getServerName();
endDialog(TRUE);
break;
case IDCANCEL :
endDialog(TRUE);
break;
}
return (CallbackData::ReturnType)FALSE;
}

68
pop/old/Srvrdlg.hpp Normal file
View File

@@ -0,0 +1,68 @@
#ifndef _POP_SERVERDLG_HPP_
#define _POP_SERVERDLG_HPP_
#ifndef _COMMON_DWINDOW_HPP_
#include <common/dwindow.hpp>
#endif
#ifndef _COMMON_WINDOW_HPP_
#include <common/window.hpp>
#endif
#ifndef _POP_POP_HPP_
#include <pop/pop.hpp>
#endif
#ifndef _POP_SERVERREG_HPP_
#include <pop/srvrreg.hpp>
#endif
class String;
class ServerDialog : private DWindow
{
public:
ServerDialog(const GUIWindow &parentWindow);
virtual ~ServerDialog();
WORD performDialog(void);
private:
enum{ServerName=NS_SERVERNAME};
ServerDialog(const ServerDialog &someServerDialog);
ServerDialog &operator=(const ServerDialog &someServerDialog);
CallbackData::ReturnType initDialogHandler(CallbackData &someCallbackData);
CallbackData::ReturnType commandHandler(CallbackData &someCallbackData);
void getServerName(void);
Callback<ServerDialog> mInitDialogHandler;
Callback<ServerDialog> mCommandHandler;
ServerReg mServerReg;
HWND mhParent;
};
inline
ServerDialog::ServerDialog(const GUIWindow &parentWindow)
: mhParent(parentWindow)
{
mInitDialogHandler.setCallback(this,&ServerDialog::initDialogHandler);
mCommandHandler.setCallback(this,&ServerDialog::commandHandler);
insertHandler(VectorHandler::CommandHandler,&mCommandHandler);
insertHandler(VectorHandler::InitDialogHandler,&mInitDialogHandler);
}
inline
ServerDialog::ServerDialog(const ServerDialog &someServerDialog)
: mhParent(someServerDialog.mhParent)
{ // no implementation
mInitDialogHandler.setCallback(this,&ServerDialog::initDialogHandler);
mCommandHandler.setCallback(this,&ServerDialog::commandHandler);
}
inline
ServerDialog::~ServerDialog()
{
removeHandler(VectorHandler::CommandHandler,&mCommandHandler);
removeHandler(VectorHandler::InitDialogHandler,&mInitDialogHandler);
}
inline
ServerDialog &ServerDialog::operator=(const ServerDialog &/*someServerDialog*/)
{ // no implementation
return *this;
}
#endif

46
pop/old/mail.hpp Normal file
View File

@@ -0,0 +1,46 @@
#ifndef _POP_MAILMESSAGE_HPP_
#define _POP_MAILMESSAGE_HPP_
#ifndef _POP_HEADER_HPP_
#include <pop/header.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
class Mail : public Block<String>, public Header
{
public:
Mail(void);
Mail(Block<String> &msgLines);
virtual ~Mail();
Mail &operator=(Block<String> &msgLines);
private:
};
inline
Mail::Mail(void)
{
}
inline
Mail::Mail(Block<String> &msgLines)
: Block<String>(msgLines), Header(msgLines)
{
}
inline
Mail::~Mail()
{
}
inline
Mail &Mail::operator=(Block<String> &msgLines)
{
(Block<String>&)*this=msgLines;
(Header&)*this=msgLines;
return *this;
}
#endif

4
pop/old/pop.hpp Normal file
View File

@@ -0,0 +1,4 @@
#ifndef _POP_POP_HPP_
#define _POP_POP_HPP_
#include <pop/pop.h>
#endif

263
pop/old/popclnt.Cpp Normal file
View File

@@ -0,0 +1,263 @@
#include <pop/popclnt.hpp>
#include <socket/hostent.hpp>
#include <socket/servent.hpp>
POPClient::POPClient(void)
: mSpace(" "), mIsLoggedIn(FALSE)
{
createCmds();
createStats();
}
POPClient::~POPClient()
{
}
BOOL POPClient::open(const String &hostName)
{
HostEnt hostEntry;
ServEnt serverEntry;
Block<String> responseLines;
INETSocketAddress internetSocketAddress;
if(hostName.isNull())return FALSE;
if(mPOPControl.isConnected())mPOPControl.closeSocket();
message(String("trying ")+hostName+String("..."));
if(!mWSASystem.isInitialized()){message("WINSOCK initialization failure.");return FALSE;}
InternetAddress internetAddress(hostName);
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){return FALSE;}}
else if(!hostEntry.hostByName(hostName)){return FALSE;}
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){message(String("no DNS entry for ")+hostName);return FALSE;}}
else if(!hostEntry.hostByName(hostName)){message(String("no DNS entry for ")+hostName);return FALSE;}
message(String("connect...")+String("'")+hostEntry.hostName()+String("' (")+(String)(hostEntry.addresses())[0]+String(")"));
internetSocketAddress.internetAddress((hostEntry.addresses())[0]);
if(serverEntry.serviceByName("pop3","tcp"))
{
if(!mPOPControl.openSocket()){message("unable to create socket.");return FALSE;}
internetSocketAddress.family(PF_INET);
internetSocketAddress.port(serverEntry.port());
}
else
{
if(!mPOPControl.openSocket()){message("unable to create socket.");return FALSE;}
internetSocketAddress.family(PF_INET);
internetSocketAddress.port(htons(POPPort));
}
if(!mPOPControl.connect(internetSocketAddress)){message("unable to connect to pop3 server");return FALSE;}
mPOPControl.getSocketName(internetSocketAddress);
if(!mPOPControl.isConnected())return FALSE;
if(!receive(responseLines)||!isInAckResponse(responseLines))
{
mPOPControl.closeSocket();
return FALSE;
}
return TRUE;
}
BOOL POPClient::quit(void)
{
Block<String> responseLines;
if(!isConnected())return FALSE;
isLoggedIn(FALSE);
if(!putControlData(mPOPCmds[Quit],FALSE))return FALSE;
receive(responseLines);
mPOPControl.closeSocket();
return TRUE;
}
BOOL POPClient::authenticate(const String &user,const String &password)
{
Block<String> responseLines;
if(!isConnected())return FALSE;
if(!putControlData(mPOPCmds[User]+String(" ")+user,FALSE))return FALSE;
if(!receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
if(!putControlData(mPOPCmds[Pass]+String(" ")+password,FALSE))return FALSE;
if(!receive(responseLines))return FALSE;
isLoggedIn(TRUE);
return TRUE;
}
BOOL POPClient::stat(WORD &messages,WORD &octets)
{
Block<String> responseLines;
String strItem;
if(!isConnected()||!isLoggedIn())return FALSE;
if(!putControlData(mPOPCmds[Stat],FALSE))return FALSE;
if(!receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
strItem=responseLines[0].betweenString(' ',' ');
messages=::atoi((char*)strItem);
strItem=responseLines[0].betweenString(' ',0);
strItem=strItem.betweenString(' ',0);
octets=::atoi((char*)strItem);
return TRUE;
}
BOOL POPClient::retrieve(WORD msgNum,Block<String> &messageLines)
{
Block<String> responseLines;
String strMsg;
messageLines.remove();
if(!isConnected()||!isLoggedIn())return FALSE;
::sprintf(strMsg,"%d",msgNum);
if(!putControlData(mPOPCmds[Retr]+String(" ")+strMsg,FALSE))return FALSE;
if(!receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
receiveLines(messageLines);
return TRUE;
}
BOOL POPClient::dele(WORD msgNum)
{
Block<String> responseLines;
String strMsg;
if(!isConnected()||!isLoggedIn())return FALSE;
::sprintf(strMsg,"%d",msgNum);
if(!putControlData(mPOPCmds[Dele]+String(" ")+strMsg,FALSE))return FALSE;
if(!receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
return TRUE;
}
BOOL POPClient::noop(void)
{
Block<String> responseLines;
if(!isConnected()||!isLoggedIn())return FALSE;
if(!putControlData(mPOPCmds[Noop],FALSE))return FALSE;
if(!receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
return TRUE;
}
BOOL POPClient::rset(void)
{
Block<String> responseLines;
if(!isConnected()||!isLoggedIn())return FALSE;
if(!putControlData(mPOPCmds[Rset],FALSE))return FALSE;
if(!receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
return TRUE;
}
BOOL POPClient::top(Block<String> &msgLines,WORD msgNum,WORD lineCount)
{
Block<String> responseLines;
String strMsg;
if(!isConnected()||!isLoggedIn())return FALSE;
::sprintf(strMsg,"%d %d",msgNum,lineCount);
if(!putControlData(mPOPCmds[Top]+String(" ")+strMsg,FALSE))return FALSE;
if(!receive(responseLines))return FALSE;
if(!isInAckResponse(responseLines))return FALSE;
if(!receiveLines(msgLines))return FALSE;
return TRUE;
}
void POPClient::createStats(void)
{
mPOPStatus.insert(&String("+OK"));
mPOPStatus.insert(&String("-ERR"));
}
void POPClient::createCmds(void)
{
mPOPCmds.remove();
mPOPCmds.insert(&String("QUIT"));
mPOPCmds.insert(&String("USER"));
mPOPCmds.insert(&String("PASS"));
mPOPCmds.insert(&String("STAT"));
mPOPCmds.insert(&String("RETR"));
mPOPCmds.insert(&String("RSET"));
mPOPCmds.insert(&String("DELE"));
mPOPCmds.insert(&String("NOOP"));
mPOPCmds.insert(&String("TOP"));
}
WORD POPClient::putControlData(const String &stringData,WORD waitForResponse)
{
if(!mPOPControl.isConnected())return FALSE;
if(!mPOPControl.send(stringData))
{
mPOPControl.closeSocket();
String errorString(String("error sending '")+stringData+String("' to POP server."));
message(errorString);
errorString+="\n";
::OutputDebugString(errorString);
return FALSE;
}
if(waitForResponse&&!getControlData())
{
mPOPControl.closeSocket();
String errorString(String("error reading result of '")+stringData+String("' command from NNTP server."));
message(errorString);
errorString+="\n";
::OutputDebugString(errorString);
return FALSE;
}
return TRUE;
}
WORD POPClient::getControlData(void)
{
Block<String> responseStrings;
mPOPControl.receive(responseStrings);
return responseStrings.size();
}
BOOL POPClient::isInAckResponse(Block<String> &responseLines)
{
if(!responseLines.size())return FALSE;
if(responseLines[0].substr(0,2)==mPOPStatus[Ok])return TRUE;
return FALSE;
}
BOOL POPClient::isInNakResponse(Block<String> &responseLines)
{
if(!responseLines.size())return FALSE;
if(responseLines[0].substr(0,3)==mPOPStatus[Error])return TRUE;
return FALSE;
}
BOOL POPClient::receive(Block<String> &responseLines)
{
if(!mPOPControl.receive(responseLines))return FALSE;
// message(responseLines);
return TRUE;
}
BOOL POPClient::receiveLines(Block<String> &receiveStrings)
{
String stringData;
String seriesItem;
receiveStrings.remove();
while(TRUE)
{
if(!mPOPControl.receive(stringData))break;
if(stringData==String("."))break;
if(stringData==String(".."))stringData=".";
receiveStrings.insert(&stringData);
if(!isConnected())break;
}
return TRUE;
}
// virtuals
void POPClient::message(const String &messageString)
{
::OutputDebugString(messageString+String("\n"));
}
void POPClient::message(Block<String> &messageStrings)
{
for(int itemIndex=0;itemIndex<messageStrings.size();itemIndex++)
::OutputDebugString(messageStrings[itemIndex]+String("\n"));
}

83
pop/old/popclnt.Hpp Normal file
View File

@@ -0,0 +1,83 @@
#ifndef _POP_POPCLIENT_HPP_
#define _POP_POPCLIENT_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _SOCKET_SOCKET_HPP_
#include <socket/socket.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
class String;
class POPClient
{
public:
POPClient(void);
virtual ~POPClient();
BOOL open(const String &hostName);
void close(void);
BOOL isConnected(void)const;
BOOL isLoggedIn(void)const;
BOOL quit(void);
BOOL authenticate(const String &user,const String &password);
BOOL retrieve(WORD msgNum,Block<String> &messageLines);
BOOL top(Block<String> &messageLines,WORD msgNum,WORD lineCount=10);
BOOL dele(WORD msgNum);
BOOL rset(void);
BOOL noop(void);
BOOL stat(WORD &messages,WORD &octets);
protected:
virtual void message(const String &messageString);
virtual void message(Block<String> &messageStrings);
private:
enum {POPPort=110};
enum POPCmds{Quit,User,Pass,Stat,Retr,Rset,Dele,Noop,Top};
enum POPStatus{Ok,Error};
POPClient(const POPClient &somePOPClient);
POPClient &operator=(const POPClient &somePOPClient);
void isLoggedIn(BOOL isLoggedIn);
WORD putControlData(const String &stringData,WORD waitForResponse=TRUE);
BOOL isInNakResponse(Block<String> &responseLines);
BOOL isInAckResponse(Block<String> &responseLines);
BOOL receive(Block<String> &responseLines);
BOOL receiveLines(Block<String> &receiveStrings);
WORD getControlData(void);
void createCmds(void);
void createStats(void);
Socket mPOPControl;
WSASystem mWSASystem;
Block<String> mPOPCmds;
Block<String> mPOPStatus;
BOOL mIsLoggedIn;
String mSpace;
};
inline
BOOL POPClient::isConnected(void)const
{
return mPOPControl.isConnected();
}
inline
BOOL POPClient::isLoggedIn(void)const
{
return mIsLoggedIn;
}
inline
void POPClient::isLoggedIn(BOOL isLoggedIn)
{
mIsLoggedIn=isLoggedIn;
}
inline
void POPClient::close(void)
{
mPOPControl.closeSocket();
isLoggedIn(FALSE);
}
#endif

241
pop/old/popdlg.cpp Normal file
View File

@@ -0,0 +1,241 @@
#include <pop/popdlg.hpp>
#include <pop/srvrdlg.hpp>
#include <pop/popclnt.hpp>
#include <pop/srvrreg.hpp>
#include <pop/logindlg.hpp>
#include <pop/header.hpp>
#include <pop/mail.hpp>
#include <common/systime.hpp>
#include <common/opendlg.hpp>
#include <statbar/statbar.hpp>
#include <imagelst/ftree.hpp>
POPDlg::POPDlg(void)
{
mInitHandler.setCallback(this,&POPDlg::initHandler);
mDestroyHandler.setCallback(this,&POPDlg::destroyHandler);
mCommandHandler.setCallback(this,&POPDlg::commandHandler);
mCloseHandler.setCallback(this,&POPDlg::closeHandler);
mDlgCodeHandler.setCallback(this,&POPDlg::dlgCodeHandler);
mMailSelChangedHandler.setCallback(this,&POPDlg::mailSelChangedHandler);
DWindow::insertHandler(VectorHandler::InitDialogHandler,&mInitHandler);
DWindow::insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
DWindow::insertHandler(VectorHandler::CommandHandler,&mCommandHandler);
DWindow::insertHandler(VectorHandler::CloseHandler,&mCloseHandler);
DWindow::insertHandler(VectorHandler::DialogCodeHandler,&mDlgCodeHandler);
}
POPDlg::~POPDlg()
{
DWindow::removeHandler(VectorHandler::InitDialogHandler,&mInitHandler);
DWindow::removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
DWindow::removeHandler(VectorHandler::CommandHandler,&mCommandHandler);
DWindow::removeHandler(VectorHandler::CloseHandler,&mCloseHandler);
DWindow::insertHandler(VectorHandler::DialogCodeHandler,&mDlgCodeHandler);
}
POPDlg &POPDlg::operator=(const POPDlg &/*somePOPDlg*/)
{ // private implementation
return *this;
}
BOOL POPDlg::perform(void)
{
return ::DialogBoxParam(processInstance(),(LPSTR)"POPCLIENT",(HWND)0,DWindow::DlgProc,(LPARAM)(DWindow*)this);
}
CallbackData::ReturnType POPDlg::initHandler(CallbackData &/*someCallbackData*/)
{
mStatusBar=new StatusBar(*this);
mFolderTree=new FolderTree(*this,Rect(xFolder,yFolder,cxFolder,cyFolder));
mMailTree=new FolderTree(*this,Rect(xMail,yMail,cxMail,cyMail));
mMailTree->insertHandler(FolderTree::SelChangedHandler,&mMailSelChangedHandler);
mStatusBar.disposition(PointerDisposition::Delete);
// getMail();
// retrieveMail();
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType POPDlg::destroyHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType POPDlg::dlgCodeHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)DLGC_WANTARROWS|DLGC_WANTCHARS;
}
CallbackData::ReturnType POPDlg::commandHandler(CallbackData &someCallbackData)
{
switch(someCallbackData.wmCommandID())
{
case IDOK :
break;
case IDCANCEL :
endDialog(FALSE);
break;
case Server :
handleServer(someCallbackData);
break;
case GetMail :
getMail();
break;
}
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType POPDlg::closeHandler(CallbackData &/*someCallbackData*/)
{
return (CallbackData::ReturnType)FALSE;
}
CallbackData::ReturnType POPDlg::mailSelChangedHandler(CallbackData &someCallbackData)
{
setDisplay(someCallbackData.loWord());
return (CallbackData::ReturnType)FALSE;
}
void POPDlg::handleServer(CallbackData &someCallbackData)
{
ServerDialog serverDialog(*this);
serverDialog.performDialog();
}
void POPDlg::getMail(void)
{
retrieveMail();
populateMail();
populateFolders();
}
void POPDlg::retrieveMail(void)
{
mMailBlock.remove();
for(int itemIndex=0;itemIndex<20;itemIndex++)
{
Block<String> mailBlock;
mailBlock.insert(&String("From: Sean Kessler<europa@li.net>"));
mailBlock.insert(&String(" "));
mailBlock.insert(&String("Sean Kessler wrote:"));
mailBlock.insert(&String("hello"));
mMailBlock.insert(&Mail(mailBlock));
}
}
#if 0
void POPDlg::retrieveMail(void)
{
POPClient popClient;
ServerReg serverReg;
WORD messages;
WORD octets;
mMailBlock.remove();
if(!handleLoginParams(serverReg)){userMessage("Incorrect Login.");return;}
if(!popClient.open(serverReg.serverName())){userMessage("Connect Failed..");return;}
if(!popClient.authenticate(serverReg.userName(),serverReg.password()))
{
popClient.quit();
popClient.close();
userMessage("Authentication Failed.");
return;
}
popClient.stat(messages,octets);
if(!messages){userMessage("No Messages.");return;}
for(int msgIndex=1;msgIndex<=messages;msgIndex++)
{
mMailBlock.insert(&Mail());
Block<String> &msgLines=mMailBlock[mMailBlock.size()-1];
Header &mailHeader=mMailBlock[mMailBlock.size()-1];
popClient.retrieve(msgIndex,msgLines);
mailHeader=msgLines;
if(!msgLines.size())continue;
}
popClient.quit();
popClient.close();
}
#endif
BOOL POPDlg::handleLoginParams(ServerReg &serverReg)
{
if(serverReg.serverName().isNull()){::MessageBox(*this,(LPSTR)"No Server Defined",(LPSTR)"SERVER ERROR",MB_ICONSTOP);return FALSE;}
if(serverReg.userName().isNull()||serverReg.password().isNull())
{
String userName;
String password;
LoginDialog loginDialog;
if(!loginDialog.performLogin())return FALSE;
userName=loginDialog.userName();
password=loginDialog.password();
serverReg.userName(userName);
serverReg.password(password);
}
if(serverReg.userName().isNull()||serverReg.password().isNull())return FALSE;
return TRUE;
}
void POPDlg::populateMail(void)
{
String strMailBox(STRING_MAILBOXNAME);
mMailTree->setRedraw(FALSE);
mMailTree->remove();
mMailTree->addRootNode(FolderTree::FolderClosed,strMailBox,makeItemID(NullNode,RootID));
for(int itemIndex=0;itemIndex<mMailBlock.size();itemIndex++)
{
TreeViewItem insertItem(0,0,0,0,(LPSTR)mMailBlock[itemIndex].from(),mMailBlock[itemIndex].from().length(),FolderTree::FolderClosed,FolderTree::FolderOpen,0,makeItemID(MailNode,itemIndex));
mMailTree->addNode(TreeView::NodeChild,insertItem,strMailBox);
}
mMailTree->setRedraw(TRUE);
}
void POPDlg::populateFolders(void)
{
String strUserFolder(STRING_USERFOLDERNAME);
mFolderTree->setRedraw(FALSE);
mFolderTree->remove();
mFolderTree->addRootNode(FolderTree::FolderClosed,strUserFolder,makeItemID(NullNode,RootID));
mFolderTree->setRedraw(TRUE);
}
void POPDlg::setDisplay(int itemID)
{
String lineItem;
Block<String> &mailList=mMailBlock[itemID];
for(int itemIndex=0;itemIndex<mailList.size();itemIndex++)
{
lineItem=mailList[itemIndex];
lineItem+="\n";
}
setText(EditControl,(LPSTR)lineItem);
}
void POPDlg::userMessage(const String &message)
{
::MessageBox(*this,(LPSTR)(String&)message,(LPSTR)"POPClient",MB_OK);
}
// **************** virtuals
void POPDlg::message(const String &messageString)
{
if(!mStatusBar.isOkay())return;
mStatusBar->setText(messageString);
}
void POPDlg::message(Block<String> &messageStrings)
{
if(!mStatusBar.isOkay())return;
for(int lineIndex=0;lineIndex<messageStrings.size();lineIndex++)
mStatusBar->setText(messageStrings[lineIndex]);
}

69
pop/old/popdlg.hpp Normal file
View File

@@ -0,0 +1,69 @@
#ifndef _POP_POPDLG_HPP_
#define _POP_POPDLG_HPP_
#ifndef _COMMON_DWINDOW_HPP_
#include <common/dwindow.hpp>
#endif
#ifndef _COMMON_SMARTPOINTER_HPP_
#include <common/pointer.hpp>
#endif
#ifndef _POP_POP_HPP_
#include <pop/pop.hpp>
#endif
class StatusBar;
class FolderTree;
class ServerReg;
class Mail;
class POPDlg : public DWindow
{
public:
POPDlg(void);
virtual ~POPDlg();
BOOL perform(void);
protected:
virtual void message(const String &messageString);
virtual void message(Block<String> &messageStrings);
private:
enum DlgControls{Server=PC_SERVER,GetMail=PC_GETMAIL,EditControl=PC_EDIT};
enum FolderCoords{xFolder=5,yFolder=50,cxFolder=235,cyFolder=150};
enum MailCoords{xMail=245,yMail=50,cxMail=235,cyMail=150};
enum {RootID=0};
enum NodeType{NullNode=0x0000,MailNode=0x0001};
POPDlg &operator=(const POPDlg &someMailDlg);
CallbackData::ReturnType initHandler(CallbackData &someCallbackData);
CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData);
CallbackData::ReturnType commandHandler(CallbackData &someCallbackData);
CallbackData::ReturnType closeHandler(CallbackData &someCallbackData);
CallbackData::ReturnType dlgCodeHandler(CallbackData &someCallbackData);
CallbackData::ReturnType mailSelChangedHandler(CallbackData &someCallbackData);
void handleServer(CallbackData &someCallbackData);
void userMessage(const String &message);
void retrieveMail(void);
void populateFolders(void);
void populateMail(void);
void getMail(void);
void setDisplay(int itemID);
BOOL handleLoginParams(ServerReg &serverReg);
LPARAM makeItemID(NodeType nodeType,WORD itemID);
Callback<POPDlg> mInitHandler;
Callback<POPDlg> mDestroyHandler;
Callback<POPDlg> mCommandHandler;
Callback<POPDlg> mCloseHandler;
Callback<POPDlg> mDlgCodeHandler;
Callback<POPDlg> mMailSelChangedHandler;
SmartPointer<StatusBar> mStatusBar;
SmartPointer<FolderTree> mFolderTree;
SmartPointer<FolderTree> mMailTree;
Block<Mail> mMailBlock;
};
inline
LPARAM POPDlg::makeItemID(NodeType nodeType,WORD itemID)
{
return MAKELPARAM(itemID,nodeType);
}
#endif

142
pop/old/srvrreg.hpp Normal file
View File

@@ -0,0 +1,142 @@
#ifndef _POP_SERVERREG_HPP_
#define _POP_SERVERREG_HPP_
#ifndef _COMMON_WINDOWS_HPP_
#include <common/windows.hpp>
#endif
#ifndef _COMMON_REGKEY_HPP_
#include <common/regkey.hpp>
#endif
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_DISKINFO_HPP_
#include <common/diskinfo.hpp>
#endif
#ifndef _POP_POP_HPP_
#include <pop/pop.hpp>
#endif
class ServerReg
{
public:
ServerReg(void);
ServerReg(const ServerReg &someServerReg);
virtual ~ServerReg();
ServerReg &operator=(const ServerReg &someServerReg);
const String &serverName(void)const;
void serverName(const String &hostName);
const String &userName(void)const;
void userName(const String &userName);
const String &password(void)const;
void password(const String &password);
const String &mailDir(void)const;
void mailDir(const String &mailDirectory);
private:
RegKey mRegKey;
String mServerName;
String mMailDir;
String mUserName;
String mPassword;
String mRegEntryKey;
String mServerNameKey;
String mMailDirKey;
String mUserNameKey;
String mPasswordKey;
};
inline
ServerReg::ServerReg(void)
: mRegKey(RegKey::CurrentUser), mRegEntryKey(STRING_REGENTRYKEY),
mServerNameKey(STRING_SERVERNAMEKEY), mMailDirKey(STRING_MAILDIRKEY),
mUserNameKey(STRING_USERNAMEKEY), mPasswordKey(STRING_PASSWORDKEY)
{
if(!mRegKey.openKey(mRegEntryKey))
{
mRegKey.createKey(mRegEntryKey,"");
mRegKey.openKey(mRegEntryKey);
}
mRegKey.queryValue(mMailDirKey,mMailDir);
if(mMailDir.isNull())
{
DiskInfo diskInfo;
diskInfo.getCurrentDirectory(mMailDir);
mRegKey.setValue(mMailDirKey,mMailDir);
}
mRegKey.queryValue(mServerNameKey,mServerName);
mRegKey.queryValue(mUserNameKey,mUserName);
mRegKey.queryValue(mPasswordKey,mPassword);
}
inline
ServerReg::ServerReg(const ServerReg &someServerReg)
: mRegKey(RegKey::CurrentUser), mRegEntryKey(STRING_REGENTRYKEY),
mServerNameKey(STRING_SERVERNAMEKEY), mMailDirKey(STRING_MAILDIRKEY),
mUserNameKey(STRING_USERNAMEKEY), mPasswordKey(STRING_PASSWORDKEY)
{
*this=someServerReg;
}
inline
ServerReg::~ServerReg()
{
}
inline
ServerReg &ServerReg::operator=(const ServerReg &someServerReg)
{
return *this;
}
inline
const String &ServerReg::serverName(void)const
{
return mServerName;
}
inline
void ServerReg::serverName(const String &serverName)
{
mServerName=serverName;
mRegKey.setValue(mServerNameKey,mServerName);
}
inline
const String &ServerReg::mailDir(void)const
{
return mMailDir;
}
inline
void ServerReg::mailDir(const String &mailDir)
{
mMailDir=mailDir;
mRegKey.setValue(mMailDirKey,mMailDir);
}
inline
const String &ServerReg::userName(void)const
{
return mUserName;
}
inline
void ServerReg::userName(const String &userName)
{
mUserName=userName;
mRegKey.setValue(mUserNameKey,mUserName);
}
inline
const String &ServerReg::password(void)const
{
return mPassword;
}
inline
void ServerReg::password(const String &password)
{
mPassword=password;
mRegKey.setValue(mPasswordKey,mPassword);
}
#endif