https://git.reactos.org/?p=reactos.git;a=commitdiff;h=627739aed9b355e7e51e7…
commit 627739aed9b355e7e51e7adca93867071c70ce17
Author: Alexander Shaposhnikov <sanchaez(a)reactos.org>
AuthorDate: Sat Apr 7 19:17:22 2018 +0300
Commit: Alexander Shaposhnikov <sanchaez(a)reactos.org>
CommitDate: Sat Apr 7 19:25:12 2018 +0300
[RAPPS] Introduce 'SizeBytes' DB entry and use it for display
This will allow us to reduce the DB size a little by avoiding
duplication for each and every entry.
Original patch by JIRA user "swyter"
CORE-10310
---
base/applications/rapps/available.cpp | 24 +++++++++++++++++++++---
base/applications/rapps/include/available.h | 1 +
base/applications/rapps/include/misc.h | 4 ++--
base/applications/rapps/include/resource.h | 3 +++
base/applications/rapps/installed.cpp | 2 +-
base/applications/rapps/misc.cpp | 11 +++++++----
6 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/base/applications/rapps/available.cpp
b/base/applications/rapps/available.cpp
index 5ed7119853..61c5a16e5e 100644
--- a/base/applications/rapps/available.cpp
+++ b/base/applications/rapps/available.cpp
@@ -38,7 +38,7 @@ VOID CAvailableApplicationInfo::RetrieveGeneralInfo()
{
m_Parser = new CConfigParser(m_sFileName);
- m_Category = m_Parser->GetInt(L"Category");
+ m_Parser->GetInt(L"Category", m_Category);
if (!GetString(L"Name", m_szName)
|| !GetString(L"URLDownload", m_szUrlDownload))
@@ -51,15 +51,16 @@ VOID CAvailableApplicationInfo::RetrieveGeneralInfo()
GetString(L"Version", m_szVersion);
GetString(L"License", m_szLicense);
GetString(L"Description", m_szDesc);
- GetString(L"Size", m_szSize);
GetString(L"URLSite", m_szUrlSite);
GetString(L"CDPath", m_szCDPath);
GetString(L"Language", m_szRegName);
GetString(L"SHA1", m_szSHA1);
+ RetrieveSize();
RetrieveLicenseType();
RetrieveLanguages();
RetrieveInstalledStatus();
+
if (m_IsInstalled)
{
RetrieveInstalledVersion();
@@ -128,7 +129,9 @@ VOID CAvailableApplicationInfo::RetrieveLanguages()
VOID CAvailableApplicationInfo::RetrieveLicenseType()
{
- INT IntBuffer = m_Parser->GetInt(L"LicenseType");
+ INT IntBuffer;
+
+ m_Parser->GetInt(L"LicenseType", IntBuffer);
if (IsLicenseType(IntBuffer))
{
@@ -140,6 +143,21 @@ VOID CAvailableApplicationInfo::RetrieveLicenseType()
}
}
+VOID CAvailableApplicationInfo::RetrieveSize()
+{
+ INT iSizeBytes;
+
+ if (!m_Parser->GetInt(L"SizeBytes", iSizeBytes))
+ {
+ // fall back to "Size" string
+ GetString(L"Size", m_szSize);
+ return;
+ }
+
+ StrFormatByteSizeW(iSizeBytes, m_szSize.GetBuffer(MAX_PATH), MAX_PATH);
+ m_szSize.ReleaseBuffer();
+}
+
BOOL CAvailableApplicationInfo::FindInLanguages(LCID what) const
{
if (!m_HasLanguageInfo)
diff --git a/base/applications/rapps/include/available.h
b/base/applications/rapps/include/available.h
index 876465fd09..c0b0f2017f 100644
--- a/base/applications/rapps/include/available.h
+++ b/base/applications/rapps/include/available.h
@@ -75,6 +75,7 @@ private:
VOID RetrieveInstalledVersion();
VOID RetrieveLanguages();
VOID RetrieveLicenseType();
+ VOID RetrieveSize();
inline BOOL FindInLanguages(LCID what) const;
};
diff --git a/base/applications/rapps/include/misc.h
b/base/applications/rapps/include/misc.h
index 738f6746cb..143d9769b7 100644
--- a/base/applications/rapps/include/misc.h
+++ b/base/applications/rapps/include/misc.h
@@ -41,6 +41,6 @@ class CConfigParser
public:
CConfigParser(const ATL::CStringW& FileName = "");
- UINT GetString(const ATL::CStringW& KeyName, ATL::CStringW& ResultString);
- UINT GetInt(const ATL::CStringW& KeyName);
+ BOOL GetString(const ATL::CStringW& KeyName, ATL::CStringW& ResultString);
+ BOOL GetInt(const ATL::CStringW& KeyName, INT& iResult);
};
diff --git a/base/applications/rapps/include/resource.h
b/base/applications/rapps/include/resource.h
index 9f4c4b15de..7d5a9b9ebf 100644
--- a/base/applications/rapps/include/resource.h
+++ b/base/applications/rapps/include/resource.h
@@ -154,6 +154,9 @@
#define IDS_AINFO_URLDOWNLOAD 355
#define IDS_AINFO_AVAILABLEVERSION 356
#define IDS_AINFO_LANGUAGES 357
+#define IDS_AINFO_KILOBYTE_EXT 358
+#define IDS_AINFO_MEGABYTE_EXT 359
+#define IDS_AINFO_GIGABYTE_EXT 360
/* Names of categories */
diff --git a/base/applications/rapps/installed.cpp
b/base/applications/rapps/installed.cpp
index e1325770da..c8418dca93 100644
--- a/base/applications/rapps/installed.cpp
+++ b/base/applications/rapps/installed.cpp
@@ -129,7 +129,7 @@ BOOL ShowInstalledAppInfo(INT Index)
GET_INFO(L"UninstallString", IDS_INFO_UNINSTALLSTR, CFE_BOLD, 0);
GET_INFO(L"InstallSource", IDS_INFO_INSTALLSRC, CFE_BOLD, 0);
GET_INFO(L"ModifyPath", IDS_INFO_MODIFYPATH, CFE_BOLD, 0);
-
+
return TRUE;
}
diff --git a/base/applications/rapps/misc.cpp b/base/applications/rapps/misc.cpp
index db0ae0bf1b..cc1dc6541f 100644
--- a/base/applications/rapps/misc.cpp
+++ b/base/applications/rapps/misc.cpp
@@ -354,7 +354,7 @@ VOID CConfigParser::CacheINILocale()
m_szCachedINISectionLocaleNeutral = m_szCachedINISectionLocale +
m_szLocaleID.Right(2);
}
-UINT CConfigParser::GetString(const ATL::CStringW& KeyName, ATL::CStringW&
ResultString)
+BOOL CConfigParser::GetString(const ATL::CStringW& KeyName, ATL::CStringW&
ResultString)
{
DWORD dwResult;
@@ -392,10 +392,12 @@ UINT CConfigParser::GetString(const ATL::CStringW& KeyName,
ATL::CStringW& Resul
return (dwResult != 0 ? TRUE : FALSE);
}
-UINT CConfigParser::GetInt(const ATL::CStringW& KeyName)
+BOOL CConfigParser::GetInt(const ATL::CStringW& KeyName, INT& iResult)
{
ATL::CStringW Buffer;
+ iResult = 0;
+
// grab the text version of our entry
if (!GetString(KeyName, Buffer))
return FALSE;
@@ -404,8 +406,9 @@ UINT CConfigParser::GetInt(const ATL::CStringW& KeyName)
return FALSE;
// convert it to an actual integer
- INT result = StrToIntW(Buffer.GetString());
+ iResult = StrToIntW(Buffer.GetString());
- return (UINT) (result <= 0) ? 0 : result;
+ // we only care about values > 0
+ return (iResult > 0);
}
// CConfigParser