[RAPPS] Move database source URL to settings dialog (#2792)

- Add download source in settings dialog, and apply it when download .cab file
- Now user should specify full rappmgr.cab URL
- Check if URL is vaild in settings dialog
- Move source settings to the end of struct (will refactor settings to one value per option later)
This commit is contained in:
He Yang 2020-05-20 01:06:10 +08:00 committed by GitHub
parent fb2a9bb60d
commit a21d959e90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 515 additions and 283 deletions

View file

@ -55,6 +55,14 @@
#define CERT_SUBJECT_INFO "rapps.reactos.org"
#endif
enum DownloadType
{
DLTYPE_APPLICATION,
DLTYPE_DBUPDATE,
DLTYPE_DBUPDATE_UNOFFICIAL
};
enum DownloadStatus
{
DLSTATUS_WAITING = IDS_STATUS_WAITING,
@ -76,13 +84,15 @@ struct DownloadInfo
{
DownloadInfo() {}
DownloadInfo(const CAvailableApplicationInfo& AppInfo)
: szUrl(AppInfo.m_szUrlDownload)
: DLType(DLTYPE_APPLICATION)
, szUrl(AppInfo.m_szUrlDownload)
, szName(AppInfo.m_szName)
, szSHA1(AppInfo.m_szSHA1)
, SizeInBytes(AppInfo.m_SizeBytes)
{
}
DownloadType DLType;
ATL::CStringW szUrl;
ATL::CStringW szName;
ATL::CStringW szSHA1;
@ -546,7 +556,6 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
ULONG dwStatusLen = sizeof(dwStatus);
BOOL bTempfile = FALSE;
BOOL bCab = FALSE;
HINTERNET hOpen = NULL;
HINTERNET hFile = NULL;
@ -581,9 +590,8 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
}
// is this URL an update package for RAPPS? if so store it in a different place
if (InfoArray[iAppId].szUrl == APPLICATION_DATABASE_URL)
if (InfoArray[iAppId].DLType != DLTYPE_APPLICATION)
{
bCab = TRUE;
if (!GetStorageDirectory(Path))
{
ShowLastError(hMainWnd, GetLastError());
@ -592,19 +600,23 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
}
else
{
bCab = FALSE;
Path = SettingsInfo.szDownloadDir;
}
// Change caption to show the currently downloaded app
if (!bCab)
switch(InfoArray[iAppId].DLType)
{
case DLTYPE_APPLICATION:
szNewCaption.Format(szCaption, InfoArray[iAppId].szName.GetString());
}
else
{
break;
case DLTYPE_DBUPDATE:
szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_DOWNLOAD_DISP);
break;
case DLTYPE_DBUPDATE_UNOFFICIAL:
szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP);
break;
}
SetWindowTextW(hDlg, szNewCaption.GetString());
@ -641,7 +653,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
Path += L"\\";
Path += (LPWSTR) (p + 1);
if (!bCab && InfoArray[iAppId].szSHA1[0] && GetFileAttributesW(Path.GetString()) != INVALID_FILE_ATTRIBUTES)
if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] && GetFileAttributesW(Path.GetString()) != INVALID_FILE_ATTRIBUTES)
{
// only open it in case of total correctness
if (VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path))
@ -759,7 +771,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
#ifdef USE_CERT_PINNING
// are we using HTTPS to download the RAPPS update package? check if the certificate is original
if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
(wcscmp(InfoArray[iAppId].szUrl, APPLICATION_DATABASE_URL) == 0))
(InfoArray[iAppId].DLType == DLTYPE_DBUPDATE))
{
CLocalPtr subjectName, issuerName;
CStringW szMsgText;
@ -836,7 +848,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param)
/* if this thing isn't a RAPPS update and it has a SHA-1 checksum
verify its integrity by using the native advapi32.A_SHA1 functions */
if (!bCab && InfoArray[iAppId].szSHA1[0] != 0)
if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] != 0)
{
ATL::CStringW szMsgText;
@ -868,7 +880,7 @@ run:
DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_WAITING_INSTALL);
// run it
if (!bCab)
if (InfoArray[iAppId].DLType == DLTYPE_APPLICATION)
{
SHELLEXECUTEINFOW shExInfo = {0};
shExInfo.cbSize = sizeof(shExInfo);
@ -906,7 +918,7 @@ end:
if (bTempfile)
{
if (bCancelled || (SettingsInfo.bDelInstaller && !bCab))
if (bCancelled || (SettingsInfo.bDelInstaller && (InfoArray[iAppId].DLType == DLTYPE_APPLICATION)))
DeleteFileW(Path.GetString());
}
@ -966,11 +978,12 @@ BOOL DownloadApplication(CAvailableApplicationInfo* pAppInfo, BOOL bIsModal)
return TRUE;
}
VOID DownloadApplicationsDB(LPCWSTR lpUrl)
VOID DownloadApplicationsDB(LPCWSTR lpUrl, BOOL IsOfficial)
{
static DownloadInfo DatabaseDLInfo;
DatabaseDLInfo.szUrl = lpUrl;
DatabaseDLInfo.szName.LoadStringW(IDS_DL_DIALOG_DB_DISP);
DatabaseDLInfo.DLType = IsOfficial ? DLTYPE_DBUPDATE : DLTYPE_DBUPDATE_UNOFFICIAL;
CDownloadManager::Download(DatabaseDLInfo, TRUE);
}