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.

147 lines
5.6 KiB

  1. //+----------------------------------------------------------------------------
  2. // File: factory.hxx
  3. //
  4. // Synopsis:
  5. //
  6. //-----------------------------------------------------------------------------
  7. #ifndef _FACTORY_HXX
  8. #define _FACTORY_HXX
  9. // Routines -------------------------------------------------------------------
  10. HRESULT LicenseManagerFactory(IUnknown * pUnkOuter, REFIID riid, void ** ppvObj);
  11. //+----------------------------------------------------------------------------
  12. //
  13. // Class: CLicenseManager
  14. //
  15. // Synopsis:
  16. //
  17. //-----------------------------------------------------------------------------
  18. class CLicenseManager : public CComponent,
  19. public IObjectWithSite,
  20. public IOleObject,
  21. public ILicensedClassManager,
  22. public ILocalRegistry,
  23. public IRequireClasses,
  24. public IPersistStream,
  25. public IPersistStreamInit,
  26. public IPersistPropertyBag
  27. {
  28. friend HRESULT LicenseManagerFactory(IUnknown * pUnkOuter, REFIID riid, void ** ppvObj);
  29. typedef CComponent parent;
  30. public:
  31. CLicenseManager(IUnknown * pUnkOuter);
  32. ~CLicenseManager();
  33. // IUnknown methods
  34. DEFINE_IUNKNOWN_METHODS;
  35. // IObjectWithSite methods
  36. STDMETHOD(SetSite)(IUnknown * pUnkSite);
  37. STDMETHOD(GetSite)(REFIID riid, void **ppvSite);
  38. // IOleObject methods
  39. STDMETHOD(SetClientSite)(IOleClientSite * pClientSite);
  40. STDMETHOD(GetClientSite)(IOleClientSite ** ppClientSite);
  41. STDMETHOD(SetHostNames)(LPCOLESTR, LPCOLESTR) { return E_NOTIMPL; }
  42. STDMETHOD(Close)(DWORD) { return E_NOTIMPL; }
  43. STDMETHOD(SetMoniker)(DWORD, IMoniker *) { return E_NOTIMPL; }
  44. STDMETHOD(GetMoniker)(DWORD, DWORD, IMoniker **) { return E_NOTIMPL; }
  45. STDMETHOD(InitFromData)(IDataObject *, BOOL, DWORD) { return E_NOTIMPL; }
  46. STDMETHOD(GetClipboardData)(DWORD, IDataObject **) { return E_NOTIMPL; }
  47. STDMETHOD(DoVerb)(LONG, LPMSG, IOleClientSite *, LONG, HWND, LPCRECT) { return E_NOTIMPL; }
  48. STDMETHOD(EnumVerbs)(IEnumOLEVERB **) { return E_NOTIMPL; }
  49. STDMETHOD(Update)() { return E_NOTIMPL; }
  50. STDMETHOD(IsUpToDate)() { return E_NOTIMPL; }
  51. STDMETHOD(GetUserClassID)(CLSID *) { return E_NOTIMPL; }
  52. STDMETHOD(GetUserType)(DWORD, LPOLESTR *) { return E_NOTIMPL; }
  53. STDMETHOD(SetExtent)(DWORD, SIZEL *) { return E_NOTIMPL; }
  54. STDMETHOD(GetExtent)(DWORD, SIZEL *) { return E_NOTIMPL; }
  55. STDMETHOD(Advise)(IAdviseSink *, DWORD *) { return E_NOTIMPL; }
  56. STDMETHOD(Unadvise)(DWORD) { return E_NOTIMPL; }
  57. STDMETHOD(EnumAdvise)(IEnumSTATDATA **) { return E_NOTIMPL; }
  58. STDMETHOD(GetMiscStatus)(DWORD dwAspect, DWORD *pdwStatus)
  59. {
  60. if (!pdwStatus)
  61. return E_INVALIDARG;
  62. *pdwStatus = OLEMISC_SETCLIENTSITEFIRST | OLEMISC_INVISIBLEATRUNTIME;
  63. return S_OK;
  64. }
  65. STDMETHOD(SetColorScheme)(LOGPALETTE *) { return E_NOTIMPL; }
  66. // ILicensedClassManager methods
  67. STDMETHOD(OnChangeInRequiredClasses)(IRequireClasses * pRequireClasses);
  68. // ILocalRegistry methods
  69. STDMETHOD(CreateInstance)(CLSID clsid,
  70. IUnknown * punkOuter,
  71. REFIID riid,
  72. DWORD dwClsCtx,
  73. void ** ppvObj);
  74. STDMETHOD(GetTypeLibOfClsid)(CLSID clsid, ITypeLib ** ptlib);
  75. STDMETHOD(GetClassObjectOfClsid)(REFCLSID rclsid,
  76. DWORD dwClsCtx,
  77. LPVOID lpReserved,
  78. REFIID riid,
  79. void ** ppcClassObject);
  80. // IRequireClasses methods
  81. STDMETHOD(CountRequiredClasses)(ULONG * pcClasses);
  82. STDMETHOD(GetRequiredClasses)(ULONG iClass, CLSID * pclsid);
  83. // IPersist methods
  84. STDMETHOD(GetClassID)(CLSID * pclsid);
  85. // IPersistStream methods
  86. STDMETHOD(IsDirty)();
  87. STDMETHOD(Load)(IStream * pstm);
  88. STDMETHOD(Save)(IStream * pstm, BOOL fClearDirty);
  89. STDMETHOD(GetSizeMax)(ULARGE_INTEGER * pcbSize);
  90. // IPersistStreamInit methods
  91. STDMETHOD(InitNew)();
  92. // IPersistPropertyBag methods
  93. STDMETHOD(Load)(IPropertyBag * pPropBag, IErrorLog * pErrorLog);
  94. STDMETHOD(Save)(IPropertyBag * pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties);
  95. protected:
  96. struct LICENSE // CLSID-License structure
  97. {
  98. CLSID clsid; // CLSID of the object
  99. BSTR bstrLic; // License (as a BSTR)
  100. IClassFactory2 * pcf2; // Cached class factory (not persisted)
  101. };
  102. DEFINE_ARY(LICENSE);
  103. IUnknown * _pUnkSite; // Site object
  104. BOOL _fDirty:1; // Object is dirty
  105. BOOL _fLoaded:1; // Object has been loaded
  106. BOOL _fPersistPBag:1; // IPersistPropertyBag is being used
  107. BOOL _fPersistStream:1; // IPersistStream is being used
  108. GUID _guidLPK; // Identifying GUID of the .LPK
  109. CAryLICENSE _aryLic; // Array of CLSID-License pairs
  110. HRESULT PrivateQueryInterface(REFIID riid, void ** ppvObj);
  111. HRESULT FindInStream(IStream * pstm, BYTE * pbData, ULONG cbData);
  112. HRESULT Load(IStream * pstm, ULONG cbSize);
  113. HRESULT AddClass(REFCLSID rclsid, int * piLic);
  114. BOOL FindClass(REFCLSID rclsid, int * piLic);
  115. };
  116. #endif // _FACTORY_HXX