diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-06-12 19:05:59 +0200 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2020-06-12 20:03:03 +0200 |
commit | 1038fa83b820bbdaa9bcf37118cf23b0e48a86c5 (patch) | |
tree | d403cffa091932c1c46ea17fd15da588c1e5a7a2 /gui | |
parent | 971c28f6563de35b1d66401d6919f86787af0611 (diff) |
[refactor] reorganize modules
bitmaskd: so long and thanks for all the fish!
Signed-off-by: kali kaneko (leap communications) <kali@leap.se>
Diffstat (limited to 'gui')
-rw-r--r-- | gui/backend.go | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/gui/backend.go b/gui/backend.go index d05ba7a..cf7c0fb 100644 --- a/gui/backend.go +++ b/gui/backend.go @@ -6,22 +6,16 @@ import ( "bytes" "encoding/json" "fmt" - "io" "log" "net/http" "os" - "path" "reflect" "sync" //"time" "unsafe" "0xacab.org/leap/bitmask-vpn/pkg/bitmask" - "0xacab.org/leap/bitmask-vpn/pkg/config" "0xacab.org/leap/bitmask-vpn/pkg/pickle" - "0xacab.org/leap/bitmask-vpn/pkg/systray2" - "github.com/jmshal/go-locale" - "golang.org/x/text/message" ) // typedef void (*cb)(); @@ -184,37 +178,17 @@ func setStatusFromStr(stStr string) { setStatus(unknown.fromString(stStr)) } -func initPrinter() *message.Printer { - locale, err := go_locale.DetectLocale() - if err != nil { - log.Println("Error detecting the system locale: ", err) - } - - return message.NewPrinter(message.MatchLanguage(locale, "en")) -} - -const logFile = "systray.log" - -var logger io.Closer - // initializeBitmask instantiates a bitmask connection func initializeBitmask() { - _, err := config.ConfigureLogger(path.Join(config.Path, logFile)) - - if err != nil { - log.Println("Can't configure logger: ", err) - } - if ctx == nil { log.Println("error: cannot initialize bitmask, ctx is nil") os.Exit(1) } - conf := systray.ParseConfig() - conf.Version = "unknown" - conf.Printer = initPrinter() - b, err := bitmask.Init(conf.Printer) + bitmask.InitializeLogger() + + b, err := bitmask.InitializeBitmask() if err != nil { - log.Fatal(err) + log.Println("error: cannot initialize bitmask") } ctx.bm = b } @@ -318,10 +292,10 @@ func SubscribeToEvent(event string, f unsafe.Pointer) { //export InitializeBitmaskContext func InitializeBitmaskContext() { - provider := config.Provider - appName := config.ApplicationName + pi := bitmask.GetConfiguredProvider() + initOnce.Do(func() { - initializeContext(provider, appName) + initializeContext(pi.Provider, pi.AppName) }) go ctx.updateStatus() |