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.

255 lines
6.9 KiB

  1. /*
  2. * CState.h - definitions/declarations for Windows Update V3 Catalog infra-structure
  3. *
  4. * Copyright (c) 1998-1999 Microsoft Corporation. All Rights Reserved.
  5. *
  6. * Purpose:
  7. * This file defines the structures, values, macros, and functions
  8. * used by the Version 3 Windows Update Catalog State management.
  9. *
  10. */
  11. #ifndef _WU_V3_STATE_INC
  12. #include <varray.h>
  13. #include <wuv3.h>
  14. #include <ccatalog.h>
  15. #include <stdlib.h> //For MAX_FNAME.
  16. #include <applog.h>
  17. #define ITEM_STATUS_SUCCESS 0 //The package was installed successfully.
  18. #define ITEM_STATUS_INSTALLED_ERROR 1 //The package was Installed however there were some minor problems that did not prevent installation.
  19. #define ITEM_STATUS_FAILED 2 //The packages was not installed.
  20. #define ITEM_STATUS_SUCCESS_REBOOT_REQUIRED 3 //The package was installed and requires a reboot.
  21. #define ITEM_STATUS_DOWNLOAD_COMPLETE 4 //The package was downloaded but not installed
  22. #define ITEM_STATUS_UNINSTALL_STARTED 5 //uninstall was started
  23. const unsigned int WUV3_CLIENT_AUTOUPDATE = 1;
  24. const unsigned int WUV3_CLIENT_UNSPECIFIED = 0;
  25. const unsigned int WUV3_CLIENT_WEBSITE = 2;
  26. typedef struct _STATESTRUCT
  27. {
  28. PUID puid; //catalog name
  29. CCatalog *pCatalog; //pointer to pruned catalog structure
  30. } STATESTRUCT, *PSTATESTRUCT;
  31. typedef struct _SELECTITEMINFO
  32. {
  33. PUID puid; //item identifier
  34. int iStatus; //last installation status
  35. HRESULT hrError; //specific error number if an error occured on installation.
  36. SYSTEMTIME stDateTime; //date time of item install or removal.
  37. BOOL bInstall; //TRUE if item was installed or FALSE if item was removed.
  38. int iCount; //useage count when this becomes 0 array element is removed.
  39. } SELECTITEMINFO, *PSELECTITEMINFO;
  40. #define SERVERTYPE_SITE 1
  41. #define SERVERTYPE_CABPOOL 2
  42. #define SERVERTYPE_CONTENT 3
  43. struct TRUSTEDSERVER
  44. {
  45. int iServerType;
  46. TCHAR szServerName[MAX_PATH];
  47. };
  48. struct DETDLLNAME
  49. {
  50. TCHAR szDLLName[32]; //we store file name only
  51. };
  52. //
  53. // CSelectItems class
  54. //
  55. class CSelectItems
  56. {
  57. public:
  58. CSelectItems();
  59. //This method selects an item for installation.
  60. void Select(
  61. PUID puid, //Inventory catalog item identifier to be selected.
  62. BOOL bInstall //If TRUE then the item is being selected for installation, FALSE=Remove
  63. );
  64. //This method unselects an item.
  65. void Unselect(PUID puid);
  66. void Clear();
  67. //This method returns the total number of selected items in selected item array.
  68. int GetTotal()
  69. {
  70. return m_iTotalItems;
  71. }
  72. //This method returns a pointer to the selected items array.
  73. PSELECTITEMINFO GetItems()
  74. {
  75. return &m_info[0];
  76. }
  77. private:
  78. int m_iTotalItems; //Total items currently in selected item array.
  79. Varray<SELECTITEMINFO> m_info; //Array of selected items
  80. };
  81. //
  82. // CState class
  83. //
  84. class CState
  85. {
  86. public:
  87. //Class constructor, Note: There is only 1 state management class for the entire V3
  88. //control. This class is created when the control is first loaded by the VBscript
  89. //page. The state management class is destroyed when the control is freed by the
  90. //VB script page.
  91. CState();
  92. ~CState();
  93. //This method retrieves a catalog from the state array. The catalog is
  94. //retrieved by name. If the catalog name is not found NULL is returned.
  95. CCatalog* Get(PUID puid);
  96. //This function gets a catalog inventory item and or catalog within the state store
  97. //by puid. The caller can retrieve the specific catalog item catalog or both. For
  98. //info that is not needed pass in NULL to the parameter. For example, if you do not
  99. //require the catalog parameter set the parameter to NULL.
  100. BOOL GetCatalogAndItem(
  101. IN PUID puid, //puid of item to be returned.
  102. IN OPTIONAL PINVENTORY_ITEM *ppItem, //returned pointer to specific item that equates to this puid
  103. IN OPTIONAL CCatalog **ppCatalog //returned pointer to specific catalog that this puid is in.
  104. );
  105. //Retrieves the full list of items that have this puid. The return value is the number
  106. //of returned items. If the case of an error 0 is returned. Note: This function is only
  107. //called from the ChangeItemState method.
  108. int GetItemList(
  109. IN PUID puid, //puid of item to be returned.
  110. IN Varray<PINVENTORY_ITEM> &itemsList //returned array of pointers to inventory items
  111. //that match this puid
  112. );
  113. //This method adds a new pruned catalog into the state array. This method returns
  114. //the total number of catalogs currently stored in the state array. This number
  115. //includes the new catalog. Note: The application must not delete a catalog that
  116. //is added to the state structure. Once the catalog is added it is the
  117. //responsibility of this class to delete the catalog.
  118. int Add(
  119. PUID puid, //PUID of Catalog to be added to state management class.
  120. CCatalog *pCatalog //Pointer to pruned catalog class to be added to state array.
  121. );
  122. //This function gets a catalog inventory item within the state store by puid.
  123. //If the catalog item is not found then NULL is returned.
  124. PINVENTORY_ITEM GetItem(
  125. PUID puid //puid of item to be returned.
  126. );
  127. //checks if the specified server is trusted or not
  128. void CheckTrustedServer(LPCTSTR pszIdentServer, CDiamond* pDiamond);
  129. void Reset();
  130. BOOL CacheDLLName(LPCTSTR pszDLLName);
  131. CAppLog& AppLog()
  132. {
  133. return m_AppLog;
  134. }
  135. LPCTSTR GetCabPoolServer()
  136. {
  137. return m_vTrustedServers[m_iCabPoolServer].szServerName;
  138. }
  139. LPCTSTR GetSiteServer()
  140. {
  141. return m_vTrustedServers[m_iSiteServer].szServerName;
  142. }
  143. LPCTSTR GetContentServer()
  144. {
  145. return m_vTrustedServers[m_iContentServer].szServerName;
  146. }
  147. LPCTSTR GetIdentServer()
  148. {
  149. return m_vTrustedServers[m_iIdentServer].szServerName;
  150. }
  151. LPCTSTR GetRootServer()
  152. {
  153. return m_vTrustedServers[m_iRootServer].szServerName;
  154. }
  155. LPCTSTR GetSiteURL()
  156. {
  157. return m_szSiteURL;
  158. }
  159. void SetSiteURL(LPCTSTR pszURL)
  160. {
  161. lstrcpy(m_szSiteURL, pszURL);
  162. }
  163. // Can only be called after SetSiteURL() has been called
  164. BOOL ValidateSiteURL();
  165. // returns the numeric browser locale set in the first catalog
  166. // in the state catalog array
  167. DWORD GetBrowserLocale();
  168. PBYTE m_pOemInfoTable; //OEM table used in client machine detection.
  169. CSelectItems m_selectedItems; //Selected items array.
  170. PDWORD m_pdwPlatformList; //Detected Platform list.
  171. int m_iTotalPlatforms; //Total number of detected platforms.
  172. int m_DefPlat; //default platform id
  173. BOOL m_bRebootNeeded; //true if reboot is required after install
  174. CAppLog m_AppLog;
  175. BOOL m_bInsengChecked;
  176. unsigned int m_nClient;
  177. private:
  178. //This method finds a catalog within the state store by name. If the catalog is
  179. //not found then NULL is returned.
  180. int Find(PUID puid);
  181. // catalogs
  182. int m_iTotalCatalogs;
  183. Varray<STATESTRUCT> m_vState;
  184. // trusted servers
  185. int m_cTrustedServers;
  186. Varray<TRUSTEDSERVER> m_vTrustedServers;
  187. int m_iCabPoolServer;
  188. int m_iSiteServer;
  189. int m_iContentServer;
  190. int m_iIdentServer;
  191. int m_iRootServer;
  192. // detection dlls
  193. int m_cDetDLLs;
  194. Varray<DETDLLNAME> m_vDetDLLs;
  195. // URL of the site
  196. TCHAR m_szSiteURL[MAX_PATH];
  197. };
  198. #define _WU_V3_STATE_INC
  199. #endif