-
-
Notifications
You must be signed in to change notification settings - Fork 141
feat(windows): honour Windows "metered connection" flag for downloading updates #16099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
a9933ab
cc8b4d2
94756fd
e92f01a
293f8ec
5e26d5d
3974f03
85da9dc
448d63e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -212,6 +212,7 @@ implementation | |||||
| utilexecute, | ||||||
| utilkmshell, | ||||||
| utilhttp, | ||||||
| UtilNetworkConnection, | ||||||
| utiluac, | ||||||
| utilxml, | ||||||
| KeymanPaths; | ||||||
|
|
@@ -817,12 +818,34 @@ procedure TfrmMain.Update_ApplyNow; | |||||
| ShellPath : string; | ||||||
| FResult, InstallNow: Boolean; | ||||||
| frmStartInstallNow: TfrmStartInstall; | ||||||
| IsMetered: Boolean; | ||||||
| EInstallScenario: TInstallCase; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The prefix
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Long story I initally called it InstallScenario, but then I found following that unwritten enum rule of the small letter preffix it became |
||||||
| begin | ||||||
| InstallNow := True; | ||||||
| // Confirm User is ok that this will require a reset | ||||||
| if HasKeymanRun then | ||||||
| IsMetered := UtilNetworkConnection.IsMetered; | ||||||
|
|
||||||
| // If a restart is required (HasKeymanRun == True) | ||||||
| // OR it is a Metered connection warn the user and allow | ||||||
| // them to cancel their request to Install Now. | ||||||
| // Otherwise start installing with out pop-up warnings. | ||||||
| EInstallScenario := TInstallCase.icNone; | ||||||
| if HasKeymanRun and not IsMetered then | ||||||
| begin | ||||||
| frmStartInstallNow := TfrmStartInstall.Create(nil, true); | ||||||
| EInstallScenario := TInstallCase.icRestartRequiredNotMetered; | ||||||
| end | ||||||
| else if HasKeymanRun and IsMetered then | ||||||
| begin | ||||||
| EInstallScenario := TInstallCase.icRestartRequiredMetered; | ||||||
| end | ||||||
| else if (not HasKeymanRun) and IsMetered then | ||||||
| begin | ||||||
| EInstallScenario := TInstallCase.icNoInstallMessageMetered; | ||||||
| end; | ||||||
|
|
||||||
| // Render dialog if conditions require it | ||||||
| if EInstallScenario <> TInstallCase.icNone then | ||||||
| begin | ||||||
| frmStartInstallNow := TfrmStartInstall.Create(nil, EInstallScenario); | ||||||
| try | ||||||
| if frmStartInstallNow.ShowModal = mrOk then | ||||||
| InstallNow := True | ||||||
|
|
@@ -833,18 +856,23 @@ procedure TfrmMain.Update_ApplyNow; | |||||
| end; | ||||||
| end; | ||||||
|
|
||||||
| if InstallNow = True then | ||||||
| // Process installation execution execution path | ||||||
| if InstallNow then | ||||||
| begin | ||||||
| ShellPath := TKeymanPaths.KeymanDesktopInstallPath(TKeymanPaths.S_KMShell); | ||||||
| FResult := TUtilExecute.Shell(0, ShellPath, '', '-an'); | ||||||
| if not FResult then | ||||||
| begin | ||||||
| TKeymanSentryClient.Client.MessageEvent(Sentry.Client.SENTRY_LEVEL_ERROR, | ||||||
| 'TrmfMain: Shell Execute Update_ApplyNow Failed') | ||||||
| 'TrmfMain: Shell Execute Update_ApplyNow Failed'); | ||||||
| end | ||||||
| else | ||||||
| ModalResult := mrAbort; | ||||||
| begin | ||||||
| // If a splash screen is currently open when "Install Now" is executed, | ||||||
| // setting mrAbort ensures the splash screen is closed on the | ||||||
| // return of "Keyman Configuration". | ||||||
| ModalResult := mrAbort; | ||||||
| end; | ||||||
| end; | ||||||
| end; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -677,7 +677,8 @@ function ShouldSendToBUpdateSM(FSilent: Boolean; BUpdateSM: TUpdateStateMachine; | |||||||||
| (FMode in [fmStart, fmSplash, fmMain, fmAbout, | ||||||||||
| fmHelp, fmShowHelp, fmSettings, fmBoot]) then | ||||||||||
| begin | ||||||||||
| frmStartInstall := TfrmStartInstall.Create(nil, false); | ||||||||||
| // We are ready to install Metered warning not needed even if on Metered connection | ||||||||||
| frmStartInstall := TfrmStartInstall.Create(nil, TInstallCase.icReadyToInstallNotMetered); | ||||||||||
|
Comment on lines
+680
to
+681
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| try | ||||||||||
| Result := frmStartInstall.ShowModal = mrOk; | ||||||||||
| finally | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this install case name confusing; is the following name accurate?
I guess my confusion extends to the dialog box as well -- would it be possible for the dialog box to say something to clarify that a download is required, something like this?
The update has not yet been downloaded.and
You're on a metered connection. Downloading now may incur data charges.