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.

501 lines
17 KiB

  1. /********************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. SAFlib.h
  5. Abstract:
  6. This is declaration of SAF Channel objects
  7. Revision History:
  8. Steve Shih created 07/15/99
  9. ********************************************************************/
  10. #if !defined(__INCLUDED___PCH___SAFLIB_H___)
  11. #define __INCLUDED___PCH___SAFLIB_H___
  12. #include <time.h>
  13. //
  14. // From HelpServiceTypeLib.idl
  15. //
  16. #include <HelpServiceTypeLib.h>
  17. #include <MPC_main.h>
  18. #include <MPC_com.h>
  19. #include <MPC_utils.h>
  20. #include <MPC_xml.h>
  21. #include <MPC_config.h>
  22. #include <MPC_streams.h>
  23. #include <AccountsLib.h>
  24. #include <TaxonomyDatabase.h>
  25. /////////////////////////////////////////////////////////////////////////////
  26. class CSAFChannel;
  27. class CSAFIncidentItem;
  28. class CSAFReg;
  29. class CIncidentStore;
  30. typedef MPC::CComObjectParent<CSAFChannel> CSAFChannel_Object;
  31. /////////////////////////////////////////////////////////////////////////////
  32. #define MAX_REC_LEN 1024
  33. #define MAX_ID 1024
  34. class CSAFIncidentRecord
  35. {
  36. public:
  37. DWORD m_dwRecIndex;
  38. CComBSTR m_bstrVendorID;
  39. CComBSTR m_bstrProductID;
  40. CComBSTR m_bstrDisplay;
  41. CComBSTR m_bstrURL;
  42. CComBSTR m_bstrProgress;
  43. CComBSTR m_bstrXMLDataFile;
  44. CComBSTR m_bstrXMLBlob;
  45. DATE m_dCreatedTime;
  46. DATE m_dChangedTime;
  47. DATE m_dClosedTime;
  48. IncidentStatusEnum m_iStatus;
  49. CComBSTR m_bstrSecurity;
  50. CComBSTR m_bstrOwner;
  51. CSAFIncidentRecord();
  52. friend HRESULT operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ CSAFIncidentRecord& increc );
  53. friend HRESULT operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const CSAFIncidentRecord& increc );
  54. };
  55. class CSAFChannelRecord
  56. {
  57. public:
  58. typedef enum
  59. {
  60. SAFREG_SKU ,
  61. SAFREG_Language ,
  62. SAFREG_VendorID ,
  63. SAFREG_ProductID ,
  64. SAFREG_VendorName ,
  65. SAFREG_ProductName ,
  66. SAFREG_ProductDescription,
  67. SAFREG_VendorIcon ,
  68. SAFREG_SupportUrl ,
  69. SAFREG_PublicKey ,
  70. SAFREG_UserAccount ,
  71. SAFREG_Security ,
  72. SAFREG_Notification ,
  73. } SAFREG_Field;
  74. ////////////////////
  75. Taxonomy::HelpSet m_ths;
  76. CComBSTR m_bstrVendorID;
  77. CComBSTR m_bstrProductID;
  78. CComBSTR m_bstrVendorName;
  79. CComBSTR m_bstrProductName;
  80. CComBSTR m_bstrDescription;
  81. CComBSTR m_bstrIcon;
  82. CComBSTR m_bstrURL;
  83. CComBSTR m_bstrPublicKey;
  84. CComBSTR m_bstrUserAccount;
  85. CComBSTR m_bstrSecurity;
  86. CComBSTR m_bstrNotification;
  87. ////////////////////
  88. CSAFChannelRecord();
  89. HRESULT GetField( /*[in]*/ SAFREG_Field field, /*[out]*/ BSTR *pVal );
  90. HRESULT SetField( /*[in]*/ SAFREG_Field field, /*[in ]*/ BSTR newVal );
  91. };
  92. ////////////////////////////////////////////////////////////////////////////////
  93. //
  94. // Adding MPC::CComObjectRootParentBase to take care of the Parent Child relation between Channel and IncidentItem.
  95. //
  96. class ATL_NO_VTABLE CSAFChannel :
  97. public MPC::CComObjectRootParentBase,
  98. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  99. public IDispatchImpl<ISAFChannel, &IID_ISAFChannel, &LIBID_HelpServiceTypeLib>
  100. {
  101. public:
  102. typedef std::list< CSAFIncidentItem* > List;
  103. typedef List::iterator Iter;
  104. typedef List::const_iterator IterConst;
  105. private:
  106. CSAFChannelRecord m_data;
  107. CComPtr<IPCHSecurityDescriptor> m_Security;
  108. List m_lstIncidentItems;
  109. public:
  110. DECLARE_NO_REGISTRY()
  111. DECLARE_PROTECT_FINAL_CONSTRUCT()
  112. BEGIN_COM_MAP(CSAFChannel)
  113. COM_INTERFACE_ENTRY(IDispatch)
  114. COM_INTERFACE_ENTRY(ISAFChannel)
  115. END_COM_MAP()
  116. CSAFChannel();
  117. void FinalRelease();
  118. void Passivate ();
  119. BSTR GetVendorID () { return m_data.m_bstrVendorID; }
  120. BSTR GetProductID () { return m_data.m_bstrProductID; }
  121. size_t GetSizeIncidentList() { return m_lstIncidentItems.size(); }
  122. static HRESULT OpenIncidentStore ( /*[out]*/ CIncidentStore*& pIStore );
  123. static HRESULT CloseIncidentStore( /*[out]*/ CIncidentStore*& pIStore );
  124. HRESULT Init( /*[in]*/ const CSAFChannelRecord& cr );
  125. HRESULT Import( /*[in]*/ const CSAFIncidentRecord& increc ,
  126. /*[out]*/ CSAFIncidentItem* *pVal );
  127. HRESULT Create( /*[in]*/ BSTR bstrDesc ,
  128. /*[in]*/ BSTR bstrURL ,
  129. /*[in]*/ BSTR bstrProgress ,
  130. /*[in]*/ BSTR bstrXMLDataFile ,
  131. /*[in]*/ BSTR bstrXMLBlob ,
  132. /*[out]*/ CSAFIncidentItem* *pVal );
  133. IterConst Find( /*[in]*/ BSTR bstrURL );
  134. IterConst Find( /*[in]*/ DWORD dwIndex );
  135. HRESULT RemoveIncidentFromList( /*[in]*/ CSAFIncidentItem* pVal );
  136. HRESULT Fire_NotificationEvent( /*[in]*/ int iEventType ,
  137. /*[in]*/ int iCountIncidentInChannel ,
  138. /*[in]*/ ISAFChannel* pC ,
  139. /*[in]*/ ISAFIncidentItem* pI ,
  140. /*[in]*/ DWORD dwCode );
  141. // ISAFChannel
  142. public:
  143. STDMETHOD(get_VendorID )( /*[out, retval]*/ BSTR *pVal );
  144. STDMETHOD(get_ProductID )( /*[out, retval]*/ BSTR *pVal );
  145. STDMETHOD(get_VendorName )( /*[out, retval]*/ BSTR *pVal );
  146. STDMETHOD(get_ProductName )( /*[out, retval]*/ BSTR *pVal );
  147. STDMETHOD(get_Description )( /*[out, retval]*/ BSTR *pVal );
  148. STDMETHOD(get_VendorDirectory)( /*[out, retval]*/ BSTR *pVal );
  149. STDMETHOD(get_Security )( /*[out, retval]*/ IPCHSecurityDescriptor* *pVal );
  150. STDMETHOD(put_Security )( /*[in] */ IPCHSecurityDescriptor* newVal );
  151. STDMETHOD(get_Notification )( /*[out, retval]*/ BSTR *pVal );
  152. STDMETHOD(put_Notification )( /*[in] */ BSTR newVal );
  153. STDMETHOD(Incidents)( /*[in]*/ IncidentCollectionOptionEnum opt, /*[out, retval]*/ IPCHCollection* *ppC );
  154. STDMETHOD(RecordIncident)( /*[in]*/ BSTR bstrDisplay ,
  155. /*[in]*/ BSTR bstrURL ,
  156. /*[in]*/ VARIANT vProgress ,
  157. /*[in]*/ VARIANT vXMLDataFile ,
  158. /*[in]*/ VARIANT vXMLBlob ,
  159. /*[out]*/ ISAFIncidentItem* *pVal );
  160. };
  161. ///////////////////////////////////////////////////////////////////////////////////////////////////
  162. //
  163. // Use CComObjectRootChildEx() in place of CComObjectRootEx()
  164. // public CComObjectRootEx<CComSingleThreadModel>,
  165. //
  166. // Also adding MPC::CComObjectRootParentBase to take care of the Parent Child relation between Channel and IncidentItem.
  167. //
  168. // This is a child of Incidents Object.
  169. class ATL_NO_VTABLE CSAFIncidentItem :
  170. public MPC::CComObjectRootChildEx<MPC::CComSafeMultiThreadModel, CSAFChannel>,
  171. public IDispatchImpl<ISAFIncidentItem, &IID_ISAFIncidentItem, &LIBID_HelpServiceTypeLib>
  172. {
  173. CSAFIncidentRecord m_increc;
  174. bool m_fDirty;
  175. public:
  176. BEGIN_COM_MAP(CSAFIncidentItem)
  177. COM_INTERFACE_ENTRY(IDispatch)
  178. COM_INTERFACE_ENTRY(ISAFIncidentItem)
  179. END_COM_MAP()
  180. CSAFIncidentItem();
  181. HRESULT Import( /*[in] */ const CSAFIncidentRecord& increc );
  182. HRESULT Export( /*[out]*/ CSAFIncidentRecord& increc );
  183. HRESULT Save();
  184. DWORD GetRecIndex() { return m_increc.m_dwRecIndex; }
  185. CComBSTR& GetURL () { return m_increc.m_bstrURL; }
  186. bool MatchEnumOption( /*[in]*/ IncidentCollectionOptionEnum opt );
  187. HRESULT VerifyPermissions( /*[in]*/ bool fModify = false );
  188. // ISAFIncidentItem
  189. public:
  190. STDMETHOD(get_DisplayString)( /*[out, retval]*/ BSTR *pVal );
  191. STDMETHOD(put_DisplayString)( /*[in] */ BSTR newVal );
  192. STDMETHOD(get_URL )( /*[out, retval]*/ BSTR *pVal );
  193. STDMETHOD(put_URL )( /*[in] */ BSTR newVal );
  194. STDMETHOD(get_Progress )( /*[out, retval]*/ BSTR *pVal );
  195. STDMETHOD(put_Progress )( /*[in] */ BSTR newVal );
  196. STDMETHOD(get_XMLDataFile )( /*[out, retval]*/ BSTR *pVal );
  197. STDMETHOD(put_XMLDataFile )( /*[in] */ BSTR newVal );
  198. STDMETHOD(get_XMLBlob )( /*[out, retval]*/ BSTR *pVal );
  199. STDMETHOD(put_XMLBlob )( /*[in] */ BSTR newVal );
  200. STDMETHOD(get_CreationTime )( /*[out, retval]*/ DATE *pVal );
  201. STDMETHOD(get_ClosedTime )( /*[out, retval]*/ DATE *pVal );
  202. STDMETHOD(get_ChangedTime )( /*[out, retval]*/ DATE *pVal );
  203. STDMETHOD(get_Status )( /*[out, retval]*/ IncidentStatusEnum *pVal );
  204. STDMETHOD(get_Security )( /*[out, retval]*/ IPCHSecurityDescriptor* *pVal );
  205. STDMETHOD(put_Security )( /*[in] */ IPCHSecurityDescriptor* newVal );
  206. STDMETHOD(get_Owner )( /*[out, retval]*/ BSTR *pVal );
  207. STDMETHOD(CloseIncidentItem )();
  208. STDMETHOD(DeleteIncidentItem)();
  209. };
  210. /////////////////////////////////////////////////////////////////////////////
  211. //
  212. // This is the read-only, flat version of CSAFReg.
  213. //
  214. class ATL_NO_VTABLE CSAFRegDummy :
  215. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  216. public IDispatchImpl<ISAFReg, &IID_ISAFReg, &LIBID_HelpServiceTypeLib>
  217. {
  218. typedef std::list< CSAFChannelRecord > ChannelsList;
  219. typedef ChannelsList::iterator ChannelsIter;
  220. typedef ChannelsList::const_iterator ChannelsIterConst;
  221. ////////////////////////////////////////
  222. ChannelsList m_lstChannels;
  223. ChannelsIter m_itCurrent; // Used by MoveFirst / MoveNext / get_EOF
  224. ////////////////////////////////////////
  225. HRESULT ReturnField( /*[in]*/ CSAFChannelRecord::SAFREG_Field field, /*[out]*/ BSTR *pVal );
  226. ////////////////////////////////////////
  227. public:
  228. BEGIN_COM_MAP(CSAFRegDummy)
  229. COM_INTERFACE_ENTRY(IDispatch)
  230. COM_INTERFACE_ENTRY(ISAFReg)
  231. END_COM_MAP()
  232. CSAFRegDummy();
  233. HRESULT Append( /*[in]*/ const CSAFChannelRecord& cr );
  234. ////////////////////////////////////////////////////////////////////////////////
  235. // ISAFReg
  236. public:
  237. STDMETHOD(get_EOF )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  238. STDMETHOD(get_VendorID )( /*[out, retval]*/ BSTR *pVal );
  239. STDMETHOD(get_ProductID )( /*[out, retval]*/ BSTR *pVal );
  240. STDMETHOD(get_VendorName )( /*[out, retval]*/ BSTR *pVal );
  241. STDMETHOD(get_ProductName )( /*[out, retval]*/ BSTR *pVal );
  242. STDMETHOD(get_ProductDescription)( /*[out, retval]*/ BSTR *pVal );
  243. STDMETHOD(get_VendorIcon )( /*[out, retval]*/ BSTR *pVal );
  244. STDMETHOD(get_SupportUrl )( /*[out, retval]*/ BSTR *pVal );
  245. STDMETHOD(get_PublicKey )( /*[out, retval]*/ BSTR *pVal );
  246. STDMETHOD(get_UserAccount )( /*[out, retval]*/ BSTR *pVal );
  247. STDMETHOD(MoveFirst)();
  248. STDMETHOD(MoveNext )();
  249. };
  250. /////////////////////////////////////////////////////////////////////////////
  251. // CSAFReg
  252. class CSAFReg :
  253. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>, // Just for locking...
  254. public MPC::Config::TypeConstructor
  255. {
  256. class Inner_UI : public MPC::Config::TypeConstructor
  257. {
  258. DECLARE_CONFIG_MAP(Inner_UI);
  259. public:
  260. Taxonomy::HelpSet m_ths;
  261. CComBSTR m_bstrVendorName;
  262. CComBSTR m_bstrProductName;
  263. CComBSTR m_bstrDescription;
  264. CComBSTR m_bstrIcon;
  265. CComBSTR m_bstrURL;
  266. ////////////////////////////////////////
  267. //
  268. // MPC::Config::TypeConstructor
  269. //
  270. DEFINE_CONFIG_DEFAULTTAG();
  271. DECLARE_CONFIG_METHODS();
  272. //
  273. ////////////////////////////////////////
  274. };
  275. typedef std::list< Inner_UI > UIList;
  276. typedef UIList::iterator UIIter;
  277. typedef UIList::const_iterator UIIterConst;
  278. ////////////////////////////////////////
  279. class Inner_Product : public MPC::Config::TypeConstructor
  280. {
  281. DECLARE_CONFIG_MAP(Inner_Product);
  282. public:
  283. CComBSTR m_bstrProductID;
  284. UIList m_lstUI;
  285. CComBSTR m_bstrSecurity;
  286. CComBSTR m_bstrNotification;
  287. ////////////////////////////////////////
  288. //
  289. // MPC::Config::TypeConstructor
  290. //
  291. DEFINE_CONFIG_DEFAULTTAG();
  292. DECLARE_CONFIG_METHODS();
  293. //
  294. ////////////////////////////////////////
  295. };
  296. typedef std::list< Inner_Product > ProdList;
  297. typedef ProdList::iterator ProdIter;
  298. typedef ProdList::const_iterator ProdIterConst;
  299. ////////////////////////////////////////
  300. class Inner_Vendor : public MPC::Config::TypeConstructor
  301. {
  302. DECLARE_CONFIG_MAP(Inner_Vendor);
  303. public:
  304. CComBSTR m_bstrVendorID;
  305. ProdList m_lstProducts;
  306. CComBSTR m_bstrPublicKey;
  307. CComBSTR m_bstrUserAccount;
  308. ////////////////////////////////////////
  309. //
  310. // MPC::Config::TypeConstructor
  311. //
  312. DEFINE_CONFIG_DEFAULTTAG();
  313. DECLARE_CONFIG_METHODS();
  314. //
  315. ////////////////////////////////////////
  316. };
  317. typedef std::list< Inner_Vendor > VendorList;
  318. typedef VendorList::iterator VendorIter;
  319. typedef VendorList::const_iterator VendorIterConst;
  320. ////////////////////////////////////////
  321. DECLARE_CONFIG_MAP(CSAFReg);
  322. MPC::wstring m_szSAFStore;
  323. VendorList m_lstVendors;
  324. bool m_fLoaded;
  325. bool m_fDirty;
  326. ////////////////////////////////////////
  327. HRESULT EnsureInSync();
  328. HRESULT ParseFileField( /*[in]*/ MPC::XmlUtil& xml ,
  329. /*[in]*/ LPCWSTR szTag ,
  330. /*[in]*/ CComBSTR& bstrDest );
  331. HRESULT ParseFile( /*[in ]*/ MPC::XmlUtil& xml ,
  332. /*[in/out]*/ CSAFChannelRecord& cr );
  333. HRESULT MoveToChannel( /*[in ]*/ const CSAFChannelRecord& cr ,
  334. /*[in ]*/ bool fCreate ,
  335. /*[out]*/ bool& fFound ,
  336. /*[out]*/ VendorIter& itVendor ,
  337. /*[out]*/ ProdIter* pitProduct = NULL ,
  338. /*[out]*/ UIIter* pitUI = NULL );
  339. void PopulateRecord( /*[in]*/ CSAFChannelRecord& cr ,
  340. /*[in]*/ VendorIter itVendor ,
  341. /*[in]*/ ProdIter itProduct ,
  342. /*[in]*/ UIIter itUI );
  343. ////////////////////////////////////////
  344. public:
  345. CSAFReg();
  346. ////////////////////////////////////////
  347. //
  348. // MPC::Config::TypeConstructor
  349. //
  350. DEFINE_CONFIG_DEFAULTTAG();
  351. DECLARE_CONFIG_METHODS();
  352. //
  353. ////////////////////////////////////////
  354. HRESULT CreateReadOnlyCopy( /*[in]*/ const Taxonomy::HelpSet& ths, /*[out]*/ CSAFRegDummy* *pVal );
  355. HRESULT LookupAccountData( /*[in]*/ BSTR bstrVendorID, /*[out]*/ CPCHUserProcess::UserEntry& ue );
  356. ////////////////////////////////////////////////////////////////////////////////
  357. static CSAFReg* s_GLOBAL;
  358. static HRESULT InitializeSystem();
  359. static void FinalizeSystem ();
  360. ////////////////////////////////////////////////////////////////////////////////
  361. HRESULT RegisterSupportChannel( /*[in]*/ const CSAFChannelRecord& cr, /*[in]*/ MPC::XmlUtil& xml );
  362. HRESULT RemoveSupportChannel ( /*[in]*/ const CSAFChannelRecord& cr, /*[in]*/ MPC::XmlUtil& xml );
  363. HRESULT UpdateField( /*[in ]*/ const CSAFChannelRecord& cr, /*[in]*/ CSAFChannelRecord::SAFREG_Field field );
  364. HRESULT Synchronize( /*[in/out]*/ CSAFChannelRecord& cr, /*[out]*/ bool& fFound );
  365. HRESULT RemoveSKU( /*[in]*/ const Taxonomy::HelpSet& ths );
  366. };
  367. ////////////////////////////////////////////////////////////////////////////////
  368. #endif // !defined(__INCLUDED___PCH___SAFLIB_H___)