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.

112 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. FaxDevices.h
  5. Abstract:
  6. Declaration of the CFaxDevices class.
  7. Author:
  8. Iv Garber (IvG) Jun, 2000
  9. Revision History:
  10. --*/
  11. #ifndef __FAXDEVICES_H_
  12. #define __FAXDEVICES_H_
  13. #include "resource.h" // main symbols
  14. #include "FaxCommon.h"
  15. #include <vector>
  16. #include "VCUE_Copy.h"
  17. #include "FaxDevice.h"
  18. namespace DevicesNamespace
  19. {
  20. //
  21. // Device Objects are stored in Vector of STL.
  22. // When initialized, they got ALL their data, and Fax Server Ptr.
  23. // They do not depend on Devices Collection, only on Fax Server.
  24. // So, they implemented as usual COM Objects.
  25. // They inherit from CFaxInitInnerAddRef class, which means they make AddRef()
  26. // on Fax Server ( at Init() ).
  27. // By doing this, the objects prevent the death of the Fax Server prematurely.
  28. // So, if the User frees all its references to the Fax Server, but holds its
  29. // reference to the Device Object, the Device Object will continue to work,
  30. // because Fax Server Object actually did not died.
  31. // The Collection stores Ptrs to them, and makes ONE AddRef().
  32. // Each time User asks for an Object from the Collection, an additional AddRef() happens.
  33. // When killed, Collection calls Release() on all its Device Provider Objects.
  34. // Those that were not requested by the User, dies.
  35. // Those, that have User's AddRef() - remains alive, untill User free its Reference on them.
  36. // Fax Server remains alive untill all the Device Collections and all Device Objects are killed.
  37. // At their death, they Release() the Fax Server.
  38. //
  39. typedef std::vector<IFaxDevice*> ContainerType;
  40. // Use IEnumVARIANT as the enumerator for VB compatibility
  41. typedef VARIANT EnumExposedType;
  42. typedef IEnumVARIANT EnumIfc;
  43. // Copy Classes
  44. typedef VCUE::CopyIfc2Variant<ContainerType::value_type> EnumCopyType;
  45. typedef VCUE::CopyIfc<ContainerType::value_type> CollectionCopyType;
  46. typedef CComEnumOnSTL< EnumIfc, &__uuidof(EnumIfc), EnumExposedType, EnumCopyType,
  47. ContainerType > EnumType;
  48. typedef ICollectionOnSTLImpl< IFaxDevices, ContainerType, ContainerType::value_type,
  49. CollectionCopyType, EnumType > CollectionType;
  50. };
  51. using namespace DevicesNamespace;
  52. //
  53. //===================== FAX DEVICES =============================================
  54. //
  55. class ATL_NO_VTABLE CFaxDevices :
  56. public CComObjectRootEx<CComSingleThreadModel>,
  57. public ISupportErrorInfo,
  58. public IDispatchImpl<DevicesNamespace::CollectionType, &IID_IFaxDevices, &LIBID_FAXCOMEXLib>,
  59. public CFaxInitInner // for Debug + Creation thru CObjectHandler
  60. {
  61. public:
  62. CFaxDevices() : CFaxInitInner(_T("FAX DEVICES"))
  63. {
  64. }
  65. ~CFaxDevices()
  66. {
  67. CCollectionKiller<DevicesNamespace::ContainerType> CKiller;
  68. CKiller.EmptyObjectCollection(&m_coll);
  69. }
  70. DECLARE_REGISTRY_RESOURCEID(IDR_FAXDEVICES)
  71. DECLARE_NOT_AGGREGATABLE(CFaxDevices)
  72. DECLARE_PROTECT_FINAL_CONSTRUCT()
  73. BEGIN_COM_MAP(CFaxDevices)
  74. COM_INTERFACE_ENTRY(IFaxDevices)
  75. COM_INTERFACE_ENTRY(IDispatch)
  76. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  77. COM_INTERFACE_ENTRY(IFaxInitInner)
  78. END_COM_MAP()
  79. // Interfaces
  80. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  81. STDMETHOD(get_Item)(/*[in]*/ VARIANT vIndex, /*[out, retval]*/ IFaxDevice **ppDevice);
  82. STDMETHOD(get_ItemById)(/*[in]*/ long lId, /*[out, retval]*/ IFaxDevice **ppFaxDevice);
  83. // Internal Use
  84. static HRESULT Create(IFaxDevices **ppDevices);
  85. STDMETHOD(Init)(IFaxServerInner *pServer);
  86. };
  87. #endif //__FAXDEVICES_H_