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.

331 lines
13 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. SearchEngineLib.h
  5. Abstract:
  6. This file contains the declaration of the classes involved in
  7. the SearchEngine Application.
  8. Revision History:
  9. Ghim-Sim Chua (gschua) 04/10/2000
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___PCH___SEARCHENGINELIB_H___)
  13. #define __INCLUDED___PCH___SEARCHENGINELIB_H___
  14. #include <TaxonomyDatabase.h>
  15. #include <MPC_security.h>
  16. /////////////////////////////////////////////////////////////////////////////
  17. namespace SearchEngine
  18. {
  19. class ATL_NO_VTABLE Manager :
  20. public MPC::CComObjectRootParentBase,
  21. public MPC::ConnectionPointImpl< Manager, &DIID_DPCHSEMgrEvents, MPC::CComSafeMultiThreadModel >,
  22. public IDispatchImpl < IPCHSEManager, &IID_IPCHSEManager, &LIBID_HelpServiceTypeLib >,
  23. public MPC::Thread<Manager,IUnknown>
  24. {
  25. typedef std::list< IPCHSEWrapperItem* > WrapperItemList;
  26. typedef WrapperItemList::iterator WrapperItemIter;
  27. typedef WrapperItemList::const_iterator WrapperItemIterConst;
  28. Taxonomy::HelpSet m_ths;
  29. WrapperItemList m_lstWrapperItem;
  30. bool m_fInitialized;
  31. MPC::FileLog m_fl;
  32. MPC::Impersonation m_imp;
  33. CComBSTR m_bstrQueryString;
  34. long m_lNumResult;
  35. long m_lEnabledSE;
  36. long m_lCountComplete;
  37. HRESULT m_hrLastError;
  38. CComPtr<IPCHSEManagerInternal> m_Notifier;
  39. CComPtr<IDispatch> m_Progress;
  40. CComPtr<IDispatch> m_Complete;
  41. CComPtr<IDispatch> m_WrapperComplete;
  42. ////////////////////////////////////////
  43. HRESULT Fire_OnProgress ( /*[in]*/ long lDone, /*[in]*/ long lTotal, /*[in]*/ BSTR bstrSEWrapperName );
  44. HRESULT Fire_OnComplete ( /*[in]*/ long lSucceeded );
  45. HRESULT Fire_OnWrapperComplete( /*[in]*/ IPCHSEWrapperItem* pIPCHSEWICompleted );
  46. HRESULT CreateAndAddWrapperToList( /*[in]*/ MPC::SmartLock<_ThreadModel>& lock ,
  47. /*[in]*/ BSTR bstrCLSID ,
  48. /*[in]*/ BSTR bstrID ,
  49. /*[in]*/ BSTR bstrData );
  50. void AcquireLock( /*[in]*/ MPC::SmartLock<_ThreadModel>& lock );
  51. HRESULT Initialize ( /*[in]*/ MPC::SmartLock<_ThreadModel>& lock );
  52. HRESULT ExecQuery();
  53. void CloneListOfWrappers( /*[out]*/ WrapperItemList& lst );
  54. public:
  55. BEGIN_COM_MAP(Manager)
  56. COM_INTERFACE_ENTRY2(IDispatch, IPCHSEManager)
  57. COM_INTERFACE_ENTRY(IPCHSEManager)
  58. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  59. END_COM_MAP()
  60. Manager();
  61. //
  62. // This is called by the CComObjectParent.Release method, to prepare for shutdown.
  63. //
  64. void Passivate();
  65. HRESULT IsNetworkAlive ( /*[out]*/ VARIANT_BOOL *pvbVar );
  66. HRESULT IsDestinationReachable( /*[in]*/ BSTR bstrDestination, /*[out]*/ VARIANT_BOOL *pvbVar );
  67. public:
  68. // IPCHSEManager
  69. STDMETHOD(get_QueryString )( /*[out, retval]*/ BSTR *pVal );
  70. STDMETHOD(put_QueryString )( /*[in]*/ BSTR newVal );
  71. STDMETHOD(get_NumResult )( /*[out, retval]*/ long *pVal );
  72. STDMETHOD(put_NumResult )( /*[in]*/ long newVal );
  73. STDMETHOD(put_onComplete )( /*[in]*/ IDispatch* function );
  74. STDMETHOD(put_onProgress )( /*[in]*/ IDispatch* function );
  75. STDMETHOD(put_onWrapperComplete )( /*[in]*/ IDispatch* function );
  76. STDMETHOD(get_SKU )( /*[out, retval]*/ BSTR *pVal );
  77. STDMETHOD(get_LCID )( /*[out, retval]*/ long *pVal );
  78. STDMETHOD(AbortQuery )( );
  79. STDMETHOD(ExecuteAsynchQuery)( );
  80. STDMETHOD(EnumEngine )( /*[out, retval]*/ IPCHCollection* *ppC );
  81. ////////////////////////////////////////
  82. // Internal Initialization.
  83. HRESULT InitializeFromDatabase( /*[in]*/ const Taxonomy::HelpSet& ths );
  84. HRESULT NotifyWrapperComplete( /*[in]*/ long lSucceeded, /*[in]*/ IPCHSEWrapperItem* pIPCHSEWICompleted );
  85. HRESULT LogRecord( /*[in]*/ BSTR bstrRecord );
  86. };
  87. typedef MPC::CComObjectParent<Manager> Manager_Object;
  88. class ATL_NO_VTABLE ManagerInternal :
  89. public MPC::CComObjectRootChildEx<MPC::CComSafeMultiThreadModel, Manager>,
  90. public IDispatchImpl<IPCHSEManagerInternal, &IID_IPCHSEManagerInternal, &LIBID_HelpServiceTypeLib>
  91. {
  92. public:
  93. BEGIN_COM_MAP(ManagerInternal)
  94. COM_INTERFACE_ENTRY(IDispatch)
  95. COM_INTERFACE_ENTRY(IPCHSEManagerInternal)
  96. END_COM_MAP()
  97. // IPCHSEManagerInternal
  98. public:
  99. STDMETHOD(WrapperComplete)( /*[in]*/ long lSucceeded, /*[in]*/ IPCHSEWrapperItem* pIPCHSEWICompleted );
  100. STDMETHOD(IsNetworkAlive )( /*[out]*/ VARIANT_BOOL *pvbVar );
  101. STDMETHOD(IsDestinationReachable)( /*[in]*/ BSTR bstrDestination, /*[out]*/ VARIANT_BOOL *pvbVar );
  102. STDMETHOD(LogRecord)( /*[in]*/ BSTR bstrRecord );
  103. };
  104. ////////////////////////////////////////////////////////////////////////////////
  105. struct ResultItem_Data
  106. {
  107. CComBSTR m_bstrTitle;
  108. CComBSTR m_bstrURI;
  109. long m_lContentType;
  110. CComBSTR m_bstrLocation;
  111. long m_lHits;
  112. double m_dRank;
  113. CComBSTR m_bstrImageURL;
  114. CComBSTR m_bstrVendor;
  115. CComBSTR m_bstrProduct;
  116. CComBSTR m_bstrComponent;
  117. CComBSTR m_bstrDescription;
  118. DATE m_dateLastModified;
  119. ResultItem_Data();
  120. };
  121. class ATL_NO_VTABLE ResultItem :
  122. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  123. public IDispatchImpl<IPCHSEResultItem, &IID_IPCHSEResultItem, &LIBID_HelpServiceTypeLib>
  124. {
  125. ResultItem_Data m_data;
  126. public:
  127. DECLARE_PROTECT_FINAL_CONSTRUCT()
  128. BEGIN_COM_MAP(ResultItem)
  129. COM_INTERFACE_ENTRY(IPCHSEResultItem)
  130. COM_INTERFACE_ENTRY(IDispatch)
  131. END_COM_MAP()
  132. ResultItem();
  133. ResultItem_Data& Data() { return m_data; }
  134. // IPCHSEResultItem
  135. public:
  136. STDMETHOD(get_Title )( /*[out, retval]*/ BSTR *pVal );
  137. STDMETHOD(get_URI )( /*[out, retval]*/ BSTR *pVal );
  138. STDMETHOD(get_ContentType)( /*[out, retval]*/ long *pVal );
  139. STDMETHOD(get_Location )( /*[out, retval]*/ BSTR *pVal );
  140. STDMETHOD(get_Hits )( /*[out, retval]*/ long *pVal );
  141. STDMETHOD(get_Rank )( /*[out, retval]*/ double *pVal );
  142. STDMETHOD(get_Description)( /*[out, retval]*/ BSTR *pVal );
  143. };
  144. ////////////////////////////////////////////////////////////////////////////////
  145. struct ParamItem_Definition
  146. {
  147. ParamTypeEnum m_pteParamType;
  148. VARIANT_BOOL m_bRequired;
  149. VARIANT_BOOL m_bVisible;
  150. LPCWSTR m_szName;
  151. UINT m_iDisplayString;
  152. LPCWSTR m_szDisplayString;
  153. LPCWSTR m_szData;
  154. };
  155. struct ParamItem_Definition2 : public ParamItem_Definition
  156. {
  157. MPC::wstring m_strName;
  158. MPC::wstring m_strDisplayString;
  159. MPC::wstring m_strData;
  160. ParamItem_Definition2();
  161. };
  162. struct ParamItem_Data
  163. {
  164. ParamTypeEnum m_pteParamType;
  165. VARIANT_BOOL m_bRequired;
  166. VARIANT_BOOL m_bVisible;
  167. CComBSTR m_bstrDisplayString;
  168. CComBSTR m_bstrName;
  169. CComVariant m_varData;
  170. ParamItem_Data();
  171. };
  172. class ATL_NO_VTABLE ParamItem :
  173. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  174. public IDispatchImpl<IPCHSEParamItem, &IID_IPCHSEParamItem, &LIBID_HelpServiceTypeLib>
  175. {
  176. ParamItem_Data m_data;
  177. public:
  178. BEGIN_COM_MAP(ParamItem)
  179. COM_INTERFACE_ENTRY(IPCHSEParamItem)
  180. COM_INTERFACE_ENTRY(IDispatch)
  181. END_COM_MAP()
  182. ParamItem();
  183. ParamItem_Data& Data() { return m_data; }
  184. // IPCHSEParamItem
  185. public:
  186. STDMETHOD(get_Type )( /*[out, retval]*/ ParamTypeEnum *pVal );
  187. STDMETHOD(get_Display )( /*[out, retval]*/ BSTR *pVal );
  188. STDMETHOD(get_Name )( /*[out, retval]*/ BSTR *pVal );
  189. STDMETHOD(get_Required)( /*[out, retval]*/ VARIANT_BOOL *pVal );
  190. STDMETHOD(get_Visible )( /*[out, retval]*/ VARIANT_BOOL *pVal );
  191. STDMETHOD(get_Data )( /*[out, retval]*/ VARIANT *pVal );
  192. };
  193. ////////////////////////////////////////////////////////////////////////////////
  194. typedef std::map<MPC::wstring, CComVariant> ParamMap;
  195. typedef ParamMap::iterator ParamMapIter;
  196. class ATL_NO_VTABLE WrapperBase :
  197. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  198. public IDispatchImpl<IPCHSEWrapperItem , &IID_IPCHSEWrapperItem , &LIBID_HelpServiceTypeLib>,
  199. public IDispatchImpl<IPCHSEWrapperInternal, &IID_IPCHSEWrapperInternal, &LIBID_HelpServiceTypeLib>
  200. {
  201. protected:
  202. VARIANT_BOOL m_bEnabled;
  203. CComBSTR m_bstrID;
  204. CComBSTR m_bstrOwner;
  205. CComBSTR m_bstrName;
  206. CComBSTR m_bstrDescription;
  207. CComBSTR m_bstrHelpURL;
  208. CComBSTR m_bstrScope;
  209. CComBSTR m_bstrQueryString;
  210. long m_lNumResult;
  211. CComPtr<IPCHSEManagerInternal> m_pSEMgr;
  212. Taxonomy::HelpSet m_ths;
  213. CComPtr<CPCHCollection> m_pParamDef;
  214. ParamMap m_aParam;
  215. ////////////////////////////////////////
  216. public:
  217. WrapperBase();
  218. virtual ~WrapperBase();
  219. virtual HRESULT Clean();
  220. VARIANT* GetParamInternal( /*[in]*/ LPCWSTR szParamName );
  221. HRESULT CreateParam( /*[in/out]*/ CPCHCollection* coll, /*[in]*/ const ParamItem_Definition* def );
  222. virtual HRESULT CreateListOfParams( /*[in]*/ CPCHCollection* coll );
  223. virtual HRESULT GetParamDefinition( /*[out]*/ const ParamItem_Definition*& lst, /*[out]*/ int& len );
  224. // IPCHSEWrapperItem
  225. public:
  226. STDMETHOD(get_Enabled )( /*[out, retval]*/ VARIANT_BOOL * pVal );
  227. STDMETHOD(put_Enabled )( /*[in]*/ VARIANT_BOOL newVal );
  228. STDMETHOD(get_Owner )( /*[out, retval]*/ BSTR * pVal );
  229. STDMETHOD(get_Description)( /*[out, retval]*/ BSTR * pVal );
  230. STDMETHOD(get_Name )( /*[out, retval]*/ BSTR * pVal );
  231. STDMETHOD(get_ID )( /*[out, retval]*/ BSTR * pVal );
  232. STDMETHOD(get_HelpURL )( /*[out, retval]*/ BSTR * pVal );
  233. STDMETHOD(get_SearchTerms)( /*[out, retval]*/ VARIANT * pVal );
  234. STDMETHOD(Param )( /*[out,retval]*/ IPCHCollection* *ppC );
  235. STDMETHOD(AddParam)( /*[in]*/ BSTR bstrParamName, /*[in]*/ VARIANT newVal );
  236. STDMETHOD(GetParam)( /*[in]*/ BSTR bstrParamName, /*[out,retval]*/ VARIANT * pVal );
  237. STDMETHOD(DelParam)( /*[in]*/ BSTR bstrParamName );
  238. // IPCHSEWrapperInternal
  239. public:
  240. STDMETHOD(get_QueryString)( /*[out, retval]*/ BSTR * pVal );
  241. STDMETHOD(put_QueryString)( /*[in]*/ BSTR newVal );
  242. STDMETHOD(get_NumResult )( /*[out, retval]*/ long * pVal );
  243. STDMETHOD(put_NumResult )( /*[in]*/ long newVal );
  244. STDMETHOD(SECallbackInterface)( /*[in]*/ IPCHSEManagerInternal* pMgr );
  245. STDMETHOD(Initialize )( /*[in]*/ BSTR bstrID, /*[in]*/ BSTR bstrSKU, /*[in]*/ long lLCID, /*[in]*/ BSTR bstrData );
  246. };
  247. ////////////////////////////////////////////////////////////////////////////////
  248. extern HRESULT WrapperItem__Create_Keyword ( /*[out]*/ CComPtr<IPCHSEWrapperInternal>& pVal );
  249. extern HRESULT WrapperItem__Create_FullTextSearch( /*[out]*/ CComPtr<IPCHSEWrapperInternal>& pVal );
  250. };
  251. ////////////////////////////////////////////////////////////////////////////////
  252. #endif // !defined(__INCLUDED___PCH___SEARCHENGINELIB_H___)