[RAPPS] Replace pointer array with object array in parts related to app DL.
authorAlexander Shaposhnikov <sanchaez@reactos.org>
Sat, 21 Oct 2017 21:00:50 +0000 (00:00 +0300)
committerAlexander Shaposhnikov <sanchaez@reactos.org>
Fri, 27 Oct 2017 19:03:27 +0000 (22:03 +0300)
base/applications/rapps/available.cpp
base/applications/rapps/gui.cpp
base/applications/rapps/include/available.h
base/applications/rapps/include/dialogs.h
base/applications/rapps/loaddlg.cpp
base/applications/rapps/unattended.cpp

index 6fa51ad..8ee80c9 100644 (file)
@@ -411,15 +411,15 @@ CAvailableApplicationInfo* CAvailableApps::FindInfo(const ATL::CStringW& szAppNa
     return NULL;
 }
 
-ATL::CSimpleArray<CAvailableApplicationInfo*> CAvailableApps::FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const
+ATL::CSimpleArray<CAvailableApplicationInfo> CAvailableApps::FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const
 {
-    ATL::CSimpleArray<CAvailableApplicationInfo*> result;
+    ATL::CSimpleArray<CAvailableApplicationInfo> result;
     for (INT i = 0; i < arrAppsNames.GetSize(); ++i)
     {
         CAvailableApplicationInfo* Info = FindInfo(arrAppsNames[i]);
         if (Info)
         {
-            result.Add(Info);
+            result.Add(*Info);
         }
     }
     return result;
index 368836d..76a5e76 100644 (file)
@@ -554,20 +554,20 @@ public:
         }
     }
 
-    ATL::CSimpleArray<CAvailableApplicationInfo*> GetCheckedItems()
+    ATL::CSimpleArray<CAvailableApplicationInfo> GetCheckedItems()
     {
         if (!bHasCheckboxes)
         {
-            return ATL::CSimpleArray<CAvailableApplicationInfo*>();
+            return ATL::CSimpleArray<CAvailableApplicationInfo>();
         }
 
-        ATL::CSimpleArray<CAvailableApplicationInfo*> list;
+        ATL::CSimpleArray<CAvailableApplicationInfo> list;
         for (INT i = 0; i >= 0; i = GetNextItem(i, LVNI_ALL))
         {
             if (GetCheckState(i) != FALSE)
             {
                 CAvailableApplicationInfo* pAppInfo = (CAvailableApplicationInfo*) GetItemData(i);
-                list.Add(pAppInfo);
+                list.Add(*pAppInfo);
             }
         }
         return list;
index aa1aebd..e005250 100644 (file)
@@ -45,6 +45,7 @@ struct CAvailableApplicationInfo
     ATL::CStringW m_szSHA1;
     ATL::CStringW m_szInstalledVersion;
 
+    // Create an object from file
     CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
 
     // Load all info from the file
@@ -100,7 +101,7 @@ public:
     BOOL Enum(INT EnumType, AVAILENUMPROC lpEnumProc);
 
     CAvailableApplicationInfo* FindInfo(const ATL::CStringW& szAppName) const;
-    ATL::CSimpleArray<CAvailableApplicationInfo*> FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const;
+    ATL::CSimpleArray<CAvailableApplicationInfo> FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const;
 
     const ATL::CStringW& GetFolderPath() const;
     const ATL::CStringW& GetAppPath() const;
index 51efdc8..ea607e0 100644 (file)
@@ -26,7 +26,7 @@ public:
                                                  DWORD_PTR dwRefData);
 
     static DWORD WINAPI ThreadFunc(LPVOID Context);
-    static BOOL DownloadListOfApplications(const ATL::CSimpleArray<CAvailableApplicationInfo*>& AppsList, BOOL bIsModal = FALSE);
+    static BOOL DownloadListOfApplications(const ATL::CSimpleArray<CAvailableApplicationInfo>& AppsList, BOOL bIsModal = FALSE);
     static BOOL DownloadApplication(CAvailableApplicationInfo* pAppInfo, BOOL bIsModal = FALSE);
     static VOID DownloadApplicationsDB(LPCWSTR lpUrl);
     static VOID LaunchDownloadDialog(BOOL);
index 6ef55b4..346167c 100644 (file)
@@ -830,20 +830,15 @@ end:
     return 0;
 }
 
-BOOL CDownloadManager::DownloadListOfApplications(const ATL::CSimpleArray<CAvailableApplicationInfo*>& AppsList, BOOL bIsModal)
+BOOL CDownloadManager::DownloadListOfApplications(const ATL::CSimpleArray<CAvailableApplicationInfo>& AppsList, BOOL bIsModal)
 {
     if (AppsList.GetSize() == 0)
-    {
         return FALSE;
-    }
 
     // Initialize shared variables
     for (INT i = 0; i < AppsList.GetSize(); ++i)
     {
-        if (AppsList[i])
-        {
-            AppsToInstallList.Add(*(AppsList[i]));
-        }
+        AppsToInstallList.Add(AppsList[i]); // implicit conversion to DownloadInfo
     }
 
     // Create a dialog and issue a download process
index 328dbb5..b785b9a 100644 (file)
@@ -64,7 +64,7 @@ BOOL UseCmdParameters(LPWSTR lpCmdLine)
     apps.UpdateAppsDB();
     apps.Enum(ENUM_ALL_AVAILABLE, NULL);
 
-    ATL::CSimpleArray<CAvailableApplicationInfo*> arrAppInfo = apps.FindInfoList(arrNames);
+    ATL::CSimpleArray<CAvailableApplicationInfo> arrAppInfo = apps.FindInfoList(arrNames);
     if (arrAppInfo.GetSize() > 0)
     {
         CDownloadManager::DownloadListOfApplications(arrAppInfo, TRUE);