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.

285 lines
11 KiB

  1. #ifndef __SRCHASST_H_
  2. #define __SRCHASST_H_
  3. #include "caggunk.h"
  4. #include "dspsprt.h"
  5. class CSearch : public ISearch,
  6. protected CImpIDispatch
  7. {
  8. public:
  9. //IUnknown methods
  10. STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppv);
  11. STDMETHODIMP_(ULONG) AddRef(void);
  12. STDMETHODIMP_(ULONG) Release(void);
  13. //IDispatch members
  14. virtual STDMETHODIMP GetTypeInfoCount(UINT * pctinfo)
  15. { return CImpIDispatch::GetTypeInfoCount(pctinfo); }
  16. virtual STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo)
  17. { return CImpIDispatch::GetTypeInfo(itinfo, lcid, pptinfo); }
  18. virtual STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID * rgdispid)
  19. { return CImpIDispatch::GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid); }
  20. virtual STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr)
  21. { return CImpIDispatch::Invoke(dispidMember, riid, lcid, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr); }
  22. //ISearch methods
  23. STDMETHODIMP get_Title(BSTR *pbstrTitle);
  24. STDMETHODIMP get_Id(BSTR *pbstrId);
  25. STDMETHODIMP get_Url(BSTR *pbstrUrl);
  26. private:
  27. CSearch(GUID *pguid, BSTR bstrTitle, BSTR bstrUrl);
  28. ~CSearch();
  29. LONG _cRef;
  30. BSTR _bstrTitle;
  31. BSTR _bstrUrl;
  32. TCHAR _szId[40];
  33. friend HRESULT CSearch_Create(GUID *pguid, BSTR bstrTitle, BSTR bstrUrl, ISearch **ppSearch);
  34. };
  35. class CSearchCollection : public ISearches,
  36. protected CImpIDispatch
  37. {
  38. public:
  39. //IUnknown methods
  40. STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppv);
  41. STDMETHODIMP_(ULONG) AddRef(void);
  42. STDMETHODIMP_(ULONG) Release(void);
  43. //IDispatch members
  44. virtual STDMETHODIMP GetTypeInfoCount(UINT * pctinfo)
  45. { return CImpIDispatch::GetTypeInfoCount(pctinfo); }
  46. virtual STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo)
  47. { return CImpIDispatch::GetTypeInfo(itinfo, lcid, pptinfo); }
  48. virtual STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID * rgdispid)
  49. { return CImpIDispatch::GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid); }
  50. virtual STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr)
  51. { return CImpIDispatch::Invoke(dispidMember, riid, lcid, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr); }
  52. STDMETHODIMP get_Count(long *plCount);
  53. STDMETHODIMP get_Default(BSTR *pbstr);
  54. STDMETHODIMP Item(VARIANT index, ISearch **ppid);
  55. STDMETHODIMP _NewEnum(IUnknown **ppunk);
  56. private:
  57. CSearchCollection(IFolderSearches *pfs);
  58. ~CSearchCollection();
  59. LONG _cRef;
  60. TCHAR _szDefault[40];
  61. HDSA _hdsaItems;
  62. friend HRESULT CSearchCollection_Create(IFolderSearches *pfs, ISearches **ppSearches);
  63. };
  64. //////////////////////////////////////////////////////////////////////////////
  65. // CProxy_SearchAssistantEvents
  66. template <class T>
  67. class CProxy_SearchAssistantEvents : public IConnectionPointImpl<T, &
  68. DIID__SearchAssistantEvents, CComDynamicUnkArray>
  69. {
  70. public:
  71. //methods:
  72. //_SearchAssistantEvents : IDispatch
  73. public:
  74. void Fire_OnNextMenuSelect(int idItem)
  75. {
  76. VARIANTARG* pvars = new VARIANTARG[1];
  77. if (NULL != pvars)
  78. {
  79. for (int i = 0; i < 1; i++)
  80. VariantInit(&pvars[i]);
  81. T* pT = (T*)this;
  82. pT->Lock();
  83. IUnknown** pp = m_vec.begin();
  84. while (pp < m_vec.end())
  85. {
  86. if (*pp != NULL)
  87. {
  88. pvars[0].vt = VT_I4;
  89. pvars[0].lVal= idItem;
  90. DISPPARAMS disp = { pvars, NULL, 1, 0 };
  91. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
  92. pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  93. }
  94. pp++;
  95. }
  96. pT->Unlock();
  97. delete[] pvars;
  98. }
  99. }
  100. void Fire_OnNewSearch()
  101. {
  102. T* pT = (T*)this;
  103. pT->Lock();
  104. IUnknown** pp = m_vec.begin();
  105. while (pp < m_vec.end())
  106. {
  107. if (*pp != NULL)
  108. {
  109. DISPPARAMS disp = { NULL, NULL, 0, 0 };
  110. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
  111. pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
  112. }
  113. pp++;
  114. }
  115. pT->Unlock();
  116. }
  117. };
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CSearchAssistantOC
  120. class ATL_NO_VTABLE CSearchAssistantOC :
  121. public CComObjectRootEx<CComSingleThreadModel>,
  122. public CComCoClass<CSearchAssistantOC, &CLSID_SearchAssistantOC>,
  123. public CComControl<CSearchAssistantOC>,
  124. public IDispatchImpl<ISearchAssistantOC3, &IID_ISearchAssistantOC3, &LIBID_SHDocVw>,
  125. public IProvideClassInfo2Impl<&CLSID_SearchAssistantOC, &DIID__SearchAssistantEvents, &LIBID_SHDocVw>,
  126. public IQuickActivateImpl<CSearchAssistantOC>,
  127. public IOleControlImpl<CSearchAssistantOC>,
  128. public IOleObjectImpl<CSearchAssistantOC>,
  129. public IOleInPlaceActiveObjectImpl<CSearchAssistantOC>,
  130. public IViewObjectExImpl<CSearchAssistantOC>,
  131. public IOleInPlaceObjectWindowlessImpl<CSearchAssistantOC>,
  132. public IDataObjectImpl<CSearchAssistantOC>,
  133. public CProxy_SearchAssistantEvents<CSearchAssistantOC>,
  134. public IConnectionPointContainerImpl<CSearchAssistantOC>,
  135. public IObjectSafetyImpl<CSearchAssistantOC, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
  136. public IOleCommandTarget,
  137. public IObjectWithSite // HACKHACK: need non-IOleClientSite host for FindXXX methods.
  138. {
  139. public:
  140. CSearchAssistantOC();
  141. ~CSearchAssistantOC();
  142. BEGIN_COM_MAP(CSearchAssistantOC)
  143. COM_INTERFACE_ENTRY(ISearchAssistantOC3)
  144. COM_INTERFACE_ENTRY_IID(IID_ISearchAssistantOC, ISearchAssistantOC3)
  145. COM_INTERFACE_ENTRY(IDispatch)
  146. COM_INTERFACE_ENTRY(IOleCommandTarget)
  147. COM_INTERFACE_ENTRY_IMPL(IViewObjectEx)
  148. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx)
  149. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx)
  150. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless)
  151. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
  152. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
  153. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject)
  154. COM_INTERFACE_ENTRY_IMPL(IOleControl)
  155. COM_INTERFACE_ENTRY_IMPL(IOleObject)
  156. COM_INTERFACE_ENTRY_IMPL(IQuickActivate)
  157. COM_INTERFACE_ENTRY_IMPL(IDataObject)
  158. COM_INTERFACE_ENTRY(IProvideClassInfo)
  159. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  160. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  161. COM_INTERFACE_ENTRY(IObjectSafety)
  162. COM_INTERFACE_ENTRY(IObjectWithSite)
  163. END_COM_MAP()
  164. BEGIN_CONNECTION_POINT_MAP(CSearchAssistantOC)
  165. CONNECTION_POINT_ENTRY(DIID__SearchAssistantEvents)
  166. END_CONNECTION_POINT_MAP()
  167. BEGIN_MSG_MAP(CSearchAssistantOC)
  168. MESSAGE_HANDLER(WM_PAINT, OnPaint)
  169. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  170. MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  171. END_MSG_MAP()
  172. // IViewObjectEx
  173. STDMETHOD(GetViewStatus)(DWORD* pdwStatus)
  174. {
  175. ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n"));
  176. *pdwStatus = 0;
  177. return S_OK;
  178. }
  179. public:
  180. // *** ISearchAssistantOC methods ***
  181. STDMETHOD(AddNextMenuItem)(BSTR bstrText, long idItem);
  182. STDMETHOD(SetDefaultSearchUrl)(BSTR bstrUrl);
  183. STDMETHOD(NavigateToDefaultSearch)();
  184. STDMETHOD(IsRestricted)(BSTR bstrGuid, VARIANT_BOOL *pVal);
  185. STDMETHOD(get_ShellFeaturesEnabled)(VARIANT_BOOL *pVal);
  186. STDMETHOD(get_SearchAssistantDefault)(VARIANT_BOOL *pVal);
  187. STDMETHOD(get_Searches)(ISearches **ppid);
  188. STDMETHOD(get_InWebFolder)(VARIANT_BOOL *pVal);
  189. STDMETHOD(PutProperty)(VARIANT_BOOL bPerLocale, BSTR bstrName, BSTR bstrValue);
  190. STDMETHOD(GetProperty)(VARIANT_BOOL bPerLocale, BSTR bstrName, BSTR *pbstrValue);
  191. STDMETHOD(put_EventHandled)(VARIANT_BOOL bHandled);
  192. STDMETHOD(ResetNextMenu)();
  193. STDMETHOD(FindOnWeb)() ;
  194. STDMETHOD(FindFilesOrFolders)() ;
  195. STDMETHOD(FindComputer)() ;
  196. STDMETHOD(FindPrinter)() ;
  197. STDMETHOD(FindPeople)() ;
  198. STDMETHOD(GetSearchAssistantURL)(VARIANT_BOOL bSubstitute, VARIANT_BOOL bCustomize, BSTR *pbstrValue);
  199. STDMETHOD(NotifySearchSettingsChanged)();
  200. STDMETHOD(put_ASProvider)(BSTR Provider);
  201. STDMETHOD(get_ASProvider)(BSTR *pProvider);
  202. STDMETHOD(put_ASSetting)(int Setting);
  203. STDMETHOD(get_ASSetting)(int *pSetting);
  204. STDMETHOD(NETDetectNextNavigate)();
  205. STDMETHOD(PutFindText)(BSTR FindText);
  206. STDMETHOD(get_Version)(int *pVersion);
  207. STDMETHOD(EncodeString)(BSTR bstrValue, BSTR bstrCharSet, VARIANT_BOOL bUseUTF8, BSTR *pbstrResult);
  208. // *** ISearchAssistantOC2 methods ***
  209. STDMETHOD(get_ShowFindPrinter)(VARIANT_BOOL *pbShowFindPrinter);
  210. // *** ISearchAssistantOC3 methods ***
  211. STDMETHOD(get_SearchCompanionAvailable)(VARIANT_BOOL *pbAvailable);
  212. STDMETHOD(put_UseSearchCompanion)(VARIANT_BOOL bUseSC);
  213. STDMETHOD(get_UseSearchCompanion)(VARIANT_BOOL *pbUseSC);
  214. // *** IObjectWithSite ***
  215. STDMETHOD(SetSite)(IUnknown*) ;
  216. STDMETHOD(GetSite)(REFIID, void**) ;
  217. // *** IOleObject overrides ***
  218. STDMETHOD(SetClientSite)(IOleClientSite *pClientSite);
  219. STDMETHOD(QueryStatus)(const GUID *pguidCmdGroup,
  220. ULONG cCmds,
  221. OLECMD prgCmds[],
  222. OLECMDTEXT *pCmdText);
  223. STDMETHOD(Exec)(const GUID *pguidCmdGroup,
  224. DWORD nCmdID,
  225. DWORD nCmdexecopt,
  226. VARIANT *pvaIn,
  227. VARIANT *pvaOut);
  228. HRESULT OnDraw(ATL_DRAWINFO& di);
  229. BOOL IsTrustedSite();
  230. HRESULT ShowSearchBand( REFGUID guidSearch ) ;
  231. static HRESULT UpdateRegistry(BOOL bRegister);
  232. private:
  233. ISearchBandTBHelper *m_pSearchBandTBHelper;
  234. BOOL m_bSafetyInited : 1;
  235. BOOL m_bIsTrustedSite : 1;
  236. IUnknown* m_punkSite ; // to accomodate clients who aren't hosting us as an OC.
  237. VARIANT_BOOL m_bEventHandled;
  238. STDMETHOD(LocalZoneCheck)(); // for wininet netdetect security
  239. };
  240. #define CP_BOGUS ((UINT)-1)
  241. #define CP_UTF_8 65001
  242. #endif // __SRCHASST_H_