From ab92e68628ad2afa5298df06640e4d2ca3e42ecf Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 26 Sep 2019 16:36:35 -0700 Subject: [PATCH] ping ACN status on window acticate (mostly for android) --- go/characters/appEventListener.go | 2 +- go/gothings/gcd.go | 6 ++++++ main.go | 1 + qml/main.qml | 11 +++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/go/characters/appEventListener.go b/go/characters/appEventListener.go index d1ffcbc7..8685ad97 100644 --- a/go/characters/appEventListener.go +++ b/go/characters/appEventListener.go @@ -73,7 +73,7 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool } onion := e.Data[event.Identity] - the.CwtchApp.AddPeerPlugin(onion, plugins.CONTACTRETRY) + the.CwtchApp.AddPeerPlugin(onion, plugins.CONNECTIONRETRY) the.Peer = the.CwtchApp.GetPeer(onion) the.EventBus = the.CwtchApp.GetEventBus(onion) diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index d9e8f2e4..cda95b9c 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -79,6 +79,7 @@ type GrandCentralDispatcher struct { _ func(locale string) `signal:"setLocale,auto"` _ func() `signal:"allowUnknownPeers,auto"` _ func() `signal:"blockUnknownPeers,auto"` + _ func() `signal:"onActivate,auto"` } func (this *GrandCentralDispatcher) sendMessage(message string, mID string) { @@ -581,6 +582,11 @@ func (this *GrandCentralDispatcher) setLocale(locale string) { } +func (this *GrandCentralDispatcher) onActivate() { + log.Debugln("onActivate") + the.CwtchApp.QueryACNStatus() +} + func (this *GrandCentralDispatcher) SetLocale_helper(locale string) { core.QCoreApplication_RemoveTranslator(this.Translator) this.Translator = core.NewQTranslator(nil) diff --git a/main.go b/main.go index fa3e32dd..483e3e3a 100644 --- a/main.go +++ b/main.go @@ -118,6 +118,7 @@ func mainService() { log.Infoln("Making QGuiApplication...") app = gui.NewQGuiApplication(len(os.Args), os.Args) } + log.Infoln("Cwtch Service starting app.Exec") app.Exec() } diff --git a/qml/main.qml b/qml/main.qml index d4584884..a7ab5d20 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -250,4 +250,15 @@ ApplicationWindow { theStack.title = str } } + + Connections { + target: Qt.application + onStateChanged: function() { + // https://doc.qt.io/qt-5/qt.html#ApplicationState-enum + if (Qt.application.state == 4) { + // Active + gcd.onActivate() + } + } + } }