mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 01:15:42 +00:00
[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:
parent
fb2a9bb60d
commit
a21d959e90
31 changed files with 515 additions and 283 deletions
|
@ -50,6 +50,31 @@ BOOL ChooseFolder(HWND hwnd)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
BOOL IsUrlValid(const WCHAR * Url)
|
||||
{
|
||||
URL_COMPONENTSW UrlComponmentInfo = { 0 };
|
||||
UrlComponmentInfo.dwStructSize = sizeof(UrlComponmentInfo);
|
||||
UrlComponmentInfo.dwSchemeLength = 1;
|
||||
|
||||
BOOL bSuccess = InternetCrackUrlW(Url, wcslen(Url), 0, &UrlComponmentInfo);
|
||||
if(!bSuccess)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch(UrlComponmentInfo.nScheme)
|
||||
{
|
||||
case INTERNET_SCHEME_HTTP:
|
||||
case INTERNET_SCHEME_HTTPS:
|
||||
case INTERNET_SCHEME_FTP:
|
||||
// supported
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
inline BOOL IsCheckedDlgItem(HWND hDlg, INT nIDDlgItem)
|
||||
|
@ -79,7 +104,12 @@ namespace
|
|||
EnableWindow(GetDlgItem(hDlg, IDC_PROXY_SERVER), FALSE);
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_NO_PROXY_FOR), FALSE);
|
||||
}
|
||||
|
||||
CheckRadioButton(hDlg, IDC_SOURCE_DEFAULT, IDC_USE_SOURCE, Info->bUseSource ? IDC_USE_SOURCE : IDC_SOURCE_DEFAULT);
|
||||
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_SOURCE_URL), Info->bUseSource);
|
||||
|
||||
SetWindowTextW(GetDlgItem(hDlg, IDC_SOURCE_URL), Info->szSourceURL);
|
||||
SetWindowTextW(GetDlgItem(hDlg, IDC_PROXY_SERVER), Info->szProxyServer);
|
||||
SetWindowTextW(GetDlgItem(hDlg, IDC_NO_PROXY_FOR), Info->szNoProxyFor);
|
||||
}
|
||||
|
@ -119,6 +149,16 @@ namespace
|
|||
NewSettingsInfo.bDelInstaller = IsCheckedDlgItem(hDlg, IDC_DEL_AFTER_INSTALL);
|
||||
break;
|
||||
|
||||
case IDC_SOURCE_DEFAULT:
|
||||
NewSettingsInfo.bUseSource = FALSE;
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_SOURCE_URL), NewSettingsInfo.bUseSource);
|
||||
break;
|
||||
|
||||
case IDC_USE_SOURCE:
|
||||
NewSettingsInfo.bUseSource = TRUE;
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_SOURCE_URL), NewSettingsInfo.bUseSource);
|
||||
break;
|
||||
|
||||
case IDC_PROXY_DEFAULT:
|
||||
NewSettingsInfo.Proxy = 0;
|
||||
EnableWindow(GetDlgItem(hDlg, IDC_PROXY_SERVER), FALSE);
|
||||
|
@ -145,6 +185,7 @@ namespace
|
|||
case IDOK:
|
||||
{
|
||||
ATL::CStringW szDir;
|
||||
ATL::CStringW szSource;
|
||||
ATL::CStringW szProxy;
|
||||
ATL::CStringW szNoProxy;
|
||||
DWORD dwAttr;
|
||||
|
@ -153,6 +194,10 @@ namespace
|
|||
szDir.GetBuffer(MAX_PATH), MAX_PATH);
|
||||
szDir.ReleaseBuffer();
|
||||
|
||||
GetWindowTextW(GetDlgItem(hDlg, IDC_SOURCE_URL),
|
||||
szSource.GetBuffer(INTERNET_MAX_URL_LENGTH), INTERNET_MAX_URL_LENGTH);
|
||||
szSource.ReleaseBuffer();
|
||||
|
||||
GetWindowTextW(GetDlgItem(hDlg, IDC_PROXY_SERVER),
|
||||
szProxy.GetBuffer(MAX_PATH), MAX_PATH);
|
||||
szProxy.ReleaseBuffer();
|
||||
|
@ -196,6 +241,24 @@ namespace
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(NewSettingsInfo.bUseSource && !IsUrlValid(szSource.GetString()))
|
||||
{
|
||||
ATL::CStringW szMsgText;
|
||||
szMsgText.LoadStringW(IDS_URL_INVALID);
|
||||
|
||||
MessageBoxW(hDlg, szMsgText.GetString(), NULL, 0);
|
||||
SetFocus(GetDlgItem(hDlg, IDC_SOURCE_URL));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ATL::CStringW::CopyChars(NewSettingsInfo.szSourceURL,
|
||||
_countof(NewSettingsInfo.szSourceURL),
|
||||
szSource.GetString(),
|
||||
szSource.GetLength() + 1);
|
||||
}
|
||||
|
||||
SettingsInfo = NewSettingsInfo;
|
||||
SaveSettings(GetParent(hDlg));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue