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.

308 lines
14 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Utility.h
  5. Abstract:
  6. This file contains the declaration of the service-side class exposed as the "pchealth" object.
  7. Revision History:
  8. Davide Massarenti (dmassare) 03/20/2000
  9. created
  10. Kalyani Narlanka (KalyaniN) 03/15/01
  11. Moved Incident and Encryption Objects from HelpService to HelpCtr to improve Perf.
  12. ******************************************************************************/
  13. #if !defined(__INCLUDED___PCH___UTILITY_H___)
  14. #define __INCLUDED___PCH___UTILITY_H___
  15. #include <MPC_COM.h>
  16. #include <MPC_Security.h>
  17. #include <Debug.h>
  18. #include <SAFLib.h>
  19. #include <TaxonomyDatabase.h>
  20. #include <SystemMonitor.h>
  21. #include <FileList.h>
  22. /////////////////////////////////////////////////////////////////////////////
  23. /////////////////////////////////////////////////////////////////////////////
  24. class ATL_NO_VTABLE CPCHUserSettings :
  25. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  26. public IDispatchImpl<IPCHUserSettings, &IID_IPCHUserSettings, &LIBID_HelpServiceTypeLib>
  27. {
  28. bool m_fAttached;
  29. Taxonomy::Settings m_ts;
  30. HRESULT get_SKU( /*[in]*/ bool fMachine, /*[out, retval]*/ IPCHSetOfHelpTopics* *pVal );
  31. public:
  32. BEGIN_COM_MAP(CPCHUserSettings)
  33. COM_INTERFACE_ENTRY(IDispatch)
  34. COM_INTERFACE_ENTRY(IPCHUserSettings)
  35. END_COM_MAP()
  36. CPCHUserSettings();
  37. virtual ~CPCHUserSettings();
  38. void Passivate();
  39. HRESULT InitUserSettings( /*[out]*/ Taxonomy::HelpSet& ths );
  40. ////////////////////
  41. // IPCHUserSettings
  42. STDMETHOD(get_CurrentSKU)( /*[out, retval]*/ IPCHSetOfHelpTopics* *pVal );
  43. STDMETHOD(get_MachineSKU)( /*[out, retval]*/ IPCHSetOfHelpTopics* *pVal );
  44. STDMETHOD(get_HelpLocation )( /*[out, retval]*/ BSTR *pVal );
  45. STDMETHOD(get_DatabaseDir )( /*[out, retval]*/ BSTR *pVal );
  46. STDMETHOD(get_DatabaseFile )( /*[out, retval]*/ BSTR *pVal );
  47. STDMETHOD(get_IndexFile )( /*[in,optional]*/ VARIANT vScope, /*[out, retval]*/ BSTR *pVal );
  48. STDMETHOD(get_IndexDisplayName)( /*[in,optional]*/ VARIANT vScope, /*[out, retval]*/ BSTR *pVal );
  49. STDMETHOD(get_LastUpdated )( /*[out, retval]*/ DATE *pVal );
  50. STDMETHOD(get_AreHeadlinesEnabled)( /*[out, retval]*/ VARIANT_BOOL *pVal );
  51. STDMETHOD(get_News )( /*[out, retval]*/ IUnknown* *pVal );
  52. STDMETHOD(Select)( /*[in]*/ BSTR bstrSKU, /*[in]*/ long lLCID );
  53. };
  54. /////////////////////////////////////////////////////////////////////////////
  55. class ATL_NO_VTABLE CPCHSetOfHelpTopics :
  56. public MPC::Thread < CPCHSetOfHelpTopics, IPCHSetOfHelpTopics >,
  57. public MPC::ConnectionPointImpl< CPCHSetOfHelpTopics, &DIID_DPCHSetOfHelpTopicsEvents, MPC::CComSafeMultiThreadModel >,
  58. public IDispatchImpl < IPCHSetOfHelpTopics, &IID_IPCHSetOfHelpTopics, &LIBID_HelpServiceTypeLib >,
  59. public IPersistStream
  60. {
  61. Taxonomy::Settings m_ts;
  62. Taxonomy::Instance m_inst;
  63. ////////////////////
  64. CComPtr<IDispatch> m_sink_onStatusChange;
  65. SHT_STATUS m_shtStatus;
  66. HRESULT m_hrErrorCode;
  67. bool m_fReadyForCommands;
  68. MPC::Impersonation m_imp;
  69. bool m_fInstalled;
  70. bool m_fConnectedToDisk;
  71. MPC::wstring m_strDirectory;
  72. MPC::wstring m_strCAB;
  73. MPC::wstring m_strLocalCAB;
  74. bool m_fConnectedToServer;
  75. MPC::wstring m_strServer;
  76. CComPtr<IPCHSetOfHelpTopics> m_sku;
  77. CComPtr<IPCHService> m_svc;
  78. bool m_fActAsCollection;
  79. CComPtr<CPCHCollection> m_coll;
  80. //////////////////////////////////////////////////////////////////////
  81. HRESULT PrepareSettings ( );
  82. HRESULT Close ( /*[in]*/ bool fCleanup );
  83. void CleanupWorkerThread( /*[in]*/ HRESULT hr );
  84. HRESULT ImpersonateCaller();
  85. HRESULT EndImpersonation ();
  86. HRESULT GetListOfFilesFromDatabase( /*[in]*/ const MPC::wstring& strDB, /*[out]*/ MPC::WStringList& lst );
  87. HRESULT ProcessPackages();
  88. HRESULT CreateIndex ();
  89. //////////////////////////////////////////////////////////////////////
  90. HRESULT RunInitFromDisk ();
  91. HRESULT RunInitFromServer();
  92. HRESULT RunInstall ();
  93. HRESULT RunUninstall ();
  94. HRESULT put_Status( /*[in]*/ SHT_STATUS newVal, /*[in]*/ BSTR bstrFile );
  95. //////////////////////////////////////////////////////////////////////
  96. //
  97. // Event firing methods.
  98. //
  99. HRESULT Fire_onStatusChange( IPCHSetOfHelpTopics* obj, SHT_STATUS lStatus, long hrErrorCode, BSTR bstrFile );
  100. //////////////////////////////////////////////////////////////////////
  101. HRESULT PopulateFromDisk ( /*[in]*/ CPCHSetOfHelpTopics* pParent, /*[in]*/ const MPC::wstring& strDirectory );
  102. HRESULT PopulateFromServer( /*[in]*/ CPCHSetOfHelpTopics* pParent, /*[in]*/ IPCHSetOfHelpTopics* sku, /*[in]*/ IPCHService* svc );
  103. public:
  104. BEGIN_COM_MAP(CPCHSetOfHelpTopics)
  105. COM_INTERFACE_ENTRY(IDispatch)
  106. COM_INTERFACE_ENTRY(IPCHSetOfHelpTopics)
  107. COM_INTERFACE_ENTRY(IPersistStream)
  108. END_COM_MAP()
  109. CPCHSetOfHelpTopics();
  110. virtual ~CPCHSetOfHelpTopics();
  111. HRESULT Init ( /*[in]*/ const Taxonomy::Instance& inst );
  112. HRESULT InitFromDisk ( /*[in]*/ LPCWSTR szDirectory , /*[in]*/ CPCHCollection* pColl );
  113. HRESULT InitFromServer( /*[in]*/ LPCWSTR szServerName, /*[in]*/ CPCHCollection* pColl );
  114. static HRESULT VerifyWritePermissions();
  115. //////////////////////////////////////////////////////////////////////
  116. HRESULT RegisterPackage( /*[in]*/ const MPC::wstring& strFile, /*[in]*/ bool fBuiltin );
  117. HRESULT DirectInstall ( /*[in]*/ Installer::Package& pkg, /*[in]*/ bool fSetup, /*[in]*/ bool fSystem, /*[in]*/ bool fMUI );
  118. HRESULT DirectUninstall( /*[in]*/ const Taxonomy::HelpSet* ths = NULL );
  119. HRESULT ScanBatch ( );
  120. static HRESULT RebuildSKU( /*[in]*/ const Taxonomy::HelpSet& ths );
  121. //////////////////////////////////////////////////////////////////////
  122. // IPCHSetOfHelpTopics
  123. STDMETHOD(get_SKU )( /*[out, retval]*/ BSTR *pVal );
  124. STDMETHOD(get_Language )( /*[out, retval]*/ long *pVal );
  125. STDMETHOD(get_DisplayName )( /*[out, retval]*/ BSTR *pVal );
  126. STDMETHOD(get_ProductID )( /*[out, retval]*/ BSTR *pVal );
  127. STDMETHOD(get_Version )( /*[out, retval]*/ BSTR *pVal );
  128. STDMETHOD(get_Location )( /*[out, retval]*/ BSTR *pVal );
  129. STDMETHOD(get_Exported )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  130. STDMETHOD(put_Exported )( /*[in ]*/ VARIANT_BOOL newVal );
  131. STDMETHOD(put_onStatusChange)( /*[in ]*/ IDispatch* function );
  132. STDMETHOD(get_Status )( /*[out, retval]*/ SHT_STATUS *pVal );
  133. STDMETHOD(get_ErrorCode )( /*[out, retval]*/ long *pVal );
  134. STDMETHOD(get_IsMachineHelp )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  135. STDMETHOD(get_IsInstalled )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  136. STDMETHOD(get_CanInstall )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  137. STDMETHOD(get_CanUninstall )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  138. STDMETHOD(Install )();
  139. STDMETHOD(Uninstall)();
  140. STDMETHOD(Abort )();
  141. ////////////////////////////////////////
  142. //
  143. // IPersist
  144. //
  145. STDMETHOD(GetClassID)( /*[out]*/ CLSID *pClassID );
  146. //
  147. // IPersistStream
  148. //
  149. STDMETHOD(IsDirty)();
  150. STDMETHOD(Load)( /*[in]*/ IStream *pStm );
  151. STDMETHOD(Save)( /*[in]*/ IStream *pStm, /*[in]*/ BOOL fClearDirty );
  152. STDMETHOD(GetSizeMax)( /*[out]*/ ULARGE_INTEGER *pcbSize );
  153. //
  154. ////////////////////////////////////////
  155. };
  156. typedef CComObject<CPCHSetOfHelpTopics> CPCHSetOfHelpTopics_Object;
  157. /////////////////////////////////////////////////////////////////////////////
  158. class ATL_NO_VTABLE CPCHTaxonomyDatabase :
  159. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  160. public IDispatchImpl<IPCHTaxonomyDatabase, &IID_IPCHTaxonomyDatabase, &LIBID_HelpServiceTypeLib>
  161. {
  162. Taxonomy::Settings m_ts;
  163. CComPtr<IPCHSetOfHelpTopics> m_ActiveObject;
  164. public:
  165. BEGIN_COM_MAP(CPCHTaxonomyDatabase)
  166. COM_INTERFACE_ENTRY(IDispatch)
  167. COM_INTERFACE_ENTRY(IPCHTaxonomyDatabase)
  168. END_COM_MAP()
  169. Taxonomy::Settings& GetTS() { return m_ts; }
  170. static HRESULT SelectInstalledSKUs( /*[in]*/ bool fOnlyExported, /*[out, retval]*/ IPCHCollection* *pVal );
  171. // IPCHTaxonomyDatabase
  172. STDMETHOD(get_InstalledSKUs )( /*[out, retval]*/ IPCHCollection* *pVal );
  173. STDMETHOD(get_HasWritePermissions)( /*[out, retval]*/ VARIANT_BOOL *pVal );
  174. STDMETHOD(LookupNode )( /*[in]*/ BSTR bstrNode , /*[out, retval]*/ IPCHCollection* *ppC );
  175. STDMETHOD(LookupSubNodes )( /*[in]*/ BSTR bstrNode , /*[in]*/ VARIANT_BOOL fVisibleOnly, /*[out, retval]*/ IPCHCollection* *ppC );
  176. STDMETHOD(LookupNodesAndTopics)( /*[in]*/ BSTR bstrNode , /*[in]*/ VARIANT_BOOL fVisibleOnly, /*[out, retval]*/ IPCHCollection* *ppC );
  177. STDMETHOD(LookupTopics )( /*[in]*/ BSTR bstrNode , /*[in]*/ VARIANT_BOOL fVisibleOnly, /*[out, retval]*/ IPCHCollection* *ppC );
  178. STDMETHOD(LocateContext )( /*[in]*/ BSTR bstrURL , /*[in,optional]*/ VARIANT vSubSite, /*[out, retval]*/ IPCHCollection* *ppC );
  179. STDMETHOD(KeywordSearch )( /*[in]*/ BSTR bstrQuery, /*[in,optional]*/ VARIANT vSubSite, /*[out, retval]*/ IPCHCollection* *ppC );
  180. STDMETHOD(GatherNodes )( /*[in]*/ BSTR bstrNode , /*[in]*/ VARIANT_BOOL fVisibleOnly, /*[out, retval]*/ IPCHCollection* *ppC );
  181. STDMETHOD(GatherTopics )( /*[in]*/ BSTR bstrNode , /*[in]*/ VARIANT_BOOL fVisibleOnly, /*[out, retval]*/ IPCHCollection* *ppC );
  182. STDMETHOD(ConnectToDisk )( /*[in]*/ BSTR bstrDirectory , /*[in]*/ IDispatch* notify, /*[out, retval]*/ IPCHCollection* *ppC );
  183. STDMETHOD(ConnectToServer)( /*[in]*/ BSTR bstrServerName, /*[in]*/ IDispatch* notify, /*[out, retval]*/ IPCHCollection* *ppC );
  184. STDMETHOD(Abort )( );
  185. };
  186. ////////////////////////////////////////////////////////////////////////////////
  187. class ATL_NO_VTABLE CPCHUtility :
  188. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  189. public IDispatchImpl<IPCHUtility, &IID_IPCHUtility, &LIBID_HelpServiceTypeLib>
  190. {
  191. CComPtr<CPCHUserSettings> m_UserSettings;
  192. HRESULT InitUserSettings( /*[in]*/ Taxonomy::Settings& ts );
  193. public:
  194. BEGIN_COM_MAP(CPCHUtility)
  195. COM_INTERFACE_ENTRY(IDispatch)
  196. COM_INTERFACE_ENTRY(IPCHUtility)
  197. END_COM_MAP()
  198. HRESULT FinalConstruct();
  199. // IPCHUtility
  200. STDMETHOD(get_UserSettings)( /*[out, retval]*/ IPCHUserSettings* *pVal );
  201. STDMETHOD(get_Channels )( /*[out, retval]*/ ISAFReg* *pVal );
  202. STDMETHOD(get_Security )( /*[out, retval]*/ IPCHSecurity* *pVal );
  203. STDMETHOD(get_Database )( /*[out, retval]*/ IPCHTaxonomyDatabase* *pVal );
  204. STDMETHOD(FormatError)( /*[in]*/ VARIANT vError, /*[out, retval]*/ BSTR *pVal );
  205. STDMETHOD(CreateObject_SearchEngineMgr)( /*[out, retval]*/ IPCHSEManager* *ppSE );
  206. STDMETHOD(CreateObject_DataCollection )( /*[out, retval]*/ ISAFDataCollection* *ppDC );
  207. STDMETHOD(CreateObject_Cabinet )( /*[out, retval]*/ ISAFCabinet* *ppCB );
  208. STDMETHOD(CreateObject_Encryption )( /*[out, retval]*/ ISAFEncrypt* *ppEn );
  209. STDMETHOD(CreateObject_Channel )( /*[in]*/ BSTR bstrVendorID, /*[in]*/ BSTR bstrProductID, /*[out, retval]*/ ISAFChannel* *ppCh );
  210. STDMETHOD(CreateObject_RemoteDesktopConnection)( /*[out, retval]*/ ISAFRemoteDesktopConnection* *ppRDC );
  211. STDMETHOD(CreateObject_RemoteDesktopSession )( /*[in] */ REMOTE_DESKTOP_SHARING_CLASS sharingClass ,
  212. /*[in] */ long lTimeout ,
  213. /*[in] */ BSTR bstrConnectionParms ,
  214. /*[in] */ BSTR bstrUserHelpBlob ,
  215. /*[out, retval]*/ ISAFRemoteDesktopSession* *ppRCS );
  216. STDMETHOD(ConnectToExpert)( /*[in]*/ BSTR bstrExpertConnectParm, /*[in]*/ LONG lTimeout, /*[out, retval]*/ LONG *lSafErrorCode );
  217. STDMETHOD(SwitchDesktopMode)( /*[in]*/ int nMode, /* [in]*/ int nRAType );
  218. };
  219. ////////////////////////////////////////////////////////////////////////////////
  220. #endif // !defined(__INCLUDED___PCH___UTILITY_H___)