Commit 40463c7a authored by spiiroin's avatar spiiroin

[systemd] Change systemd_control_service() return value and type

The systemd_control_service() function looks like it should return
a boolean success/failure, but it is returning integer zero on success
and integer one on failure - which is confusing.

Make it return gboolean value so that success is TRUE and failure FALSE.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 4e7f9709
...@@ -262,9 +262,8 @@ int activate_sync(const char *mode) ...@@ -262,9 +262,8 @@ int activate_sync(const char *mode)
if(data->systemd) if(data->systemd)
{ {
if(!systemd_control_service(data->name, SYSTEMD_START)) if(!systemd_control_service(data->name, SYSTEMD_START))
mark_active(data->name, 0);
else
goto error; goto error;
mark_active(data->name, 0);
} }
else if(data->launch) else if(data->launch)
{ {
...@@ -323,7 +322,7 @@ int activate_sync_post(const char *mode) ...@@ -323,7 +322,7 @@ int activate_sync_post(const char *mode)
log_debug("launching post-enum-app %s\n", data->name); log_debug("launching post-enum-app %s\n", data->name);
if(data->systemd) if(data->systemd)
{ {
if(systemd_control_service(data->name, SYSTEMD_START)) if(!systemd_control_service(data->name, SYSTEMD_START))
goto error; goto error;
mark_active(data->name, 1); mark_active(data->name, 1);
} }
...@@ -445,7 +444,7 @@ static void appsync_stop_apps(int post) ...@@ -445,7 +444,7 @@ static void appsync_stop_apps(int post)
if(data->systemd && data->state == APP_STATE_ACTIVE && data->post == post) if(data->systemd && data->state == APP_STATE_ACTIVE && data->post == post)
{ {
log_debug("stopping %s-enum-app %s", post ? "post" : "pre", data->name); 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); log_debug("Failed to stop %s\n", data->name);
data->state = APP_STATE_DONTCARE; data->state = APP_STATE_DONTCARE;
} }
......
/** /**
@file usb_moded-systemd.c @file usb_moded-systemd.c
Copyright (C) 2013 Jolla oy. All rights reserved. Copyright (C) 2013-2016 Jolla oy. All rights reserved.
@author: Philippe De Swert <philippe.deswert@jollamobile.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 This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
version 2 as published by the Free Software Foundation. version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the Lesser GNU General Public License You should have received a copy of the Lesser GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
...@@ -57,13 +58,13 @@ static DBusConnection * get_systemd_dbus_connection(void) ...@@ -57,13 +58,13 @@ static DBusConnection * get_systemd_dbus_connection(void)
// mode = replace // mode = replace
// method = StartUnit or StopUnit // method = StartUnit or StopUnit
int systemd_control_service(const char *name, const char *method) gboolean systemd_control_service(const char *name, const char *method)
{ {
DBusConnection *bus; DBusConnection *bus;
DBusError error; DBusError error;
DBusMessage *msg = NULL, *reply = NULL; DBusMessage *msg = NULL, *reply = NULL;
int ret = 1; gboolean ret = FALSE;
const char * replace = "replace"; const char * replace = "replace";
dbus_error_init(&error); dbus_error_init(&error);
...@@ -88,7 +89,7 @@ int systemd_control_service(const char *name, const char *method) ...@@ -88,7 +89,7 @@ int systemd_control_service(const char *name, const char *method)
if(reply) if(reply)
{ {
dbus_message_unref(reply); dbus_message_unref(reply);
ret = 0; ret = TRUE;
} }
dbus_message_unref(msg); dbus_message_unref(msg);
} }
......
/* /*
Copyright (C) 2013 Jolla Oy. All rights reserved. Copyright (C) 2013-2016 Jolla Oy. All rights reserved.
author: Philippe De Swert <philippe.deswert@njollamobile.com> author: Philippe De Swert <philippe.deswert@njollamobile.com>
author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License modify it under the terms of the Lesser GNU General Public License
...@@ -22,4 +23,4 @@ ...@@ -22,4 +23,4 @@
#define SYSTEMD_STOP "StopUnit" #define SYSTEMD_STOP "StopUnit"
#define SYSTEMD_START "StartUnit" #define SYSTEMD_START "StartUnit"
int systemd_control_service(const char *name, const char *method); gboolean systemd_control_service(const char *name, const char *method);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment