mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[ui] improve check for updates
* Update policy * Better status report * Better UI handling
This commit is contained in:
		
							parent
							
								
									13a6b6b751
								
							
						
					
					
						commit
						303f35d5f1
					
				
					 4 changed files with 38 additions and 18 deletions
				
			
		|  | @ -91,16 +91,16 @@ const char* additional_copyrights = | ||||||
| const char* update_policy = | const char* update_policy = | ||||||
| "{\\rtf1\\ansi{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}{\\f1\\fnil\\fcharset2 Symbol;}}\n" | "{\\rtf1\\ansi{\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}{\\f1\\fnil\\fcharset2 Symbol;}}\n" | ||||||
| "\\fs16\\b Update Policy:\\b0\\line\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" | "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" | "\\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" | "{\\pntext\\f1\\'B7\\tab}The version of the application you use\\par\n" | ||||||
| "{\\pntext\\f1\\'B7\\tab}Your IP address\\line\\pard\n" | "{\\pntext\\f1\\'B7\\tab}Your IP address\\line\\pard\n" | ||||||
| "\\line\n" | "\\line\n" | ||||||
| "For the purpose of generating private usage statistics, we reserve the right to keep the information collected, \n" | "For the purpose of generating private usage statistics, we may 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" | "\\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" | "\\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" | 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 will be required when checking for new versions.\n"  | "Internet access is of course required when checking for updates.\\line\n" | ||||||
| "}"; | "}"; | ||||||
| 
 | 
 | ||||||
| const char* gplv3 = | const char* gplv3 = | ||||||
|  |  | ||||||
							
								
								
									
										21
									
								
								src/net.c
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								src/net.c
									
										
									
									
									
								
							|  | @ -403,6 +403,7 @@ static __inline uint64_t to_uint64_t(uint16_t x[4]) { | ||||||
| static DWORD WINAPI CheckForUpdatesThread(LPVOID param) | static DWORD WINAPI CheckForUpdatesThread(LPVOID param) | ||||||
| { | { | ||||||
| 	BOOL releases_only, found_new_version = FALSE; | 	BOOL releases_only, found_new_version = FALSE; | ||||||
|  | 	int status = 0; | ||||||
| 	const char* server_url = RUFUS_URL "/"; | 	const char* server_url = RUFUS_URL "/"; | ||||||
| 	int i, j, k, verbose = 0, verpos[4]; | 	int i, j, k, verbose = 0, verpos[4]; | ||||||
| 	static const char* archname[] = {"win_x86", "win_x64"}; | 	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)) { | 	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; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -483,6 +485,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param) | ||||||
| 	if (hConnection == NULL) | 	if (hConnection == NULL) | ||||||
| 		goto out; | 		goto out; | ||||||
| 
 | 
 | ||||||
|  | 	status++;	// 2
 | ||||||
| 	releases_only = !GetRegistryKeyBool(REGKEY_INCLUDE_BETAS); | 	releases_only = !GetRegistryKeyBool(REGKEY_INCLUDE_BETAS); | ||||||
| 
 | 
 | ||||||
| 	for (k=0; (k<(releases_only?1:(int)ARRAYSIZE(channel))) && (!found_new_version); k++) { | 	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)) | 		if (!InternetReadFile(hRequest, buf, dwTotalSize, &dwDownloaded) || (dwDownloaded != dwTotalSize)) | ||||||
| 			goto out; | 			goto out; | ||||||
| 
 | 
 | ||||||
|  | 		status++; | ||||||
| 		vuprintf("Successfully downloaded version file (%d bytes)\n", dwTotalSize); | 		vuprintf("Successfully downloaded version file (%d bytes)\n", dwTotalSize); | ||||||
| 
 | 
 | ||||||
| 		parse_update(buf, dwTotalSize+1); | 		parse_update(buf, dwTotalSize+1); | ||||||
|  | @ -593,6 +597,19 @@ out: | ||||||
| 	if (hRequest) InternetCloseHandle(hRequest); | 	if (hRequest) InternetCloseHandle(hRequest); | ||||||
| 	if (hConnection) InternetCloseHandle(hConnection); | 	if (hConnection) InternetCloseHandle(hConnection); | ||||||
| 	if (hSession) InternetCloseHandle(hSession); | 	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
 | 	// Start the new download after cleanup
 | ||||||
| 	if (found_new_version) { | 	if (found_new_version) { | ||||||
| 		// User may have started an operation while we were checking
 | 		// User may have started an operation while we were checking
 | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 206, 316 | IDD_DIALOG DIALOGEX 12, 12, 206, 316 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| EXSTYLE WS_EX_APPWINDOW | EXSTYLE WS_EX_APPWINDOW | ||||||
| CAPTION "Rufus v1.3.0.211" | CAPTION "Rufus v1.3.0.212" | ||||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||||
| BEGIN | BEGIN | ||||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,278,50,14 |     DEFPUSHBUTTON   "Start",IDC_START,94,278,50,14 | ||||||
|  | @ -274,8 +274,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 1,3,0,211 |  FILEVERSION 1,3,0,212 | ||||||
|  PRODUCTVERSION 1,3,0,211 |  PRODUCTVERSION 1,3,0,212 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -292,13 +292,13 @@ BEGIN | ||||||
|         BEGIN |         BEGIN | ||||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" |             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "1.3.0.211" |             VALUE "FileVersion", "1.3.0.212" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "(c) 2011-2012 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "(c) 2011-2012 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" |             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||||
|             VALUE "OriginalFilename", "rufus.exe" |             VALUE "OriginalFilename", "rufus.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "1.3.0.211" |             VALUE "ProductVersion", "1.3.0.212" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
							
								
								
									
										11
									
								
								src/stdlg.c
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								src/stdlg.c
									
										
									
									
									
								
							|  | @ -1134,19 +1134,21 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l | ||||||
| { | { | ||||||
| 	HWND hPolicy; | 	HWND hPolicy; | ||||||
| 	static HWND hFrequency, hBeta; | 	static HWND hFrequency, hBeta; | ||||||
| 	uint32_t freq; | 	int32_t freq; | ||||||
| 
 | 
 | ||||||
| 	switch (message) { | 	switch (message) { | ||||||
| 	case WM_INITDIALOG: | 	case WM_INITDIALOG: | ||||||
| 		SetTitleBarIcon(hDlg); | 		SetTitleBarIcon(hDlg); | ||||||
| 		CenterDialog(hDlg); | 		CenterDialog(hDlg); | ||||||
| 		hFrequency = GetDlgItem(hDlg, IDC_UPDATE_FREQUENCY); | 		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, "Disabled"), -1)); | ||||||
| 		IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Daily (Default)"), 86400)); | 		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, "Weekly"), 604800)); | ||||||
| 		IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Monthly"), 2629800)); | 		IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Monthly"), 2629800)); | ||||||
| 		freq = ReadRegistryKey32(REGKEY_UPDATE_INTERVAL); | 		freq = ReadRegistryKey32(REGKEY_UPDATE_INTERVAL); | ||||||
| 		EnableWindow(GetDlgItem(hDlg, IDC_CHECK_NOW), (freq != 0)); | 		EnableWindow(GetDlgItem(hDlg, IDC_CHECK_NOW), (freq != 0)); | ||||||
|  | 		EnableWindow(hBeta, (freq >= 0)); | ||||||
| 		switch(freq) { | 		switch(freq) { | ||||||
| 		case -1: | 		case -1: | ||||||
| 			IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 0)); | 			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)); | 			IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 4)); | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 		hBeta = GetDlgItem(hDlg, IDC_INCLUDE_BETAS); |  | ||||||
| 		IGNORE_RETVAL(ComboBox_AddStringU(hBeta, "Yes")); | 		IGNORE_RETVAL(ComboBox_AddStringU(hBeta, "Yes")); | ||||||
| 		IGNORE_RETVAL(ComboBox_AddStringU(hBeta, "No")); | 		IGNORE_RETVAL(ComboBox_AddStringU(hBeta, "No")); | ||||||
| 		IGNORE_RETVAL(ComboBox_SetCurSel(hBeta, GetRegistryKeyBool(REGKEY_INCLUDE_BETAS)?0:1)); | 		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: | 		case IDC_UPDATE_FREQUENCY: | ||||||
| 			if (HIWORD(wParam) != CBN_SELCHANGE) | 			if (HIWORD(wParam) != CBN_SELCHANGE) | ||||||
| 				break; | 				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; | 			return (INT_PTR)TRUE; | ||||||
| 		case IDC_INCLUDE_BETAS: | 		case IDC_INCLUDE_BETAS: | ||||||
| 			if (HIWORD(wParam) != CBN_SELCHANGE) | 			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 the update interval is not set, this is the first time we run so prompt the user
 | ||||||
| 	if (ReadRegistryKey32(REGKEY_UPDATE_INTERVAL) == 0) { | 	if (ReadRegistryKey32(REGKEY_UPDATE_INTERVAL) == 0) { | ||||||
| 		enable_updates = Notification(MSG_QUESTION, &more_info, | 		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) { | 		if (!enable_updates) { | ||||||
| 			WriteRegistryKey32(REGKEY_UPDATE_INTERVAL, -1);	// large enough
 | 			WriteRegistryKey32(REGKEY_UPDATE_INTERVAL, -1);	// large enough
 | ||||||
| 			return FALSE; | 			return FALSE; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue