diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 5c222929..9e64880d 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -110,7 +110,7 @@ - + diff --git a/main.go b/main.go index 919df035..dc539239 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "flag" "git.openprivacy.ca/openprivacy/libricochet-go/connectivity" "git.openprivacy.ca/openprivacy/libricochet-go/log" + "github.com/therecipe/qt/androidextras" "github.com/therecipe/qt/core" "github.com/therecipe/qt/gui" "github.com/therecipe/qt/network" @@ -87,12 +88,23 @@ func main() { } } +// QRunnable is a shim for QAndroidService and QGuiApplication +type QRunnable interface { + Exec() int +} + func mainService() { log.Infoln("I am the service") log.Infoln("Starting a cwtch app...") go loadNetworkingAndFiles(nil, true, false) - //app := androidextras.NewQAndroidService(len(os.Args), os.Args) - app := gui.NewQGuiApplication(len(os.Args), os.Args) + var app QRunnable + if runtime.GOOS == "android" { + log.Infoln("Making QAndroidService...") + app = androidextras.NewQAndroidService(len(os.Args), os.Args) + } else { + log.Infoln("Making QGuiApplication...") + app = gui.NewQGuiApplication(len(os.Args), os.Args) + } log.Infoln("Cwtch Service starting app.Exec") app.Exec() }