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.

418 lines
14 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. archfldr.c
  5. Abstract:
  6. Property sheet handler for "Archive folder" page and "Remote" page
  7. Environment:
  8. Fax driver user interface
  9. Revision History:
  10. 04/09/00 -taoyuan-
  11. Created it.
  12. mm/dd/yy -author-
  13. description
  14. --*/
  15. #include <stdio.h>
  16. #include "faxui.h"
  17. #include "resource.h"
  18. INT_PTR
  19. CALLBACK
  20. ArchiveInfoDlgProc(
  21. HWND hDlg,
  22. UINT uMsg,
  23. WPARAM wParam,
  24. LPARAM lParam
  25. )
  26. /*++
  27. Routine Description:
  28. Procedure for handling the archive folder tab
  29. Arguments:
  30. hDlg - Identifies the property sheet page
  31. uMsg - Specifies the message
  32. wParam - Specifies additional message-specific information
  33. lParam - Specifies additional message-specific information
  34. Return Value:
  35. Depends on the value of message parameter
  36. --*/
  37. {
  38. DWORD dwRes = 0;
  39. switch (uMsg)
  40. {
  41. case WM_INITDIALOG :
  42. {
  43. PFAX_ARCHIVE_CONFIG pFaxArchiveConfig;
  44. SetLTREditDirection(hDlg, IDC_OUTGOING_FOLDER);
  45. SetLTREditDirection(hDlg, IDC_INCOMING_FOLDER);
  46. // set edit box text limit
  47. SendDlgItemMessage(hDlg, IDC_INCOMING_FOLDER, EM_SETLIMITTEXT, MAX_ARCHIVE_FOLDER_PATH, 0);
  48. SendDlgItemMessage(hDlg, IDC_OUTGOING_FOLDER, EM_SETLIMITTEXT, MAX_ARCHIVE_FOLDER_PATH, 0);
  49. if(!Connect(hDlg, TRUE))
  50. {
  51. return TRUE;
  52. }
  53. // load incoming archive folder info
  54. if(FaxGetArchiveConfiguration(g_hFaxSvcHandle, FAX_MESSAGE_FOLDER_INBOX, &pFaxArchiveConfig))
  55. {
  56. CheckDlgButton(hDlg, IDC_INCOMING, pFaxArchiveConfig->bUseArchive ? BST_CHECKED : BST_UNCHECKED);
  57. SetDlgItemText(hDlg, IDC_INCOMING_FOLDER, pFaxArchiveConfig->lpcstrFolder);
  58. if(g_bUserCanChangeSettings)
  59. {
  60. EnableWindow(GetDlgItem(hDlg, IDC_INCOMING), TRUE);
  61. EnableWindow(GetDlgItem(hDlg, IDC_INCOMING_FOLDER), IsDlgButtonChecked(hDlg, IDC_INCOMING));
  62. EnableWindow(GetDlgItem(hDlg, IDC_INCOMING_FOLDER_BR), IsDlgButtonChecked(hDlg, IDC_INCOMING));
  63. }
  64. FaxFreeBuffer(pFaxArchiveConfig);
  65. }
  66. else
  67. {
  68. dwRes = GetLastError();
  69. Error(("FaxGetArchiveConfiguration(FAX_MESSAGE_FOLDER_INBOX) failed. Error code is %d.\n", dwRes));
  70. goto Exit;
  71. }
  72. // load incoming archive folder info
  73. if(FaxGetArchiveConfiguration(g_hFaxSvcHandle, FAX_MESSAGE_FOLDER_SENTITEMS, &pFaxArchiveConfig))
  74. {
  75. CheckDlgButton(hDlg, IDC_OUTGOING, pFaxArchiveConfig->bUseArchive ? BST_CHECKED : BST_UNCHECKED);
  76. SetDlgItemText(hDlg, IDC_OUTGOING_FOLDER, pFaxArchiveConfig->lpcstrFolder);
  77. if(g_bUserCanChangeSettings)
  78. {
  79. EnableWindow(GetDlgItem(hDlg, IDC_OUTGOING), TRUE);
  80. EnableWindow(GetDlgItem(hDlg, IDC_OUTGOING_FOLDER), IsDlgButtonChecked(hDlg, IDC_OUTGOING));
  81. EnableWindow(GetDlgItem(hDlg, IDC_OUTGOING_FOLDER_BR), IsDlgButtonChecked(hDlg, IDC_OUTGOING));
  82. }
  83. FaxFreeBuffer(pFaxArchiveConfig);
  84. }
  85. else
  86. {
  87. dwRes = GetLastError();
  88. Error(( "FaxGetArchiveConfiguration(FAX_MESSAGE_FOLDER_SENTITEMS) failed. Error code is %d.\n", dwRes));
  89. goto Exit;
  90. }
  91. if (g_pSHAutoComplete)
  92. {
  93. g_pSHAutoComplete (GetDlgItem(hDlg, IDC_OUTGOING_FOLDER), SHACF_FILESYSTEM);
  94. g_pSHAutoComplete (GetDlgItem(hDlg, IDC_INCOMING_FOLDER), SHACF_FILESYSTEM);
  95. }
  96. Exit:
  97. DisConnect();
  98. if (dwRes != 0)
  99. {
  100. DisplayErrorMessage(hDlg, 0, dwRes);
  101. return TRUE;
  102. }
  103. if(!g_bUserCanChangeSettings)
  104. {
  105. PageEnable(hDlg, FALSE);
  106. }
  107. return TRUE;
  108. }
  109. case WM_COMMAND:
  110. switch(LOWORD(wParam))
  111. {
  112. case IDC_INCOMING_FOLDER:
  113. case IDC_OUTGOING_FOLDER:
  114. if(HIWORD(wParam) == EN_CHANGE) // notification code
  115. {
  116. Notify_Change(hDlg);
  117. }
  118. if (HIWORD(wParam) == EN_KILLFOCUS)
  119. {
  120. TCHAR szFolder[MAX_PATH * 2];
  121. TCHAR szResult[MAX_PATH * 2];
  122. //
  123. // Edit control lost its focus
  124. //
  125. GetDlgItemText (hDlg, LOWORD(wParam), szFolder, ARR_SIZE(szFolder));
  126. if (lstrlen (szFolder))
  127. {
  128. if (GetFullPathName(szFolder, ARR_SIZE(szResult), szResult, NULL))
  129. {
  130. if (g_pPathMakePrettyW)
  131. {
  132. g_pPathMakePrettyW (szResult);
  133. }
  134. SetDlgItemText (hDlg, LOWORD(wParam), szResult);
  135. }
  136. }
  137. }
  138. break;
  139. case IDC_INCOMING:
  140. case IDC_OUTGOING:
  141. if( HIWORD(wParam) == BN_CLICKED ) // notification code
  142. {
  143. BOOL bEnabled;
  144. if(LOWORD(wParam) == IDC_INCOMING)
  145. {
  146. bEnabled = IsDlgButtonChecked(hDlg, IDC_INCOMING);
  147. EnableWindow(GetDlgItem(hDlg, IDC_INCOMING_FOLDER), bEnabled);
  148. EnableWindow(GetDlgItem(hDlg, IDC_INCOMING_FOLDER_BR), bEnabled);
  149. }
  150. else
  151. {
  152. bEnabled = IsDlgButtonChecked(hDlg, IDC_OUTGOING);
  153. EnableWindow(GetDlgItem(hDlg, IDC_OUTGOING_FOLDER), bEnabled);
  154. EnableWindow(GetDlgItem(hDlg, IDC_OUTGOING_FOLDER_BR), bEnabled);
  155. }
  156. Notify_Change(hDlg);
  157. }
  158. break;
  159. case IDC_INCOMING_FOLDER_BR:
  160. case IDC_OUTGOING_FOLDER_BR:
  161. {
  162. TCHAR szTitle[MAX_TITLE_LEN];
  163. BOOL bResult;
  164. if(!LoadString(g_hResource, IDS_BROWSE_FOLDER, szTitle, MAX_TITLE_LEN))
  165. {
  166. Error(( "LoadString failed, string ID is %d.\n", IDS_BROWSE_FOLDER ));
  167. }
  168. if( LOWORD(wParam) == IDC_INCOMING_FOLDER_BR )
  169. {
  170. bResult = BrowseForDirectory(hDlg, IDC_INCOMING_FOLDER, MAX_ARCHIVE_FOLDER_PATH, szTitle);
  171. }
  172. else
  173. {
  174. bResult = BrowseForDirectory(hDlg, IDC_OUTGOING_FOLDER, MAX_ARCHIVE_FOLDER_PATH, szTitle);
  175. }
  176. if(bResult)
  177. {
  178. Notify_Change(hDlg);
  179. }
  180. break;
  181. }
  182. default:
  183. break;
  184. }
  185. break;
  186. case WM_NOTIFY:
  187. {
  188. LPNMHDR lpnm = (LPNMHDR) lParam;
  189. switch (lpnm->code)
  190. {
  191. case PSN_APPLY:
  192. {
  193. PFAX_ARCHIVE_CONFIG pFaxArchiveConfig = NULL;
  194. BOOL bEnabled;
  195. TCHAR szArchiveFolder[MAX_PATH] = {0};
  196. HWND hControl;
  197. // if the user only has read permission, return immediately
  198. if(!g_bUserCanChangeSettings)
  199. {
  200. return TRUE;
  201. }
  202. // check the validaty of edit box if they are enabled.
  203. if(IsDlgButtonChecked(hDlg, IDC_INCOMING))
  204. {
  205. hControl = GetDlgItem(hDlg, IDC_INCOMING_FOLDER);
  206. GetWindowText(hControl, szArchiveFolder, MAX_PATH);
  207. if ((g_pPathIsRelativeW && g_pPathIsRelativeW(szArchiveFolder)) ||
  208. !DirectoryExists(szArchiveFolder))
  209. {
  210. DisplayErrorMessage(hDlg, 0, ERROR_PATH_NOT_FOUND);
  211. SendMessage(hControl, EM_SETSEL, 0, -1);
  212. SetFocus(hControl);
  213. SetActiveWindow(hControl);
  214. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID);
  215. return TRUE;
  216. }
  217. szArchiveFolder[0] = 0; // set string to empty string
  218. }
  219. if(IsDlgButtonChecked(hDlg, IDC_OUTGOING))
  220. {
  221. hControl = GetDlgItem(hDlg, IDC_OUTGOING_FOLDER);
  222. GetWindowText(hControl, szArchiveFolder, MAX_PATH);
  223. // if(lstrlen(szArchiveFolder) == 0)
  224. if( !DirectoryExists(szArchiveFolder) )
  225. {
  226. DisplayErrorMessage(hDlg, 0, ERROR_PATH_NOT_FOUND);
  227. SendMessage(hControl, EM_SETSEL, 0, -1);
  228. SetFocus(hControl);
  229. SetActiveWindow(hControl);
  230. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID);
  231. return TRUE;
  232. }
  233. szArchiveFolder[0] = 0; // set string to empty string
  234. }
  235. if(!Connect(hDlg, TRUE))
  236. {
  237. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID);
  238. return TRUE;
  239. }
  240. //
  241. // save incoming archive folder info
  242. //
  243. if(!FaxGetArchiveConfiguration(g_hFaxSvcHandle, FAX_MESSAGE_FOLDER_INBOX, &pFaxArchiveConfig))
  244. {
  245. dwRes = GetLastError();
  246. Error(( "FaxGetArchiveConfiguration(FAX_MESSAGE_FOLDER_INBOX) failed. Error code is %d.\n", dwRes));
  247. goto ApplyExit;
  248. }
  249. bEnabled = (IsDlgButtonChecked(hDlg, IDC_INCOMING) == BST_CHECKED);
  250. GetDlgItemText(hDlg, IDC_INCOMING_FOLDER, szArchiveFolder, MAX_PATH);
  251. ValidatePath(szArchiveFolder);
  252. pFaxArchiveConfig->bUseArchive = bEnabled;
  253. pFaxArchiveConfig->lpcstrFolder = szArchiveFolder;
  254. if (!FaxSetArchiveConfiguration(g_hFaxSvcHandle, FAX_MESSAGE_FOLDER_INBOX, pFaxArchiveConfig))
  255. {
  256. dwRes = GetLastError();
  257. Error(("FaxSetArchiveConfiguration(FAX_MESSAGE_FOLDER_INBOX) failed. Error code is %d.\n", dwRes));
  258. goto ApplyExit;
  259. }
  260. FaxFreeBuffer(pFaxArchiveConfig);
  261. pFaxArchiveConfig = NULL;
  262. //
  263. // save outgoing archive folder info
  264. //
  265. if(!FaxGetArchiveConfiguration(g_hFaxSvcHandle, FAX_MESSAGE_FOLDER_SENTITEMS, &pFaxArchiveConfig))
  266. {
  267. dwRes = GetLastError();
  268. Error(("FaxGetArchiveConfiguration(FAX_MESSAGE_FOLDER_SENTITEMS) failed. Error code is %d.\n", dwRes));
  269. goto ApplyExit;
  270. }
  271. bEnabled = (IsDlgButtonChecked(hDlg, IDC_OUTGOING) == BST_CHECKED);
  272. GetDlgItemText(hDlg, IDC_OUTGOING_FOLDER, szArchiveFolder, MAX_PATH);
  273. ValidatePath(szArchiveFolder);
  274. pFaxArchiveConfig->bUseArchive = bEnabled;
  275. pFaxArchiveConfig->lpcstrFolder = szArchiveFolder;
  276. if(!FaxSetArchiveConfiguration(g_hFaxSvcHandle, FAX_MESSAGE_FOLDER_SENTITEMS, pFaxArchiveConfig))
  277. {
  278. dwRes = GetLastError();
  279. Error(("FaxSetArchiveConfiguration(FAX_MESSAGE_FOLDER_SENTITEMS) failed. Error code is %d.\n", dwRes));
  280. goto ApplyExit;
  281. }
  282. Notify_UnChange(hDlg);
  283. ApplyExit:
  284. DisConnect();
  285. if (pFaxArchiveConfig)
  286. {
  287. FaxFreeBuffer(pFaxArchiveConfig);
  288. }
  289. if (dwRes != 0)
  290. {
  291. DisplayErrorMessage(hDlg, 0, dwRes);
  292. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID);
  293. }
  294. return TRUE;
  295. }
  296. default :
  297. break;
  298. } // switch
  299. break;
  300. }
  301. case WM_HELP:
  302. WinHelpContextPopup(((LPHELPINFO)lParam)->dwContextId, hDlg);
  303. return TRUE;
  304. default:
  305. break;
  306. }
  307. return FALSE;
  308. }
  309. INT_PTR
  310. CALLBACK
  311. RemoteInfoDlgProc(
  312. HWND hDlg,
  313. UINT uMsg,
  314. WPARAM wParam,
  315. LPARAM lParam
  316. )
  317. /*++
  318. Routine Description:
  319. Procedure for handling the archive folder tab
  320. Arguments:
  321. hDlg - Identifies the property sheet page
  322. uMsg - Specifies the message
  323. wParam - Specifies additional message-specific information
  324. lParam - Specifies additional message-specific information
  325. Return Value:
  326. Depends on the value of message parameter
  327. --*/
  328. {
  329. return FALSE;
  330. }