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.

322 lines
12 KiB

  1. /**************************************************************************
  2. Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  3. MODULE: MESSAGE.CPP
  4. PURPOSE: Source module for Passport Manager config tool
  5. FUNCTIONS:
  6. COMMENTS:
  7. **************************************************************************/
  8. /**************************************************************************
  9. Include Files
  10. **************************************************************************/
  11. #include "pmcfg.h"
  12. struct
  13. {
  14. UINT uErrorID;
  15. UINT uWarningID;
  16. } g_ControlMessageTable[] =
  17. {
  18. {IDS_TIMEWINDOW_ERROR, IDS_CONSISTENCY_WARN}, //IDC_TIMEWINDOW
  19. {0, IDS_CONSISTENCY_WARN}, //IDC_FORCESIGNIN
  20. {IDS_LANGUAGEID_ERROR, IDS_CONSISTENCY_WARN}, //IDC_LANGUAGEID
  21. {IDS_COBRANDING_ERROR, IDS_CONSISTENCY_WARN}, //IDC_COBRANDING_TEMPLATE
  22. {IDS_SITEID_ERROR, IDS_SITEID_WARN}, //IDC_SITEID
  23. {IDS_RETURNURL_ERROR, IDS_CONSISTENCY_WARN}, //IDC_RETURNURL
  24. {IDS_COOKIEDOMAIN_ERROR, IDS_CONSISTENCY_WARN}, //IDC_COOKIEDOMAIN
  25. {IDS_COOKIEPATH_ERROR, IDS_CONSISTENCY_WARN}, //IDC_COOKIEPATH
  26. {0, IDS_STANDALONE_WARN}, //IDC_STANDALONE
  27. {0, IDS_DISABLECOOKIE_WARN}, //IDC_DISABLECOOKIES
  28. {IDS_DISASTERURL_ERROR, IDS_CONSISTENCY_WARN}, //IDC_DISASTERURL
  29. {IDS_HOSTNAME_ERROR, IDS_CONSISTENCY_WARN}, //IDC_HOSTNAMEEDIT
  30. {IDS_HOSTIP_ERROR, IDS_CONSISTENCY_WARN}, //IDC_HOSTIPEDIT
  31. {IDS_PROFILEDOMAIN_ERROR, IDS_CONSISTENCY_WARN}, //IDC_PROFILEDOMAIN
  32. {IDS_PROFILEPATH_ERROR, IDS_CONSISTENCY_WARN}, //IDC_PROFILEPATH
  33. {IDS_SECUREDOMAIN_ERROR, IDS_CONSISTENCY_WARN}, //IDC_SECUREDOMAIN
  34. {IDS_SECUREPATH_ERROR, IDS_CONSISTENCY_WARN} //IDC_SECUREPATH
  35. };
  36. INT_PTR CALLBACK CommitOKDlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  37. void ReportControlMessage
  38. (
  39. HWND hWnd,
  40. INT idCtrl,
  41. WORD wMessageType
  42. )
  43. {
  44. UINT uMBType = MB_OK;
  45. TCHAR szMessageBoxTitle[MAX_TITLE];
  46. TCHAR szMessage[MAX_MESSAGE];
  47. UINT uID;
  48. // Load the appropriate title
  49. switch (wMessageType)
  50. {
  51. case VALIDATION_ERROR:
  52. LoadString(g_hInst, IDS_ERROR, szMessageBoxTitle, DIMENSION(szMessageBoxTitle));
  53. uMBType |= MB_ICONERROR;
  54. uID = g_ControlMessageTable[idCtrl - CTRL_BASE].uErrorID;
  55. break;
  56. case CHANGE_WARNING:
  57. LoadString(g_hInst, IDS_WARNING, szMessageBoxTitle, DIMENSION(szMessageBoxTitle));
  58. uMBType |= MB_ICONWARNING;
  59. uID = g_ControlMessageTable[idCtrl - CTRL_BASE].uWarningID;
  60. break;
  61. }
  62. // Load the appropriate message
  63. LoadString(g_hInst, uID, szMessage, DIMENSION(szMessage));
  64. MessageBox(hWnd, szMessage, szMessageBoxTitle, uMBType);
  65. }
  66. BOOL CommitOKWarning
  67. (
  68. HWND hWndDlg
  69. )
  70. {
  71. if (IDOK == DialogBox( g_hInst,
  72. MAKEINTRESOURCE (IDD_CONFIRM_COMMIT),
  73. hWndDlg,
  74. CommitOKDlgProc ))
  75. return TRUE;
  76. else
  77. return FALSE;
  78. }
  79. void ReportError
  80. (
  81. HWND hWndDlg,
  82. UINT idError
  83. )
  84. {
  85. TCHAR szMessageBoxTitle[MAX_TITLE];
  86. TCHAR szMessage[MAX_MESSAGE];
  87. LoadString(g_hInst, IDS_ERROR, szMessageBoxTitle, DIMENSION(szMessageBoxTitle));
  88. LoadString(g_hInst, idError, szMessage, DIMENSION(szMessage));
  89. MessageBox(hWndDlg, szMessage, szMessageBoxTitle, MB_OK | MB_ICONERROR);
  90. }
  91. INT_PTR CALLBACK CommitOKDlgProc
  92. (
  93. HWND hWndDlg,
  94. UINT uMsg,
  95. WPARAM wParam,
  96. LPARAM lParam
  97. )
  98. {
  99. switch ( uMsg )
  100. {
  101. case WM_INITDIALOG:
  102. {
  103. TCHAR szTemp[MAX_RESOURCE];
  104. TCHAR szFields[MAX_MESSAGE];
  105. BOOL bOther = FALSE;
  106. ShowWindow(GetDlgItem(hWndDlg, IDC_OTHERPROCESS), SW_HIDE);
  107. // See which of the "other" fields have been modified
  108. szFields[0] = '\0';
  109. if (g_OriginalSettings.dwTimeWindow != g_CurrentSettings.dwTimeWindow)
  110. {
  111. bOther = TRUE;
  112. LoadString(g_hInst, IDS_TIMEWINDOW, szTemp, DIMENSION(szTemp));
  113. lstrcat(szFields, szTemp);
  114. }
  115. if (g_OriginalSettings.dwForceSignIn != g_CurrentSettings.dwForceSignIn)
  116. {
  117. bOther = TRUE;
  118. LoadString(g_hInst, IDS_FORCESIGNIN, szTemp, DIMENSION(szTemp));
  119. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  120. //
  121. // It is not good just skip if buffer overrun. In this case, we assume
  122. // user would detect the skipped warning item. And it is not likely we
  123. // would have buffer overrun here. If buffer is to small, we just skip
  124. // for now.
  125. //
  126. lstrcat(szFields, szTemp);
  127. }
  128. }
  129. if (g_OriginalSettings.dwVerboseMode != g_CurrentSettings.dwVerboseMode)
  130. {
  131. bOther = TRUE;
  132. LoadString(g_hInst, IDS_VERBOSE_MODE, szTemp, DIMENSION(szTemp));
  133. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  134. lstrcat(szFields, szTemp);
  135. }
  136. }
  137. if (g_OriginalSettings.dwLanguageID != g_CurrentSettings.dwLanguageID)
  138. {
  139. bOther = TRUE;
  140. LoadString(g_hInst, IDS_LANGUAGEID, szTemp, DIMENSION(szTemp));
  141. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  142. lstrcat(szFields, szTemp);
  143. }
  144. }
  145. if (0 != lstrcmpi(g_OriginalSettings.szCoBrandTemplate, g_CurrentSettings.szCoBrandTemplate))
  146. {
  147. bOther = TRUE;
  148. LoadString(g_hInst, IDS_COBRANDTEMPLATE, szTemp, DIMENSION(szTemp));
  149. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  150. lstrcat(szFields, szTemp);
  151. }
  152. }
  153. if (0 != lstrcmpi(g_OriginalSettings.szReturnURL, g_CurrentSettings.szReturnURL))
  154. {
  155. bOther = TRUE;
  156. LoadString(g_hInst, IDS_RETURNURL, szTemp, DIMENSION(szTemp));
  157. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  158. lstrcat(szFields, szTemp);
  159. }
  160. }
  161. if (0 != lstrcmpi(g_OriginalSettings.szTicketDomain, g_CurrentSettings.szTicketDomain))
  162. {
  163. bOther = TRUE;
  164. LoadString(g_hInst, IDS_COOKIEDOMAIN, szTemp, DIMENSION(szTemp));
  165. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  166. lstrcat(szFields, szTemp);
  167. }
  168. }
  169. if (0 != lstrcmpi(g_OriginalSettings.szTicketPath, g_CurrentSettings.szTicketPath))
  170. {
  171. bOther = TRUE;
  172. LoadString(g_hInst, IDS_COOKIEPATH, szTemp, DIMENSION(szTemp));
  173. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  174. lstrcat(szFields, szTemp);
  175. }
  176. }
  177. if (0 != lstrcmpi(g_OriginalSettings.szProfileDomain, g_CurrentSettings.szProfileDomain))
  178. {
  179. bOther = TRUE;
  180. LoadString(g_hInst, IDS_PROFILEDOMAIN, szTemp, DIMENSION(szTemp));
  181. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  182. lstrcat(szFields, szTemp);
  183. }
  184. }
  185. if (0 != lstrcmpi(g_OriginalSettings.szProfilePath, g_CurrentSettings.szProfilePath))
  186. {
  187. bOther = TRUE;
  188. LoadString(g_hInst, IDS_PROFILEPATH, szTemp, DIMENSION(szTemp));
  189. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  190. lstrcat(szFields, szTemp);
  191. }
  192. }
  193. if (0 != lstrcmpi(g_OriginalSettings.szSecureDomain, g_CurrentSettings.szSecureDomain))
  194. {
  195. bOther = TRUE;
  196. LoadString(g_hInst, IDS_SECUREDOMAIN, szTemp, DIMENSION(szTemp));
  197. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  198. lstrcat(szFields, szTemp);
  199. }
  200. }
  201. if (0 != lstrcmpi(g_OriginalSettings.szSecurePath, g_CurrentSettings.szSecurePath))
  202. {
  203. bOther = TRUE;
  204. LoadString(g_hInst, IDS_SECUREPATH, szTemp, DIMENSION(szTemp));
  205. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  206. lstrcat(szFields, szTemp);
  207. }
  208. }
  209. if (0 != lstrcmpi(g_OriginalSettings.szDisasterURL, g_CurrentSettings.szDisasterURL))
  210. {
  211. bOther = TRUE;
  212. LoadString(g_hInst, IDS_DISASTERURL, szTemp, DIMENSION(szTemp));
  213. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  214. lstrcat(szFields, szTemp);
  215. }
  216. }
  217. if (0 != lstrcmpi(g_OriginalSettings.szEnvName, g_CurrentSettings.szEnvName))
  218. {
  219. bOther = TRUE;
  220. LoadString(g_hInst, IDS_ENVNAME, szTemp, DIMENSION(szTemp));
  221. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  222. lstrcat(szFields, szTemp);
  223. }
  224. }
  225. if (0 != lstrcmpi(g_OriginalSettings.szHostName, g_CurrentSettings.szHostName))
  226. {
  227. bOther = TRUE;
  228. LoadString(g_hInst, IDS_HOSTNAME, szTemp, DIMENSION(szTemp));
  229. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  230. lstrcat(szFields, szTemp);
  231. }
  232. }
  233. if (0 != lstrcmpi(g_OriginalSettings.szHostIP, g_CurrentSettings.szHostIP))
  234. {
  235. bOther = TRUE;
  236. LoadString(g_hInst, IDS_HOSTIP, szTemp, DIMENSION(szTemp));
  237. if ((lstrlen(szFields) + lstrlen(szTemp)) < MAX_MESSAGE) {
  238. lstrcat(szFields, szTemp);
  239. }
  240. }
  241. if (bOther)
  242. {
  243. // Kill the final comma and space, since each of the above field names has a
  244. // comma and space for concatenation purposes
  245. szFields[lstrlen(szFields)-2] ='\0';
  246. SetDlgItemText(hWndDlg, IDC_OTHER_TYPE, szFields);
  247. }
  248. else
  249. {
  250. ShowWindow(GetDlgItem(hWndDlg,IDC_OTHER_TYPE), SW_HIDE);
  251. ShowWindow(GetDlgItem(hWndDlg,IDC_OTHER_WARN), SW_HIDE);
  252. }
  253. // See if DisableCookies has been changed
  254. if (g_OriginalSettings.dwDisableCookies == g_CurrentSettings.dwDisableCookies)
  255. {
  256. ShowWindow(GetDlgItem(hWndDlg,IDC_COOKIES_TYPE), SW_HIDE);
  257. ShowWindow(GetDlgItem(hWndDlg,IDC_COOKIES_WARN), SW_HIDE);
  258. }
  259. // See if SiteID has been changed
  260. if (g_OriginalSettings.dwSiteID == g_CurrentSettings.dwSiteID)
  261. {
  262. ShowWindow(GetDlgItem(hWndDlg,IDC_SITEID_TYPE), SW_HIDE);
  263. ShowWindow(GetDlgItem(hWndDlg,IDC_SITEID_WARN), SW_HIDE);
  264. }
  265. // See if StandAlone Mode has been changed
  266. if (g_OriginalSettings.dwStandAlone == g_CurrentSettings.dwStandAlone)
  267. {
  268. ShowWindow(GetDlgItem(hWndDlg,IDC_STANDALONE_TYPE), SW_HIDE);
  269. ShowWindow(GetDlgItem(hWndDlg,IDC_STANDALONE_WARN), SW_HIDE);
  270. }
  271. return TRUE;
  272. }
  273. case WM_COMMAND:
  274. {
  275. switch (LOWORD(wParam))
  276. {
  277. case IDOK:
  278. {
  279. EndDialog( hWndDlg, TRUE );
  280. break;
  281. }
  282. case IDCANCEL:
  283. {
  284. EndDialog( hWndDlg, FALSE );
  285. break;
  286. }
  287. }
  288. break;
  289. }
  290. }
  291. return FALSE;
  292. }