forked from Silverfish/proton-bridge
[GODT-274] GUI changes for autoupdates
[GODT-275] Add enable/disable auto updates GUI option Refactor Updater module GODT-805 Changed manual update information bar layout GODT-806, GODT-875 Change update dialogs Refactor InformationBar
This commit is contained in:
committed by
James Houlahan
parent
b7b2297635
commit
98ab794f13
@ -95,6 +95,9 @@ type FrontendQt struct {
|
||||
userIDAdded string
|
||||
|
||||
restarter types.Restarter
|
||||
|
||||
// saving most up-to-date update info to install it manually
|
||||
updateInfo updater.VersionInfo
|
||||
}
|
||||
|
||||
// New returns a new Qt frontend for the bridge.
|
||||
@ -173,9 +176,21 @@ func (s *FrontendQt) Loop() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *FrontendQt) NotifyManualUpdate(update updater.VersionInfo) error {
|
||||
// NOTE: Save the update somewhere so that it can be installed when user chooses "install now".
|
||||
return nil
|
||||
func (s *FrontendQt) NotifyManualUpdate(update updater.VersionInfo, canInstall bool) {
|
||||
s.Qml.SetUpdateVersion(update.Version.String())
|
||||
s.Qml.SetUpdateLandingPage(update.Landing)
|
||||
s.Qml.SetUpdateReleaseNotesLink("https://protonmail.com/download/bridge/release_notes.html")
|
||||
s.Qml.SetUpdateCanInstall(canInstall)
|
||||
s.updateInfo = update
|
||||
s.Qml.NotifyManualUpdate()
|
||||
}
|
||||
|
||||
func (s *FrontendQt) NotifySilentUpdateInstalled() {
|
||||
s.Qml.NotifySilentUpdateRestartNeeded()
|
||||
}
|
||||
|
||||
func (s *FrontendQt) NotifySilentUpdateError(err error) {
|
||||
s.Qml.NotifySilentUpdateError()
|
||||
}
|
||||
|
||||
func (s *FrontendQt) watchEvents() {
|
||||
@ -233,7 +248,7 @@ func (s *FrontendQt) watchEvents() {
|
||||
s.Qml.NotifyLogout(user.Username())
|
||||
case <-updateApplicationCh:
|
||||
s.Qml.ProcessFinished()
|
||||
s.Qml.NotifyUpdate()
|
||||
s.Qml.NotifyForceUpdate()
|
||||
case <-newUserCh:
|
||||
s.Qml.LoadAccounts()
|
||||
case <-certIssue:
|
||||
@ -343,6 +358,12 @@ func (s *FrontendQt) qtExecute(Procedure func(*FrontendQt) error) error {
|
||||
s.Qml.SetIsAutoStart(false)
|
||||
}
|
||||
|
||||
if s.settings.GetBool(settings.AutoUpdateKey) {
|
||||
s.Qml.SetIsAutoUpdate(true)
|
||||
} else {
|
||||
s.Qml.SetIsAutoUpdate(false)
|
||||
}
|
||||
|
||||
if s.settings.GetBool(settings.AllowProxyKey) {
|
||||
s.Qml.SetIsProxyAllowed(true)
|
||||
} else {
|
||||
@ -397,16 +418,30 @@ func (s *FrontendQt) openLogs() {
|
||||
go open.Run(logsPath)
|
||||
}
|
||||
|
||||
// Check version in separate goroutine to not block the GUI (avoid program not responding message).
|
||||
func (s *FrontendQt) isNewVersionAvailable(showMessage bool) {
|
||||
func (s *FrontendQt) checkForUpdates() {
|
||||
go func() {
|
||||
defer s.panicHandler.HandlePanic()
|
||||
defer s.Qml.ProcessFinished()
|
||||
s.Qml.SetConnectionStatus(true) // If we are here connection is ok.
|
||||
s.Qml.SetUpdateState("upToDate")
|
||||
if showMessage {
|
||||
s.Qml.NotifyVersionIsTheLatest()
|
||||
version, err := s.updater.Check()
|
||||
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("An error occurred while checking updates manually")
|
||||
s.Qml.NotifyManualUpdateError()
|
||||
return
|
||||
}
|
||||
|
||||
if !s.updater.IsUpdateApplicable(version) {
|
||||
logrus.Debug("No need to update")
|
||||
return
|
||||
}
|
||||
|
||||
logrus.WithField("version", version.Version).Info("An update is available")
|
||||
|
||||
if !s.updater.CanInstall(version) {
|
||||
logrus.Debug("A manual update is required")
|
||||
s.NotifyManualUpdate(version, false)
|
||||
return
|
||||
}
|
||||
|
||||
s.NotifyManualUpdate(version, true)
|
||||
}()
|
||||
}
|
||||
|
||||
@ -501,6 +536,18 @@ func (s *FrontendQt) toggleAutoStart() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *FrontendQt) toggleAutoUpdate() {
|
||||
defer s.Qml.ProcessFinished()
|
||||
|
||||
if s.settings.GetBool(settings.AutoUpdateKey) {
|
||||
s.settings.SetBool(settings.AutoUpdateKey, false)
|
||||
s.Qml.SetIsAutoUpdate(false)
|
||||
} else {
|
||||
s.settings.SetBool(settings.AutoUpdateKey, true)
|
||||
s.Qml.SetIsAutoUpdate(true)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *FrontendQt) toggleAllowProxy() {
|
||||
defer s.Qml.ProcessFinished()
|
||||
|
||||
@ -594,6 +641,15 @@ func (s *FrontendQt) saveOutgoingNoEncPopupCoord(x, y float32) {
|
||||
//prefs.SetFloat(prefs.OutgoingNoEncPopupCoordY, y)
|
||||
}
|
||||
|
||||
func (s *FrontendQt) StartUpdate() {
|
||||
// NOTE: Fix this.
|
||||
func (s *FrontendQt) startManualUpdate() {
|
||||
go func() {
|
||||
err := s.updater.InstallUpdate(s.updateInfo)
|
||||
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("An error occurred while installing updates manually")
|
||||
s.Qml.NotifyManualUpdateError()
|
||||
}
|
||||
|
||||
s.Qml.NotifyManualUpdateRestartNeeded()
|
||||
}()
|
||||
}
|
||||
|
||||
@ -43,9 +43,14 @@ func (s *FrontendHeadless) Loop() error {
|
||||
return http.ListenAndServe(":8081", nil)
|
||||
}
|
||||
|
||||
func (s *FrontendHeadless) NotifyManualUpdate(update updater.VersionInfo) error {
|
||||
func (s *FrontendHeadless) NotifyManualUpdate(update updater.VersionInfo, canInstall bool) {
|
||||
// NOTE: Save the update somewhere so that it can be installed when user chooses "install now".
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *FrontendHeadless) NotifySilentUpdateInstalled() {
|
||||
}
|
||||
|
||||
func (s *FrontendHeadless) NotifySilentUpdateError(err error) {
|
||||
}
|
||||
|
||||
func (s *FrontendHeadless) InstanceExistAlert() {}
|
||||
|
||||
@ -34,6 +34,7 @@ type GoQMLInterface struct {
|
||||
_ func() `constructor:"init"`
|
||||
|
||||
_ bool `property:"isAutoStart"`
|
||||
_ bool `property:"isAutoUpdate"`
|
||||
_ bool `property:"isProxyAllowed"`
|
||||
_ string `property:"currentAddress"`
|
||||
_ string `property:"goos"`
|
||||
@ -45,11 +46,21 @@ type GoQMLInterface struct {
|
||||
_ bool `property:"isDefaultPort"`
|
||||
|
||||
_ string `property:"programTitle"`
|
||||
_ string `property:"newversion"`
|
||||
_ string `property:"fullversion"`
|
||||
_ string `property:"downloadLink"`
|
||||
_ string `property:"landingPage"`
|
||||
_ string `property:"releaseNotesLink"`
|
||||
|
||||
_ string `property:"updateVersion"`
|
||||
_ bool `property:"updateCanInstall"`
|
||||
_ string `property:"updateLandingPage"`
|
||||
_ string `property:"updateReleaseNotesLink"`
|
||||
_ func() `signal:"notifyManualUpdate"`
|
||||
_ func() `signal:"notifyManualUpdateRestartNeeded"`
|
||||
_ func() `signal:"notifyManualUpdateError"`
|
||||
_ func() `signal:"notifyForceUpdate"`
|
||||
_ func() `signal:"notifySilentUpdateRestartNeeded"`
|
||||
_ func() `signal:"notifySilentUpdateError"`
|
||||
_ func() `slot:"checkForUpdates"`
|
||||
_ func() `slot:"startManualUpdate"`
|
||||
|
||||
// Translations.
|
||||
_ string `property:"wrongCredentials"`
|
||||
@ -82,6 +93,7 @@ type GoQMLInterface struct {
|
||||
_ func() `signal:"showQuit"`
|
||||
|
||||
_ func() `slot:"toggleAutoStart"`
|
||||
_ func() `slot:"toggleAutoUpdate"`
|
||||
_ func() `slot:"toggleAllowProxy"`
|
||||
_ func() `slot:"loadAccounts"`
|
||||
_ func() `slot:"openLogs"`
|
||||
@ -121,7 +133,6 @@ type GoQMLInterface struct {
|
||||
_ func() `signal:"notifyVersionIsTheLatest"`
|
||||
_ func() `signal:"notifyKeychainRebuild"`
|
||||
_ func() `signal:"notifyHasNoKeychain"`
|
||||
_ func() `signal:"notifyUpdate"`
|
||||
_ func(accname string) `signal:"notifyLogout"`
|
||||
_ func(accname string) `signal:"notifyAddressChanged"`
|
||||
_ func(accname string) `signal:"notifyAddressChangedLogout"`
|
||||
@ -137,7 +148,6 @@ type GoQMLInterface struct {
|
||||
_ func(recipient string) `signal:"showNoActiveKeyForRecipient"`
|
||||
_ func() `signal:"showCertIssue"`
|
||||
|
||||
_ func() `slot:"startUpdate"`
|
||||
_ func(hasError bool) `signal:"updateFinished"`
|
||||
}
|
||||
|
||||
@ -147,15 +157,16 @@ func (s *GoQMLInterface) init() {}
|
||||
// SetFrontend connects all slots and signals from Go to QML.
|
||||
func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
|
||||
s.ConnectToggleAutoStart(f.toggleAutoStart)
|
||||
s.ConnectToggleAutoUpdate(f.toggleAutoUpdate)
|
||||
s.ConnectToggleAllowProxy(f.toggleAllowProxy)
|
||||
s.ConnectLoadAccounts(f.loadAccounts)
|
||||
s.ConnectOpenLogs(f.openLogs)
|
||||
s.ConnectClearCache(f.clearCache)
|
||||
s.ConnectClearKeychain(f.clearKeychain)
|
||||
|
||||
s.ConnectOpenLicenseFile(f.openLicenseFile)
|
||||
s.ConnectStartManualUpdate(f.startManualUpdate)
|
||||
s.ConnectGetLocalVersionInfo(f.getLocalVersionInfo)
|
||||
s.ConnectIsNewVersionAvailable(f.isNewVersionAvailable)
|
||||
s.ConnectCheckForUpdates(f.checkForUpdates)
|
||||
s.ConnectGetIMAPPort(f.getIMAPPort)
|
||||
s.ConnectGetSMTPPort(f.getSMTPPort)
|
||||
s.ConnectGetLastMailClient(f.getLastMailClient)
|
||||
@ -180,8 +191,6 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
|
||||
s.SetGoos(runtime.GOOS)
|
||||
s.SetProgramTitle(f.programName)
|
||||
|
||||
s.SetReleaseNotesLink("https://protonmail.com/download/bridge/release_notes.html")
|
||||
|
||||
s.ConnectGetBackendVersion(func() string {
|
||||
return f.programVer
|
||||
})
|
||||
@ -193,5 +202,4 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
|
||||
s.ConnectToggleIsReportingOutgoingNoEnc(f.toggleIsReportingOutgoingNoEnc)
|
||||
s.ConnectShouldSendAnswer(f.shouldSendAnswer)
|
||||
s.ConnectSaveOutgoingNoEncPopupCoord(f.saveOutgoingNoEncPopupCoord)
|
||||
s.ConnectStartUpdate(f.StartUpdate)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user