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.

321 lines
11 KiB

  1. //////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // ApplicationManager.h
  4. //
  5. // Copyright (C) 1998, 1999 Microsoft Corporation. All rights reserved.
  6. //
  7. // Abstract :
  8. //
  9. // This include file supports all the definitions used internally by the Application Manager
  10. //
  11. // History :
  12. //
  13. // 05/06/1999 luish Created
  14. //
  15. //////////////////////////////////////////////////////////////////////////////////////////////
  16. #ifndef __APPLICATIONMANAGER_
  17. #define __APPLICATIONMANAGER_
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include <windows.h>
  22. #include <winbase.h>
  23. #include <objbase.h>
  24. #include <assert.h>
  25. #include "AppMan.h"
  26. #include "AppManAdmin.h"
  27. #include "EmptyVc.h"
  28. #include "CriticalSection.h"
  29. #include "InformationManager.h"
  30. #define DISKCLEANER_DAY_THRESHOLD 120
  31. #define DEFAULT_PERCENT_CACHE_SIZE 70
  32. //
  33. // The defines are used to denote the current action of an object
  34. //
  35. #define CURRENT_ACTION_NONE 0x00000001
  36. #define CURRENT_ACTION_INSTALLING 0x00000002
  37. #define CURRENT_ACTION_REINSTALLING 0x00000004
  38. #define CURRENT_ACTION_DOWNSIZING 0x00000008
  39. #define CURRENT_ACTION_UNINSTALLING 0x00000010
  40. #define CURRENT_ACTION_SELFTESTING 0x00000020
  41. #define CURRENT_ACTION_RUNNING 0x00000040
  42. //////////////////////////////////////////////////////////////////////////////////////////////
  43. class CApplicationManagerRoot;
  44. class CEmptyVolumeCache;
  45. class CEmptyVolumeCacheCallBack;
  46. //////////////////////////////////////////////////////////////////////////////////////////////
  47. //
  48. // CApplicationManager
  49. //
  50. //////////////////////////////////////////////////////////////////////////////////////////////
  51. class CApplicationManager : public IApplicationManager
  52. {
  53. public :
  54. //
  55. // Constructor and destructor
  56. //
  57. CApplicationManager(void);
  58. CApplicationManager(CApplicationManagerRoot *pParent);
  59. ~CApplicationManager(void);
  60. //
  61. // IUnknown Interfaces
  62. //
  63. STDMETHOD (QueryInterface) (REFIID RefIID, LPVOID * lppVoidObject);
  64. STDMETHOD_(ULONG, AddRef) (void);
  65. STDMETHOD_(ULONG, Release) (void);
  66. //
  67. // IApplicationManager Interfaces
  68. //
  69. STDMETHOD (GetAdvancedMode) (LPDWORD lpdwAdvancedModeMask);
  70. STDMETHOD (GetAvailableSpace) (const DWORD dwApplicationCategory, LPDWORD lpdwMaximumSpace, LPDWORD lpdwOptimalSpace);
  71. STDMETHOD (CreateApplicationEntry) (IApplicationEntry ** lppObject);
  72. STDMETHOD (GetApplicationInfo) (IApplicationEntry * lpObject);
  73. STDMETHOD (EnumApplications) (const DWORD dwIndex, IApplicationEntry * lpObject);
  74. STDMETHOD (EnumDevices) (const DWORD dwIndex, LPDWORD lpdwKilobytes, LPDWORD lpdwExclusionMask, const DWORD dwStringMask, LPVOID lpData, const DWORD dwDataLen);
  75. private:
  76. CApplicationManagerRoot * m_pParentObject;
  77. CInformationManager m_InformationManager;
  78. };
  79. //////////////////////////////////////////////////////////////////////////////////////////////
  80. //
  81. // CApplicationEntry
  82. //
  83. //////////////////////////////////////////////////////////////////////////////////////////////
  84. class CApplicationEntry : public IApplicationEntry
  85. {
  86. public:
  87. //
  88. // Constructors, default copy constructor and assignment operator
  89. //
  90. CApplicationEntry(void);
  91. CApplicationEntry(const CApplicationEntry & refApplicationEntry);
  92. CApplicationEntry & operator = (const CApplicationEntry & refSourceObject);
  93. ~CApplicationEntry(void);
  94. //
  95. // IUnknown interfaces
  96. //
  97. STDMETHOD (QueryInterface) (REFIID RefIID, LPVOID * lppVoidObject);
  98. STDMETHOD_(ULONG, AddRef) (void);
  99. STDMETHOD_(ULONG, Release) (void);
  100. //
  101. // IApplicationEntry Interfaces
  102. //
  103. STDMETHOD (Initialize) (void);
  104. STDMETHOD (SetInitializationLevel) (DWORD dwInitializationLevel);
  105. STDMETHOD_(DWORD, GetActionState) (void);
  106. STDMETHOD (Clear) (void);
  107. STDMETHOD (GetProperty) (const DWORD dwProperty, LPVOID lpData, const DWORD dwDataLen);
  108. STDMETHOD (SetProperty) (const DWORD dwProperty, LPCVOID lpData, const DWORD dwDataLen);
  109. STDMETHOD (InitializeInstall) (void);
  110. STDMETHOD (FinalizeInstall) (void);
  111. STDMETHOD (InitializeDownsize) (void);
  112. STDMETHOD (FinalizeDownsize) (void);
  113. STDMETHOD (InitializeReInstall) (void);
  114. STDMETHOD (FinalizeReInstall) (void);
  115. STDMETHOD (InitializeUnInstall) (void);
  116. STDMETHOD (FinalizeUnInstall) (void);
  117. STDMETHOD (InitializeSelfTest) (void);
  118. STDMETHOD (FinalizeSelfTest) (void);
  119. STDMETHOD (Abort) (void);
  120. STDMETHOD (Run) (const DWORD dwRunFlags, const DWORD dwStringMask, LPVOID lpData, const DWORD dwDataLen);
  121. STDMETHOD (AddAssociation) (const DWORD dwAssociationType, const IApplicationEntry * pApplicationEntry);
  122. STDMETHOD (RemoveAssociation) (const DWORD dwAssociationType, const IApplicationEntry * pApplicationEntry);
  123. STDMETHOD (EnumAssociations) (const DWORD dwIndex, LPDWORD lpdwAssociationMask, IApplicationEntry * pApplicationEntry);
  124. STDMETHOD (GetTemporarySpace) (const DWORD dwSpace, const DWORD dwStringMask, LPVOID lpData, const DWORD dwDataLen);
  125. STDMETHOD (RemoveTemporarySpace) (const DWORD dwStringMask, LPVOID lpData, const DWORD dwDataLen);
  126. STDMETHOD (EnumTemporarySpaces) (const DWORD dwIndex, LPDWORD lpdwSpace, const DWORD dwStringMask, LPVOID lpData, const DWORD dwDataLen);
  127. LPAPPLICATION_DATA GetApplicationDataPtr(void);
  128. private :
  129. STDMETHOD (LockApplication) (void);
  130. STDMETHOD (UnLockApplication) (void);
  131. STDMETHOD (ValidateGetPropertyParameters) (const DWORD dwPropertyIndex, const DWORD dwPropertyModifiers, LPVOID lpData, const DWORD dwDataLen);
  132. STDMETHOD (ValidateStringProperty) (const DWORD dwPropertyIndex, const DWORD dwPropertyModifiers, LPCWSTR wszStringProperty);
  133. STDMETHOD (ValidateSetPropertyParameters) (const DWORD dwPropertyIndex, const DWORD dwPropertyModifiers, LPCVOID lpData, const DWORD dwDataLen);
  134. STDMETHOD (ValidateCommandLine) (LPCWSTR wszRootPath, LPCWSTR wszCommandLine);
  135. STDMETHOD (ComputeApplicationSpaceInfo) (const DWORD dwInstalledKilobytesExpected);
  136. STDMETHOD (ComputeOriginalApplicationSpaceInfo) (void);
  137. GUID m_sInstanceGuid;
  138. HANDLE m_hInstanceMutex;
  139. DWORD m_dwLockCount;
  140. BOOL m_fIsInitialized;
  141. LONG m_lReferenceCount;
  142. CInformationManager m_InformationManager;
  143. DWORD m_dwInitializationLevel;
  144. DWORD m_dwCurrentAction;
  145. DWORD m_dwOriginalSetupRootPathSizeKilobytes;
  146. DWORD m_dwOriginalApplicationRootPathSizeKilobytes;
  147. DWORD m_dwOriginalState;
  148. CCriticalSection m_sCriticalSection;
  149. APPLICATION_DATA m_sApplicationData;
  150. };
  151. //////////////////////////////////////////////////////////////////////////////////////////////
  152. //
  153. // CEmptyVolumeCache
  154. //
  155. //////////////////////////////////////////////////////////////////////////////////////////////
  156. class CEmptyVolumeCache : public IEmptyVolumeCache
  157. {
  158. public:
  159. //
  160. // Constructors, default copy constructor and assignment operator
  161. //
  162. CEmptyVolumeCache(void);
  163. CEmptyVolumeCache(CApplicationManagerRoot * lpParent);
  164. ~CEmptyVolumeCache(void);
  165. //
  166. // IUnknown interfaces
  167. //
  168. STDMETHOD (QueryInterface) (REFIID RefIID, LPVOID * lppVoidObject);
  169. STDMETHOD_(ULONG, AddRef) (void);
  170. STDMETHOD_(ULONG, Release) (void);
  171. STDMETHOD (Initialize) (HKEY hRegKey, LPCWSTR lpwszVolume, LPWSTR * lppwszDisplayName, LPWSTR * lppwszDescription, DWORD * lpdwFlags);
  172. STDMETHOD (GetSpaceUsed) (DWORDLONG * lpdwSpaceUsed, IEmptyVolumeCacheCallBack * lpCallBack);
  173. STDMETHOD (Purge) (DWORDLONG dwSpaceToFree, IEmptyVolumeCacheCallBack * lpCallBack);
  174. STDMETHOD (ShowProperties) (HWND hwnd);
  175. STDMETHOD (Deactivate) (DWORD * lpdwFlags);
  176. WCHAR m_wszDiskCleanerName[MAX_PATH_CHARCOUNT];
  177. WCHAR m_wszDiskCleanerName2[MAX_PATH_CHARCOUNT];
  178. WCHAR m_wszDiskCleanerDesc[2048];
  179. WCHAR m_wszDiskCleanerDesc2[1024];
  180. WCHAR m_wszDiskCleanerDayTH[10];
  181. private:
  182. HRESULT GetSpaceUtilization(DWORD dwDeviceIndex, DWORD dwDays, LPDWORD lpdwKilobytes, IEmptyVolumeCacheCallBack * lpCallBack);
  183. HRESULT CleanDisk(DWORD dwDeviceIndex, DWORD dwDays, DWORD dwKilobytesToFree, IEmptyVolumeCacheCallBack * lpCallBack);
  184. HRESULT CleanDiskUnattended(DWORD dwDays);
  185. DWORD VolumeStringToNumber(LPCWSTR lpwszVolume);
  186. DWORD ElapsedDays(SYSTEMTIME * lpLastUsedDate);
  187. DWORD m_dwVolume;
  188. DWORD m_dwDiskCleanerDayThreshold;
  189. CApplicationManagerRoot * m_lpoParentObject;
  190. CInformationManager m_oInformationManager;
  191. };
  192. //////////////////////////////////////////////////////////////////////////////////////////////
  193. //
  194. // CApplicationManager
  195. //
  196. //////////////////////////////////////////////////////////////////////////////////////////////
  197. class CApplicationManagerAdmin : public IApplicationManagerAdmin
  198. {
  199. public :
  200. //
  201. // Constructor and destructor
  202. //
  203. CApplicationManagerAdmin(void);
  204. CApplicationManagerAdmin(CApplicationManagerRoot * lpParent);
  205. ~CApplicationManagerAdmin(void);
  206. //
  207. // IUnknown Interfaces
  208. //
  209. STDMETHOD (QueryInterface) (REFIID RefIID, LPVOID * lppVoidObject);
  210. STDMETHOD_(ULONG, AddRef) (void);
  211. STDMETHOD_(ULONG, Release) (void);
  212. //
  213. // IApplicationManager Interfaces
  214. //
  215. STDMETHOD (EnumerateDevices) (const DWORD dwIndex, GUID * lpGuid);
  216. STDMETHOD (GetDeviceProperty) (const DWORD dwProperty, const GUID * lpGuid, LPVOID lpData, const DWORD dwDataLen);
  217. STDMETHOD (SetDeviceProperty) (const DWORD dwProperty, const GUID * lpGuid, LPVOID lpData, const DWORD dwDataLen);
  218. STDMETHOD (GetAppManProperty) (const DWORD dwProperty, LPVOID lpData, const DWORD dwDataLen);
  219. STDMETHOD (SetAppManProperty) (const DWORD dwProperty, LPCVOID lpData, const DWORD dwDataLen);
  220. STDMETHOD (CreateApplicationEntry) (IApplicationEntry **ppObject);
  221. STDMETHOD (GetApplicationInfo) (IApplicationEntry * pObject);
  222. STDMETHOD (EnumApplications) (const DWORD dwApplicationIndex, IApplicationEntry * lpObject);
  223. STDMETHOD (DoApplicationAction) (const DWORD dwAction, const GUID * lpGuid, const DWORD dwStringProperty, LPVOID lpData, const DWORD dwDataLen);
  224. private:
  225. CApplicationManagerRoot * m_pParentObject;
  226. CInformationManager m_InformationManager;
  227. };
  228. //////////////////////////////////////////////////////////////////////////////////////////////
  229. //
  230. // CApplicationManagerRoot class
  231. //
  232. //////////////////////////////////////////////////////////////////////////////////////////////
  233. class CApplicationManagerRoot : public IUnknown
  234. {
  235. public :
  236. //
  237. // Constructor and Destructor
  238. //
  239. CApplicationManagerRoot(void);
  240. ~CApplicationManagerRoot(void);
  241. //
  242. // IUnknow interface methods
  243. //
  244. STDMETHOD (QueryInterface) (REFIID RefIID, LPVOID *ppVoidObject);
  245. STDMETHOD_(ULONG, AddRef) (void);
  246. STDMETHOD_(ULONG, Release) (void);
  247. BOOL m_bInsufficientAccessToRun;
  248. private :
  249. CApplicationManager m_ApplicationManager;
  250. CApplicationManagerAdmin m_ApplicationManagerAdmin;
  251. CEmptyVolumeCache m_EmptyVolumeCache;
  252. LONG m_lReferenceCount;
  253. };
  254. #ifdef __cplusplus
  255. }
  256. #endif
  257. #endif // __APPLICATIONMANAGER_