[RAPPS] Introduce 'SizeBytes' DB entry and use it for display
[reactos.git] / base / applications / rapps / include / available.h
1 #pragma once
2
3 #include <windef.h>
4 #include <atlstr.h>
5 #include <atlsimpcoll.h>
6 #include <atlcoll.h>
7
8 #include "misc.h"
9
10 enum LicenseType
11 {
12 LICENSE_NONE,
13 LICENSE_OPENSOURCE,
14 LICENSE_FREEWARE,
15 LICENSE_TRIAL,
16 LICENSE_MIN = LICENSE_NONE,
17 LICENSE_MAX = LICENSE_TRIAL
18 };
19
20 inline BOOL IsLicenseType(INT x)
21 {
22 return (x >= LICENSE_MIN && x <= LICENSE_MAX);
23 }
24
25 struct CAvailableApplicationInfo
26 {
27 INT m_Category;
28 BOOL m_IsSelected;
29 LicenseType m_LicenseType;
30 ATL::CStringW m_szName;
31 ATL::CStringW m_szRegName;
32 ATL::CStringW m_szVersion;
33 ATL::CStringW m_szLicense;
34 ATL::CStringW m_szDesc;
35 ATL::CStringW m_szSize;
36 ATL::CStringW m_szUrlSite;
37 ATL::CStringW m_szUrlDownload;
38 ATL::CStringW m_szCDPath;
39 ATL::CSimpleArray<LCID> m_LanguageLCIDs;
40
41 // Caching mechanism related entries
42 ATL::CStringW m_sFileName;
43 FILETIME m_ftCacheStamp;
44
45 // Optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form)
46 ATL::CStringW m_szSHA1;
47 ATL::CStringW m_szInstalledVersion;
48
49 // Create an object from file
50 CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
51
52 // Load all info from the file
53 VOID RefreshAppInfo();
54 BOOL HasLanguageInfo() const;
55 BOOL HasNativeLanguage() const;
56 BOOL HasEnglishLanguage() const;
57 BOOL IsInstalled() const;
58 BOOL HasInstalledVersion() const;
59 BOOL HasUpdate() const;
60
61 // Set a timestamp
62 VOID SetLastWriteTime(FILETIME* ftTime);
63
64 private:
65 BOOL m_IsInstalled;
66 BOOL m_HasLanguageInfo;
67 BOOL m_HasInstalledVersion;
68 CConfigParser* m_Parser;
69
70 inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString);
71
72 // Lazily load general info from the file
73 VOID RetrieveGeneralInfo();
74 VOID RetrieveInstalledStatus();
75 VOID RetrieveInstalledVersion();
76 VOID RetrieveLanguages();
77 VOID RetrieveLicenseType();
78 VOID RetrieveSize();
79 inline BOOL FindInLanguages(LCID what) const;
80 };
81
82 typedef BOOL(CALLBACK *AVAILENUMPROC)(CAvailableApplicationInfo *Info, LPCWSTR szFolderPath);
83
84 struct AvailableStrings
85 {
86 ATL::CStringW szPath;
87 ATL::CStringW szCabPath;
88 ATL::CStringW szAppsPath;
89 ATL::CStringW szSearchPath;
90 ATL::CStringW szCabName;
91 ATL::CStringW szCabDir;
92
93 AvailableStrings();
94 };
95
96 class CAvailableApps
97 {
98 static AvailableStrings m_Strings;
99 ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
100
101 public:
102 CAvailableApps();
103
104 static BOOL UpdateAppsDB();
105 static BOOL ForceUpdateAppsDB();
106 static VOID DeleteCurrentAppsDB();
107
108 VOID FreeCachedEntries();
109 BOOL Enum(INT EnumType, AVAILENUMPROC lpEnumProc);
110
111 CAvailableApplicationInfo* FindInfo(const ATL::CStringW& szAppName) const;
112 ATL::CSimpleArray<CAvailableApplicationInfo> FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const;
113 ATL::CSimpleArray<CAvailableApplicationInfo> GetSelected() const;
114
115 const ATL::CStringW& GetFolderPath() const;
116 const ATL::CStringW& GetAppPath() const;
117 const ATL::CStringW& GetCabPath() const;
118 };