https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4439b538007bdf5dd2f4b3e52e079363f73b946d

commit 4439b538007bdf5dd2f4b3e52e079363f73b946d
Author:     Mark Jansen <[email protected]>
AuthorDate: Tue Mar 17 20:54:45 2020 +0100
Commit:     Mark Jansen <[email protected]>
CommitDate: Sat Apr 4 19:55:31 2020 +0200

    [RAPPS] Use the provided SizeBytes for the progress,
    when the host does not give a file size
---
 base/applications/rapps/available.cpp       |  5 +++--
 base/applications/rapps/include/available.h |  1 +
 base/applications/rapps/loaddlg.cpp         | 21 ++++++++++++++++-----
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/base/applications/rapps/available.cpp 
b/base/applications/rapps/available.cpp
index 16e4fc00775..e029d9c13fd 100644
--- a/base/applications/rapps/available.cpp
+++ b/base/applications/rapps/available.cpp
@@ -19,7 +19,7 @@
 
  // CAvailableApplicationInfo
 CAvailableApplicationInfo::CAvailableApplicationInfo(const ATL::CStringW& 
sFileNameParam)
-    : m_IsSelected(FALSE), m_LicenseType(LICENSE_NONE), 
m_sFileName(sFileNameParam),
+    : m_IsSelected(FALSE), m_LicenseType(LICENSE_NONE), m_SizeBytes(0), 
m_sFileName(sFileNameParam),
     m_IsInstalled(FALSE), m_HasLanguageInfo(FALSE), 
m_HasInstalledVersion(FALSE)
 {
     RetrieveGeneralInfo();
@@ -153,7 +153,8 @@ VOID CAvailableApplicationInfo::RetrieveSize()
         GetString(L"Size", m_szSize);
         return;
     }
- 
+
+    m_SizeBytes = iSizeBytes;
     StrFormatByteSizeW(iSizeBytes, m_szSize.GetBuffer(MAX_PATH), MAX_PATH);
     m_szSize.ReleaseBuffer();
 }
diff --git a/base/applications/rapps/include/available.h 
b/base/applications/rapps/include/available.h
index f5beb9e44cf..5e3a464fc03 100644
--- a/base/applications/rapps/include/available.h
+++ b/base/applications/rapps/include/available.h
@@ -37,6 +37,7 @@ struct CAvailableApplicationInfo
     ATL::CStringW m_szUrlDownload;
     ATL::CStringW m_szCDPath;
     ATL::CSimpleArray<LCID> m_LanguageLCIDs;
+    ULONG m_SizeBytes;
 
     // Caching mechanism related entries
     ATL::CStringW m_sFileName;
diff --git a/base/applications/rapps/loaddlg.cpp 
b/base/applications/rapps/loaddlg.cpp
index 5b31ed06f0e..c5b7b06c880 100644
--- a/base/applications/rapps/loaddlg.cpp
+++ b/base/applications/rapps/loaddlg.cpp
@@ -73,13 +73,17 @@ struct DownloadInfo
 {
     DownloadInfo() {}
     DownloadInfo(const CAvailableApplicationInfo& AppInfo)
-        :szUrl(AppInfo.m_szUrlDownload), szName(AppInfo.m_szName), 
szSHA1(AppInfo.m_szSHA1)
+        : szUrl(AppInfo.m_szUrlDownload)
+        , szName(AppInfo.m_szName)
+        , szSHA1(AppInfo.m_szSHA1)
+        , SizeInBytes(AppInfo.m_SizeBytes)
     {
     }
 
     ATL::CStringW szUrl;
     ATL::CStringW szName;
     ATL::CStringW szSHA1;
+    ULONG SizeInBytes;
 };
 
 struct DownloadParam
@@ -669,8 +673,7 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
             // query content length
             HttpQueryInfoW(hFile, HTTP_QUERY_CONTENT_LENGTH | 
HTTP_QUERY_FLAG_NUMBER, &dwContentLen, &dwStatusLen, NULL);
         }
-
-        if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
+        else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
         {
             // force passive mode on FTP
             hFile = InternetOpenUrlW(hOpen, 
InfoArray[iAppId].szUrl.GetString(), NULL, 0,
@@ -687,8 +690,16 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
 
         if (!dwContentLen)
         {
-            // content-length is not known, enable marquee mode
-            ProgressBar.SetMarquee(TRUE);
+            // Someone was nice enough to add this, let's use it
+            if (InfoArray[iAppId].SizeInBytes)
+            {
+                dwContentLen = InfoArray[iAppId].SizeInBytes;
+            }
+            else
+            {
+                // content-length is not known, enable marquee mode
+                ProgressBar.SetMarquee(TRUE);
+            }
         }
 
         free(urlComponents.lpszScheme);

Reply via email to