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.

152 lines
5.2 KiB

  1. #include "precomp.h"
  2. #include "rsop.h"
  3. /////////////////////////////////////////////////////////////////////
  4. void InitUserAgentDlgInRSoPMode(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. for (long nObj = 0; nObj < nPSObjects; nObj++)
  15. {
  16. // userAgentText field
  17. _variant_t vtValue;
  18. hr = paPSObj[nObj]->pObj->Get(L"userAgentText", 0, &vtValue, NULL, NULL);
  19. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  20. {
  21. _bstr_t bstrValue = vtValue;
  22. BOOL bChecked = (bstrValue.length() > 0);
  23. SetDlgItemTextTriState(hDlg, IDC_UASTRING, IDC_UASTRINGCHECK, (LPTSTR)bstrValue, bChecked);
  24. break;
  25. }
  26. }
  27. }
  28. EnableDlgItem2(hDlg, IDC_UASTRING, FALSE);
  29. EnableDlgItem2(hDlg, IDC_UASTRINGCHECK, FALSE);
  30. }
  31. __except(TRUE)
  32. {
  33. }
  34. }
  35. /////////////////////////////////////////////////////////////////////
  36. HRESULT InitUserAgentPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  37. {
  38. return InitGenericPrecedencePage(pDRD, hwndList, L"userAgentText");
  39. }
  40. /////////////////////////////////////////////////////////////////////
  41. INT_PTR CALLBACK UserAgentDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  42. {
  43. // Retrieve Property Sheet Page info for each call into dlg proc.
  44. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  45. BOOL fUserAgent;
  46. int nStatus;
  47. switch(msg)
  48. {
  49. case WM_INITDIALOG:
  50. SetPropSheetCookie(hDlg, lParam);
  51. EnableDBCSChars(hDlg, IDC_UASTRING);
  52. // find out if this dlg is in RSoP mode
  53. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  54. if (psCookie->pCS->IsRSoP())
  55. {
  56. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  57. if (pDRD)
  58. InitUserAgentDlgInRSoPMode(hDlg, pDRD);
  59. }
  60. else
  61. Edit_LimitText(GetDlgItem(hDlg, IDC_UASTRING), MAX_PATH - 1);
  62. break;
  63. case WM_DESTROY:
  64. DestroyDlgRSoPData(hDlg); break;
  65. case WM_HELP: // F1
  66. ShowHelpTopic(hDlg);
  67. break;
  68. case WM_COMMAND:
  69. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  70. return FALSE;
  71. switch (GET_WM_COMMAND_ID(wParam, lParam))
  72. {
  73. case IDC_UASTRINGCHECK:
  74. fUserAgent = (IsDlgButtonChecked(hDlg, IDC_UASTRINGCHECK) == BST_CHECKED);
  75. EnableDlgItem2(hDlg, IDC_UASTRING, fUserAgent);
  76. EnableDlgItem2(hDlg, IDC_UASTRING_TXT, fUserAgent);
  77. break;
  78. default:
  79. return FALSE;
  80. }
  81. break;
  82. case WM_NOTIFY:
  83. switch (((LPNMHDR)lParam)->code)
  84. {
  85. TCHAR szMsgTitle[1024];
  86. TCHAR szMsgText[1024];
  87. case PSN_HELP:
  88. ShowHelpTopic(hDlg);
  89. break;
  90. case PSN_SETACTIVE:
  91. // don't do any of this stuff in RSoP mode
  92. if (!psCookie->pCS->IsRSoP())
  93. {
  94. // load information from ins file
  95. SetDlgItemTextFromIns(hDlg, IDC_UASTRING, IDC_UASTRINGCHECK, IS_BRANDING,
  96. USER_AGENT, GetInsFile(hDlg), NULL, INSIO_TRISTATE);
  97. EnableDlgItem2(hDlg, IDC_UASTRING_TXT, (IsDlgButtonChecked(hDlg, IDC_UASTRINGCHECK) == BST_CHECKED));
  98. }
  99. break;
  100. case PSN_APPLY:
  101. if (psCookie->pCS->IsRSoP())
  102. return FALSE;
  103. else
  104. {
  105. nStatus = TS_CHECK_OK;
  106. IsTriStateValid(hDlg, IDC_UASTRING, IDC_UASTRINGCHECK, &nStatus,
  107. res2Str(IDS_QUERY_CLEARSETTING, szMsgText, countof(szMsgText)),
  108. res2Str(IDS_TITLE, szMsgTitle, countof(szMsgTitle)));
  109. if (nStatus == TS_CHECK_ERROR ||
  110. !AcquireWriteCriticalSection(hDlg))
  111. {
  112. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  113. break;
  114. }
  115. WriteDlgItemTextToIns(hDlg, IDC_UASTRING, IDC_UASTRINGCHECK, IS_BRANDING,
  116. USER_AGENT, GetInsFile(hDlg), NULL, INSIO_TRISTATE);
  117. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  118. }
  119. break;
  120. default:
  121. return FALSE;
  122. }
  123. break;
  124. default:
  125. return FALSE;
  126. }
  127. return TRUE;
  128. }