From fa5488f4a76b2705a7611556494aaa3eb9c513c8 Mon Sep 17 00:00:00 2001 From: Philippe De Swert Date: Mon, 25 Nov 2013 15:21:07 +0200 Subject: [PATCH] Split out appsync-dbus as an extra compile-time option Signed-off-by: Philippe De Swert --- configure.ac | 8 ++++++++ src/Makefile.am | 8 ++++++-- src/usb_moded-appsync.c | 18 ++++++++++++++++-- src/usb_moded.c | 5 +++-- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 460d397..49942d0 100644 --- a/configure.ac +++ b/configure.ac @@ -70,6 +70,14 @@ AC_ARG_ENABLE([app_sync], AS_HELP_STRING([--enable-app-sync], [Enable applicatio esac],[app_sync=true]) AM_CONDITIONAL([APP_SYNC], [test x$app_sync = xtrue]) +AC_ARG_ENABLE([app_sync_dbus], AS_HELP_STRING([--enable-app-sync-dbus], [Enable application syncing with dbus @<:@default=false@:>@]), + [case "${enableval}" in + yes) app_sync_dbus=true ; CFLAGS="-DAPP_SYNC_DBUS $CFLAGS" ;; + no) app_sync_dbus=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-app-sync-dbus]) ;; + esac],[app_sync_dbus=false]) +AM_CONDITIONAL([APP_SYNC_DBUS], [test x$app_sync_dbus = xtrue]) + AC_ARG_ENABLE([udev], AS_HELP_STRING([--enable-udev], [Enable udev interface @<:@default=true@:>@]), [case "${enableval}" in yes) udev=true ; CFLAGS="-DUDEV -ludev $CFLAGS" ;; diff --git a/src/Makefile.am b/src/Makefile.am index 8bd9f3e..d280d66 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -60,10 +60,14 @@ if APP_SYNC usb_moded_SOURCES += \ usb_moded-appsync.c \ usb_moded-appsync.h \ + usb_moded-systemd.c \ + usb_moded-systemd.h +endif + +if APP_SYNC_DBUS +usb_moded_SOURCES += \ usb_moded-appsync-dbus.c \ usb_moded-appsync-dbus.h \ - usb_moded-systemd.c \ - usb_moded-systemd.h \ usb_moded-appsync-dbus-private.h endif diff --git a/src/usb_moded-appsync.c b/src/usb_moded-appsync.c index 2709600..f1c34c5 100644 --- a/src/usb_moded-appsync.c +++ b/src/usb_moded-appsync.c @@ -49,6 +49,12 @@ static GList *sync_list = NULL; static unsigned sync_tag = 0; static unsigned enum_tag = 0; static struct timeval sync_tv; +#ifdef APP_SYNC_DBUS +static int no_dbus = 0; +#else +static int no_dbus = 0; +#endif /* APP_SYNC_DBUS */ + static void free_elem(gpointer aptr) { @@ -100,7 +106,9 @@ void readlist(void) if( sync_list ) { log_debug("Sync list valid\n"); +#ifdef APP_SYN_DBUS usb_moded_app_sync_init_connection(); +#endif } } @@ -154,7 +162,6 @@ int activate_sync(const char *mode) { GList *iter; int count = 0, count2 = 0; - int no_dbus = 0; log_debug("activate sync"); @@ -192,12 +199,14 @@ int activate_sync(const char *mode) return(0); } +#ifdef APP_SYNC_DBUS /* check dbus initialisation, skip dbus activated services if this fails */ if(!usb_moded_app_sync_init()) { log_debug("dbus setup failed => skipping dbus launched apps \n"); no_dbus = 1; } +#endif /* APP_SYNC_DBUS */ /* start timer */ log_debug("Starting appsync timer\n"); @@ -228,14 +237,17 @@ int activate_sync(const char *mode) #endif /* UPSTART */ else if(data->launch) { - /* skipping if dbus session bus is not available */ + /* skipping if dbus session bus is not available, + or not compiled in */ if(no_dbus) mark_active(data->name); +#ifdef APP_SYNC_DBUS else if(usb_moded_dbus_app_launch(data->launch)) mark_active(data->name); else goto error; +#endif /* APP_SYNC_DBUS */ } } } @@ -315,8 +327,10 @@ static gboolean enumerate_usb(gpointer data) timersub(&tv, &sync_tv, &tv); log_debug("sync to enum: %.3f seconds", tv.tv_sec + tv.tv_usec * 1e-6); +#ifdef APP_SYNC_DBUS /* remove dbus service */ usb_moded_appsync_cleanup(); +#endif /* APP_SYNC_DBUS */ } /* return false to stop the timer from repeating */ return FALSE; diff --git a/src/usb_moded.c b/src/usb_moded.c index 96e1e6a..65c6e69 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -544,9 +544,10 @@ static void handle_exit(void) #ifdef APP_SYNC free_appsync_list(); +#ifdef APP_SYNC_DBUS usb_moded_appsync_cleanup(); -#endif - +#endif /* APP_SYNC_DBUS */ +#endif /* APP_SYNC */ dbus_shutdown(); /* If the mainloop is initialised, unreference it */