mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[net] add ISO selection after successful download
* Also use UM_TIMER_START message to start timed operations
This commit is contained in:
		
							parent
							
								
									e073fb47b0
								
							
						
					
					
						commit
						2a77763dc3
					
				
					 4 changed files with 45 additions and 33 deletions
				
			
		
							
								
								
									
										31
									
								
								src/net.c
									
										
									
									
									
								
							
							
						
						
									
										31
									
								
								src/net.c
									
										
									
									
									
								
							|  | @ -825,8 +825,8 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) | ||||||
| 	static_sprintf(icon_path, "%s%s.ico", temp_dir, APPLICATION_NAME); | 	static_sprintf(icon_path, "%s%s.ico", temp_dir, APPLICATION_NAME); | ||||||
| 	ExtractAppIcon(icon_path, TRUE); | 	ExtractAppIcon(icon_path, TRUE); | ||||||
| 
 | 
 | ||||||
| 	PrintInfo(0, MSG_149); | //#define FORCE_URL "https://github.com/pbatard/rufus/raw/master/res/loc/test/windows_to_go.iso"
 | ||||||
| 
 | #if !defined(FORCE_URL) | ||||||
| #if defined(RUFUS_TEST) | #if defined(RUFUS_TEST) | ||||||
| 	// In test mode, just use our local script
 | 	// In test mode, just use our local script
 | ||||||
| 	static_strcpy(script_path, "D:\\Projects\\Fido\\Fido.ps1"); | 	static_strcpy(script_path, "D:\\Projects\\Fido\\Fido.ps1"); | ||||||
|  | @ -844,7 +844,12 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) | ||||||
| 		} | 		} | ||||||
| 		free(sig); | 		free(sig); | ||||||
| 		uprintf("Signature is valid ✓"); | 		uprintf("Signature is valid ✓"); | ||||||
|  | 		SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0); | ||||||
|  | 		SetTaskbarProgressState(TASKBAR_NORMAL); | ||||||
|  | 		SetTaskbarProgressValue(0, MAX_PROGRESS); | ||||||
|  | 		SendMessage(hProgress, PBM_SETPOS, 0, 0); | ||||||
| 	} | 	} | ||||||
|  | 	PrintInfo(0, MSG_149); | ||||||
| 
 | 
 | ||||||
| 	assert((fido_script != NULL) && (fido_len != 0)); | 	assert((fido_script != NULL) && (fido_len != 0)); | ||||||
| 
 | 
 | ||||||
|  | @ -881,7 +886,11 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) | ||||||
| 	FormatStatus = RunCommand(cmdline, app_dir, TRUE); | 	FormatStatus = RunCommand(cmdline, app_dir, TRUE); | ||||||
| 	if ((FormatStatus == 0) && PeekNamedPipe(hPipe, NULL, dwPipeSize, NULL, &dwAvail, NULL) && (dwAvail != 0)) { | 	if ((FormatStatus == 0) && PeekNamedPipe(hPipe, NULL, dwPipeSize, NULL, &dwAvail, NULL) && (dwAvail != 0)) { | ||||||
| 		url = malloc(dwAvail + 1); | 		url = malloc(dwAvail + 1); | ||||||
| 		if ((url != NULL) && ReadFile(hPipe, url, dwAvail, &dwSize, NULL) && (dwSize != 0)) { | 		if ((url != NULL) && ReadFile(hPipe, url, dwAvail, &dwSize, NULL) && (dwSize > 4)) { | ||||||
|  | #else | ||||||
|  | 	{	{	url = strdup(FORCE_URL); | ||||||
|  | 			dwSize = (DWORD)strlen(FORCE_URL); | ||||||
|  | #endif | ||||||
| 			IMG_SAVE img_save = { 0 }; | 			IMG_SAVE img_save = { 0 }; | ||||||
| 			url[dwSize] = 0; | 			url[dwSize] = 0; | ||||||
| 			for (i = dwSize - 1; i != 0; i--) { | 			for (i = dwSize - 1; i != 0; i--) { | ||||||
|  | @ -893,12 +902,10 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) | ||||||
| 			p = strstr(iso_name, ".iso"); | 			p = strstr(iso_name, ".iso"); | ||||||
| 			if (p != NULL) { | 			if (p != NULL) { | ||||||
| 				p[4] = 0; | 				p[4] = 0; | ||||||
| 			} else { | 			} else for (i = 0; i < strlen(iso_name); i++) { | ||||||
| 				for (i = 0; i < strlen(iso_name); i++) { | 				if (iso_name[i] == '?') { | ||||||
| 					if (iso_name[i] == '?') { | 					iso_name[i] = 0; | ||||||
| 						iso_name[i] = 0; | 					break; | ||||||
| 						break; |  | ||||||
| 					} |  | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | @ -909,13 +916,13 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) | ||||||
| 				goto out; | 				goto out; | ||||||
| 			} | 			} | ||||||
| 			// Download the ISO and report errors if any
 | 			// Download the ISO and report errors if any
 | ||||||
| 			// TODO: We may want to start a timer here too...
 |  | ||||||
| 			SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0); | 			SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0); | ||||||
| 			SetTaskbarProgressState(TASKBAR_NORMAL); | 			SetTaskbarProgressState(TASKBAR_NORMAL); | ||||||
| 			SetTaskbarProgressValue(0, MAX_PROGRESS); | 			SetTaskbarProgressValue(0, MAX_PROGRESS); | ||||||
| 			SendMessage(hProgress, PBM_SETPOS, 0, 0); | 			SendMessage(hProgress, PBM_SETPOS, 0, 0); | ||||||
| 			FormatStatus = 0; | 			FormatStatus = 0; | ||||||
| 			format_op_in_progress = TRUE; | 			format_op_in_progress = TRUE; | ||||||
|  | 			SendMessage(hMainDialog, UM_TIMER_START, 0, 0); | ||||||
| 			if (DownloadToFileOrBuffer(url, img_save.ImagePath, NULL, hMainDialog) == 0) { | 			if (DownloadToFileOrBuffer(url, img_save.ImagePath, NULL, hMainDialog) == 0) { | ||||||
| 				if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) { | 				if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) { | ||||||
| 					uprintf("Download cancelled by user"); | 					uprintf("Download cancelled by user"); | ||||||
|  | @ -934,7 +941,9 @@ static DWORD WINAPI DownloadISOThread(LPVOID param) | ||||||
| 					Notification(MSG_ERROR, NULL, NULL, lmprintf(MSG_194, iso_name), lmprintf(MSG_043, WinInetErrorString())); | 					Notification(MSG_ERROR, NULL, NULL, lmprintf(MSG_194, iso_name), lmprintf(MSG_043, WinInetErrorString())); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			// TODO: If download was successful we should select and scan the ISO
 | 			// Download was successful => Select and scan the ISO
 | ||||||
|  | 			image_path = safe_strdup(img_save.ImagePath); | ||||||
|  | 			PostMessage(hMainDialog, UM_SELECT_ISO, 0, 0); | ||||||
| 			format_op_in_progress = FALSE; | 			format_op_in_progress = FALSE; | ||||||
| 			safe_free(img_save.ImagePath); | 			safe_free(img_save.ImagePath); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
							
								
								
									
										35
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										35
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -1710,10 +1710,7 @@ static void SaveVHD(void) | ||||||
| 				if (format_thid != NULL) { | 				if (format_thid != NULL) { | ||||||
| 					uprintf("\r\nSave to VHD operation started"); | 					uprintf("\r\nSave to VHD operation started"); | ||||||
| 					PrintInfo(0, -1); | 					PrintInfo(0, -1); | ||||||
| 					timer = 0; | 					SendMessage(hMainDialog, UM_TIMER_START, 0, 0); | ||||||
| 					static_sprintf(szTimer, "00:00:00"); |  | ||||||
| 					SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); |  | ||||||
| 					SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); |  | ||||||
| 				} else { | 				} else { | ||||||
| 					uprintf("Unable to start VHD save thread"); | 					uprintf("Unable to start VHD save thread"); | ||||||
| 					FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD); | 					FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD); | ||||||
|  | @ -1776,10 +1773,7 @@ static void SaveISO(void) | ||||||
| 	if (format_thid != NULL) { | 	if (format_thid != NULL) { | ||||||
| 		uprintf("\r\nSave to ISO operation started"); | 		uprintf("\r\nSave to ISO operation started"); | ||||||
| 		PrintInfo(0, -1); | 		PrintInfo(0, -1); | ||||||
| 		timer = 0; | 		SendMessage(hMainDialog, UM_TIMER_START, 0, 0); | ||||||
| 		static_sprintf(szTimer, "00:00:00"); |  | ||||||
| 		SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); |  | ||||||
| 		SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); |  | ||||||
| 	} else { | 	} else { | ||||||
| 		uprintf("Unable to start ISO save thread"); | 		uprintf("Unable to start ISO save thread"); | ||||||
| 		FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD); | 		FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD); | ||||||
|  | @ -2254,10 +2248,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 				format_thid = CreateThread(NULL, 0, SumThread, (LPVOID)thread_affinity, 0, NULL); | 				format_thid = CreateThread(NULL, 0, SumThread, (LPVOID)thread_affinity, 0, NULL); | ||||||
| 				if (format_thid != NULL) { | 				if (format_thid != NULL) { | ||||||
| 					PrintInfo(0, -1); | 					PrintInfo(0, -1); | ||||||
| 					timer = 0; | 					SendMessage(hMainDialog, UM_TIMER_START, 0, 0); | ||||||
| 					static_sprintf(szTimer, "00:00:00"); |  | ||||||
| 					SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); |  | ||||||
| 					SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); |  | ||||||
| 				} else { | 				} else { | ||||||
| 					uprintf("Unable to start checksum thread"); | 					uprintf("Unable to start checksum thread"); | ||||||
| 					FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD); | 					FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD); | ||||||
|  | @ -2284,6 +2275,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 		CreateTooltip(GetDlgItem(hMainDialog, IDS_CSM_HELP_TXT), lmprintf((tt == TT_UEFI) ? MSG_152 : MSG_151), 30000); | 		CreateTooltip(GetDlgItem(hMainDialog, IDS_CSM_HELP_TXT), lmprintf((tt == TT_UEFI) ? MSG_152 : MSG_151), 30000); | ||||||
| 		break; | 		break; | ||||||
| 	case UM_ENABLE_CONTROLS: | 	case UM_ENABLE_CONTROLS: | ||||||
|  | 		KillTimer(hMainDialog, TID_APP_TIMER); | ||||||
| 		if (!IS_ERROR(FormatStatus)) | 		if (!IS_ERROR(FormatStatus)) | ||||||
| 			PrintInfo(0, MSG_210); | 			PrintInfo(0, MSG_210); | ||||||
| 		else if (SCODE_CODE(FormatStatus)) | 		else if (SCODE_CODE(FormatStatus)) | ||||||
|  | @ -2292,6 +2284,19 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 			PrintInfo(0, MSG_212); | 			PrintInfo(0, MSG_212); | ||||||
| 		EnableControls(TRUE); | 		EnableControls(TRUE); | ||||||
| 		break; | 		break; | ||||||
|  | 	case UM_TIMER_START: | ||||||
|  | 		PrintInfo(0, -1); | ||||||
|  | 		timer = 0; | ||||||
|  | 		static_sprintf(szTimer, "00:00:00"); | ||||||
|  | 		SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); | ||||||
|  | 		SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); | ||||||
|  | 		break; | ||||||
|  | 	case UM_SELECT_ISO: | ||||||
|  | 		select_index = 0; | ||||||
|  | 		iso_provided = TRUE; | ||||||
|  | 		SetWindowTextU(GetDlgItem(hDlg, IDC_SELECT), uppercase_select[0]); | ||||||
|  | 		SendMessage(hDlg, WM_COMMAND, IDC_SELECT, 0); | ||||||
|  | 		break; | ||||||
| 	case UM_MEDIA_CHANGE: | 	case UM_MEDIA_CHANGE: | ||||||
| 		wParam = DBT_CUSTOMEVENT; | 		wParam = DBT_CUSTOMEVENT; | ||||||
| 		// Fall through
 | 		// Fall through
 | ||||||
|  | @ -2611,11 +2616,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | ||||||
| 			PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0); | 			PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0); | ||||||
| 		} else { | 		} else { | ||||||
| 			uprintf("\r\nFormat operation started"); | 			uprintf("\r\nFormat operation started"); | ||||||
| 			PrintInfo(0, -1); | 			SendMessage(hMainDialog, UM_TIMER_START, 0, 0); | ||||||
| 			timer = 0; |  | ||||||
| 			static_sprintf(szTimer, "00:00:00"); |  | ||||||
| 			SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); |  | ||||||
| 			SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); |  | ||||||
| 			// Set focus to the Cancel button
 | 			// Set focus to the Cancel button
 | ||||||
| 			SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hMainDialog, IDCANCEL), TRUE); | 			SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hMainDialog, IDCANCEL), TRUE); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -189,6 +189,8 @@ enum user_message_type { | ||||||
| 	UM_UPDATE_CSM_TOOLTIP, | 	UM_UPDATE_CSM_TOOLTIP, | ||||||
| 	UM_RESIZE_BUTTONS, | 	UM_RESIZE_BUTTONS, | ||||||
| 	UM_ENABLE_CONTROLS, | 	UM_ENABLE_CONTROLS, | ||||||
|  | 	UM_SELECT_ISO, | ||||||
|  | 	UM_TIMER_START, | ||||||
| 	UM_FORMAT_START, | 	UM_FORMAT_START, | ||||||
| 	// Start of the WM IDs for the language menu items
 | 	// Start of the WM IDs for the language menu items
 | ||||||
| 	UM_LANGUAGE_MENU = WM_APP + 0x100 | 	UM_LANGUAGE_MENU = WM_APP + 0x100 | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 232, 326 | IDD_DIALOG DIALOGEX 12, 12, 232, 326 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| EXSTYLE WS_EX_ACCEPTFILES | EXSTYLE WS_EX_ACCEPTFILES | ||||||
| CAPTION "Rufus 3.5.1449" | CAPTION "Rufus 3.5.1450" | ||||||
| FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | ||||||
| BEGIN | BEGIN | ||||||
|     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP |     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP | ||||||
|  | @ -394,8 +394,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 3,5,1449,0 |  FILEVERSION 3,5,1450,0 | ||||||
|  PRODUCTVERSION 3,5,1449,0 |  PRODUCTVERSION 3,5,1450,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -413,13 +413,13 @@ BEGIN | ||||||
|             VALUE "Comments", "https://akeo.ie" |             VALUE "Comments", "https://akeo.ie" | ||||||
|             VALUE "CompanyName", "Akeo Consulting" |             VALUE "CompanyName", "Akeo Consulting" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "3.5.1449" |             VALUE "FileVersion", "3.5.1450" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" |             VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" | ||||||
|             VALUE "OriginalFilename", "rufus-3.5.exe" |             VALUE "OriginalFilename", "rufus-3.5.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "3.5.1449" |             VALUE "ProductVersion", "3.5.1450" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue