[ui] improve check for updates

* Update policy
* Better status report
* Better UI handling
This commit is contained in:
Pete Batard 2012-12-16 00:29:37 +00:00
parent 13a6b6b751
commit 303f35d5f1
4 changed files with 38 additions and 18 deletions

View File

@ -91,16 +91,16 @@ const char* additional_copyrights =
const char* update_policy =
"{\\rtf1\\ansi{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}{\\f1\\fnil\\fcharset2 Symbol;}}\n"
"\\fs16\\b Update Policy:\\b0\\line\n"
"If you choose to allow update checks, you agree that the following information may be collected on our server(s):\\par\n"
"\\pard{\\pntext\\f1\\'B7\\tab}{\\*\\pn\\pnlvlblt\\pnf2\\pnindent0{\\pntxtb\\'B7}}\\fi-150\\li220 Your Operating System's architecture and version\\par\n"
"{\\pntext\\f1\\'B7\\tab}The version of the application\\par\n"
"If you choose to allow this program to check for application updates, you agree that the following information may be collected on our server(s):\\par\n"
"\\pard{\\pntext\\f1\\'B7\\tab}{\\*\\pn\\pnlvlblt\\pnf2\\pnindent0{\\pntxtb\\'B7}}\\fi-150\\li220 Your operating system's architecture and version\\par\n"
"{\\pntext\\f1\\'B7\\tab}The version of the application you use\\par\n"
"{\\pntext\\f1\\'B7\\tab}Your IP address\\line\\pard\n"
"\\line\n"
"For the purpose of generating private usage statistics, we reserve the right to keep the information collected, \n"
"\\b for at most a year\\b0 . However \\b none\\b0 of the data provided above will be disclosed to third parties.\\line\n\\line\n"
"For the purpose of generating private usage statistics, we may keep the information collected, \n"
"\\b for at most a year\\b0 . However, we will not willingly disclose any of this individual data to third parties.\\line\n\\line\n"
"\\b Update Process:\\b0\\line\n"
APPLICATION_NAME " does not install or run any background services, therefore update checks are only performed when the main application is running.\\line\n"
"Internet access will be required when checking for new versions.\n"
APPLICATION_NAME " does not install or run background services, therefore update checks are performed only when the main application is running.\\line\n"
"Internet access is of course required when checking for updates.\\line\n"
"}";
const char* gplv3 =

View File

@ -403,6 +403,7 @@ static __inline uint64_t to_uint64_t(uint16_t x[4]) {
static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
{
BOOL releases_only, found_new_version = FALSE;
int status = 0;
const char* server_url = RUFUS_URL "/";
int i, j, k, verbose = 0, verpos[4];
static const char* archname[] = {"win_x86", "win_x64"};
@ -453,10 +454,11 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
}
}
PrintStatus(3000, FALSE, "Checking for " APPLICATION_NAME " updates...\n");
PrintStatus(3000, TRUE, "Checking for " APPLICATION_NAME " updates...\n");
status++; // 1
if (!GetVersionExA(&os_version)) {
vuprintf("Could not read Windows version - Check for updates cancelled.\n");
uprintf("Could not read Windows version - Check for updates cancelled.\n");
goto out;
}
@ -483,6 +485,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
if (hConnection == NULL)
goto out;
status++; // 2
releases_only = !GetRegistryKeyBool(REGKEY_INCLUDE_BETAS);
for (k=0; (k<(releases_only?1:(int)ARRAYSIZE(channel))) && (!found_new_version); k++) {
@ -572,6 +575,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
if (!InternetReadFile(hRequest, buf, dwTotalSize, &dwDownloaded) || (dwDownloaded != dwTotalSize))
goto out;
status++;
vuprintf("Successfully downloaded version file (%d bytes)\n", dwTotalSize);
parse_update(buf, dwTotalSize+1);
@ -593,6 +597,19 @@ out:
if (hRequest) InternetCloseHandle(hRequest);
if (hConnection) InternetCloseHandle(hConnection);
if (hSession) InternetCloseHandle(hSession);
switch(status) {
case 1:
PrintStatus(3000, TRUE, "Updates: Unable to connect to the internet.\n");
break;
case 2:
PrintStatus(3000, TRUE, "Updates: Unable to access version data.\n");
break;
case 3:
PrintStatus(3000, FALSE, " %s new version of " APPLICATION_NAME " %s\n",
found_new_version?"A":"No", found_new_version?"is available!":"was found.");
default:
break;
}
// Start the new download after cleanup
if (found_new_version) {
// User may have started an operation while we were checking

View File

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 316
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.3.0.211"
CAPTION "Rufus v1.3.0.212"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
@ -274,8 +274,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,211
PRODUCTVERSION 1,3,0,211
FILEVERSION 1,3,0,212
PRODUCTVERSION 1,3,0,212
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -292,13 +292,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.3.0.211"
VALUE "FileVersion", "1.3.0.212"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "(c) 2011-2012 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.3.0.211"
VALUE "ProductVersion", "1.3.0.212"
END
END
BLOCK "VarFileInfo"

View File

@ -1134,19 +1134,21 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
{
HWND hPolicy;
static HWND hFrequency, hBeta;
uint32_t freq;
int32_t freq;
switch (message) {
case WM_INITDIALOG:
SetTitleBarIcon(hDlg);
CenterDialog(hDlg);
hFrequency = GetDlgItem(hDlg, IDC_UPDATE_FREQUENCY);
hBeta = GetDlgItem(hDlg, IDC_INCLUDE_BETAS);
IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Disabled"), -1));
IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Daily (Default)"), 86400));
IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Weekly"), 604800));
IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Monthly"), 2629800));
freq = ReadRegistryKey32(REGKEY_UPDATE_INTERVAL);
EnableWindow(GetDlgItem(hDlg, IDC_CHECK_NOW), (freq != 0));
EnableWindow(hBeta, (freq >= 0));
switch(freq) {
case -1:
IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 0));
@ -1166,7 +1168,6 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 4));
break;
}
hBeta = GetDlgItem(hDlg, IDC_INCLUDE_BETAS);
IGNORE_RETVAL(ComboBox_AddStringU(hBeta, "Yes"));
IGNORE_RETVAL(ComboBox_AddStringU(hBeta, "No"));
IGNORE_RETVAL(ComboBox_SetCurSel(hBeta, GetRegistryKeyBool(REGKEY_INCLUDE_BETAS)?0:1));
@ -1189,7 +1190,9 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
case IDC_UPDATE_FREQUENCY:
if (HIWORD(wParam) != CBN_SELCHANGE)
break;
WriteRegistryKey32(REGKEY_UPDATE_INTERVAL, (DWORD)ComboBox_GetItemData(hFrequency, ComboBox_GetCurSel(hFrequency)));
freq = ComboBox_GetItemData(hFrequency, ComboBox_GetCurSel(hFrequency));
WriteRegistryKey32(REGKEY_UPDATE_INTERVAL, (DWORD)freq);
EnableWindow(hBeta, (freq >= 0));
return (INT_PTR)TRUE;
case IDC_INCLUDE_BETAS:
if (HIWORD(wParam) != CBN_SELCHANGE)
@ -1220,7 +1223,7 @@ BOOL SetUpdateCheck(void)
// If the update interval is not set, this is the first time we run so prompt the user
if (ReadRegistryKey32(REGKEY_UPDATE_INTERVAL) == 0) {
enable_updates = Notification(MSG_QUESTION, &more_info,
APPLICATION_NAME " updates", "Do you want to allow " APPLICATION_NAME " to check for updates?\n");
APPLICATION_NAME " update policy", "Do you want to allow " APPLICATION_NAME " to check for application updates?\n");
if (!enable_updates) {
WriteRegistryKey32(REGKEY_UPDATE_INTERVAL, -1); // large enough
return FALSE;