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.

133 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FaxOutboundRoutingRules.h
  5. Abstract:
  6. Declaration of the CFaxOutboundRoutingRules class.
  7. Author:
  8. Iv Garber (IvG) Jun, 2000
  9. Revision History:
  10. --*/
  11. #ifndef __FAXOUTBOUNDROUTINGRULES_H_
  12. #define __FAXOUTBOUNDROUTINGRULES_H_
  13. #include "resource.h" // main symbols
  14. #include "FaxCommon.h"
  15. #include <vector>
  16. #include "VCUE_Copy.h"
  17. namespace RulesNamespace
  18. {
  19. //
  20. // Rule Objects are stored in Vector of STL.
  21. //
  22. // When initialized, they got ALL their data, and Fax Server Ptr.
  23. // They do not depend on Rules Collection, only on Fax Server.
  24. // They inherit from CFaxInitInnerAddRef class, which means they make AddRef()
  25. // on Fax Server ( at Init() ).
  26. //
  27. // The Collection makes ONE AddRef() for each Rule Object, to prevent its death.
  28. // When killed, Collection calls Release() on all its Rule Objects.
  29. //
  30. // At Rule Object's death, it calls Release() on the Fax Server Object.
  31. //
  32. typedef std::vector<IFaxOutboundRoutingRule*> ContainerType;
  33. // Use IEnumVARIANT as the enumerator for VB compatibility
  34. typedef VARIANT EnumExposedType;
  35. typedef IEnumVARIANT EnumIfc;
  36. // Copy Classes
  37. typedef VCUE::CopyIfc2Variant<ContainerType::value_type> EnumCopyType;
  38. typedef VCUE::CopyIfc<ContainerType::value_type> CollectionCopyType;
  39. typedef CComEnumOnSTL< EnumIfc, &__uuidof(EnumIfc), EnumExposedType, EnumCopyType,
  40. ContainerType > EnumType;
  41. typedef ICollectionOnSTLImpl< IFaxOutboundRoutingRules, ContainerType,
  42. ContainerType::value_type, CollectionCopyType, EnumType > CollectionType;
  43. };
  44. using namespace RulesNamespace;
  45. //
  46. //==================== FAX OUTBOUND ROUTING RULES ===================================
  47. //
  48. // FaxOutboundRoutingRules creates a collection of all its Rule Objects at Init.
  49. // It needs Ptr to the Fax Server Object, for Add and Remove operations.
  50. // To prevent the death of the Fax Server before its own death, the Collection
  51. // makes AddRef() on Server. To do this, it inherits from CFaxInitInnerAddRef.
  52. //
  53. // When creating Rule Objects, the Collection passes Ptr to the Fax Server Object
  54. // to them, and from this moment, the Objects are not dependent on the Collection.
  55. // They live their own lifes. Collection makes one AddRef() on them, to prevent their
  56. // death before its own death, exactly as in the case with the Fax Server Object.
  57. //
  58. // The Rule Object itself needs Ptr to the Fax Server Object, to perform its
  59. // Save and Refresh. So, Rule Object also makes AddRef() on the Fax Server Object,
  60. // to prevent its permature death.
  61. //
  62. class ATL_NO_VTABLE CFaxOutboundRoutingRules :
  63. public CComObjectRootEx<CComSingleThreadModel>,
  64. public ISupportErrorInfo,
  65. public IDispatchImpl<RulesNamespace::CollectionType, &IID_IFaxOutboundRoutingRules, &LIBID_FAXCOMEXLib>,
  66. public CFaxInitInnerAddRef
  67. {
  68. public:
  69. CFaxOutboundRoutingRules() : CFaxInitInnerAddRef(_T("FAX OUTBOUND ROUTING RULES"))
  70. {
  71. }
  72. ~CFaxOutboundRoutingRules()
  73. {
  74. CCollectionKiller<RulesNamespace::ContainerType> CKiller;
  75. CKiller.EmptyObjectCollection(&m_coll);
  76. }
  77. DECLARE_REGISTRY_RESOURCEID(IDR_FAXOUTBOUNDROUTINGRULES)
  78. DECLARE_NOT_AGGREGATABLE(CFaxOutboundRoutingRules)
  79. DECLARE_PROTECT_FINAL_CONSTRUCT()
  80. BEGIN_COM_MAP(CFaxOutboundRoutingRules)
  81. COM_INTERFACE_ENTRY(IFaxOutboundRoutingRules)
  82. COM_INTERFACE_ENTRY(IDispatch)
  83. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  84. COM_INTERFACE_ENTRY(IFaxInitInner)
  85. END_COM_MAP()
  86. // Interfaces
  87. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  88. STDMETHOD(Remove)(/*[in]*/ long lIndex);
  89. STDMETHOD(RemoveByCountryAndArea)(/*[in]*/ long lCountryCode, /*[in]*/ long lAreaCode);
  90. STDMETHOD(ItemByCountryAndArea)(/*[in]*/ long lCountryCode, /*[in]*/ long lAreaCode,
  91. /*[out, retval]*/ IFaxOutboundRoutingRule **ppRule);
  92. STDMETHOD(Add)(long lCountryCode, long lAreaCode, VARIANT_BOOL bUseDevice, BSTR bstrGroupName,
  93. long lDeviceId, IFaxOutboundRoutingRule **pFaxOutboundRoutingRule);
  94. // Internal Use
  95. static HRESULT Create(IFaxOutboundRoutingRules **ppRules);
  96. STDMETHOD(Init)(IFaxServerInner *pServer);
  97. private:
  98. STDMETHOD(RemoveRule)(long lAreaCode, long lCountryCode, RulesNamespace::ContainerType::iterator &it);
  99. STDMETHOD(FindRule)(long lCountryCode, long lAreaCode, RulesNamespace::ContainerType::iterator *pRule);
  100. STDMETHOD(AddRule)(FAX_OUTBOUND_ROUTING_RULE *pInfo, IFaxOutboundRoutingRule **ppNewRule = NULL);
  101. };
  102. #endif //__FAXOUTBOUNDROUTINGRULES_H_