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.

713 lines
29 KiB

  1. #include "precomp.h"
  2. #define MSGR_MAX_URL MAX_PATH
  3. #define MSGR_MAX_BRAND 65
  4. #define MSGR_MAX_SHORTBRAND 33
  5. extern PROPSHEETPAGE g_psp[NUM_PAGES];
  6. extern TCHAR g_szBuildRoot[MAX_PATH];
  7. extern TCHAR g_szLanguage[];
  8. extern TCHAR g_szCustIns[MAX_PATH];
  9. extern TCHAR g_szTempSign[];
  10. extern int g_iCurPage;
  11. TCHAR g_szMsgrIns[MAX_PATH] = TEXT("");
  12. static TCHAR g_szMsgrPath[MAX_PATH] = TEXT("");
  13. static const TCHAR c_szEmpty[] = TEXT("");
  14. const TCHAR szHttpPrefix[] = TEXT("http://");
  15. const TCHAR g_szMSNBrand[] = TEXT("MSN Messenger Service");
  16. const TCHAR g_szHotmailDomain[] = TEXT("hotmail.com");
  17. const TCHAR g_szPassportDomain[] = TEXT("passport.com");
  18. BOOL RewriteMsgrInfWithBrand(LPTSTR lpszINF);
  19. INT_PTR CALLBACK MessengerDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  20. {
  21. TCHAR szBrand[MSGR_MAX_SHORTBRAND];
  22. TCHAR szDownload[MSGR_MAX_URL];
  23. TCHAR szProvider[MSGR_MAX_SHORTBRAND];
  24. UNREFERENCED_PARAMETER(wParam);
  25. switch (message)
  26. {
  27. case WM_INITDIALOG:
  28. //----- Set up the global goo -----
  29. g_hWizard = hDlg;
  30. //----- Set up dialog controls -----
  31. EnableDBCSChars(hDlg, IDE_MSGRBRAND);
  32. EnableDBCSChars(hDlg, IDE_MSGRDOWNLOAD);
  33. Edit_LimitText(GetDlgItem(hDlg, IDE_MSGRBRAND), MSGR_MAX_SHORTBRAND - 1);
  34. Edit_LimitText(GetDlgItem(hDlg, IDE_MSGRBRAND2), MSGR_MAX_SHORTBRAND - 1);
  35. Edit_LimitText(GetDlgItem(hDlg, IDE_MSGRDOWNLOAD), countof(szDownload)-1);
  36. // Simulate click on first radio button to gray out appropriate controls
  37. SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_BRAND1, BN_CLICKED), NULL);
  38. CheckRadioButton(hDlg, IDC_BRAND1, IDC_BRAND2, IDC_BRAND1);
  39. if (TEXT('\0') == g_szMsgrIns[0])
  40. {
  41. // Set up MSGR path and IN_ file
  42. StrCpy(g_szMsgrPath, g_szCustIns);
  43. PathRemoveFileSpec(g_szMsgrPath);
  44. PathCreatePath(g_szMsgrPath);
  45. PathCombine(g_szMsgrIns, g_szMsgrPath, TEXT("MSMSGS.IN_"));
  46. // First 7 chars of customization key written to this IN_ later.
  47. }
  48. break;
  49. case WM_HELP:
  50. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  51. break;
  52. case WM_NOTIFY:
  53. switch (((NMHDR FAR *)lParam)->code)
  54. {
  55. case PSN_SETACTIVE:
  56. //----- Standard prolog -----
  57. // Note. Another case of the global goo.
  58. SetBannerText(hDlg);
  59. //----- Initialization of fields -----
  60. SHGetIniString(IS_MESSENGER, IK_PROVIDERNAME, szProvider, countof(szProvider), g_szMsgrIns);
  61. SHGetIniString(IS_MESSENGER, IK_SHORTNAME, szBrand, countof(szBrand), g_szMsgrIns);
  62. StrRemoveWhitespace(szBrand);
  63. StrRemoveWhitespace(szProvider);
  64. if (*szProvider)
  65. {
  66. // Use Option 1--set the provider name
  67. SetDlgItemText(hDlg, IDE_MSGRBRAND, szProvider);
  68. }
  69. else if (*szBrand)
  70. {
  71. // Use Option 2--set the brand name
  72. SetDlgItemText(hDlg, IDE_MSGRBRAND2, szBrand);
  73. SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_BRAND2, BN_CLICKED), NULL);
  74. CheckRadioButton(hDlg, IDC_BRAND1, IDC_BRAND2, IDC_BRAND2);
  75. }
  76. GetPrivateProfileString(IS_MESSENGER, IK_DOWNLOAD, c_szEmpty, szDownload, countof(szDownload), g_szMsgrIns);
  77. StrRemoveWhitespace(szDownload);
  78. SetDlgItemText(hDlg, IDE_MSGRDOWNLOAD, szDownload);
  79. CheckBatchAdvance(hDlg); // standard line
  80. break;
  81. case PSN_WIZBACK:
  82. case PSN_WIZNEXT:
  83. case PSN_WIZFINISH:
  84. if (!CheckField(hDlg, IDE_MSGRDOWNLOAD, FC_URL))
  85. {
  86. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  87. break;
  88. }
  89. //----- Read data from controls into internal variables -----
  90. // The brand name is written via SHSetIniString to UTF7 encode Unicode. This is the only
  91. // parameter for which Unicode characters can be used.
  92. if (IsDlgButtonChecked(hDlg, IDC_BRAND1))
  93. {
  94. TCHAR szProvider[MSGR_MAX_SHORTBRAND];
  95. // In this case, short name is just "MSN Messenger Service"
  96. SHSetIniString(IS_MESSENGER, IK_SHORTNAME, g_szMSNBrand, g_szMsgrIns);
  97. GetDlgItemText(hDlg, IDE_MSGRBRAND, szProvider, countof(szProvider));
  98. StrRemoveWhitespace(szProvider);
  99. SHSetIniString(IS_MESSENGER, IK_PROVIDERNAME, szProvider, g_szMsgrIns);
  100. SHSetIniString(IS_MESSENGER, IK_SHORTNAME, c_szEmpty, g_szMsgrIns);
  101. }
  102. else
  103. {
  104. GetDlgItemText(hDlg, IDE_MSGRBRAND2, szBrand, countof(szBrand));
  105. StrRemoveWhitespace(szBrand);
  106. SHSetIniString(IS_MESSENGER, IK_SHORTNAME, szBrand, g_szMsgrIns);
  107. SHSetIniString(IS_MESSENGER, IK_PROVIDERNAME, c_szEmpty, g_szMsgrIns);
  108. }
  109. GetDlgItemText(hDlg, IDE_MSGRDOWNLOAD, szDownload, countof(szDownload));
  110. StrRemoveWhitespace(szDownload);
  111. //----- Serialize data to the *.ins file -----
  112. WritePrivateProfileString(IS_MESSENGER, IK_DOWNLOAD, szDownload, g_szMsgrIns);
  113. //----- Standard epilog -----
  114. // Note. Last and classical at that example of the global goo.
  115. g_iCurPage = PPAGE_MESSENGER;
  116. EnablePages();
  117. if (((LPNMHDR)lParam)->code == PSN_WIZNEXT)
  118. PageNext(hDlg);
  119. else if (((LPNMHDR)lParam)->code == PSN_WIZBACK)
  120. PagePrev(hDlg);
  121. break;
  122. case PSN_HELP:
  123. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  124. break;
  125. case PSN_QUERYCANCEL:
  126. return !QueryCancel(hDlg);
  127. default:
  128. return FALSE;
  129. }
  130. break;
  131. case WM_COMMAND:
  132. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  133. return FALSE;
  134. switch (GET_WM_COMMAND_ID(wParam, lParam))
  135. {
  136. case IDC_BRAND1:
  137. DisableDlgItem(hDlg, IDE_MSGRBRAND2);
  138. DisableDlgItem(hDlg, IDC_NAME2_STATIC);
  139. DisableDlgItem(hDlg, IDC_BRAND2_STATIC);
  140. EnableDlgItem(hDlg, IDC_NAME1_STATIC);
  141. EnableDlgItem(hDlg, IDE_MSGRBRAND);
  142. EnableDlgItem(hDlg, IDC_BRAND1_STATIC);
  143. break;
  144. case IDC_BRAND2:
  145. DisableDlgItem(hDlg, IDC_NAME1_STATIC);
  146. DisableDlgItem(hDlg, IDE_MSGRBRAND);
  147. DisableDlgItem(hDlg, IDC_BRAND1_STATIC);
  148. EnableDlgItem(hDlg, IDE_MSGRBRAND2);
  149. EnableDlgItem(hDlg, IDC_NAME2_STATIC);
  150. EnableDlgItem(hDlg, IDC_BRAND2_STATIC);
  151. break;
  152. }
  153. break;
  154. default:
  155. return FALSE;
  156. }
  157. return TRUE;
  158. }
  159. INT_PTR CALLBACK MessengerLogoSoundDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  160. {
  161. TCHAR szLogo[MAX_PATH];
  162. TCHAR szLogoLink[MSGR_MAX_URL];
  163. TCHAR szContactOnlineSound[MAX_PATH];
  164. TCHAR szNewEmailSound[MAX_PATH];
  165. TCHAR szNewMessageSound[MAX_PATH];
  166. TCHAR szXML[MSGR_MAX_URL];
  167. UNREFERENCED_PARAMETER(wParam);
  168. switch (message)
  169. {
  170. case WM_INITDIALOG:
  171. //----- Set up the global goo -----
  172. g_hWizard = hDlg;
  173. EnableDBCSChars(hDlg, IDE_LOGO);
  174. EnableDBCSChars(hDlg, IDE_MSGRWEBLINK);
  175. EnableDBCSChars(hDlg, IDE_CONTACTONLINE);
  176. EnableDBCSChars(hDlg, IDE_NEWEMAIL);
  177. EnableDBCSChars(hDlg, IDE_NEWMESSAGE );
  178. EnableDBCSChars(hDlg, IDE_XMLURL );
  179. //----- Set up dialog controls -----
  180. Edit_LimitText(GetDlgItem(hDlg, IDE_LOGO), countof(szLogo)-1);
  181. Edit_LimitText(GetDlgItem(hDlg, IDE_MSGRWEBLINK), countof(szLogoLink)-1);
  182. Edit_LimitText(GetDlgItem(hDlg, IDE_CONTACTONLINE), countof(szContactOnlineSound)-1);
  183. Edit_LimitText(GetDlgItem(hDlg, IDE_NEWEMAIL), countof(szNewEmailSound)-1);
  184. Edit_LimitText(GetDlgItem(hDlg, IDE_NEWMESSAGE), countof(szNewMessageSound)-1);
  185. Edit_LimitText(GetDlgItem(hDlg, IDE_XMLURL), countof(szXML)-1);
  186. break;
  187. case WM_HELP:
  188. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  189. break;
  190. case WM_NOTIFY:
  191. switch (((NMHDR FAR *)lParam)->code)
  192. {
  193. case PSN_SETACTIVE:
  194. //----- Standard prolog -----
  195. // Note. Another case of the global goo.
  196. SetBannerText(hDlg);
  197. //----- Initialization of fields -----
  198. // BUGBUG: sounds path storage?
  199. GetPrivateProfileString(IS_MESSENGER, IK_PRODUCTLINK, c_szEmpty, szLogoLink, countof(szLogoLink), g_szMsgrIns);
  200. GetPrivateProfileString(IS_MESSENGER, IK_PARTNERLOGO, c_szEmpty, szLogo, countof(szLogo), g_szMsgrIns);
  201. GetPrivateProfileString(IS_MESSENGER, IK_CONTACTONLINE, c_szEmpty, szContactOnlineSound, countof(szContactOnlineSound), g_szMsgrIns);
  202. GetPrivateProfileString(IS_MESSENGER, IK_NEWEMAIL, c_szEmpty, szNewEmailSound, countof(szNewEmailSound), g_szMsgrIns);
  203. GetPrivateProfileString(IS_MESSENGER, IK_INCOMINGIM, c_szEmpty, szNewMessageSound, countof(szNewMessageSound), g_szMsgrIns);
  204. GetPrivateProfileString(IS_MESSENGER, IK_XMLLINK, c_szEmpty, szXML, countof(szXML), g_szMsgrIns);
  205. StrRemoveWhitespace(szLogoLink);
  206. StrRemoveWhitespace(szLogo);
  207. StrRemoveWhitespace(szContactOnlineSound);
  208. StrRemoveWhitespace(szNewEmailSound);
  209. StrRemoveWhitespace(szNewMessageSound);
  210. StrRemoveWhitespace(szXML);
  211. SetDlgItemText(hDlg, IDE_MSGRWEBLINK, szLogoLink);
  212. SetDlgItemText(hDlg, IDE_LOGO, szLogo);
  213. SetDlgItemText(hDlg, IDE_CONTACTONLINE, szContactOnlineSound);
  214. SetDlgItemText(hDlg, IDE_NEWEMAIL, szNewEmailSound);
  215. SetDlgItemText(hDlg, IDE_NEWMESSAGE, szNewMessageSound);
  216. SetDlgItemText(hDlg, IDE_XMLURL, szXML);
  217. CheckBatchAdvance(hDlg); // standard line
  218. break;
  219. case PSN_WIZBACK:
  220. case PSN_WIZNEXT:
  221. case PSN_WIZFINISH:
  222. if (!CheckField(hDlg, IDE_MSGRWEBLINK, FC_URL) ||
  223. !CheckField(hDlg, IDE_LOGO, FC_FILE | FC_EXISTS) ||
  224. !CheckField(hDlg, IDE_CONTACTONLINE, FC_FILE | FC_EXISTS) ||
  225. !CheckField(hDlg, IDE_NEWEMAIL, FC_FILE | FC_EXISTS) ||
  226. !CheckField(hDlg, IDE_NEWMESSAGE, FC_FILE | FC_EXISTS) ||
  227. !CheckField(hDlg, IDE_XMLURL, FC_URL))
  228. {
  229. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  230. break;
  231. }
  232. //----- Read data from controls into internal variables -----
  233. GetDlgItemText(hDlg, IDE_LOGO, szLogo, countof(szLogo));
  234. GetDlgItemText(hDlg, IDE_MSGRWEBLINK, szLogoLink, countof(szLogoLink));
  235. GetDlgItemText(hDlg, IDE_CONTACTONLINE, szContactOnlineSound, countof(szContactOnlineSound));
  236. GetDlgItemText(hDlg, IDE_NEWEMAIL, szNewEmailSound, countof(szNewEmailSound));
  237. GetDlgItemText(hDlg, IDE_NEWMESSAGE, szNewMessageSound, countof(szNewMessageSound));
  238. GetDlgItemText(hDlg, IDE_XMLURL, szXML, countof(szXML));
  239. StrRemoveWhitespace(szLogo);
  240. StrRemoveWhitespace(szLogoLink);
  241. StrRemoveWhitespace(szContactOnlineSound);
  242. StrRemoveWhitespace(szNewEmailSound);
  243. StrRemoveWhitespace(szNewMessageSound);
  244. StrRemoveWhitespace(szXML);
  245. //----- Serialize data to the *.ins file -----
  246. WritePrivateProfileString(IS_MESSENGER, IK_PRODUCTLINK, szLogoLink, g_szMsgrIns);
  247. WritePrivateProfileString(IS_MESSENGER, IK_PARTNERLOGO, szLogo, g_szMsgrIns);
  248. WritePrivateProfileString(IS_MESSENGER, IK_CONTACTONLINE, szContactOnlineSound, g_szMsgrIns);
  249. WritePrivateProfileString(IS_MESSENGER, IK_NEWEMAIL, szNewEmailSound, g_szMsgrIns);
  250. WritePrivateProfileString(IS_MESSENGER, IK_INCOMINGIM, szNewMessageSound, g_szMsgrIns);
  251. WritePrivateProfileString(IS_MESSENGER, IK_XMLLINK, szXML, g_szMsgrIns);
  252. //----- Standard epilog -----
  253. // Note. Last and classical at that example of the global goo.
  254. g_iCurPage = PPAGE_LOGOSOUND;
  255. EnablePages();
  256. if (((LPNMHDR)lParam)->code == PSN_WIZNEXT)
  257. PageNext(hDlg);
  258. else if (((LPNMHDR)lParam)->code == PSN_WIZBACK)
  259. PagePrev(hDlg);
  260. break;
  261. case PSN_HELP:
  262. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  263. break;
  264. case PSN_QUERYCANCEL:
  265. return !QueryCancel(hDlg);
  266. default:
  267. return FALSE;
  268. }
  269. break;
  270. case WM_COMMAND:
  271. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  272. return FALSE;
  273. switch (GET_WM_COMMAND_ID(wParam, lParam))
  274. {
  275. case IDC_BROWSELOGO:
  276. GetDlgItemText(hDlg, IDE_LOGO, szLogo, countof(szLogo));
  277. if (BrowseForFile(hDlg, szLogo, countof(szLogo), GFN_GIF))
  278. SetDlgItemText(hDlg, IDE_LOGO, szLogo);
  279. break;
  280. case IDC_BROWSEONLINE:
  281. GetDlgItemText(hDlg, IDE_CONTACTONLINE, szContactOnlineSound, countof(szContactOnlineSound));
  282. if (BrowseForFile(hDlg, szContactOnlineSound, countof(szContactOnlineSound), GFN_WAV))
  283. SetDlgItemText(hDlg, IDE_CONTACTONLINE, szContactOnlineSound);
  284. break;
  285. case IDC_BROWSENEWEMAIL:
  286. GetDlgItemText(hDlg, IDE_NEWEMAIL, szNewEmailSound, countof(szNewEmailSound));
  287. if (BrowseForFile(hDlg, szNewEmailSound, countof(szNewEmailSound), GFN_WAV))
  288. SetDlgItemText(hDlg, IDE_NEWEMAIL, szNewEmailSound);
  289. break;
  290. case IDC_BROWSENEWMESSAGE:
  291. GetDlgItemText(hDlg, IDE_NEWMESSAGE, szNewMessageSound, countof(szNewMessageSound));
  292. if (BrowseForFile(hDlg, szNewMessageSound, countof(szNewMessageSound), GFN_WAV))
  293. SetDlgItemText(hDlg, IDE_NEWMESSAGE, szNewMessageSound);
  294. break;
  295. }
  296. break;
  297. default:
  298. return FALSE;
  299. }
  300. return TRUE;
  301. }
  302. INT_PTR CALLBACK MessengerAccountsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  303. {
  304. TCHAR szSignup[MSGR_MAX_URL];
  305. TCHAR szMailServer[MAX_PATH];
  306. TCHAR szDefaultDomain[MAX_PATH];
  307. UNREFERENCED_PARAMETER(wParam);
  308. switch (message)
  309. {
  310. case WM_INITDIALOG:
  311. //----- Set up the global goo -----
  312. g_hWizard = hDlg;
  313. //----- Set up dialog controls -----
  314. EnableDBCSChars(hDlg, IDE_SIGNUP);
  315. EnableDBCSChars(hDlg, IDE_POPSERVER);
  316. EnableDBCSChars(hDlg, IDE_MAILURL);
  317. Edit_LimitText(GetDlgItem(hDlg, IDE_SIGNUP), countof(szSignup)-1);
  318. Edit_LimitText(GetDlgItem(hDlg, IDE_POPSERVER), countof(szMailServer)-1);
  319. Edit_LimitText(GetDlgItem(hDlg, IDC_DOMAINCOMBO), countof(szDefaultDomain)-1);
  320. Edit_LimitText(GetDlgItem(hDlg, IDE_MAILURL), countof(szMailServer)-1);
  321. SendDlgItemMessage(hDlg, IDC_DOMAINCOMBO, CB_ADDSTRING, 0, (LPARAM) g_szHotmailDomain);
  322. SendDlgItemMessage(hDlg, IDC_DOMAINCOMBO, CB_ADDSTRING, 0, (LPARAM) g_szPassportDomain);
  323. SendDlgItemMessage(hDlg, IDC_DOMAINCOMBO, CB_SETCURSEL, 0, 0);
  324. break;
  325. case WM_HELP:
  326. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  327. break;
  328. case WM_NOTIFY:
  329. switch (((NMHDR FAR *)lParam)->code)
  330. {
  331. case PSN_SETACTIVE:
  332. {
  333. //----- Standard prolog -----
  334. // Note. Another case of the global goo.
  335. SetBannerText(hDlg);
  336. //----- Initialization of fields -----
  337. GetPrivateProfileString(IS_MESSENGER, IK_PPSIGNUP, c_szEmpty, szSignup, countof(szSignup), g_szMsgrIns);
  338. GetPrivateProfileString(IS_MESSENGER, IK_PPDOMAIN, c_szEmpty, szDefaultDomain, countof(szDefaultDomain), g_szMsgrIns);
  339. StrRemoveWhitespace(szSignup);
  340. StrRemoveWhitespace(szDefaultDomain);
  341. SetDlgItemText(hDlg, IDE_SIGNUP, szSignup);
  342. TCHAR szMailFunction[2];
  343. GetPrivateProfileString(IS_MESSENGER, IK_MAILFUNCTION, c_szEmpty, szMailFunction, countof(szMailFunction), g_szMsgrIns);
  344. if (TEXT('1') == *szMailFunction) // 1 == POP mail
  345. {
  346. GetPrivateProfileString(IS_MESSENGER, IK_MAILSERVER, c_szEmpty, szMailServer, countof(szMailServer), g_szMsgrIns);
  347. StrRemoveWhitespace(szMailServer);
  348. SetDlgItemText(hDlg, IDE_POPSERVER, szMailServer);
  349. TCHAR szSPA[2];
  350. GetPrivateProfileString(IS_MESSENGER, IK_MAILSPA, c_szEmpty, szSPA, countof(szSPA), g_szMsgrIns);
  351. if (TEXT('1') == *szSPA)
  352. {
  353. CheckDlgButton(hDlg, IDC_MSGRSPA, BST_CHECKED);
  354. }
  355. else
  356. {
  357. CheckDlgButton(hDlg, IDC_MSGRSPA, BST_UNCHECKED);
  358. }
  359. // Simulate click on radio button to gray out appropriate controls
  360. SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_RADIO_MAILSERVER, BN_CLICKED), NULL);
  361. CheckRadioButton(hDlg, IDC_RADIO_HOTMAIL, IDC_RADIO_MAILSERVER, IDC_RADIO_MAILSERVER);
  362. }
  363. else if (TEXT('2') == *szMailFunction) // 2 = URL mail
  364. {
  365. GetPrivateProfileString(IS_MESSENGER, IK_MAILURL, c_szEmpty, szMailServer, countof(szMailServer), g_szMsgrIns);
  366. StrRemoveWhitespace(szMailServer);
  367. SetDlgItemText(hDlg, IDE_MAILURL, szMailServer);
  368. // Simulate click on radio button to gray out appropriate controls
  369. SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_RADIO_URL, BN_CLICKED), NULL);
  370. CheckRadioButton(hDlg, IDC_RADIO_HOTMAIL, IDC_RADIO_MAILSERVER, IDC_RADIO_URL);
  371. }
  372. else
  373. {
  374. // Simulate click on first radio button to gray out appropriate controls
  375. SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_RADIO_HOTMAIL, BN_CLICKED), NULL);
  376. CheckRadioButton(hDlg, IDC_RADIO_HOTMAIL, IDC_RADIO_MAILSERVER, IDC_RADIO_HOTMAIL);
  377. }
  378. if (*szDefaultDomain)
  379. {
  380. SetDlgItemText(hDlg, IDC_DOMAINCOMBO, szDefaultDomain);
  381. }
  382. CheckBatchAdvance(hDlg); // standard line
  383. break;
  384. }
  385. case PSN_WIZBACK:
  386. case PSN_WIZNEXT:
  387. case PSN_WIZFINISH:
  388. if (!CheckField(hDlg, IDE_SIGNUP, FC_URL) ||
  389. !CheckField(hDlg, IDC_DOMAINCOMBO, FC_NOSPACE))
  390. {
  391. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  392. break;
  393. }
  394. //----- Read data from controls into internal variables -----
  395. if (IsDlgButtonChecked(hDlg, IDC_RADIO_URL))
  396. {
  397. if (!CheckField(hDlg, IDE_MAILURL, FC_URL | FC_NONNULL))
  398. {
  399. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  400. break;
  401. }
  402. GetDlgItemText(hDlg, IDE_MAILURL, szMailServer, countof(szMailServer));
  403. StrRemoveWhitespace(szMailServer);
  404. WritePrivateProfileString(IS_MESSENGER, IK_MAILURL, szMailServer, g_szMsgrIns);
  405. WritePrivateProfileString(IS_MESSENGER, IK_MAILSERVER, c_szEmpty, g_szMsgrIns);
  406. // 2 signifies URL Mail integration
  407. WritePrivateProfileString(IS_MESSENGER, IK_MAILFUNCTION, TEXT("2"), g_szMsgrIns);
  408. WritePrivateProfileString(IS_MESSENGER, IK_MAILSPA, TEXT("0"), g_szMsgrIns);
  409. }
  410. else if (IsDlgButtonChecked(hDlg, IDC_RADIO_MAILSERVER))
  411. {
  412. if (!CheckField(hDlg, IDE_POPSERVER, FC_NOSPACE))
  413. {
  414. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  415. break;
  416. }
  417. GetDlgItemText(hDlg, IDE_POPSERVER, szMailServer, countof(szMailServer));
  418. StrRemoveWhitespace(szMailServer);
  419. WritePrivateProfileString(IS_MESSENGER, IK_MAILSERVER, szMailServer, g_szMsgrIns);
  420. WritePrivateProfileString(IS_MESSENGER, IK_MAILURL, c_szEmpty, g_szMsgrIns);
  421. // 1 signifies POP Mail integration
  422. WritePrivateProfileString(IS_MESSENGER, IK_MAILFUNCTION, TEXT("1"), g_szMsgrIns);
  423. WritePrivateProfileString( IS_MESSENGER,
  424. IK_MAILSPA,
  425. IsDlgButtonChecked(hDlg, IDC_MSGRSPA) ? TEXT("1") : TEXT("0"),
  426. g_szMsgrIns);
  427. }
  428. else
  429. {
  430. WritePrivateProfileString(IS_MESSENGER, IK_MAILSERVER, c_szEmpty, g_szMsgrIns);
  431. WritePrivateProfileString(IS_MESSENGER, IK_MAILURL, c_szEmpty, g_szMsgrIns);
  432. // 0 signifies Hotmail Mail integration
  433. WritePrivateProfileString(IS_MESSENGER, IK_MAILFUNCTION, TEXT("0"), g_szMsgrIns);
  434. WritePrivateProfileString(IS_MESSENGER, IK_MAILSPA, TEXT("0"), g_szMsgrIns);
  435. }
  436. GetDlgItemText(hDlg, IDE_SIGNUP, szSignup, countof(szSignup));
  437. GetDlgItemText(hDlg, IDC_DOMAINCOMBO, szDefaultDomain, countof(szDefaultDomain));
  438. StrRemoveWhitespace(szSignup);
  439. StrRemoveWhitespace(szDefaultDomain);
  440. //----- Serialize data to the *.ins file -----
  441. WritePrivateProfileString(IS_MESSENGER, IK_PPSIGNUP, szSignup, g_szMsgrIns);
  442. WritePrivateProfileString(IS_MESSENGER, IK_PPDOMAIN, szDefaultDomain, g_szMsgrIns);
  443. WritePrivateProfileString(IS_MESSENGER, IK_PPSUFFIX, szDefaultDomain, g_szMsgrIns);
  444. //----- Standard epilog -----
  445. // Note. Last and classical at that example of the global goo.
  446. g_iCurPage = PPAGE_MSGRACCOUNTS;
  447. EnablePages();
  448. if (((LPNMHDR)lParam)->code == PSN_WIZNEXT)
  449. PageNext(hDlg);
  450. else if (((LPNMHDR)lParam)->code == PSN_WIZBACK)
  451. PagePrev(hDlg);
  452. break;
  453. case PSN_HELP:
  454. IeakPageHelp(hDlg, g_psp[g_iCurPage].pszTemplate);
  455. break;
  456. case PSN_QUERYCANCEL:
  457. return !QueryCancel(hDlg);
  458. default:
  459. return FALSE;
  460. }
  461. break;
  462. case WM_COMMAND:
  463. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  464. return FALSE;
  465. switch (GET_WM_COMMAND_ID(wParam, lParam))
  466. {
  467. case IDC_RADIO_HOTMAIL:
  468. DisableDlgItem(hDlg, IDC_MAILURL_STATIC);
  469. DisableDlgItem(hDlg, IDE_MAILURL);
  470. DisableDlgItem(hDlg, IDE_POPSERVER);
  471. DisableDlgItem(hDlg, IDC_MAILSERVER_STATIC);
  472. DisableDlgItem(hDlg, IDC_MSGRSPA);
  473. break;
  474. case IDC_RADIO_MAILSERVER:
  475. DisableDlgItem(hDlg, IDC_MAILURL_STATIC);
  476. DisableDlgItem(hDlg, IDE_MAILURL);
  477. EnableDlgItem(hDlg, IDE_POPSERVER);
  478. EnableDlgItem(hDlg, IDC_MAILSERVER_STATIC);
  479. EnableDlgItem(hDlg, IDC_MSGRSPA);
  480. break;
  481. case IDC_RADIO_URL:
  482. EnableDlgItem(hDlg, IDC_MAILURL_STATIC);
  483. EnableDlgItem(hDlg, IDE_MAILURL);
  484. DisableDlgItem(hDlg, IDE_POPSERVER);
  485. DisableDlgItem(hDlg, IDC_MAILSERVER_STATIC);
  486. DisableDlgItem(hDlg, IDC_MSGRSPA);
  487. break;
  488. }
  489. break;
  490. default:
  491. return FALSE;
  492. }
  493. return TRUE;
  494. }
  495. const CHAR g_szEmbeddedStrings[] = "[Strings.Embedded]";
  496. BOOL RewriteMsgrInfWithBrand(LPTSTR lpszINF)
  497. {
  498. BOOL bRet = FALSE;
  499. TCHAR szBrand[MSGR_MAX_SHORTBRAND];
  500. GetPrivateProfileString(IS_MESSENGER, IK_SHORTNAME, c_szEmpty, szBrand, countof(szBrand), g_szMsgrIns);
  501. CHAR szaBrand[MSGR_MAX_SHORTBRAND];
  502. T2Abux(szBrand, szaBrand);
  503. // Replace the brand in the INF, as specified by the PGMITEM_MSMSGS field
  504. TCHAR szOldBrand[MSGR_MAX_SHORTBRAND];
  505. GetPrivateProfileString(TEXT("Strings"), TEXT("PGMITEM_MSMSGS"), c_szEmpty, szOldBrand, countof(szOldBrand), lpszINF);
  506. // because we're mixing ini string functions with binary file operations
  507. WritePrivateProfileString(NULL, NULL, NULL, lpszINF);
  508. CHAR szaOldBrand[MSGR_MAX_SHORTBRAND];
  509. T2Abux(szOldBrand, szaOldBrand);
  510. ASSERT(*szaOldBrand && *szaBrand && "Both of these parameters should be valid when RewriteMsgrInfWithBrand is called");
  511. if (*szaOldBrand && *szaBrand)
  512. {
  513. CHAR szaINFBrand[MSGR_MAX_SHORTBRAND*4];
  514. StrCpyA(szaINFBrand, szaBrand);
  515. HANDLE hFile = ::CreateFile(lpszINF, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  516. if (INVALID_HANDLE_VALUE != hFile)
  517. {
  518. DWORD dwSize = ::GetFileSize(hFile, NULL);
  519. if (dwSize)
  520. {
  521. LPSTR lpszData = new CHAR[dwSize + 1];
  522. if (lpszData)
  523. {
  524. ULONG nRead;
  525. if (ReadFile(hFile, lpszData, dwSize, &nRead, NULL))
  526. {
  527. // Null terminate the data
  528. lpszData[nRead] = '\0';
  529. // Reset the file pointer so we can write the branded INF data
  530. // over the old data.
  531. SetFilePointer(hFile, 0, 0, FILE_BEGIN);
  532. LPSTR pszEmbeddedStrings = StrStrA(lpszData, g_szEmbeddedStrings);
  533. // Write data up until an occurrence of the old brand name, replace the old brand name with the new
  534. // brand name, and loop.
  535. LPSTR lpszDataStart = lpszData, lpszDataEnd;
  536. DWORD dwBytesWritten;
  537. BOOL fPassedEmbedded = FALSE;
  538. while (NULL != (lpszDataEnd = StrStrA(lpszDataStart, szaOldBrand)))
  539. {
  540. // If we pass the [Strings.Embedded] section header,
  541. // that means all occurrences of the brand from here on are
  542. // embedded, so we need to quadruple the quotes.
  543. if (!fPassedEmbedded && pszEmbeddedStrings &&
  544. lpszDataEnd > pszEmbeddedStrings)
  545. {
  546. LPSTR pszTemp = szaINFBrand, pszSrc = szaBrand;
  547. fPassedEmbedded = TRUE;
  548. // Need to write FOUR of either kind of quote to make it show up correctly in the INF
  549. // in the embedded strings
  550. while (*pszSrc)
  551. {
  552. if ('\'' == *pszSrc || '\"' == *pszSrc)
  553. {
  554. *pszTemp++ = *pszSrc;
  555. *pszTemp++ = *pszSrc;
  556. *pszTemp++ = *pszSrc;
  557. }
  558. *pszTemp++ = *pszSrc++;
  559. }
  560. *pszTemp = '\0';
  561. }
  562. WriteFile(hFile, lpszDataStart, (DWORD)(lpszDataEnd - lpszDataStart), &dwBytesWritten, NULL);
  563. WriteFile(hFile, szaINFBrand, lstrlenA(szaINFBrand), &dwBytesWritten, NULL);
  564. lpszDataStart = lpszDataEnd + lstrlenA(szaOldBrand);
  565. }
  566. // Write the rest of the data after the last occurrence of the old brand name.
  567. WriteFile(hFile, lpszDataStart, dwSize - (DWORD)(lpszDataStart - lpszData), &dwBytesWritten, NULL);
  568. bRet = SetEndOfFile(hFile);
  569. }
  570. }
  571. }
  572. // because we're mixing ini string functions with binary file operations
  573. FlushFileBuffers(hFile);
  574. CloseHandle(hFile);
  575. }
  576. }
  577. return bRet;
  578. }