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.

728 lines
27 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) 1993-1996 Microsoft Corporation. All Rights Reserved.
  3. //
  4. // MODULE: fldrprop.cpp
  5. //
  6. // PURPOSE: Implements the property sheets for news groups and mail
  7. // folders.
  8. //
  9. #include "pch.hxx"
  10. #include "resource.h"
  11. #include "fldrprop.h"
  12. #include <optres.h>
  13. #include <shlwapi.h>
  14. #include "storutil.h"
  15. #include "storecb.h"
  16. #include "newsdlgs.h"
  17. #include "shared.h"
  18. #include "demand.h"
  19. /////////////////////////////////////////////////////////////////////////////
  20. // Private types
  21. //
  22. // FOLDERPROP_INFO
  23. //
  24. // This struct contains the information needed to invoke and display the info
  25. // on a property sheet for a mail folder.
  26. typedef struct
  27. {
  28. //LPTSTR pszFolder;
  29. //CIMAPFolderMgr *pFM;
  30. //LPCFOLDERIDLIST pfidl;
  31. FOLDERID idFolder;
  32. HICON hIcon;
  33. BOOL fDirty;
  34. } FOLDERPROP_INFO, *PFOLDERPROP_INFO;
  35. // GROUPPROP_INFO
  36. //
  37. // This struct contains the information needed to invoke and display the info
  38. // on a property sheet for a news group.
  39. typedef struct
  40. {
  41. LPTSTR pszServer;
  42. LPTSTR pszGroup;
  43. FOLDERID idFolder;
  44. //LPCFOLDERIDLIST pfidl;
  45. //CSubList *pSubList;
  46. HICON hIcon;
  47. } GROUPPROP_INFO, *PGROUPPROP_INFO;
  48. /////////////////////////////////////////////////////////////////////////////
  49. // Private function prototypes
  50. //
  51. INT_PTR CALLBACK GroupProp_GeneralDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  52. LPARAM lParam);
  53. INT_PTR CALLBACK GroupProp_UpdateDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  54. LPARAM lParam);
  55. INT_PTR CALLBACK FolderProp_GeneralDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  56. LPARAM lParam);
  57. INT_PTR CALLBACK NewsProp_CacheDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  58. LPARAM lParam);
  59. BOOL FolderProp_GetFolder(HWND hwnd, PFOLDERPROP_INFO pfpi, FOLDERID idFolder);
  60. /////////////////////////////////////////////////////////////////////////////
  61. //
  62. // FUNCTION: GroupProp_Create()
  63. //
  64. // PURPOSE: Invokes a property sheet which displays properties for the
  65. // specified group.
  66. //
  67. // PARAMETERS:
  68. // <in> hwndParent - Handle of the window that should be the dialog's
  69. // parent.
  70. // <in> pfidl - fully qualified pidl to the newsgroup
  71. //
  72. // RETURN VALUE:
  73. // TRUE - The dialog was successfully displayed
  74. // FALSE - The dialog failed.
  75. //
  76. BOOL GroupProp_Create(HWND hwndParent, FOLDERID idFolder, BOOL fUpdatePage)
  77. {
  78. GROUPPROP_INFO gpi;
  79. BOOL fReturn;
  80. HIMAGELIST himl, himlSmall;
  81. HICON hIcon, hIconSmall;
  82. FOLDERINFO Folder;
  83. FOLDERINFO Store;
  84. LONG iIcon;
  85. PROPSHEETPAGE psp[3], *ppsp;
  86. PROPSHEETHEADER psh;
  87. Assert(IsWindow(hwndParent));
  88. fReturn = FALSE;
  89. if (FAILED(g_pStore->GetFolderInfo(idFolder, &Folder)))
  90. return FALSE;
  91. if (FAILED(GetFolderStoreInfo(Folder.idFolder, &Store)))
  92. {
  93. g_pStore->FreeRecord(&Folder);
  94. return FALSE;
  95. }
  96. iIcon = GetFolderIcon(&Folder);
  97. // TODO: we should probably just have a global image list for this...
  98. himl = ImageList_LoadBitmap(g_hLocRes, MAKEINTRESOURCE(idbFoldersLarge), 32, 0, RGB(255, 0, 255));
  99. if (himl != NULL)
  100. {
  101. hIcon = ImageList_GetIcon(himl, GetFolderIcon(&Folder), ILD_NORMAL);
  102. if (hIcon != NULL)
  103. {
  104. himlSmall = ImageList_LoadBitmap(g_hLocRes, MAKEINTRESOURCE(idbFolders), 16, 0, RGB(255, 0, 255));
  105. if (himlSmall != NULL)
  106. {
  107. hIconSmall = ImageList_GetIcon(himlSmall, iIcon, ILD_NORMAL);
  108. if (hIconSmall != NULL)
  109. {
  110. gpi.pszServer = Store.pszName;
  111. gpi.pszGroup = Folder.pszName;
  112. gpi.idFolder = idFolder;
  113. gpi.hIcon = hIcon;
  114. ppsp = psp;
  115. ZeroMemory(psp, sizeof(psp));
  116. ppsp->dwSize = sizeof(PROPSHEETPAGE);
  117. ppsp->dwFlags = PSP_DEFAULT;
  118. ppsp->hInstance = g_hLocRes;
  119. ppsp->pszTemplate = MAKEINTRESOURCE(iddGroupProp_General);
  120. ppsp->pfnDlgProc = GroupProp_GeneralDlgProc;
  121. ppsp->lParam = (LPARAM) &gpi;
  122. ppsp++;
  123. if (!!(Folder.dwFlags & FOLDER_SUBSCRIBED))
  124. {
  125. ppsp->dwSize = sizeof(PROPSHEETPAGE);
  126. ppsp->dwFlags = PSP_DEFAULT;
  127. ppsp->hInstance = g_hLocRes;
  128. ppsp->pszTemplate = MAKEINTRESOURCE(iddGroupProp_Update);
  129. ppsp->pfnDlgProc = GroupProp_UpdateDlgProc;
  130. ppsp->lParam = (LPARAM) &gpi;
  131. ppsp++;
  132. }
  133. else
  134. {
  135. fUpdatePage = FALSE;
  136. }
  137. ppsp->dwSize = sizeof(PROPSHEETPAGE);
  138. ppsp->dwFlags = PSP_DEFAULT;
  139. ppsp->hInstance = g_hLocRes;
  140. ppsp->pszTemplate = MAKEINTRESOURCE(iddNewsProp_Cache);
  141. ppsp->pfnDlgProc = NewsProp_CacheDlgProc;
  142. ppsp->lParam = (LPARAM) &gpi;
  143. ppsp++;
  144. psh.dwSize = sizeof(PROPSHEETHEADER);
  145. psh.dwFlags = PSH_USEHICON | PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEPAGELANG;
  146. psh.hwndParent = hwndParent;
  147. psh.hInstance = g_hLocRes;
  148. psh.hIcon = hIconSmall;
  149. psh.pszCaption = gpi.pszGroup;
  150. psh.nPages = (int) (ppsp - psp);
  151. psh.nStartPage = fUpdatePage ? 1 : 0;
  152. psh.ppsp = psp;
  153. fReturn = (0 != PropertySheet(&psh));
  154. DestroyIcon(hIconSmall);
  155. }
  156. ImageList_Destroy(himlSmall);
  157. }
  158. DestroyIcon(hIcon);
  159. }
  160. ImageList_Destroy(himl);
  161. }
  162. g_pStore->FreeRecord(&Folder);
  163. g_pStore->FreeRecord(&Store);
  164. return (fReturn);
  165. }
  166. //
  167. // FUNCTION: FolderProp_Create()
  168. //
  169. // PURPOSE: Invokes a property sheet which displays properties for the
  170. // specified folder.
  171. //
  172. // PARAMETERS:
  173. // <in> hwndParent - Handle of the window that should be the dialog's
  174. // parent.
  175. // <in> pfidl - fully qualified pidl to the folder
  176. //
  177. // RETURN VALUE:
  178. // TRUE - The dialog was successfully displayed
  179. // FALSE - The dialog failed.
  180. //
  181. BOOL FolderProp_Create(HWND hwndParent, FOLDERID idFolder)
  182. {
  183. FOLDERPROP_INFO fpi = {0};
  184. GROUPPROP_INFO gpi = {0};
  185. BOOL fReturn;
  186. HIMAGELIST himl, himlSmall;
  187. HICON hIcon, hIconSmall;
  188. LONG iIcon;
  189. FOLDERINFO Folder;
  190. PROPSHEETPAGE psp[3], *ppsp;
  191. PROPSHEETHEADER psh;
  192. Assert(IsWindow(hwndParent));
  193. fReturn = FALSE;
  194. if (FAILED(g_pStore->GetFolderInfo(idFolder, &Folder)))
  195. return FALSE;
  196. iIcon = GetFolderIcon(&Folder);
  197. // TODO: we should probably just have a global image list for this...
  198. himl = ImageList_LoadBitmap(g_hLocRes, MAKEINTRESOURCE(idbFoldersLarge), 32, 0, RGB(255, 0, 255));
  199. if (himl != NULL)
  200. {
  201. hIcon = ImageList_GetIcon(himl, iIcon, ILD_NORMAL);
  202. if (hIcon != NULL)
  203. {
  204. himlSmall = ImageList_LoadBitmap(g_hLocRes, MAKEINTRESOURCE(idbFolders), 16, 0, RGB(255, 0, 255));
  205. if (himlSmall != NULL)
  206. {
  207. hIconSmall = ImageList_GetIcon(himlSmall, iIcon, ILD_NORMAL);
  208. if (hIconSmall != NULL)
  209. {
  210. if (FolderProp_GetFolder(hwndParent, &fpi, idFolder))
  211. {
  212. fpi.hIcon = hIcon;
  213. fpi.fDirty = FALSE;
  214. fpi.idFolder = idFolder;
  215. ppsp = psp;
  216. ZeroMemory(psp, sizeof(psp));
  217. ppsp->dwSize = sizeof(PROPSHEETPAGE);
  218. ppsp->dwFlags = PSP_DEFAULT;
  219. ppsp->hInstance = g_hLocRes;
  220. ppsp->pszTemplate = MAKEINTRESOURCE(iddFolderProp_General);
  221. ppsp->pfnDlgProc = FolderProp_GeneralDlgProc;
  222. ppsp->lParam = (LPARAM) &fpi;
  223. ppsp++;
  224. if (Folder.tyFolder != FOLDER_LOCAL)
  225. {
  226. gpi.hIcon = fpi.hIcon;
  227. gpi.idFolder = fpi.idFolder;
  228. ppsp->dwSize = sizeof(PROPSHEETPAGE);
  229. ppsp->dwFlags = PSP_DEFAULT;
  230. ppsp->hInstance = g_hLocRes;
  231. ppsp->pszTemplate = MAKEINTRESOURCE(iddFolderProp_Update);
  232. ppsp->pfnDlgProc = GroupProp_UpdateDlgProc;
  233. ppsp->lParam = (LPARAM) &gpi;
  234. ppsp++;
  235. ppsp->dwSize = sizeof(PROPSHEETPAGE);
  236. ppsp->dwFlags = PSP_DEFAULT;
  237. ppsp->hInstance = g_hLocRes;
  238. ppsp->pszTemplate = MAKEINTRESOURCE(iddNewsProp_Cache);
  239. ppsp->pfnDlgProc = NewsProp_CacheDlgProc;
  240. ppsp->lParam = (LPARAM) &gpi;
  241. ppsp++;
  242. }
  243. psh.dwSize = sizeof(PROPSHEETHEADER);
  244. psh.dwFlags = PSH_USEHICON | PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEPAGELANG;
  245. psh.hwndParent = hwndParent;
  246. psh.hInstance = g_hLocRes;
  247. psh.hIcon = hIconSmall;
  248. psh.pszCaption = Folder.pszName;
  249. psh.nPages = (int) (ppsp - psp);
  250. psh.nStartPage = 0;
  251. psh.ppsp = psp;
  252. fReturn = (0 != PropertySheet(&psh));
  253. }
  254. DestroyIcon(hIconSmall);
  255. }
  256. ImageList_Destroy(himlSmall);
  257. }
  258. DestroyIcon(hIcon);
  259. }
  260. ImageList_Destroy(himl);
  261. }
  262. g_pStore->FreeRecord(&Folder);
  263. return (fReturn);
  264. }
  265. INT_PTR CALLBACK GroupProp_GeneralDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  266. LPARAM lParam)
  267. {
  268. PGROUPPROP_INFO pgpi = (PGROUPPROP_INFO) GetWindowLongPtr(hwnd, DWLP_USER);
  269. TCHAR szBuffer[CCHMAX_STRINGRES];
  270. TCHAR szRes[CCHMAX_STRINGRES];
  271. FOLDERINFO Folder;
  272. switch (uMsg)
  273. {
  274. case WM_INITDIALOG:
  275. // Stuff the group name and server name into the dialog's extra bytes
  276. pgpi = (PGROUPPROP_INFO) ((PROPSHEETPAGE*) lParam)->lParam;
  277. SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) pgpi);
  278. // Intl Stuff
  279. SetIntlFont(GetDlgItem(hwnd, IDC_FOLDER_FILE));
  280. // Fill in what blanks we know
  281. SetDlgItemText(hwnd, IDC_GROUPNAME_STATIC, pgpi->pszGroup);
  282. // Put a default value into the string first
  283. AthLoadString(idsGroupPropStatusDef, szBuffer, ARRAYSIZE(szBuffer));
  284. // Get the folder info
  285. if (SUCCEEDED(g_pStore->GetFolderInfo(pgpi->idFolder, &Folder)))
  286. {
  287. // Is there a file
  288. if (Folder.pszFile)
  289. {
  290. // Locals
  291. CHAR szRootDir[MAX_PATH];
  292. // Get the store root
  293. if (SUCCEEDED(GetStoreRootDirectory(szRootDir, ARRAYSIZE(szRootDir))))
  294. {
  295. // Locals
  296. CHAR szFilePath[MAX_PATH + MAX_PATH];
  297. // Make the file path
  298. if (SUCCEEDED(MakeFilePath(szRootDir, Folder.pszFile, c_szEmpty, szFilePath, ARRAYSIZE(szFilePath))))
  299. SetDlgItemText(hwnd, IDC_FOLDER_FILE, szFilePath);
  300. }
  301. }
  302. // Load the status string and fill in the blanks
  303. AthLoadString(idsFolderPropStatus, szRes, ARRAYSIZE(szRes));
  304. // Format the string
  305. wnsprintf(szBuffer, ARRAYSIZE(szBuffer), szRes, Folder.cMessages, Folder.cUnread);
  306. // Cleanup
  307. g_pStore->FreeRecord(&Folder);
  308. }
  309. // Set the group status info
  310. SetDlgItemText(hwnd, IDC_STATUS_STATIC, szBuffer);
  311. // Set the icon correctly
  312. SendDlgItemMessage(hwnd, IDC_FOLDER_ICON, STM_SETICON, (WPARAM)pgpi->hIcon, 0);
  313. return (TRUE);
  314. }
  315. return (FALSE);
  316. }
  317. INT_PTR CALLBACK GroupProp_UpdateDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  318. LPARAM lParam)
  319. {
  320. PGROUPPROP_INFO pgpi = (PGROUPPROP_INFO) GetWindowLongPtr(hwnd, DWLP_USER);
  321. BOOL fEnabled;
  322. DWORD dwFlags;
  323. FOLDERINFO Folder;
  324. switch (uMsg)
  325. {
  326. case WM_INITDIALOG:
  327. // Stuff the group name and server name into the dialog's extra bytes
  328. pgpi = (PGROUPPROP_INFO) ((PROPSHEETPAGE*) lParam)->lParam;
  329. SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) pgpi);
  330. // Get the Folder Info
  331. if (SUCCEEDED(g_pStore->GetFolderInfo(pgpi->idFolder, &Folder)))
  332. {
  333. fEnabled = (Folder.dwFlags & (FOLDER_DOWNLOADHEADERS | FOLDER_DOWNLOADNEW | FOLDER_DOWNLOADALL));
  334. Button_SetCheck(GetDlgItem(hwnd, IDC_GET_CHECK), fEnabled);
  335. Button_Enable(GetDlgItem(hwnd, IDC_NEWHEADERS_RADIO), fEnabled);
  336. Button_Enable(GetDlgItem(hwnd, IDC_NEWMSGS_RADIO), fEnabled);
  337. Button_Enable(GetDlgItem(hwnd, IDC_ALLMSGS_RADIO), fEnabled);
  338. // Check the right radio button
  339. if (fEnabled)
  340. {
  341. if (Folder.dwFlags & FOLDER_DOWNLOADHEADERS)
  342. Button_SetCheck(GetDlgItem(hwnd, IDC_NEWHEADERS_RADIO), TRUE);
  343. else if (Folder.dwFlags & FOLDER_DOWNLOADNEW)
  344. Button_SetCheck(GetDlgItem(hwnd, IDC_NEWMSGS_RADIO), TRUE);
  345. else if (Folder.dwFlags & FOLDER_DOWNLOADALL)
  346. Button_SetCheck(GetDlgItem(hwnd, IDC_ALLMSGS_RADIO), TRUE);
  347. }
  348. else
  349. {
  350. Button_SetCheck(GetDlgItem(hwnd, IDC_NEWHEADERS_RADIO), TRUE);
  351. }
  352. g_pStore->FreeRecord(&Folder);
  353. }
  354. return (TRUE);
  355. case WM_COMMAND:
  356. switch (GET_WM_COMMAND_ID(wParam, lParam))
  357. {
  358. case IDC_GET_CHECK:
  359. // Check to see whether this is actually checked or not
  360. fEnabled = Button_GetCheck(GET_WM_COMMAND_HWND(wParam, lParam));
  361. // Enable or disable the radio buttons
  362. Button_Enable(GetDlgItem(hwnd, IDC_NEWHEADERS_RADIO), fEnabled);
  363. Button_Enable(GetDlgItem(hwnd, IDC_NEWMSGS_RADIO), fEnabled);
  364. Button_Enable(GetDlgItem(hwnd, IDC_ALLMSGS_RADIO), fEnabled);
  365. // Fall through...
  366. case IDC_NEWHEADERS_RADIO:
  367. case IDC_NEWMSGS_RADIO:
  368. case IDC_ALLMSGS_RADIO:
  369. PropSheet_Changed(GetParent(hwnd), hwnd);
  370. return (TRUE);
  371. }
  372. return (FALSE);
  373. case WM_NOTIFY:
  374. switch (((NMHDR FAR *) lParam)->code)
  375. {
  376. case PSN_APPLY:
  377. if (SUCCEEDED(g_pStore->GetFolderInfo(pgpi->idFolder, &Folder)))
  378. {
  379. dwFlags = Folder.dwFlags;
  380. // Remove the previous flags
  381. Folder.dwFlags &= ~(FOLDER_DOWNLOADHEADERS | FOLDER_DOWNLOADNEW | FOLDER_DOWNLOADALL);
  382. if (Button_GetCheck(GetDlgItem(hwnd, IDC_GET_CHECK)))
  383. {
  384. if (Button_GetCheck(GetDlgItem(hwnd, IDC_NEWHEADERS_RADIO)))
  385. Folder.dwFlags |= FOLDER_DOWNLOADHEADERS;
  386. else if (Button_GetCheck(GetDlgItem(hwnd, IDC_NEWMSGS_RADIO)))
  387. Folder.dwFlags |= FOLDER_DOWNLOADNEW;
  388. else if (Button_GetCheck(GetDlgItem(hwnd, IDC_ALLMSGS_RADIO)))
  389. Folder.dwFlags |= FOLDER_DOWNLOADALL;
  390. }
  391. if (Folder.dwFlags != dwFlags)
  392. g_pStore->UpdateRecord(&Folder);
  393. g_pStore->FreeRecord(&Folder);
  394. }
  395. PropSheet_UnChanged(GetParent(hwnd), hwnd);
  396. SetDlgMsgResult(hwnd, WM_NOTIFY, PSNRET_NOERROR);
  397. return (TRUE);
  398. }
  399. return (FALSE);
  400. }
  401. return (FALSE);
  402. }
  403. INT_PTR CALLBACK FolderProp_GeneralDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  404. LPARAM lParam)
  405. {
  406. PFOLDERPROP_INFO pfpi = (PFOLDERPROP_INFO) GetWindowLongPtr(hwnd, DWLP_USER);
  407. TCHAR szBuffer[CCHMAX_STRINGRES];
  408. TCHAR szRes[CCHMAX_STRINGRES];
  409. TCHAR szRes2[64];
  410. TCHAR szFldr[CCHMAX_FOLDER_NAME + 1];
  411. FOLDERINFO Folder;
  412. HRESULT hr;
  413. HWND hwndEdit;
  414. HLOCK hLock;
  415. switch (uMsg)
  416. {
  417. case WM_INITDIALOG:
  418. // Stuff the folder name into the dialog's extra bytes
  419. pfpi = (PFOLDERPROP_INFO) ((PROPSHEETPAGE*) lParam)->lParam;
  420. SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) pfpi);
  421. // Put a default value into the string
  422. AthLoadString(idsFolderPropStatusDef, szBuffer, ARRAYSIZE(szBuffer));
  423. hwndEdit = GetDlgItem(hwnd, IDC_FOLDERNAME_EDIT);
  424. SetIntlFont(hwndEdit);
  425. SetIntlFont(GetDlgItem(hwnd, IDC_FOLDER_FILE));
  426. if (SUCCEEDED(g_pStore->GetFolderInfo(pfpi->idFolder, &Folder)))
  427. {
  428. if (Folder.pszFile)
  429. {
  430. CHAR szRootDir[MAX_PATH];
  431. if (SUCCEEDED(GetStoreRootDirectory(szRootDir, ARRAYSIZE(szRootDir))))
  432. {
  433. CHAR szFilePath[MAX_PATH + MAX_PATH];
  434. if (SUCCEEDED(MakeFilePath(szRootDir, Folder.pszFile, c_szEmpty, szFilePath, ARRAYSIZE(szFilePath))))
  435. SetDlgItemText(hwnd, IDC_FOLDER_FILE, szFilePath);
  436. }
  437. }
  438. AthLoadString(idsFolderPropStatus, szRes, ARRAYSIZE(szRes));
  439. wnsprintf(szBuffer, ARRAYSIZE(szBuffer), szRes, Folder.cMessages, Folder.cUnread);
  440. if (FOLDER_IMAP != Folder.tyFolder && Folder.tySpecial == FOLDER_NOTSPECIAL)
  441. {
  442. SendMessage(hwndEdit, EM_SETREADONLY, (WPARAM)FALSE, 0);
  443. SendMessage(hwndEdit, EM_LIMITTEXT, CCHMAX_FOLDER_NAME, 0);
  444. }
  445. SetWindowText(hwndEdit, Folder.pszName);
  446. g_pStore->FreeRecord(&Folder);
  447. }
  448. // Set the group status info
  449. SetDlgItemText(hwnd, IDC_STATUS_STATIC, szBuffer);
  450. // Need to set the specified icon
  451. SendDlgItemMessage(hwnd, IDC_FOLDER_ICON, STM_SETICON, (WPARAM)pfpi->hIcon, 0);
  452. pfpi->fDirty = FALSE;
  453. return (TRUE);
  454. case WM_COMMAND:
  455. if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
  456. {
  457. PropSheet_Changed(GetParent(hwnd), hwnd);
  458. pfpi->fDirty = TRUE;
  459. }
  460. break;
  461. case WM_NOTIFY:
  462. NMHDR* pnmhdr = (NMHDR*) lParam;
  463. switch (pnmhdr->code)
  464. {
  465. case PSN_APPLY:
  466. // Bug #13121 - Only try to change the folder name if the
  467. // the propsheet is dirty.
  468. if (pfpi->fDirty)
  469. {
  470. GetDlgItemText(hwnd, IDC_FOLDERNAME_EDIT, szFldr, sizeof(szFldr) / sizeof(TCHAR));
  471. if (!FAILED(hr = RenameFolderProgress(hwnd, pfpi->idFolder, szFldr, NOFLAGS)))
  472. SetDlgMsgResult(hwnd, WM_NOTIFY, PSNRET_NOERROR);
  473. else
  474. AthErrorMessageW(hwnd, MAKEINTRESOURCEW(idsAthenaMail), MAKEINTRESOURCEW(idsErrRenameFld), hr);
  475. pfpi->fDirty = FALSE;
  476. }
  477. return (0);
  478. case PSN_KILLACTIVE:
  479. SetDlgMsgResult(hwnd, WM_NOTIFY, 0L);
  480. return (0);
  481. }
  482. break;
  483. }
  484. return (FALSE);
  485. }
  486. //
  487. // FUNCTION: FolderProp_GetFolder()
  488. //
  489. // PURPOSE: This function is used by the Folder Property dialog to get
  490. // the store object and folder handle for callers who did not
  491. // already provide this information.
  492. //
  493. // PARAMETERS:
  494. // <in> hwnd - Handle of the property sheet window
  495. // <in> pfpi - Pointer to the FOLDERPROP_INFO struct that stores the prop
  496. // sheet's information.
  497. // <in> pfidl - fully qualified pidl of folder
  498. // <in> pfidlLeaf - leaf pidl of folder
  499. //
  500. // RETURN VALUE:
  501. // TRUE - The information was retrieved
  502. // FALSE - The information was not available
  503. //
  504. BOOL FolderProp_GetFolder(HWND hwnd, PFOLDERPROP_INFO pfpi, FOLDERID idFolder)
  505. {
  506. pfpi->idFolder = idFolder;
  507. return (TRUE);
  508. }
  509. INT_PTR CALLBACK NewsProp_CacheDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  510. {
  511. FOLDERINFO Folder;
  512. PGROUPPROP_INFO pgpi = (PGROUPPROP_INFO) GetWindowLongPtr(hwnd, DWLP_USER);
  513. CHAR szRes[255];
  514. CHAR szMsg[255 + 255];
  515. switch (uMsg)
  516. {
  517. case WM_INITDIALOG:
  518. // Stuff the group name and server name into the dialog's extra bytes
  519. pgpi = (PGROUPPROP_INFO) ((PROPSHEETPAGE*) lParam)->lParam;
  520. SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) pgpi);
  521. SendDlgItemMessage(hwnd, IDC_FOLDER_ICON, STM_SETICON, (WPARAM)pgpi->hIcon, 0);
  522. // Disable the Reset button
  523. EnableWindow(GetDlgItem(hwnd, idbReset), FALSE);
  524. // Get the folder information
  525. if (SUCCEEDED(g_pStore->GetFolderInfo(pgpi->idFolder, &Folder)))
  526. {
  527. // News
  528. if (FOLDER_NEWS == Folder.tyFolder)
  529. {
  530. // If Its news, enable the
  531. EnableWindow(GetDlgItem(hwnd, idbReset), TRUE);
  532. }
  533. // Free the Folder Infp
  534. g_pStore->FreeRecord(&Folder);
  535. }
  536. // Locals
  537. DisplayFolderSizeInfo(hwnd, RECURSE_INCLUDECURRENT, pgpi->idFolder);
  538. // Done
  539. break;
  540. case WM_COMMAND:
  541. BOOL fRet = FALSE;
  542. UINT nCmd = GET_WM_COMMAND_ID(wParam, lParam);
  543. HCURSOR hCur = SetCursor(LoadCursor(NULL, IDC_WAIT)); // Bug 12513. Need to disable button, when process command
  544. switch (GET_WM_COMMAND_ID(wParam, lParam))
  545. {
  546. case idbCompactCache:
  547. {
  548. if (SUCCEEDED(CleanupFolder(GetParent(hwnd), RECURSE_INCLUDECURRENT, pgpi->idFolder, CLEANUP_COMPACT)))
  549. DisplayFolderSizeInfo(hwnd, RECURSE_INCLUDECURRENT, pgpi->idFolder);
  550. fRet = TRUE;
  551. }
  552. break;
  553. case idbRemove:
  554. case idbReset:
  555. case idbDelete:
  556. {
  557. // Get Folder Info
  558. if (SUCCEEDED(g_pStore->GetFolderInfo(pgpi->idFolder, &Folder)))
  559. {
  560. // Get Command
  561. UINT idCommand=GET_WM_COMMAND_ID(wParam, lParam);
  562. UINT idString;
  563. CLEANUPFOLDERTYPE tyCleanup;
  564. // Remove
  565. if (idbRemove == idCommand)
  566. {
  567. idString = idsConfirmDelBodies;
  568. tyCleanup = CLEANUP_REMOVEBODIES;
  569. }
  570. // Delete
  571. else if (idbDelete == idCommand)
  572. {
  573. idString = idsConfirmDelMsgs;
  574. tyCleanup = CLEANUP_DELETE;
  575. }
  576. // Remove
  577. else
  578. {
  579. Assert(idbReset == idCommand);
  580. idString = idsConfirmReset;
  581. tyCleanup = CLEANUP_RESET;
  582. }
  583. // Load the String
  584. AthLoadString(idString, szRes, ARRAYSIZE(szRes));
  585. // Format with the Folder Name
  586. wnsprintf(szMsg, ARRAYSIZE(szMsg), szRes, Folder.pszName);
  587. // Confirm
  588. if (IDYES == AthMessageBox(hwnd, MAKEINTRESOURCE(idsAthena), szMsg, NULL, MB_YESNO | MB_ICONEXCLAMATION))
  589. {
  590. // Cleanup the Folder
  591. if (SUCCEEDED(CleanupFolder(hwnd, RECURSE_INCLUDECURRENT, pgpi->idFolder, tyCleanup)))
  592. {
  593. // Reset Information
  594. DisplayFolderSizeInfo(hwnd, RECURSE_INCLUDECURRENT, pgpi->idFolder);
  595. }
  596. }
  597. // Free Folder Information
  598. g_pStore->FreeRecord(&Folder);
  599. }
  600. // Message Handled
  601. fRet = TRUE;
  602. }
  603. break;
  604. }
  605. SetCursor(hCur);
  606. if(fRet)
  607. return 1;
  608. break;
  609. }
  610. return (FALSE);
  611. }