5221e762095ec4cf2e9dfec62ebe7cbc430f0f89
[reactos.git] / reactos / base / applications / rapps / include / available.h
1 #pragma once
2 #include <windef.h>
3 #include <atlstr.h>
4 #include <atlsimpcoll.h>
5 #include <atlcoll.h>
6
7 /* EnumType flags for EnumAvailableApplications */
8 enum AvailableCategories
9 {
10 ENUM_ALL_AVAILABLE,
11 ENUM_CAT_AUDIO,
12 ENUM_CAT_VIDEO,
13 ENUM_CAT_GRAPHICS,
14 ENUM_CAT_GAMES,
15 ENUM_CAT_INTERNET,
16 ENUM_CAT_OFFICE,
17 ENUM_CAT_DEVEL,
18 ENUM_CAT_EDU,
19 ENUM_CAT_ENGINEER,
20 ENUM_CAT_FINANCE,
21 ENUM_CAT_SCIENCE,
22 ENUM_CAT_TOOLS,
23 ENUM_CAT_DRIVERS,
24 ENUM_CAT_LIBS,
25 ENUM_CAT_OTHER,
26 ENUM_AVAILABLE_MIN = ENUM_ALL_AVAILABLE,
27 ENUM_AVAILABLE_MAX = ENUM_CAT_OTHER
28 };
29
30 inline BOOL isAvailableEnum(INT x)
31 {
32 return (x >= ENUM_AVAILABLE_MIN && x <= ENUM_AVAILABLE_MAX);
33 }
34
35 typedef enum LICENSE_TYPE
36 {
37 None,
38 OpenSource,
39 Freeware,
40 Trial,
41 Max = Trial,
42 Min = None
43 } *PLICENSE_TYPE;
44
45 class CConfigParser
46 {
47 // Locale names cache
48 const static INT m_cchLocaleSize = 5;
49
50 static ATL::CStringW m_szLocaleID;
51 static ATL::CStringW m_szCachedINISectionLocale;
52 static ATL::CStringW m_szCachedINISectionLocaleNeutral;
53
54 const LPCWSTR STR_VERSION_CURRENT = L"CURRENT";
55 const ATL::CStringW szConfigPath;
56
57 static ATL::CStringW GetINIFullPath(const ATL::CStringW& FileName);
58 static VOID CacheINILocaleLazy();
59
60 public:
61 static const ATL::CStringW& GetLocale();
62 static INT CConfigParser::GetLocaleSize();
63
64 CConfigParser(const ATL::CStringW& FileName);
65
66 UINT GetString(const ATL::CStringW& KeyName, ATL::CStringW& ResultString);
67 UINT GetInt(const ATL::CStringW& KeyName);
68 };
69
70 typedef struct APPLICATION_INFO
71 {
72 INT Category;
73 LICENSE_TYPE LicenseType;
74 ATL::CStringW szName;
75 ATL::CStringW szRegName;
76 ATL::CStringW szVersion;
77 ATL::CStringW szLicense;
78 ATL::CStringW szDesc;
79 ATL::CStringW szSize;
80 ATL::CStringW szUrlSite;
81 ATL::CStringW szUrlDownload;
82 ATL::CStringW szCDPath;
83 ATL::CSimpleArray<LCID> Languages;
84
85 // Caching mechanism related entries
86 ATL::CStringW sFileName;
87 FILETIME ftCacheStamp;
88
89 // Optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form)
90 ATL::CStringW szSHA1;
91
92 } *PAPPLICATION_INFO;
93
94 typedef BOOL(CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info, LPCWSTR szFolderPath);
95
96 struct CAvailableApplicationInfo : public APPLICATION_INFO
97 {
98 ATL::CStringW szInstalledVersion;
99 CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
100
101 // Load all info from the file
102 VOID RefreshAppInfo();
103 BOOL HasLanguageInfo() const;
104 BOOL HasNativeLanguage() const;
105 BOOL HasEnglishLanguage() const;
106 BOOL IsInstalled() const;
107 BOOL HasInstalledVersion() const;
108 BOOL HasUpdate() const;
109
110 // Set a timestamp
111 VOID SetLastWriteTime(FILETIME* ftTime);
112
113 private:
114 BOOL m_IsInstalled = FALSE;
115 BOOL m_HasLanguageInfo = FALSE;
116 BOOL m_HasInstalledVersion = FALSE;
117 CConfigParser m_Parser;
118
119 inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString);
120
121 // Lazily load general info from the file
122 VOID RetrieveGeneralInfo();
123 VOID RetrieveInstalledStatus();
124 VOID RetrieveInstalledVersion();
125 VOID RetrieveLanguages();
126 VOID RetrieveLicenseType();
127 inline BOOL FindInLanguages(LCID what) const;
128 };
129
130 class CAvailableApps
131 {
132 ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
133 ATL::CStringW m_szPath;
134 ATL::CStringW m_szCabPath;
135 ATL::CStringW m_szAppsPath;
136 ATL::CStringW m_szSearchPath;
137
138 public:
139 CAvailableApps();
140 VOID FreeCachedEntries();
141 BOOL DeleteCurrentAppsDB();
142 BOOL UpdateAppsDB();
143 BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
144 const PAPPLICATION_INFO FindInfo(const ATL::CStringW& szAppName);
145 const ATL::CStringW& GetFolderPath();
146 const ATL::CStringW& GetAppPath();
147 const ATL::CStringW& GetCabPath();
148 const LPCWSTR GetFolderPathString();
149 const LPCWSTR GetAppPathString();
150 const LPCWSTR GetCabPathString();
151 };