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.

268 lines
9.1 KiB

  1. //
  2. // MODULE: TSHOOTCtrl.h
  3. //
  4. // PURPOSE: Interface for the component
  5. //
  6. // PROJECT: Troubleshooter 99
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  9. //
  10. // AUTHOR: Oleg Kalosha
  11. //
  12. // ORIGINAL DATE: 12.23.98
  13. //
  14. // NOTES:
  15. // Declaration of CTSHOOTCtrl
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V3.1 12/23/98 OK Windows related functionality is disabled;
  20. // IObjectSafetyImpl is added
  21. #ifndef __TSHOOTCTRL_H_
  22. #define __TSHOOTCTRL_H_
  23. #include "resource.h" // main symbols
  24. #include <atlctl.h>
  25. #include "CPTSHOOT.h"
  26. #include "apgtsstr.h"
  27. #include "TSNameValueMgr.h"
  28. #include "SniffConnector.h"
  29. #include "RenderConnector.h"
  30. #include <new.h>
  31. class CDBLoadConfiguration;
  32. class CThreadPool;
  33. class COnlineECB;
  34. class CPoolQueue;
  35. class CHTMLLog;
  36. class CLocalECB;
  37. class CVariantBuilder;
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CTSHOOTCtrl
  40. class ATL_NO_VTABLE CTSHOOTCtrl :
  41. //public CComObjectRootEx<CComMultiThreadModel>,
  42. public CComObjectRootEx<CComSingleThreadModel>,
  43. public IDispatchImpl<ITSHOOTCtrl, &IID_ITSHOOTCtrl, &LIBID_TSHOOTLib>,
  44. public CComControl<CTSHOOTCtrl>,
  45. public IPersistStreamInitImpl<CTSHOOTCtrl>,
  46. public IOleControlImpl<CTSHOOTCtrl>,
  47. public IOleObjectImpl<CTSHOOTCtrl>,
  48. public IOleInPlaceActiveObjectImpl<CTSHOOTCtrl>,
  49. public IViewObjectExImpl<CTSHOOTCtrl>,
  50. public IOleInPlaceObjectWindowlessImpl<CTSHOOTCtrl>,
  51. public ISupportErrorInfo,
  52. public IConnectionPointContainerImpl<CTSHOOTCtrl>,
  53. public IPersistStorageImpl<CTSHOOTCtrl>,
  54. public ISpecifyPropertyPagesImpl<CTSHOOTCtrl>,
  55. public IQuickActivateImpl<CTSHOOTCtrl>,
  56. public IDataObjectImpl<CTSHOOTCtrl>,
  57. public IProvideClassInfo2Impl<&CLSID_TSHOOTCtrl, &DIID__ITSHOOTCtrlEvents, &LIBID_TSHOOTLib>,
  58. public IPropertyNotifySinkCP<CTSHOOTCtrl>,
  59. public CComCoClass<CTSHOOTCtrl, &CLSID_TSHOOTCtrl>,
  60. public CProxy_ITSHOOTCtrlEvents< CTSHOOTCtrl >,
  61. public IObjectSafetyImpl<CTSHOOTCtrl, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>,
  62. public CSniffConnector,
  63. public CRenderConnector
  64. {
  65. friend class CProxy_ITSHOOTCtrlEvents< CTSHOOTCtrl >;
  66. public:
  67. CTSHOOTCtrl();
  68. virtual ~CTSHOOTCtrl();
  69. DECLARE_REGISTRY_RESOURCEID(IDR_TSHOOTCTRL)
  70. DECLARE_PROTECT_FINAL_CONSTRUCT()
  71. BEGIN_COM_MAP(CTSHOOTCtrl)
  72. COM_INTERFACE_ENTRY(ITSHOOTCtrl)
  73. COM_INTERFACE_ENTRY(IDispatch)
  74. COM_INTERFACE_ENTRY(IViewObjectEx)
  75. COM_INTERFACE_ENTRY(IViewObject2)
  76. COM_INTERFACE_ENTRY(IViewObject)
  77. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  78. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  79. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  80. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  81. COM_INTERFACE_ENTRY(IOleControl)
  82. COM_INTERFACE_ENTRY(IOleObject)
  83. COM_INTERFACE_ENTRY(IPersistStreamInit)
  84. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  85. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  86. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  87. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  88. COM_INTERFACE_ENTRY(IQuickActivate)
  89. COM_INTERFACE_ENTRY(IPersistStorage)
  90. COM_INTERFACE_ENTRY(IDataObject)
  91. COM_INTERFACE_ENTRY(IProvideClassInfo)
  92. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  93. COM_INTERFACE_ENTRY(IObjectSafety)
  94. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  95. END_COM_MAP()
  96. BEGIN_PROP_MAP(CTSHOOTCtrl)
  97. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  98. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  99. // Example entries
  100. // PROP_ENTRY("Property Description", dispid, clsid)
  101. // PROP_PAGE(CLSID_StockColorPage)
  102. END_PROP_MAP()
  103. BEGIN_CONNECTION_POINT_MAP(CTSHOOTCtrl)
  104. CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
  105. CONNECTION_POINT_ENTRY(DIID__ITSHOOTCtrlEvents)
  106. END_CONNECTION_POINT_MAP()
  107. /* >>> I have commented anything related to Windows messaging
  108. in order to relieve the Control. Oleg. 12.23.98
  109. BEGIN_MSG_MAP(CTSHOOTCtrl)
  110. CHAIN_MSG_MAP(CComControl<CTSHOOTCtrl>)
  111. DEFAULT_REFLECTION_HANDLER()
  112. END_MSG_MAP()
  113. */
  114. // Handler prototypes:
  115. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  116. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  117. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  118. // ISupportsErrorInfo
  119. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
  120. {
  121. static const IID* arr[] =
  122. {
  123. &IID_ITSHOOTCtrl,
  124. };
  125. for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
  126. {
  127. if (InlineIsEqualGUID(*arr[i], riid))
  128. return S_OK;
  129. }
  130. return S_FALSE;
  131. }
  132. // IViewObjectEx
  133. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  134. // ITSHOOTCtrl
  135. public:
  136. STDMETHOD(NotifyNothingChecked)(/*[in]*/ BSTR bstrMessage);
  137. STDMETHOD(ProblemPage)(/*[out, retval]*/ BSTR * pbstrFirstPage);
  138. STDMETHOD(RunQuery2)(/*[in]*/ BSTR, /*[in]*/ BSTR, /*[in]*/ BSTR, /*[out, retval]*/ BSTR * pbstrPage);
  139. STDMETHOD(SetPair)(/*[in]*/ BSTR bstrCmd, /*[in]*/ BSTR bstrVal);
  140. STDMETHOD(Restart)(/*[out, retval]*/ BSTR * pbstrPage);
  141. STDMETHOD(PreLoadURL)(/*[in]*/ BSTR bstrRoot, /*[out, retval]*/ BSTR * pbstrPage);
  142. STDMETHOD(SetSniffResult)(/*[in]*/ VARIANT varNodeName, /*[in]*/ VARIANT varState, /*[out, retval]*/ BOOL * bResult);
  143. STDMETHOD(RunQuery)(/*[in]*/ VARIANT varCmds, /*[in]*/ VARIANT varVals, /*[in]*/ short size, /*[out, retval]*/ BSTR * pbstrPage);
  144. /* >>> I have commented anything related to Windows messaging
  145. in order to relieve the Control. Oleg. 12.23.98
  146. HRESULT OnDraw(ATL_DRAWINFO& di)
  147. {
  148. RECT& rc = *(RECT*)di.prcBounds;
  149. Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
  150. SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
  151. LPCTSTR pszText = _T("ATL 3.0 : TSHOOTCtrl");
  152. TextOut(di.hdcDraw,
  153. (rc.left + rc.right) / 2,
  154. (rc.top + rc.bottom) / 2,
  155. pszText,
  156. lstrlen(pszText));
  157. return S_OK;
  158. }
  159. */
  160. protected:
  161. static bool SendSimpleHtmlPage(CLocalECB *pLocalECB,
  162. LPCTSTR pszStatus,
  163. const CString& str);
  164. static bool SendError(CDBLoadConfiguration *pConf,
  165. CLocalECB *pLocalECB,
  166. LPCTSTR pszStatus,
  167. const CString& strMessage);
  168. public:
  169. STDMETHOD(IsLocked)(/*[out, retval]*/ BOOL * pbResult);
  170. STDMETHOD(setLocale2)(/*[in]*/ BSTR bstrNewLocale);
  171. static bool RemoveStartOverButton(CString& strWriteClient);
  172. static bool RemoveBackButton(CString& strWriteClient);
  173. //static DWORD WINAPI Worker(LPVOID pParameter);
  174. protected:
  175. bool Init(HMODULE hModule);
  176. void Destroy();
  177. // Launcher integration
  178. bool ExtractLauncherData(CString& error);
  179. //
  180. DWORD HttpExtensionProc(CLocalECB* pECB);
  181. DWORD StartRequest(CLocalECB *pLocalECB, HANDLE hImpersonationToken);
  182. bool SendError(CLocalECB *pLocalECB,
  183. LPCTSTR pszStatus,
  184. const CString & strMessage) const;
  185. bool ReadStaticPageFile(const CString& strTopicName, CString& strContent);
  186. void RegisterGlobal();
  187. protected:
  188. virtual long PerformSniffingInternal(CString strNodeName, CString strLaunchBasis, CString strAdditionalArgs);
  189. virtual void RenderInternal(CString strPage);
  190. protected:
  191. _PNH m_SetNewHandlerPtr; // Used to store the initial _set_new_handler pointer.
  192. int m_SetNewMode; // Used to store the initial _set_new_mode value which
  193. // is then restored in the destructor.
  194. protected:
  195. bool m_bInitialized;
  196. bool m_bFirstCall;
  197. CThreadPool* m_pThreadPool; // thread management
  198. CPoolQueue* m_poolctl; // Keeps track of user requests queued up to be serviced
  199. // by working threads (a.k.a. "pool threads")
  200. CDBLoadConfiguration* m_pConf; // manages loading support files
  201. CHTMLLog* m_pLog; // manages user logging: what was requested by end user
  202. DWORD m_dwErr; // general error status. 0 - OK. Once set, never gets
  203. bool m_bShutdown; // Set true to say we're shutting down & can't handle
  204. // new requests.
  205. DWORD m_dwRollover; // We increment this each time we make a WORK_QUEUE_ITEM so
  206. // we can use it there as a unique ID (unique as long as
  207. // this DLL stays loaded).
  208. CString m_strFirstPage; // First page, saved when RunQuery is invoked
  209. // for the first time
  210. bool m_bStartedFromLauncher; // true if started from the Launcher,
  211. // false (from static page) by default
  212. CString m_strTopicName; // topic name - only one topic for Local TS
  213. CArrNameValue m_arrNameValueFromLauncher; // array of name - value pairs, extracted from Launcher
  214. // passed from Launcher
  215. // and can be used for sniffing
  216. CString m_strMachineID;
  217. CString m_strPNPDeviceID;
  218. CString m_strDeviceInstanceID;
  219. CString m_strGuidClass;
  220. CVariantBuilder * m_pVariantBuilder;
  221. CString m_strRequestedLocale; // Used to hold the requested locale string.
  222. // Could be null, hence the bool variable
  223. // m_bRequestToSetLocale.
  224. bool m_bRequestToSetLocale; // Set to true when a request to set the locale
  225. // is made, set to false after the LocalECB
  226. // object has been created. Initially set to false.
  227. vector<DWORD> m_vecCookies;
  228. IGlobalInterfaceTable* m_pGIT;
  229. bool m_bCanRegisterGlobal;
  230. };
  231. #endif //__TSHOOTCTRL_H_