[RAPPS] Refactoring & bugfixes
authorAlexander Shaposhnikov <sanchaez@reactos.org>
Tue, 18 Jul 2017 22:52:51 +0000 (22:52 +0000)
committerAlexander Shaposhnikov <sanchaez@reactos.org>
Tue, 18 Jul 2017 22:52:51 +0000 (22:52 +0000)
- Made a bunch of classes for Available apps;
- Removed unnessesary GetBuffer calls;
- Set a bit higher minimum height for RichEdit;
- Added "Single" indicator for the Languages to show that the translation available is the only one;
- Small style changes.

svn path=/branches/GSoC_2017/rapps/; revision=75373

reactos/base/applications/rapps/available.cpp
reactos/base/applications/rapps/crichedit.h
reactos/base/applications/rapps/gui.cpp
reactos/base/applications/rapps/installed.cpp
reactos/base/applications/rapps/lang/en-US.rc
reactos/base/applications/rapps/loaddlg.cpp
reactos/base/applications/rapps/misc.cpp
reactos/base/applications/rapps/rapps.h
reactos/base/applications/rapps/resource.h
reactos/base/applications/rapps/winmain.cpp

index f6e12b8..ee75087 100644 (file)
@@ -2,7 +2,7 @@
  * PROJECT:         ReactOS Applications Manager
  * LICENSE:         GPL - See COPYING in the top level directory
  * FILE:            base/applications/rapps/available.cpp
- * PURPOSE:         Functions for working with available applications
+ * PURPOSE:         Classes for working with available applications
  * PROGRAMMERS:     Dmitry Chapyshev           (dmitry@reactos.org)
  *                  Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com)
  *                  Alexander Shaposhnikov     (chaez.san@gmail.com)
 
 #include "rapps.h"
 
-ATL::CAtlList<PAPPLICATION_INFO> InfoList;
+ // CAvailableApplicationInfo
 
-inline VOID 
-InsertTextAfterLoaded_RichEdit(UINT uStringID, const ATL::CStringW& szText, DWORD StringFlags, DWORD TextFlags)
+CAvailableApplicationInfo::CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam)
 {
-    ATL::CStringW szLoadedText;
-    if (!szText.IsEmpty() && szLoadedText.LoadStringW(hInst, uStringID))
-    {
-        InsertRichEditText(szLoadedText, StringFlags);
-        InsertRichEditText(szText, TextFlags);
-    }
+    LicenseType = LICENSE_TYPE::None;
+    sFileName = sFileNameParam;
+    RetrieveCategory();
 }
 
-inline VOID 
-InsertLoadedTextNewl_RichEdit(UINT uStringID, DWORD StringFlags)
+VOID CAvailableApplicationInfo::RefreshAppInfo()
 {
-    ATL::CStringW szLoadedText;
-    if (szLoadedText.LoadStringW(hInst, uStringID))
+    if (RetrieveGeneralInfo())
     {
-        InsertRichEditText(L"\n", 0);
-        InsertRichEditText(szLoadedText, StringFlags);
-        InsertRichEditText(L"\n", 0);
+        RetrieveLicenseType();
+        RetrieveLanguages();
+        RetrieveInstalledStatus();
+        if (m_IsInstalled)
+        {
+            RetrieveInstalledVersion();
+        }
     }
 }
 
-inline BOOL 
-GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString, const ATL::CStringW& cFileName)
+BOOL CAvailableApplicationInfo::RetrieveGeneralInfo()
 {
-    if (!ParserGetString(lpKeyName, cFileName, ReturnedString))
+    if (szUrlDownload.IsEmpty())
     {
-        ReturnedString.Empty();
-        return FALSE;
-    }
-    return TRUE;
-}
+        if (!GetString(L"Name", szName)
+            || !GetString(L"URLDownload", szUrlDownload))
+        {
+            return FALSE;
+        }
 
-//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)
-{
-    return (!Info->szRegName.IsEmpty()
-            && (GetInstalledVersion_WowUser(szVersion, Info->szRegName, TRUE, key)
-                || GetInstalledVersion_WowUser(szVersion, Info->szRegName, FALSE, key)))
-        || (!Info->szName.IsEmpty()
-            && (GetInstalledVersion_WowUser(szVersion, Info->szName, TRUE, key)
-                || GetInstalledVersion_WowUser(szVersion, Info->szName, FALSE, key)));
+        GetString(L"RegName", szRegName);
+        GetString(L"Version", szVersion);
+        GetString(L"License", szLicense);
+        GetString(L"Description", szDesc);
+        GetString(L"Size", szSize);
+        GetString(L"URLSite", szUrlSite);
+        GetString(L"CDPath", szCDPath);
+        GetString(L"Language", szRegName);
+        GetString(L"SHA1", szSHA1);
+        return TRUE;
+    }
+    return FALSE;
 }
 
-inline BOOL 
-GetInstalledVersion(PAPPLICATION_INFO Info, ATL::CStringW* szVersion)
+VOID CAvailableApplicationInfo::RetrieveInstalledStatus()
 {
-    return  GetInstalledVersionEx(Info, szVersion, KEY_WOW64_32KEY)
-        || GetInstalledVersionEx(Info, szVersion, KEY_WOW64_64KEY);
+    m_IsInstalled = ::GetInstalledVersion(NULL, szRegName)
+        || ::GetInstalledVersion(NULL, szName);
 }
 
-inline BOOL 
-IsAppInstalled(PAPPLICATION_INFO Info)
+VOID CAvailableApplicationInfo::RetrieveInstalledVersion()
 {
-    return GetInstalledVersion(Info, NULL);
+    m_HasInstalledVersion = ::GetInstalledVersion(&szInstalledVersion, szRegName)
+        || ::GetInstalledVersion(&szInstalledVersion, szName);
 }
 
-ATL::CSimpleArray<ATL::CStringW> 
-ParserGetAppLanguages(const ATL::CStringW& szFileName)
+BOOL CAvailableApplicationInfo::RetrieveLanguages()
 {
     const WCHAR cDelimiter = L'|';
     ATL::CStringW szBuffer;
 
-    if (!ParserGetString(L"Languages", szFileName, szBuffer))
-        return CSimpleArray<ATL::CStringW>();
+    // TODO: Get multiline parameter
+    if (!ParserGetString(L"Languages", sFileName, szBuffer))
+        return FALSE;
 
+    // Parse parameter string
     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);
+        }
+        else
+        {
+            Languages.Add(szLocale);
             szLocale.Empty();
         }
     }
+
     // For the text after delimiter
     if (!szLocale.IsEmpty())
     {
-        arrLocalesResult.Add(szLocale);
+        Languages.Add(szLocale);
     }
-    return arrLocalesResult;
+
+    return TRUE;
 }
 
-BOOL
-HasNativeLanguage(PAPPLICATION_INFO Info)
+VOID CAvailableApplicationInfo::RetrieveLicenseType()
 {
-    if (!Info)
+    INT IntBuffer = ParserGetInt(L"LicenseType", sFileName);
+
+    if (IntBuffer < 0 || IntBuffer > LICENSE_TYPE::Max)
     {
-        return FALSE;
+        LicenseType = LICENSE_TYPE::None;
+    }
+    else
+    {
+        LicenseType = (LICENSE_TYPE) IntBuffer;
     }
-    //TODO: make the actual check
-    return TRUE;
 }
-BOOL
-HasEnglishLanguage(PAPPLICATION_INFO Info)
+
+VOID CAvailableApplicationInfo::RetrieveCategory()
 {
-    if (!Info)
+    Category = ParserGetInt(L"Category", sFileName);
+}
+
+BOOL CAvailableApplicationInfo::HasLanguageInfo() const
+{
+    return m_HasLanguageInfo;
+}
+
+BOOL CAvailableApplicationInfo::HasNativeLanguage() const
+{
+    if (!m_HasLanguageInfo)
     {
         return FALSE;
     }
+
     //TODO: make the actual check
     return TRUE;
 }
 
-LICENSE_TYPE
-ParserGetLicenseType(const ATL::CStringW& szFileName)
+BOOL CAvailableApplicationInfo::HasEnglishLanguage() const
 {
-    INT IntBuffer = ParserGetInt(L"LicenseType", szFileName);
-    if (IntBuffer < 0 || IntBuffer > LICENSE_TYPE::Max)
+    if (!m_HasLanguageInfo)
     {
-        return LICENSE_TYPE::None;
+        return FALSE;
     }
-    return (LICENSE_TYPE) IntBuffer;
-}
 
-LIST_ENTRY CachedEntriesHead = {&CachedEntriesHead, &CachedEntriesHead};
-PLIST_ENTRY pCachedEntry = &CachedEntriesHead;
+    //TODO: make the actual check
+    return TRUE;
+}
 
-VOID 
-InsertVersionInfo_RichEdit(PAPPLICATION_INFO Info)
+BOOL CAvailableApplicationInfo::IsInstalled() const
 {
-    ATL::CStringW szVersion;
-    BOOL bIsInstalled = IsAppInstalled(Info),
-        bHasVersion = GetInstalledVersion(Info, &szVersion);
-
-    if (bIsInstalled)
-    {
-        if (bHasVersion)
-        {
-            if (Info->szVersion.Compare(szVersion) > 0)
-                InsertLoadedTextNewl_RichEdit(IDS_STATUS_UPDATE_AVAILABLE, CFE_ITALIC);
-            else
-                InsertLoadedTextNewl_RichEdit(IDS_STATUS_INSTALLED, CFE_ITALIC);
-
-            InsertTextAfterLoaded_RichEdit(IDS_AINFO_VERSION, szVersion, CFE_BOLD, 0);
-        }
-        else
-        {
-            InsertLoadedTextNewl_RichEdit(IDS_STATUS_INSTALLED, CFE_ITALIC);
-        }
-    }
-    else
-    {
-        InsertLoadedTextNewl_RichEdit(IDS_STATUS_NOTINSTALLED, CFE_ITALIC);
-    }
-    
-    InsertTextAfterLoaded_RichEdit(IDS_AINFO_AVAILABLEVERSION, Info->szVersion, CFE_BOLD, 0);
+    return m_IsInstalled;
 }
 
-VOID
-InsertLicenseInfo_RichEdit(PAPPLICATION_INFO Info)
+BOOL CAvailableApplicationInfo::HasInstalledVersion() const
 {
-    ATL::CStringW szLicense;
-    switch (Info->LicenseType)
-    {
-    case LICENSE_TYPE::OpenSource:
-        szLicense.LoadStringW(hInst, IDS_LICENSE_OPENSOURCE);
-        break;
-    case LICENSE_TYPE::Freeware:
-        szLicense.LoadStringW(hInst, IDS_LICENSE_FREEWARE);
-        break;
-    case LICENSE_TYPE::Trial:
-        szLicense.LoadStringW(hInst, IDS_LICENSE_TRIAL);
-        break;
-    default:
-        break;
-    }
-
-    if (szLicense.IsEmpty())
-    {
-        InsertTextAfterLoaded_RichEdit(IDS_AINFO_LICENSE, Info->szLicense, CFE_BOLD, 0);
-    }
-    else
-    {
-        szLicense.Format(L"(%ls)", Info->szLicense);
-        InsertTextAfterLoaded_RichEdit(IDS_AINFO_LICENSE, szLicense, CFE_BOLD, 0);
-    }
+    return m_HasInstalledVersion;
+}
 
+BOOL CAvailableApplicationInfo::HasUpdate() const
+{
+    return (szInstalledVersion.Compare(szVersion) < 0) ? TRUE : FALSE;
 }
 
-VOID
-InsertLanguageInfo_RichEdit(PAPPLICATION_INFO Info)
+VOID CAvailableApplicationInfo::SetLastWriteTime(FILETIME* ftTime)
 {
-    const INT nTranslations = Info->Languages.GetSize();
-    ATL::CStringW szLangInfo;
-    ATL::CStringW szLoadedTextAvailability;
-    ATL::CStringW szLoadedAInfoText;
-    szLoadedAInfoText.LoadStringW(IDS_AINFO_LANGUAGES);
+    RtlCopyMemory(&ftCacheStamp, ftTime, sizeof(FILETIME));
+}
 
-    if(HasNativeLanguage(Info))
-    {
-        szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_AVAILABLE_TRANSLATION);
-    }
-    else if (HasEnglishLanguage(Info))
-    {
-        szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_ENGLISH_TRANSLATION);
-    }
-    else
+inline BOOL CAvailableApplicationInfo::GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString)
+{
+    if (!ParserGetString(lpKeyName, sFileName, ReturnedString))
     {
-        szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_NO_TRANSLATION);
+        ReturnedString.Empty();
+        return FALSE;
     }
+    return TRUE;
+}
 
-    if (nTranslations > 1)
+// CAvailableApps
+CAvailableApps::CAvailableApps()
+{
+    //set all paths
+    if (GetStorageDirectory(m_szPath))
     {
-        szLangInfo.Format(L" (+%d more)", nTranslations - 1);
+        m_szAppsPath = m_szPath + L"\\rapps\\";
+        m_szCabPath = m_szPath + L"\\rappmgr.cab";
+        m_szSearchPath = m_szAppsPath + L"*.txt";
     }
-
-    InsertRichEditText(szLoadedAInfoText, CFE_BOLD);
-    InsertRichEditText(szLoadedTextAvailability, NULL);
-    InsertRichEditText(szLangInfo, CFE_ITALIC);
 }
 
-BOOL
-ShowAvailableAppInfo(INT Index)
+VOID CAvailableApps::FreeCachedEntries()
 {
-    PAPPLICATION_INFO Info = (PAPPLICATION_INFO) ListViewGetlParam(Index);
-    if (!Info) return FALSE;
-
-    NewRichEditText(Info->szName, CFE_BOLD);
-    InsertVersionInfo_RichEdit(Info);
-    InsertLicenseInfo_RichEdit(Info);
-    InsertLanguageInfo_RichEdit(Info);
+    POSITION InfoListPosition = m_InfoList.GetHeadPosition();
 
-    InsertTextAfterLoaded_RichEdit(IDS_AINFO_SIZE, Info->szSize, CFE_BOLD, 0);
-    InsertTextAfterLoaded_RichEdit(IDS_AINFO_URLSITE, Info->szUrlSite, CFE_BOLD, CFE_LINK);
-    InsertTextAfterLoaded_RichEdit(IDS_AINFO_DESCRIPTION, Info->szDesc, CFE_BOLD, 0);
-    InsertTextAfterLoaded_RichEdit(IDS_AINFO_URLDOWNLOAD, Info->szUrlDownload, CFE_BOLD, CFE_LINK);
+    /* loop and deallocate all the cached app infos in the list */
+    while (InfoListPosition)
+    {
+        CAvailableApplicationInfo* Info = m_InfoList.GetAt(InfoListPosition);
+        m_InfoList.RemoveHead();
+        delete Info;
 
-    return TRUE;
+        InfoListPosition = m_InfoList.GetHeadPosition();
+    }
 }
 
-static BOOL
-DeleteCurrentAppsDB(VOID)
+BOOL CAvailableApps::DeleteCurrentAppsDB()
 {
     HANDLE hFind = INVALID_HANDLE_VALUE;
     WIN32_FIND_DATAW FindFileData;
-    ATL::CStringW szCabPath;
-    ATL::CStringW szSearchPath;
-    ATL::CStringW szPath;
     BOOL result = TRUE;
 
-    if (!GetStorageDirectory(szPath))
+    if (m_szPath.IsEmpty())
         return FALSE;
 
-    szCabPath = szPath + L"\\rappmgr.cab";
-    result = result && DeleteFileW(szCabPath.GetString());
-
-    szPath += L"\\rapps\\";
-    szSearchPath = szPath + L"*.txt";
-
-    hFind = FindFirstFileW(szSearchPath.GetString(), &FindFileData);
+    result = result && DeleteFileW(m_szCabPath.GetString());
+    hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
 
     if (hFind == INVALID_HANDLE_VALUE)
         return result;
@@ -276,7 +223,7 @@ DeleteCurrentAppsDB(VOID)
     ATL::CStringW szTmp;
     do
     {
-        szTmp = szPath + FindFileData.cFileName;
+        szTmp = m_szPath + FindFileData.cFileName;
         result = result && DeleteFileW(szTmp.GetString());
     } while (FindNextFileW(hFind, &FindFileData) != 0);
 
@@ -285,25 +232,17 @@ DeleteCurrentAppsDB(VOID)
     return result;
 }
 
-BOOL
-UpdateAppsDB(VOID)
+BOOL CAvailableApps::UpdateAppsDB()
 {
-    ATL::CStringW szPath;
-    ATL::CStringW szAppsPath;
-    ATL::CStringW szCabPath;
-
     if (!DeleteCurrentAppsDB())
         return FALSE;
 
     DownloadApplicationsDB(APPLICATION_DATABASE_URL);
 
-    if (!GetStorageDirectory(szPath))
+    if (m_szPath.IsEmpty())
         return FALSE;
 
-    szCabPath = szPath + L"\\rappmgr.cab";
-    szAppsPath = szPath + L"\\rapps\\";
-
-    if (!ExtractFilesFromCab(szCabPath, szAppsPath))
+    if (!ExtractFilesFromCab(m_szCabPath, m_szAppsPath))
     {
         return FALSE;
     }
@@ -311,40 +250,26 @@ UpdateAppsDB(VOID)
     return TRUE;
 }
 
-
-BOOL
-EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc)
+BOOL CAvailableApps::EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc)
 {
     HANDLE hFind = INVALID_HANDLE_VALUE;
     WIN32_FIND_DATAW FindFileData;
-    ATL::CStringW szPath;
-    ATL::CStringW szAppsPath;
-    ATL::CStringW szCabPath;
-    PAPPLICATION_INFO Info;
 
-    if (!GetStorageDirectory(szPath))
-        return FALSE;
-
-    szCabPath = szPath + L"\\rappmgr.cab";
-    szPath += L"\\rapps\\";
-    szAppsPath = szPath;
-
-    if (!CreateDirectoryW(szPath.GetString(), NULL) &&
+    if (!CreateDirectoryW(m_szPath.GetString(), NULL) &&
         GetLastError() != ERROR_ALREADY_EXISTS)
     {
         return FALSE;
     }
 
-    szPath += L"*.txt";
-    hFind = FindFirstFileW(szPath.GetString(), &FindFileData);
+    hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
 
     if (hFind == INVALID_HANDLE_VALUE)
     {
-        if (GetFileAttributesW(szCabPath) == INVALID_FILE_ATTRIBUTES)
+        if (GetFileAttributesW(m_szCabPath) == INVALID_FILE_ATTRIBUTES)
             DownloadApplicationsDB(APPLICATION_DATABASE_URL);
 
-        ExtractFilesFromCab(szCabPath, szAppsPath);
-        hFind = FindFirstFileW(szPath, &FindFileData);
+        ExtractFilesFromCab(m_szCabPath, m_szAppsPath);
+        hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
 
         if (hFind == INVALID_HANDLE_VALUE)
             return FALSE;
@@ -353,22 +278,25 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc)
     do
     {
         /* loop for all the cached entries */
-        POSITION CurrentListPosition = InfoList.GetHeadPosition();
+        POSITION CurrentListPosition = m_InfoList.GetHeadPosition();
+        CAvailableApplicationInfo* Info = NULL;
 
         while (CurrentListPosition != NULL)
         {
             POSITION LastListPosition = CurrentListPosition;
-            Info = InfoList.GetNext(CurrentListPosition);
+            Info = m_InfoList.GetNext(CurrentListPosition);
 
             /* do we already have this entry in cache? */
-            if (!Info->cFileName.Compare(FindFileData.cFileName))
+            if (Info->sFileName == FindFileData.cFileName)
             {
                 /* is it current enough, or the file has been modified since our last time here? */
                 if (CompareFileTime(&FindFileData.ftLastWriteTime, &Info->ftCacheStamp) == 1)
                 {
                     /* recreate our cache, this is the slow path */
-                    InfoList.RemoveAt(LastListPosition);
+                    m_InfoList.RemoveAt(LastListPosition);
+
                     delete Info;
+                    Info = nullptr;
                     break;
                 }
                 else
@@ -380,21 +308,11 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc)
         }
 
         /* create a new entry */
-        Info = new APPLICATION_INFO();
+        Info = new CAvailableApplicationInfo(FindFileData.cFileName);
 
-        if (!Info)
-            break;
-
-        Info->Category = ParserGetInt(L"Category", FindFileData.cFileName);
-        Info->LicenseType = ParserGetLicenseType(FindFileData.cFileName);
-        Info->Languages = ParserGetAppLanguages(FindFileData.cFileName);
-
-        /* copy the cache-related fields for the next time */
-        Info->cFileName = FindFileData.cFileName;
-        RtlCopyMemory(&Info->ftCacheStamp, &FindFileData.ftLastWriteTime, sizeof(FILETIME));
-
-        /* add our cached entry to the cached list */
-        InfoList.AddTail(Info);
+        /* set a timestamp for the next time */
+        Info->SetLastWriteTime(&FindFileData.ftLastWriteTime);
+        m_InfoList.AddTail(Info);
 
 skip_if_cached:
         if (Info->Category == FALSE)
@@ -403,50 +321,43 @@ skip_if_cached:
         if (EnumType != Info->Category && EnumType != ENUM_ALL_AVAILABLE)
             continue;
 
-        /* if our cache hit was only partial, we need to parse
-           and lazily fill the rest of fields only when needed */
-
-        if (Info->szUrlDownload.IsEmpty())
-        {
-            if (!GetString(L"Name", Info->szName, FindFileData.cFileName)
-                || !GetString(L"URLDownload", Info->szUrlDownload, FindFileData.cFileName))
-            {
-                continue;
-            }
-
-            GetString(L"RegName", Info->szRegName, FindFileData.cFileName);
-            GetString(L"Version", Info->szVersion, FindFileData.cFileName);
-            GetString(L"License", Info->szLicense, FindFileData.cFileName);
-            GetString(L"Description", Info->szDesc, FindFileData.cFileName);
-            GetString(L"Size", Info->szSize, FindFileData.cFileName);
-            GetString(L"URLSite", Info->szUrlSite, FindFileData.cFileName);
-            GetString(L"CDPath", Info->szCDPath, FindFileData.cFileName);
-            GetString(L"Language", Info->szRegName, FindFileData.cFileName);
-            GetString(L"SHA1", Info->szSHA1, FindFileData.cFileName);
-        }
+        Info->RefreshAppInfo();
 
-        if (!lpEnumProc(Info))
+        if (!lpEnumProc(static_cast<PAPPLICATION_INFO>(Info), m_szAppsPath.GetString()))
             break;
 
     } while (FindNextFileW(hFind, &FindFileData) != 0);
 
     FindClose(hFind);
-
     return TRUE;
 }
 
-VOID FreeCachedAvailableEntries(VOID)
+const ATL::CStringW & CAvailableApps::GetFolderPath()
 {
-    PAPPLICATION_INFO Info;
-    POSITION InfoListPosition = InfoList.GetHeadPosition();
+    return m_szPath;
+}
 
-    /* loop and deallocate all the cached app infos in the list */
-    while (InfoListPosition)
-    {
-        Info = InfoList.GetAt(InfoListPosition);
-        InfoList.RemoveHead();
-        InfoListPosition = InfoList.GetHeadPosition();
-        
-        delete Info;
-    }
-}
\ No newline at end of file
+const ATL::CStringW & CAvailableApps::GetAppPath()
+{
+    return m_szAppsPath;
+}
+
+const ATL::CStringW & CAvailableApps::GetCabPath()
+{
+    return m_szCabPath;
+}
+
+const LPCWSTR CAvailableApps::GetFolderPathString()
+{
+    return m_szPath.GetString();
+}
+
+const LPCWSTR CAvailableApps::GetAppPathString()
+{
+    return m_szPath.GetString();
+}
+
+const LPCWSTR CAvailableApps::GetCabPathString()
+{
+    return m_szPath.GetString();
+}
index 28c47ff..e6dd568 100644 (file)
@@ -83,7 +83,6 @@ public:
 
     HWND Create(HWND hwndParent)
     {
-        // TODO: FreeLibrary when the window is destroyed
         LoadedLibrary = LoadLibraryW(L"riched20.dll");
 
         m_hWnd = CreateWindowExW(0,
index 5d90c3e..01ce7d9 100644 (file)
 
 HWND hListView = NULL;
 
+class CAvailableAppView
+{
+    static inline VOID InsertTextAfterLoaded_RichEdit(UINT uStringID,
+                                                      const ATL::CStringW& szText,
+                                                      DWORD StringFlags,
+                                                      DWORD TextFlags)
+    {
+        ATL::CStringW szLoadedText;
+        if (!szText.IsEmpty() && szLoadedText.LoadStringW(hInst, uStringID))
+        {
+            InsertRichEditText(szLoadedText, StringFlags);
+            InsertRichEditText(szText, TextFlags);
+        }
+    }
+
+    static inline VOID InsertLoadedTextNewl_RichEdit(UINT uStringID,
+                                                     DWORD StringFlags)
+    {
+        ATL::CStringW szLoadedText;
+        if (szLoadedText.LoadStringW(hInst, uStringID))
+        {
+            InsertRichEditText(L"\n", 0);
+            InsertRichEditText(szLoadedText, StringFlags);
+            InsertRichEditText(L"\n", 0);
+        }
+    }
+
+    static VOID InsertVersionInfo_RichEdit(CAvailableApplicationInfo* Info)
+    {
+        if (Info->IsInstalled())
+        {
+            if (Info->HasInstalledVersion())
+            {
+                if (Info->HasUpdate())
+                    InsertLoadedTextNewl_RichEdit(IDS_STATUS_UPDATE_AVAILABLE, CFE_ITALIC);
+                else
+                    InsertLoadedTextNewl_RichEdit(IDS_STATUS_INSTALLED, CFE_ITALIC);
+
+                InsertTextAfterLoaded_RichEdit(IDS_AINFO_VERSION, Info->szInstalledVersion, CFE_BOLD, 0);
+            }
+            else
+            {
+                InsertLoadedTextNewl_RichEdit(IDS_STATUS_INSTALLED, CFE_ITALIC);
+            }
+        }
+        else
+        {
+            InsertLoadedTextNewl_RichEdit(IDS_STATUS_NOTINSTALLED, CFE_ITALIC);
+        }
+
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_AVAILABLEVERSION, Info->szVersion, CFE_BOLD, 0);
+    }
+
+    static VOID InsertLicenseInfo_RichEdit(CAvailableApplicationInfo* Info)
+    {
+        ATL::CStringW szLicense;
+        switch (Info->LicenseType)
+        {
+        case LICENSE_TYPE::OpenSource:
+            szLicense.LoadStringW(hInst, IDS_LICENSE_OPENSOURCE);
+            break;
+        case LICENSE_TYPE::Freeware:
+            szLicense.LoadStringW(hInst, IDS_LICENSE_FREEWARE);
+            break;
+        case LICENSE_TYPE::Trial:
+            szLicense.LoadStringW(hInst, IDS_LICENSE_TRIAL);
+            break;
+        default:
+            InsertTextAfterLoaded_RichEdit(IDS_AINFO_LICENSE, Info->szLicense, CFE_BOLD, 0);
+            return;
+        }
+
+        szLicense += L" (" + Info->szLicense + L")";
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_LICENSE, szLicense, CFE_BOLD, 0);
+    }
+
+    static VOID InsertLanguageInfo_RichEdit(CAvailableApplicationInfo* Info)
+    {
+        const INT nTranslations = Info->Languages.GetSize();
+        ATL::CStringW szLangInfo;
+        ATL::CStringW szLoadedTextAvailability;
+        ATL::CStringW szLoadedAInfoText;
+        szLoadedAInfoText.LoadStringW(IDS_AINFO_LANGUAGES);
+
+        if (Info->HasNativeLanguage())
+        {
+            szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_AVAILABLE_TRANSLATION);
+        }
+        else if (Info->HasEnglishLanguage())
+        {
+            szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_ENGLISH_TRANSLATION);
+        }
+        else
+        {
+            szLoadedTextAvailability.LoadStringW(IDS_LANGUAGE_NO_TRANSLATION);
+        }
+
+        if (nTranslations > 1)
+        {
+            szLangInfo.Format(L" (+%d more)", nTranslations - 1);
+        }
+        else
+        {
+            szLangInfo.LoadStringW(IDS_LANGUAGE_SINGLE);
+            szLangInfo = L" (" + szLangInfo + L")";
+        }
+
+        InsertRichEditText(szLoadedAInfoText, CFE_BOLD);
+        InsertRichEditText(szLoadedTextAvailability, NULL);
+        InsertRichEditText(szLangInfo, CFE_ITALIC);
+    }
+
+public:
+    static BOOL ShowAvailableAppInfo(INT Index)
+    {
+        CAvailableApplicationInfo* Info = (CAvailableApplicationInfo*) ListViewGetlParam(Index);
+        if (!Info) return FALSE;
+
+        NewRichEditText(Info->szName, CFE_BOLD);
+        InsertVersionInfo_RichEdit(Info);
+        InsertLicenseInfo_RichEdit(Info);
+        InsertLanguageInfo_RichEdit(Info);
+
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_SIZE, Info->szSize, CFE_BOLD, 0);
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_URLSITE, Info->szUrlSite, CFE_BOLD, CFE_LINK);
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_DESCRIPTION, Info->szDesc, CFE_BOLD, 0);
+        InsertTextAfterLoaded_RichEdit(IDS_AINFO_URLDOWNLOAD, Info->szUrlDownload, CFE_BOLD, CFE_LINK);
+
+        return TRUE;
+    }
+};
+
 class CMainToolbar :
     public CUiWindow< CToolbar<> >
 {
@@ -222,9 +354,7 @@ public:
 
     BOOL AddColumn(INT Index, ATL::CStringW& Text, INT Width, INT Format)
     {
-        BOOL result = AddColumn(Index, Text.GetBuffer(), Width, Format);
-
-        return result;
+        return AddColumn(Index, const_cast<LPWSTR>(Text.GetString()), Width, Format);
     }
 
     BOOL AddColumn(INT Index, LPWSTR lpText, INT Width, INT Format)
@@ -315,9 +445,7 @@ class CSideTreeView :
 public:
     HTREEITEM AddItem(HTREEITEM hParent, ATL::CStringW &Text, INT Image, INT SelectedImage, LPARAM lParam)
     {
-        HTREEITEM result = CUiWindow<CTreeView>::AddItem(hParent, Text.GetBuffer(), Image, SelectedImage, lParam);
-        Text.ReleaseBuffer();
-        return result;
+        return CUiWindow<CTreeView>::AddItem(hParent, const_cast<LPWSTR>(Text.GetString()), Image, SelectedImage, lParam);
     }
 
     HTREEITEM AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex)
@@ -406,6 +534,8 @@ class CMainWindow :
 
     BOOL SearchEnabled;
 
+    CAvailableApps m_AvailableApps;
+
 public:
     CMainWindow() :
         m_ClientPanel(NULL),
@@ -413,7 +543,6 @@ public:
         SearchEnabled(TRUE)
     {
     }
-
 private:
 
     VOID InitApplicationsList(VOID)
@@ -538,7 +667,7 @@ private:
         m_HSplitter->m_Horizontal = TRUE;
         m_HSplitter->m_Pos = 32768;
         m_HSplitter->m_MinFirst = 300;
-        m_HSplitter->m_MinSecond = 80;
+        m_HSplitter->m_MinSecond = 150;
         m_VSplitter->Second().Append(m_HSplitter);
 
         return m_HSplitter->Create(m_hWnd) != NULL;
@@ -670,8 +799,6 @@ private:
 
             FreeLogs();
 
-            FreeCachedAvailableEntries();
-
             if (IS_INSTALLED_ENUM(SelectedEnumType))
                 FreeInstalledAppList();
 
@@ -839,7 +966,7 @@ private:
                         if (IS_INSTALLED_ENUM(SelectedEnumType))
                             ShowInstalledAppInfo(ItemIndex);
                         if (IS_AVAILABLE_ENUM(SelectedEnumType))
-                            ShowAvailableAppInfo(ItemIndex);
+                            CAvailableAppView::ShowAvailableAppInfo(ItemIndex);
                     }
                 }
             }
@@ -860,7 +987,7 @@ private:
                     if (IS_INSTALLED_ENUM(SelectedEnumType))
                         ShowInstalledAppInfo(-1);
                     if (IS_AVAILABLE_ENUM(SelectedEnumType))
-                        ShowAvailableAppInfo(-1);
+                        CAvailableAppView::ShowAvailableAppInfo(-1);
                 }
             }
             break;
@@ -1094,7 +1221,7 @@ private:
             break;
 
         case ID_RESETDB:
-            UpdateAppsDB();
+            m_AvailableApps.UpdateAppsDB();
             UpdateApplicationsList(-1);
             break;
 
@@ -1158,21 +1285,20 @@ private:
 
         /* Get version info */
         GetApplicationString(ItemInfo->hSubKey, L"DisplayVersion", szText);
-        ListView_SetItemText(hListView, Index, 1, szText.GetBuffer());
-        szText.ReleaseBuffer();
+        ListView_SetItemText(hListView, Index, 1, const_cast<LPWSTR>(szText.GetString()));
 
         /* Get comments */
         GetApplicationString(ItemInfo->hSubKey, L"Comments", szText);
-        ListView_SetItemText(hListView, Index, 2, szText.GetBuffer());
-        szText.ReleaseBuffer();
+        ListView_SetItemText(hListView, Index, 2, const_cast<LPWSTR>(szText.GetString()));
+
         return TRUE;
     }
 
-    static BOOL CALLBACK s_EnumAvailableAppProc(PAPPLICATION_INFO Info)
+    static BOOL CALLBACK s_EnumAvailableAppProc(PAPPLICATION_INFO Info, LPCWSTR szFolderPath)
     {
         INT Index;
         HICON hIcon = NULL;
-        ATL::CStringW szIconPath;
+
         HIMAGELIST hImageListView = ListView_GetImageList(hListView, LVSIL_SMALL);
 
         if (!SearchPatternMatch(Info->szName, szSearchPattern) &&
@@ -1181,34 +1307,31 @@ private:
             return TRUE;
         }
 
-        if (GetStorageDirectory(szIconPath))
-        {
-            /* Load icon from file */
-            szIconPath += L"\\rapps\\icons\\" + Info->szName + L".ico";
-            hIcon = (HICON) LoadImageW(NULL,
-                                       szIconPath.GetString(),
-                                       IMAGE_ICON,
-                                       LISTVIEW_ICON_SIZE,
-                                       LISTVIEW_ICON_SIZE,
-                                       LR_LOADFROMFILE);
-        }
-
-        if (!hIcon)
+        /* Load icon from file */
+        ATL::CStringW szIconPath;
+        szIconPath.Format(L"%lsicons\\%ls.ico", szFolderPath, Info->szName);
+        hIcon = (HICON) LoadImageW(NULL,
+                                   szIconPath.GetString(),
+                                   IMAGE_ICON,
+                                   LISTVIEW_ICON_SIZE,
+                                   LISTVIEW_ICON_SIZE,
+                                   LR_LOADFROMFILE);
+
+        if (!hIcon || GetLastError() != ERROR_SUCCESS)
         {
             /* Load default icon */
             hIcon = (HICON) LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN));
         }
+
         Index = ImageList_AddIcon(hImageListView, hIcon);
         DestroyIcon(hIcon);
 
         Index = ListViewAddItem(Info->Category, Index, Info->szName, (LPARAM) Info);
-        hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
+        ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
 
-        ListView_SetItemText(hListView, Index, 1, Info->szVersion.GetBuffer());
-        Info->szVersion.ReleaseBuffer();
+        ListView_SetItemText(hListView, Index, 1, const_cast<LPWSTR>(Info->szVersion.GetString()));
+        ListView_SetItemText(hListView, Index, 2, const_cast<LPWSTR>(Info->szDesc.GetString()));
 
-        ListView_SetItemText(hListView, Index, 2, Info->szDesc.GetBuffer());
-        Info->szDesc.ReleaseBuffer();
         return TRUE;
     }
 
@@ -1216,7 +1339,7 @@ private:
     VOID UpdateApplicationsList(INT EnumType)
     {
         ATL::CStringW szBuffer1, szBuffer2;
-        HIMAGELIST hImageListView = NULL;
+        HIMAGELIST hImageListView;
 
         m_ListView->SendMessageW(WM_SETREDRAW, FALSE, 0);
 
@@ -1226,20 +1349,23 @@ private:
             FreeInstalledAppList();
 
         (VOID) ListView_DeleteAllItems(hListView);
+
         /* Create new ImageList */
         hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE,
                                           LISTVIEW_ICON_SIZE,
                                           GetSystemColorDepth() | ILC_MASK,
                                           0, 1);
-        hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
+        HIMAGELIST hImageListBuf = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
+        if (hImageListBuf)
+        {
+            ImageList_Destroy(hImageListBuf);
+        }
 
-        if (hImageListView)
-            ImageList_Destroy(hImageListView);
 
         if (IS_AVAILABLE_ENUM(EnumType))
         {
             /* Enum available applications */
-            EnumAvailableApplications(EnumType, s_EnumAvailableAppProc);
+            m_AvailableApps.EnumAvailableApplications(EnumType, s_EnumAvailableAppProc);
         }
 
         SelectedEnumType = EnumType;
@@ -1263,18 +1389,18 @@ public:
         DWORD csStyle = CS_VREDRAW | CS_HREDRAW;
         static ATL::CWndClassInfo wc =
         {
-            { 
-                sizeof(WNDCLASSEX), 
-                csStyle, 
+            {
+                sizeof(WNDCLASSEX),
+                csStyle,
                 StartWindowProc,
-                0, 
-                0, 
+                0,
+                0,
                 NULL,
                 LoadIconW(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCEW(IDI_MAIN)),
                 LoadCursorW(NULL, IDC_ARROW),
-                (HBRUSH) (COLOR_BTNFACE + 1), 
+                (HBRUSH) (COLOR_BTNFACE + 1),
                 MAKEINTRESOURCEW(IDR_MAINMENU),
-                L"RAppsWnd", 
+                L"RAppsWnd",
                 NULL
             },
             NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
@@ -1313,8 +1439,15 @@ public:
     {
         return m_RichEdit;
     }
+
+    CAvailableApps * GetAvailableApps()
+    {
+        return &m_AvailableApps;
+    }
 };
 
+// File interface
+
 CMainWindow * g_MainWindow;
 
 HWND CreateMainWindow()
@@ -1360,9 +1493,7 @@ VOID SetStatusBarText(const ATL::CStringW& szText)
 
 INT ListViewAddItem(INT ItemIndex, INT IconIndex, ATL::CStringW & Name, LPARAM lParam)
 {
-    INT result = ListViewAddItem(ItemIndex, IconIndex, Name.GetBuffer(), lParam);
-    Name.ReleaseBuffer();
-    return result;
+    return ListViewAddItem(ItemIndex, IconIndex, const_cast<LPWSTR>(Name.GetString()), lParam);
 }
 
 VOID NewRichEditText(const ATL::CStringW& szText, DWORD flags)
@@ -1375,3 +1506,7 @@ VOID InsertRichEditText(const ATL::CStringW& szText, DWORD flags)
     InsertRichEditText(szText.GetString(), flags);
 }
 
+CAvailableApps* GetAvailableApps()
+{
+    return g_MainWindow->GetAvailableApps();
+}
index 298c610..dbb86d6 100644 (file)
@@ -37,7 +37,10 @@ GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString)
 }
 
 BOOL
-GetInstalledVersion_WowUser(_Out_opt_ ATL::CStringW* szVersionResult, _In_z_ const ATL::CStringW& RegName, _In_ BOOL IsUserKey, _In_ REGSAM keyWow)
+GetInstalledVersion_WowUser(_Out_opt_ ATL::CStringW* szVersionResult, 
+                            _In_z_ const ATL::CStringW& RegName, 
+                            _In_ BOOL IsUserKey, 
+                            _In_ REGSAM keyWow)
 {
     HKEY hKey;
     BOOL bHasSucceded = FALSE;
@@ -48,7 +51,7 @@ GetInstalledVersion_WowUser(_Out_opt_ ATL::CStringW* szVersionResult, _In_z_ con
                       szPath.GetString(), 0, keyWow | KEY_READ,
                       &hKey) == ERROR_SUCCESS)
     {
-        if (szVersionResult)
+        if (szVersionResult != NULL)
         {
             DWORD dwSize = MAX_PATH * sizeof(WCHAR);
             DWORD dwType = REG_SZ;
@@ -80,6 +83,14 @@ GetInstalledVersion_WowUser(_Out_opt_ ATL::CStringW* szVersionResult, _In_z_ con
     return bHasSucceded;
 }
 
+BOOL GetInstalledVersion(ATL::CStringW* pszVersion, const ATL::CStringW& szRegName)
+{
+    return (!szRegName.IsEmpty()
+            && (::GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY)
+                || ::GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_32KEY)
+                || ::GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_64KEY)
+                || ::GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_64KEY)));
+}
 
 BOOL
 UninstallApplication(INT Index, BOOL bModify)
index dd04cae..a778fb3 100644 (file)
@@ -232,4 +232,5 @@ BEGIN
     IDS_LANGUAGE_NO_TRANSLATION "In your language"
     IDS_LANGUAGE_NOT_AVAILABLE "No translations"
     IDS_LANGUAGE_ENGLISH_TRANSLATION "In English"
+    IDS_LANGUAGE_SINGLE "Single language"
 END
index 8d1fdf9..a42dc3f 100644 (file)
@@ -111,8 +111,7 @@ public:
                                   uiPercentage,
                                   szProgress,
                                   szProgressMax);
-            SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) m_ProgressText.GetBuffer());
-            m_ProgressText.ReleaseBuffer();
+            SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) m_ProgressText.GetString());
         }
 
         Item = GetDlgItem(m_hDialog, IDC_DOWNLOAD_STATUS);
@@ -134,8 +133,7 @@ public:
             }
 
             /* paste it into our dialog and don't do it again in this instance */
-            SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) buf.GetBuffer());
-            buf.ReleaseBuffer();
+            SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) buf.GetString());
             m_UrlHasBeenCopied = TRUE;
         }
 
@@ -436,8 +434,7 @@ ThreadFunc(LPVOID Context)
             goto end;
 
         SetWindowText(Dlg, szMsgText.GetString());
-        SendMessageW(GetDlgItem(Dlg, IDC_DOWNLOAD_STATUS), WM_SETTEXT, 0, (LPARAM) Path.GetBuffer());
-        Path.ReleaseBuffer();
+        SendMessageW(GetDlgItem(Dlg, IDC_DOWNLOAD_STATUS), WM_SETTEXT, 0, (LPARAM) Path.GetString());
 
         /* this may take a while, depending on the file size */
         if (!VerifyInteg(AppInfo->szSHA1, Path.GetString()))
index 1115262..707cc32 100644 (file)
@@ -193,8 +193,7 @@ ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
 BOOL
 StartProcess(ATL::CStringW &Path, BOOL Wait)
 {
-    BOOL result = StartProcess(Path.GetBuffer(), Wait);
-    Path.ReleaseBuffer();
+    BOOL result = StartProcess(const_cast<LPWSTR>(Path.GetString()), Wait);
     return result;
 }
 
index 23245fd..f3d0d23 100644 (file)
@@ -104,7 +104,7 @@ typedef struct
     ATL::CSimpleArray<ATL::CStringW> Languages;
 
     /* caching mechanism related entries */
-    ATL::CStringW cFileName;
+    ATL::CStringW sFileName;
     FILETIME ftCacheStamp;
 
     /* optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form) */
@@ -143,11 +143,66 @@ typedef struct
 } SETTINGS_INFO, *PSETTINGS_INFO;
 
 /* available.cpp */
-typedef BOOL (CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info);
-BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
-BOOL ShowAvailableAppInfo(INT Index);
-BOOL UpdateAppsDB(VOID);
-VOID FreeCachedAvailableEntries(VOID);
+typedef BOOL (CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info, LPCWSTR szFolderPath);
+struct CAvailableApplicationInfo : public APPLICATION_INFO
+{
+    ATL::CStringW szInstalledVersion;
+
+    CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
+
+    // Load all info from the file
+    VOID RefreshAppInfo();
+
+
+
+    BOOL HasLanguageInfo() const;
+    BOOL HasNativeLanguage() const;
+    BOOL HasEnglishLanguage() const;
+    BOOL IsInstalled() const;
+    BOOL HasInstalledVersion() const;
+    BOOL HasUpdate() const;
+
+    // Set a timestamp
+    VOID SetLastWriteTime(FILETIME* ftTime);
+
+private:
+    BOOL m_IsInstalled = FALSE;
+    BOOL m_HasLanguageInfo = FALSE;
+    BOOL m_HasInstalledVersion = FALSE;
+
+    inline BOOL GetString(LPCWSTR lpKeyName, 
+                          ATL::CStringW& ReturnedString);
+
+    // Lazily load general info from the file
+    BOOL RetrieveGeneralInfo();
+    VOID RetrieveInstalledStatus();
+    VOID RetrieveInstalledVersion();
+    BOOL RetrieveLanguages();
+    VOID RetrieveLicenseType();
+    VOID RetrieveCategory();
+};
+
+class CAvailableApps
+{
+    ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
+    ATL::CStringW m_szPath;
+    ATL::CStringW m_szCabPath;
+    ATL::CStringW m_szAppsPath;
+    ATL::CStringW m_szSearchPath;
+
+public:
+    CAvailableApps();
+    VOID FreeCachedEntries();
+    BOOL DeleteCurrentAppsDB();
+    BOOL UpdateAppsDB();
+    BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
+    const ATL::CStringW& GetFolderPath();
+    const ATL::CStringW& GetAppPath();
+    const ATL::CStringW& GetCabPath();
+    const LPCWSTR GetFolderPathString();
+    const LPCWSTR GetAppPathString();
+    const LPCWSTR GetCabPathString();
+};
 
 /* installdlg.cpp */
 BOOL InstallApplication(INT Index);
@@ -162,7 +217,7 @@ BOOL ShowInstalledAppInfo(INT Index);
 BOOL UninstallApplication(INT Index, BOOL bModify);
 VOID RemoveAppFromRegistry(INT Index);
 
-BOOL GetInstalledVersion_WowUser(ATL::CStringW* szVersionResult, const ATL::CStringW& RegName, BOOL IsUserKey, REGSAM keyWow);
+BOOL GetInstalledVersion(ATL::CStringW* pszVersion, const ATL::CStringW& szRegName);
 
 /* winmain.cpp */
 extern HWND hMainWnd;
@@ -211,6 +266,7 @@ VOID SetStatusBarText(const ATL::CStringW& szText);
 INT ListViewAddItem(INT ItemIndex, INT IconIndex, ATL::CStringW & Name, LPARAM lParam);
 VOID NewRichEditText(const ATL::CStringW& szText, DWORD flags);
 VOID InsertRichEditText(const ATL::CStringW& szText, DWORD flags);
+CAvailableApps * GetAvailableApps();
 extern HWND hListView;
 extern ATL::CStringW szSearchPattern;
 
index c2367e0..9658732 100644 (file)
 #define IDS_LANGUAGE_NO_TRANSLATION             911
 #define IDS_LANGUAGE_NOT_AVAILABLE              912
 #define IDS_LANGUAGE_ENGLISH_TRANSLATION        913
+#define IDS_LANGUAGE_SINGLE                     914
 
 /* Accelerators */
 #define HOTKEYS                  715
index 82fffaf..32dfe36 100644 (file)
@@ -183,8 +183,9 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nSh
     ShowWindow(hMainWnd, (SettingsInfo.bSaveWndPos && SettingsInfo.Maximized ? SW_MAXIMIZE : nShowCmd));
     UpdateWindow(hMainWnd);
 
+    //TODO: get around the ugliness
     if (SettingsInfo.bUpdateAtStart)
-        UpdateAppsDB();
+        GetAvailableApps()->UpdateAppsDB();
 
     /* Load the menu hotkeys */
     KeyBrd = LoadAccelerators(NULL, MAKEINTRESOURCE(HOTKEYS));