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