#include "rapps.h"
// CAvailableApplicationInfo
-
CAvailableApplicationInfo::CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam)
: m_Parser(sFileNameParam)
{
// Parse parameter string
ATL::CStringW m_szLocale;
+ int iLCID;
for (INT i = 0; szBuffer[i] != UNICODE_NULL; ++i)
{
- if (szBuffer[i] != cDelimiter)
+ if (szBuffer[i] != cDelimiter && szBuffer[i] != L'\n')
{
m_szLocale += szBuffer[i];
}
else
{
- Languages.Add(m_szLocale);
- m_szLocale.Empty();
+ if (StrToIntExW(m_szLocale.GetString(), STIF_DEFAULT, &iLCID))
+ {
+ Languages.Add(static_cast<LCID>(iLCID));
+ m_szLocale.Empty();
+ }
}
}
// For the text after delimiter
if (!m_szLocale.IsEmpty())
{
- Languages.Add(m_szLocale);
+ if (StrToIntExW(m_szLocale.GetString(), STIF_DEFAULT, &iLCID))
+ {
+ Languages.Add(static_cast<LCID>(iLCID));
+ }
}
m_HasLanguageInfo = TRUE;
}
}
-BOOL CAvailableApplicationInfo::HasLanguageInfo() const
-{
- return m_HasLanguageInfo;
-}
-
-BOOL CAvailableApplicationInfo::HasNativeLanguage() const
+BOOL CAvailableApplicationInfo::FindInLanguages(LCID what) const
{
if (!m_HasLanguageInfo)
{
const INT nLanguagesSize = Languages.GetSize();
for (INT i = 0; i < nLanguagesSize; ++i)
{
- if (Languages[i] == CConfigParser::GetLocale())
+ if (Languages[i] == what)
{
return TRUE;
}
return FALSE;
}
-BOOL CAvailableApplicationInfo::HasEnglishLanguage() const
+BOOL CAvailableApplicationInfo::HasLanguageInfo() const
{
- static ATL::CStringW szEnglishLocaleID;
- const INT cchLocaleSize = m_Parser.GetLocaleSize();
- if (!m_HasLanguageInfo)
- {
- return FALSE;
- }
-
- //Get English locale code
- if (szEnglishLocaleID.IsEmpty())
- {
- INT result = GetLocaleInfoW(MAKELCID(LANG_ENGLISH, SORT_DEFAULT), LOCALE_ILANGUAGE,
- szEnglishLocaleID.GetBuffer(cchLocaleSize), cchLocaleSize);
- szEnglishLocaleID.ReleaseBuffer();
- if (result != ERROR_SUCCESS)
- {
- return FALSE;
- }
-
- }
+ return m_HasLanguageInfo;
+}
- //Find locale code in the list
- const INT nLanguagesSize = Languages.GetSize();
- for (INT i = 0; i < nLanguagesSize; ++i)
- {
- if (Languages[i] == szEnglishLocaleID)
- {
- return TRUE;
- }
- }
+BOOL CAvailableApplicationInfo::HasNativeLanguage() const
+{
+ return FindInLanguages(GetUserDefaultLCID());
+}
- return FALSE;
+BOOL CAvailableApplicationInfo::HasEnglishLanguage() const
+{
+ return FindInLanguages(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT));
}
BOOL CAvailableApplicationInfo::IsInstalled() const
if (!DeleteCurrentAppsDB())
return FALSE;
- DownloadApplicationsDB(APPLICATION_DATABASE_URL);
+ Ă‘DownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL);
if (m_szPath.IsEmpty())
return FALSE;
if (hFind == INVALID_HANDLE_VALUE)
{
if (GetFileAttributesW(m_szCabPath) == INVALID_FILE_ATTRIBUTES)
- DownloadApplicationsDB(APPLICATION_DATABASE_URL);
+ Ă‘DownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL);
ExtractFilesFromCab(m_szCabPath, m_szAppsPath);
hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
m_InfoList.RemoveAt(LastListPosition);
delete Info;
- Info = nullptr;
+ Info = NULL;
break;
}
else
// CAvailableApps
// CConfigParser
-ATL::CStringW CConfigParser::m_szLocale;
+ATL::CStringW CConfigParser::m_szLocaleID;
ATL::CStringW CConfigParser::m_szCachedINISectionLocale;
ATL::CStringW CConfigParser::m_szCachedINISectionLocaleNeutral;
ATL::CStringW CConfigParser::GetINIFullPath(const ATL::CStringW& FileName)
{
ATL::CStringW szDir;
- static ATL::CStringW szBuffer;
+ ATL::CStringW szBuffer;
GetStorageDirectory(szDir);
szBuffer.Format(L"%ls\\rapps\\%ls", szDir, FileName);
VOID CConfigParser::CacheINILocaleLazy()
{
- if (m_szLocale.IsEmpty())
+ if (m_szLocaleID.IsEmpty())
{
// TODO: Set default locale if call fails
// find out what is the current system lang code (e.g. "0a") and append it to SectionLocale
- GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE,
- m_szLocale.GetBuffer(m_cchLocaleSize), m_cchLocaleSize);
- m_szLocale.ReleaseBuffer();
- m_szCachedINISectionLocale = L"Section." + m_szLocale;
+ GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE,
+ m_szLocaleID.GetBuffer(m_cchLocaleSize), m_cchLocaleSize);
+
+ m_szLocaleID.ReleaseBuffer();
+ m_szCachedINISectionLocale = L"Section." + m_szLocaleID;
// turn "Section.0c0a" into "Section.0a", keeping just the neutral lang part
- m_szCachedINISectionLocaleNeutral = m_szCachedINISectionLocale + m_szLocale.Right(2);
+ m_szCachedINISectionLocaleNeutral = m_szCachedINISectionLocale + m_szLocaleID.Right(2);
}
}
const ATL::CStringW& CConfigParser::GetLocale()
{
CacheINILocaleLazy();
- return m_szLocale;
+ return m_szLocaleID;
}
INT CConfigParser::GetLocaleSize()
UINT CConfigParser::GetInt(const ATL::CStringW& KeyName)
{
ATL::CStringW Buffer;
- UNICODE_STRING BufferW;
- ULONG Result;
// grab the text version of our entry
if (!GetString(KeyName, Buffer))
return FALSE;
// convert it to an actual integer
- RtlInitUnicodeString(&BufferW, Buffer.GetString());
- RtlUnicodeStringToInteger(&BufferW, 0, &Result);
+ int result = StrToIntW(Buffer.GetString());
- return (UINT) Result;
+ return (UINT) (result <= 0) ? 0 : result;
}
-// CConfigParser
+// CConfigParser
\ No newline at end of file