GODT-1425: Factory reset enables launch on startup

This commit is contained in:
Jakub
2021-12-01 13:23:01 +01:00
committed by Jakub Cuth
parent a0dc764bb9
commit f2d568d92f
11 changed files with 105 additions and 34 deletions

View File

@ -19,7 +19,6 @@
package frontend
import (
"github.com/ProtonMail/go-autostart"
"github.com/ProtonMail/proton-bridge/internal/bridge"
"github.com/ProtonMail/proton-bridge/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/config/useragent"
@ -55,7 +54,6 @@ func New(
userAgent *useragent.UserAgent,
bridge *bridge.Bridge,
noEncConfirmator types.NoEncConfirmator,
autostart *autostart.App,
restarter types.Restarter,
) Frontend {
bridgeWrap := types.NewBridgeWrap(bridge)
@ -74,7 +72,6 @@ func New(
userAgent,
bridgeWrap,
noEncConfirmator,
autostart,
restarter,
)
case "cli":

View File

@ -25,7 +25,6 @@ import (
"fmt"
"sync"
"github.com/ProtonMail/go-autostart"
"github.com/ProtonMail/proton-bridge/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/frontend/types"
@ -50,7 +49,6 @@ type FrontendQt struct {
userAgent *useragent.UserAgent
bridge types.Bridger
noEncConfirmator types.NoEncConfirmator
autostart *autostart.App
restarter types.Restarter
showOnStartup bool
@ -82,7 +80,6 @@ func New(
userAgent *useragent.UserAgent,
bridge types.Bridger,
_ types.NoEncConfirmator,
autostart *autostart.App,
restarter types.Restarter,
) *FrontendQt {
userAgent.SetPlatform(core.QSysInfo_PrettyProductName())
@ -99,7 +96,6 @@ func New(
updater: updater,
userAgent: userAgent,
bridge: bridge,
autostart: autostart,
restarter: restarter,
showOnStartup: showWindowOnStart,
}
@ -122,6 +118,12 @@ func (f *FrontendQt) Loop() error {
f.watchEvents()
}()
// Set whether this is the first time GUI starts.
f.qml.SetIsFirstGUIStart(f.settings.GetBool(settings.FirstStartGUIKey))
defer func() {
f.settings.SetBool(settings.FirstStartGUIKey, false)
}()
if ret := f.app.Exec(); ret != 0 {
err := fmt.Errorf("Event loop ended with return value: %v", ret)
f.log.Warn("App exec", err)

View File

@ -23,7 +23,6 @@ import (
"fmt"
"net/http"
"github.com/ProtonMail/go-autostart"
"github.com/ProtonMail/proton-bridge/internal/config/settings"
"github.com/ProtonMail/proton-bridge/internal/config/useragent"
"github.com/ProtonMail/proton-bridge/internal/frontend/types"
@ -50,7 +49,6 @@ func New(
userAgent *useragent.UserAgent,
bridge types.Bridger,
noEncConfirmator types.NoEncConfirmator,
autostart *autostart.App,
restarter types.Restarter,
) *FrontendHeadless {
return &FrontendHeadless{}

View File

@ -75,21 +75,21 @@ func (f *FrontendQt) changeLocalCache(enableDiskCache bool, diskCachePath *core.
}
func (f *FrontendQt) setIsAutostartOn() {
f.qml.SetIsAutostartOn(f.autostart.IsEnabled())
f.qml.SetIsAutostartOn(f.bridge.IsAutostartEnabled())
}
func (f *FrontendQt) toggleAutostart(makeItEnabled bool) {
defer f.qml.ToggleAutostartFinished()
if makeItEnabled == f.autostart.IsEnabled() {
if makeItEnabled == f.bridge.IsAutostartEnabled() {
f.setIsAutostartOn()
return
}
var err error
if makeItEnabled {
err = f.autostart.Enable()
err = f.bridge.EnableAutostart()
} else {
err = f.autostart.Disable()
err = f.bridge.DisableAutostart()
}
f.setIsAutostartOn()

View File

@ -90,6 +90,8 @@ type QMLBackend struct {
_ func(enableDiskCache bool, diskCachePath core.QUrl) `slot:"changeLocalCache"`
_ func() `signal:"changeLocalCacheFinished"`
_ bool `property:"isFirstGUIStart"`
_ bool `property:"isAutomaticUpdateOn"`
_ func(makeItActive bool) `slot:"toggleAutomaticUpdate"`

View File

@ -87,6 +87,9 @@ type Bridger interface {
GetKeychainApp() string
SetKeychainApp(keychain string)
HasError(err error) bool
IsAutostartEnabled() bool
EnableAutostart() error
DisableAutostart() error
}
type bridgeWrap struct {