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.

1471 lines
61 KiB

  1. #include "pch.h"
  2. #define MAX_SERVER 256
  3. static const TCHAR c_sz1[] = TEXT("1");
  4. static const TCHAR c_sz0[] = TEXT("0");
  5. static const TCHAR c_szYes[] = TEXT("Yes");
  6. static const TCHAR c_szNo[] = TEXT("No");
  7. static const TCHAR c_szEmpty[] = TEXT("");
  8. static const TCHAR c_szNULL[] = TEXT("NULL");
  9. /////////////////////////////////////////////////////////////////////////////
  10. // MailServer
  11. INT_PTR CALLBACK MailServer(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  12. {
  13. TCHAR szMailServer[MAX_SERVER],
  14. szSMTPServer[MAX_SERVER],
  15. szNewsServer[MAX_SERVER],
  16. szChoice[16];
  17. LPCTSTR pszKey;
  18. HWND hComboBox;
  19. BOOL fIMAP, fCheckDirtyOnly,
  20. fSPAMail, fSPASMTP, fSPANNTP,
  21. fAcctRO, fNoModify;
  22. switch(msg)
  23. {
  24. case WM_INITDIALOG:
  25. //----- Set up dialog controls -----
  26. EnableDBCSChars(hDlg, IDE_MAILSERVER);
  27. EnableDBCSChars(hDlg, IDE_SMTPSERVER);
  28. EnableDBCSChars(hDlg, IDE_NEWSERVER);
  29. Edit_LimitText(GetDlgItem(hDlg, IDE_MAILSERVER), countof(szMailServer)-1);
  30. Edit_LimitText(GetDlgItem(hDlg, IDE_SMTPSERVER), countof(szSMTPServer)-1);
  31. Edit_LimitText(GetDlgItem(hDlg, IDE_NEWSERVER), countof(szNewsServer)-1);
  32. hComboBox = GetDlgItem(hDlg, IDC_POPIMAP);
  33. ComboBox_ResetContent(hComboBox);
  34. LoadString(g_hInst, IDS_POP3, szChoice, countof(szChoice));
  35. ComboBox_AddString(hComboBox, szChoice);
  36. LoadString(g_hInst, IDS_IMAP, szChoice, countof(szChoice));
  37. ComboBox_AddString(hComboBox, szChoice);
  38. //----- Initialization of fields -----
  39. fIMAP = InsGetYesNo(IS_INTERNETMAIL, IK_USEIMAP, FALSE, g_szInsFile);
  40. pszKey = fIMAP ? IK_IMAPSERVER : IK_POPSERVER;
  41. GetPrivateProfileString(IS_INTERNETMAIL, pszKey, c_szEmpty, szMailServer, countof(szMailServer), g_szInsFile);
  42. GetPrivateProfileString(IS_INTERNETMAIL, IK_SMTPSERVER, c_szEmpty, szSMTPServer, countof(szSMTPServer), g_szInsFile);
  43. GetPrivateProfileString(IS_INTERNETNEWS, IK_NNTPSERVER, c_szEmpty, szNewsServer, countof(szNewsServer), g_szInsFile);
  44. StrRemoveWhitespace(szMailServer);
  45. StrRemoveWhitespace(szSMTPServer);
  46. StrRemoveWhitespace(szNewsServer);
  47. fSPAMail = InsGetYesNo(IS_INTERNETMAIL, IK_USESPA, FALSE, g_szInsFile);
  48. fSPASMTP = InsGetYesNo(IS_INTERNETMAIL, IK_SMTPUSESPA, FALSE, g_szInsFile);
  49. fSPANNTP = InsGetYesNo(IS_INTERNETNEWS, IK_USESPA, FALSE, g_szInsFile);
  50. fAcctRO = InsGetYesNo(IS_OEGLOBAL, IK_READONLY, FALSE, g_szInsFile);
  51. fNoModify = InsGetYesNo(IS_OEGLOBAL, IK_NOMODIFYACCTS, FALSE, g_szInsFile);
  52. SetDlgItemText(hDlg, IDE_MAILSERVER, szMailServer);
  53. SetDlgItemText(hDlg, IDE_SMTPSERVER, szSMTPServer);
  54. SetDlgItemText(hDlg, IDE_NEWSERVER, szNewsServer);
  55. CheckDlgButton(hDlg, IDC_USESPAMAIL, fSPAMail);
  56. CheckDlgButton(hDlg, IDC_USESPASMTP, fSPASMTP);
  57. CheckDlgButton(hDlg, IDC_USESPANNTP, fSPANNTP);
  58. CheckDlgButton(hDlg, IDC_ACCTRO, fAcctRO);
  59. CheckDlgButton(hDlg, IDC_ACCTNOCONFIG, fNoModify);
  60. ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_POPIMAP), fIMAP ? 1 : 0);
  61. break;
  62. case UM_SAVE:
  63. fCheckDirtyOnly = (BOOL) lParam;
  64. //----- Read data from controls into internal variables -----
  65. fIMAP = (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_POPIMAP)) > 0);
  66. GetDlgItemText(hDlg, IDE_MAILSERVER, szMailServer, countof(szMailServer));
  67. GetDlgItemText(hDlg, IDE_SMTPSERVER, szSMTPServer, countof(szSMTPServer));
  68. GetDlgItemText(hDlg, IDE_NEWSERVER, szNewsServer, countof(szNewsServer));
  69. StrRemoveWhitespace(szMailServer);
  70. StrRemoveWhitespace(szSMTPServer);
  71. StrRemoveWhitespace(szNewsServer);
  72. fSPAMail = IsDlgButtonChecked(hDlg, IDC_USESPAMAIL);
  73. fSPASMTP = IsDlgButtonChecked(hDlg, IDC_USESPASMTP);
  74. fSPANNTP = IsDlgButtonChecked(hDlg, IDC_USESPANNTP);
  75. fAcctRO = IsDlgButtonChecked(hDlg, IDC_ACCTRO);
  76. fNoModify = IsDlgButtonChecked(hDlg, IDC_ACCTNOCONFIG);
  77. //----- Handle g_fInsDirty flag -----
  78. if (!g_fInsDirty)
  79. {
  80. TCHAR szWasMailServer[MAX_SERVER],
  81. szWasSMTPServer[MAX_SERVER],
  82. szWasNewsServer[MAX_SERVER];
  83. BOOL fWasIMAP, fWasSPAMail, fWasSPASMTP, fWasSPANNTP,
  84. fWasAcctRO, fWasNoModify;
  85. fWasIMAP = InsGetYesNo(IS_INTERNETMAIL, IK_USEIMAP, FALSE, g_szInsFile);
  86. pszKey = fWasIMAP ? IK_IMAPSERVER : IK_POPSERVER;
  87. GetPrivateProfileString(IS_INTERNETMAIL, pszKey, c_szEmpty, szWasMailServer, countof(szWasMailServer), g_szInsFile);
  88. GetPrivateProfileString(IS_INTERNETMAIL, IK_SMTPSERVER, c_szEmpty, szWasSMTPServer, countof(szWasSMTPServer), g_szInsFile);
  89. GetPrivateProfileString(IS_INTERNETNEWS, IK_NNTPSERVER, c_szEmpty, szWasNewsServer, countof(szWasNewsServer), g_szInsFile);
  90. StrRemoveWhitespace(szWasMailServer);
  91. StrRemoveWhitespace(szWasSMTPServer);
  92. StrRemoveWhitespace(szWasNewsServer);
  93. fWasSPAMail = InsGetYesNo(IS_INTERNETMAIL, IK_USESPA, FALSE, g_szInsFile);
  94. fWasSPASMTP = InsGetYesNo(IS_INTERNETMAIL, IK_SMTPUSESPA, FALSE, g_szInsFile);
  95. fWasSPANNTP = InsGetYesNo(IS_INTERNETNEWS, IK_USESPA, FALSE, g_szInsFile);
  96. fWasAcctRO = InsGetYesNo(IS_OEGLOBAL, IK_READONLY, FALSE, g_szInsFile);
  97. fWasNoModify = InsGetYesNo(IS_OEGLOBAL, IK_NOMODIFYACCTS, FALSE, g_szInsFile);
  98. if (fIMAP != fWasIMAP ||
  99. fSPAMail != fWasSPAMail ||
  100. fSPASMTP != fWasSPASMTP ||
  101. fSPANNTP != fWasSPANNTP ||
  102. fAcctRO != fWasAcctRO ||
  103. fNoModify != fWasNoModify ||
  104. StrCmpI(szMailServer, szWasMailServer) != 0 ||
  105. StrCmpI(szSMTPServer, szWasSMTPServer) != 0 ||
  106. StrCmpI(szNewsServer, szWasNewsServer) != 0)
  107. g_fInsDirty = TRUE;
  108. }
  109. //----- Serialize data to the *.ins file -----
  110. if (!fCheckDirtyOnly)
  111. {
  112. WritePrivateProfileString(IS_INTERNETMAIL, IK_USEIMAP, fIMAP ? c_szYes : c_szNo, g_szInsFile);
  113. if (fIMAP)
  114. {
  115. WritePrivateProfileString(IS_INTERNETMAIL, IK_IMAPSERVER, szMailServer, g_szInsFile);
  116. WritePrivateProfileString(IS_INTERNETMAIL, IK_POPSERVER, NULL, g_szInsFile);
  117. }
  118. else
  119. {
  120. WritePrivateProfileString(IS_INTERNETMAIL, IK_IMAPSERVER, NULL, g_szInsFile);
  121. WritePrivateProfileString(IS_INTERNETMAIL, IK_POPSERVER, szMailServer, g_szInsFile);
  122. }
  123. WritePrivateProfileString(IS_INTERNETMAIL, IK_SMTPSERVER, szSMTPServer, g_szInsFile);
  124. WritePrivateProfileString(IS_INTERNETNEWS, IK_NNTPSERVER, szNewsServer, g_szInsFile);
  125. WritePrivateProfileString(IS_INTERNETMAIL, IK_USESPA, fSPAMail ? c_szYes : c_szNo, g_szInsFile);
  126. WritePrivateProfileString(IS_INTERNETMAIL, IK_SMTPUSESPA, fSPASMTP ? c_szYes : c_szNo, g_szInsFile);
  127. WritePrivateProfileString(IS_INTERNETMAIL, IK_SMTPREQLOGON, fSPASMTP ? c_sz1 : c_sz0, g_szInsFile);
  128. WritePrivateProfileString(IS_INTERNETNEWS, IK_USESPA, fSPANNTP ? c_szYes : c_szNo, g_szInsFile);
  129. WritePrivateProfileString(IS_INTERNETNEWS, IK_REQLOGON, fSPANNTP ? c_sz1 : c_sz0, g_szInsFile);
  130. WritePrivateProfileString(IS_OEGLOBAL, IK_READONLY, fAcctRO ? c_sz1 : c_sz0, g_szInsFile);
  131. WritePrivateProfileString(IS_OEGLOBAL, IK_NOMODIFYACCTS,fNoModify ? c_sz1 : c_sz0, g_szInsFile);
  132. }
  133. *((LPBOOL)wParam) = TRUE;
  134. break;
  135. case WM_CLOSE:
  136. DestroyWindow(hDlg);
  137. break;
  138. default:
  139. return FALSE;
  140. }
  141. return TRUE;
  142. }
  143. /////////////////////////////////////////////////////////////////////////////
  144. // IMAPSettings
  145. INT_PTR CALLBACK IMAPSettings(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  146. {
  147. TCHAR szRFP[MAX_PATH], szSentPath[MAX_PATH], szDrafts[MAX_PATH];
  148. BOOL fSpecial, fCheckNew, fCheckDirtyOnly;
  149. switch(msg)
  150. {
  151. case WM_INITDIALOG:
  152. //----- Set up dialog controls -----
  153. EnableDBCSChars(hDlg, IDE_ROOTPATH);
  154. EnableDBCSChars(hDlg, IDE_SENTPATH);
  155. EnableDBCSChars(hDlg, IDE_DRAFTSPATH);
  156. Edit_LimitText(GetDlgItem(hDlg, IDE_ROOTPATH), countof(szRFP)-1);
  157. Edit_LimitText(GetDlgItem(hDlg, IDE_SENTPATH), countof(szSentPath)-1);
  158. Edit_LimitText(GetDlgItem(hDlg, IDE_DRAFTSPATH), countof(szDrafts)-1);
  159. //----- Initialization of fields -----
  160. GetPrivateProfileString(IS_INTERNETMAIL, IK_RFP, c_szEmpty, szRFP, countof(szRFP), g_szInsFile);
  161. GetPrivateProfileString(IS_INTERNETMAIL, IK_SENTITEMS, c_szEmpty, szSentPath, countof(szSentPath), g_szInsFile);
  162. GetPrivateProfileString(IS_INTERNETMAIL, IK_DRAFTS, c_szEmpty, szDrafts, countof(szDrafts), g_szInsFile);
  163. StrRemoveWhitespace(szRFP);
  164. StrRemoveWhitespace(szSentPath);
  165. StrRemoveWhitespace(szDrafts);
  166. fCheckNew = GetPrivateProfileInt(IS_INTERNETMAIL, IK_CHECKFORNEW, FALSE, g_szInsFile);
  167. fSpecial = GetPrivateProfileInt(IS_INTERNETMAIL, IK_USESPECIAL, FALSE, g_szInsFile);
  168. SetDlgItemText(hDlg, IDE_ROOTPATH, szRFP);
  169. SetDlgItemText(hDlg, IDE_SENTPATH, szSentPath);
  170. SetDlgItemText(hDlg, IDE_DRAFTSPATH, szDrafts);
  171. CheckDlgButton(hDlg, IDC_STORESPECIAL, fSpecial);
  172. CheckDlgButton(hDlg, IDC_CHECKNEW, fCheckNew);
  173. EnableDlgItem2(hDlg, IDE_SENTPATH, fSpecial);
  174. EnableDlgItem2(hDlg, IDC_SENTPATH_TXT, fSpecial);
  175. EnableDlgItem2(hDlg, IDE_DRAFTSPATH, fSpecial);
  176. EnableDlgItem2(hDlg, IDC_DRAFTSPATH_TXT, fSpecial);
  177. break;
  178. case WM_COMMAND:
  179. if (BN_CLICKED == HIWORD(wParam))
  180. {
  181. switch (LOWORD(wParam))
  182. {
  183. case IDC_STORESPECIAL:
  184. fSpecial = IsDlgButtonChecked(hDlg, IDC_STORESPECIAL);
  185. EnableDlgItem2(hDlg, IDE_SENTPATH, fSpecial);
  186. EnableDlgItem2(hDlg, IDC_SENTPATH_TXT, fSpecial);
  187. EnableDlgItem2(hDlg, IDE_DRAFTSPATH, fSpecial);
  188. EnableDlgItem2(hDlg, IDC_DRAFTSPATH_TXT, fSpecial);
  189. break;
  190. }
  191. }
  192. break;
  193. case UM_SAVE:
  194. fCheckDirtyOnly = (BOOL) lParam;
  195. //----- Read data from controls into internal variables -----
  196. GetDlgItemText(hDlg, IDE_ROOTPATH, szRFP, countof(szRFP));
  197. GetDlgItemText(hDlg, IDE_SENTPATH, szSentPath, countof(szSentPath));
  198. GetDlgItemText(hDlg, IDE_DRAFTSPATH, szDrafts, countof(szDrafts));
  199. StrRemoveWhitespace(szRFP);
  200. StrRemoveWhitespace(szSentPath);
  201. StrRemoveWhitespace(szDrafts);
  202. fCheckNew = IsDlgButtonChecked(hDlg, IDC_CHECKNEW);
  203. fSpecial = IsDlgButtonChecked(hDlg, IDC_STORESPECIAL);
  204. //----- Handle g_fInsDirty flag -----
  205. if (!g_fInsDirty)
  206. {
  207. TCHAR szWasRFP[MAX_PATH], szWasSentPath[MAX_PATH], szWasDrafts[MAX_PATH];
  208. BOOL fWasSpecial, fWasCheckNew;
  209. GetPrivateProfileString(IS_INTERNETMAIL, IK_RFP, c_szEmpty, szWasRFP, countof(szWasRFP), g_szInsFile);
  210. GetPrivateProfileString(IS_INTERNETMAIL, IK_SENTITEMS, c_szEmpty, szWasSentPath, countof(szWasSentPath), g_szInsFile);
  211. GetPrivateProfileString(IS_INTERNETMAIL, IK_DRAFTS, c_szEmpty, szWasDrafts, countof(szWasDrafts), g_szInsFile);
  212. StrRemoveWhitespace(szWasRFP);
  213. StrRemoveWhitespace(szWasSentPath);
  214. StrRemoveWhitespace(szWasDrafts);
  215. fWasCheckNew = GetPrivateProfileInt(IS_INTERNETMAIL, IK_CHECKFORNEW, FALSE, g_szInsFile);
  216. fWasSpecial = GetPrivateProfileInt(IS_INTERNETMAIL, IK_USESPECIAL, FALSE, g_szInsFile);
  217. if (fCheckNew != fWasCheckNew ||
  218. fSpecial != fWasSpecial ||
  219. StrCmpI(szRFP, szWasRFP) != 0 ||
  220. StrCmpI(szSentPath, szWasSentPath) != 0 ||
  221. StrCmpI(szDrafts, szWasDrafts) != 0)
  222. g_fInsDirty = TRUE;
  223. }
  224. //----- Serialize data to the *.ins file -----
  225. if (!fCheckDirtyOnly)
  226. {
  227. WritePrivateProfileString(IS_INTERNETMAIL, IK_RFP, szRFP, g_szInsFile);
  228. WritePrivateProfileString(IS_INTERNETMAIL, IK_SENTITEMS, szSentPath, g_szInsFile);
  229. WritePrivateProfileString(IS_INTERNETMAIL, IK_DRAFTS, szDrafts, g_szInsFile);
  230. WritePrivateProfileString(IS_INTERNETMAIL, IK_CHECKFORNEW, fCheckNew ? c_sz1 : c_sz0, g_szInsFile);
  231. WritePrivateProfileString(IS_INTERNETMAIL, IK_USESPECIAL, fSpecial ? c_sz1 : c_sz0, g_szInsFile);
  232. }
  233. *((LPBOOL)wParam) = TRUE;
  234. break;
  235. case WM_CLOSE:
  236. DestroyWindow(hDlg);
  237. break;
  238. default:
  239. return FALSE;
  240. }
  241. return TRUE;
  242. }
  243. void SetTimeoutString(HWND hwnd, UINT pos)
  244. {
  245. UINT cch, csec, cmin;
  246. TCHAR szOut[128], sz[128];
  247. csec = TIMEOUT_SEC_MIN + (pos * TIMEOUT_DSEC);
  248. ASSERT(csec >= TIMEOUT_SEC_MIN && csec <= TIMEOUT_SEC_MAX);
  249. cmin = csec / 60;
  250. csec = csec % 60;
  251. if (cmin > 1)
  252. {
  253. LoadString(g_hInst, IDS_XMINUTES, sz, countof(sz));
  254. wsprintf(szOut, sz, cmin);
  255. cch = lstrlen(szOut);
  256. }
  257. else if (cmin == 1)
  258. {
  259. cch = LoadString(g_hInst, IDS_1MINUTE, szOut, countof(szOut));
  260. }
  261. else
  262. {
  263. cch = 0;
  264. }
  265. if (csec != 0)
  266. {
  267. if (cmin > 0)
  268. {
  269. szOut[cch] = TEXT(' ');
  270. cch++;
  271. }
  272. LoadString(g_hInst, IDS_XSECONDS, sz, countof(sz));
  273. wsprintf(&szOut[cch], sz, csec);
  274. }
  275. SetWindowText(hwnd, szOut);
  276. }
  277. /////////////////////////////////////////////////////////////////////////////
  278. // LDAPServer
  279. INT_PTR CALLBACK LDAPServer(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  280. {
  281. TCHAR szLDAPServer[MAX_SERVER],
  282. szLDAPHome[INTERNET_MAX_URL_LENGTH],
  283. szLDAPBitmap[MAX_PATH],
  284. szWorkDir[MAX_PATH],
  285. szLDAPFriendly[MAX_SERVER],
  286. szLDAPBase[128];
  287. UINT uTimeout, uMatches, uAuthType;
  288. BOOL fLDAPCheck, fCheckDirtyOnly, fTrans;
  289. switch(msg)
  290. {
  291. case WM_INITDIALOG:
  292. //----- Set up dialog controls -----
  293. EnableDBCSChars(hDlg, IDE_FRIENDLYNAME);
  294. EnableDBCSChars(hDlg, IDE_SEARCHBASE);
  295. EnableDBCSChars(hDlg, IDE_LDAPBITMAP);
  296. EnableDBCSChars(hDlg, IDE_DIRSERVICE);
  297. EnableDBCSChars(hDlg, IDE_LDAPHOMEPAGE);
  298. Edit_LimitText(GetDlgItem(hDlg, IDE_FRIENDLYNAME), countof(szLDAPFriendly) - 1);
  299. Edit_LimitText(GetDlgItem(hDlg, IDE_DIRSERVICE), countof(szLDAPServer) - 1);
  300. Edit_LimitText(GetDlgItem(hDlg, IDE_LDAPHOMEPAGE), countof(szLDAPHome) - 1);
  301. Edit_LimitText(GetDlgItem(hDlg, IDE_SEARCHBASE), countof(szLDAPBase) - 1);
  302. Edit_LimitText(GetDlgItem(hDlg, IDE_LDAPBITMAP), countof(szLDAPBitmap) - 1);
  303. SendDlgItemMessage(hDlg, IDC_TIMEOUTSLD, TBM_SETRANGE, 0, (LPARAM)MAKELONG(0, CTIMEOUT - 1));
  304. SendDlgItemMessage(hDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(MATCHES_MAX, MATCHES_MIN));
  305. Edit_LimitText(GetDlgItem(hDlg, IDE_MATCHES), 4);
  306. //----- Initialization of fields -----
  307. GetPrivateProfileString(IS_LDAP, IK_FRIENDLYNAME, c_szEmpty, szLDAPFriendly, countof(szLDAPFriendly), g_szInsFile);
  308. GetPrivateProfileString(IS_LDAP, IK_SERVER, c_szEmpty, szLDAPServer, countof(szLDAPServer), g_szInsFile);
  309. GetPrivateProfileString(IS_LDAP, IK_LDAPHOMEPAGE, c_szEmpty, szLDAPHome, countof(szLDAPHome), g_szInsFile);
  310. GetPrivateProfileString(IS_LDAP, IK_SEARCHBASE, c_szNULL, szLDAPBase, countof(szLDAPBase), g_szInsFile);
  311. GetPrivateProfileString(IS_LDAP, IK_BITMAP, c_szEmpty, szLDAPBitmap, countof(szLDAPBitmap), g_szInsFile);
  312. StrRemoveWhitespace(szLDAPFriendly);
  313. StrRemoveWhitespace(szLDAPServer);
  314. StrRemoveWhitespace(szLDAPHome);
  315. StrRemoveWhitespace(szLDAPBase);
  316. StrRemoveWhitespace(szLDAPBitmap);
  317. fLDAPCheck = (BOOL)GetPrivateProfileInt(IS_LDAP, IK_CHECKNAMES, FALSE, g_szInsFile);
  318. uTimeout = GetPrivateProfileInt(IS_LDAP, IK_TIMEOUT, TIMEOUT_SEC_DEFAULT, g_szInsFile);
  319. if (uTimeout < TIMEOUT_SEC_MIN)
  320. uTimeout = TIMEOUT_SEC_MIN;
  321. else if (uTimeout > TIMEOUT_SEC_MAX)
  322. uTimeout = TIMEOUT_SEC_MAX;
  323. uMatches = GetPrivateProfileInt(IS_LDAP, IK_MATCHES, MATCHES_DEFAULT, g_szInsFile);
  324. if (uMatches < MATCHES_MIN)
  325. uMatches = MATCHES_MIN;
  326. else if (uMatches > MATCHES_MAX)
  327. uMatches = MATCHES_MAX;
  328. uAuthType = GetPrivateProfileInt(IS_LDAP, IK_AUTHTYPE, AUTH_ANONYMOUS, g_szInsFile);
  329. if (uAuthType != AUTH_ANONYMOUS && uAuthType != AUTH_SPA)
  330. uAuthType = AUTH_ANONYMOUS;
  331. SetDlgItemText(hDlg, IDE_FRIENDLYNAME, szLDAPFriendly);
  332. SetDlgItemText(hDlg, IDE_DIRSERVICE, szLDAPServer);
  333. SetDlgItemText(hDlg, IDE_LDAPHOMEPAGE, szLDAPHome);
  334. SetDlgItemText(hDlg, IDE_SEARCHBASE, szLDAPBase);
  335. SetDlgItemText(hDlg, IDE_LDAPBITMAP, szLDAPBitmap);
  336. uTimeout = (uTimeout / TIMEOUT_DSEC) - 1;
  337. SendDlgItemMessage(hDlg, IDC_TIMEOUTSLD, TBM_SETPOS, TRUE, (LPARAM)uTimeout);
  338. SetTimeoutString(GetDlgItem(hDlg, IDC_TIMEOUT), uTimeout);
  339. SetDlgItemInt(hDlg, IDE_MATCHES, uMatches, FALSE);
  340. CheckDlgButton(hDlg, IDC_CHECKNAMES, fLDAPCheck ? BST_CHECKED : BST_UNCHECKED);
  341. CheckDlgButton(hDlg, IDC_SPA, uAuthType == AUTH_SPA ? BST_CHECKED : BST_UNCHECKED);
  342. break;
  343. case WM_COMMAND:
  344. if (HIWORD(wParam) == BN_CLICKED)
  345. {
  346. switch (LOWORD(wParam))
  347. {
  348. case IDC_BROWSELDAP:
  349. GetDlgItemText(hDlg, IDE_LDAPBITMAP, szLDAPBitmap, countof(szLDAPBitmap));
  350. if (BrowseForFile(hDlg, szLDAPBitmap, countof(szLDAPBitmap), GFN_BMP))
  351. SetDlgItemText(hDlg, IDE_LDAPBITMAP, szLDAPBitmap);
  352. SetFocus(GetDlgItem(hDlg, IDC_BROWSELDAP));
  353. break;
  354. default:
  355. return FALSE;
  356. }
  357. }
  358. break;
  359. case WM_HSCROLL:
  360. SetTimeoutString(GetDlgItem(hDlg, IDC_TIMEOUT), (UINT) SendMessage((HWND)lParam, TBM_GETPOS, 0, 0));
  361. break;
  362. case UM_SAVE:
  363. fCheckDirtyOnly = (BOOL) lParam;
  364. //----- Read data from controls into internal variables -----
  365. GetDlgItemText(hDlg, IDE_FRIENDLYNAME, szLDAPFriendly, countof(szLDAPFriendly));
  366. GetDlgItemText(hDlg, IDE_DIRSERVICE, szLDAPServer, countof(szLDAPServer));
  367. GetDlgItemText(hDlg, IDE_LDAPHOMEPAGE, szLDAPHome, countof(szLDAPHome));
  368. GetDlgItemText(hDlg, IDE_SEARCHBASE, szLDAPBase, countof(szLDAPBase));
  369. GetDlgItemText(hDlg, IDE_LDAPBITMAP, szLDAPBitmap, countof(szLDAPBitmap));
  370. StrRemoveWhitespace(szLDAPFriendly);
  371. StrRemoveWhitespace(szLDAPServer);
  372. StrRemoveWhitespace(szLDAPHome);
  373. StrRemoveWhitespace(szLDAPBase);
  374. StrRemoveWhitespace(szLDAPBitmap);
  375. fLDAPCheck = IsDlgButtonChecked(hDlg, IDC_CHECKNAMES);
  376. uAuthType = IsDlgButtonChecked(hDlg, IDC_SPA) ? AUTH_SPA : AUTH_ANONYMOUS;
  377. uTimeout = (UINT) SendDlgItemMessage(hDlg, IDC_TIMEOUTSLD, TBM_GETPOS, 0, 0);
  378. uTimeout = TIMEOUT_SEC_MIN + (uTimeout * TIMEOUT_DSEC);
  379. uMatches = GetDlgItemInt(hDlg, IDE_MATCHES, &fTrans, FALSE);
  380. // TODO: we should probably display an error msg here
  381. if (!fTrans)
  382. uMatches = MATCHES_DEFAULT;
  383. else if (uMatches < MATCHES_MIN)
  384. uMatches = MATCHES_MIN;
  385. else if (uMatches > MATCHES_MAX)
  386. uMatches = MATCHES_MAX;
  387. //----- Validate the input -----
  388. if (!fCheckDirtyOnly)
  389. {
  390. if (!CheckField(hDlg, IDE_LDAPBITMAP, FC_FILE | FC_EXISTS))
  391. return(TRUE);
  392. if (!CheckField(hDlg, IDE_LDAPHOMEPAGE, FC_URL))
  393. return(TRUE);
  394. }
  395. //----- Handle g_fInsDirty flag -----
  396. if (!g_fInsDirty)
  397. {
  398. TCHAR szWasLDAPServer[MAX_SERVER],
  399. szWasLDAPHome[INTERNET_MAX_URL_LENGTH],
  400. szWasLDAPBitmap[MAX_PATH],
  401. szWasLDAPFriendly[MAX_SERVER],
  402. szWasLDAPBase[128];
  403. UINT uWasTimeout, uWasMatches, uWasAuthType;
  404. BOOL fWasLDAPCheck;
  405. GetPrivateProfileString(IS_LDAP, IK_FRIENDLYNAME, c_szEmpty, szWasLDAPFriendly, countof(szWasLDAPFriendly), g_szInsFile);
  406. GetPrivateProfileString(IS_LDAP, IK_SERVER, c_szEmpty, szWasLDAPServer, countof(szWasLDAPServer), g_szInsFile);
  407. GetPrivateProfileString(IS_LDAP, IK_LDAPHOMEPAGE, c_szEmpty, szWasLDAPHome, countof(szWasLDAPHome), g_szInsFile);
  408. GetPrivateProfileString(IS_LDAP, IK_SEARCHBASE, c_szNULL, szWasLDAPBase, countof(szWasLDAPBase), g_szInsFile);
  409. GetPrivateProfileString(IS_LDAP, IK_BITMAP, c_szEmpty, szWasLDAPBitmap, countof(szWasLDAPBitmap), g_szInsFile);
  410. StrRemoveWhitespace(szWasLDAPFriendly);
  411. StrRemoveWhitespace(szWasLDAPServer);
  412. StrRemoveWhitespace(szWasLDAPHome);
  413. StrRemoveWhitespace(szWasLDAPBase);
  414. StrRemoveWhitespace(szWasLDAPBitmap);
  415. fWasLDAPCheck = (BOOL)GetPrivateProfileInt(IS_LDAP, IK_CHECKNAMES, FALSE, g_szInsFile);
  416. uWasTimeout = GetPrivateProfileInt(IS_LDAP, IK_TIMEOUT, TIMEOUT_SEC_MIN, g_szInsFile);
  417. uWasMatches = GetPrivateProfileInt(IS_LDAP, IK_MATCHES, MATCHES_DEFAULT, g_szInsFile);
  418. uWasAuthType = GetPrivateProfileInt(IS_LDAP, IK_AUTHTYPE, AUTH_ANONYMOUS, g_szInsFile);
  419. if (fLDAPCheck != fWasLDAPCheck ||
  420. uTimeout != uWasTimeout ||
  421. uMatches != uWasMatches ||
  422. uAuthType != uWasAuthType ||
  423. StrCmpI(szLDAPFriendly, szWasLDAPFriendly) != 0 ||
  424. StrCmpI(szLDAPServer, szWasLDAPServer) != 0 ||
  425. StrCmpI(szLDAPHome, szWasLDAPHome) != 0 ||
  426. StrCmpI(szLDAPBase, szWasLDAPBase) != 0 ||
  427. StrCmpI(szLDAPBitmap, szWasLDAPBitmap) != 0)
  428. g_fInsDirty = TRUE;
  429. }
  430. //----- Serialize data to the *.ins file -----
  431. if (!fCheckDirtyOnly)
  432. {
  433. // clear of the old entry and associated image.
  434. ImportLDAPBitmap(g_szInsFile, g_szWorkDir, FALSE);
  435. WritePrivateProfileString(IS_LDAP, IK_FRIENDLYNAME, szLDAPFriendly, g_szInsFile);
  436. WritePrivateProfileString(IS_LDAP, IK_SERVER, szLDAPServer, g_szInsFile);
  437. WritePrivateProfileString(IS_LDAP, IK_LDAPHOMEPAGE, szLDAPHome, g_szInsFile);
  438. InsWriteQuotedString (IS_LDAP, IK_SEARCHBASE, szLDAPBase, g_szInsFile);
  439. WritePrivateProfileString(IS_LDAP, IK_BITMAP, szLDAPBitmap, g_szInsFile);
  440. WritePrivateProfileString(IS_LDAP, IK_CHECKNAMES, fLDAPCheck ? c_sz1 : c_sz0, g_szInsFile);
  441. wsprintf(szWorkDir, TEXT("%i"), uTimeout);
  442. WritePrivateProfileString(IS_LDAP, IK_TIMEOUT, szWorkDir, g_szInsFile);
  443. wsprintf(szWorkDir, TEXT("%i"), uMatches);
  444. WritePrivateProfileString(IS_LDAP, IK_MATCHES, szWorkDir, g_szInsFile);
  445. wsprintf(szWorkDir, TEXT("%i"), uAuthType);
  446. WritePrivateProfileString(IS_LDAP, IK_AUTHTYPE, szWorkDir, g_szInsFile);
  447. PathCombine(szWorkDir, g_szWorkDir, TEXT("ldap.wrk"));
  448. ImportLDAPBitmap(g_szInsFile, szWorkDir, TRUE);
  449. }
  450. *((LPBOOL)wParam) = TRUE;
  451. break;
  452. case WM_CLOSE:
  453. DestroyWindow(hDlg);
  454. break;
  455. default:
  456. return FALSE;
  457. }
  458. return TRUE;
  459. }
  460. /////////////////////////////////////////////////////////////////////////////
  461. // CustomizeOE
  462. INT_PTR CALLBACK CustomizeOE(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  463. {
  464. TCHAR szInfopane[INTERNET_MAX_URL_LENGTH],
  465. szInfopaneBmp[MAX_PATH],
  466. szHTMLPath[MAX_PATH],
  467. szWorkDir[MAX_PATH],
  468. szSender[255],
  469. szReply[255];
  470. UINT nID;
  471. BOOL fURL,
  472. fCheckDirtyOnly;
  473. switch(msg)
  474. {
  475. case WM_INITDIALOG:
  476. //----- Set up dialog controls -----
  477. EnableDBCSChars(hDlg, IDE_OELOCALPATH);
  478. EnableDBCSChars(hDlg, IDE_OEIMAGEPATH);
  479. EnableDBCSChars(hDlg, IDE_OEWMPATH);
  480. EnableDBCSChars(hDlg, IDE_OEWMSENDER);
  481. EnableDBCSChars(hDlg, IDE_OEPANEURL);
  482. EnableDBCSChars(hDlg, IDE_OEWMREPLYTO);
  483. Edit_LimitText(GetDlgItem(hDlg, IDE_OEPANEURL), countof(szInfopane) - 1);
  484. Edit_LimitText(GetDlgItem(hDlg, IDE_OELOCALPATH), MAX_PATH);
  485. Edit_LimitText(GetDlgItem(hDlg, IDE_OEIMAGEPATH), countof(szInfopaneBmp) - 1);
  486. Edit_LimitText(GetDlgItem(hDlg, IDE_OEWMPATH), countof(szHTMLPath) - 1);
  487. Edit_LimitText(GetDlgItem(hDlg, IDE_OEWMSENDER), countof(szSender) - 1);
  488. Edit_LimitText(GetDlgItem(hDlg, IDE_OEWMREPLYTO), countof(szReply) - 1);
  489. //----- Initialization of fields (1st phase) -----
  490. GetPrivateProfileString(IS_INTERNETMAIL, IK_INFOPANE, c_szEmpty, szInfopane, countof(szInfopane), g_szInsFile);
  491. GetPrivateProfileString(IS_INTERNETMAIL, IK_INFOPANEBMP, c_szEmpty, szInfopaneBmp, countof(szInfopaneBmp), g_szInsFile);
  492. GetPrivateProfileString(IS_INTERNETMAIL, IK_WELCOMEMESSAGE, c_szEmpty, szHTMLPath, countof(szHTMLPath), g_szInsFile);
  493. GetPrivateProfileString(IS_INTERNETMAIL, IK_WELCOMENAME, c_szEmpty, szSender, countof(szSender), g_szInsFile);
  494. GetPrivateProfileString(IS_INTERNETMAIL, IK_WELCOMEADDR, c_szEmpty, szReply, countof(szReply), g_szInsFile);
  495. StrRemoveWhitespace(szInfopane);
  496. StrRemoveWhitespace(szInfopaneBmp);
  497. StrRemoveWhitespace(szHTMLPath);
  498. StrRemoveWhitespace(szSender);
  499. StrRemoveWhitespace(szReply);
  500. //----- Initialization of fields (2nd phase) -----
  501. nID = PathIsURL(szInfopane) ? IDC_OEPANEURL : IDC_OEPANELOCAL;
  502. //----- Set read values in the controls -----
  503. CheckRadioButton(hDlg, IDC_OEPANEURL, IDC_OEPANELOCAL, nID);
  504. SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(nID, BN_CLICKED), (LPARAM)GetDlgItem(hDlg, nID));
  505. if (nID == IDC_OEPANEURL)
  506. {
  507. SetDlgItemText(hDlg, IDE_OEPANEURL, szInfopane);
  508. SetDlgItemText(hDlg, IDE_OELOCALPATH, NULL);
  509. }
  510. else
  511. {
  512. SetDlgItemText(hDlg, IDE_OEPANEURL, NULL);
  513. SetDlgItemText(hDlg, IDE_OELOCALPATH, szInfopane);
  514. }
  515. SetDlgItemText(hDlg, IDE_OEIMAGEPATH, szInfopaneBmp);
  516. SetDlgItemText(hDlg, IDE_OEWMPATH, szHTMLPath);
  517. SetDlgItemText(hDlg, IDE_OEWMSENDER, szSender);
  518. SetDlgItemText(hDlg, IDE_OEWMREPLYTO, szReply);
  519. break;
  520. case WM_COMMAND:
  521. if (HIWORD(wParam) == BN_CLICKED)
  522. {
  523. switch (LOWORD(wParam))
  524. {
  525. case IDC_OEPANEURL:
  526. case IDC_OEPANELOCAL:
  527. fURL = (LOWORD(wParam) == IDC_OEPANEURL);
  528. EnableDlgItem2(hDlg, IDE_OEPANEURL, fURL);
  529. EnableDlgItem2(hDlg, IDE_OELOCALPATH, !fURL);
  530. EnableDlgItem2(hDlg, IDC_BROWSEOEHTML, !fURL);
  531. EnableDlgItem2(hDlg, IDC_OELOCALPATH_TXT, !fURL);
  532. EnableDlgItem2(hDlg, IDE_OEIMAGEPATH, !fURL);
  533. EnableDlgItem2(hDlg, IDC_BROWSEOEIMAGE, !fURL);
  534. EnableDlgItem2(hDlg, IDC_OEIMAGEPATH_TXT, !fURL);
  535. break;
  536. case IDC_BROWSEOEHTML:
  537. GetDlgItemText(hDlg, IDE_OELOCALPATH, szInfopane, countof(szInfopane));
  538. if (BrowseForFile(hDlg, szInfopane, countof(szInfopane), GFN_LOCALHTM))
  539. SetDlgItemText(hDlg, IDE_OELOCALPATH, szInfopane);
  540. SetFocus(GetDlgItem(hDlg, IDC_BROWSEOEHTML));
  541. break;
  542. case IDC_BROWSEOEIMAGE:
  543. GetDlgItemText(hDlg, IDE_OEIMAGEPATH, szInfopaneBmp, countof(szInfopaneBmp));
  544. if (BrowseForFile(hDlg, szInfopaneBmp, countof(szInfopaneBmp), GFN_PICTURE))
  545. SetDlgItemText(hDlg, IDE_OEIMAGEPATH, szInfopaneBmp);
  546. SetFocus(GetDlgItem(hDlg, IDC_BROWSEOEIMAGE));
  547. break;
  548. case IDC_BROWSEOEWM:
  549. GetDlgItemText(hDlg, IDE_OEWMPATH, szHTMLPath, countof(szHTMLPath));
  550. if (BrowseForFile(hDlg, szHTMLPath, countof(szHTMLPath), GFN_LOCALHTM))
  551. SetDlgItemText(hDlg, IDE_OEWMPATH, szHTMLPath);
  552. SetFocus(GetDlgItem(hDlg, IDC_BROWSEOEWM));
  553. break;
  554. default:
  555. break;
  556. }
  557. }
  558. break;
  559. case UM_SAVE:
  560. fCheckDirtyOnly = (BOOL) lParam;
  561. //----- Read data from controls into internal variables -----
  562. nID = IsDlgButtonChecked(hDlg, IDC_OEPANEURL) == BST_CHECKED ? IDE_OEPANEURL : IDE_OELOCALPATH;
  563. GetDlgItemText(hDlg, nID, szInfopane, countof(szInfopane));
  564. GetDlgItemText(hDlg, IDE_OEWMSENDER, szSender, countof(szSender));
  565. GetDlgItemText(hDlg, IDE_OEWMREPLYTO, szReply, countof(szReply));
  566. GetDlgItemText(hDlg, IDE_OEWMPATH, szHTMLPath, countof(szHTMLPath));
  567. GetDlgItemText(hDlg, IDE_OEIMAGEPATH, szInfopaneBmp, countof(szInfopaneBmp));
  568. StrRemoveWhitespace(szInfopane);
  569. StrRemoveWhitespace(szSender);
  570. StrRemoveWhitespace(szReply);
  571. //----- Validate the input -----
  572. if (!fCheckDirtyOnly)
  573. {
  574. szInfopaneBmp[0] = TEXT('\0');
  575. if (nID == IDE_OEPANEURL)
  576. {
  577. if (!CheckField(hDlg, IDE_OEPANEURL, FC_URL))
  578. return(TRUE);
  579. }
  580. else
  581. { /* if (nID == IDE_OELOCALPATH) */
  582. if (!CheckField(hDlg, IDE_OELOCALPATH, FC_FILE | FC_EXISTS))
  583. return(TRUE);
  584. if (!CheckField(hDlg, IDE_OEIMAGEPATH, FC_FILE | FC_EXISTS))
  585. return(TRUE);
  586. }
  587. if (!CheckField(hDlg, IDE_OEWMPATH, FC_FILE | FC_EXISTS))
  588. return(TRUE);
  589. if (*szHTMLPath != TEXT('\0') && (!CheckField(hDlg, IDE_OEWMSENDER, FC_NONNULL) ||
  590. !CheckField(hDlg, IDE_OEWMREPLYTO, FC_NONNULL)))
  591. return TRUE;
  592. }
  593. //----- Handle g_fInsDirty flag -----
  594. if (!g_fInsDirty)
  595. {
  596. TCHAR szWasInfopane[INTERNET_MAX_URL_LENGTH],
  597. szWasInfopaneBmp[MAX_PATH],
  598. szWasHTMLPath[MAX_PATH],
  599. szWasSender[255],
  600. szWasReply[255];
  601. GetPrivateProfileString(IS_INTERNETMAIL, IK_INFOPANE, TEXT(""), szWasInfopane, countof(szInfopane), g_szInsFile);
  602. GetPrivateProfileString(IS_INTERNETMAIL, IK_INFOPANEBMP, TEXT(""), szWasInfopaneBmp, countof(szInfopaneBmp), g_szInsFile);
  603. GetPrivateProfileString(IS_INTERNETMAIL, IK_WELCOMEMESSAGE, TEXT(""), szWasHTMLPath, countof(szHTMLPath), g_szInsFile);
  604. GetPrivateProfileString(IS_INTERNETMAIL, IK_WELCOMENAME, TEXT(""), szWasSender, countof(szSender), g_szInsFile);
  605. GetPrivateProfileString(IS_INTERNETMAIL, IK_WELCOMEADDR, TEXT(""), szWasReply, countof(szReply), g_szInsFile);
  606. StrRemoveWhitespace(szWasInfopane);
  607. StrRemoveWhitespace(szWasInfopaneBmp);
  608. StrRemoveWhitespace(szWasHTMLPath);
  609. StrRemoveWhitespace(szWasSender);
  610. StrRemoveWhitespace(szWasReply);
  611. if (StrCmpI(szWasInfopane, szInfopane) != 0 ||
  612. StrCmpI(szWasInfopaneBmp, szInfopaneBmp) != 0 ||
  613. StrCmpI(szWasHTMLPath, szHTMLPath) != 0 ||
  614. StrCmp (szWasSender, szSender) != 0 ||
  615. StrCmpI(szWasReply, szReply) != 0)
  616. g_fInsDirty = TRUE;
  617. }
  618. //----- Serialize data to the *.ins file -----
  619. if (!fCheckDirtyOnly)
  620. {
  621. // clear of the old entries and associated images.
  622. ImportOEInfo(g_szInsFile, g_szWorkDir, FALSE);
  623. WritePrivateProfileString(IS_INTERNETMAIL, IK_INFOPANE, szInfopane, g_szInsFile);
  624. WritePrivateProfileString(IS_INTERNETMAIL, IK_INFOPANEBMP, szInfopaneBmp, g_szInsFile);
  625. WritePrivateProfileString(IS_INTERNETMAIL, IK_WELCOMEMESSAGE, szHTMLPath, g_szInsFile);
  626. WritePrivateProfileString(IS_INTERNETMAIL, IK_WELCOMENAME, szSender, g_szInsFile);
  627. WritePrivateProfileString(IS_INTERNETMAIL, IK_WELCOMEADDR, szReply, g_szInsFile);
  628. PathCombine(szWorkDir, g_szWorkDir, TEXT("oe.wrk"));
  629. ImportOEInfo(g_szInsFile, szWorkDir, TRUE);
  630. }
  631. *((LPBOOL)wParam) = TRUE;
  632. break;
  633. case WM_CLOSE:
  634. DestroyWindow(hDlg);
  635. break;
  636. default:
  637. return FALSE;
  638. }
  639. return TRUE;
  640. }
  641. /////////////////////////////////////////////////////////////////////////////
  642. // Signature
  643. INT_PTR CALLBACK Signature(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  644. {
  645. TCHAR szBuf1[1024],
  646. szBuf2[1024];
  647. BOOL fUseMailForNews,
  648. fDoSig,
  649. fHtmlMail,
  650. fHtmlNews,
  651. fCheckDirtyOnly,
  652. fEnable;
  653. switch (msg)
  654. {
  655. case WM_INITDIALOG:
  656. //----- Set up dialog controls -----
  657. EnableDBCSChars(hDlg, IDE_MAILSIGTEXT);
  658. EnableDBCSChars(hDlg, IDE_NEWSSIGTEXT);
  659. Edit_LimitText(GetDlgItem(hDlg, IDE_MAILSIGTEXT), countof(szBuf1)-1);
  660. Edit_LimitText(GetDlgItem(hDlg, IDE_NEWSSIGTEXT), countof(szBuf1)-1);
  661. //----- Initialization of fields -----
  662. fUseMailForNews = (BOOL)GetPrivateProfileInt(IS_MAILSIG, IK_USEMAILFORNEWS, FALSE, g_szInsFile);
  663. fDoSig = (BOOL)GetPrivateProfileInt(IS_MAILSIG, IK_USESIG, FALSE, g_szInsFile);
  664. fHtmlMail = (BOOL)GetPrivateProfileInt(IS_INTERNETMAIL, IK_HTMLMSGS, TRUE, g_szInsFile);
  665. fHtmlNews = (BOOL)GetPrivateProfileInt(IS_INTERNETNEWS, IK_HTMLMSGS, FALSE, g_szInsFile);
  666. GetPrivateProfileString(IS_MAILSIG, IK_SIGTEXT, c_szEmpty, szBuf1, countof(szBuf1), g_szInsFile);
  667. EncodeSignature(szBuf1, szBuf2, FALSE);
  668. SetDlgItemText(hDlg, IDE_MAILSIGTEXT, szBuf2);
  669. if (!fUseMailForNews)
  670. {
  671. GetPrivateProfileString(IS_SIG, IK_SIGTEXT, c_szEmpty, szBuf1, countof(szBuf1), g_szInsFile);
  672. EncodeSignature(szBuf1, szBuf2, FALSE);
  673. SetDlgItemText(hDlg, IDE_NEWSSIGTEXT, szBuf2);
  674. }
  675. //----- Set up dialog controls -----
  676. // Note. Some of it is done above already;
  677. CheckDlgButton(hDlg, IDC_MAILSIGTEXT, fDoSig ? BST_CHECKED : BST_UNCHECKED);
  678. CheckDlgButton(hDlg, IDC_NEWSSIGTEXT, (fDoSig && !fUseMailForNews) ? BST_CHECKED : BST_UNCHECKED);
  679. EnableDlgItem2(hDlg, IDE_MAILSIGTEXT, fDoSig);
  680. EnableDlgItem2(hDlg, IDC_NEWSSIGTEXT, fDoSig);
  681. EnableDlgItem2(hDlg, IDE_NEWSSIGTEXT, fDoSig && !fUseMailForNews);
  682. CheckDlgButton(hDlg, IDC_HTMLMAIL, fHtmlMail ? BST_CHECKED : BST_UNCHECKED);
  683. CheckDlgButton(hDlg, IDC_HTMLNEWS, fHtmlNews ? BST_CHECKED : BST_UNCHECKED);
  684. break;
  685. case WM_COMMAND:
  686. switch (HIWORD(wParam))
  687. {
  688. case BN_CLICKED:
  689. switch (LOWORD(wParam))
  690. {
  691. case IDC_MAILSIGTEXT:
  692. case IDC_NEWSSIGTEXT:
  693. fEnable = (IsDlgButtonChecked(hDlg, IDC_MAILSIGTEXT) == BST_CHECKED);
  694. EnableDlgItem2(hDlg, IDE_MAILSIGTEXT, fEnable);
  695. EnableDlgItem2(hDlg, IDC_NEWSSIGTEXT, fEnable);
  696. fEnable &= (IsDlgButtonChecked(hDlg, IDC_NEWSSIGTEXT) == BST_CHECKED);
  697. EnableDlgItem2(hDlg, IDE_NEWSSIGTEXT, fEnable);
  698. break;
  699. }
  700. break;
  701. default:
  702. return FALSE;
  703. }
  704. break;
  705. case UM_SAVE:
  706. fCheckDirtyOnly = (BOOL) lParam;
  707. //----- Read data from controls into internal variables -----
  708. fUseMailForNews = (IsDlgButtonChecked(hDlg, IDC_NEWSSIGTEXT) != BST_CHECKED);
  709. fDoSig = (IsDlgButtonChecked(hDlg, IDC_MAILSIGTEXT) == BST_CHECKED);
  710. fHtmlMail = (IsDlgButtonChecked(hDlg, IDC_HTMLMAIL) == BST_CHECKED);
  711. fHtmlNews = (IsDlgButtonChecked(hDlg, IDC_HTMLNEWS) == BST_CHECKED);
  712. //----- Handle g_fInsDirty flag -----
  713. if (!g_fInsDirty)
  714. {
  715. BOOL fChgMailSig,
  716. fChgNewsSig,
  717. fWasUseMailForNews,
  718. fWasHtmlMail,
  719. fWasHtmlNews,
  720. fWasDoSig;
  721. GetPrivateProfileString(IS_MAILSIG, IK_SIGTEXT, c_szEmpty, szBuf1, countof(szBuf1), g_szInsFile);
  722. EncodeSignature(szBuf1, szBuf2, FALSE);
  723. GetDlgItemText(hDlg, IDE_MAILSIGTEXT, szBuf1, countof(szBuf1));
  724. fChgMailSig = (StrCmp(szBuf1, szBuf2) != 0);
  725. GetPrivateProfileString(IS_SIG, IK_SIGTEXT, c_szEmpty, szBuf1, countof(szBuf1), g_szInsFile);
  726. EncodeSignature(szBuf1, szBuf2, FALSE);
  727. GetDlgItemText(hDlg, IDE_NEWSSIGTEXT, szBuf1, countof(szBuf1));
  728. fChgNewsSig = (StrCmp(szBuf1, szBuf2) != 0);
  729. fWasUseMailForNews = (BOOL)GetPrivateProfileInt(IS_MAILSIG, IK_USEMAILFORNEWS, FALSE, g_szInsFile);
  730. fWasDoSig = (BOOL)GetPrivateProfileInt(IS_MAILSIG, IK_USESIG, FALSE, g_szInsFile);
  731. fWasHtmlMail = (BOOL)GetPrivateProfileInt(IS_INTERNETMAIL, IK_HTMLMSGS, TRUE, g_szInsFile);
  732. fWasHtmlNews = (BOOL)GetPrivateProfileInt(IS_INTERNETNEWS, IK_HTMLMSGS, FALSE, g_szInsFile);
  733. if (fChgMailSig ||
  734. fChgNewsSig ||
  735. fWasUseMailForNews != fUseMailForNews ||
  736. fWasDoSig != fDoSig ||
  737. fWasHtmlMail != fHtmlMail ||
  738. fWasHtmlNews != fHtmlNews)
  739. g_fInsDirty = TRUE;
  740. }
  741. //----- Serialize data to the *.ins file (main part) -----
  742. if (!fCheckDirtyOnly)
  743. {
  744. GetDlgItemText(hDlg, IDE_MAILSIGTEXT, szBuf1, countof(szBuf1));
  745. EncodeSignature(szBuf1, szBuf2, TRUE);
  746. WritePrivateProfileString(MAIL_SIG, SIG_TEXT, szBuf2, g_szInsFile);
  747. GetDlgItemText(hDlg, IDE_NEWSSIGTEXT, szBuf1, countof(szBuf1));
  748. EncodeSignature(szBuf1, szBuf2, TRUE);
  749. WritePrivateProfileString(SIGNATURE, SIG_TEXT, szBuf2, g_szInsFile);
  750. // Note. Some of it is done above already.
  751. WritePrivateProfileString(IS_MAILSIG, IK_USEMAILFORNEWS, fUseMailForNews ? c_sz1 : c_sz0, g_szInsFile);
  752. WritePrivateProfileString(IS_MAILSIG, IK_USESIG, fDoSig ? c_sz1 : c_sz0, g_szInsFile);
  753. WritePrivateProfileString(IS_SIG, IK_USESIG, fDoSig ? c_sz1 : c_sz0, g_szInsFile);
  754. WritePrivateProfileString(IS_INTERNETMAIL, IK_HTMLMSGS, fHtmlMail ? c_sz1 : c_sz0, g_szInsFile);
  755. WritePrivateProfileString(IS_INTERNETNEWS, IK_HTMLMSGS, fHtmlNews ? c_sz1 : c_sz0, g_szInsFile);
  756. }
  757. *((LPBOOL)wParam) = TRUE;
  758. break;
  759. case WM_CLOSE:
  760. DestroyWindow(hDlg);
  761. break;
  762. default:
  763. return FALSE;
  764. }
  765. return TRUE;
  766. }
  767. #define CBSECTION 1024
  768. void InitializeNewsgroups(HWND hwnd, LPCTSTR pszSection, LPCTSTR pszValue, LPCTSTR pszFile)
  769. {
  770. LPTSTR pszGroups, psz, pszDest;
  771. TCHAR szGroupSection[256];
  772. DWORD dw;
  773. dw = GetPrivateProfileString(pszSection, pszValue, c_szEmpty, szGroupSection, countof(szGroupSection), pszFile);
  774. if (dw > 0)
  775. {
  776. pszGroups = (LPTSTR)LocalAlloc(LMEM_FIXED, StrCbFromCch(CBSECTION));
  777. if (pszGroups != NULL)
  778. {
  779. dw = GetPrivateProfileSection(szGroupSection, pszGroups, CBSECTION, pszFile);
  780. if (dw > 0)
  781. {
  782. psz = pszGroups;
  783. pszDest = pszGroups;
  784. while (*psz != 0)
  785. {
  786. while (*psz != 0 && *psz != '=')
  787. {
  788. *pszDest = *psz;
  789. psz++;
  790. pszDest++;
  791. }
  792. if (*psz != 0)
  793. {
  794. psz++;
  795. while (*psz != 0)
  796. psz++;
  797. }
  798. psz++;
  799. *pszDest = 0x0d;
  800. pszDest++;
  801. *pszDest = 0x0a;
  802. pszDest++;
  803. }
  804. *pszDest = 0;
  805. }
  806. SetWindowText(hwnd, pszGroups);
  807. LocalFree(pszGroups);
  808. }
  809. }
  810. }
  811. void SaveNewsgroups(HWND hwnd, LPCTSTR pszSection, LPCTSTR pszValue, LPCTSTR pszFile)
  812. {
  813. LPTSTR pszGroups, psz, pszDest, pszDestT;
  814. TCHAR szGroupSection[256];
  815. DWORD dw, cch;
  816. BOOL fGroups;
  817. fGroups = FALSE;
  818. cch = GetWindowTextLength(hwnd);
  819. if (cch > 0)
  820. {
  821. cch += 4;
  822. pszGroups = (LPTSTR)LocalAlloc(LMEM_FIXED, StrCbFromCch(cch));
  823. if (pszGroups != NULL)
  824. {
  825. cch = GetWindowText(hwnd, pszGroups, cch);
  826. psz = pszGroups;
  827. pszDest = pszGroups;
  828. pszDestT = pszDest;
  829. while (*psz != 0)
  830. {
  831. if (*psz == '\r' && *(psz + 1) == '\n')
  832. {
  833. psz += 2;
  834. if (pszDest > pszDestT)
  835. {
  836. *pszDest = '=';
  837. pszDest++;
  838. *pszDest = 0;
  839. pszDest++;
  840. pszDestT = pszDest;
  841. fGroups = TRUE;
  842. }
  843. continue;
  844. }
  845. else if (*psz != '\t' && *psz != ' ' && *psz != '\r' && *psz != '\n')
  846. {
  847. *pszDest = *psz;
  848. pszDest++;
  849. }
  850. psz++;
  851. }
  852. if (pszDest > pszDestT)
  853. {
  854. *pszDest = '=';
  855. pszDest++;
  856. *pszDest = 0;
  857. pszDest++;
  858. }
  859. *pszDest = 0;
  860. if (fGroups)
  861. {
  862. dw = GetPrivateProfileString(pszSection, pszValue, c_szEmpty, szGroupSection, countof(szGroupSection), pszFile);
  863. if (dw == 0)
  864. lstrcpy(szGroupSection, IK_NEWSGROUPLIST);
  865. WritePrivateProfileString(pszSection, pszValue, szGroupSection, pszFile);
  866. WritePrivateProfileSection(szGroupSection, pszGroups, pszFile);
  867. }
  868. LocalFree(pszGroups);
  869. }
  870. }
  871. if (!fGroups)
  872. {
  873. dw = GetPrivateProfileString(pszSection, pszValue, c_szEmpty, szGroupSection, countof(szGroupSection), pszFile);
  874. if (dw > 0)
  875. WritePrivateProfileSection(szGroupSection, NULL, pszFile);
  876. WritePrivateProfileString(pszSection, pszValue, NULL, pszFile);
  877. }
  878. }
  879. /////////////////////////////////////////////////////////////////////////////
  880. // PreConfigSettings
  881. INT_PTR CALLBACK PreConfigSettings(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  882. {
  883. BOOL fDefMail,
  884. fDefNews,
  885. #if defined(CONDITIONAL_JUNKMAIL)
  886. fJunkMail,
  887. #endif
  888. fDeleteLinks,
  889. fCheckDirtyOnly;
  890. TCHAR szServiceName[MAX_PATH],
  891. szServiceURL[INTERNET_MAX_URL_LENGTH];
  892. switch(msg)
  893. {
  894. case WM_INITDIALOG:
  895. //----- Set up dialog controls -----
  896. // EnableDBCSChars(hDlg, IDE_NGROUPS);
  897. EnableDBCSChars(hDlg, IDE_SERVICENAME);
  898. EnableDBCSChars(hDlg, IDE_SERVICEURL);
  899. Edit_LimitText(GetDlgItem(hDlg, IDE_SERVICENAME), countof(szServiceName)-1);
  900. Edit_LimitText(GetDlgItem(hDlg, IDE_SERVICEURL), countof(szServiceURL)-1);
  901. #if defined(CONDITIONAL_JUNKMAIL)
  902. //----- Initialization of fields -----
  903. fJunkMail = InsGetYesNo(IS_INTERNETMAIL, IK_JUNKMAIL, FALSE, g_szInsFile);
  904. #endif
  905. fDefMail = InsGetYesNo(IS_INTERNETMAIL, IK_DEFAULTCLIENT, FALSE, g_szInsFile);
  906. fDefNews = InsGetYesNo(IS_INTERNETNEWS, IK_DEFAULTCLIENT, FALSE, g_szInsFile);
  907. fDeleteLinks = InsGetBool(IS_OUTLKEXP, IK_DELETELINKS, FALSE, g_szInsFile);
  908. GetPrivateProfileString(IS_OEGLOBAL, IK_SERVICENAME, c_szEmpty, szServiceName, countof(szServiceName), g_szInsFile);
  909. GetPrivateProfileString(IS_OEGLOBAL, IK_SERVICEURL, c_szEmpty, szServiceURL, countof(szServiceURL), g_szInsFile);
  910. StrRemoveWhitespace(szServiceName);
  911. StrRemoveWhitespace(szServiceURL);
  912. //----- Set up dialog controls -----
  913. CheckDlgButton(hDlg, IDC_DEFMAIL, fDefMail ? BST_CHECKED : BST_UNCHECKED);
  914. CheckDlgButton(hDlg, IDC_DEFNEWS, fDefNews ? BST_CHECKED : BST_UNCHECKED);
  915. #if defined(CONDITIONAL_JUNKMAIL)
  916. CheckDlgButton(hDlg, IDC_JUNKMAIL,fJunkMail? BST_CHECKED : BST_UNCHECKED);
  917. #endif
  918. CheckDlgButton(hDlg, IDC_DELETELINKS, fDeleteLinks ? BST_CHECKED : BST_UNCHECKED);
  919. InitializeNewsgroups(GetDlgItem(hDlg, IDE_NGROUPS), IS_INTERNETNEWS, IK_NEWSGROUPS, g_szInsFile);
  920. SendDlgItemMessage(hDlg, IDE_NGROUPS, EM_SETMODIFY, 0, 0);
  921. SetDlgItemText(hDlg, IDE_SERVICENAME, szServiceName);
  922. SetDlgItemText(hDlg, IDE_SERVICEURL, szServiceURL);
  923. break;
  924. case UM_SAVE:
  925. fCheckDirtyOnly = (BOOL) lParam;
  926. //----- Read data from controls into internal variables -----
  927. fDefMail = (IsDlgButtonChecked(hDlg, IDC_DEFMAIL) == BST_CHECKED);
  928. fDefNews = (IsDlgButtonChecked(hDlg, IDC_DEFNEWS) == BST_CHECKED);
  929. #if defined(CONDITIONAL_JUNKMAIL)
  930. fJunkMail= (IsDlgButtonChecked(hDlg, IDC_JUNKMAIL) == BST_CHECKED);
  931. #endif
  932. fDeleteLinks = (IsDlgButtonChecked(hDlg, IDC_DELETELINKS) == BST_CHECKED);
  933. GetDlgItemText(hDlg, IDE_SERVICENAME, szServiceName, countof(szServiceName));
  934. GetDlgItemText(hDlg, IDE_SERVICEURL, szServiceURL, countof(szServiceURL));
  935. StrRemoveWhitespace(szServiceName);
  936. StrRemoveWhitespace(szServiceURL);
  937. //----- Validate the input -----
  938. if (!fCheckDirtyOnly)
  939. {
  940. if (ISNONNULL(szServiceName) || ISNONNULL(szServiceURL))
  941. {
  942. if (!CheckField(hDlg, IDE_SERVICENAME, FC_NONNULL))
  943. return(TRUE);
  944. if (!CheckField(hDlg, IDE_SERVICEURL, FC_URL | FC_NONNULL))
  945. return(TRUE);
  946. }
  947. }
  948. //----- Handle g_fInsDirty flag -----
  949. if (!g_fInsDirty)
  950. {
  951. BOOL fWasDefMail,
  952. #if defined(CONDITIONAL_JUNKMAIL)
  953. fWasJunkMail,
  954. #endif
  955. fWasDefNews,
  956. fWasDeleteLinks;
  957. TCHAR szWasRulesFile[MAX_PATH],
  958. szWasServiceName[MAX_PATH],
  959. szWasServiceURL[INTERNET_MAX_URL_LENGTH];
  960. fWasDefMail = InsGetYesNo(IS_INTERNETMAIL, IK_DEFAULTCLIENT, FALSE, g_szInsFile);
  961. fWasDefNews = InsGetYesNo(IS_INTERNETNEWS, IK_DEFAULTCLIENT, FALSE, g_szInsFile);
  962. #if defined(CONDITIONAL_JUNKMAIL)
  963. fWasJunkMail = InsGetYesNo(IS_INTERNETMAIL, IK_JUNKMAIL, FALSE, g_szInsFile);
  964. #endif
  965. fWasDeleteLinks = InsGetBool(IS_OUTLKEXP, IK_DELETELINKS, FALSE, g_szInsFile);
  966. GetPrivateProfileString(IS_OEGLOBAL, IK_SERVICENAME, c_szEmpty, szWasServiceName, countof(szWasServiceName), g_szInsFile);
  967. GetPrivateProfileString(IS_OEGLOBAL, IK_SERVICEURL, c_szEmpty, szWasServiceURL, countof(szWasServiceURL), g_szInsFile);
  968. StrRemoveWhitespace(szWasServiceName);
  969. StrRemoveWhitespace(szWasServiceURL);
  970. StrRemoveWhitespace(szWasRulesFile);
  971. if (fDefMail != fWasDefMail ||
  972. fDefNews != fWasDefNews ||
  973. #if defined(CONDITIONAL_JUNKMAIL)
  974. fJunkMail != fWasJunkMail ||
  975. #endif
  976. fDeleteLinks != fWasDeleteLinks ||
  977. SendDlgItemMessage(hDlg, IDE_NGROUPS, EM_GETMODIFY, 0, 0) ||
  978. StrCmpI(szServiceName, szWasServiceName) != 0 ||
  979. StrCmpI(szServiceURL, szWasServiceURL) != 0)
  980. g_fInsDirty = TRUE;
  981. }
  982. //----- Serialize data to the *.ins file -----
  983. if (!fCheckDirtyOnly)
  984. {
  985. WritePrivateProfileString(IS_INTERNETMAIL, IK_DEFAULTCLIENT, fDefMail ? c_szYes : c_szNo, g_szInsFile);
  986. WritePrivateProfileString(IS_INTERNETNEWS, IK_DEFAULTCLIENT, fDefNews ? c_szYes : c_szNo, g_szInsFile);
  987. #if defined(CONDITIONAL_JUNKMAIL)
  988. WritePrivateProfileString(IS_INTERNETMAIL, IK_JUNKMAIL, fJunkMail? c_sz1 : c_sz0, g_szInsFile);
  989. #endif
  990. InsWriteBool(IS_OUTLKEXP, IK_DELETELINKS, fDeleteLinks? c_sz1 : NULL, g_szInsFile);
  991. SaveNewsgroups(GetDlgItem(hDlg, IDE_NGROUPS), IS_INTERNETNEWS, IK_NEWSGROUPS, g_szInsFile);
  992. WritePrivateProfileString(IS_OEGLOBAL, IK_SERVICENAME, szServiceName, g_szInsFile);
  993. WritePrivateProfileString(IS_OEGLOBAL, IK_SERVICEURL, szServiceURL, g_szInsFile);
  994. }
  995. *((LPBOOL)wParam) = TRUE;
  996. break;
  997. case WM_CLOSE:
  998. DestroyWindow(hDlg);
  999. break;
  1000. default:
  1001. return FALSE;
  1002. }
  1003. return TRUE;
  1004. }
  1005. /////////////////////////////////////////////////////////////////////////////
  1006. // ViewSettings
  1007. INT_PTR CALLBACK ViewSettings(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  1008. {
  1009. BOOL fFolderBar,
  1010. fFolderList,
  1011. fContacts,
  1012. fTip,
  1013. fStatus,
  1014. fToolbar,
  1015. fToolbarText,
  1016. fOutlook,
  1017. fPreview,
  1018. fPreviewHdr,
  1019. fPreviewSide,
  1020. fCheckDirtyOnly;
  1021. LPCTSTR psz;
  1022. switch(msg)
  1023. {
  1024. case WM_INITDIALOG:
  1025. //----- Initialization of fields -----
  1026. fFolderBar = GetPrivateProfileInt(IS_OUTLKEXP, IK_FOLDERBAR, TRUE, g_szInsFile);
  1027. fFolderList = GetPrivateProfileInt(IS_OUTLKEXP, IK_FOLDERLIST, TRUE, g_szInsFile);
  1028. fOutlook = GetPrivateProfileInt(IS_OUTLKEXP, IK_OUTLOOKBAR, FALSE, g_szInsFile);
  1029. fStatus = GetPrivateProfileInt(IS_OUTLKEXP, IK_STATUSBAR, TRUE, g_szInsFile);
  1030. fContacts = GetPrivateProfileInt(IS_OUTLKEXP, IK_CONTACTS, TRUE, g_szInsFile);
  1031. fTip = GetPrivateProfileInt(IS_OUTLKEXP, IK_TIPOFTHEDAY, TRUE, g_szInsFile);
  1032. fToolbar = GetPrivateProfileInt(IS_OUTLKEXP, IK_TOOLBAR, TRUE, g_szInsFile);
  1033. if (fToolbar)
  1034. fToolbarText = GetPrivateProfileInt(IS_OUTLKEXP, IK_TOOLBARTEXT, TRUE, g_szInsFile);
  1035. else
  1036. fToolbarText = TRUE;
  1037. fPreview = GetPrivateProfileInt(IS_OUTLKEXP, IK_PREVIEWPANE, TRUE, g_szInsFile);
  1038. if (fPreview)
  1039. {
  1040. fPreviewHdr = GetPrivateProfileInt(IS_OUTLKEXP, IK_PREVIEWHDR, TRUE, g_szInsFile);
  1041. fPreviewSide = GetPrivateProfileInt(IS_OUTLKEXP, IK_PREVIEWSIDE, FALSE, g_szInsFile);
  1042. }
  1043. else
  1044. {
  1045. fPreviewHdr = TRUE;
  1046. fPreviewSide = FALSE;
  1047. }
  1048. //----- Set up dialog controls -----
  1049. CheckDlgButton(hDlg, IDC_FOLDERBAR, fFolderBar ? BST_CHECKED : BST_UNCHECKED);
  1050. CheckDlgButton(hDlg, IDC_FOLDERLIST, fFolderList ? BST_CHECKED : BST_UNCHECKED);
  1051. CheckDlgButton(hDlg, IDC_OUTLOOKBAR, fOutlook ? BST_CHECKED : BST_UNCHECKED);
  1052. CheckDlgButton(hDlg, IDC_STATUSBAR, fStatus ? BST_CHECKED : BST_UNCHECKED);
  1053. CheckDlgButton(hDlg, IDC_CONTACTS, fContacts ? BST_CHECKED : BST_UNCHECKED);
  1054. CheckDlgButton(hDlg, IDC_TIPOFDAY, fTip ? BST_CHECKED : BST_UNCHECKED);
  1055. CheckDlgButton(hDlg, IDC_TOOLBAR, fToolbar ? BST_CHECKED : BST_UNCHECKED);
  1056. if (!fToolbar)
  1057. SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_TOOLBAR, BN_CLICKED), (LPARAM)GetDlgItem(hDlg, IDC_TOOLBAR));
  1058. CheckDlgButton(hDlg, IDC_TBARTEXT, fToolbarText ? BST_CHECKED : BST_UNCHECKED);
  1059. CheckDlgButton(hDlg, IDC_PREVIEW, fPreview ? BST_CHECKED : BST_UNCHECKED);
  1060. if (!fPreview)
  1061. SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_PREVIEW, BN_CLICKED), (LPARAM)GetDlgItem(hDlg, IDC_PREVIEW));
  1062. CheckDlgButton(hDlg, fPreviewSide ? IDC_SPLITVERT : IDC_SPLITHORZ, BST_CHECKED);
  1063. CheckDlgButton(hDlg, IDC_PREVIEWHDR, fPreviewHdr ? BST_CHECKED : BST_UNCHECKED);
  1064. break;
  1065. case WM_COMMAND:
  1066. if (BN_CLICKED == HIWORD(wParam))
  1067. {
  1068. switch (LOWORD(wParam))
  1069. {
  1070. case IDC_TOOLBAR:
  1071. fToolbar = IsDlgButtonChecked(hDlg, IDC_TOOLBAR);
  1072. EnableDlgItem2(hDlg, IDC_TBARTEXT, fToolbar);
  1073. break;
  1074. case IDC_PREVIEW:
  1075. fPreview = IsDlgButtonChecked(hDlg, IDC_PREVIEW);
  1076. EnableDlgItem2(hDlg, IDC_SPLITVERT, fPreview);
  1077. EnableDlgItem2(hDlg, IDC_SPLITHORZ, fPreview);
  1078. EnableDlgItem2(hDlg, IDC_PREVIEWHDR, fPreview);
  1079. break;
  1080. }
  1081. break;
  1082. }
  1083. break;
  1084. case UM_SAVE:
  1085. fCheckDirtyOnly = (BOOL) lParam;
  1086. //----- Read data from controls into internal variables -----
  1087. fFolderBar = (IsDlgButtonChecked(hDlg, IDC_FOLDERBAR) == BST_CHECKED);
  1088. fFolderList = (IsDlgButtonChecked(hDlg, IDC_FOLDERLIST) == BST_CHECKED);
  1089. fOutlook = (IsDlgButtonChecked(hDlg, IDC_OUTLOOKBAR) == BST_CHECKED);
  1090. fStatus = (IsDlgButtonChecked(hDlg, IDC_STATUSBAR) == BST_CHECKED);
  1091. fContacts = (IsDlgButtonChecked(hDlg, IDC_CONTACTS) == BST_CHECKED);
  1092. fTip = (IsDlgButtonChecked(hDlg, IDC_TIPOFDAY) == BST_CHECKED);
  1093. fToolbar = (IsDlgButtonChecked(hDlg, IDC_TOOLBAR) == BST_CHECKED);
  1094. fToolbarText = (IsDlgButtonChecked(hDlg, IDC_TBARTEXT) == BST_CHECKED);
  1095. fPreview = (IsDlgButtonChecked(hDlg, IDC_PREVIEW) == BST_CHECKED);
  1096. fPreviewSide = (IsDlgButtonChecked(hDlg, IDC_SPLITVERT) == BST_CHECKED);
  1097. fPreviewHdr = (IsDlgButtonChecked(hDlg, IDC_PREVIEWHDR) == BST_CHECKED);
  1098. //----- Handle g_fInsDirty flag -----
  1099. if (!g_fInsDirty)
  1100. {
  1101. BOOL fWasFolderBar,
  1102. fWasFolderList,
  1103. fWasContacts,
  1104. fWasTip,
  1105. fWasStatus,
  1106. fWasToolbar,
  1107. fWasToolbarText,
  1108. fWasOutlook,
  1109. fWasPreview,
  1110. fWasPreviewHdr,
  1111. fWasPreviewSide;
  1112. fWasFolderBar = GetPrivateProfileInt(IS_OUTLKEXP, IK_FOLDERBAR, TRUE, g_szInsFile);
  1113. fWasFolderList = GetPrivateProfileInt(IS_OUTLKEXP, IK_FOLDERLIST, TRUE, g_szInsFile);
  1114. fWasOutlook = GetPrivateProfileInt(IS_OUTLKEXP, IK_OUTLOOKBAR, FALSE, g_szInsFile);
  1115. fWasStatus = GetPrivateProfileInt(IS_OUTLKEXP, IK_STATUSBAR, TRUE, g_szInsFile);
  1116. fWasContacts = GetPrivateProfileInt(IS_OUTLKEXP, IK_CONTACTS, TRUE, g_szInsFile);
  1117. fWasTip = GetPrivateProfileInt(IS_OUTLKEXP, IK_TIPOFTHEDAY, TRUE, g_szInsFile);
  1118. fWasToolbar = GetPrivateProfileInt(IS_OUTLKEXP, IK_TOOLBAR, TRUE, g_szInsFile);
  1119. fWasToolbarText = GetPrivateProfileInt(IS_OUTLKEXP, IK_TOOLBARTEXT, TRUE, g_szInsFile);
  1120. fWasPreview = GetPrivateProfileInt(IS_OUTLKEXP, IK_PREVIEWPANE, TRUE, g_szInsFile);
  1121. fWasPreviewHdr = GetPrivateProfileInt(IS_OUTLKEXP, IK_PREVIEWHDR, TRUE, g_szInsFile);
  1122. fWasPreviewSide = GetPrivateProfileInt(IS_OUTLKEXP, IK_PREVIEWSIDE, FALSE, g_szInsFile);
  1123. if (fFolderBar != fWasFolderBar ||
  1124. fFolderList != fWasFolderList ||
  1125. fContacts != fWasContacts ||
  1126. fTip != fWasTip ||
  1127. fStatus != fWasStatus ||
  1128. fToolbar != fWasToolbar ||
  1129. fToolbarText != fWasToolbarText ||
  1130. fOutlook != fWasOutlook ||
  1131. fPreview != fWasPreview ||
  1132. fPreviewHdr != fWasPreviewHdr ||
  1133. fPreviewSide != fWasPreviewSide)
  1134. g_fInsDirty = TRUE;
  1135. }
  1136. //----- Serialize data to the *.ins file -----
  1137. if (!fCheckDirtyOnly)
  1138. {
  1139. WritePrivateProfileString(IS_OUTLKEXP, IK_FOLDERBAR, fFolderBar ? c_sz1 : c_sz0, g_szInsFile);
  1140. WritePrivateProfileString(IS_OUTLKEXP, IK_FOLDERLIST, fFolderList ? c_sz1 : c_sz0, g_szInsFile);
  1141. WritePrivateProfileString(IS_OUTLKEXP, IK_OUTLOOKBAR, fOutlook ? c_sz1 : c_sz0, g_szInsFile);
  1142. WritePrivateProfileString(IS_OUTLKEXP, IK_STATUSBAR, fStatus ? c_sz1 : c_sz0, g_szInsFile);
  1143. WritePrivateProfileString(IS_OUTLKEXP, IK_CONTACTS, fContacts ? c_sz1 : c_sz0, g_szInsFile);
  1144. WritePrivateProfileString(IS_OUTLKEXP, IK_TIPOFTHEDAY, fTip ? c_sz1 : c_sz0, g_szInsFile);
  1145. WritePrivateProfileString(IS_OUTLKEXP, IK_TOOLBAR, fToolbar ? c_sz1 : c_sz0, g_szInsFile);
  1146. if (fToolbar)
  1147. psz = fToolbarText ? c_sz1 : c_sz0;
  1148. else
  1149. psz = NULL;
  1150. WritePrivateProfileString(IS_OUTLKEXP, IK_TOOLBARTEXT, psz, g_szInsFile);
  1151. WritePrivateProfileString(IS_OUTLKEXP, IK_PREVIEWPANE, fPreview ? c_sz1 : c_sz0, g_szInsFile);
  1152. if (fPreview)
  1153. psz = fPreviewHdr ? c_sz1 : c_sz0;
  1154. else
  1155. psz = NULL;
  1156. WritePrivateProfileString(IS_OUTLKEXP, IK_PREVIEWHDR, psz, g_szInsFile);
  1157. if (fPreview)
  1158. psz = fPreviewSide ? c_sz1 : c_sz0;
  1159. else
  1160. psz = NULL;
  1161. WritePrivateProfileString(IS_OUTLKEXP, IK_PREVIEWSIDE, psz, g_szInsFile);
  1162. }
  1163. *((LPBOOL)wParam) = TRUE;
  1164. break;
  1165. case WM_CLOSE:
  1166. DestroyWindow(hDlg);
  1167. break;
  1168. default:
  1169. return FALSE;
  1170. }
  1171. return TRUE;
  1172. }
  1173. /////////////////////////////////////////////////////////////////////////////
  1174. // LDAPFinalCopy
  1175. HRESULT LDAPFinalCopy(LPCTSTR pcszDestDir, DWORD dwFlags, LPDWORD pdwCabState)
  1176. {
  1177. TCHAR szFrom[MAX_PATH];
  1178. PathCombine(szFrom, g_szWorkDir, TEXT("ldap.wrk"));
  1179. if (HasFlag(dwFlags, PM_CHECK) && pdwCabState != NULL && !PathIsEmptyPath(szFrom, FILES_ONLY))
  1180. SetFlag(pdwCabState, CAB_TYPE_CONFIG);
  1181. if (HasFlag(dwFlags, PM_COPY))
  1182. CopyFileToDir(szFrom, pcszDestDir);
  1183. if (HasFlag(dwFlags, PM_CLEAR))
  1184. PathRemovePath(szFrom);
  1185. return S_OK;
  1186. }
  1187. /////////////////////////////////////////////////////////////////////////////
  1188. // OEFinalCopy
  1189. HRESULT OEFinalCopy(LPCTSTR pcszDestDir, DWORD dwFlags, LPDWORD pdwCabState)
  1190. {
  1191. TCHAR szFrom[MAX_PATH];
  1192. PathCombine(szFrom, g_szWorkDir, TEXT("oe.wrk"));
  1193. if (HasFlag(dwFlags, PM_CHECK) && pdwCabState != NULL && !PathIsEmptyPath(szFrom, FILES_ONLY))
  1194. SetFlag(pdwCabState, CAB_TYPE_CONFIG);
  1195. if (HasFlag(dwFlags, PM_COPY))
  1196. CopyFileToDir(szFrom, pcszDestDir);
  1197. if (HasFlag(dwFlags, PM_CLEAR))
  1198. PathRemovePath(szFrom);
  1199. return S_OK;
  1200. }