Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

391 lines
9.4 KiB

  1. // ConfigTestDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ConfigTest.h"
  5. #include "ConfigTestDlg.h"
  6. #include "QueueState.h"
  7. #include "SMTPDlg.h"
  8. #include "DlgVersion.h"
  9. #include "OutboxDlg.h"
  10. #include "DlgActivityLogging.h"
  11. #include "DlgProviders.h"
  12. #include "DlgDevices.h"
  13. #include "DlgExtensionData.h"
  14. #include "AddGroupDlg.h"
  15. #include "AddFSPDlg.h"
  16. #include "RemoveFSPDlg.h"
  17. #include "ArchiveAccessDlg.h"
  18. #include "DlgTiff.h"
  19. #include "RemoveRtExt.h"
  20. //#include "ManualAnswer.h"
  21. typedef unsigned long ULONG_PTR, *PULONG_PTR;
  22. typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
  23. #include "..\..\..\inc\fxsapip.h"
  24. #include "ArchiveDLg.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CAboutDlg dialog used for App About
  32. class CAboutDlg : public CDialog
  33. {
  34. public:
  35. CAboutDlg();
  36. // Dialog Data
  37. //{{AFX_DATA(CAboutDlg)
  38. enum { IDD = IDD_ABOUTBOX };
  39. //}}AFX_DATA
  40. // ClassWizard generated virtual function overrides
  41. //{{AFX_VIRTUAL(CAboutDlg)
  42. protected:
  43. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  44. //}}AFX_VIRTUAL
  45. // Implementation
  46. protected:
  47. //{{AFX_MSG(CAboutDlg)
  48. //}}AFX_MSG
  49. DECLARE_MESSAGE_MAP()
  50. };
  51. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  52. {
  53. //{{AFX_DATA_INIT(CAboutDlg)
  54. //}}AFX_DATA_INIT
  55. }
  56. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  57. {
  58. CDialog::DoDataExchange(pDX);
  59. //{{AFX_DATA_MAP(CAboutDlg)
  60. //}}AFX_DATA_MAP
  61. }
  62. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  63. //{{AFX_MSG_MAP(CAboutDlg)
  64. // No message handlers
  65. //}}AFX_MSG_MAP
  66. END_MESSAGE_MAP()
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CConfigTestDlg dialog
  69. CConfigTestDlg::CConfigTestDlg(CWnd* pParent /*=NULL*/)
  70. : CDialog(CConfigTestDlg::IDD, pParent)
  71. {
  72. //{{AFX_DATA_INIT(CConfigTestDlg)
  73. m_cstrServerName = _T("");
  74. //}}AFX_DATA_INIT
  75. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  76. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  77. m_FaxHandle = INVALID_HANDLE_VALUE;
  78. }
  79. CConfigTestDlg::~CConfigTestDlg ()
  80. {
  81. if (INVALID_HANDLE_VALUE != m_FaxHandle)
  82. {
  83. //
  84. // Disconnect upon termination
  85. //
  86. FaxClose (m_FaxHandle);
  87. }
  88. }
  89. void CConfigTestDlg::DoDataExchange(CDataExchange* pDX)
  90. {
  91. CDialog::DoDataExchange(pDX);
  92. //{{AFX_DATA_MAP(CConfigTestDlg)
  93. DDX_Control(pDX, IDC_CONNECT, m_btnConnect);
  94. DDX_Text(pDX, IDC_EDIT1, m_cstrServerName);
  95. //}}AFX_DATA_MAP
  96. }
  97. BEGIN_MESSAGE_MAP(CConfigTestDlg, CDialog)
  98. //{{AFX_MSG_MAP(CConfigTestDlg)
  99. ON_WM_SYSCOMMAND()
  100. ON_WM_PAINT()
  101. ON_WM_QUERYDRAGICON()
  102. ON_BN_CLICKED(IDC_QUEUESTATE, OnQueueState)
  103. ON_BN_CLICKED(IDC_CONNECT, OnConnect)
  104. ON_BN_CLICKED(IDC_SMTP, OnSmtp)
  105. ON_BN_CLICKED(IDC_VERSION, OnVersion)
  106. ON_BN_CLICKED(IDC_OUTBOX, OnOutbox)
  107. ON_BN_CLICKED(IDC_SENTITEMS, OnSentitems)
  108. ON_BN_CLICKED(IDC_INBOX, OnInbox)
  109. ON_BN_CLICKED(IDC_ACTIVITY, OnActivity)
  110. ON_BN_CLICKED(IDC_FSPS, OnFsps)
  111. ON_BN_CLICKED(IDC_DEVICES, OnDevices)
  112. ON_BN_CLICKED(IDC_EXTENSION, OnExtension)
  113. ON_BN_CLICKED(IDC_ADDGROUP, OnAddGroup)
  114. ON_BN_CLICKED(IDC_ADDFSP, OnAddFSP)
  115. ON_BN_CLICKED(IDC_REMOVEFSP, OnRemoveFSP)
  116. ON_BN_CLICKED(IDC_ARCHIVEACCESS, OnArchiveAccess)
  117. ON_BN_CLICKED(IDC_TIFF, OnGerTiff)
  118. ON_BN_CLICKED(IDC_REMOVERR, OnRemoveRtExt)
  119. // ON_BN_CLICKED(IDC_MANUAL_ANSWER, OnManualAnswer)
  120. //}}AFX_MSG_MAP
  121. END_MESSAGE_MAP()
  122. /////////////////////////////////////////////////////////////////////////////
  123. // CConfigTestDlg message handlers
  124. BOOL CConfigTestDlg::OnInitDialog()
  125. {
  126. CDialog::OnInitDialog();
  127. // Add "About..." menu item to system menu.
  128. // IDM_ABOUTBOX must be in the system command range.
  129. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  130. ASSERT(IDM_ABOUTBOX < 0xF000);
  131. CMenu* pSysMenu = GetSystemMenu(FALSE);
  132. if (pSysMenu != NULL)
  133. {
  134. CString strAboutMenu;
  135. strAboutMenu.LoadString(IDS_ABOUTBOX);
  136. if (!strAboutMenu.IsEmpty())
  137. {
  138. pSysMenu->AppendMenu(MF_SEPARATOR);
  139. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  140. }
  141. }
  142. // Set the icon for this dialog. The framework does this automatically
  143. // when the application's main window is not a dialog
  144. SetIcon(m_hIcon, TRUE); // Set big icon
  145. SetIcon(m_hIcon, FALSE); // Set small icon
  146. EnableTests (FALSE);
  147. return TRUE; // return TRUE unless you set the focus to a control
  148. }
  149. void CConfigTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
  150. {
  151. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  152. {
  153. CAboutDlg dlgAbout;
  154. dlgAbout.DoModal();
  155. }
  156. else
  157. {
  158. CDialog::OnSysCommand(nID, lParam);
  159. }
  160. }
  161. // If you add a minimize button to your dialog, you will need the code below
  162. // to draw the icon. For MFC applications using the document/view model,
  163. // this is automatically done for you by the framework.
  164. void CConfigTestDlg::OnPaint()
  165. {
  166. if (IsIconic())
  167. {
  168. CPaintDC dc(this); // device context for painting
  169. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  170. // Center icon in client rectangle
  171. int cxIcon = GetSystemMetrics(SM_CXICON);
  172. int cyIcon = GetSystemMetrics(SM_CYICON);
  173. CRect rect;
  174. GetClientRect(&rect);
  175. int x = (rect.Width() - cxIcon + 1) / 2;
  176. int y = (rect.Height() - cyIcon + 1) / 2;
  177. // Draw the icon
  178. dc.DrawIcon(x, y, m_hIcon);
  179. }
  180. else
  181. {
  182. CDialog::OnPaint();
  183. }
  184. }
  185. // The system calls this to obtain the cursor to display while the user drags
  186. // the minimized window.
  187. HCURSOR CConfigTestDlg::OnQueryDragIcon()
  188. {
  189. return (HCURSOR) m_hIcon;
  190. }
  191. void CConfigTestDlg::OnQueueState()
  192. {
  193. CQueueState dlg(m_FaxHandle);
  194. dlg.DoModal ();
  195. }
  196. void CConfigTestDlg::EnableTests (BOOL bEnable)
  197. {
  198. GetDlgItem (IDC_QUEUESTATE)->EnableWindow (bEnable);
  199. GetDlgItem (IDC_SMTP)->EnableWindow (bEnable);
  200. GetDlgItem (IDC_VERSION)->EnableWindow (bEnable);
  201. GetDlgItem (IDC_OUTBOX)->EnableWindow (bEnable);
  202. GetDlgItem (IDC_INBOX)->EnableWindow (bEnable);
  203. GetDlgItem (IDC_SENTITEMS)->EnableWindow (bEnable);
  204. GetDlgItem (IDC_ACTIVITY)->EnableWindow (bEnable);
  205. GetDlgItem (IDC_FSPS)->EnableWindow (bEnable);
  206. GetDlgItem (IDC_DEVICES)->EnableWindow (bEnable);
  207. GetDlgItem (IDC_EXTENSION)->EnableWindow (bEnable);
  208. GetDlgItem (IDC_ADDGROUP)->EnableWindow (bEnable);
  209. GetDlgItem (IDC_ADDFSP)->EnableWindow (bEnable);
  210. GetDlgItem (IDC_REMOVEFSP)->EnableWindow (bEnable);
  211. GetDlgItem (IDC_ARCHIVEACCESS)->EnableWindow (bEnable);
  212. GetDlgItem (IDC_TIFF)->EnableWindow (bEnable);
  213. GetDlgItem (IDC_REMOVERR)->EnableWindow (bEnable);
  214. GetDlgItem (IDC_MANUAL_ANSWER)->EnableWindow (bEnable);
  215. }
  216. void CConfigTestDlg::OnConnect()
  217. {
  218. UpdateData ();
  219. if (INVALID_HANDLE_VALUE == m_FaxHandle)
  220. {
  221. //
  222. // Connect
  223. //
  224. if (!FaxConnectFaxServer (m_cstrServerName, &m_FaxHandle))
  225. {
  226. //
  227. // Failed to connect
  228. //
  229. CString cs;
  230. cs.Format ("Failed to connect to %s (%ld)", m_cstrServerName, GetLastError());
  231. AfxMessageBox (cs, MB_OK | MB_ICONHAND);
  232. return;
  233. }
  234. //
  235. // Connection succeeded
  236. //
  237. EnableTests (TRUE);
  238. m_btnConnect.SetWindowText ("Disconnect");
  239. }
  240. else
  241. {
  242. //
  243. // Disconnect
  244. //
  245. if (!FaxClose (m_FaxHandle))
  246. {
  247. //
  248. // Failed to disconnect
  249. //
  250. CString cs;
  251. cs.Format ("Failed to disconnect from server (%ld)", GetLastError());
  252. AfxMessageBox (cs, MB_OK | MB_ICONHAND);
  253. return;
  254. }
  255. //
  256. // Disconnection succeeded
  257. //
  258. EnableTests (FALSE);
  259. m_btnConnect.SetWindowText ("Connect");
  260. }
  261. }
  262. void CConfigTestDlg::OnSmtp()
  263. {
  264. CSMTPDlg dlg(m_FaxHandle);
  265. dlg.DoModal ();
  266. }
  267. void CConfigTestDlg::OnVersion()
  268. {
  269. CDlgVersion dlg(m_FaxHandle);
  270. dlg.DoModal ();
  271. }
  272. void CConfigTestDlg::OnOutbox()
  273. {
  274. COutboxDlg dlg(m_FaxHandle);
  275. dlg.DoModal ();
  276. }
  277. void CConfigTestDlg::OnSentitems()
  278. {
  279. CArchiveDlg dlg(m_FaxHandle, FAX_MESSAGE_FOLDER_SENTITEMS);
  280. dlg.DoModal ();
  281. }
  282. void CConfigTestDlg::OnInbox()
  283. {
  284. CArchiveDlg dlg(m_FaxHandle, FAX_MESSAGE_FOLDER_INBOX);
  285. dlg.DoModal ();
  286. }
  287. void CConfigTestDlg::OnActivity()
  288. {
  289. CDlgActivityLogging dlg(m_FaxHandle);
  290. dlg.DoModal ();
  291. }
  292. void CConfigTestDlg::OnFsps()
  293. {
  294. CDlgProviders dlg(m_FaxHandle);
  295. dlg.DoModal ();
  296. }
  297. void CConfigTestDlg::OnDevices()
  298. {
  299. CDlgDevices dlg(m_FaxHandle);
  300. dlg.DoModal ();
  301. }
  302. void CConfigTestDlg::OnExtension()
  303. {
  304. CDlgExtensionData dlg(m_FaxHandle);
  305. dlg.DoModal ();
  306. }
  307. void CConfigTestDlg::OnAddGroup()
  308. {
  309. CAddGroupDlg dlg (m_FaxHandle);
  310. dlg.DoModal ();
  311. }
  312. void CConfigTestDlg::OnAddFSP()
  313. {
  314. CAddFSPDlg dlg (m_FaxHandle);
  315. dlg.DoModal ();
  316. }
  317. void CConfigTestDlg::OnRemoveFSP()
  318. {
  319. CRemoveFSPDlg dlg (m_FaxHandle);
  320. dlg.DoModal ();
  321. }
  322. void CConfigTestDlg::OnArchiveAccess()
  323. {
  324. CArchiveAccessDlg dlg (m_FaxHandle);
  325. dlg.DoModal ();
  326. }
  327. void CConfigTestDlg::OnGerTiff()
  328. {
  329. CDlgTIFF dlg (m_FaxHandle);
  330. dlg.DoModal ();
  331. }
  332. void CConfigTestDlg::OnRemoveRtExt()
  333. {
  334. CRemoveRtExt dlg(m_FaxHandle);
  335. dlg.DoModal ();
  336. }