/****************************************************************/
/* */
/* ApplicationDlg.cpp */
/* */
/* Implementation of the CApplicationDlg class. */
/* This class is a part of the FTP Server. */
/* */
/* Programmed by Pablo van der Meer */
/* Copyright Pablo Software Solutions 2002 */
/* http://www.pablovandermeer.nl */
/* */
/* Last updated: 10 july 2002 */
/* */
/****************************************************************/
#include "stdafx.h"
#include "FTPServerApp.h"
#include "FTPServer.h"
#include "ApplicationDlg.h"
#include "UserAccountsDlg.h"
#include "WizardPages.h"
#include "AboutDlg.h"
#include <afxpriv.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CFTPServerApp theApp;
extern CFTPServer theServer;
static UINT auIDStatusBar[] =
{
ID_SEPARATOR,
ID_INDICATOR_DATA_RECEIVED,
ID_INDICATOR_DATA_SEND,
ID_INDICATOR_ONLINELED,
ID_INDICATOR_OFFLINELED
};
/********************************************************************/
/* */
/* Function name : CApplicationDlg::CApplicationDlg */
/* Description : Constructor */
/* */
/********************************************************************/
CApplicationDlg::CApplicationDlg(CWnd* pParent /*=NULL*/)
: CDialogResize(CApplicationDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CApplicationDlg)
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDI_FTPSERVER);
m_bInitialized = FALSE;
}
/********************************************************************/
/* */
/* Function name : CApplicationDlg::~CApplicationDlg */
/* Description : Destructor */
/* */
/********************************************************************/
CApplicationDlg::~CApplicationDlg()
{
}
/********************************************************************/
/* */
/* Function name : CApplicationDlg::DoDataExchange */
/* Description : Called by the framework to exchange and validate */
/* dialog data. */
/* */
/********************************************************************/
void CApplicationDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogResize::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CApplicationDlg)
DDX_Control(pDX, IDC_INFOBAR, m_InfobarCtrl);
DDX_Control(pDX, IDC_OUTLOOKBAR, m_OutlookBar);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CApplicationDlg, CDialogResize)
//{{AFX_MSG_MAP(CApplicationDlg)
ON_WM_SYSCOMMAND()
ON_WM_SIZE()
ON_WM_DESTROY()
ON_COMMAND(ID_SERVER_START, OnServerStart)
ON_UPDATE_COMMAND_UI(ID_SERVER_START, OnUpdateServerStart)
ON_COMMAND(ID_SERVER_STOP, OnServerStop)
ON_UPDATE_COMMAND_UI(ID_SERVER_STOP, OnUpdateServerStop)
ON_COMMAND(ID_SERVER_EXIT, OnServerExit)
ON_NOTIFY(NM_CLICK, IDC_OUTLOOKBAR, OnClickOutlookBar)
ON_NOTIFY(LVN_KEYDOWN, IDC_OUTLOOKBAR, OnKeydownOutlookBar)
ON_COMMAND(ID_USER_ACCOUNTS, OnUserAccounts)
ON_WM_CLOSE()
ON_COMMAND(IDC_VIEW_TRACE, OnViewTrace)
ON_COMMAND(IDC_VIEW_ONLINE_USERS, OnViewOnlineUsers)
ON_COMMAND(IDC_VIEW_CONFIGURATION, OnViewConfiguration)
ON_UPDATE_COMMAND_UI(IDC_VIEW_TRACE, OnUpdateViewTrace)
ON_UPDATE_COMMAND_UI(IDC_VIEW_ONLINE_USERS, OnUpdateViewOnlineUsers)
ON_UPDATE_COMMAND_UI(IDC_VIEW_CONFIGURATION, OnUpdateViewConfiguration)
ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
ON_COMMAND(IDC_VIEW_STATISTICS, OnViewStatistics)
ON_UPDATE_COMMAND_UI(IDC_VIEW_STATISTICS, OnUpdateViewStatistics)
ON_COMMAND(IDC_VIEW_SECURITY, OnViewSecurity)
ON_UPDATE_COMMAND_UI(IDC_VIEW_SECURITY, OnUpdateViewSecurity)
ON_COMMAND(ID_ACCOUNT_WIZARD, OnAccountWizard)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
ON_COMMAND(IDC_APPLY, OnApply)
END_MESSAGE_MAP()
BEGIN_DLGRESIZE_MAP(CApplicationDlg)
DLGRESIZE_CONTROL(IDC_OUTLOOKBAR, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_DIALOG_AREA, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(AFX_IDW_STATUS_BAR, DLSZ_MOVE_Y | DLSZ_SIZE_X)
DLGRESIZE_CONTROL(AFX_IDW_TOOLBAR, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_STATIC1, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_INFOBAR, DLSZ_SIZE_X)
END_DLGRESIZE_MAP()
/********************************************************************/
/* */
/* Function name : CApplicationDlg::OnInitDialog */
/* Description : Called by the framework in response to the */
/* WM_INITDIALOG message. */
/* */
/********************************************************************/
BOOL CApplicationDlg::OnInitDialog()
{
CDialogResize::OnInitDialog();
// setup listview ctrl, so that it looks like the outbar control
SetupOutlookBar();
// Add statusbar to the dialog
CreateStatusbar();
CRect rect;
GetDlgItem(IDC_STATIC1)->GetWindowRect(rect);
ScreenToClient(rect);
rect.right+=4;
GetDlgItem(IDC_STATIC1)->MoveWindow(rect);
InitResizing(FALSE);
int s, t, b, r, l;
if (AfxGetApp()->GetProfileInt("Settings", "SavePosition", 1))
{
// only restore if there is a previously saved position
if ( -1 != (s = AfxGetApp()->GetProfileInt("Settings", "FrameStatus", -1)) &&
-1 != (t = AfxGetApp()->GetProfileInt("Settings", "FrameTop", -1)) &&
-1 != (l = AfxGetApp()->GetProfileInt("Settings", "FrameLeft", -1)) &&
-1 != (b = AfxGetApp()->GetProfileInt("Settings", "FrameBottom", -1)) &&
-1 != (r = AfxGetApp()->GetProfileInt("Settings", "FrameRight", -1))
)
{
WINDOWPLACEMENT wp;
// restore the window's status
wp.showCmd = s;
// restore the window's width and height
wp.rcNormalPosition.bottom = b;
wp.rcNormalPosition.right = r;
// the following correction is needed when the taskbar is
// at the left or top and it is not "auto-hidden"
RECT workArea;
SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
l += workArea.left;
t += workArea.top;
// make sure the window is not completely out of sight
int max_x = GetSystemMetrics(SM_CXSCREEN) -
GetSystemMetrics(SM_CXICON);
int max_y = GetSystemMetrics(SM_CYSCREEN) -
GetSystemMetrics(SM_CYICON);
wp.rcNormalPosition.top = min(t, max_y);
wp.rcNormalPosition.left = min(l, max_x);
SetWindowPlacement(&wp);
}
}
// create property pages
m_TracePage.Create(IDD_PROPPAGE_TRACE, this);
m_OnlineUsersPage.Create(IDD_PROPPAGE_ONLINE, this);
m_ConfigurationPage.Create(IDD_PROPPAGE_CONFIGURATION, this);
m_StatisticsPage.Create(IDD_PROPPAGE_STATISTICS, this);
m_SecurityPage.Create(IDD_PROPPAGE_SECURITY, this);
// activate main page
ActivatePage(0);
// Set the icon for this dialog.
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// get registry values
m_ConfigurationPage.m_nPort = AfxGetApp()->GetProfileInt("Settings", "Port", 21);
m_ConfigurationPage.m_nMaxUsers = AfxGetApp()->GetProfileInt("Settings", "MaxUsers", 10);
m_ConfigurationPage.m_nTimeout = AfxGetApp()->GetProfileInt("Settings", "Timeout", 5);
m_ConfigurationPage.m_strWelcomeMessage = AfxGetApp()->GetProfileString("Settings", "WelcomeMsg", "Welcome to Pablo's FTP Server");
m_ConfigurationPage.m_strGoodbyeMessage = AfxGetApp()->GetProfileString("Settings", "GoodbyeMsg", "Bye");
m_ConfigurationPage.m_bLaunchOnStartup = AfxGetApp()->GetProfileInt("Settings", "LaunchOnStartup", 0);
m_ConfigurationPage.m_bStartInTray = AfxGetApp()->GetProfileInt("Settings", "StartInTray", 0);
m_ConfigurationPage.m_bAutoActivate = AfxGetApp()->GetProfileInt("Settings", "AutoActivate", 0);
m_ConfigurationPage.m_nLogLevel = AfxGetApp()->GetP