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.

421 lines
12 KiB

  1. #include "precomp.h"
  2. #include "rsop.h"
  3. #include "channels.h"
  4. #include <tchar.h>
  5. static BOOL CALLBACK addEditChannelRSoPProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  6. /////////////////////////////////////////////////////////////////////
  7. DWORD AddItemsToList(HWND hwndList, CDlgRSoPData *pDRD, BSTR bstrTempClass,
  8. BOOL bCategory, PCHANNEL paChannels)
  9. {
  10. DWORD dwRet = 0;
  11. __try
  12. {
  13. _bstr_t bstrClass = bstrTempClass;
  14. CPSObjData **paObj = NULL;
  15. long nObjects = 0;
  16. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass, L"rsopPrecedence",
  17. &paObj, &nObjects);
  18. if (SUCCEEDED(hr))
  19. {
  20. // For each button returned from any GPO
  21. long nObj;
  22. PCHANNEL pChan;
  23. for (nObj = 0, pChan = paChannels; nObj < nObjects; nObj++, pChan++)
  24. {
  25. _bstr_t bstrGPOName = L" (";
  26. bstrGPOName += pDRD->GetGPONameFromPSAssociation(paObj[nObj]->pObj,
  27. L"rsopPrecedence") +
  28. L")";
  29. pChan->fCategory = bCategory;
  30. // title field
  31. _variant_t vtValue;
  32. hr = paObj[nObj]->pObj->Get(L"title", 0, &vtValue, NULL, NULL);
  33. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  34. {
  35. _bstr_t bstrValue = vtValue;
  36. _bstr_t bstrEntry = bstrValue + bstrGPOName;
  37. StrCpy(pChan->szTitle, (LPCTSTR)bstrValue);
  38. if (bCategory)
  39. {
  40. // categoryHTMLPage field
  41. hr = paObj[nObj]->pObj->Get(L"categoryHTMLPage", 0, &vtValue, NULL, NULL);
  42. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  43. {
  44. bstrValue = vtValue;
  45. StrCpy(pChan->szWebUrl, (LPCTSTR)bstrValue);
  46. }
  47. }
  48. else
  49. {
  50. // channelDefinitionURL field
  51. hr = paObj[nObj]->pObj->Get(L"channelDefinitionURL", 0, &vtValue, NULL, NULL);
  52. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  53. {
  54. bstrValue = vtValue;
  55. StrCpy(pChan->szWebUrl, (LPCTSTR)bstrValue);
  56. }
  57. // channelDefinitionFilePath field
  58. hr = paObj[nObj]->pObj->Get(L"channelDefinitionFilePath", 0, &vtValue, NULL, NULL);
  59. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  60. {
  61. bstrValue = vtValue;
  62. StrCpy(pChan->szPreUrlPath, (LPCTSTR)bstrValue);
  63. }
  64. // makeAvailableOffline
  65. hr = paObj[nObj]->pObj->Get(L"makeAvailableOffline", 0, &vtValue, NULL, NULL);
  66. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  67. pChan->fOffline = (bool)vtValue ? TRUE : FALSE;
  68. }
  69. // iconPath field
  70. hr = paObj[nObj]->pObj->Get(L"iconPath", 0, &vtValue, NULL, NULL);
  71. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  72. {
  73. bstrValue = vtValue;
  74. StrCpy(pChan->szIcon, (LPCTSTR)bstrValue);
  75. }
  76. // narrowImagePath field
  77. hr = paObj[nObj]->pObj->Get(L"narrowImagePath", 0, &vtValue, NULL, NULL);
  78. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  79. {
  80. bstrValue = vtValue;
  81. StrCpy(pChan->szLogo, (LPCTSTR)bstrValue);
  82. }
  83. int nItem = (int)SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)((LPCTSTR)bstrEntry));
  84. SendMessage(hwndList, LB_SETITEMDATA, (WPARAM)nItem, (LPARAM)pChan);
  85. }
  86. }
  87. dwRet = nObj;
  88. CoTaskMemFree(paObj);
  89. }
  90. }
  91. __except(TRUE)
  92. {
  93. }
  94. return dwRet;
  95. }
  96. /////////////////////////////////////////////////////////////////////
  97. DWORD InitChannelsDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  98. {
  99. DWORD dwRet = 0;
  100. __try
  101. {
  102. // First go through all PS objects and look for channels data
  103. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  104. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass);
  105. if (SUCCEEDED(hr))
  106. {
  107. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  108. long nPSObjects = pDRD->GetPSObjCount();
  109. BOOL bDeleteHandled = FALSE;
  110. BOOL bEnableHandled = FALSE;
  111. for (long nObj = 0; nObj < nPSObjects; nObj++)
  112. {
  113. // deleteExistingChannels field
  114. _variant_t vtValue;
  115. if (!bDeleteHandled)
  116. {
  117. hr = paPSObj[nObj]->pObj->Get(L"deleteExistingChannels", 0, &vtValue, NULL, NULL);
  118. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  119. {
  120. if ((bool)vtValue)
  121. CheckDlgButton(hDlg, IDC_DELETECHANNELS, BST_CHECKED);
  122. bDeleteHandled = TRUE;
  123. }
  124. }
  125. // enableDesktopChannelBarByDefault field
  126. if (!bEnableHandled)
  127. {
  128. hr = paPSObj[nObj]->pObj->Get(L"enableDesktopChannelBarByDefault", 0, &vtValue, NULL, NULL);
  129. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  130. {
  131. if ((bool)vtValue)
  132. CheckDlgButton(hDlg, IDC_CHANBARON, BST_CHECKED);
  133. bEnableHandled = TRUE;
  134. }
  135. }
  136. // no need to process other GPOs since enabled properties have been found
  137. if (bDeleteHandled && bEnableHandled)
  138. break;
  139. }
  140. }
  141. EnableDlgItem2(hDlg, IDC_DELETECHANNELS, FALSE);
  142. EnableDlgItem2(hDlg, IDC_CHANBARON, FALSE);
  143. EnableDlgItem2(hDlg, IDC_DELETELINKS, FALSE);
  144. // Now go through all Channel & Category objects and populate the list
  145. HWND hwndList = GetDlgItem(hDlg, IDC_CHANNELLIST);
  146. SendDlgItemMessage(hDlg, IDC_CHANNELLIST, LB_RESETCONTENT, 0, 0);
  147. PCHANNEL paChannels = (PCHANNEL)CoTaskMemAlloc(sizeof(CHANNEL) * MAX_CHAN);
  148. if (NULL != paChannels)
  149. {
  150. ZeroMemory(paChannels, sizeof(CHANNEL) * MAX_CHAN);
  151. PCHANNEL paOldChannels = (PCHANNEL)SetWindowLongPtr(hwndList, GWLP_USERDATA, (LONG_PTR)paChannels);
  152. // delete previous allocation(mainly for profile manager)
  153. if (paOldChannels != NULL)
  154. CoTaskMemFree(paOldChannels);
  155. AddItemsToList(hwndList, pDRD, L"RSOP_IEChannelItem", FALSE, paChannels);
  156. AddItemsToList(hwndList, pDRD, L"RSOP_IECategoryItem", TRUE, paChannels);
  157. }
  158. SendMessage(hwndList, LB_SETCURSEL, (WPARAM)-1, 0);
  159. EnableDlgItem2(hDlg, IDC_ADDCATEGORY, FALSE);
  160. EnableDlgItem2(hDlg, IDC_ADDCHANNEL, FALSE);
  161. EnableDlgItem2(hDlg, IDC_REMOVECHANNEL, FALSE);
  162. EnableDlgItem2(hDlg, IDC_EDITCHANNEL, FALSE);
  163. EnableDlgItem2(hDlg, IDC_IMPORTCHAN, FALSE);
  164. }
  165. __except(TRUE)
  166. {
  167. }
  168. return dwRet;
  169. }
  170. /////////////////////////////////////////////////////////////////////
  171. HRESULT InitChanDeletePrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  172. {
  173. HRESULT hr = NOERROR;
  174. __try
  175. {
  176. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  177. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  178. if (SUCCEEDED(hr))
  179. {
  180. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  181. long nPSObjects = pDRD->GetPSObjCount();
  182. for (long nObj = 0; nObj < nPSObjects; nObj++)
  183. {
  184. _bstr_t bstrGPOName = pDRD->GetGPONameFromPS(paPSObj[nObj]->pObj);
  185. // deleteExistingChannels field
  186. BOOL bDelete = FALSE;
  187. _variant_t vtValue;
  188. hr = paPSObj[nObj]->pObj->Get(L"deleteExistingChannels", 0, &vtValue, NULL, NULL);
  189. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  190. bDelete = (bool)vtValue ? TRUE : FALSE;
  191. _bstr_t bstrSetting;
  192. if (bDelete)
  193. {
  194. TCHAR szTemp[MAX_PATH];
  195. LoadString(g_hInstance, IDS_DELETE_CHAN_SETTING, szTemp, countof(szTemp));
  196. bstrSetting = szTemp;
  197. }
  198. else
  199. bstrSetting = GetDisabledString();
  200. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  201. }
  202. }
  203. }
  204. __except(TRUE)
  205. {
  206. }
  207. return hr;
  208. }
  209. /////////////////////////////////////////////////////////////////////
  210. HRESULT InitChanEnablePrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  211. {
  212. HRESULT hr = NOERROR;
  213. __try
  214. {
  215. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  216. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  217. if (SUCCEEDED(hr))
  218. {
  219. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  220. long nPSObjects = pDRD->GetPSObjCount();
  221. for (long nObj = 0; nObj < nPSObjects; nObj++)
  222. {
  223. _bstr_t bstrGPOName = pDRD->GetGPONameFromPS(paPSObj[nObj]->pObj);
  224. // enableDesktopChannelBarByDefault field
  225. BOOL bEnable = FALSE;
  226. _variant_t vtValue;
  227. hr = paPSObj[nObj]->pObj->Get(L"enableDesktopChannelBarByDefault", 0, &vtValue, NULL, NULL);
  228. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  229. bEnable = (bool)vtValue ? TRUE : FALSE;
  230. _bstr_t bstrSetting;
  231. if (bEnable)
  232. {
  233. TCHAR szTemp[MAX_PATH];
  234. LoadString(g_hInstance, IDS_ENABLE_CHBAR_SETTING, szTemp, countof(szTemp));
  235. bstrSetting = szTemp;
  236. }
  237. else
  238. bstrSetting = GetDisabledString();
  239. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  240. }
  241. }
  242. }
  243. __except(TRUE)
  244. {
  245. }
  246. return hr;
  247. }
  248. /////////////////////////////////////////////////////////////////////
  249. HRESULT InitChannelsPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  250. {
  251. HRESULT hr = NOERROR;
  252. __try
  253. {
  254. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  255. hr = pDRD->GetArrayOfPSObjects(bstrClass);
  256. if (SUCCEEDED(hr))
  257. {
  258. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  259. long nPSObjects = pDRD->GetPSObjCount();
  260. for (long nObj = 0; nObj < nPSObjects; nObj++)
  261. {
  262. _bstr_t bstrGPOName = pDRD->GetGPONameFromPS(paPSObj[nObj]->pObj);
  263. // channels field
  264. long nChan = 0, nCat = 0;
  265. _variant_t vtValue;
  266. hr = paPSObj[nObj]->pObj->Get(L"channels", 0, &vtValue, NULL, NULL);
  267. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  268. nChan = vtValue;
  269. // categories field
  270. hr = paPSObj[nObj]->pObj->Get(L"categories", 0, &vtValue, NULL, NULL);
  271. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  272. nCat = vtValue;
  273. _bstr_t bstrSetting;
  274. if (nChan > 0 || nCat > 0)
  275. {
  276. TCHAR szTemp[MAX_PATH];
  277. LoadString(g_hInstance, IDS_CHAN_AND_CAT_SETTING, szTemp, countof(szTemp));
  278. TCHAR szSetting[MAX_PATH];
  279. wnsprintf(szSetting, countof(szSetting), szTemp, nChan, nCat);
  280. bstrSetting = szSetting;
  281. }
  282. else
  283. bstrSetting = GetDisabledString();
  284. InsertPrecedenceListItem(hwndList, nObj, bstrGPOName, bstrSetting);
  285. }
  286. }
  287. }
  288. __except(TRUE)
  289. {
  290. }
  291. return hr;
  292. }
  293. /////////////////////////////////////////////////////////////////////
  294. BOOL CALLBACK addEditChannelRSoPProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  295. {
  296. switch (uMsg)
  297. {
  298. case WM_INITDIALOG:
  299. {
  300. PCHANNEL pSelCh = (PCHANNEL)lParam;
  301. if (pSelCh->fCategory)
  302. {
  303. EnableDBCSChars(hDlg, IDC_CATEGORYHTML);
  304. EnableDBCSChars(hDlg, IDE_CATEGORYTITLE);
  305. SetDlgItemText(hDlg, IDC_CATEGORYHTML, pSelCh->szWebUrl);
  306. SetDlgItemText(hDlg, IDE_CATEGORYTITLE, pSelCh->szTitle);
  307. EnableDlgItem2(hDlg, IDC_CATEGORYHTML, FALSE);
  308. EnableDlgItem2(hDlg, IDE_CATEGORYTITLE, FALSE);
  309. EnableDlgItem2(hDlg, IDC_BROWSECATHTML, FALSE);
  310. }
  311. else
  312. {
  313. EnableDBCSChars(hDlg, IDE_CHANNELSRVURL2);
  314. EnableDBCSChars(hDlg, IDE_CHANNELTITLE2);
  315. SetDlgItemText(hDlg, IDE_CHANNELSRVURL2, pSelCh->szWebUrl);
  316. SetDlgItemText(hDlg, IDE_CHANNELTITLE2, pSelCh->szTitle);
  317. EnableDlgItem2(hDlg, IDE_CHANNELSRVURL2, FALSE);
  318. EnableDlgItem2(hDlg, IDE_CHANNELTITLE2, FALSE);
  319. EnableDlgItem2(hDlg, IDC_BROWSECDF2, FALSE);
  320. }
  321. EnableDBCSChars(hDlg, IDC_CHANNELBITMAP2);
  322. EnableDBCSChars(hDlg, IDC_CHANNELICON2);
  323. SetDlgItemText(hDlg, IDC_CHANNELBITMAP2, pSelCh->szLogo);
  324. SetDlgItemText(hDlg, IDC_CHANNELICON2, pSelCh->szIcon);
  325. EnableDlgItem2(hDlg, IDC_CHANNELBITMAP2, FALSE);
  326. EnableDlgItem2(hDlg, IDC_CHANNELICON2, FALSE);
  327. EnableDlgItem2(hDlg, IDC_BROWSECHICO2, FALSE);
  328. EnableDlgItem2(hDlg, IDC_BROWSECHBMP2, FALSE);
  329. if (!pSelCh->fCategory)
  330. {
  331. EnableDBCSChars(hDlg, IDC_CHANNELURL2);
  332. SetDlgItemText(hDlg, IDC_CHANNELURL2, pSelCh->szPreUrlPath);
  333. if (pSelCh->fOffline)
  334. CheckDlgButton(hDlg, IDC_CHANNELOFFL, BST_CHECKED);
  335. EnableDlgItem2(hDlg, IDC_CHANNELURL2, FALSE);
  336. EnableDlgItem2(hDlg, IDC_CHANNELOFFL, FALSE);
  337. }
  338. break;
  339. }
  340. case WM_COMMAND:
  341. switch(HIWORD(wParam))
  342. {
  343. case BN_CLICKED:
  344. switch (LOWORD(wParam))
  345. {
  346. case IDCANCEL:
  347. EndDialog( hDlg, IDCANCEL );
  348. break;
  349. case IDOK:
  350. EndDialog( hDlg, IDOK );
  351. break;
  352. }
  353. break;
  354. }
  355. break;
  356. default:
  357. return FALSE;
  358. }
  359. return TRUE;
  360. }