[RAPPS] Make selection global
[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 inline BOOL FindInLanguages(LCID what) const;
79 };
80
81 typedef BOOL(CALLBACK *AVAILENUMPROC)(CAvailableApplicationInfo *Info, LPCWSTR szFolderPath);
82
83 struct AvailableStrings
84 {
85 ATL::CStringW szPath;
86 ATL::CStringW szCabPath;
87 ATL::CStringW szAppsPath;
88 ATL::CStringW szSearchPath;
89
90 AvailableStrings();
91 };
92
93 class CAvailableApps
94 {
95 static AvailableStrings m_Strings;
96 ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
97
98 public:
99 CAvailableApps();
100
101 static BOOL UpdateAppsDB();
102 static BOOL ForceUpdateAppsDB();
103 static VOID DeleteCurrentAppsDB();
104
105 VOID FreeCachedEntries();
106 BOOL Enum(INT EnumType, AVAILENUMPROC lpEnumProc);
107
108 CAvailableApplicationInfo* FindInfo(const ATL::CStringW& szAppName) const;
109 ATL::CSimpleArray<CAvailableApplicationInfo> FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const;
110 ATL::CSimpleArray<CAvailableApplicationInfo> GetSelected() const;
111
112 const ATL::CStringW& GetFolderPath() const;
113 const ATL::CStringW& GetAppPath() const;
114 const ATL::CStringW& GetCabPath() const;
115 };