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.

250 lines
9.4 KiB

  1. #include "precomp.h"
  2. #include "rsop.h"
  3. /////////////////////////////////////////////////////////////////////
  4. void InitUrlsDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  5. {
  6. __try
  7. {
  8. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  9. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass);
  10. if (SUCCEEDED(hr))
  11. {
  12. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  13. long nPSObjects = pDRD->GetPSObjCount();
  14. BOOL bHomeHandled = FALSE;
  15. BOOL bSearchHandled = FALSE;
  16. BOOL bSupportHandled = FALSE;
  17. for (long nObj = 0; nObj < nPSObjects; nObj++)
  18. {
  19. // homePageURL field
  20. _variant_t vtValue;
  21. if (!bHomeHandled)
  22. {
  23. hr = paPSObj[nObj]->pObj->Get(L"homePageURL", 0, &vtValue, NULL, NULL);
  24. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  25. {
  26. _bstr_t bstrValue = vtValue;
  27. BOOL bChecked = (bstrValue.length() > 0);
  28. SetDlgItemTextTriState(hDlg, IDE_STARTPAGE, IDC_STARTPAGE, (LPTSTR)bstrValue, bChecked);
  29. bHomeHandled = TRUE;
  30. }
  31. }
  32. // searchBarURL field
  33. vtValue;
  34. if (!bSearchHandled)
  35. {
  36. hr = paPSObj[nObj]->pObj->Get(L"searchBarURL", 0, &vtValue, NULL, NULL);
  37. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  38. {
  39. _bstr_t bstrValue = vtValue;
  40. BOOL bChecked = (bstrValue.length() > 0);
  41. SetDlgItemTextTriState(hDlg, IDE_SEARCHPAGE, IDC_SEARCHPAGE, (LPTSTR)bstrValue, bChecked);
  42. bSearchHandled = TRUE;
  43. }
  44. }
  45. // onlineHelpPageURL field
  46. vtValue;
  47. if (!bSupportHandled)
  48. {
  49. hr = paPSObj[nObj]->pObj->Get(L"onlineHelpPageURL", 0, &vtValue, NULL, NULL);
  50. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  51. {
  52. _bstr_t bstrValue = vtValue;
  53. BOOL bChecked = (bstrValue.length() > 0);
  54. SetDlgItemTextTriState(hDlg, IDE_CUSTOMSUPPORT, IDC_CUSTOMSUPPORT, (LPTSTR)bstrValue, bChecked);
  55. bSupportHandled = TRUE;
  56. }
  57. }
  58. // no need to process other GPOs since enabled properties have been found
  59. if (bHomeHandled && bSearchHandled && bSupportHandled)
  60. break;
  61. }
  62. }
  63. EnableDlgItem2(hDlg, IDC_STARTPAGE, FALSE);
  64. EnableDlgItem2(hDlg, IDE_STARTPAGE, FALSE);
  65. EnableDlgItem2(hDlg, IDC_SEARCHPAGE, FALSE);
  66. EnableDlgItem2(hDlg, IDE_SEARCHPAGE, FALSE);
  67. EnableDlgItem2(hDlg, IDC_CUSTOMSUPPORT, FALSE);
  68. EnableDlgItem2(hDlg, IDE_CUSTOMSUPPORT, FALSE);
  69. }
  70. __except(TRUE)
  71. {
  72. }
  73. }
  74. /////////////////////////////////////////////////////////////////////
  75. HRESULT InitHomePageUrlPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  76. {
  77. return InitGenericPrecedencePage(pDRD, hwndList, L"homePageURL");
  78. }
  79. /////////////////////////////////////////////////////////////////////
  80. HRESULT InitSearchBarUrlPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  81. {
  82. return InitGenericPrecedencePage(pDRD, hwndList, L"searchBarURL");
  83. }
  84. /////////////////////////////////////////////////////////////////////
  85. HRESULT InitSupportPageUrlPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  86. {
  87. return InitGenericPrecedencePage(pDRD, hwndList, L"onlineHelpPageURL");
  88. }
  89. /////////////////////////////////////////////////////////////////////
  90. INT_PTR CALLBACK UrlsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  91. {
  92. // Retrieve Property Sheet Page info for each call into dlg proc.
  93. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  94. BOOL fStartPage, fSearchPage, fSupportPage;
  95. int nStatus;
  96. switch( msg )
  97. {
  98. case WM_INITDIALOG:
  99. SetPropSheetCookie(hDlg, lParam);
  100. EnableDBCSChars(hDlg, IDE_STARTPAGE);
  101. EnableDBCSChars(hDlg, IDE_SEARCHPAGE);
  102. EnableDBCSChars(hDlg, IDE_CUSTOMSUPPORT);
  103. // find out if this dlg is in RSoP mode
  104. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  105. if (psCookie->pCS->IsRSoP())
  106. {
  107. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  108. if (pDRD)
  109. InitUrlsDlgInRSoPMode(hDlg, pDRD);
  110. }
  111. else
  112. {
  113. Edit_LimitText(GetDlgItem(hDlg, IDE_STARTPAGE), INTERNET_MAX_URL_LENGTH - 1);
  114. Edit_LimitText(GetDlgItem(hDlg, IDE_SEARCHPAGE), INTERNET_MAX_URL_LENGTH - 1);
  115. Edit_LimitText(GetDlgItem(hDlg, IDE_CUSTOMSUPPORT), INTERNET_MAX_URL_LENGTH - 1);
  116. // disable customization of search and online support page in preference mode
  117. if (!InsIsKeyEmpty(IS_BRANDING, IK_GPE_ONETIME_GUID, GetInsFile(hDlg)))
  118. {
  119. int rgids[] = { IDC_SEARCHPAGE, IDC_SEARCHPAGE_TXT, IDE_SEARCHPAGE,
  120. IDC_CUSTOMSUPPORT, IDC_CUSTOMSUPPORT_TXT, IDE_CUSTOMSUPPORT};
  121. DisableDlgItems(hDlg, rgids, countof(rgids));
  122. }
  123. }
  124. break;
  125. case WM_DESTROY:
  126. if (psCookie->pCS->IsRSoP())
  127. DestroyDlgRSoPData(hDlg);
  128. break;
  129. case WM_COMMAND:
  130. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  131. return FALSE;
  132. switch (GET_WM_COMMAND_ID(wParam, lParam))
  133. {
  134. case IDC_STARTPAGE:
  135. fStartPage = (IsDlgButtonChecked(hDlg, IDC_STARTPAGE) == BST_CHECKED);
  136. EnableDlgItem2(hDlg, IDE_STARTPAGE, fStartPage);
  137. EnableDlgItem2(hDlg, IDC_STARTPAGE_TXT, fStartPage);
  138. break;
  139. case IDC_SEARCHPAGE:
  140. fSearchPage = (IsDlgButtonChecked(hDlg, IDC_SEARCHPAGE) == BST_CHECKED);
  141. EnableDlgItem2(hDlg, IDE_SEARCHPAGE, fSearchPage);
  142. EnableDlgItem2(hDlg, IDC_SEARCHPAGE_TXT, fSearchPage);
  143. break;
  144. case IDC_CUSTOMSUPPORT:
  145. fSupportPage = (IsDlgButtonChecked(hDlg, IDC_CUSTOMSUPPORT) == BST_CHECKED);
  146. EnableDlgItem2(hDlg, IDE_CUSTOMSUPPORT, fSupportPage);
  147. EnableDlgItem2(hDlg, IDC_CUSTOMSUPPORT_TXT, fSupportPage);
  148. break;
  149. default:
  150. return FALSE;
  151. }
  152. break;
  153. case WM_HELP: // F1
  154. ShowHelpTopic(hDlg);
  155. break;
  156. case WM_NOTIFY:
  157. switch (((LPNMHDR)lParam)->code)
  158. {
  159. TCHAR szMsgTitle[1024];
  160. TCHAR szMsgText[1024];
  161. case PSN_HELP:
  162. ShowHelpTopic(hDlg);
  163. break;
  164. case PSN_SETACTIVE:
  165. // don't do any of this stuff in RSoP mode
  166. if (!psCookie->pCS->IsRSoP())
  167. {
  168. // BUGBUG: <oliverl> revisit this in IE6 when we have server-side file
  169. InitializeStartSearch(hDlg, GetInsFile(hDlg), NULL);
  170. }
  171. break;
  172. case PSN_APPLY:
  173. if (psCookie->pCS->IsRSoP())
  174. return FALSE;
  175. else
  176. {
  177. // BUGBUG: <oliverl> revisit this in IE6 when we have server-side file
  178. fStartPage = (IsDlgButtonChecked(hDlg, IDC_STARTPAGE) == BST_CHECKED);
  179. fSearchPage = (IsDlgButtonChecked(hDlg, IDC_SEARCHPAGE) == BST_CHECKED);
  180. fSupportPage = (IsDlgButtonChecked(hDlg, IDC_CUSTOMSUPPORT) == BST_CHECKED);
  181. if ((fStartPage && !CheckField(hDlg, IDE_STARTPAGE, FC_URL)) ||
  182. (fSearchPage && !CheckField(hDlg, IDE_SEARCHPAGE, FC_URL)) ||
  183. (fSupportPage && !CheckField(hDlg, IDE_CUSTOMSUPPORT, FC_URL)))
  184. {
  185. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  186. break;
  187. }
  188. nStatus = TS_CHECK_OK;
  189. IsTriStateValid(hDlg, IDE_STARTPAGE, IDC_STARTPAGE, &nStatus,
  190. res2Str(IDS_QUERY_CLEARSETTING, szMsgText, countof(szMsgText)),
  191. res2Str(IDS_TITLE, szMsgTitle, countof(szMsgTitle)));
  192. IsTriStateValid(hDlg, IDE_SEARCHPAGE, IDC_SEARCHPAGE, &nStatus, szMsgText, szMsgTitle);
  193. IsTriStateValid(hDlg, IDE_CUSTOMSUPPORT, IDC_CUSTOMSUPPORT, &nStatus, szMsgText, szMsgTitle);
  194. if (nStatus == TS_CHECK_ERROR ||
  195. !AcquireWriteCriticalSection(hDlg))
  196. {
  197. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  198. break;
  199. }
  200. SaveStartSearch(hDlg, GetInsFile(hDlg), NULL);
  201. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  202. }
  203. break;
  204. default:
  205. return FALSE;
  206. }
  207. break;
  208. default:
  209. return FALSE;
  210. }
  211. return TRUE;
  212. }