Source code of Windows XP (NT5)
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.

1347 lines
42 KiB

  1. #include "private.h"
  2. #include "offl_cpp.h"
  3. #include "helper.h"
  4. #include <mluisupp.h>
  5. #include "apithk.h"
  6. // REARCHITECT: (tnoonan) This whole file needs some cleanup - starting with a base dialog class.
  7. const TCHAR c_szStrEmpty[] = TEXT("");
  8. const TCHAR c_szStrBoot[] = TEXT("boot");
  9. const TCHAR c_szStrScrnSave[] = TEXT("scrnsave.exe");
  10. const TCHAR c_szStrSystemIni[] = TEXT("system.ini");
  11. const TCHAR c_szShowWelcome[] = TEXT("ShowWelcome");
  12. TCHAR g_szDontAskScreenSaver[] = TEXT("DontAskAboutScreenSaver");
  13. extern BOOL CALLBACK MailOptionDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  14. extern void ReadDefaultEmail(LPTSTR, UINT);
  15. extern BOOL CALLBACK LoginOptionDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  16. extern void ReadDefaultEmail(LPTSTR szBuf, UINT cch);
  17. extern void ReadDefaultSMTPServer(LPTSTR szBuf, UINT cch);
  18. INT_PTR CALLBACK WelcomeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  19. INT_PTR CALLBACK DownloadDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  20. INT_PTR CALLBACK PickScheduleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  21. INT_PTR CALLBACK NewScheduleWizDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  22. INT_PTR CALLBACK LoginDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  23. #define WIZPAGE_NOINTRO 0x0001
  24. #define WIZPAGE_NODOWNLOAD 0x0002
  25. #define WIZPAGE_NOLOGIN 0x0004
  26. struct WizInfo
  27. {
  28. SUBSCRIPTIONTYPE subType;
  29. POOEBuf pOOE;
  30. DWORD dwExceptFlags;
  31. BOOL bShowWelcome;
  32. BOOL bIsNewSchedule;
  33. NOTIFICATIONCOOKIE newCookie;
  34. };
  35. struct WizPage
  36. {
  37. int nResourceID;
  38. DLGPROC dlgProc;
  39. DWORD dwExceptFlags;
  40. };
  41. const WizPage WizPages[] =
  42. {
  43. { IDD_WIZARD0, WelcomeDlgProc, WIZPAGE_NOINTRO },
  44. { IDD_WIZARD1, DownloadDlgProc, WIZPAGE_NODOWNLOAD },
  45. { IDD_WIZARD2, PickScheduleDlgProc, 0 },
  46. { IDD_WIZARD3, NewScheduleWizDlgProc, 0 },
  47. { IDD_WIZARD4, LoginDlgProc, WIZPAGE_NOLOGIN }
  48. };
  49. // Helper functions
  50. inline BOOL IsDesktop(SUBSCRIPTIONTYPE subType)
  51. {
  52. return (subType == SUBSTYPE_DESKTOPURL) || (subType == SUBSTYPE_DESKTOPCHANNEL);
  53. }
  54. inline BOOL IsChannel(SUBSCRIPTIONTYPE subType)
  55. {
  56. return (subType == SUBSTYPE_CHANNEL) || (subType == SUBSTYPE_DESKTOPCHANNEL);
  57. }
  58. inline DWORD GetShowWelcomeScreen()
  59. {
  60. DWORD dwShowWelcome = TRUE;
  61. ReadRegValue(HKEY_CURRENT_USER, c_szRegKey, c_szShowWelcome, &dwShowWelcome, sizeof(DWORD));
  62. return dwShowWelcome;
  63. }
  64. inline void SetShowWelcomeScreen(DWORD dwShowWelcome)
  65. {
  66. WriteRegValue(HKEY_CURRENT_USER, c_szRegKey, c_szShowWelcome, &dwShowWelcome, sizeof(DWORD), REG_DWORD);
  67. }
  68. //
  69. // Explanation of logic for the back/next/finish button
  70. //
  71. // Wiz0 - welcome
  72. // Wiz1 - download
  73. // Wiz2 - pick schedule
  74. // Wiz3 - create schedule
  75. // Wiz4 - login
  76. //
  77. // A state machine can be derived to determine the different possibilities.
  78. // The resulting state table is as follows:
  79. //
  80. // Wiz0: Always has next button
  81. //
  82. // Wiz1: Show back if Wiz0 was shown
  83. // Always has next button
  84. //
  85. // Wiz2: Show back if Wiz0 or Wiz1 was shown
  86. // Show next if create new schedule or show login, otherwise show finish
  87. //
  88. // Wiz3: Always has back button
  89. // Show next if show login, otherwise show finish
  90. //
  91. // Wiz4: Always has back button
  92. // Always has finish button
  93. //
  94. void SetWizButtons(HWND hDlg, INT_PTR resID, WizInfo *pwi)
  95. {
  96. DWORD dwButtons;
  97. switch (resID)
  98. {
  99. case IDD_WIZARD0:
  100. dwButtons = PSWIZB_NEXT;
  101. break;
  102. case IDD_WIZARD1:
  103. dwButtons = PSWIZB_NEXT;
  104. if (pwi && !(pwi->dwExceptFlags & WIZPAGE_NOINTRO))
  105. {
  106. dwButtons |= PSWIZB_BACK;
  107. }
  108. break;
  109. case IDD_WIZARD2:
  110. if (pwi && ((!(pwi->dwExceptFlags & WIZPAGE_NODOWNLOAD)) ||
  111. (!(pwi->dwExceptFlags & WIZPAGE_NOINTRO))))
  112. {
  113. dwButtons = PSWIZB_BACK;
  114. }
  115. else
  116. {
  117. dwButtons = 0;
  118. }
  119. dwButtons |= (pwi && (pwi->bIsNewSchedule || (!(pwi->dwExceptFlags & WIZPAGE_NOLOGIN))))
  120. ? PSWIZB_NEXT : PSWIZB_FINISH;
  121. break;
  122. case IDD_WIZARD3:
  123. dwButtons = PSWIZB_BACK |
  124. ((pwi && (!(pwi->dwExceptFlags & WIZPAGE_NOLOGIN))) ? PSWIZB_NEXT : PSWIZB_FINISH);
  125. break;
  126. case IDD_WIZARD4:
  127. dwButtons = PSWIZB_BACK | PSWIZB_FINISH;
  128. break;
  129. default:
  130. dwButtons = 0;
  131. ASSERT(FALSE);
  132. break;
  133. }
  134. PropSheet_SetWizButtons(GetParent(hDlg), dwButtons);
  135. }
  136. HRESULT CreateAndAddPage(PROPSHEETHEADER& psh, PROPSHEETPAGE& psp, int nPageIndex, DWORD dwExceptFlags)
  137. {
  138. HRESULT hr = S_OK;
  139. if (!(WizPages[nPageIndex].dwExceptFlags & dwExceptFlags))
  140. {
  141. psp.pszTemplate = MAKEINTRESOURCE(WizPages[nPageIndex].nResourceID);
  142. psp.pfnDlgProc = WizPages[nPageIndex].dlgProc;
  143. HPROPSHEETPAGE hpage = Whistler_CreatePropertySheetPageW(&psp);
  144. if (NULL != hpage)
  145. {
  146. psh.phpage[psh.nPages++] = hpage;
  147. }
  148. else
  149. {
  150. hr = E_OUTOFMEMORY;
  151. }
  152. }
  153. else
  154. {
  155. hr = S_FALSE;
  156. }
  157. return hr;
  158. }
  159. HRESULT CreateWizard(HWND hwndParent, SUBSCRIPTIONTYPE subType, POOEBuf pOOE)
  160. {
  161. HRESULT hr = S_OK;
  162. UINT i;
  163. HPROPSHEETPAGE hPropPage[ARRAYSIZE(WizPages)];
  164. PROPSHEETPAGE psp = { 0 };
  165. PROPSHEETHEADER psh = { 0 };
  166. WizInfo wi;
  167. ASSERT(NULL != pOOE);
  168. ASSERT((subType >= SUBSTYPE_URL) && (subType <= SUBSTYPE_DESKTOPCHANNEL));
  169. wi.subType = subType;
  170. wi.pOOE = pOOE;
  171. wi.dwExceptFlags = 0;
  172. wi.bShowWelcome = GetShowWelcomeScreen();
  173. wi.bIsNewSchedule = FALSE;
  174. if (FALSE == wi.bShowWelcome)
  175. {
  176. wi.dwExceptFlags |= WIZPAGE_NOINTRO;
  177. }
  178. if (IsDesktop(subType))
  179. {
  180. wi.dwExceptFlags |= WIZPAGE_NODOWNLOAD;
  181. }
  182. if ((pOOE->bChannel && (!pOOE->bNeedPassword)) ||
  183. SHRestricted2W(REST_NoSubscriptionPasswords, NULL, 0))
  184. {
  185. wi.dwExceptFlags |= WIZPAGE_NOLOGIN;
  186. }
  187. // initialize propsheet header.
  188. psh.dwSize = sizeof(PROPSHEETHEADER);
  189. psh.dwFlags = PSH_WIZARD;
  190. psh.hwndParent = hwndParent;
  191. psh.pszCaption = NULL;
  192. psh.hInstance = MLGetHinst();
  193. psh.nPages = 0;
  194. psh.nStartPage = 0;
  195. psh.phpage = hPropPage;
  196. // initialize propsheet page.
  197. psp.dwSize = sizeof(PROPSHEETPAGE);
  198. psp.dwFlags = PSP_DEFAULT;
  199. psp.hInstance = MLGetHinst();
  200. psp.pszIcon = NULL;
  201. psp.pszTitle = NULL;
  202. psp.lParam = (LPARAM)&wi;
  203. for (i = 0; (i < ARRAYSIZE(WizPages)) && (SUCCEEDED(hr)); i++)
  204. {
  205. hr = CreateAndAddPage(psh, psp, i, wi.dwExceptFlags);
  206. }
  207. if (SUCCEEDED(hr))
  208. {
  209. // invoke the property sheet
  210. INT_PTR nResult = PropertySheet(&psh);
  211. if (nResult > 0)
  212. {
  213. SetShowWelcomeScreen(wi.bShowWelcome);
  214. hr = S_OK;
  215. }
  216. else if (nResult == 0)
  217. {
  218. hr = E_ABORT;
  219. }
  220. else
  221. {
  222. hr = E_FAIL;
  223. }
  224. }
  225. else
  226. {
  227. for (i = 0; i < psh.nPages; i++)
  228. {
  229. DestroyPropertySheetPage(hPropPage[i]);
  230. }
  231. }
  232. return hr;
  233. }
  234. //--------------------------------------------------------------------
  235. // Helper functions
  236. BOOL IsADScreenSaverActive()
  237. {
  238. BOOL bEnabled = FALSE;
  239. for (;;)
  240. {
  241. // NOTE: This is always written as an 8.3 filename
  242. TCHAR szCurrScrnSavePath[MAX_PATH];
  243. if (GetPrivateProfileString(c_szStrBoot,
  244. c_szStrScrnSave,
  245. c_szStrEmpty,
  246. szCurrScrnSavePath,
  247. ARRAYSIZE(szCurrScrnSavePath),
  248. c_szStrSystemIni) == 0)
  249. {
  250. break;
  251. }
  252. TraceMsg(TF_ALWAYS, "szCurrScrnSavePath = %s", szCurrScrnSavePath);
  253. // If scrnsave = [none], we will get a null string back!
  254. if (!(*szCurrScrnSavePath))
  255. break;
  256. TCHAR szScrnSavePath[MAX_PATH];
  257. MLLoadString(IDS_SCREENSAVEREXE, szScrnSavePath,
  258. ARRAYSIZE(szScrnSavePath));
  259. TCHAR szFullScrnSavePath[MAX_PATH];
  260. TCHAR szWinPath[MAX_PATH];
  261. // Find the full file name and path of the screen saver
  262. // GetFileAttributes returns 0xFFFFFFFF if there is an error (ie: no file!)
  263. if (GetWindowsDirectory(szWinPath, ARRAYSIZE(szWinPath)))
  264. {
  265. PathCombine(szFullScrnSavePath, szWinPath, szScrnSavePath);
  266. if (GetFileAttributes(szFullScrnSavePath) == 0xFFFFFFFF)
  267. {
  268. TCHAR szSysPath[MAX_PATH];
  269. if (GetSystemDirectory(szSysPath, ARRAYSIZE(szSysPath)))
  270. {
  271. PathCombine(szFullScrnSavePath, szSysPath, szScrnSavePath);
  272. if (GetFileAttributes(szFullScrnSavePath) == 0xFFFFFFFF)
  273. {
  274. PathCombine(szFullScrnSavePath, szWinPath, TEXT("actsaver.scr"));
  275. if (GetFileAttributes(szFullScrnSavePath) == 0xFFFFFFFF)
  276. {
  277. PathCombine(szFullScrnSavePath, szSysPath, TEXT("actsaver.scr"));
  278. if (GetFileAttributes(szFullScrnSavePath) == 0xFFFFFFFF)
  279. break;
  280. }
  281. }
  282. }
  283. else
  284. break;
  285. }
  286. }
  287. else
  288. break;
  289. // Convert to 8.3 -- for some reason this is the
  290. // only format that the CPL applet recognizes...
  291. TCHAR szShortScrnSavePath[MAX_PATH];
  292. if (GetShortPathName(szFullScrnSavePath, szShortScrnSavePath, ARRAYSIZE(szShortScrnSavePath)))
  293. {
  294. TraceMsg(TF_ALWAYS, "szCurrScrnSavePath = %s", szCurrScrnSavePath);
  295. TraceMsg(TF_ALWAYS, "szShortScrnSavePath = %s", szShortScrnSavePath);
  296. bEnabled = (StrCmpI(PathFindFileName(szCurrScrnSavePath),
  297. PathFindFileName(szShortScrnSavePath)) == 0);
  298. }
  299. break;
  300. }
  301. return bEnabled;
  302. }
  303. HRESULT MakeADScreenSaverActive()
  304. {
  305. TCHAR szScrnSavePath[MAX_PATH];
  306. MLLoadString(IDS_SCREENSAVEREXE, szScrnSavePath,
  307. ARRAYSIZE(szScrnSavePath));
  308. if (PathFindOnPath(szScrnSavePath, NULL))
  309. {
  310. // Convert to 8.3 -- for some reason this is the
  311. // only format that the CPL applet recognizes...
  312. TCHAR szShortScrnSavePath[MAX_PATH];
  313. GetShortPathName(szScrnSavePath, szShortScrnSavePath, ARRAYSIZE(szShortScrnSavePath));
  314. WritePrivateProfileString( c_szStrBoot,
  315. c_szStrScrnSave,
  316. szShortScrnSavePath,
  317. c_szStrSystemIni);
  318. // Flip the screen saver ON
  319. SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,
  320. TRUE,
  321. NULL,
  322. SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
  323. return S_OK;
  324. }
  325. else
  326. return E_FAIL;
  327. }
  328. //--------------------------------------------------------------------
  329. // Dialog Procs
  330. INT_PTR CALLBACK WelcomeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  331. {
  332. LPPROPSHEETPAGE lpPropSheet =(LPPROPSHEETPAGE) GetWindowLongPtr(hDlg, DWLP_USER);
  333. WizInfo *pWiz = lpPropSheet ? (WizInfo *)lpPropSheet->lParam : NULL;
  334. NMHDR FAR *lpnm;
  335. BOOL result = FALSE;
  336. switch (message)
  337. {
  338. case WM_INITDIALOG:
  339. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  340. result = TRUE;
  341. break;
  342. case WM_NOTIFY:
  343. lpnm = (NMHDR FAR *)lParam;
  344. switch (lpnm->code)
  345. {
  346. case PSN_SETACTIVE:
  347. ASSERT(NULL != lpPropSheet);
  348. ASSERT(NULL != pWiz);
  349. SetWizButtons(hDlg, (INT_PTR) lpPropSheet->pszTemplate, pWiz);
  350. result = TRUE;
  351. break;
  352. case PSN_KILLACTIVE:
  353. if (pWiz)
  354. {
  355. pWiz->bShowWelcome = !IsDlgButtonChecked(hDlg, IDC_WIZ_DONT_SHOW_INTRO);
  356. result = TRUE;
  357. }
  358. break;
  359. }
  360. break;
  361. }
  362. return result;
  363. }
  364. void EnableLevelsDeep(HWND hwndDlg, BOOL fEnable)
  365. {
  366. ASSERT(hwndDlg != NULL);
  367. EnableWindow(GetDlgItem(hwndDlg,IDC_WIZ_LINKSDEEP_STATIC1), fEnable);
  368. EnableWindow(GetDlgItem(hwndDlg,IDC_WIZ_LINKSDEEP_STATIC2), fEnable);
  369. EnableWindow(GetDlgItem(hwndDlg,IDC_WIZ_LINKSDEEP_EDIT), fEnable);
  370. EnableWindow(GetDlgItem(hwndDlg,IDC_WIZ_LINKSDEEP_SPIN), fEnable);
  371. return;
  372. }
  373. //
  374. // shows or hides the UI for specifying the number "levels deep" to recurse
  375. //
  376. void ShowLevelsDeep(HWND hwndDlg, BOOL fShow)
  377. {
  378. INT nCmdShow = fShow ? SW_SHOW: SW_HIDE;
  379. ASSERT(hwndDlg != NULL);
  380. ShowWindow(GetDlgItem(hwndDlg,IDC_WIZ_LINKSDEEP_STATIC1), nCmdShow);
  381. ShowWindow(GetDlgItem(hwndDlg,IDC_WIZ_LINKSDEEP_STATIC2), nCmdShow);
  382. ShowWindow(GetDlgItem(hwndDlg,IDC_WIZ_LINKSDEEP_EDIT), nCmdShow);
  383. ShowWindow(GetDlgItem(hwndDlg,IDC_WIZ_LINKSDEEP_SPIN), nCmdShow);
  384. return;
  385. }
  386. //
  387. // enables or disables the UI for specifying the number "levels deep" to recurse
  388. //
  389. INT_PTR CALLBACK DownloadDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  390. {
  391. LPPROPSHEETPAGE lpPropSheet =(LPPROPSHEETPAGE) GetWindowLongPtr(hDlg, DWLP_USER);
  392. WizInfo *pWiz = lpPropSheet ? (WizInfo *)lpPropSheet->lParam : NULL;
  393. POOEBuf pBuf = pWiz ? pWiz->pOOE : NULL;
  394. NMHDR FAR *lpnm;
  395. BOOL result = FALSE;
  396. switch (message)
  397. {
  398. case WM_INITDIALOG:
  399. {
  400. TCHAR szBuf[256];
  401. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  402. pWiz = (WizInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  403. pBuf = pWiz ? pWiz->pOOE : NULL;
  404. SetListViewToString(GetDlgItem (hDlg, IDC_NAME), pBuf->m_Name);
  405. SetListViewToString(GetDlgItem (hDlg, IDC_URL), pBuf->m_URL);
  406. MLLoadString(
  407. (pWiz && IsChannel(pWiz->subType)) ? IDS_WIZ_GET_LINKS_CHANNEL : IDS_WIZ_GET_LINKS_URL,
  408. szBuf, ARRAYSIZE(szBuf));
  409. SetDlgItemText(hDlg, IDC_WIZ_GET_LINKS_TEXT, szBuf);
  410. int checked;
  411. if ((pBuf->bChannel && (pBuf->fChannelFlags & CHANNEL_AGENT_PRECACHE_ALL)) ||
  412. (!pBuf->bChannel && ((pBuf->m_RecurseLevels) > 0)))
  413. {
  414. checked = IDC_WIZ_LINKS_YES;
  415. }
  416. else
  417. {
  418. checked = IDC_WIZ_LINKS_NO;
  419. }
  420. CheckRadioButton(hDlg, IDC_WIZ_LINKS_YES, IDC_WIZ_LINKS_NO, checked);
  421. //
  422. // Initialize the spin control for "levels deep" UI
  423. //
  424. HWND hwndLevelsSpin = GetDlgItem(hDlg,IDC_WIZ_LINKSDEEP_SPIN);
  425. SendMessage(hwndLevelsSpin, UDM_SETRANGE, 0, MAKELONG(MAX_WEBCRAWL_LEVELS, 1));
  426. SendMessage(hwndLevelsSpin, UDM_SETPOS, 0, pBuf->m_RecurseLevels);
  427. ShowLevelsDeep(hDlg,!pBuf->bChannel);
  428. EnableLevelsDeep(hDlg,!pBuf->bChannel && IDC_WIZ_LINKS_YES==checked);
  429. result = TRUE;
  430. break;
  431. }
  432. case WM_COMMAND:
  433. switch (HIWORD(wParam))
  434. {
  435. case BN_CLICKED:
  436. if (!pBuf->bChannel)
  437. switch (LOWORD(wParam))
  438. {
  439. case IDC_WIZ_LINKS_YES:
  440. EnableLevelsDeep(hDlg,TRUE);
  441. break;
  442. case IDC_WIZ_LINKS_NO:
  443. EnableLevelsDeep(hDlg,FALSE);
  444. break;
  445. }
  446. break;
  447. case EN_KILLFOCUS:
  448. //
  449. // This code checks for bogus values in the "levels deep"
  450. // edit control and replaces them with something valid
  451. //
  452. if (LOWORD(wParam)==IDC_WIZ_LINKSDEEP_EDIT)
  453. {
  454. BOOL fTranslated = FALSE;
  455. UINT cLevels = GetDlgItemInt(hDlg,IDC_WIZ_LINKSDEEP_EDIT,&fTranslated,FALSE);
  456. if (!fTranslated || cLevels < 1)
  457. {
  458. SetDlgItemInt(hDlg,IDC_WIZ_LINKSDEEP_EDIT,1,FALSE);
  459. }
  460. else if (cLevels > MAX_WEBCRAWL_LEVELS)
  461. {
  462. SetDlgItemInt(hDlg,IDC_WIZ_LINKSDEEP_EDIT,MAX_WEBCRAWL_LEVELS,FALSE);
  463. }
  464. }
  465. break;
  466. }
  467. break;
  468. case WM_NOTIFY:
  469. lpnm = (NMHDR FAR *)lParam;
  470. switch (lpnm->code)
  471. {
  472. case PSN_SETACTIVE:
  473. ASSERT(NULL != lpPropSheet);
  474. ASSERT(NULL != pWiz);
  475. SetWizButtons(hDlg, (INT_PTR) lpPropSheet->pszTemplate, pWiz);
  476. result = TRUE;
  477. break;
  478. case PSN_KILLACTIVE:
  479. ASSERT(NULL != pBuf);
  480. if (IsDlgButtonChecked(hDlg, IDC_WIZ_LINKS_YES))
  481. {
  482. if (pWiz && IsChannel(pWiz->subType))
  483. {
  484. pBuf->fChannelFlags |= CHANNEL_AGENT_PRECACHE_ALL;
  485. }
  486. else
  487. {
  488. DWORD dwPos = (DWORD)SendDlgItemMessage(hDlg,IDC_WIZ_LINKSDEEP_SPIN,UDM_GETPOS,0,0);
  489. //
  490. // Set the m_RecurseLevels field to the given by the
  491. // spin control. HIWORD(dwPos) indicated errror.
  492. //
  493. if (HIWORD(dwPos))
  494. pBuf->m_RecurseLevels = 1;
  495. else
  496. pBuf->m_RecurseLevels = LOWORD(dwPos);
  497. pBuf->m_RecurseFlags |= WEBCRAWL_LINKS_ELSEWHERE;
  498. }
  499. }
  500. else
  501. {
  502. if (pWiz && IsChannel(pWiz->subType))
  503. {
  504. pBuf->fChannelFlags &= ~CHANNEL_AGENT_PRECACHE_ALL;
  505. pBuf->fChannelFlags |= CHANNEL_AGENT_PRECACHE_SOME;
  506. }
  507. else
  508. {
  509. pBuf->m_RecurseLevels = 0;
  510. pBuf->m_RecurseFlags &= ~WEBCRAWL_LINKS_ELSEWHERE;
  511. }
  512. }
  513. break;
  514. }
  515. break;
  516. }
  517. return result;
  518. }
  519. void HandleScheduleButtons(HWND hDlg, LPPROPSHEETPAGE lpPropSheet, WizInfo *pWiz)
  520. {
  521. ASSERT(NULL != lpPropSheet);
  522. ASSERT(NULL != pWiz);
  523. EnableWindow(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_LIST),
  524. IsDlgButtonChecked(hDlg, IDC_WIZ_SCHEDULE_EXISTING));
  525. pWiz->bIsNewSchedule = IsDlgButtonChecked(hDlg, IDC_WIZ_SCHEDULE_NEW);
  526. SetWizButtons(hDlg, (INT_PTR) lpPropSheet->pszTemplate, pWiz);
  527. }
  528. struct PICKSCHED_LIST_DATA
  529. {
  530. SYNCSCHEDULECOOKIE SchedCookie;
  531. };
  532. struct PICKSCHED_ENUM_DATA
  533. {
  534. HWND hwndSchedList;
  535. POOEBuf pBuf;
  536. SYNCSCHEDULECOOKIE defSchedule;
  537. SYNCSCHEDULECOOKIE customSchedule;
  538. int *pnDefaultSelection;
  539. BOOL bHasAtLeastOneSchedule:1;
  540. BOOL bFoundCustomSchedule:1;
  541. };
  542. BOOL PickSched_EnumCallback(ISyncSchedule *pSyncSchedule,
  543. SYNCSCHEDULECOOKIE *pSchedCookie,
  544. LPARAM lParam)
  545. {
  546. BOOL bAdded = FALSE;
  547. PICKSCHED_ENUM_DATA *psed = (PICKSCHED_ENUM_DATA *)lParam;
  548. DWORD dwSyncScheduleFlags;
  549. PICKSCHED_LIST_DATA *psld = NULL;
  550. ASSERT(NULL != pSyncSchedule);
  551. if (SUCCEEDED(pSyncSchedule->GetFlags(&dwSyncScheduleFlags)))
  552. {
  553. // This checks to make sure we only add a publisher's schedule to the
  554. // list if it belongs to this item.
  555. if ((!(dwSyncScheduleFlags & SYNCSCHEDINFO_FLAGS_READONLY)) ||
  556. (*pSchedCookie == psed->customSchedule))
  557. {
  558. psld = new PICKSCHED_LIST_DATA;
  559. if (NULL != psld)
  560. {
  561. WCHAR wszName[MAX_PATH];
  562. DWORD cchName = ARRAYSIZE(wszName);
  563. if (SUCCEEDED(pSyncSchedule->GetScheduleName(&cchName, wszName)))
  564. {
  565. TCHAR szName[MAX_PATH];
  566. MyOleStrToStrN(szName, ARRAYSIZE(szName), wszName);
  567. psed->bHasAtLeastOneSchedule = TRUE;
  568. psld->SchedCookie = *pSchedCookie;
  569. int index;
  570. if (*pSchedCookie == psed->customSchedule)
  571. {
  572. index = ComboBox_InsertString(psed->hwndSchedList, 0, szName);
  573. if ((index >= 0) && (psed->defSchedule == GUID_NULL))
  574. {
  575. // Do this always for custom schedules if there
  576. // is no defSchedule set
  577. *psed->pnDefaultSelection = index;
  578. psed->bFoundCustomSchedule = TRUE;
  579. }
  580. }
  581. else
  582. {
  583. index = ComboBox_AddString(psed->hwndSchedList, szName);
  584. }
  585. if (index >= 0)
  586. {
  587. bAdded = (ComboBox_SetItemData(psed->hwndSchedList, index, psld) != CB_ERR);
  588. if ((psed->defSchedule == *pSchedCookie)
  589. ||
  590. ((-1 == *psed->pnDefaultSelection) &&
  591. IsCookieOnSchedule(pSyncSchedule, &psed->pBuf->m_Cookie)))
  592. {
  593. *psed->pnDefaultSelection = index;
  594. }
  595. }
  596. }
  597. }
  598. }
  599. }
  600. if (!bAdded)
  601. {
  602. SAFEDELETE(psld);
  603. }
  604. return TRUE;
  605. }
  606. BOOL PickSched_FillSchedList(HWND hDlg, POOEBuf pBuf, int *pnDefaultSelection)
  607. {
  608. PICKSCHED_ENUM_DATA sed;
  609. sed.hwndSchedList = GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_LIST);
  610. sed.pBuf = pBuf;
  611. sed.customSchedule = GUID_NULL;
  612. sed.pnDefaultSelection = pnDefaultSelection;
  613. sed.bHasAtLeastOneSchedule = FALSE;
  614. sed.bFoundCustomSchedule = FALSE;
  615. sed.defSchedule = pBuf->groupCookie; // usually GUID_NULL, but if the user hits
  616. // customize multiple times, he/she would
  617. // expect it to be highlighted
  618. EnumSchedules(PickSched_EnumCallback, (LPARAM)&sed);
  619. if (!sed.bFoundCustomSchedule && pBuf->bChannel &&
  620. (sizeof(TASK_TRIGGER) == pBuf->m_Trigger.cbTriggerSize))
  621. {
  622. // This item has a custom schedule but it isn't an existing
  623. // schedule (actually, this is the normal case). We now
  624. // have to add a fake entry.
  625. PICKSCHED_LIST_DATA *psld = new PICKSCHED_LIST_DATA;
  626. if (NULL != psld)
  627. {
  628. TCHAR szSchedName[MAX_PATH];
  629. BOOL bAdded = FALSE;
  630. CreatePublisherScheduleName(szSchedName, ARRAYSIZE(szSchedName),
  631. pBuf->m_Name, NULL);
  632. int index = ComboBox_InsertString(sed.hwndSchedList, 0, szSchedName);
  633. if (index >= 0)
  634. {
  635. bAdded = (ComboBox_SetItemData(sed.hwndSchedList, index, psld) != CB_ERR);
  636. sed.bHasAtLeastOneSchedule = TRUE;
  637. *pnDefaultSelection = index;
  638. }
  639. if (!bAdded)
  640. {
  641. delete psld;
  642. }
  643. }
  644. }
  645. return sed.bHasAtLeastOneSchedule;
  646. }
  647. PICKSCHED_LIST_DATA *PickSchedList_GetData(HWND hwndSchedList, int index)
  648. {
  649. PICKSCHED_LIST_DATA *psld = NULL;
  650. if (index < 0)
  651. {
  652. index = ComboBox_GetCurSel(hwndSchedList);
  653. }
  654. if (index >= 0)
  655. {
  656. psld = (PICKSCHED_LIST_DATA *)ComboBox_GetItemData(hwndSchedList, index);
  657. if (psld == (PICKSCHED_LIST_DATA *)CB_ERR)
  658. {
  659. psld = NULL;
  660. }
  661. }
  662. return psld;
  663. }
  664. void PickSchedList_FreeAllData(HWND hwndSchedList)
  665. {
  666. int count = ComboBox_GetCount(hwndSchedList);
  667. for (int i = 0; i < count; i++)
  668. {
  669. PICKSCHED_LIST_DATA *psld = PickSchedList_GetData(hwndSchedList, i);
  670. if (NULL != psld)
  671. {
  672. delete psld;
  673. }
  674. }
  675. }
  676. INT_PTR CALLBACK PickScheduleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  677. {
  678. LPPROPSHEETPAGE lpPropSheet =(LPPROPSHEETPAGE)GetWindowLongPtr(hDlg, DWLP_USER);
  679. WizInfo *pWiz = lpPropSheet ? (WizInfo *)lpPropSheet->lParam : NULL;
  680. POOEBuf pBuf = pWiz ? pWiz->pOOE : NULL;
  681. NMHDR FAR *lpnm;
  682. BOOL result = FALSE;
  683. switch (message)
  684. {
  685. case WM_INITDIALOG:
  686. {
  687. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  688. lpPropSheet = (LPPROPSHEETPAGE)lParam;
  689. pWiz = (WizInfo *)lpPropSheet->lParam;
  690. int nDefaultSelection = -1;
  691. BOOL bHaveSchedules = PickSched_FillSchedList(hDlg, pWiz->pOOE,
  692. &nDefaultSelection);
  693. BOOL bNoScheduledUpdates = SHRestricted2W(REST_NoScheduledUpdates, NULL, 0);
  694. int defID = IDC_WIZ_SCHEDULE_NONE;
  695. if (!bHaveSchedules)
  696. {
  697. ShowWindow(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_EXISTING), SW_HIDE);
  698. ShowWindow(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_LIST), SW_HIDE);
  699. }
  700. else if (!bNoScheduledUpdates)
  701. {
  702. if (-1 == nDefaultSelection)
  703. {
  704. // This item isn't on any schedule yet
  705. nDefaultSelection = 0;
  706. }
  707. else
  708. {
  709. // This item is on at least one schedule
  710. defID = IDC_WIZ_SCHEDULE_EXISTING;
  711. }
  712. ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_LIST),
  713. nDefaultSelection);
  714. }
  715. CheckRadioButton(hDlg, IDC_WIZ_SCHEDULE_NONE, IDC_WIZ_SCHEDULE_EXISTING,
  716. defID);
  717. ASSERT(NULL != lpPropSheet);
  718. ASSERT(NULL != pWiz);
  719. if (bNoScheduledUpdates)
  720. {
  721. EnableWindow(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_NEW), FALSE);
  722. EnableWindow(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_EXISTING), FALSE);
  723. EnableWindow(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_LIST), FALSE);
  724. }
  725. else if (SHRestricted2(REST_NoEditingScheduleGroups, NULL, 0))
  726. {
  727. EnableWindow(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_NEW), FALSE);
  728. }
  729. HandleScheduleButtons(hDlg, lpPropSheet, pWiz);
  730. result = TRUE;
  731. break;
  732. }
  733. case WM_DESTROY:
  734. PickSchedList_FreeAllData(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_LIST));
  735. break;
  736. case WM_COMMAND:
  737. switch (LOWORD(wParam))
  738. {
  739. case IDC_WIZ_SCHEDULE_EXISTING:
  740. case IDC_WIZ_SCHEDULE_NEW:
  741. case IDC_WIZ_SCHEDULE_NONE:
  742. ASSERT(NULL != lpPropSheet);
  743. ASSERT(NULL != pWiz);
  744. HandleScheduleButtons(hDlg, lpPropSheet, pWiz);
  745. result = TRUE;
  746. break;
  747. }
  748. break;
  749. case WM_NOTIFY:
  750. lpnm = (NMHDR FAR *)lParam;
  751. switch (lpnm->code)
  752. {
  753. case PSN_SETACTIVE:
  754. ASSERT(NULL != lpPropSheet);
  755. ASSERT(NULL != pWiz);
  756. SetWizButtons(hDlg, (INT_PTR) lpPropSheet->pszTemplate, pWiz);
  757. result = TRUE;
  758. break;
  759. case PSN_WIZNEXT:
  760. case PSN_WIZFINISH:
  761. if (IsDlgButtonChecked(hDlg, IDC_WIZ_SCHEDULE_NONE) && NULL != pBuf)
  762. {
  763. pBuf->groupCookie = NOTFCOOKIE_SCHEDULE_GROUP_MANUAL;
  764. }
  765. else if (IsDlgButtonChecked(hDlg, IDC_WIZ_SCHEDULE_EXISTING))
  766. {
  767. PICKSCHED_LIST_DATA *psld =
  768. PickSchedList_GetData(GetDlgItem(hDlg, IDC_WIZ_SCHEDULE_LIST), -1);
  769. if (NULL != psld && NULL != pBuf)
  770. {
  771. pBuf->groupCookie = psld->SchedCookie;
  772. }
  773. }
  774. result = TRUE;
  775. break;
  776. }
  777. break;
  778. }
  779. return result;
  780. }
  781. #ifdef NEWSCHED_AUTONAME
  782. void NewSchedWiz_AutoName(HWND hDlg, POOEBuf pBuf)
  783. {
  784. if (!(pBuf->m_dwPropSheetFlags & PSF_NO_AUTO_NAME_SCHEDULE))
  785. {
  786. pBuf->m_dwPropSheetFlags &= ~PSF_NO_CHECK_SCHED_CONFLICT;
  787. NewSched_AutoNameHelper(hDlg);
  788. }
  789. }
  790. #endif
  791. BOOL NewSchedWiz_ResolveNameConflict(HWND hDlg, POOEBuf pBuf)
  792. {
  793. BOOL bResult = TRUE;
  794. if (!(pBuf->m_dwPropSheetFlags & PSF_NO_CHECK_SCHED_CONFLICT))
  795. {
  796. bResult = NewSched_ResolveNameConflictHelper(hDlg, &pBuf->m_Trigger,
  797. &pBuf->groupCookie);
  798. }
  799. if (bResult)
  800. {
  801. pBuf->m_dwPropSheetFlags |= PSF_NO_CHECK_SCHED_CONFLICT;
  802. }
  803. return bResult;
  804. }
  805. inline void NewSchedWiz_CreateSchedule(HWND hDlg, POOEBuf pBuf)
  806. {
  807. ASSERT(pBuf->m_dwPropSheetFlags & PSF_NO_CHECK_SCHED_CONFLICT);
  808. NewSched_CreateScheduleHelper(hDlg, &pBuf->m_Trigger,
  809. &pBuf->groupCookie);
  810. }
  811. INT_PTR CALLBACK NewScheduleWizDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  812. {
  813. LPPROPSHEETPAGE lpPropSheet =(LPPROPSHEETPAGE)GetWindowLongPtr(hDlg, DWLP_USER);
  814. WizInfo *pWiz = lpPropSheet ? (WizInfo *)lpPropSheet->lParam : NULL;
  815. POOEBuf pBuf = pWiz ? pWiz->pOOE : NULL;
  816. NMHDR *lpnm;
  817. BOOL result = FALSE;
  818. switch (message)
  819. {
  820. case WM_INITDIALOG:
  821. {
  822. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  823. NewSched_OnInitDialogHelper(hDlg);
  824. pWiz = (WizInfo *)((LPPROPSHEETPAGE)lParam)->lParam;
  825. pBuf = pWiz->pOOE;
  826. pBuf->hwndNewSchedDlg = hDlg;
  827. /*
  828. SUBCLASS_DATA *psd = new SUBCLASS_DATA;
  829. if (NULL != psd)
  830. {
  831. HWND hwndEdit = GetDlgItem(hDlg, IDC_SCHEDULE_NAME);
  832. psd->pBuf = pBuf;
  833. psd->lpfnOldWndProc = (WNDPROC)GetWindowLong(hwndEdit, GWL_WNDPROC);
  834. if (SetProp(hwndEdit, c_szSubClassProp, (HANDLE)psd))
  835. {
  836. SubclassWindow(hwndEdit, EditSubclassProc);
  837. }
  838. else
  839. {
  840. delete psd;
  841. }
  842. }
  843. */
  844. result = TRUE;
  845. break;
  846. }
  847. case WM_COMMAND:
  848. if (NULL != pBuf)
  849. {
  850. switch (LOWORD(wParam))
  851. {
  852. case IDC_SCHEDULE_DAYS:
  853. if (HIWORD(wParam) == EN_UPDATE)
  854. {
  855. if (LOWORD(wParam) == IDC_SCHEDULE_DAYS)
  856. {
  857. KeepSpinNumberInRange(hDlg, IDC_SCHEDULE_DAYS,
  858. IDC_SCHEDULE_DAYS_SPIN, 1, 99);
  859. pBuf->m_dwPropSheetFlags &= ~PSF_NO_CHECK_SCHED_CONFLICT;
  860. result = TRUE;
  861. }
  862. }
  863. #ifdef NEWSCHED_AUTONAME
  864. else if (HIWORD(wParam) == EN_CHANGE)
  865. {
  866. NewSchedWiz_AutoName(hDlg, pBuf);
  867. result = TRUE;
  868. }
  869. #endif
  870. break;
  871. case IDC_SCHEDULE_NAME:
  872. if (HIWORD(wParam) == EN_CHANGE)
  873. {
  874. pBuf->m_dwPropSheetFlags &= ~PSF_NO_CHECK_SCHED_CONFLICT;
  875. result = TRUE;
  876. }
  877. break;
  878. /*
  879. case IDC_SCHEDULE_NAME:
  880. if (HIWORD(wParam) == EN_CHANGE)
  881. {
  882. TCHAR szName[MAX_PATH];
  883. GetDlgItemText(hDlg, IDC_SCHEDULE_NAME, szName, ARRAYSIZE(szName));
  884. if (lstrlen(szName) == 0)
  885. {
  886. pBuf->m_dwPropSheetFlags &= ~PSF_NO_AUTO_NAME_SCHEDULE;
  887. }
  888. }
  889. break;
  890. */
  891. }
  892. }
  893. break;
  894. case WM_NOTIFY:
  895. lpnm = (NMHDR FAR *)lParam;
  896. switch (lpnm->code)
  897. {
  898. case PSN_SETACTIVE:
  899. ASSERT(NULL != lpPropSheet);
  900. ASSERT(NULL != pWiz);
  901. if (!pWiz->bIsNewSchedule)
  902. {
  903. // If the user didn't pick a new schedule, move on
  904. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, -1);
  905. }
  906. else
  907. {
  908. SetWizButtons(hDlg, (INT_PTR) lpPropSheet->pszTemplate, pWiz);
  909. }
  910. result = TRUE;
  911. break;
  912. #ifdef NEWSCHED_AUTONAME
  913. case DTN_DATETIMECHANGE:
  914. if (NULL != pBuf)
  915. {
  916. NewSchedWiz_AutoName(hDlg, pBuf);
  917. }
  918. break;
  919. #endif
  920. case PSN_KILLACTIVE:
  921. result = TRUE;
  922. break;
  923. case PSN_WIZNEXT:
  924. if (!NewSchedWiz_ResolveNameConflict(hDlg, pBuf))
  925. {
  926. // Don't proceed
  927. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  928. }
  929. result = TRUE;
  930. break;
  931. case PSN_WIZFINISH:
  932. if (NewSchedWiz_ResolveNameConflict(hDlg, pBuf))
  933. {
  934. NewSchedWiz_CreateSchedule(hDlg, pBuf);
  935. }
  936. else
  937. {
  938. // Don't proceed
  939. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  940. }
  941. result = TRUE;
  942. break;
  943. }
  944. break;
  945. }
  946. return result;
  947. }
  948. void Login_EnableControls(HWND hDlg, BOOL bEnable)
  949. {
  950. int IDs[] = {
  951. IDC_USERNAME_LABEL,
  952. IDC_USERNAME,
  953. IDC_PASSWORD_LABEL,
  954. IDC_PASSWORD,
  955. IDC_PASSWORDCONFIRM_LABEL,
  956. IDC_PASSWORDCONFIRM
  957. };
  958. for (int i = 0; i < ARRAYSIZE(IDs); i++)
  959. {
  960. EnableWindow(GetDlgItem(hDlg, IDs[i]), bEnable);
  961. }
  962. }
  963. INT_PTR CALLBACK LoginDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  964. {
  965. LPPROPSHEETPAGE lpPropSheet =(LPPROPSHEETPAGE)GetWindowLongPtr(hDlg, DWLP_USER);
  966. WizInfo *pWiz = lpPropSheet ? (WizInfo *)lpPropSheet->lParam : NULL;
  967. POOEBuf pBuf = pWiz ? pWiz->pOOE : NULL;
  968. NMHDR FAR *lpnm;
  969. BOOL result = FALSE;
  970. switch (message)
  971. {
  972. case WM_INITDIALOG:
  973. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  974. lpPropSheet = (LPPROPSHEETPAGE)lParam;
  975. pWiz = (WizInfo *)lpPropSheet->lParam;
  976. pBuf = pWiz->pOOE;
  977. if (pBuf->bChannel)
  978. {
  979. ShowWindow(GetDlgItem(hDlg, IDC_PASSWORD_NO), SW_HIDE);
  980. ShowWindow(GetDlgItem(hDlg, IDC_PASSWORD_YES), SW_HIDE);
  981. ShowWindow(GetDlgItem(hDlg, IDC_LOGIN_PROMPT_URL), SW_HIDE);
  982. }
  983. else
  984. {
  985. CheckRadioButton(hDlg, IDC_PASSWORD_NO, IDC_PASSWORD_YES,
  986. (((pBuf->username[0] == 0) && (pBuf->password[0] == 0)) ?
  987. IDC_PASSWORD_NO : IDC_PASSWORD_YES));
  988. ShowWindow(GetDlgItem(hDlg, IDC_LOGIN_PROMPT), SW_HIDE);
  989. ShowWindow(GetDlgItem(hDlg, IDC_LOGIN_PROMPT_CHANNEL), SW_HIDE);
  990. }
  991. Edit_LimitText(GetDlgItem(hDlg, IDC_USERNAME), ARRAYSIZE(pBuf->username) - 1);
  992. SetDlgItemText(hDlg, IDC_USERNAME, pBuf->username);
  993. Edit_LimitText(GetDlgItem(hDlg, IDC_PASSWORD), ARRAYSIZE(pBuf->password) - 1);
  994. SetDlgItemText(hDlg, IDC_PASSWORD, pBuf->password);
  995. Edit_LimitText(GetDlgItem(hDlg, IDC_PASSWORDCONFIRM), ARRAYSIZE(pBuf->password) - 1);
  996. SetDlgItemText(hDlg, IDC_PASSWORDCONFIRM, pBuf->password);
  997. Login_EnableControls(hDlg, (IsDlgButtonChecked(hDlg, IDC_PASSWORD_YES) || pBuf->bChannel));
  998. result = TRUE;
  999. break;
  1000. case WM_COMMAND:
  1001. switch (LOWORD(wParam))
  1002. {
  1003. case IDC_PASSWORD_YES:
  1004. case IDC_PASSWORD_NO:
  1005. if (BN_CLICKED == HIWORD(wParam))
  1006. {
  1007. Login_EnableControls(hDlg, IsDlgButtonChecked(hDlg, IDC_PASSWORD_YES));
  1008. result = TRUE;
  1009. }
  1010. break;
  1011. }
  1012. break;
  1013. case WM_NOTIFY:
  1014. lpnm = (NMHDR FAR *)lParam;
  1015. switch (lpnm->code)
  1016. {
  1017. case PSN_SETACTIVE:
  1018. ASSERT(NULL != lpPropSheet);
  1019. ASSERT(NULL != pWiz);
  1020. SetWizButtons(hDlg, (INT_PTR) lpPropSheet->pszTemplate, pWiz);
  1021. result = TRUE;
  1022. break;
  1023. case PSN_WIZFINISH:
  1024. {
  1025. BOOL bFinishOK = TRUE;
  1026. if (pBuf)
  1027. {
  1028. if (pBuf->bChannel || IsDlgButtonChecked(hDlg, IDC_PASSWORD_YES))
  1029. {
  1030. TCHAR szUsername[ARRAYSIZE(pBuf->username) + 1];
  1031. TCHAR szPassword[ARRAYSIZE(pBuf->password) + 1];
  1032. TCHAR szPasswordConfirm[ARRAYSIZE(pBuf->password) + 1];
  1033. GetDlgItemText(hDlg, IDC_USERNAME, szUsername, ARRAYSIZE(szUsername));
  1034. GetDlgItemText(hDlg, IDC_PASSWORD, szPassword, ARRAYSIZE(szPassword));
  1035. GetDlgItemText(hDlg, IDC_PASSWORDCONFIRM, szPasswordConfirm, ARRAYSIZE(szPasswordConfirm));
  1036. if (!szUsername[0] && (szPassword[0] || szPasswordConfirm[0]))
  1037. {
  1038. SGMessageBox(hDlg,
  1039. (pBuf->bChannel ? IDS_NEEDCHANNELUSERNAME : IDS_NEEDUSERNAME),
  1040. MB_ICONWARNING);
  1041. bFinishOK = FALSE;
  1042. }
  1043. else if (szUsername[0] && !szPassword[0])
  1044. {
  1045. SGMessageBox(hDlg,
  1046. (pBuf->bChannel ? IDS_NEEDCHANNELPASSWORD : IDS_NEEDPASSWORD),
  1047. MB_ICONWARNING);
  1048. bFinishOK = FALSE;
  1049. }
  1050. else if (StrCmp(szPassword, szPasswordConfirm) != 0)
  1051. {
  1052. SGMessageBox(hDlg, IDS_MISMATCHED_PASSWORDS, MB_ICONWARNING);
  1053. bFinishOK = FALSE;
  1054. }
  1055. else
  1056. {
  1057. StrCpyN(pBuf->username, szUsername, ARRAYSIZE(pBuf->username));
  1058. StrCpyN(pBuf->password, szPassword, ARRAYSIZE(pBuf->password));
  1059. pBuf->dwFlags |= (PROP_WEBCRAWL_UNAME | PROP_WEBCRAWL_PSWD);
  1060. }
  1061. }
  1062. if (!bFinishOK)
  1063. {
  1064. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  1065. }
  1066. else if (pWiz->bIsNewSchedule)
  1067. {
  1068. NewSchedWiz_CreateSchedule(pBuf->hwndNewSchedDlg, pBuf);
  1069. }
  1070. result = TRUE;
  1071. }
  1072. break;
  1073. }
  1074. }
  1075. }
  1076. return result;
  1077. }
  1078. INT_PTR CALLBACK EnableScreenSaverDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  1079. {
  1080. switch(message)
  1081. {
  1082. case WM_COMMAND:
  1083. {
  1084. switch (LOWORD(wParam))
  1085. {
  1086. case IDOK:
  1087. case IDCANCEL:
  1088. {
  1089. DWORD dwChecked = IsDlgButtonChecked(hDlg, IDC_DONTASKAGAIN);
  1090. WriteRegValue( HKEY_CURRENT_USER,
  1091. WEBCHECK_REGKEY,
  1092. g_szDontAskScreenSaver,
  1093. &dwChecked,
  1094. sizeof(DWORD),
  1095. REG_DWORD);
  1096. if (wParam == IDOK)
  1097. MakeADScreenSaverActive();
  1098. EndDialog(hDlg, wParam);
  1099. break;
  1100. }
  1101. default:
  1102. return FALSE;
  1103. }
  1104. break;
  1105. }
  1106. default:
  1107. return FALSE;
  1108. }
  1109. return TRUE;
  1110. }