Source code of Windows XP (NT5)
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.

574 lines
20 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: Update.h
  6. //
  7. // Owner: JHou
  8. //
  9. // Description:
  10. //
  11. // Industry Update v1.0 client control stub - Declaration of the CUpdate
  12. //
  13. //
  14. // Revision History:
  15. //
  16. // Date Author Desc
  17. // ~~~~ ~~~~~~ ~~~~
  18. // 9/15/2000 JHou created.
  19. //
  20. //=======================================================================
  21. #ifndef __UPDATE_H_
  22. #define __UPDATE_H_
  23. #include "resource.h" // main symbols
  24. #include "IUCtl.h"
  25. #include "IUCtlCP.h"
  26. #include "EvtMsgWnd.h"
  27. #include <iu.h> // for HIUENGINE
  28. // BOOL IsThisUpdate2();
  29. class CMyComClassFactory : public CComClassFactory
  30. {
  31. public:
  32. // IClassFactory
  33. STDMETHOD(CreateInstance)(LPUNKNOWN pUnkOuter, REFIID riid, void** ppvObj)
  34. {
  35. HRESULT hr = CComClassFactory::CreateInstance(pUnkOuter, riid, ppvObj);
  36. if (SUCCEEDED(hr))
  37. {
  38. //
  39. // allocate thread global variables, thread handle
  40. //
  41. }
  42. return hr;
  43. }
  44. };
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CUpdate
  47. class ATL_NO_VTABLE CUpdate :
  48. public CComObjectRootEx<CComMultiThreadModel>,
  49. public CComCoClass<CUpdate, &CLSID_Update>,
  50. public IObjectWithSiteImpl<CUpdate>,
  51. public IObjectSafety,
  52. public ISupportErrorInfo,
  53. public IConnectionPointContainerImpl<CUpdate>,
  54. public IProvideClassInfo2Impl<&CLSID_Update, NULL, &LIBID_IUCTLLib>,
  55. public IDispatchImpl<IUpdate, &IID_IUpdate, &LIBID_IUCTLLib>,
  56. public CProxyIUpdateEvents<CUpdate>
  57. {
  58. public:
  59. CUpdate();
  60. ~CUpdate();
  61. //
  62. // impl of object safety for scripting
  63. //
  64. ULONG InternalRelease();
  65. STDMETHOD(GetInterfaceSafetyOptions)(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions);
  66. STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions);
  67. DECLARE_REGISTRY_RESOURCEID(IDR_UPDATE)
  68. /*
  69. we decided to use the new Win32 API GetControlUpdateInfo() to expose these
  70. data and let a wrapper control to call it so we won't have reboot issue on
  71. OS prior to WinXP
  72. static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
  73. {
  74. UINT nResID = IsThisUpdate2() ? IDR_UPDATE2 : IDR_UPDATE;
  75. return _Module.UpdateRegistryFromResource(nResID, bRegister);
  76. }
  77. */
  78. DECLARE_NOT_AGGREGATABLE(CUpdate)
  79. DECLARE_PROTECT_FINAL_CONSTRUCT()
  80. BEGIN_COM_MAP(CUpdate)
  81. COM_INTERFACE_ENTRY(IUpdate)
  82. COM_INTERFACE_ENTRY(IDispatch)
  83. COM_INTERFACE_ENTRY(IObjectSafety)
  84. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  85. COM_INTERFACE_ENTRY(IProvideClassInfo)
  86. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  87. COM_INTERFACE_ENTRY_IMPL(IObjectWithSite)
  88. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  89. END_COM_MAP()
  90. BEGIN_CONNECTION_POINT_MAP(CUpdate)
  91. CONNECTION_POINT_ENTRY(DIID_IUpdateEvents)
  92. END_CONNECTION_POINT_MAP()
  93. // ISupportsErrorInfo
  94. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  95. // IUpdate
  96. public:
  97. DECLARE_CLASSFACTORY_EX(CMyComClassFactory);
  98. /////////////////////////////////////////////////////////////////////////////
  99. //
  100. // Initialize() API must be called before any other API will function
  101. //
  102. // If any other API is called before the control is initialized,
  103. // that API will return OLE_E_BLANK, signalling this OLE control is an
  104. // uninitialized object (although in this case it's a bit different from
  105. // its original meaning)
  106. //
  107. // Parameters:
  108. //
  109. // lInitFlag - IU_INIT_CHECK, cause Initialize() download ident and check if any
  110. // of the components need updated. currently we support control version
  111. // check and engine version check. Return value is a bit mask
  112. //
  113. // - IU_INIT_UPDATE_SYNC, cause Initialize() kicks off update engine
  114. // process if already called by IU_INIT_CHECK and a new engine is available.
  115. // When API returns, the update process is finished.
  116. //
  117. // - IU_INIT_UPDATE_ASYNC, cause Initialize() kicks off update engine
  118. // process in Asynchronized mode if already called by IU_INIT_CHECK and
  119. // a new engine is available. This API will return right after the
  120. // update process starts.
  121. //
  122. // punkUpdateCompleteListener - this is a pointer to a user-implemented
  123. // COM callback feature. It contains only one function OnComplete() that
  124. // will be called when the engine update is done.
  125. // This value can be NULL.
  126. //
  127. /////////////////////////////////////////////////////////////////////////////
  128. STDMETHOD(Initialize)(
  129. /*[in]*/ LONG lInitFlag,
  130. /*[in]*/ IUnknown* punkUpdateCompleteListener,
  131. /*[out, retval]*/ LONG* plRetVal);
  132. /////////////////////////////////////////////////////////////////////////////
  133. // GetSystemSpec()
  134. //
  135. // Gets the basic system specs.
  136. // Input:
  137. // bstrXmlClasses - a list of requested classes in xml format, NULL if any.
  138. // For example:
  139. // <devices>
  140. // <class name="video"/>
  141. // <class name="sound" id="2560AD4D-3ED3-49C6-A937-4368C0B0E06A"/>
  142. // </devices>
  143. // Output:
  144. // pbstrXmlDetectionResult - the detection result in xml format.
  145. /////////////////////////////////////////////////////////////////////////////
  146. STDMETHOD(GetSystemSpec)(BSTR bstrXmlClasses,
  147. BSTR* pbstrXmlDetectionResult);
  148. /////////////////////////////////////////////////////////////////////////////
  149. // GetManifest()
  150. //
  151. // Gets a catalog base on the specified information.
  152. // Input:
  153. // bstrXmlClientInfo - the credentials of the client in xml format
  154. // bstrXmlSystemSpec - the detected system specifications in xml
  155. // bstrXmlQuery - the user query infomation in xml
  156. // Output:
  157. // pbstrXmlCatalog - the xml catalog retrieved
  158. /////////////////////////////////////////////////////////////////////////////
  159. STDMETHOD(GetManifest)(BSTR bstrXmlClientInfo,
  160. BSTR bstrXmlSystemSpec,
  161. BSTR bstrXmlQuery,
  162. BSTR* pbstrXmlCatalog);
  163. /////////////////////////////////////////////////////////////////////////////
  164. // Detect()
  165. //
  166. // Do detection.
  167. // Input:
  168. // bstrXmlCatalog - the xml catalog portion containing items to be detected
  169. // Output:
  170. // pbstrXmlItems - the detected items in xml format
  171. // e.g.
  172. // <id guid="2560AD4D-3ED3-49C6-A937-4368C0B0E06D" installed="1" force="1"/>
  173. /////////////////////////////////////////////////////////////////////////////
  174. STDMETHOD(Detect)(BSTR bstrXmlCatalog,
  175. BSTR* pbstrXmlItems);
  176. /////////////////////////////////////////////////////////////////////////////
  177. // Download()
  178. //
  179. // Do synchronized downloading.
  180. // Input:
  181. // bstrXmlClientInfo - the credentials of the client in xml format
  182. // bstrXmlCatalog - the xml catalog portion containing items to be downloaded
  183. // bstrDestinationFolder - the destination folder. Null will use the default IU folder
  184. // lMode - indicates throttled or fore-ground downloading mode
  185. // punkProgressListener - the callback function pointer for reporting download progress
  186. // Output:
  187. // pbstrXmlItems - the items with download status in xml format
  188. // e.g.
  189. // <id guid="2560AD4D-3ED3-49C6-A937-4368C0B0E06D" downloaded="1"/>
  190. /////////////////////////////////////////////////////////////////////////////
  191. STDMETHOD(Download)(BSTR bstrXmlClientInfo,
  192. BSTR bstrXmlCatalog,
  193. BSTR bstrDestinationFolder,
  194. LONG lMode,
  195. IUnknown* punkProgressListener,
  196. BSTR* pbstrXmlItems);
  197. /////////////////////////////////////////////////////////////////////////////
  198. // DownloadAsync()
  199. //
  200. // Download asynchronously - the method will return before completion.
  201. // Input:
  202. // bstrXmlClientInfo - the credentials of the client in xml format
  203. // bstrXmlCatalog - the xml catalog portion containing items to be downloaded
  204. // bstrDestinationFolder - the destination folder. Null will use the default IU folder
  205. // lMode - indicates throttled or fore-ground downloading mode
  206. // punkProgressListener - the callback function pointer for reporting download progress
  207. // bstrUuidOperation - an id provided by the client to provide further
  208. // identification to the operation as indexes may be reused.
  209. // Output:
  210. // pbstrUuidOperation - the operation ID. If it is not provided by the in bstrUuidOperation
  211. // parameter (an empty string is passed), it will generate a new UUID,
  212. // in which case, the caller will be responsible to free the memory of
  213. // the string buffer that holds the generated UUID using SysFreeString().
  214. // Otherwise, it returns the value passed by bstrUuidOperation.
  215. /////////////////////////////////////////////////////////////////////////////
  216. STDMETHOD(DownloadAsync)(BSTR bstrXmlClientInfo,
  217. BSTR bstrXmlCatalog,
  218. BSTR bstrDestinationFolder,
  219. LONG lMode,
  220. IUnknown* punkProgressListener,
  221. BSTR bstrUuidOperation,
  222. BSTR* pbstrUuidOperation);
  223. /////////////////////////////////////////////////////////////////////////////
  224. // Install()
  225. //
  226. // Do synchronized installation.
  227. // Input:
  228. // bstrXmlCatalog - the xml catalog portion containing items to be installed
  229. // bstrXmlDownloadedItems - the xml of downloaded items and their respective download
  230. // result as described in the result schema. Install uses this
  231. // to know whether the items were downloaded and if so where they
  232. // were downloaded to so that it can install the items
  233. // lMode - indicates different installation mode
  234. // punkProgressListener - the callback function pointer for reporting install progress
  235. // Output:
  236. // pbstrXmlItems - the items with installation status in xml format
  237. // e.g.
  238. // <id guid="2560AD4D-3ED3-49C6-A937-4368C0B0E06D" installed="1"/>
  239. /////////////////////////////////////////////////////////////////////////////
  240. STDMETHOD(Install)(BSTR bstrXmlClientInfo,
  241. BSTR bstrXmlCatalog,
  242. BSTR bstrXmlDownloadedItems,
  243. LONG lMode,
  244. IUnknown* punkProgressListener,
  245. BSTR* pbstrXmlItems);
  246. /////////////////////////////////////////////////////////////////////////////
  247. // InstallAsync()
  248. //
  249. // Install Asynchronously.
  250. // Input:
  251. // bstrXmlCatalog - the xml catalog portion containing items to be installed
  252. // bstrXmlDownloadedItems - the xml of downloaded items and their respective download
  253. // result as described in the result schema. Install uses this
  254. // to know whether the items were downloaded and if so where they
  255. // were downloaded to so that it can install the items
  256. // lMode - indicates different installation mode
  257. // punkProgressListener - the callback function pointer for reporting install progress
  258. // bstrUuidOperation - an id provided by the client to provide further
  259. // identification to the operation as indexes may be reused.
  260. // Output:
  261. // pbstrUuidOperation - the operation ID. If it is not provided by the in bstrUuidOperation
  262. // parameter (an empty string is passed), it will generate a new UUID,
  263. // in which case, the caller will be responsible to free the memory of
  264. // the string buffer that holds the generated UUID using SysFreeString().
  265. // Otherwise, it returns the value passed by bstrUuidOperation.
  266. /////////////////////////////////////////////////////////////////////////////
  267. STDMETHOD(InstallAsync)(BSTR bstrXmlClientInfo,
  268. BSTR bstrXmlCatalog,
  269. BSTR bstrXmlDownloadedItems,
  270. LONG lMode,
  271. IUnknown* punkProgressListener,
  272. BSTR bstrUuidOperation,
  273. BSTR* pbstrUuidOperation);
  274. /////////////////////////////////////////////////////////////////////////////
  275. // SetOperationMode()
  276. //
  277. // Set the operation mode
  278. // Input:
  279. // bstrUuidOperation - an id provided by the client to provide further
  280. // identification to the operation as indexes may be reused.
  281. // lMode - a bitmask for the following mode:
  282. // UPDATE_COMMAND_PAUSE
  283. // UPDATE_COMMAND_RESUME
  284. // UPDATE_COMMAND_CANCEL
  285. // UPDATE_NOTIFICATION_COMPLETEONLY
  286. // UPDATE_NOTIFICATION_ANYPROGRESS
  287. // UPDATE_NOTIFICATION_1PCT
  288. // UPDATE_NOTIFICATION_5PCT
  289. // UPDATE_NOTIFICATION_10PCT
  290. // UPDATE_SHOWUI
  291. /////////////////////////////////////////////////////////////////////////////
  292. STDMETHOD(SetOperationMode)(BSTR bstrUuidOperation,
  293. LONG lMode);
  294. /**
  295. *
  296. * Get the mode of a specified operation.
  297. *
  298. * @param bstrUuidOperation: same as in SetOperationMode()
  299. * @param plMode - the retval for the mode found in a bitmask for:
  300. * (value in brackets [] means default)
  301. * UPDATE_COMMAND_PAUSE (TRUE/[FALSE])
  302. * UPDATE_COMMAND_RESUME (TRUE/[FALSE])
  303. * UPDATE_NOTIFICATION_COMPLETEONLY (TRUE/[FALSE])
  304. * UPDATE_NOTIFICATION_ANYPROGRESS ([TRUE]/FALSE)
  305. * UPDATE_NOTIFICATION_1PCT (TRUE/[FALSE])
  306. * UPDATE_NOTIFICATION_5PCT (TRUE/[FALSE])
  307. * UPDATE_NOTIFICATION_10PCT (TRUE/[FALSE])
  308. * UPDATE_SHOWUI (TRUE/[FALSE])
  309. *
  310. */
  311. STDMETHOD(GetOperationMode)(
  312. /*[in]*/ BSTR bstrUuidOperation,
  313. /*[out,retval]*/ LONG* plMode
  314. );
  315. /**
  316. *
  317. * Retrieve a property of this control
  318. * Calling this method will not cause the engine loaded
  319. *
  320. * @param lProperty - the identifier to flag which property need retrieved
  321. * UPDATE_PROP_OFFLINEMODE (TRUE/[FALSE])
  322. * UPDATE_PROP_USECOMPRESSION ([TRUE]/FALSE)
  323. *
  324. * @param varValue - the value to retrieve
  325. *
  326. */
  327. STDMETHOD(GetProperty)(
  328. /*[in]*/ LONG lProperty,
  329. /*[out,retval]*/ VARIANT* pvarValue
  330. );
  331. /**
  332. *
  333. * Set a property of this control
  334. * Calling this method will not cause the engine loaded
  335. *
  336. * @param lProperty - the identifier to flag which property need changed
  337. * UPDATE_PROP_OFFLINEMODE (TRUE/[FALSE])
  338. * UPDATE_PROP_USECOMPRESSION ([TRUE]/FALSE)
  339. *
  340. * @param varValue - the value to change
  341. *
  342. */
  343. STDMETHOD(SetProperty)(
  344. /*[in]*/ LONG lProperty,
  345. /*[in]*/ VARIANT varValue
  346. );
  347. /////////////////////////////////////////////////////////////////////////////
  348. // GetHistory()
  349. //
  350. // Get the history log.
  351. // Input:
  352. // bstrDateTimeFrom - the start date and time for which a log is required.
  353. // This is a string in ANSI format (YYYY-MM-DDTHH-MM).
  354. // If the string is empty, there will be no date restriction
  355. // of the returned history log.
  356. // bstrDateTimeTo - the end date and time for which a log is required.
  357. // This is a string in ANSI format (YYYY-MM-DDTHH-MM).
  358. // If the string is empty, there will be no date restriction
  359. // of the returned history log.
  360. // bstrClient - the name of the client that initiated the action. If this parameter
  361. // is null or an empty string, then there will be no filtering based
  362. // on the client.
  363. // bstrPath - the path used for download or install. Used in the corporate version
  364. // by IT managers. If this parameter is null or an empty string, then
  365. // there will be no filtering based on the path.
  366. // Output:
  367. // pbstrLog - the history log in xml format
  368. /////////////////////////////////////////////////////////////////////////////
  369. STDMETHOD(GetHistory)(BSTR bstrDateTimeFrom,
  370. BSTR bstrDateTimeTo,
  371. BSTR bstrClient,
  372. BSTR bstrPath,
  373. BSTR* pbstrLog);
  374. /////////////////////////////////////////////////////////////////////////////
  375. //
  376. // Primarily expose shlwapi BrowseForFolder API, can also do checking
  377. // on R/W access if flagged so.
  378. //
  379. // @param bstrStartFolder - the folder from which to start. If NULL or empty str
  380. // is being passed in, then start from desktop
  381. //
  382. // @param flag - validating check
  383. // UI_WRITABLE for checking write access, OK button may disabled.
  384. // UI_READABLE for checking read access, OK button may disabled.
  385. // NO_UI_WRITABLE for checking write access, return error if no access
  386. // NO_UI_READABLE for checking read access, return error if no access
  387. // 0 (default) for no checking.
  388. //
  389. // @param pbstrFolder - returned folder if a valid folder selected
  390. //
  391. /////////////////////////////////////////////////////////////////////////////
  392. STDMETHOD(BrowseForFolder)(BSTR bstrStartFolder,
  393. LONG flag,
  394. BSTR* pbstrFolder);
  395. /////////////////////////////////////////////////////////////////////////////
  396. //
  397. // Allows the Caller to Request the Control to do a Reboot
  398. //
  399. /////////////////////////////////////////////////////////////////////////////
  400. STDMETHOD(RebootMachine)();
  401. /////////////////////////////////////////////////////////////////////////////
  402. //
  403. // Make the other control can be unloaded from IE/OLE
  404. //
  405. /////////////////////////////////////////////////////////////////////////////
  406. STDMETHOD(PrepareSelfUpdate)(/*[in]*/ LONG lStep);
  407. /////////////////////////////////////////////////////////////////////////////
  408. //
  409. // Helper API to let the caller (script) knows the necessary information
  410. // when Initialize() returns control need updated.
  411. //
  412. // For the current implementation, bstrClientName is ignored, and
  413. // the returned bstr has format:
  414. // "<version>|<url>"
  415. // where:
  416. // <version> is the expacted version number of the control
  417. // <url> is the base url to get the control if this is a CorpWU policy controlled machine,
  418. // or empty if this is a consumer machine (in that case caller, i.e., script, knows
  419. // the default base url, which is the v4 live site)
  420. //
  421. // Script will need these two pieces of information in order to make a right <OBJECT> tag
  422. // for control update.
  423. //
  424. /////////////////////////////////////////////////////////////////////////////
  425. STDMETHOD(GetControlExtraInfo)(/*[in]*/ BSTR bstrClientName,
  426. /*[out,retval]*/ BSTR *pbstrExtraInfo);
  427. //
  428. // override IObjectWithSiteImpl function to get the site pointer
  429. //
  430. STDMETHOD(SetSite)(IUnknown* pSite);
  431. HRESULT ChangeControlInitState(LONG lNewState);
  432. inline CEventMsgWindow& GetEventWndClass() {return m_EvtWindow;};
  433. private:
  434. HANDLE m_evtControlQuit;
  435. DWORD m_dwMode;
  436. DWORD m_dwSafety;
  437. HMODULE m_hEngineModule;
  438. HIUENGINE m_hIUEngine; // Life of this handle must be within scope of valid m_hEngineModule
  439. BOOL m_fUseCompression;
  440. BOOL m_fOfflineMode;
  441. HRESULT m_hValidated; // E_FAIL: initialized,
  442. // S_OK: validated,
  443. // INET_E_INVALID_URL: bad URL, don't continue
  444. LONG m_lInitState; // 0 - not initialized
  445. // 1 - need update
  446. // 2 - initialized, ready to work
  447. DWORD m_dwUpdateInfo; // result of first Initialize() call
  448. IUnknown* m_pClientSite;
  449. TCHAR m_szReqControlVer[64];
  450. //
  451. // private function
  452. //
  453. /////////////////////////////////////////////////////////////////////////////
  454. //
  455. // Security feature: make sure if the user of this control is
  456. // a web page then the URL can be found in iuident.txt
  457. //
  458. // This function should be called after iuident refreshed.
  459. //
  460. // Return: TRUE/FALSE, to tell if we can continue
  461. //
  462. /////////////////////////////////////////////////////////////////////////////
  463. HRESULT ValidateControlContainer(void);
  464. /////////////////////////////////////////////////////////////////////////////
  465. // UnlockEngine()
  466. //
  467. // release the engine dll if ref cnt of engine is down to zero
  468. /////////////////////////////////////////////////////////////////////////////
  469. HRESULT UnlockEngine();
  470. /////////////////////////////////////////////////////////////////////////////
  471. // GetPropUpdateInfo()
  472. //
  473. // get the latest iuident.txt, find out the version requirement, then
  474. // compare with the current file version data to determine
  475. // if we will update anything if the engine get loaded.
  476. //
  477. /////////////////////////////////////////////////////////////////////////////
  478. HRESULT DetectEngine(BOOL* pfUpdateAvail);
  479. /////////////////////////////////////////////////////////////////////////////
  480. // event handling members
  481. /////////////////////////////////////////////////////////////////////////////
  482. CEventMsgWindow m_EvtWindow;
  483. /////////////////////////////////////////////////////////////////////////////
  484. // synchronization object to make sure we lock/unlock engine correctly
  485. // in multi-threaded cases
  486. /////////////////////////////////////////////////////////////////////////////
  487. CRITICAL_SECTION m_lock;
  488. BOOL m_gfInit_csLock;
  489. // BOOL m_fIsThisUpdate2;
  490. };
  491. #endif //__UPDATE_H_