add flag to allow running client/service on desktop

This commit is contained in:
Dan Ballard 2019-07-05 17:50:03 -07:00
parent d85961bb14
commit 4e671a7b3f
1 changed files with 12 additions and 11 deletions

23
main.go
View File

@ -39,7 +39,8 @@ func main() {
log.Infoln("ui main()\n") log.Infoln("ui main()\n")
flagDebug := flag.Bool("debug", false, "turn on extra logging. WARNING: THIS MAY EXPOSE PRIVATE INFORMATION IN CONSOLE OUTPUT!") flagDebug := flag.Bool("debug", false, "turn on extra logging. WARNING: THIS MAY EXPOSE PRIVATE INFORMATION IN CONSOLE OUTPUT!")
flagLocal := flag.Bool("local", false, "load user interface from the local folder \"qml\" instead of the built-in UI") flagLocal := flag.Bool("local", false, "load user interface from the local folder \"qml\" instead of the built-in UI")
flagService := flag.Bool("service", false, "indicate this process should run as an android service") flagService := flag.Bool("service", false, "run this process as an android service")
flagClientUI := flag.Bool("clientui", false, "start the UI as a client of a service app instead of a full app")
flag.Parse() flag.Parse()
if *flagDebug { if *flagDebug {
@ -49,10 +50,10 @@ func main() {
} }
// TESTING // TESTING
log.SetLevel(log.LevelDebug) //log.SetLevel(log.LevelDebug)
log.ExcludeFromPattern("connection/connection") //log.ExcludeFromPattern("connection/connection")
log.ExcludeFromPattern("outbound/3dhauthchannel") //log.ExcludeFromPattern("outbound/3dhauthchannel")
log.ExcludeFromPattern("event/eventmanager") //log.ExcludeFromPattern("event/eventmanager")
if os.Getenv("CWTCH_FOLDER") != "" { if os.Getenv("CWTCH_FOLDER") != "" {
the.CwtchDir = os.Getenv("CWTCH_FOLDER") the.CwtchDir = os.Getenv("CWTCH_FOLDER")
@ -77,7 +78,7 @@ func main() {
mainService() mainService()
} else { } else {
mainUi(*flagLocal) mainUi(*flagLocal, *flagClientUI)
} }
if the.ACN != nil { if the.ACN != nil {
@ -88,7 +89,7 @@ func main() {
func mainService() { func mainService() {
log.Infoln("I am the service") log.Infoln("I am the service")
log.Infoln("Starting a cwtch app...") log.Infoln("Starting a cwtch app...")
go loadNetworkingAndFiles(nil, true) go loadNetworkingAndFiles(nil, true, false)
//app := androidextras.NewQAndroidService(len(os.Args), os.Args) //app := androidextras.NewQAndroidService(len(os.Args), os.Args)
app := gui.NewQGuiApplication(len(os.Args), os.Args) app := gui.NewQGuiApplication(len(os.Args), os.Args)
@ -97,7 +98,7 @@ func mainService() {
} }
func mainUi(flagLocal bool) { func mainUi(flagLocal bool, flagClientUI bool) {
log.Infoln("I am the application") log.Infoln("I am the application")
app := gui.NewQGuiApplication(len(os.Args), os.Args) app := gui.NewQGuiApplication(len(os.Args), os.Args)
@ -172,7 +173,7 @@ func mainUi(flagLocal bool) {
engine.Load(qmlSource) engine.Load(qmlSource)
go loadNetworkingAndFiles(gcd, false) go loadNetworkingAndFiles(gcd, false, flagClientUI)
log.Infoln("Cwtch App starting app.Exec") log.Infoln("Cwtch App starting app.Exec")
app.Exec() app.Exec()
@ -207,8 +208,8 @@ func loadACN() {
} }
} }
func loadNetworkingAndFiles(gcd *gothings.GrandCentralDispatcher, service bool) { func loadNetworkingAndFiles(gcd *gothings.GrandCentralDispatcher, service bool, clientUI bool) {
if runtime.GOOS == "android" { if service || clientUI || runtime.GOOS == "android" {
clientIn := path.Join(the.CwtchDir, "clientIn") clientIn := path.Join(the.CwtchDir, "clientIn")
serviceIn := path.Join(the.CwtchDir, "serviceIn") serviceIn := path.Join(the.CwtchDir, "serviceIn")
if service { if service {