93705497ac20f942e3bb16fc6869c3ed7c57b3e6
[reactos.git] / reactos / base / applications / rapps / rapps.h
1 #pragma once
2
3 #ifndef _RAPPS_H
4 #define _RAPPS_H
5
6 #include <tchar.h>
7 #include <stdarg.h>
8
9 #define WIN32_NO_STATUS
10 #define _INC_WINDOWS
11 #define COM_NO_WINDOWS_H
12 #define COBJMACROS
13
14 #include <windef.h>
15 #include <winbase.h>
16 #include <winreg.h>
17 #include <wingdi.h>
18 #include <winnls.h>
19 #include <winuser.h>
20 #include <wincon.h>
21 #include <richedit.h>
22 #include <shellapi.h>
23 #include <shlobj.h>
24 #include <shlwapi.h>
25 #include <stdio.h>
26 #include <strsafe.h>
27 #include <ndk/rtlfuncs.h>
28 #include <atlcoll.h>
29 #include <atlsimpcoll.h>
30 #include <atlstr.h>
31 #include <rappsmsg.h>
32
33 #include "resource.h"
34
35 #ifdef USE_CERT_PINNING
36 #define CERT_ISSUER_INFO "BE\r\nGlobalSign nv-sa\r\nGlobalSign Domain Validation CA - SHA256 - G2"
37 #define CERT_SUBJECT_INFO "Domain Control Validated\r\n*.reactos.org"
38 #endif
39
40 #define APPLICATION_DATABASE_URL L"https://svn.reactos.org/packages/rappmgr.cab"
41
42 #define SPLIT_WIDTH 4
43 #define MAX_STR_LEN 256
44 #define LISTVIEW_ICON_SIZE 24
45 #define TREEVIEW_ICON_SIZE 24
46
47 /* EnumType flags for EnumInstalledApplications */
48 #define ENUM_ALL_COMPONENTS 30
49 #define ENUM_APPLICATIONS 31
50 #define ENUM_UPDATES 32
51 /* EnumType flags for EnumAvailableApplications */
52 #define ENUM_ALL_AVAILABLE 0
53 #define ENUM_CAT_AUDIO 1
54 #define ENUM_CAT_VIDEO 2
55 #define ENUM_CAT_GRAPHICS 3
56 #define ENUM_CAT_GAMES 4
57 #define ENUM_CAT_INTERNET 5
58 #define ENUM_CAT_OFFICE 6
59 #define ENUM_CAT_DEVEL 7
60 #define ENUM_CAT_EDU 8
61 #define ENUM_CAT_ENGINEER 9
62 #define ENUM_CAT_FINANCE 10
63 #define ENUM_CAT_SCIENCE 11
64 #define ENUM_CAT_TOOLS 12
65 #define ENUM_CAT_DRIVERS 13
66 #define ENUM_CAT_LIBS 14
67 #define ENUM_CAT_OTHER 15
68
69 #define ENUM_INSTALLED_MIN ENUM_ALL_COMPONENTS
70 #define ENUM_INSTALLED_MAX ENUM_UPDATES
71 #define ENUM_AVAILABLE_MIN ENUM_ALL_AVAILABLE
72 #define ENUM_AVAILABLE_MAX ENUM_CAT_OTHER
73
74 #define IS_INSTALLED_ENUM(a) (a >= ENUM_INSTALLED_MIN && a <= ENUM_INSTALLED_MAX)
75 #define IS_AVAILABLE_ENUM(a) (a >= ENUM_AVAILABLE_MIN && a <= ENUM_AVAILABLE_MAX)
76
77 typedef enum
78 {
79 None,
80 OpenSource,
81 Freeware,
82 Trial,
83 Max = Trial,
84 Min = None
85 } LICENSE_TYPE, *PLICENSE_TYPE;
86
87 /* aboutdlg.cpp */
88 VOID ShowAboutDialog(VOID);
89
90 /* available.cpp */
91 typedef struct
92 {
93 INT Category;
94 LICENSE_TYPE LicenseType;
95 ATL::CStringW szName;
96 ATL::CStringW szRegName;
97 ATL::CStringW szVersion;
98 ATL::CStringW szLicense;
99 ATL::CStringW szDesc;
100 ATL::CStringW szSize;
101 ATL::CStringW szUrlSite;
102 ATL::CStringW szUrlDownload;
103 ATL::CStringW szCDPath;
104 ATL::CSimpleArray<ATL::CStringW> Languages;
105
106 /* caching mechanism related entries */
107 ATL::CStringW sFileName;
108 FILETIME ftCacheStamp;
109
110 /* optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form) */
111 ATL::CStringW szSHA1;
112
113 } APPLICATION_INFO, *PAPPLICATION_INFO;
114
115 extern ATL::CAtlList<PAPPLICATION_INFO> InfoList;
116
117 typedef struct
118 {
119 HKEY hRootKey;
120 HKEY hSubKey;
121 ATL::CStringW szKeyName;
122
123 } INSTALLED_INFO, *PINSTALLED_INFO;
124
125 typedef struct
126 {
127 BOOL bSaveWndPos;
128 BOOL bUpdateAtStart;
129 BOOL bLogEnabled;
130 WCHAR szDownloadDir[MAX_PATH];
131 BOOL bDelInstaller;
132 /* Window Pos */
133 BOOL Maximized;
134 INT Left;
135 INT Top;
136 INT Width;
137 INT Height;
138 /* Proxy settings */
139 INT Proxy;
140 WCHAR szProxyServer[MAX_PATH];
141 WCHAR szNoProxyFor[MAX_PATH];
142
143 } SETTINGS_INFO, *PSETTINGS_INFO;
144
145 /* available.cpp */
146 class CConfigParser
147 {
148 // Loacale names cache
149 static ATL::CStringW m_szLocale;
150 const static INT m_cchLocaleSize = 5;
151 static ATL::CStringW m_szCachedINISectionLocale;
152 static ATL::CStringW m_szCachedINISectionLocaleNeutral;
153
154 const LPCWSTR STR_VERSION_CURRENT = L"CURRENT";
155 const ATL::CStringW szConfigPath;
156
157 static ATL::CStringW GetINIFullPath(const ATL::CStringW& FileName);
158 static VOID CacheINILocaleLazy();
159
160 public:
161 static const ATL::CStringW& GetLocale();
162 static INT CConfigParser::GetLocaleSize();
163
164 CConfigParser(const ATL::CStringW& FileName);
165
166 UINT GetString(const ATL::CStringW& KeyName, ATL::CStringW& ResultString);
167 UINT GetInt(const ATL::CStringW& KeyName);
168 };
169
170 typedef BOOL (CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info, LPCWSTR szFolderPath);
171 struct CAvailableApplicationInfo : public APPLICATION_INFO
172 {
173 ATL::CStringW szInstalledVersion;
174 CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
175
176 // Load all info from the file
177 VOID RefreshAppInfo();
178 BOOL HasLanguageInfo() const;
179 BOOL HasNativeLanguage() const;
180 BOOL HasEnglishLanguage() const;
181 BOOL IsInstalled() const;
182 BOOL HasInstalledVersion() const;
183 BOOL HasUpdate() const;
184
185 // Set a timestamp
186 VOID SetLastWriteTime(FILETIME* ftTime);
187
188 private:
189 BOOL m_IsInstalled = FALSE;
190 BOOL m_HasLanguageInfo = FALSE;
191 BOOL m_HasInstalledVersion = FALSE;
192 CConfigParser m_Parser;
193
194 inline BOOL GetString(LPCWSTR lpKeyName,
195 ATL::CStringW& ReturnedString);
196
197 // Lazily load general info from the file
198 VOID RetrieveGeneralInfo();
199 VOID RetrieveInstalledStatus();
200 VOID RetrieveInstalledVersion();
201 VOID RetrieveLanguages();
202 VOID RetrieveLicenseType();
203 };
204
205 class CAvailableApps
206 {
207 ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
208 ATL::CStringW m_szPath;
209 ATL::CStringW m_szCabPath;
210 ATL::CStringW m_szAppsPath;
211 ATL::CStringW m_szSearchPath;
212
213 public:
214 CAvailableApps();
215 VOID FreeCachedEntries();
216 BOOL DeleteCurrentAppsDB();
217 BOOL UpdateAppsDB();
218 BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
219 const ATL::CStringW& GetFolderPath();
220 const ATL::CStringW& GetAppPath();
221 const ATL::CStringW& GetCabPath();
222 const LPCWSTR GetFolderPathString();
223 const LPCWSTR GetAppPathString();
224 const LPCWSTR GetCabPathString();
225 };
226
227 /* installdlg.cpp */
228 BOOL InstallApplication(INT Index);
229
230 /* installed.cpp */
231 typedef BOOL (CALLBACK *APPENUMPROC)(INT ItemIndex, ATL::CStringW &lpName, PINSTALLED_INFO Info);
232 BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc);
233 BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString);
234 BOOL GetApplicationString(HKEY hKey, LPCWSTR RegName, ATL::CStringW& String);
235
236 BOOL ShowInstalledAppInfo(INT Index);
237 BOOL UninstallApplication(INT Index, BOOL bModify);
238 VOID RemoveAppFromRegistry(INT Index);
239
240 BOOL GetInstalledVersion(ATL::CStringW* pszVersion, const ATL::CStringW& szRegName);
241
242 /* winmain.cpp */
243 extern HWND hMainWnd;
244 extern HINSTANCE hInst;
245 extern INT SelectedEnumType;
246 extern SETTINGS_INFO SettingsInfo;
247 VOID SaveSettings(HWND hwnd);
248 VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo);
249
250 /* loaddlg.cpp */
251 BOOL DownloadApplication(INT Index);
252 VOID DownloadApplicationsDB(LPCWSTR lpUrl);
253
254 /* misc.cpp */
255 INT GetSystemColorDepth(VOID);
256 int GetWindowWidth(HWND hwnd);
257 int GetWindowHeight(HWND hwnd);
258 int GetClientWindowWidth(HWND hwnd);
259 int GetClientWindowHeight(HWND hwnd);
260 VOID CopyTextToClipboard(LPCWSTR lpszText);
261 VOID SetWelcomeText(VOID);
262 VOID ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem);
263 BOOL StartProcess(ATL::CStringW & Path, BOOL Wait);
264 BOOL StartProcess(LPWSTR lpPath, BOOL Wait);
265 BOOL GetStorageDirectory(ATL::CStringW &lpDirectory);
266 BOOL ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath);
267 VOID InitLogs(VOID);
268 VOID FreeLogs(VOID);
269 BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg);
270
271 /* settingsdlg.cpp */
272 VOID CreateSettingsDlg(HWND hwnd);
273
274 /* gui.cpp */
275 HWND CreateMainWindow();
276 DWORD_PTR ListViewGetlParam(INT item);
277 INT ListViewAddItem(INT ItemIndex, INT IconIndex, LPWSTR lpName, LPARAM lParam);
278 VOID SetStatusBarText(LPCWSTR szText);
279 VOID NewRichEditText(LPCWSTR szText, DWORD flags);
280 VOID InsertRichEditText(LPCWSTR szText, DWORD flags);
281
282 VOID SetStatusBarText(const ATL::CStringW& szText);
283 INT ListViewAddItem(INT ItemIndex, INT IconIndex, ATL::CStringW & Name, LPARAM lParam);
284 VOID NewRichEditText(const ATL::CStringW& szText, DWORD flags);
285 VOID InsertRichEditText(const ATL::CStringW& szText, DWORD flags);
286 CAvailableApps * GetAvailableApps();
287 extern HWND hListView;
288 extern ATL::CStringW szSearchPattern;
289
290 /* integrity.cpp */
291 BOOL VerifyInteg(LPCWSTR lpSHA1Hash, LPCWSTR lpFileName);
292
293 //extern HWND hTreeView;
294 //BOOL CreateTreeView(HWND hwnd);
295 //HTREEITEM TreeViewAddItem(HTREEITEM hParent, LPWSTR lpText, INT Image, INT SelectedImage, LPARAM lParam);
296
297 #endif /* _RAPPS_H */