ReactOS 0.4.15-dev-7674-gc0b4db1
CAvailableApplicationInfo Class Reference

#include <appinfo.h>

Inheritance diagram for CAvailableApplicationInfo:
Collaboration diagram for CAvailableApplicationInfo:

Public Member Functions

 CAvailableApplicationInfo (CConfigParser *Parser, const CStringW &PkgName, AppsCategories Category, const CPathW &BasePath)
 
 ~CAvailableApplicationInfo ()
 
virtual BOOL Valid () const override
 
virtual BOOL CanModify () override
 
virtual BOOL RetrieveIcon (CStringW &Path) const override
 
virtual BOOL RetrieveScreenshot (CStringW &Path) override
 
virtual VOID ShowAppInfo (CAppRichEdit *RichEdit) override
 
virtual VOID GetDownloadInfo (CStringW &Url, CStringW &Sha1, ULONG &SizeInBytes) const override
 
virtual VOID GetDisplayInfo (CStringW &License, CStringW &Size, CStringW &UrlSite, CStringW &UrlDownload) override
 
virtual BOOL UninstallApplication (BOOL bModify) override
 
- Public Member Functions inherited from CAppInfo
 CAppInfo (const CStringW &Identifier, AppsCategories Category)
 
virtual ~CAppInfo ()
 
virtual BOOL Valid () const =0
 
virtual BOOL CanModify ()=0
 
virtual BOOL RetrieveIcon (CStringW &Path) const =0
 
virtual BOOL RetrieveScreenshot (CStringW &Path)=0
 
virtual VOID ShowAppInfo (CAppRichEdit *RichEdit)=0
 
virtual VOID GetDownloadInfo (CStringW &Url, CStringW &Sha1, ULONG &SizeInBytes) const =0
 
virtual VOID GetDisplayInfo (CStringW &License, CStringW &Size, CStringW &UrlSite, CStringW &UrlDownload)=0
 
virtual BOOL UninstallApplication (BOOL bModify)=0
 

Private Member Functions

VOID InsertVersionInfo (CAppRichEdit *RichEdit)
 
VOID InsertLanguageInfo (CAppRichEdit *RichEdit)
 
VOID RetrieveLanguages ()
 
CStringW LicenseString ()
 

Private Attributes

class CConfigParserm_Parser
 
CSimpleArray< CStringWm_szScrnshotLocation
 
bool m_ScrnshotRetrieved
 
CStringW m_szUrlDownload
 
CStringW m_szSize
 
CStringW m_szUrlSite
 
CSimpleArray< LCIDm_LanguageLCIDs
 
bool m_LanguagesLoaded
 

Additional Inherited Members

- Public Attributes inherited from CAppInfo
const CStringW szIdentifier
 
const AppsCategories iCategory
 
CStringW szDisplayIcon
 
CStringW szDisplayName
 
CStringW szDisplayVersion
 
CStringW szComments
 

Detailed Description

Definition at line 100 of file appinfo.h.

Constructor & Destructor Documentation

◆ CAvailableApplicationInfo()

CAvailableApplicationInfo::CAvailableApplicationInfo ( CConfigParser Parser,
const CStringW PkgName,
AppsCategories  Category,
const CPathW BasePath 
)

Definition at line 22 of file appinfo.cpp.

27 : CAppInfo(PkgName, Category), m_Parser(Parser), m_ScrnshotRetrieved(false), m_LanguagesLoaded(false)
28{
31 m_Parser->GetString(L"URLDownload", m_szUrlDownload);
32 m_Parser->GetString(L"Description", szComments);
33
34 CPathW IconPath = BasePath;
35 IconPath += L"icons";
36
38 if (m_Parser->GetString(L"Icon", IconName))
39 {
41 }
42 else
43 {
44 // inifile.ico
45 IconPath += (szIdentifier + L".ico");
46 }
47
49 {
51 }
52
53 INT iSizeBytes;
54
55 if (m_Parser->GetInt(L"SizeBytes", iSizeBytes))
56 {
59 }
60
61 m_Parser->GetString(L"URLSite", m_szUrlSite);
62}
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:382
CStringW szComments
Definition: appinfo.h:80
CStringW szDisplayIcon
Definition: appinfo.h:77
CStringW szDisplayName
Definition: appinfo.h:78
CStringW szDisplayVersion
Definition: appinfo.h:79
const CStringW szIdentifier
Definition: appinfo.h:74
class CConfigParser * m_Parser
Definition: appinfo.h:102
BOOL GetString(const CStringW &KeyName, CStringW &ResultString)
BOOL GetInt(const CStringW &KeyName, INT &iResult)
LPCTSTR IconName
Definition: desktop.c:53
#define MAX_PATH
Definition: compat.h:34
static const WCHAR IconPath[]
Definition: install.c:51
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1777
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2380
#define L(x)
Definition: ntvdm.h:50
int32_t INT
Definition: typedefs.h:58
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ ~CAvailableApplicationInfo()

CAvailableApplicationInfo::~CAvailableApplicationInfo ( )

Definition at line 64 of file appinfo.cpp.

65{
66 delete m_Parser;
67}

Member Function Documentation

◆ CanModify()

BOOL CAvailableApplicationInfo::CanModify ( )
overridevirtual

Implements CAppInfo.

Definition at line 294 of file appinfo.cpp.

295{
296 return FALSE;
297}
#define FALSE
Definition: types.h:117

◆ GetDisplayInfo()

VOID CAvailableApplicationInfo::GetDisplayInfo ( CStringW License,
CStringW Size,
CStringW UrlSite,
CStringW UrlDownload 
)
overridevirtual

Implements CAppInfo.

Definition at line 359 of file appinfo.cpp.

360{
361 License = LicenseString();
362 Size = m_szSize;
363 UrlSite = m_szUrlSite;
364 UrlDownload = m_szUrlDownload;
365}
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ GetDownloadInfo()

VOID CAvailableApplicationInfo::GetDownloadInfo ( CStringW Url,
CStringW Sha1,
ULONG SizeInBytes 
) const
overridevirtual

Implements CAppInfo.

Definition at line 342 of file appinfo.cpp.

343{
344 Url = m_szUrlDownload;
345 m_Parser->GetString(L"SHA1", Sha1);
346 INT iSizeBytes;
347
348 if (m_Parser->GetInt(L"SizeBytes", iSizeBytes))
349 {
350 SizeInBytes = (ULONG)iSizeBytes;
351 }
352 else
353 {
354 SizeInBytes = 0;
355 }
356}
uint32_t ULONG
Definition: typedefs.h:59

◆ InsertLanguageInfo()

VOID CAvailableApplicationInfo::InsertLanguageInfo ( CAppRichEdit RichEdit)
private

Definition at line 198 of file appinfo.cpp.

199{
201 {
203 }
204
205 if (m_LanguageLCIDs.GetSize() == 0)
206 {
207 return;
208 }
209
210 const INT nTranslations = m_LanguageLCIDs.GetSize();
211 CStringW szLangInfo;
212 CStringW szLoadedTextAvailability;
213 CStringW szLoadedAInfoText;
214
215 szLoadedAInfoText.LoadStringW(IDS_AINFO_LANGUAGES);
216
219 {
220 szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_AVAILABLE_TRANSLATION);
221 if (nTranslations > 1)
222 {
225 szLangInfo.Format(buf, nTranslations - 1);
226 }
227 else
228 {
229 szLangInfo.LoadStringW(IDS_LANGUAGE_SINGLE);
230 szLangInfo = L" (" + szLangInfo + L")";
231 }
232 }
233 else if (m_LanguageLCIDs.Find(lcEnglish) >= 0)
234 {
235 szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_ENGLISH_TRANSLATION);
236 if (nTranslations > 1)
237 {
240 szLangInfo.Format(buf, nTranslations - 1);
241 }
242 else
243 {
244 szLangInfo.LoadStringW(IDS_LANGUAGE_SINGLE);
245 szLangInfo = L" (" + szLangInfo + L")";
246 }
247 }
248 else
249 {
250 szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_NO_TRANSLATION);
251 }
252
253 RichEdit->InsertText(szLoadedAInfoText, CFE_BOLD);
254 RichEdit->InsertText(szLoadedTextAvailability, NULL);
255 RichEdit->InsertText(szLangInfo, CFE_ITALIC);
256}
#define IDS_LANGUAGE_MORE_PLACEHOLDER
Definition: resource.h:213
#define IDS_LANGUAGE_SINGLE
Definition: resource.h:212
#define IDS_LANGUAGE_NO_TRANSLATION
Definition: resource.h:210
#define IDS_AINFO_LANGUAGES
Definition: resource.h:168
#define IDS_LANGUAGE_AVAILABLE_PLACEHOLDER
Definition: resource.h:214
#define IDS_LANGUAGE_AVAILABLE_TRANSLATION
Definition: resource.h:209
#define IDS_LANGUAGE_ENGLISH_TRANSLATION
Definition: resource.h:211
int GetSize() const
Definition: atlsimpcoll.h:104
int Find(const T &t) const
Definition: atlsimpcoll.h:82
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
CSimpleArray< LCID > m_LanguageLCIDs
Definition: appinfo.h:108
VOID InsertText(LPCWSTR lpszText, DWORD dwEffects)
Definition: crichedit.h:77
#define NULL
Definition: types.h:112
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:778
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
#define CFE_BOLD
Definition: richedit.h:406
#define CFE_ITALIC
Definition: richedit.h:407
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD LCID
Definition: nls.h:13

Referenced by ShowAppInfo().

◆ InsertVersionInfo()

VOID CAvailableApplicationInfo::InsertVersionInfo ( CAppRichEdit RichEdit)
private

Definition at line 116 of file appinfo.cpp.

117{
118 CStringW szRegName;
119 m_Parser->GetString(L"RegName", szRegName);
120
122 if (bIsInstalled)
123 {
124 CStringW szInstalledVersion;
125 CStringW szNameVersion = szDisplayName + L" " + szDisplayVersion;
126 BOOL bHasInstalledVersion = ::GetInstalledVersion(&szInstalledVersion, szRegName) ||
127 ::GetInstalledVersion(&szInstalledVersion, szDisplayName) ||
128 ::GetInstalledVersion(&szInstalledVersion, szNameVersion);
129
130 if (bHasInstalledVersion)
131 {
132 BOOL bHasUpdate = CompareVersion(szInstalledVersion, szDisplayVersion) < 0;
133 if (bHasUpdate)
135 else
137
138 RichEdit->LoadAndInsertText(IDS_AINFO_VERSION, szInstalledVersion, 0);
139 }
140 else
141 {
143 }
144 }
145 else
146 {
148 }
149
151}
int CompareVersion(const CStringW &left, const CStringW &right)
Definition: appinfo.cpp:85
BOOL GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName)
Definition: misc.cpp:280
#define IDS_AINFO_AVAILABLEVERSION
Definition: resource.h:167
#define IDS_STATUS_NOTINSTALLED
Definition: resource.h:195
#define IDS_AINFO_VERSION
Definition: resource.h:161
#define IDS_STATUS_UPDATE_AVAILABLE
Definition: resource.h:197
#define IDS_STATUS_INSTALLED
Definition: resource.h:194
VOID LoadAndInsertText(UINT uStringID, const CStringW &szText, DWORD TextFlags)
Definition: appview.cpp:236
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by ShowAppInfo().

◆ LicenseString()

CStringW CAvailableApplicationInfo::LicenseString ( )
private

Definition at line 154 of file appinfo.cpp.

155{
156 INT IntBuffer;
157 m_Parser->GetInt(L"LicenseType", IntBuffer);
158 CStringW szLicenseString;
159 m_Parser->GetString(L"License", szLicenseString);
160 LicenseType licenseType;
161
162 if (IsKnownLicenseType(IntBuffer))
163 {
164 licenseType = static_cast<LicenseType>(IntBuffer);
165 }
166 else
167 {
168 licenseType = LICENSE_NONE;
169 if (szLicenseString.CompareNoCase(L"Freeware") == 0)
170 {
171 licenseType = LICENSE_FREEWARE;
172 szLicenseString = L"";
173 }
174 }
175
176 CStringW szLicense;
177 switch (licenseType)
178 {
180 szLicense.LoadStringW(IDS_LICENSE_OPENSOURCE);
181 break;
182 case LICENSE_FREEWARE:
183 szLicense.LoadStringW(IDS_LICENSE_FREEWARE);
184 break;
185 case LICENSE_TRIAL:
186 szLicense.LoadStringW(IDS_LICENSE_TRIAL);
187 break;
188 default:
189 return szLicenseString;
190 }
191
192 if (!szLicenseString.IsEmpty())
193 szLicense += L" (" + szLicenseString + L")";
194 return szLicense;
195}
LicenseType
Definition: appinfo.h:9
@ LICENSE_NONE
Definition: appinfo.h:10
@ LICENSE_OPENSOURCE
Definition: appinfo.h:11
@ LICENSE_TRIAL
Definition: appinfo.h:13
@ LICENSE_FREEWARE
Definition: appinfo.h:12
BOOL IsKnownLicenseType(INT x)
Definition: appinfo.h:19
#define IDS_LICENSE_TRIAL
Definition: resource.h:206
#define IDS_LICENSE_FREEWARE
Definition: resource.h:205
#define IDS_LICENSE_OPENSOURCE
Definition: resource.h:204
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:389
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743

Referenced by GetDisplayInfo(), and ShowAppInfo().

◆ RetrieveIcon()

BOOL CAvailableApplicationInfo::RetrieveIcon ( CStringW Path) const
overridevirtual

Implements CAppInfo.

Definition at line 300 of file appinfo.cpp.

301{
303 return !Path.IsEmpty();
304}
PRTL_UNICODE_STRING_BUFFER Path

◆ RetrieveLanguages()

VOID CAvailableApplicationInfo::RetrieveLanguages ( )
private

Definition at line 259 of file appinfo.cpp.

260{
261 m_LanguagesLoaded = true;
262
263 CStringW szBuffer;
264 if (!m_Parser->GetString(L"Languages", szBuffer))
265 {
266 return;
267 }
268
269 // Parse parameter string
270 int iIndex = 0;
271 while (true)
272 {
273 CStringW szLocale = szBuffer.Tokenize(L"|", iIndex);
274 if (szLocale.IsEmpty())
275 break;
276
277 szLocale = L"0x" + szLocale;
278
279 INT iLCID;
280 if (StrToIntExW(szLocale, STIF_SUPPORT_HEX, &iLCID))
281 {
282 m_LanguageLCIDs.Add(static_cast<LCID>(iLCID));
283 }
284 }
285}
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
CStringT Tokenize(_In_z_ PCXSTR pszTokens, _Inout_ int &iStart) const
Definition: cstringt.h:947
BOOL WINAPI StrToIntExW(LPCWSTR lpszStr, DWORD dwFlags, LPINT lpiRet)
Definition: string.c:970
#define STIF_SUPPORT_HEX
Definition: shlwapi.h:1452

Referenced by InsertLanguageInfo().

◆ RetrieveScreenshot()

BOOL CAvailableApplicationInfo::RetrieveScreenshot ( CStringW Path)
overridevirtual

Implements CAppInfo.

Definition at line 308 of file appinfo.cpp.

309{
311 {
312 static_assert(MAX_SCRNSHOT_NUM < 10000, "MAX_SCRNSHOT_NUM is too big");
313 for (int i = 0; i < MAX_SCRNSHOT_NUM; i++)
314 {
315 CStringW ScrnshotField;
316 ScrnshotField.Format(L"Screenshot%d", i + 1);
317 CStringW ScrnshotLocation;
318 if (!m_Parser->GetString(ScrnshotField, ScrnshotLocation))
319 {
320 // We stop at the first screenshot not found,
321 // so screenshots _have_ to be consecutive
322 break;
323 }
324
325 if (PathIsURLW(ScrnshotLocation.GetString()))
326 {
327 m_szScrnshotLocation.Add(ScrnshotLocation);
328 }
329 }
330 m_ScrnshotRetrieved = true;
331 }
332
333 if (m_szScrnshotLocation.GetSize() > 0)
334 {
336 }
337
338 return !Path.IsEmpty();
339}
#define MAX_SCRNSHOT_NUM
Definition: appinfo.cpp:306
PXSTR GetString() noexcept
Definition: atlsimpstr.h:367
CSimpleArray< CStringW > m_szScrnshotLocation
Definition: appinfo.h:103
BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath)
Definition: url.c:2432
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

◆ ShowAppInfo()

VOID CAvailableApplicationInfo::ShowAppInfo ( CAppRichEdit RichEdit)
overridevirtual

Implements CAppInfo.

Definition at line 70 of file appinfo.cpp.

71{
72 RichEdit->SetText(szDisplayName, CFE_BOLD);
73 InsertVersionInfo(RichEdit);
75 InsertLanguageInfo(RichEdit);
76
82}
#define IDS_AINFO_SIZE
Definition: resource.h:163
#define IDS_AINFO_PACKAGE_NAME
Definition: resource.h:172
#define IDS_AINFO_LICENSE
Definition: resource.h:165
#define IDS_AINFO_DESCRIPTION
Definition: resource.h:162
#define IDS_AINFO_URLSITE
Definition: resource.h:164
#define IDS_AINFO_URLDOWNLOAD
Definition: resource.h:166
VOID InsertLanguageInfo(CAppRichEdit *RichEdit)
Definition: appinfo.cpp:198
VOID InsertVersionInfo(CAppRichEdit *RichEdit)
Definition: appinfo.cpp:116
VOID SetText(LPCWSTR lpszText, DWORD dwEffects)
Definition: crichedit.h:91
#define CFE_LINK
Definition: richedit.h:411

◆ UninstallApplication()

BOOL CAvailableApplicationInfo::UninstallApplication ( BOOL  bModify)
overridevirtual

Implements CAppInfo.

Definition at line 368 of file appinfo.cpp.

369{
370 ATLASSERT(FALSE && "Should not be called");
371 return FALSE;
372}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10

◆ Valid()

BOOL CAvailableApplicationInfo::Valid ( ) const
overridevirtual

Implements CAppInfo.

Definition at line 288 of file appinfo.cpp.

289{
291}

Member Data Documentation

◆ m_LanguageLCIDs

CSimpleArray<LCID> CAvailableApplicationInfo::m_LanguageLCIDs
private

Definition at line 108 of file appinfo.h.

Referenced by InsertLanguageInfo(), and RetrieveLanguages().

◆ m_LanguagesLoaded

bool CAvailableApplicationInfo::m_LanguagesLoaded
private

Definition at line 109 of file appinfo.h.

Referenced by InsertLanguageInfo(), and RetrieveLanguages().

◆ m_Parser

◆ m_ScrnshotRetrieved

bool CAvailableApplicationInfo::m_ScrnshotRetrieved
private

Definition at line 104 of file appinfo.h.

Referenced by RetrieveScreenshot().

◆ m_szScrnshotLocation

CSimpleArray<CStringW> CAvailableApplicationInfo::m_szScrnshotLocation
private

Definition at line 103 of file appinfo.h.

Referenced by RetrieveScreenshot().

◆ m_szSize

CStringW CAvailableApplicationInfo::m_szSize
private

Definition at line 106 of file appinfo.h.

Referenced by CAvailableApplicationInfo(), GetDisplayInfo(), and ShowAppInfo().

◆ m_szUrlDownload

CStringW CAvailableApplicationInfo::m_szUrlDownload
private

◆ m_szUrlSite

CStringW CAvailableApplicationInfo::m_szUrlSite
private

Definition at line 107 of file appinfo.h.

Referenced by CAvailableApplicationInfo(), GetDisplayInfo(), and ShowAppInfo().


The documentation for this class was generated from the following files: