1e9a1df63b3270771f23cbcebfae5fc9918141b6
[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 LicenseType m_LicenseType;
29 ATL::CStringW m_szName;
30 ATL::CStringW m_szRegName;
31 ATL::CStringW m_szVersion;
32 ATL::CStringW m_szLicense;
33 ATL::CStringW m_szDesc;
34 ATL::CStringW m_szSize;
35 ATL::CStringW m_szUrlSite;
36 ATL::CStringW m_szUrlDownload;
37 ATL::CStringW m_szCDPath;
38 ATL::CSimpleArray<LCID> m_LanguageLCIDs;
39
40 // Caching mechanism related entries
41 ATL::CStringW m_sFileName;
42 FILETIME m_ftCacheStamp;
43
44 // Optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form)
45 ATL::CStringW m_szSHA1;
46 ATL::CStringW m_szInstalledVersion;
47
48 // Create an object from file
49 CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
50
51 // Load all info from the file
52 VOID RefreshAppInfo();
53 BOOL HasLanguageInfo() const;
54 BOOL HasNativeLanguage() const;
55 BOOL HasEnglishLanguage() const;
56 BOOL IsInstalled() const;
57 BOOL HasInstalledVersion() const;
58 BOOL HasUpdate() const;
59
60 // Set a timestamp
61 VOID SetLastWriteTime(FILETIME* ftTime);
62
63 private:
64 BOOL m_IsInstalled;
65 BOOL m_HasLanguageInfo;
66 BOOL m_HasInstalledVersion;
67 CConfigParser* m_Parser;
68
69 inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString);
70
71 // Lazily load general info from the file
72 VOID RetrieveGeneralInfo();
73 VOID RetrieveInstalledStatus();
74 VOID RetrieveInstalledVersion();
75 VOID RetrieveLanguages();
76 VOID RetrieveLicenseType();
77 inline BOOL FindInLanguages(LCID what) const;
78 };
79
80 typedef BOOL(CALLBACK *AVAILENUMPROC)(CAvailableApplicationInfo *Info, LPCWSTR szFolderPath);
81
82 struct AvailableStrings
83 {
84 ATL::CStringW szPath;
85 ATL::CStringW szCabPath;
86 ATL::CStringW szAppsPath;
87 ATL::CStringW szSearchPath;
88
89 AvailableStrings();
90 };
91
92 class CAvailableApps
93 {
94 static AvailableStrings m_Strings;
95 ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
96
97 public:
98 CAvailableApps();
99
100 static BOOL UpdateAppsDB();
101 static BOOL ForceUpdateAppsDB();
102 static VOID DeleteCurrentAppsDB();
103
104 VOID FreeCachedEntries();
105 BOOL Enum(INT EnumType, AVAILENUMPROC lpEnumProc);
106
107 CAvailableApplicationInfo* FindInfo(const ATL::CStringW& szAppName) const;
108 ATL::CSimpleArray<CAvailableApplicationInfo> FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const;
109
110 const ATL::CStringW& GetFolderPath() const;
111 const ATL::CStringW& GetAppPath() const;
112 const ATL::CStringW& GetCabPath() const;
113 };