[RAPPS] Don't use CDownloadManager outside loaddlg.cpp
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 28 Apr 2019 03:19:43 +0000 (06:19 +0300)
committerMark Jansen <mark.jansen@reactos.org>
Mon, 19 Aug 2019 22:43:46 +0000 (00:43 +0200)
base/applications/rapps/available.cpp
base/applications/rapps/gui.cpp
base/applications/rapps/include/dialogs.h
base/applications/rapps/loaddlg.cpp
base/applications/rapps/unattended.cpp

index c6ee68f..9a67aba 100644 (file)
@@ -300,7 +300,7 @@ BOOL CAvailableApps::UpdateAppsDB()
         return TRUE;
     }
 
-    CDownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL);
+    DownloadApplicationsDB(APPLICATION_DATABASE_URL);
 
     if (!ExtractFilesFromCab(m_Strings.szCabName, 
                              m_Strings.szCabDir,
index f515143..3695ca7 100644 (file)
@@ -1470,11 +1470,11 @@ private:
             {
                 if (nSelectedApps > 0)
                 {
-                    CDownloadManager::DownloadListOfApplications(m_AvailableApps.GetSelected());
+                    DownloadListOfApplications(m_AvailableApps.GetSelected(), FALSE);
                     UpdateApplicationsList(-1);
                     m_ListView->SetSelected(-1, FALSE);
                 }
-                else if (CDownloadManager::DownloadApplication(m_ListView->GetSelectedData()))
+                else if (DownloadApplication(m_ListView->GetSelectedData(), FALSE))
                 {
                     UpdateApplicationsList(-1);
                 }
index f05b223..5247462 100644 (file)
@@ -5,38 +5,16 @@
 #include <windef.h>
 #include <atlsimpcoll.h>
 
-// Download dialog (loaddlg.cpp)
-class CDowloadingAppsListView;
-struct DownloadInfo;
-
-class CDownloadManager
-{
-    static ATL::CSimpleArray<DownloadInfo> AppsToInstallList;
-    static CDowloadingAppsListView DownloadsListView;
-
-    static VOID Download(const DownloadInfo& DLInfo, BOOL bIsModal = FALSE);
-    static VOID SetProgressMarquee(HWND Item, BOOL Enable);
-
-public:
-    static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-    static LRESULT CALLBACK DownloadProgressProc(HWND hWnd,
-                                                 UINT uMsg,
-                                                 WPARAM wParam,
-                                                 LPARAM lParam,
-                                                 UINT_PTR uIdSubclass,
-                                                 DWORD_PTR dwRefData);
-
-    static DWORD WINAPI ThreadFunc(LPVOID Context);
-    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);
-};
-
 // Settings dialog (settingsdlg.cpp)
 VOID CreateSettingsDlg(HWND hwnd);
 
 // About dialog (aboutdlg.cpp)
 VOID ShowAboutDialog();
 
+//Main window
 VOID ShowMainWindow(INT nShowCmd);
+
+// Download dialogs
+VOID DownloadApplicationsDB(LPCWSTR lpUrl);
+BOOL DownloadApplication(CAvailableApplicationInfo* pAppInfo, BOOL bIsModal);
+BOOL DownloadListOfApplications(const ATL::CSimpleArray<CAvailableApplicationInfo>& AppsList, BOOL bIsModal);
index 4016aa5..c4de1e2 100644 (file)
@@ -384,10 +384,43 @@ inline VOID MessageBox_LoadString(HWND hMainWnd, INT StringID)
     }
 }
 
+
+// Download dialog (loaddlg.cpp)
+class CDownloadManager
+{
+    static ATL::CSimpleArray<DownloadInfo> AppsToInstallList;
+    static CDowloadingAppsListView DownloadsListView;
+
+    static VOID SetProgressMarquee(HWND Item, BOOL Enable);
+
+public:
+    static VOID Add(DownloadInfo info);
+    static VOID Download(const DownloadInfo& DLInfo, BOOL bIsModal = FALSE);
+    static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+    static LRESULT CALLBACK DownloadProgressProc(HWND hWnd,
+                                                 UINT uMsg,
+                                                 WPARAM wParam,
+                                                 LPARAM lParam,
+                                                 UINT_PTR uIdSubclass,
+                                                 DWORD_PTR dwRefData);
+
+    static DWORD WINAPI ThreadFunc(LPVOID Context);
+    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);
+};
+
+
 // CDownloadManager
 ATL::CSimpleArray<DownloadInfo>         CDownloadManager::AppsToInstallList;
 CDowloadingAppsListView                 CDownloadManager::DownloadsListView;
 
+VOID CDownloadManager::Add(DownloadInfo info)
+{
+    AppsToInstallList.Add(info);
+}
+
 VOID CDownloadManager::Download(const DownloadInfo &DLInfo, BOOL bIsModal)
 {
     AppsToInstallList.RemoveAll();
@@ -927,7 +960,28 @@ end:
     return 0;
 }
 
-BOOL CDownloadManager::DownloadListOfApplications(const ATL::CSimpleArray<CAvailableApplicationInfo>& AppsList, BOOL bIsModal)
+//TODO: Reuse the dialog
+VOID CDownloadManager::LaunchDownloadDialog(BOOL bIsModal)
+{
+    if (bIsModal)
+    {
+        DialogBoxW(hInst,
+                   MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
+                   hMainWnd,
+                   DownloadDlgProc);
+    }
+    else
+    {
+        CreateDialogW(hInst,
+                      MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
+                      hMainWnd,
+                      DownloadDlgProc);
+    }
+}
+// CDownloadManager
+
+
+BOOL DownloadListOfApplications(const ATL::CSimpleArray<CAvailableApplicationInfo>& AppsList, BOOL bIsModal)
 {
     if (AppsList.GetSize() == 0)
         return FALSE;
@@ -935,48 +989,29 @@ BOOL CDownloadManager::DownloadListOfApplications(const ATL::CSimpleArray<CAvail
     // Initialize shared variables
     for (INT i = 0; i < AppsList.GetSize(); ++i)
     {
-        AppsToInstallList.Add(AppsList[i]); // implicit conversion to DownloadInfo
+        CDownloadManager::Add(AppsList[i]); // implicit conversion to DownloadInfo
     }
 
     // Create a dialog and issue a download process
-    LaunchDownloadDialog(bIsModal);
+    CDownloadManager::LaunchDownloadDialog(bIsModal);
 
     return TRUE;
 }
 
-BOOL CDownloadManager::DownloadApplication(CAvailableApplicationInfo* pAppInfo, BOOL bIsModal)
+BOOL DownloadApplication(CAvailableApplicationInfo* pAppInfo, BOOL bIsModal)
 {
     if (!pAppInfo)
         return FALSE;
 
-    Download(*pAppInfo, bIsModal);
+    CDownloadManager::Download(*pAppInfo, bIsModal);
     return TRUE;
 }
 
-VOID CDownloadManager::DownloadApplicationsDB(LPCWSTR lpUrl)
+VOID DownloadApplicationsDB(LPCWSTR lpUrl)
 {
     static DownloadInfo DatabaseDLInfo;
     DatabaseDLInfo.szUrl = lpUrl;
     DatabaseDLInfo.szName.LoadStringW(IDS_DL_DIALOG_DB_DISP);
-    Download(DatabaseDLInfo, TRUE);
+    CDownloadManager::Download(DatabaseDLInfo, TRUE);
 }
 
-//TODO: Reuse the dialog
-VOID CDownloadManager::LaunchDownloadDialog(BOOL bIsModal)
-{
-    if (bIsModal)
-    {
-        DialogBoxW(hInst,
-                   MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
-                   hMainWnd,
-                   DownloadDlgProc);
-    }
-    else
-    {
-        CreateDialogW(hInst,
-                      MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
-                      hMainWnd,
-                      DownloadDlgProc);
-    }
-}
-// CDownloadManager
index 7f7f351..2988ff6 100644 (file)
@@ -67,7 +67,7 @@ BOOL UseCmdParameters(LPWSTR lpCmdLine)
     ATL::CSimpleArray<CAvailableApplicationInfo> arrAppInfo = apps.FindInfoList(arrNames);
     if (arrAppInfo.GetSize() > 0)
     {
-        CDownloadManager::DownloadListOfApplications(arrAppInfo, TRUE);
+        DownloadListOfApplications(arrAppInfo, TRUE);
         return TRUE;
     }