Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Split out appsync-dbus as an extra compile-time option
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Nov 25, 2013
1 parent fc7b073 commit fa5488f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
8 changes: 8 additions & 0 deletions configure.ac
Expand Up @@ -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" ;;
Expand Down
8 changes: 6 additions & 2 deletions src/Makefile.am
Expand Up @@ -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

Expand Down
18 changes: 16 additions & 2 deletions src/usb_moded-appsync.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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 */
}
}
}
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/usb_moded.c
Expand Up @@ -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 */
Expand Down

0 comments on commit fa5488f

Please sign in to comment.