mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 17:56:06 +00:00
[RAPPS] Add support for a rapps db with the file:/// scheme
This makes it easier to test locally
This commit is contained in:
parent
a7c1f9a014
commit
4f25a47677
3 changed files with 40 additions and 9 deletions
|
@ -58,3 +58,9 @@ INT GetSystemColorDepth();
|
||||||
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime);
|
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime);
|
||||||
|
|
||||||
BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle);
|
BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle);
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class CLocalPtr : public CHeapPtr<T, CLocalAllocator>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -305,9 +305,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_CERT_PINNING
|
#ifdef USE_CERT_PINNING
|
||||||
typedef CHeapPtr<char, CLocalAllocator> CLocalPtr;
|
static BOOL CertGetSubjectAndIssuer(HINTERNET hFile, CLocalPtr<char>& subjectInfo, CLocalPtr<char>& issuerInfo)
|
||||||
|
|
||||||
static BOOL CertGetSubjectAndIssuer(HINTERNET hFile, CLocalPtr& subjectInfo, CLocalPtr& issuerInfo)
|
|
||||||
{
|
{
|
||||||
DWORD certInfoLength;
|
DWORD certInfoLength;
|
||||||
INTERNET_CERTIFICATE_INFOA certInfo;
|
INTERNET_CERTIFICATE_INFOA certInfo;
|
||||||
|
@ -528,7 +526,7 @@ VOID ShowLastError(
|
||||||
HWND hWndOwner,
|
HWND hWndOwner,
|
||||||
DWORD dwLastError)
|
DWORD dwLastError)
|
||||||
{
|
{
|
||||||
LPWSTR lpMsg;
|
CLocalPtr<WCHAR> lpMsg;
|
||||||
|
|
||||||
if (!FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
if (!FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
|
@ -543,7 +541,6 @@ VOID ShowLastError(
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBoxW(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR);
|
MessageBoxW(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR);
|
||||||
LocalFree(lpMsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
|
@ -724,7 +721,8 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
|
|
||||||
dwContentLen = 0;
|
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,
|
hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
|
||||||
dwUrlConnectFlags,
|
dwUrlConnectFlags,
|
||||||
|
@ -754,7 +752,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
|
else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
|
||||||
{
|
{
|
||||||
// force passive mode on 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,
|
dwUrlConnectFlags | INTERNET_FLAG_PASSIVE,
|
||||||
0);
|
0);
|
||||||
if (!hFile)
|
if (!hFile)
|
||||||
|
@ -765,6 +763,31 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
|
|
||||||
dwContentLen = FtpGetFileSize(hFile, &dwStatus);
|
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)
|
if (!dwContentLen)
|
||||||
{
|
{
|
||||||
|
@ -787,7 +810,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
||||||
if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
|
if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
|
||||||
(InfoArray[iAppId].DLType == DLTYPE_DBUPDATE))
|
(InfoArray[iAppId].DLType == DLTYPE_DBUPDATE))
|
||||||
{
|
{
|
||||||
CLocalPtr subjectName, issuerName;
|
CLocalPtr<char> subjectName, issuerName;
|
||||||
CStringW szMsgText;
|
CStringW szMsgText;
|
||||||
bool bAskQuestion = false;
|
bool bAskQuestion = false;
|
||||||
if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName))
|
if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName))
|
||||||
|
@ -932,6 +955,7 @@ end:
|
||||||
if (hOut != INVALID_HANDLE_VALUE)
|
if (hOut != INVALID_HANDLE_VALUE)
|
||||||
CloseHandle(hOut);
|
CloseHandle(hOut);
|
||||||
|
|
||||||
|
if (hFile)
|
||||||
InternetCloseHandle(hFile);
|
InternetCloseHandle(hFile);
|
||||||
InternetCloseHandle(hOpen);
|
InternetCloseHandle(hOpen);
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ BOOL IsUrlValid(const WCHAR * Url)
|
||||||
case INTERNET_SCHEME_HTTP:
|
case INTERNET_SCHEME_HTTP:
|
||||||
case INTERNET_SCHEME_HTTPS:
|
case INTERNET_SCHEME_HTTPS:
|
||||||
case INTERNET_SCHEME_FTP:
|
case INTERNET_SCHEME_FTP:
|
||||||
|
case INTERNET_SCHEME_FILE:
|
||||||
// supported
|
// supported
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue