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