Author: ashaposhnikov
Date: Thu Jul 13 15:29:53 2017
New Revision: 75328
URL:
http://svn.reactos.org/svn/reactos?rev=75328&view=rev
Log:
[RAPPS] Language loading
- RAPPS now can load language list from a file where locale identifiers are separated by
'|'
`Language=0C09|0813|0422 \\English|Dutch|Ukrainian`
The only limitation is that the parameter is only 260 chars.
So there arises another goal - multiline parameters
- This list is stored in `CSimpleArray<CStringW>` as strings
Maybe it would be wiser to store them as INT array.
- Some refactoring
Modified:
branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
Thu Jul 13 15:29:53 2017
@@ -12,7 +12,8 @@
ATL::CAtlList<PAPPLICATION_INFO> InfoList;
-inline void InsertTextAfterLoaded_RichEdit(UINT uStringID, const ATL::CStringW&
szText, DWORD StringFlags, DWORD TextFlags)
+inline VOID
+InsertTextAfterLoaded_RichEdit(UINT uStringID, const ATL::CStringW& szText, DWORD
StringFlags, DWORD TextFlags)
{
ATL::CStringW szLoadedText;
if (!szText.IsEmpty() && szLoadedText.LoadStringW(hInst, uStringID))
@@ -22,7 +23,8 @@
}
}
-inline void InsertLoadedTextNewl_RichEdit(UINT uStringID, DWORD StringFlags)
+inline VOID
+InsertLoadedTextNewl_RichEdit(UINT uStringID, DWORD StringFlags)
{
ATL::CStringW szLoadedText;
if (szLoadedText.LoadStringW(hInst, uStringID))
@@ -33,7 +35,8 @@
}
}
-inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString, const
ATL::CStringW& cFileName)
+inline BOOL
+GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString, const ATL::CStringW&
cFileName)
{
if (!ParserGetString(lpKeyName, cFileName, ReturnedString))
{
@@ -42,10 +45,11 @@
}
return TRUE;
}
+
//Check both registry keys in 64bit system
//TODO: check system type beforehand to avoid double checks?
-
-inline BOOL GetInstalledVersionEx(PAPPLICATION_INFO Info, ATL::CStringW* szVersion,
REGSAM key)
+inline BOOL
+GetInstalledVersionEx(PAPPLICATION_INFO Info, ATL::CStringW* szVersion, REGSAM key)
{
return (!Info->szRegName.IsEmpty()
&& (GetInstalledVersion_WowUser(szVersion, Info->szRegName, TRUE,
key)
@@ -55,34 +59,80 @@
|| GetInstalledVersion_WowUser(szVersion, Info->szName, FALSE,
key)));
}
-inline BOOL GetInstalledVersion(PAPPLICATION_INFO Info, ATL::CStringW* szVersion)
+inline BOOL
+GetInstalledVersion(PAPPLICATION_INFO Info, ATL::CStringW* szVersion)
{
return GetInstalledVersionEx(Info, szVersion, KEY_WOW64_32KEY)
|| GetInstalledVersionEx(Info, szVersion, KEY_WOW64_64KEY);
}
-inline BOOL IsAppInstalled(PAPPLICATION_INFO Info)
+inline BOOL
+IsAppInstalled(PAPPLICATION_INFO Info)
{
return GetInstalledVersion(Info, NULL);
}
+ATL::CSimpleArray<ATL::CStringW>
+ParserGetAppLanguages(const ATL::CStringW& szFileName)
+{
+ const WCHAR cDelimiter = L'|';
+ ATL::CStringW szBuffer;
+
+ if (!ParserGetString(L"Languages", szFileName, szBuffer))
+ return CSimpleArray<ATL::CStringW>();
+
+ ATL::CStringW szLocale;
+ ATL::CSimpleArray<ATL::CStringW> arrLocalesResult;
+ for (INT i = 0; szBuffer[i] != UNICODE_NULL; ++i)
+ {
+ if (szBuffer[i] != cDelimiter)
+ {
+ szLocale += szBuffer[i];
+ } else {
+ arrLocalesResult.Add(szLocale);
+ szLocale.Empty();
+ }
+ }
+ // For the text after delimiter
+ if (!szLocale.IsEmpty())
+ {
+ arrLocalesResult.Add(szLocale);
+ }
+ return arrLocalesResult;
+}
+
+BOOL
+HasNativeLanguage(PAPPLICATION_INFO Info)
+{
+ if (!Info)
+ {
+ return FALSE;
+ }
+ //TODO: make the actual check
+ return TRUE;
+}
+
+LICENSE_TYPE
+ParserGetLicenseType(const ATL::CStringW& szFileName)
+{
+ INT IntBuffer = ParserGetInt(L"LicenseType", szFileName);
+ if (IntBuffer < 0 || IntBuffer > LICENSE_TYPE::Max)
+ {
+ return LICENSE_TYPE::None;
+ }
+ return (LICENSE_TYPE) IntBuffer;
+}
LIST_ENTRY CachedEntriesHead = {&CachedEntriesHead, &CachedEntriesHead};
PLIST_ENTRY pCachedEntry = &CachedEntriesHead;
-BOOL
-ShowAvailableAppInfo(INT Index)
-{
- PAPPLICATION_INFO Info = (PAPPLICATION_INFO) ListViewGetlParam(Index);
+VOID
+InsertVersionInfo_RichEdit(PAPPLICATION_INFO Info)
+{
ATL::CStringW szVersion;
- ATL::CStringW szLicense;
BOOL bIsInstalled = IsAppInstalled(Info),
bHasVersion = GetInstalledVersion(Info, &szVersion);
- if (!Info) return FALSE;
-
- NewRichEditText(Info->szName, CFE_BOLD);
- //installed status
if (bIsInstalled)
{
if (bHasVersion)
@@ -102,7 +152,12 @@
InsertLoadedTextNewl_RichEdit(IDS_STATUS_NOTINSTALLED, CFE_ITALIC);
InsertTextAfterLoaded_RichEdit(IDS_AINFO_AVAILABLEVERSION, Info->szVersion,
CFE_BOLD, 0);
- //license
+}
+
+VOID
+InsertLicenseInfo_RichEdit(PAPPLICATION_INFO Info)
+{
+ ATL::CStringW szLicense;
switch (Info->LicenseType)
{
case LICENSE_TYPE::OpenSource:
@@ -127,6 +182,18 @@
szLicense.Format(L"(%ls)", Info->szLicense);
InsertTextAfterLoaded_RichEdit(IDS_AINFO_LICENSE, szLicense, CFE_BOLD, 0);
}
+
+}
+
+BOOL
+ShowAvailableAppInfo(INT Index)
+{
+ PAPPLICATION_INFO Info = (PAPPLICATION_INFO) ListViewGetlParam(Index);
+ if (!Info) return FALSE;
+
+ NewRichEditText(Info->szName, CFE_BOLD);
+ InsertVersionInfo_RichEdit(Info);
+ InsertLicenseInfo_RichEdit(Info);
InsertTextAfterLoaded_RichEdit(IDS_AINFO_SIZE, Info->szSize, CFE_BOLD, 0);
InsertTextAfterLoaded_RichEdit(IDS_AINFO_URLSITE, Info->szUrlSite, CFE_BOLD,
CFE_LINK);
@@ -273,11 +340,8 @@
break;
Info->Category = ParserGetInt(L"Category", FindFileData.cFileName);
- INT IntBuffer = ParserGetInt(L"LicenseType", FindFileData.cFileName);
- if (IntBuffer < LICENSE_TYPE::Max)
- {
- Info->LicenseType = (LICENSE_TYPE) IntBuffer;
- }
+ Info->LicenseType = ParserGetLicenseType(FindFileData.cFileName);
+ Info->Languages = ParserGetAppLanguages(FindFileData.cFileName);
/* copy the cache-related fields for the next time */
Info->cFileName = FindFileData.cFileName;
@@ -329,6 +393,7 @@
{
PAPPLICATION_INFO Info;
POSITION InfoListPosition = InfoList.GetHeadPosition();
+
/* loop and deallocate all the cached app infos in the list */
while (InfoListPosition)
{
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h [iso-8859-1] Thu Jul
13 15:29:53 2017
@@ -26,6 +26,7 @@
#include <strsafe.h>
#include <ndk/rtlfuncs.h>
#include <atlcoll.h>
+#include <atlsimpcoll.h>
#include <atlstr.h>
#include <rappsmsg.h>
@@ -100,7 +101,7 @@
ATL::CStringW szUrlSite;
ATL::CStringW szUrlDownload;
ATL::CStringW szCDPath;
- ATL::CStringW szLanguages;
+ ATL::CSimpleArray<ATL::CStringW> Languages;
/* caching mechanism related entries */
ATL::CStringW cFileName;