Source code of Windows XP (NT5)
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.

150 lines
3.6 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // policypage.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // Defines the class ProxyPolicyPage.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 03/01/2000 Original version.
  16. // 04/19/2000 Marshall SDOs across apartments.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #include <proxypch.h>
  20. #include <policypage.h>
  21. #include <profileprop.h>
  22. ProxyPolicyPage::ProxyPolicyPage(
  23. LONG_PTR notifyHandle,
  24. LPARAM notifyParam,
  25. Sdo& policySdo,
  26. Sdo& profileSdo,
  27. SdoConnection& connection,
  28. bool useName
  29. )
  30. : SnapInPropertyPage(notifyHandle, notifyParam, true, IDD_PROXY_POLICY),
  31. policyStream(policySdo),
  32. profileStream(profileSdo),
  33. cxn(connection)
  34. {
  35. if (useName) { policySdo.getName(name); }
  36. }
  37. BOOL ProxyPolicyPage::OnInitDialog()
  38. {
  39. // Unmarshal the interfaces.
  40. policyStream.get(policy);
  41. profileStream.get(profile);
  42. // Get the conditions.
  43. policy.getValue(PROPERTY_POLICY_CONDITIONS_COLLECTION, conditions);
  44. SnapInPropertyPage::OnInitDialog();
  45. initControl(IDC_LIST_POLICYPAGE1_CONDITIONS, listBox);
  46. condList.finalConstruct(
  47. m_hWnd,
  48. cxn.getCIASAttrList(),
  49. ALLOWEDINPROXYCONDITION,
  50. cxn.getDictionary(),
  51. conditions,
  52. cxn.getMachineName(),
  53. name
  54. );
  55. return condList.onInitDialog();
  56. }
  57. void ProxyPolicyPage::onAddCondition()
  58. {
  59. BOOL modified = FALSE;
  60. condList.onAdd(modified);
  61. if (modified) { SetModified(); }
  62. }
  63. void ProxyPolicyPage::onEditCondition()
  64. {
  65. BOOL handled, modified = FALSE;
  66. condList.onEdit(modified, handled);
  67. if (modified) { SetModified(); }
  68. }
  69. void ProxyPolicyPage::onRemoveCondition()
  70. {
  71. BOOL handled, modified = FALSE;
  72. condList.onRemove(modified, handled);
  73. if (modified) { SetModified(); }
  74. }
  75. void ProxyPolicyPage::onEditProfile()
  76. {
  77. ProxyProfileProperties sheet(profile, cxn);
  78. if (sheet.DoModal() != IDCANCEL)
  79. {
  80. SetModified();
  81. }
  82. }
  83. void ProxyPolicyPage::getData()
  84. {
  85. // There must be at least one condition.
  86. if (listBox.GetCount() == 0)
  87. {
  88. fail(IDC_LIST_POLICYPAGE1_CONDITIONS, IDS_POLICY_E_NO_CONDITIONS, false);
  89. }
  90. getValue(IDC_EDIT_NAME, name);
  91. // The user must specify a name ...
  92. if (name.Length() == 0)
  93. {
  94. fail(IDC_EDIT_NAME, IDS_POLICY_E_NAME_EMPTY);
  95. }
  96. // The name must be unique.
  97. if (!policy.setName(name))
  98. {
  99. fail(IDC_EDIT_NAME, IDS_POLICY_E_NOT_UNIQUE);
  100. }
  101. }
  102. void ProxyPolicyPage::setData()
  103. {
  104. setValue(IDC_EDIT_NAME, name);
  105. }
  106. void ProxyPolicyPage::saveChanges()
  107. {
  108. if (!condList.onApply()) { AfxThrowUserException(); }
  109. policy.setValue(PROPERTY_POLICY_PROFILE_NAME, name);
  110. policy.apply();
  111. profile.setName(name);
  112. profile.apply();
  113. }
  114. void ProxyPolicyPage::discardChanges()
  115. {
  116. policy.restore();
  117. profile.restore();
  118. SdoCollection attributes;
  119. profile.getValue(PROPERTY_PROFILE_ATTRIBUTES_COLLECTION, attributes);
  120. attributes.reload();
  121. }
  122. BEGIN_MESSAGE_MAP(ProxyPolicyPage, SnapInPropertyPage)
  123. ON_BN_CLICKED(IDC_BUTTON_CONDITION_ADD, onAddCondition)
  124. ON_BN_CLICKED(IDC_BUTTON_CONDITION_EDIT, onEditCondition)
  125. ON_BN_CLICKED(IDC_BUTTON_CONDITION_REMOVE, onRemoveCondition)
  126. ON_BN_CLICKED(IDC_BUTTON_EDITPROFILE, onEditProfile)
  127. ON_LBN_DBLCLK(IDC_LIST_CONDITIONS, onEditCondition)
  128. ON_EN_CHANGE(IDC_EDIT_NAME, onChange)
  129. END_MESSAGE_MAP()