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.

353 lines
11 KiB

  1. #include "precomp.h"
  2. #include <inetcpl.h>
  3. #include "rsop.h"
  4. #include <tchar.h>
  5. static INT_PTR CALLBACK importProgramsRSoPProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  6. /////////////////////////////////////////////////////////////////////
  7. void InitProgramsDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  8. {
  9. __try
  10. {
  11. BOOL bImport = FALSE;
  12. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  13. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass);
  14. if (SUCCEEDED(hr))
  15. {
  16. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  17. long nPSObjects = pDRD->GetPSObjCount();
  18. for (long nObj = 0; nObj < nPSObjects; nObj++)
  19. {
  20. // importProgramSettings field
  21. _variant_t vtValue;
  22. hr = paPSObj[nObj]->pObj->Get(L"importProgramSettings", 0, &vtValue, NULL, NULL);
  23. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  24. {
  25. bImport = (bool)vtValue ? TRUE : FALSE;
  26. CheckRadioButton(hDlg, IDC_PROGNOIMPORT, IDC_PROGIMPORT,
  27. (bool)vtValue ? IDC_PROGIMPORT : IDC_PROGNOIMPORT);
  28. DWORD dwCurGPOPrec = GetGPOPrecedence(paPSObj[nObj]->pObj);
  29. pDRD->SetImportedProgSettPrec(dwCurGPOPrec);
  30. break;
  31. }
  32. }
  33. }
  34. EnableDlgItem2(hDlg, IDC_PROGNOIMPORT, FALSE);
  35. EnableDlgItem2(hDlg, IDC_PROGIMPORT, FALSE);
  36. EnableDlgItem2(hDlg, IDC_MODIFYPROG, bImport);
  37. }
  38. __except(TRUE)
  39. {
  40. }
  41. }
  42. /////////////////////////////////////////////////////////////////////
  43. HRESULT InitProgramsPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  44. {
  45. HRESULT hr = NOERROR;
  46. __try
  47. {
  48. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  49. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  50. if (SUCCEEDED(hr))
  51. {
  52. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  53. long nPSObjects = pDRD->GetPSObjCount();
  54. for (long nObj = 0; nObj < nPSObjects; nObj++)
  55. {
  56. _bstr_t bstrGPOName = pDRD->GetGPONameFromPS(paPSObj[nObj]->pObj);
  57. // importProgramSettings field
  58. BOOL bImport = FALSE;
  59. _variant_t vtValue;
  60. hr = paPSObj[nObj]->pObj->Get(L"importProgramSettings", 0, &vtValue, NULL, NULL);
  61. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  62. bImport = (bool)vtValue ? TRUE : FALSE;
  63. _bstr_t bstrSetting;
  64. if (bImport)
  65. {
  66. TCHAR szTemp[MAX_PATH];
  67. LoadString(g_hInstance, IDS_IMPORT_PROG_SETTING, szTemp, countof(szTemp));
  68. bstrSetting = szTemp;
  69. }
  70. else
  71. bstrSetting = GetDisabledString();
  72. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  73. }
  74. }
  75. }
  76. __except(TRUE)
  77. {
  78. }
  79. return hr;
  80. }
  81. /////////////////////////////////////////////////////////////////////
  82. INT_PTR CALLBACK ProgramsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  83. {
  84. // Retrieve Property Sheet Page info for each call into dlg proc.
  85. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  86. TCHAR szWorkDir[MAX_PATH];
  87. BOOL fImport;
  88. switch( msg )
  89. {
  90. case WM_INITDIALOG:
  91. SetPropSheetCookie(hDlg, lParam);
  92. // find out if this dlg is in RSoP mode
  93. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  94. if (psCookie->pCS->IsRSoP())
  95. {
  96. CheckRadioButton(hDlg, IDC_PROGNOIMPORT, IDC_PROGIMPORT, IDC_PROGNOIMPORT);
  97. TCHAR szViewSettings[128];
  98. LoadString(g_hInstance, IDS_VIEW_SETTINGS, szViewSettings, countof(szViewSettings));
  99. SetDlgItemText(hDlg, IDC_MODIFYPROG, szViewSettings);
  100. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  101. InitProgramsDlgInRSoPMode(hDlg, pDRD);
  102. }
  103. else
  104. {
  105. fImport = !InsIsKeyEmpty(IS_EXTREGINF, IK_PROGRAMS, GetInsFile(hDlg));
  106. EnableDlgItem2(hDlg, IDC_MODIFYPROG, fImport);
  107. CheckRadioButton(hDlg, IDC_PROGNOIMPORT, IDC_PROGIMPORT, fImport ? IDC_PROGIMPORT : IDC_PROGNOIMPORT);
  108. }
  109. break;
  110. case WM_DESTROY:
  111. if (psCookie->pCS->IsRSoP())
  112. DestroyDlgRSoPData(hDlg);
  113. break;
  114. case WM_COMMAND:
  115. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  116. return FALSE;
  117. switch (GET_WM_COMMAND_ID(wParam, lParam))
  118. {
  119. case IDC_PROGNOIMPORT:
  120. EnableDlgItem2(hDlg, IDC_MODIFYPROG, FALSE);
  121. break;
  122. case IDC_PROGIMPORT:
  123. EnableDlgItem(hDlg, IDC_MODIFYPROG);
  124. break;
  125. case IDC_MODIFYPROG:
  126. if (psCookie->pCS->IsRSoP())
  127. {
  128. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  129. if (NULL != pDRD)
  130. {
  131. CreateINetCplLookALikePage(hDlg, IDD_IMPORTEDPROGRAMS,
  132. importProgramsRSoPProc, (LPARAM)pDRD);
  133. }
  134. }
  135. else
  136. ShowInetcpl(hDlg, INET_PAGE_PROGRAMS);
  137. break;
  138. default:
  139. return FALSE;
  140. }
  141. break;
  142. case WM_HELP: // F1
  143. ShowHelpTopic(hDlg);
  144. break;
  145. case WM_NOTIFY:
  146. switch (((LPNMHDR)lParam)->code)
  147. {
  148. case PSN_HELP:
  149. ShowHelpTopic(hDlg);
  150. break;
  151. case PSN_APPLY:
  152. if (psCookie->pCS->IsRSoP())
  153. return FALSE;
  154. else
  155. {
  156. CreateWorkDir(GetInsFile(hDlg), IEAK_GPE_BRANDING_SUBDIR TEXT("\\PROGRAMS"), szWorkDir);
  157. if (!AcquireWriteCriticalSection(hDlg))
  158. {
  159. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  160. break;
  161. }
  162. ImportPrograms(GetInsFile(hDlg), szWorkDir,
  163. (IsDlgButtonChecked(hDlg, IDC_PROGIMPORT) == BST_CHECKED));
  164. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  165. if (PathIsDirectoryEmpty(szWorkDir))
  166. PathRemovePath(szWorkDir);
  167. }
  168. break;
  169. default:
  170. return FALSE;
  171. }
  172. break;
  173. default:
  174. return FALSE;
  175. }
  176. return TRUE;
  177. }
  178. //*******************************************************************
  179. // CODE FROM INETCPL
  180. //*******************************************************************
  181. /////////////////////////////////////////////////////////////////////
  182. void InitImportedProgramsDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  183. {
  184. __try
  185. {
  186. if (NULL != pDRD->ConnectToNamespace())
  187. {
  188. // get our stored precedence value
  189. DWORD dwCurGPOPrec = pDRD->GetImportedProgSettPrec();
  190. // create the object path of the program settings for this GPO
  191. WCHAR wszObjPath[128];
  192. wnsprintf(wszObjPath, countof(wszObjPath),
  193. L"RSOP_IEProgramSettings.rsopID=\"IEAK\",rsopPrecedence=%ld", dwCurGPOPrec);
  194. _bstr_t bstrObjPath = wszObjPath;
  195. // get the RSOP_IEProgramSettings object and its properties
  196. ComPtr<IWbemServices> pWbemServices = pDRD->GetWbemServices();
  197. ComPtr<IWbemClassObject> pPSObj = NULL;
  198. HRESULT hr = pWbemServices->GetObject(bstrObjPath, 0L, NULL, (IWbemClassObject**)&pPSObj, NULL);
  199. if (SUCCEEDED(hr))
  200. {
  201. // htmlEditorProgram field
  202. _variant_t vtValue;
  203. _bstr_t bstrValue;
  204. hr = pPSObj->Get(L"htmlEditorProgram", 0, &vtValue, NULL, NULL);
  205. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  206. {
  207. bstrValue = vtValue;
  208. SendDlgItemMessage(hDlg, IDC_PROGRAMS_HTMLEDITOR_COMBO, CB_ADDSTRING, 0,
  209. (LPARAM)((LPCTSTR)bstrValue));
  210. SendDlgItemMessage(hDlg, IDC_PROGRAMS_HTMLEDITOR_COMBO, CB_SETCURSEL, 0, 0L);
  211. }
  212. // emailProgram field
  213. hr = pPSObj->Get(L"emailProgram", 0, &vtValue, NULL, NULL);
  214. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  215. {
  216. bstrValue = vtValue;
  217. SendDlgItemMessage(hDlg, IDC_PROGRAMS_MAIL_COMBO, CB_ADDSTRING, 0,
  218. (LPARAM)((LPCTSTR)bstrValue));
  219. SendDlgItemMessage(hDlg, IDC_PROGRAMS_MAIL_COMBO, CB_SETCURSEL, 0, 0L);
  220. }
  221. // newsgroupsProgram field
  222. hr = pPSObj->Get(L"newsgroupsProgram", 0, &vtValue, NULL, NULL);
  223. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  224. {
  225. bstrValue = vtValue;
  226. SendDlgItemMessage(hDlg, IDC_PROGRAMS_NEWS_COMBO, CB_ADDSTRING, 0,
  227. (LPARAM)((LPCTSTR)bstrValue));
  228. SendDlgItemMessage(hDlg, IDC_PROGRAMS_NEWS_COMBO, CB_SETCURSEL, 0, 0L);
  229. }
  230. // internetCallProgram field
  231. hr = pPSObj->Get(L"internetCallProgram", 0, &vtValue, NULL, NULL);
  232. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  233. {
  234. bstrValue = vtValue;
  235. SendDlgItemMessage(hDlg, IDC_PROGRAMS_CALL_COMBO, CB_ADDSTRING, 0,
  236. (LPARAM)((LPCTSTR)bstrValue));
  237. SendDlgItemMessage(hDlg, IDC_PROGRAMS_CALL_COMBO, CB_SETCURSEL, 0, 0L);
  238. }
  239. // calendarProgram field
  240. hr = pPSObj->Get(L"calendarProgram", 0, &vtValue, NULL, NULL);
  241. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  242. {
  243. bstrValue = vtValue;
  244. SendDlgItemMessage(hDlg, IDC_PROGRAMS_CALENDAR_COMBO, CB_ADDSTRING, 0,
  245. (LPARAM)((LPCTSTR)bstrValue));
  246. SendDlgItemMessage(hDlg, IDC_PROGRAMS_CALENDAR_COMBO, CB_SETCURSEL, 0, 0L);
  247. }
  248. // contactListProgram field
  249. hr = pPSObj->Get(L"contactListProgram", 0, &vtValue, NULL, NULL);
  250. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  251. {
  252. bstrValue = vtValue;
  253. SendDlgItemMessage(hDlg, IDC_PROGRAMS_CONTACT_COMBO, CB_ADDSTRING, 0,
  254. (LPARAM)((LPCTSTR)bstrValue));
  255. SendDlgItemMessage(hDlg, IDC_PROGRAMS_CONTACT_COMBO, CB_SETCURSEL, 0, 0L);
  256. }
  257. // checkIfIEIsDefaultBrowser field
  258. hr = pPSObj->Get(L"checkIfIEIsDefaultBrowser", 0, &vtValue, NULL, NULL);
  259. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  260. {
  261. if ((bool)vtValue)
  262. CheckDlgButton(hDlg, IDC_CHECK_ASSOCIATIONS_CHECKBOX, BST_CHECKED);
  263. }
  264. // IDC_PROGRAMS_IE_IS_FTPCLIENT
  265. }
  266. }
  267. }
  268. __except(TRUE)
  269. {
  270. }
  271. }
  272. /////////////////////////////////////////////////////////////////////
  273. INT_PTR CALLBACK importProgramsRSoPProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  274. {
  275. BOOL fResult = FALSE;
  276. switch (uMsg) {
  277. case WM_INITDIALOG:
  278. {
  279. CDlgRSoPData *pDRD = (CDlgRSoPData*)((LPPROPSHEETPAGE)lParam)->lParam;
  280. InitImportedProgramsDlgInRSoPMode(hDlg, pDRD);
  281. EnableDlgItem2(hDlg, IDC_PROGRAMS_HTMLEDITOR_COMBO, FALSE);
  282. EnableDlgItem2(hDlg, IDC_PROGRAMS_MAIL_COMBO, FALSE);
  283. EnableDlgItem2(hDlg, IDC_PROGRAMS_NEWS_COMBO, FALSE);
  284. EnableDlgItem2(hDlg, IDC_PROGRAMS_CALL_COMBO, FALSE);
  285. EnableDlgItem2(hDlg, IDC_PROGRAMS_CALENDAR_COMBO, FALSE);
  286. EnableDlgItem2(hDlg, IDC_PROGRAMS_CONTACT_COMBO, FALSE);
  287. EnableDlgItem2(hDlg, IDC_RESETWEBSETTINGS, FALSE);
  288. EnableDlgItem2(hDlg, IDC_CHECK_ASSOCIATIONS_CHECKBOX, FALSE);
  289. EnableDlgItem2(hDlg, IDC_PROGRAMS_IE_IS_FTPCLIENT, FALSE);
  290. fResult = TRUE;
  291. break;
  292. }
  293. case WM_COMMAND:
  294. switch (LOWORD(wParam)) {
  295. case IDOK:
  296. EndDialog(hDlg, IDOK);
  297. fResult = TRUE;
  298. break;
  299. case IDCANCEL:
  300. EndDialog(hDlg, IDCANCEL);
  301. fResult = TRUE;
  302. break;
  303. }
  304. break;
  305. }
  306. return fResult;
  307. }