https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4f25a47677b375a0b87ea…
commit 4f25a47677b375a0b87eab829973fdba096a5b33
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Sep 6 23:13:21 2020 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Oct 11 17:01:05 2020 +0200
[RAPPS] Add support for a rapps db with the file:/// scheme
This makes it easier to test locally
---
base/applications/rapps/include/misc.h | 6 +++++
base/applications/rapps/loaddlg.cpp | 42 ++++++++++++++++++++++++++-------
base/applications/rapps/settingsdlg.cpp | 1 +
3 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/base/applications/rapps/include/misc.h
b/base/applications/rapps/include/misc.h
index 58890958f3d..86456b0871b 100644
--- a/base/applications/rapps/include/misc.h
+++ b/base/applications/rapps/include/misc.h
@@ -58,3 +58,9 @@ INT GetSystemColorDepth();
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime);
BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle);
+
+template<class T>
+class CLocalPtr : public CHeapPtr<T, CLocalAllocator>
+{
+};
+
diff --git a/base/applications/rapps/loaddlg.cpp b/base/applications/rapps/loaddlg.cpp
index 505e48643d7..22f47597c38 100644
--- a/base/applications/rapps/loaddlg.cpp
+++ b/base/applications/rapps/loaddlg.cpp
@@ -305,9 +305,7 @@ public:
};
#ifdef USE_CERT_PINNING
-typedef CHeapPtr<char, CLocalAllocator> CLocalPtr;
-
-static BOOL CertGetSubjectAndIssuer(HINTERNET hFile, CLocalPtr& subjectInfo,
CLocalPtr& issuerInfo)
+static BOOL CertGetSubjectAndIssuer(HINTERNET hFile, CLocalPtr<char>&
subjectInfo, CLocalPtr<char>& issuerInfo)
{
DWORD certInfoLength;
INTERNET_CERTIFICATE_INFOA certInfo;
@@ -528,7 +526,7 @@ VOID ShowLastError(
HWND hWndOwner,
DWORD dwLastError)
{
- LPWSTR lpMsg;
+ CLocalPtr<WCHAR> lpMsg;
if (!FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
@@ -543,7 +541,6 @@ VOID ShowLastError(
}
MessageBoxW(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR);
- LocalFree(lpMsg);
}
unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
@@ -724,7 +721,8 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
dwContentLen = 0;
- if (urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme ==
INTERNET_SCHEME_HTTPS)
+ if (urlComponents.nScheme == INTERNET_SCHEME_HTTP ||
+ urlComponents.nScheme == INTERNET_SCHEME_HTTPS)
{
hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL,
0,
dwUrlConnectFlags,
@@ -754,7 +752,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
{
// force passive mode on FTP
- hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL,
0,
+ hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl, NULL, 0,
dwUrlConnectFlags | INTERNET_FLAG_PASSIVE,
0);
if (!hFile)
@@ -765,6 +763,31 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
dwContentLen = FtpGetFileSize(hFile, &dwStatus);
}
+ else if (urlComponents.nScheme == INTERNET_SCHEME_FILE)
+ {
+ // Add support for the file scheme so testing locally is simpler
+ WCHAR LocalFilePath[MAX_PATH];
+ DWORD cchPath = _countof(LocalFilePath);
+ // Ideally we would use PathCreateFromUrlAlloc here, but that is not exported
(yet)
+ HRESULT hr = PathCreateFromUrlW(InfoArray[iAppId].szUrl, LocalFilePath,
&cchPath, 0);
+ if (SUCCEEDED(hr))
+ {
+ if (CopyFileW(LocalFilePath, Path, FALSE))
+ {
+ goto run;
+ }
+ else
+ {
+ ShowLastError(hMainWnd, GetLastError());
+ goto end;
+ }
+ }
+ else
+ {
+ ShowLastError(hMainWnd, hr);
+ goto end;
+ }
+ }
if (!dwContentLen)
{
@@ -787,7 +810,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
(InfoArray[iAppId].DLType == DLTYPE_DBUPDATE))
{
- CLocalPtr subjectName, issuerName;
+ CLocalPtr<char> subjectName, issuerName;
CStringW szMsgText;
bool bAskQuestion = false;
if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName))
@@ -932,7 +955,8 @@ end:
if (hOut != INVALID_HANDLE_VALUE)
CloseHandle(hOut);
- InternetCloseHandle(hFile);
+ if (hFile)
+ InternetCloseHandle(hFile);
InternetCloseHandle(hOpen);
if (bTempfile)
diff --git a/base/applications/rapps/settingsdlg.cpp
b/base/applications/rapps/settingsdlg.cpp
index d1f36519d9a..50f69faf55e 100644
--- a/base/applications/rapps/settingsdlg.cpp
+++ b/base/applications/rapps/settingsdlg.cpp
@@ -66,6 +66,7 @@ BOOL IsUrlValid(const WCHAR * Url)
case INTERNET_SCHEME_HTTP:
case INTERNET_SCHEME_HTTPS:
case INTERNET_SCHEME_FTP:
+ case INTERNET_SCHEME_FILE:
// supported
return TRUE;