[RAPPS]
[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 typedef struct APPLICATION_INFO
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
69 } *PAPPLICATION_INFO;
70
71 typedef BOOL(CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info, LPCWSTR szFolderPath);
72
73 struct CAvailableApplicationInfo : public APPLICATION_INFO
74 {
75 ATL::CStringW szInstalledVersion;
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 class CAvailableApps
108 {
109 ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
110 ATL::CStringW m_szPath;
111 ATL::CStringW m_szCabPath;
112 ATL::CStringW m_szAppsPath;
113 ATL::CStringW m_szSearchPath;
114
115 public:
116 CAvailableApps();
117 VOID FreeCachedEntries();
118 VOID DeleteCurrentAppsDB();
119 BOOL UpdateAppsDB();
120 BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
121 const PAPPLICATION_INFO FindInfo(const ATL::CStringW& szAppName);
122 ATL::CSimpleArray<PAPPLICATION_INFO> FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames);
123 const ATL::CStringW& GetFolderPath();
124 const ATL::CStringW& GetAppPath();
125 const ATL::CStringW& GetCabPath();
126 const LPCWSTR GetFolderPathString();
127 const LPCWSTR GetAppPathString();
128 const LPCWSTR GetCabPathString();
129 };