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.

554 lines
23 KiB

  1. /*++
  2. Copyright (c) 1996-2002 Microsoft Corp. & Ricoh Co., Ltd. All rights reserved.
  3. FILE: RPDLDLG2.CPP (from RIAFUI.CPP)
  4. Abstract: Add OEM Page (Job/Log)
  5. Functions: JobPageProc
  6. Environment: Windows NT Unidrv5 driver
  7. Revision History:
  8. 09/22/2000 -Masatoshi Kubokura-
  9. Began to modify from RIAFUI code.
  10. 11/29/2000 -Masatoshi Kubokura-
  11. Last modified for XP inbox.
  12. 03/04/2002 -Masatoshi Kubokura-
  13. Include strsafe.h.
  14. Use OemToCharBuff() instead of OemToChar().
  15. 03/27/2002 -Masatoshi Kubokura-
  16. Eliminate "#if 0".
  17. 03/29/2002 -Masatoshi Kubokura-
  18. Use SecureZeroMemory() instead of memset(,0,)
  19. 04/01/2002 -Masatoshi Kubokura-
  20. Use safe_strlenW() instead of lstrlen().
  21. --*/
  22. #include "pdev.h"
  23. #include "resource.h"
  24. //#include <minidrv.h>
  25. //#include "devmode.h"
  26. //#include "oem.h"
  27. //#include "resource.h"
  28. #include <prsht.h>
  29. #include <mbstring.h> // _ismbcdigit, _ismbcalnum
  30. #ifndef WINNT_40
  31. #include "strsafe.h" // @Mar/01/2002
  32. #endif // !WINNT_40
  33. // Externals
  34. extern HINSTANCE ghInstance;
  35. extern "C" {
  36. // External Functions' prototype
  37. extern INT safe_strlenW(wchar_t* psz, size_t cchMax);
  38. // Local Functions' prototype
  39. INT_PTR CALLBACK JobPageProc(HWND, UINT, WPARAM, LPARAM);
  40. /***************************************************************************
  41. Function Name : InitMainDlg
  42. ***************************************************************************/
  43. VOID InitMainDlg(
  44. HWND hDlg,
  45. PUIDATA pUiData)
  46. {
  47. // initialize edit box
  48. SetDlgItemText(hDlg, IDC_EDIT_JOBMAIN_USERID, pUiData->UserIdBuf);
  49. SendDlgItemMessage(hDlg, IDC_EDIT_JOBMAIN_USERID, EM_LIMITTEXT, USERID_LEN, 0);
  50. SetDlgItemText(hDlg, IDC_EDIT_JOBMAIN_PASSWORD, pUiData->PasswordBuf);
  51. SendDlgItemMessage(hDlg, IDC_EDIT_JOBMAIN_PASSWORD, EM_LIMITTEXT, PASSWORD_LEN, 0);
  52. SetDlgItemText(hDlg, IDC_EDIT_JOBMAIN_USERCODE, pUiData->UserCodeBuf);
  53. SendDlgItemMessage(hDlg, IDC_EDIT_JOBMAIN_USERCODE, EM_LIMITTEXT, USERCODE_LEN, 0);
  54. // initialize radio button
  55. CheckRadioButton(hDlg, IDC_RADIO_JOB_NORMAL, IDC_RADIO_JOB_SECURE, pUiData->JobType);
  56. CheckRadioButton(hDlg, IDC_RADIO_LOG_DISABLED, IDC_RADIO_LOG_ENABLED, pUiData->LogDisabled);
  57. // initialize check box
  58. SendDlgItemMessage(hDlg, IDC_CHECK_JOB_DEFAULT, BM_SETCHECK,
  59. (BITTEST32(pUiData->fUiOption, HOLD_OPTIONS)? 0 : 1), 0);
  60. if (1 <= safe_strlenW(pUiData->UserIdBuf, sizeof(pUiData->UserIdBuf)))
  61. {
  62. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SAMPLE), TRUE);
  63. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SECURE), TRUE);
  64. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_JOB_DEFAULT), TRUE);
  65. }
  66. else
  67. {
  68. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SAMPLE), FALSE);
  69. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SECURE), FALSE);
  70. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_JOB_DEFAULT), FALSE);
  71. }
  72. if (IDC_RADIO_JOB_SECURE == pUiData->JobType)
  73. {
  74. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD), TRUE);
  75. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD2), TRUE);
  76. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_PASSWORD), TRUE);
  77. }
  78. else
  79. {
  80. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD), FALSE);
  81. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD2), FALSE);
  82. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_PASSWORD), FALSE);
  83. }
  84. if (IDC_RADIO_LOG_ENABLED == pUiData->LogDisabled)
  85. {
  86. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE), TRUE);
  87. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE2), TRUE);
  88. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_USERCODE), TRUE);
  89. }
  90. else
  91. {
  92. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE), FALSE);
  93. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE2), FALSE);
  94. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_USERCODE), FALSE);
  95. }
  96. #ifdef WINNT_40
  97. // Disable tab options when user has no permission.
  98. if (BITTEST32(pUiData->fUiOption, UIPLUGIN_NOPERMISSION))
  99. {
  100. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERID), FALSE);
  101. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERID2), FALSE);
  102. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERID3), FALSE);
  103. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_JOB), FALSE);
  104. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD), FALSE);
  105. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD2), FALSE);
  106. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_LOG), FALSE);
  107. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE), FALSE);
  108. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE2), FALSE);
  109. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_USERID), FALSE);
  110. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_PASSWORD), FALSE);
  111. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_USERCODE), FALSE);
  112. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_NORMAL), FALSE);
  113. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SAMPLE), FALSE);
  114. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SECURE), FALSE);
  115. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_LOG_DISABLED), FALSE);
  116. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_LOG_ENABLED), FALSE);
  117. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_JOB_DEFAULT), FALSE);
  118. }
  119. #endif // WINNT_40
  120. } //*** InitMainDlg
  121. /***************************************************************************
  122. Function Name : GetInfoFromOEMPdev
  123. get data from private devmode
  124. ***************************************************************************/
  125. VOID GetInfoFromOEMPdev(PUIDATA pUiData)
  126. {
  127. POEMUD_EXTRADATA pOEMExtra = pUiData->pOEMExtra;
  128. VERBOSE((DLLTEXT("GetInfoFromOEMPdev: print done?(%d)\n"),
  129. BITTEST32(pOEMExtra->fUiOption, PRINT_DONE)));
  130. // if previous printing is finished and reset-options flag is valid,
  131. // reset job setting.
  132. if (BITTEST32(pOEMExtra->fUiOption, PRINT_DONE) &&
  133. !BITTEST32(pOEMExtra->fUiOption, HOLD_OPTIONS))
  134. {
  135. pUiData->JobType = IDC_RADIO_JOB_NORMAL;
  136. // Use SecureZeroMemory @Mar/29/2002 ->
  137. #if defined(WINNT_40) || defined(RICOH_RELEASE)
  138. memset(pUiData->PasswordBuf, 0, sizeof(pUiData->PasswordBuf));
  139. #else
  140. SecureZeroMemory(pUiData->PasswordBuf, sizeof(pUiData->PasswordBuf));
  141. #endif
  142. // @Mar/29/2002 <-
  143. // do not clear PRINT_DONE flag here
  144. }
  145. else
  146. {
  147. pUiData->JobType = pOEMExtra->JobType;
  148. // ascii to unicode
  149. // @Mar/04/2002 ->
  150. // OemToChar((LPSTR)pOEMExtra->PasswordBuf, pUiData->PasswordBuf);
  151. OemToCharBuff((LPSTR)pOEMExtra->PasswordBuf, pUiData->PasswordBuf, PASSWORD_LEN);
  152. // @Mar/04/2002 <-
  153. }
  154. pUiData->fUiOption = pOEMExtra->fUiOption;
  155. pUiData->LogDisabled = pOEMExtra->LogDisabled;
  156. // ascii to unicode
  157. // @Mar/04/2002 ->
  158. // OemToChar((LPSTR)pOEMExtra->UserIdBuf, pUiData->UserIdBuf);
  159. // OemToChar((LPSTR)pOEMExtra->UserCodeBuf, pUiData->UserCodeBuf);
  160. OemToCharBuff((LPSTR)pOEMExtra->UserIdBuf, pUiData->UserIdBuf, USERID_LEN);
  161. OemToCharBuff((LPSTR)pOEMExtra->UserCodeBuf, pUiData->UserCodeBuf, USERCODE_LEN);
  162. // @Mar/04/2002 <-
  163. } //*** GetInfoFromOEMPdev
  164. /***************************************************************************
  165. Function Name : SetInfoToOEMPdev
  166. set data to private devmode
  167. ***************************************************************************/
  168. VOID SetInfoToOEMPdev(PUIDATA pUiData)
  169. {
  170. POEMUD_EXTRADATA pOEMExtra = pUiData->pOEMExtra;
  171. // if only main dialog is changed
  172. if (!BITTEST32(pUiData->fUiOption, JOBLOGDLG_UPDATED))
  173. return;
  174. // unicode to ascii
  175. CharToOem(pUiData->UserIdBuf, (LPSTR)pOEMExtra->UserIdBuf);
  176. CharToOem(pUiData->PasswordBuf, (LPSTR)pOEMExtra->PasswordBuf);
  177. CharToOem(pUiData->UserCodeBuf, (LPSTR)pOEMExtra->UserCodeBuf);
  178. pOEMExtra->fUiOption = pUiData->fUiOption & 0x00FF; // clear local bit
  179. pOEMExtra->JobType = pUiData->JobType;
  180. pOEMExtra->LogDisabled = pUiData->LogDisabled;
  181. #if DBG
  182. //DebugBreak();
  183. #endif // DBG
  184. return;
  185. } //*** SetInfoToOEMPdev
  186. /***************************************************************************
  187. Function Name : JobPageProc
  188. Parameters : HWND hDlg Handle of this Dialog
  189. UINT uMessage
  190. WPARAM wParam
  191. LPARAM lParam
  192. Modify Note : Modify. 03/01/2000 Masatoshi Kubokura
  193. ***************************************************************************/
  194. INT_PTR CALLBACK JobPageProc(
  195. HWND hDlg,
  196. UINT uMessage,
  197. WPARAM wParam,
  198. LPARAM lParam)
  199. {
  200. PUIDATA pUiData;
  201. WORD wOldVal, fModified = FALSE, fError = FALSE;
  202. INT iOldLen, iNewLen, iCnt;
  203. #if DBG
  204. giDebugLevel = DBG_VERBOSE;
  205. #endif // DBG
  206. switch (uMessage)
  207. {
  208. case WM_INITDIALOG:
  209. pUiData = (PUIDATA)((LPPROPSHEETPAGE)lParam)->lParam;
  210. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pUiData);
  211. // get data from private devmode
  212. GetInfoFromOEMPdev(pUiData);
  213. InitMainDlg(hDlg, pUiData);
  214. BITCLR32(pUiData->fUiOption, JOBLOGDLG_UPDATED);
  215. break;
  216. case WM_COMMAND:
  217. pUiData = (PUIDATA)GetWindowLongPtr(hDlg, DWLP_USER);
  218. switch(LOWORD(wParam))
  219. {
  220. case IDC_EDIT_JOBMAIN_USERID:
  221. iOldLen = safe_strlenW(pUiData->UserIdBuf, sizeof(pUiData->UserIdBuf));
  222. GetDlgItemText(hDlg, IDC_EDIT_JOBMAIN_USERID, pUiData->UserIdBuf,
  223. sizeof(pUiData->UserIdBuf) / sizeof(WCHAR));
  224. iNewLen = safe_strlenW(pUiData->UserIdBuf, sizeof(pUiData->UserIdBuf));
  225. if (1 <= iNewLen)
  226. {
  227. if (IDC_RADIO_JOB_SECURE == pUiData->JobType)
  228. {
  229. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD), TRUE);
  230. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD2), TRUE);
  231. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_PASSWORD), TRUE);
  232. }
  233. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SAMPLE), TRUE);
  234. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SECURE), TRUE);
  235. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_JOB_DEFAULT), TRUE);
  236. }
  237. // if UserID isn't set, disable Print Job setting.
  238. else
  239. {
  240. CheckRadioButton(hDlg, IDC_RADIO_JOB_NORMAL, IDC_RADIO_JOB_SECURE,
  241. (pUiData->JobType = IDC_RADIO_JOB_NORMAL));
  242. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SAMPLE), FALSE);
  243. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_JOB_SECURE), FALSE);
  244. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_JOB_DEFAULT), FALSE);
  245. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD), FALSE);
  246. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD2), FALSE);
  247. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_PASSWORD), FALSE);
  248. }
  249. if (iOldLen != iNewLen)
  250. fModified = TRUE;
  251. break;
  252. case IDC_EDIT_JOBMAIN_PASSWORD:
  253. iOldLen = safe_strlenW(pUiData->PasswordBuf, sizeof(pUiData->PasswordBuf));
  254. GetDlgItemText(hDlg, IDC_EDIT_JOBMAIN_PASSWORD, pUiData->PasswordBuf,
  255. sizeof(pUiData->PasswordBuf) / sizeof(WCHAR));
  256. if (iOldLen != safe_strlenW(pUiData->PasswordBuf, sizeof(pUiData->PasswordBuf)))
  257. fModified = TRUE;
  258. break;
  259. case IDC_EDIT_JOBMAIN_USERCODE:
  260. iOldLen = safe_strlenW(pUiData->UserCodeBuf, sizeof(pUiData->UserCodeBuf));
  261. GetDlgItemText(hDlg, IDC_EDIT_JOBMAIN_USERCODE, pUiData->UserCodeBuf,
  262. sizeof(pUiData->UserCodeBuf) / sizeof(WCHAR));
  263. if (iOldLen != safe_strlenW(pUiData->UserCodeBuf, sizeof(pUiData->UserCodeBuf)))
  264. fModified = TRUE;
  265. break;
  266. case IDC_RADIO_JOB_NORMAL:
  267. case IDC_RADIO_JOB_SAMPLE:
  268. case IDC_RADIO_JOB_SECURE:
  269. wOldVal = pUiData->JobType;
  270. CheckRadioButton(hDlg, IDC_RADIO_JOB_NORMAL, IDC_RADIO_JOB_SECURE,
  271. (pUiData->JobType = LOWORD(wParam)));
  272. if (IDC_RADIO_JOB_SECURE == pUiData->JobType)
  273. {
  274. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD), TRUE);
  275. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD2), TRUE);
  276. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_PASSWORD), TRUE);
  277. }
  278. else
  279. {
  280. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD), FALSE);
  281. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_PASSWORD2), FALSE);
  282. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_PASSWORD), FALSE);
  283. }
  284. if (wOldVal != pUiData->JobType)
  285. fModified = TRUE;
  286. break;
  287. case IDC_RADIO_LOG_DISABLED:
  288. case IDC_RADIO_LOG_ENABLED:
  289. wOldVal = pUiData->LogDisabled;
  290. CheckRadioButton(hDlg, IDC_RADIO_LOG_DISABLED, IDC_RADIO_LOG_ENABLED,
  291. (pUiData->LogDisabled = LOWORD(wParam)));
  292. if (IDC_RADIO_LOG_ENABLED == pUiData->LogDisabled)
  293. {
  294. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE), TRUE);
  295. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE2), TRUE);
  296. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_USERCODE), TRUE);
  297. }
  298. else
  299. {
  300. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE), FALSE);
  301. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_JOBMAIN_USERCODE2), FALSE);
  302. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_USERCODE), FALSE);
  303. }
  304. if (wOldVal != pUiData->LogDisabled)
  305. fModified = TRUE;
  306. break;
  307. case IDC_CHECK_JOB_DEFAULT:
  308. if (BITTEST32(pUiData->fUiOption, HOLD_OPTIONS))
  309. BITCLR32(pUiData->fUiOption, HOLD_OPTIONS);
  310. else
  311. BITSET32(pUiData->fUiOption, HOLD_OPTIONS);
  312. SendDlgItemMessage(hDlg, IDC_CHECK_JOB_DEFAULT, BM_SETCHECK,
  313. (BITTEST32(pUiData->fUiOption, HOLD_OPTIONS)? 0 : 1), 0);
  314. fModified = TRUE;
  315. break;
  316. default:
  317. return FALSE;
  318. }
  319. break;
  320. case WM_NOTIFY:
  321. pUiData = (PUIDATA)GetWindowLongPtr(hDlg, DWLP_USER);
  322. {
  323. NMHDR FAR *lpnmhdr = (NMHDR FAR *)lParam;
  324. switch (lpnmhdr->code)
  325. {
  326. case PSN_SETACTIVE:
  327. break;
  328. // In case of PSN_KILLACTIVE, return FALSE to get PSN_APPLY.
  329. case PSN_KILLACTIVE: // this is when user pushs OK/APPLY button.(1)
  330. VERBOSE((DLLTEXT("** JobPageProc: PSN_KILLACTIVE **\n")));
  331. BITSET32(pUiData->fUiOption, JOBLOGDLG_UPDATED);
  332. // Check User ID (Up to 8 alphanumeric characters)
  333. iNewLen = safe_strlenW(pUiData->UserIdBuf, sizeof(pUiData->UserIdBuf));
  334. for (iCnt = 0; iCnt < iNewLen; iCnt++)
  335. {
  336. // SBCS alphanumeric?
  337. if (!_ismbcalnum(pUiData->UserIdBuf[iCnt]))
  338. {
  339. fError = TRUE;
  340. break;
  341. }
  342. }
  343. if (fError)
  344. {
  345. WCHAR wcTmp1[64], wcTmp2[64];
  346. // set cursor to User ID edit box
  347. SetFocus(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_USERID));
  348. // Display warning dialog
  349. // yasho's point-out @Nov/29/2000 ->
  350. // LoadString(ghInstance, IDS_ERR_USERID_MSG, wcTmp1, sizeof(wcTmp1));
  351. // LoadString(ghInstance, IDS_ERR_USERID_TITLE, wcTmp2, sizeof(wcTmp1));
  352. LoadString(ghInstance, IDS_ERR_USERID_MSG, wcTmp1, sizeof(wcTmp1) / sizeof(*wcTmp1));
  353. LoadString(ghInstance, IDS_ERR_USERID_TITLE, wcTmp2, sizeof(wcTmp2) / sizeof(*wcTmp2));
  354. // @Nov/29/2000 <-
  355. MessageBox(hDlg, wcTmp1, wcTmp2, MB_ICONEXCLAMATION|MB_OK);
  356. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  357. // Do not close property sheets
  358. return TRUE;
  359. }
  360. // Check Password (4 digits)
  361. iNewLen = safe_strlenW(pUiData->PasswordBuf, sizeof(pUiData->PasswordBuf));
  362. if (PASSWORD_LEN != iNewLen) // Password must be exactly 4 digits.
  363. {
  364. fError = TRUE;
  365. }
  366. else
  367. {
  368. for (iCnt = 0; iCnt < iNewLen; iCnt++)
  369. {
  370. // SBCS digit?
  371. if (!_ismbcdigit(pUiData->PasswordBuf[iCnt]))
  372. {
  373. fError = TRUE;
  374. break;
  375. }
  376. }
  377. }
  378. if (fError)
  379. {
  380. // if Secure Print is enabled
  381. if (IDC_RADIO_JOB_SECURE == pUiData->JobType)
  382. {
  383. WCHAR wcTmp1[64], wcTmp2[64];
  384. // set cursor to Password edit box
  385. SetFocus(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_PASSWORD));
  386. // Display warning dialog
  387. LoadString(ghInstance, IDS_ERR_PASSWORD_MSG, wcTmp1, sizeof(wcTmp1) / sizeof(*wcTmp1));
  388. LoadString(ghInstance, IDS_ERR_PASSWORD_TITLE, wcTmp2, sizeof(wcTmp2) / sizeof(*wcTmp2));
  389. MessageBox(hDlg, wcTmp1, wcTmp2, MB_ICONEXCLAMATION|MB_OK);
  390. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  391. // Do not close property sheets
  392. return TRUE;
  393. }
  394. else
  395. {
  396. // Clear invalid Password
  397. // Use SecureZeroMemory @Mar/29/2002 ->
  398. #if defined(WINNT_40) || defined(RICOH_RELEASE)
  399. memset(pUiData->PasswordBuf, 0, sizeof(pUiData->PasswordBuf));
  400. #else
  401. SecureZeroMemory(pUiData->PasswordBuf, sizeof(pUiData->PasswordBuf));
  402. #endif
  403. // @Mar/29/2002 <-
  404. }
  405. fError = FALSE;
  406. }
  407. // Check User Code (Up to 8 characters)
  408. iNewLen = safe_strlenW(pUiData->UserCodeBuf, sizeof(pUiData->UserCodeBuf));
  409. for (iCnt = 0; iCnt < iNewLen; iCnt++)
  410. {
  411. // SBCS digit?
  412. if (!_ismbcdigit(pUiData->UserCodeBuf[iCnt]))
  413. {
  414. fError = TRUE;
  415. break;
  416. }
  417. }
  418. if (fError)
  419. {
  420. // if Log is enabled
  421. if (IDC_RADIO_LOG_ENABLED == pUiData->LogDisabled)
  422. {
  423. WCHAR wcTmp1[64], wcTmp2[64];
  424. // set cursor to User Code edit box
  425. SetFocus(GetDlgItem(hDlg, IDC_EDIT_JOBMAIN_USERCODE));
  426. // Display warning dialog
  427. LoadString(ghInstance, IDS_ERR_USERCODE_MSG, wcTmp1, sizeof(wcTmp1) / sizeof(*wcTmp1));
  428. LoadString(ghInstance, IDS_ERR_USERCODE_TITLE, wcTmp2, sizeof(wcTmp2) / sizeof(*wcTmp2));
  429. MessageBox(hDlg, wcTmp1, wcTmp2, MB_ICONEXCLAMATION|MB_OK);
  430. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  431. // Do not close property sheets
  432. return TRUE;
  433. }
  434. else
  435. {
  436. // Clear invalid User Code
  437. // Use SecureZeroMemory @Mar/29/2002 ->
  438. #if defined(WINNT_40) || defined(RICOH_RELEASE)
  439. memset(pUiData->UserCodeBuf, 0, sizeof(pUiData->UserCodeBuf));
  440. #else
  441. SecureZeroMemory(pUiData->UserCodeBuf, sizeof(pUiData->UserCodeBuf));
  442. #endif
  443. // Mar/29/2002 <-
  444. }
  445. fError = FALSE;
  446. }
  447. return FALSE;
  448. case PSN_APPLY: // this is when user pushs OK/APPLY button.(2)
  449. VERBOSE((DLLTEXT("** JobPageProc: PSN_APPLY **\n")));
  450. // clear PRINT_DONE flag and delete file.
  451. // BUGBUG: When printing document twice, printing job settings are cleared on app's print dialog
  452. // in 2nd printing. @Sep/05/2000 ->
  453. // if (BITTEST32(pUiData->pOEMExtra->fUiOption, PRINT_DONE))
  454. // {
  455. // BITCLR32(pUiData->pOEMExtra->fUiOption, PRINT_DONE);
  456. // VERBOSE(("** Delete file: %ls **\n", pUiData->pOEMExtra->SharedFileName));
  457. // DeleteFile(pUiData->pOEMExtra->SharedFileName);
  458. // }
  459. if (BITTEST32(pUiData->fUiOption, PRINT_DONE))
  460. {
  461. BITCLR32(pUiData->fUiOption, PRINT_DONE);
  462. VERBOSE(("** Delete file: %ls **\n", pUiData->pOEMExtra->SharedFileName));
  463. DeleteFile(pUiData->pOEMExtra->SharedFileName);
  464. }
  465. // @Sep/05/2000 <-
  466. // set data to private devmode
  467. SetInfoToOEMPdev(pUiData);
  468. // update private devmode
  469. pUiData->pfnComPropSheet(pUiData->hComPropSheet,
  470. CPSFUNC_SET_RESULT,
  471. (LPARAM)pUiData->hPropPage,
  472. (LPARAM)CPSUI_OK);
  473. VERBOSE((DLLTEXT("** PSN_APPLY fUiOption=%x **\n"), pUiData->fUiOption));
  474. break;
  475. case PSN_RESET: // this is when user pushs CANCEL button
  476. VERBOSE((DLLTEXT("** JobPageProc: PSN_RESET **\n")));
  477. break;
  478. }
  479. }
  480. break;
  481. default:
  482. return FALSE;
  483. }
  484. // activate APPLY button
  485. if (fModified)
  486. PropSheet_Changed(GetParent(hDlg), hDlg);
  487. return TRUE;
  488. } //*** JobPageProc
  489. } // End of extern "C"