[RAPPS] Formatting fixes
[reactos.git] / reactos / 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 /* EnumType flags for EnumAvailableApplications */
11 enum AvailableCategories
12 {
13 ENUM_ALL_AVAILABLE,
14 ENUM_CAT_AUDIO,
15 ENUM_CAT_VIDEO,
16 ENUM_CAT_GRAPHICS,
17 ENUM_CAT_GAMES,
18 ENUM_CAT_INTERNET,
19 ENUM_CAT_OFFICE,
20 ENUM_CAT_DEVEL,
21 ENUM_CAT_EDU,
22 ENUM_CAT_ENGINEER,
23 ENUM_CAT_FINANCE,
24 ENUM_CAT_SCIENCE,
25 ENUM_CAT_TOOLS,
26 ENUM_CAT_DRIVERS,
27 ENUM_CAT_LIBS,
28 ENUM_CAT_OTHER,
29 ENUM_AVAILABLE_MIN = ENUM_ALL_AVAILABLE,
30 ENUM_AVAILABLE_MAX = ENUM_CAT_OTHER
31 };
32
33 inline BOOL IsAvailableEnum(INT x)
34 {
35 return (x >= AvailableCategories::ENUM_AVAILABLE_MIN && x <= AvailableCategories::ENUM_AVAILABLE_MAX);
36 }
37
38 enum LicenseType
39 {
40 LICENSE_NONE,
41 LICENSE_OPENSOURCE,
42 LICENSE_FREEWARE,
43 LICENSE_TRIAL,
44 LICENSE_MIN = LICENSE_NONE,
45 LICENSE_MAX = LICENSE_TRIAL
46 };
47
48 inline BOOL IsLicenseType(INT x)
49 {
50 return (x >= LicenseType::LICENSE_MIN && x <= LicenseType::LICENSE_MAX);
51 }
52
53 struct CAvailableApplicationInfo
54 {
55 INT m_Category;
56 LicenseType m_LicenseType;
57 ATL::CStringW m_szName;
58 ATL::CStringW m_szRegName;
59 ATL::CStringW m_szVersion;
60 ATL::CStringW m_szLicense;
61 ATL::CStringW m_szDesc;
62 ATL::CStringW m_szSize;
63 ATL::CStringW m_szUrlSite;
64 ATL::CStringW m_szUrlDownload;
65 ATL::CStringW m_szCDPath;
66 ATL::CSimpleArray<LCID> m_LanguageLCIDs;
67
68 // Caching mechanism related entries
69 ATL::CStringW m_sFileName;
70 FILETIME m_ftCacheStamp;
71
72 // Optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form)
73 ATL::CStringW m_szSHA1;
74 ATL::CStringW m_szInstalledVersion;
75
76 CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
77
78 // Load all info from the file
79 VOID RefreshAppInfo();
80 BOOL HasLanguageInfo() const;
81 BOOL HasNativeLanguage() const;
82 BOOL HasEnglishLanguage() const;
83 BOOL IsInstalled() const;
84 BOOL HasInstalledVersion() const;
85 BOOL HasUpdate() const;
86
87 // Set a timestamp
88 VOID SetLastWriteTime(FILETIME* ftTime);
89
90 private:
91 BOOL m_IsInstalled = FALSE;
92 BOOL m_HasLanguageInfo = FALSE;
93 BOOL m_HasInstalledVersion = FALSE;
94 CConfigParser m_Parser;
95
96 inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString);
97
98 // Lazily load general info from the file
99 VOID RetrieveGeneralInfo();
100 VOID RetrieveInstalledStatus();
101 VOID RetrieveInstalledVersion();
102 VOID RetrieveLanguages();
103 VOID RetrieveLicenseType();
104 inline BOOL FindInLanguages(LCID what) const;
105 };
106
107 typedef BOOL(CALLBACK *AVAILENUMPROC)(CAvailableApplicationInfo *Info, LPCWSTR szFolderPath);
108
109 class CAvailableApps
110 {
111 ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
112 static ATL::CStringW m_szPath;
113 static ATL::CStringW m_szCabPath;
114 static ATL::CStringW m_szAppsPath;
115 static ATL::CStringW m_szSearchPath;
116
117 static BOOL InitializeStaticStrings();
118
119 public:
120 CAvailableApps();
121
122 static BOOL UpdateAppsDB();
123 static BOOL ForceUpdateAppsDB();
124 static VOID DeleteCurrentAppsDB();
125
126 VOID FreeCachedEntries();
127 BOOL Enum(INT EnumType, AVAILENUMPROC lpEnumProc);
128
129 CAvailableApplicationInfo* FindInfo(const ATL::CStringW& szAppName) const;
130 ATL::CSimpleArray<CAvailableApplicationInfo*> FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const;
131
132 const ATL::CStringW& GetFolderPath() const;
133 const ATL::CStringW& GetAppPath() const;
134 const ATL::CStringW& GetCabPath() const;
135 LPCWSTR GetFolderPathString() const;
136 LPCWSTR GetAppPathString() const;
137 LPCWSTR GetCabPathString() const;
138 };