130 lines
3.5 KiB
C++
130 lines
3.5 KiB
C++
#include <nntp/rasdlg.hpp>
|
|
#include <nntp/rasiface.hpp>
|
|
|
|
WORD RasDialog::performDialog(void)
|
|
{
|
|
::DialogBoxParam(processInstance(),(LPSTR)"RasDialog",mhParent,(DLGPROC)DWindow::DlgProc,(LONG)((DWindow*)this));
|
|
return FALSE;
|
|
}
|
|
|
|
CallbackData::ReturnType RasDialog::initDialogHandler(CallbackData &someCallbackData)
|
|
{
|
|
queryRasSettings();
|
|
queryRasEntryNames();
|
|
return (CallbackData::ReturnType)FALSE;
|
|
}
|
|
|
|
CallbackData::ReturnType RasDialog::commandHandler(CallbackData &someCallbackData)
|
|
{
|
|
switch(someCallbackData.wmCommandID())
|
|
{
|
|
case IDOK :
|
|
if(handleAccept())endDialog(TRUE);
|
|
break;
|
|
case IDCANCEL :
|
|
endDialog(TRUE);
|
|
break;
|
|
case RasEnable :
|
|
handleRasEnableEvent();
|
|
case RasList :
|
|
handleRasListEvent();
|
|
break;
|
|
}
|
|
return (CallbackData::ReturnType)FALSE;
|
|
}
|
|
|
|
void RasDialog::handleRasListEvent(void)
|
|
{
|
|
LONG itemIndex;
|
|
String selString;
|
|
|
|
itemIndex=sendMessage(RasList,LB_GETCURSEL,0,0L);
|
|
if(LB_ERR==itemIndex)return;
|
|
sendMessage(RasList,LB_GETTEXT,(WPARAM)itemIndex,(LPARAM)(LPCSTR)(LPSTR)selString);
|
|
setText(RasEntry,selString);
|
|
}
|
|
|
|
void RasDialog::handleRasEnableEvent(void)
|
|
{
|
|
if(sendMessage(RasEnable,BM_GETCHECK,0,0L))
|
|
{
|
|
RasInterface rasInterface;
|
|
if(!rasInterface.isOkay())
|
|
{
|
|
showRasError();
|
|
sendMessage(RasEnable,BM_SETCHECK,FALSE,0L);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
void RasDialog::queryRasSettings(void)
|
|
{
|
|
if(!mRasOptions.rasUserName().isNull())setText(RasUserName,mRasOptions.rasUserName());
|
|
if(!mRasOptions.rasPassword().isNull())setText(RasPassword,mRasOptions.rasPassword());
|
|
if(!mRasOptions.rasEntryName().isNull())setText(RasEntry,mRasOptions.rasEntryName());
|
|
setInt(RasMaxRetries,mRasOptions.rasMaxRetries());
|
|
if(mRasOptions.rasState())
|
|
{
|
|
if(!isRasOkay())
|
|
{
|
|
sendMessage(RasEnable,BM_SETCHECK,FALSE,0L);
|
|
mRasOptions.rasState(FALSE);
|
|
showRasError();
|
|
}
|
|
else sendMessage(RasEnable,BM_SETCHECK,TRUE,0L);
|
|
}
|
|
}
|
|
|
|
WORD RasDialog::handleAccept(void)
|
|
{
|
|
String rasUserName;
|
|
String rasPassword;
|
|
String rasEntryName;
|
|
int rasMaxRetries;
|
|
DWORD rasState;
|
|
|
|
getText(RasUserName,rasUserName);
|
|
getText(RasPassword,rasPassword);
|
|
getText(RasEntry,rasEntryName);
|
|
getInt(RasMaxRetries,rasMaxRetries);
|
|
rasState=sendMessage(RasEnable,BM_GETCHECK,0,0L);
|
|
if(rasUserName.isNull()){::MessageBox(*this,(LPSTR)"UserName is a requred entry.",(LPSTR)"Error",MB_ICONHAND);return FALSE;}
|
|
if(rasPassword.isNull()){::MessageBox(*this,(LPSTR)"Password is a requred entry.",(LPSTR)"Error",MB_ICONHAND);return FALSE;}
|
|
mRasOptions.rasUserName(rasUserName);
|
|
mRasOptions.rasPassword(rasPassword);
|
|
mRasOptions.rasEntryName(rasEntryName);
|
|
mRasOptions.rasState(rasState);
|
|
mRasOptions.rasMaxRetries(rasMaxRetries);
|
|
return TRUE;
|
|
}
|
|
|
|
void RasDialog::queryRasEntryNames(void)
|
|
{
|
|
RasInterface rasInterface;
|
|
Block<RasEntryName> rasEntryNames;
|
|
|
|
if(!rasInterface.isOkay())return;
|
|
sendMessage(RasList,WM_SETREDRAW,0,0L);
|
|
sendMessage(RasList,LB_RESETCONTENT,0,0L);
|
|
rasInterface.enumEntries(rasEntryNames);
|
|
if(!rasEntryNames.size())return;
|
|
for(int itemIndex=0;itemIndex<rasEntryNames.size();itemIndex++)
|
|
sendMessage(RasList,LB_INSERTSTRING,(WPARAM)-1,(LPARAM)(LPSTR)rasEntryNames[itemIndex].entryName());
|
|
sendMessage(RasList,WM_SETREDRAW,TRUE,0L);
|
|
setCurrentEntry(mRasOptions.rasEntryName());
|
|
}
|
|
|
|
void RasDialog::setCurrentEntry(const String &rasEntryName)
|
|
{
|
|
sendMessage(RasList,LB_SELECTSTRING,(WPARAM)0,(LPARAM)(LPCSTR)(LPSTR)rasEntryName);
|
|
setText(RasEntry,rasEntryName);
|
|
}
|
|
|
|
WORD RasDialog::isRasOkay(void)const
|
|
{
|
|
RasInterface rasInterface;
|
|
return rasInterface.isOkay();
|
|
}
|
|
|