forked from Silverfish/proton-bridge
GODT-919 GODT-1022 GODT-947 Logs and signals
+ Added startup logs + Added wait group for update notifications + Changed hooks in debug and trace level
This commit is contained in:
@ -230,6 +230,7 @@ func (f *frontendCLI) NotifyManualUpdate(update updater.VersionInfo, canInstall
|
||||
// NOTE: Save the update somewhere so that it can be installed when user chooses "install now".
|
||||
}
|
||||
|
||||
func (f *frontendCLI) WaitUntilFrontendIsReady() {}
|
||||
func (f *frontendCLI) SetVersion(version updater.VersionInfo) {}
|
||||
func (f *frontendCLI) NotifySilentUpdateInstalled() {}
|
||||
func (f *frontendCLI) NotifySilentUpdateError(err error) {}
|
||||
|
||||
@ -257,6 +257,7 @@ func (f *frontendCLI) NotifyManualUpdate(update updater.VersionInfo, canInstall
|
||||
// NOTE: Save the update somewhere so that it can be installed when user chooses "install now".
|
||||
}
|
||||
|
||||
func (f *frontendCLI) WaitUntilFrontendIsReady() {}
|
||||
func (f *frontendCLI) SetVersion(version updater.VersionInfo) {}
|
||||
func (f *frontendCLI) NotifySilentUpdateInstalled() {}
|
||||
func (f *frontendCLI) NotifySilentUpdateError(err error) {}
|
||||
|
||||
@ -45,6 +45,7 @@ type Frontend interface {
|
||||
SetVersion(update updater.VersionInfo)
|
||||
NotifySilentUpdateInstalled()
|
||||
NotifySilentUpdateError(error)
|
||||
WaitUntilFrontendIsReady()
|
||||
}
|
||||
|
||||
// New returns initialized frontend based on `frontendType`, which can be `cli` or `qt`.
|
||||
|
||||
@ -327,6 +327,8 @@ Item {
|
||||
go.failedAutostart = qsTr("Unable to configure automatic start." , "notification", -1)
|
||||
go.genericErrSeeLogs = qsTr("An error happened during procedure. See logs for more details." , "notification", -1)
|
||||
|
||||
go.guiIsReady()
|
||||
|
||||
// start window
|
||||
gui.openMainWindow(false)
|
||||
if (go.isShownOnStart) {
|
||||
|
||||
@ -432,6 +432,9 @@ Item {
|
||||
go.bugNotSent = qsTr("Unable to submit bug report." , "notification", -1)
|
||||
go.bugReportSent = qsTr("Bug report successfully sent." , "notification", -1)
|
||||
|
||||
|
||||
go.guiIsReady()
|
||||
|
||||
gui.allMonths = getMonthList(1,12)
|
||||
gui.allMonthsChanged()
|
||||
}
|
||||
|
||||
@ -360,6 +360,7 @@ Window {
|
||||
|
||||
signal updateFinished(bool hasError)
|
||||
|
||||
signal guiIsReady()
|
||||
|
||||
signal showOutgoingNoEncPopup(string subject)
|
||||
signal setOutgoingNoEncPopupCoord(real x, real y)
|
||||
|
||||
@ -918,6 +918,8 @@ Window {
|
||||
signal notifyUpdate()
|
||||
signal updateFinished(bool hasError)
|
||||
|
||||
signal guiIsReady()
|
||||
|
||||
signal openReleaseNotesExternally()
|
||||
|
||||
signal notifyLogout(string accname)
|
||||
|
||||
@ -22,6 +22,7 @@ package qtie
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/config/settings"
|
||||
"github.com/ProtonMail/proton-bridge/internal/events"
|
||||
@ -76,6 +77,9 @@ type FrontendQt struct {
|
||||
|
||||
// saving most up-to-date update info to install it manually
|
||||
updateInfo updater.VersionInfo
|
||||
|
||||
initializing sync.WaitGroup
|
||||
initializationDone sync.Once
|
||||
}
|
||||
|
||||
// New is constructor for Import-Export Qt-Go interface
|
||||
@ -102,6 +106,10 @@ func New(
|
||||
restarter: restarter,
|
||||
}
|
||||
|
||||
// Initializing.Done is only called sync.Once. Please keep the increment
|
||||
// set to 1
|
||||
f.initializing.Add(1)
|
||||
|
||||
log.Debugf("New Qt frontend: %p", f)
|
||||
return f
|
||||
}
|
||||
@ -541,3 +549,14 @@ func (f *FrontendQt) createLabelOrFolder(email, name, color string, isLabel bool
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (f *FrontendQt) WaitUntilFrontendIsReady() {
|
||||
f.initializing.Wait()
|
||||
}
|
||||
|
||||
// setGUIIsReady unlocks the WaitUntilFrontendIsReady.
|
||||
func (f *FrontendQt) setGUIIsReady() {
|
||||
f.initializationDone.Do(func() {
|
||||
f.initializing.Done()
|
||||
})
|
||||
}
|
||||
|
||||
@ -50,6 +50,9 @@ func (s *FrontendHeadless) NotifyManualUpdate(update updater.VersionInfo, canIns
|
||||
func (s *FrontendHeadless) SetVersion(update updater.VersionInfo) {
|
||||
}
|
||||
|
||||
func (s *FrontendHeadless) WaitUntilFrontendIsReady() {
|
||||
}
|
||||
|
||||
func (s *FrontendHeadless) NotifySilentUpdateInstalled() {
|
||||
}
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@ type GoQMLInterface struct {
|
||||
_ func() `slot:"checkAndOpenReleaseNotes"`
|
||||
_ func() `signal:"openReleaseNotesExternally"`
|
||||
_ func() `slot:"startManualUpdate"`
|
||||
_ func() `slot:"guiIsReady"`
|
||||
|
||||
// translations
|
||||
_ string `property:"wrongCredentials"`
|
||||
@ -201,6 +202,8 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
|
||||
s.ConnectStartExport(f.StartExport)
|
||||
s.ConnectStartImport(f.StartImport)
|
||||
|
||||
s.ConnectGuiIsReady(f.setGUIIsReady)
|
||||
|
||||
s.ConnectCheckPathStatus(CheckPathStatus)
|
||||
|
||||
s.ConnectEmitEvent(f.emitEvent)
|
||||
|
||||
@ -97,6 +97,9 @@ type FrontendQt struct {
|
||||
|
||||
// saving most up-to-date update info to install it manually
|
||||
updateInfo updater.VersionInfo
|
||||
|
||||
initializing sync.WaitGroup
|
||||
initializationDone sync.Once
|
||||
}
|
||||
|
||||
// New returns a new Qt frontend for the bridge.
|
||||
@ -132,6 +135,10 @@ func New(
|
||||
restarter: restarter,
|
||||
}
|
||||
|
||||
// Initializing.Done is only called sync.Once. Please keep the increment
|
||||
// set to 1
|
||||
tmp.initializing.Add(1)
|
||||
|
||||
// Nicer string for OS.
|
||||
currentOS := core.QSysInfo_PrettyProductName()
|
||||
bridge.SetCurrentOS(currentOS)
|
||||
@ -180,6 +187,8 @@ func (s *FrontendQt) NotifySilentUpdateError(err error) {
|
||||
}
|
||||
|
||||
func (s *FrontendQt) watchEvents() {
|
||||
s.WaitUntilFrontendIsReady()
|
||||
|
||||
errorCh := s.getEventChannel(events.ErrorEvent)
|
||||
credentialsErrorCh := s.getEventChannel(events.CredentialsErrorEvent)
|
||||
outgoingNoEncCh := s.getEventChannel(events.OutgoingNoEncEvent)
|
||||
@ -683,3 +692,14 @@ func (s *FrontendQt) startManualUpdate() {
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *FrontendQt) WaitUntilFrontendIsReady() {
|
||||
s.initializing.Wait()
|
||||
}
|
||||
|
||||
// setGUIIsReady unlocks the WaitFrontendIsReady.
|
||||
func (s *FrontendQt) setGUIIsReady() {
|
||||
s.initializationDone.Do(func() {
|
||||
s.initializing.Done()
|
||||
})
|
||||
}
|
||||
|
||||
@ -48,6 +48,9 @@ func (s *FrontendHeadless) NotifyManualUpdate(update updater.VersionInfo, canIns
|
||||
// NOTE: Save the update somewhere so that it can be installed when user chooses "install now".
|
||||
}
|
||||
|
||||
func (s *FrontendHeadless) WaitUntilFrontendIsReady() {
|
||||
}
|
||||
|
||||
func (s *FrontendHeadless) SetVersion(update updater.VersionInfo) {
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ import (
|
||||
"github.com/therecipe/qt/core"
|
||||
)
|
||||
|
||||
// Interface between go and qml.
|
||||
// GoQMLInterface between go and qml.
|
||||
//
|
||||
// Here we implement all the signals / methods.
|
||||
type GoQMLInterface struct {
|
||||
@ -64,6 +64,7 @@ type GoQMLInterface struct {
|
||||
_ func() `slot:"checkAndOpenReleaseNotes"`
|
||||
_ func() `signal:"openReleaseNotesExternally"`
|
||||
_ func() `slot:"startManualUpdate"`
|
||||
_ func() `slot:"guiIsReady"`
|
||||
|
||||
// Translations.
|
||||
_ string `property:"wrongCredentials"`
|
||||
@ -170,6 +171,7 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
|
||||
s.ConnectClearKeychain(f.clearKeychain)
|
||||
s.ConnectOpenLicenseFile(f.openLicenseFile)
|
||||
s.ConnectStartManualUpdate(f.startManualUpdate)
|
||||
s.ConnectGuiIsReady(f.setGUIIsReady)
|
||||
s.ConnectGetLocalVersionInfo(f.getLocalVersionInfo)
|
||||
s.ConnectCheckForUpdates(f.checkForUpdates)
|
||||
s.ConnectGetIMAPPort(f.getIMAPPort)
|
||||
|
||||
Reference in New Issue
Block a user