Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'mer1694_startup_and_exit' into 'master'
Fix issues related to usb-moded startup, exit and dbus usage



See merge request !20
  • Loading branch information
spiiroin committed Nov 7, 2016
2 parents 836d79f + f3a0167 commit 6f6d4fc
Show file tree
Hide file tree
Showing 18 changed files with 1,280 additions and 262 deletions.
12 changes: 7 additions & 5 deletions src/usb_moded-appsync.c
Expand Up @@ -2,8 +2,11 @@
@file usb_moded-appsync.c
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
@author: Philippe De Swert <philippe.de-swert@nokia.com>
@author: Philippe De Swert <philippe.deswert@jollamobile.com>
@author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
Expand Down Expand Up @@ -259,9 +262,8 @@ int activate_sync(const char *mode)
if(data->systemd)
{
if(!systemd_control_service(data->name, SYSTEMD_START))
mark_active(data->name, 0);
else
goto error;
mark_active(data->name, 0);
}
else if(data->launch)
{
Expand Down Expand Up @@ -320,7 +322,7 @@ int activate_sync_post(const char *mode)
log_debug("launching post-enum-app %s\n", data->name);
if(data->systemd)
{
if(systemd_control_service(data->name, SYSTEMD_START))
if(!systemd_control_service(data->name, SYSTEMD_START))
goto error;
mark_active(data->name, 1);
}
Expand Down Expand Up @@ -442,14 +444,14 @@ static void appsync_stop_apps(int post)
if(data->systemd && data->state == APP_STATE_ACTIVE && data->post == post)
{
log_debug("stopping %s-enum-app %s", post ? "post" : "pre", data->name);
if(systemd_control_service(data->name, SYSTEMD_STOP))
if(!systemd_control_service(data->name, SYSTEMD_STOP))
log_debug("Failed to stop %s\n", data->name);
data->state = APP_STATE_DONTCARE;
}
}
}

int appsync_stop(int force)
int appsync_stop(gboolean force)
{
/* If force arg is used, stop all applications that
* could have been started by usb-moded */
Expand Down
5 changes: 4 additions & 1 deletion src/usb_moded-appsync.h
@@ -1,8 +1,11 @@
/*
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
author: Philippe De Swert <philippe.de-swert@nokia.com>
author: Philippe De Swert <philippe.deswert@jollamobile.com>
author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
Expand Down Expand Up @@ -57,6 +60,6 @@ void readlist(int diag);
int activate_sync(const char *mode);
int activate_sync_post(const char *mode);
int mark_active(const gchar *name, int post);
int appsync_stop(int force);
int appsync_stop(gboolean force);
void free_appsync_list(void);
void usb_moded_appsync_cleanup(void);
29 changes: 27 additions & 2 deletions src/usb_moded-dbus-private.h
@@ -1,7 +1,12 @@
/*
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
Author: Philippe De Swert <philippe.de-swert@nokia.com>
Author: Philippe De Swert <philippe.deswert@jollamobile.com>
Author: Vesa Halttunen <vesa.halttunen@jollamobile.com>
Author: Martin Jones <martin.jones@jollamobile.com>
Author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
Expand All @@ -18,8 +23,20 @@
02110-1301 USA
*/

/* initialize dbus communication channels */
gboolean usb_moded_dbus_init(void);
/** Logical name for org.freedesktop.DBus.GetNameOwner method */
#define DBUS_GET_NAME_OWNER_REQ "GetNameOwner"

/** Logical name for org.freedesktop.DBus.NameOwnerChanged signal */
#define DBUS_NAME_OWNER_CHANGED_SIG "NameOwnerChanged"

/* Connect to D-Bus System Bus */
gboolean usb_moded_dbus_init_connection(void);

/* Claim D-Bus Service Name */
gboolean usb_moded_dbus_init_service(void);

/* Get current SystemBus connection */
DBusConnection *usb_moded_dbus_get_connection(void);

/* cleanup usb on exit */
void usb_moded_dbus_cleanup(void);
Expand All @@ -35,3 +52,11 @@ int usb_moded_send_supported_modes_signal(const char *supported_modes);

/* send hidden modes signal system bus */
int usb_moded_send_hidden_modes_signal(const char *hidden_modes);

/* Callback function type used with usb_moded_get_name_owner_async() */
typedef void (*usb_moded_get_name_owner_fn)(const char *owner);

/* Asynchronous GetNameOwner query */
gboolean usb_moded_get_name_owner_async(const char *name,
usb_moded_get_name_owner_fn cb,
DBusPendingCall **ppc);

0 comments on commit 6f6d4fc

Please sign in to comment.