From a98aac62b9699ec3d4f457dfcf24b1fd09c53736 Mon Sep 17 00:00:00 2001 From: Philippe De Swert Date: Tue, 28 Apr 2015 10:56:45 +0300 Subject: [PATCH] [upstart] Remove upstart appsync support Upstart is being obsoleted, so no use to keep this support in. Systemd is our new evil overlord. Author: Thomas Perl Signed-off-by: Philippe De Swert --- configure.ac | 8 -- docs/usb_moded-doc.txt | 10 +-- src/Makefile.am | 6 -- src/usb_moded-appsync.c | 27 ------- src/usb_moded-appsync.h | 2 - src/usb_moded-modesetting.c | 1 - src/usb_moded-upstart.c | 145 ------------------------------------ src/usb_moded-upstart.h | 33 -------- 8 files changed, 1 insertion(+), 231 deletions(-) delete mode 100644 src/usb_moded-upstart.c delete mode 100644 src/usb_moded-upstart.h diff --git a/configure.ac b/configure.ac index 6b1cf1c..d450ad9 100644 --- a/configure.ac +++ b/configure.ac @@ -56,14 +56,6 @@ AC_ARG_ENABLE([app_sync_dbus], AS_HELP_STRING([--enable-app-sync-dbus], [Enable esac],[app_sync_dbus=false]) AM_CONDITIONAL([APP_SYNC_DBUS], [test x$app_sync_dbus = xtrue]) -AC_ARG_ENABLE([upstart], AS_HELP_STRING([--enable-upstart], [Enable upstart interface for appsync @<:@default=false@:>@]), - [case "${enableval}" in - yes) upstart=true ; CFLAGS="-DUPSTART $CFLAGS" ;; - no) upstart=false ;; - *) AC_MSG_ERROR([bad value ${enableval} for --enable-upstart]) ;; - esac],[upstart=false]) -AM_CONDITIONAL([UPSTART], [test x$upstart = xtrue]) - AC_ARG_ENABLE([connman], AS_HELP_STRING([--enable-connman], [Enable connman support for usb tethering @<:@default=false@:>@]), [case "${enableval}" in yes) connman=true ; CFLAGS="-DCONNMAN $CFLAGS" ;; diff --git a/docs/usb_moded-doc.txt b/docs/usb_moded-doc.txt index 624208a..4a33945 100644 --- a/docs/usb_moded-doc.txt +++ b/docs/usb_moded-doc.txt @@ -209,7 +209,7 @@ Only condition is that it can be activated by dbus and that (preferably) it will notify usb_moded that it is ready by ready_method call on the session bus. This ready method call is just calling the regular usb_moded interface, but now on the session bus, with as argument the program name as defined in the config file. -Systemd and upstart are also supported. +Systemd is also supported. To achieve this you need to have a config file in /etc/usb-moded/run. Best practice would be giving it a descriptive name followed by .ini @@ -231,14 +231,6 @@ systemd = 1 The name here is the service name used when launching it for example with systemctl -For upstart: -[info] -name = foo -mode = foo_mode -upstart = 1 - -Here the name is service name used by upstart. - Those files will be read on start and usb_moded will keep a list of apps to launch for a certain mode. This also means that if you change the files or add/remove some you need to restart usb_moded. Later when the mode is activated, usb_moded will start diff --git a/src/Makefile.am b/src/Makefile.am index d25debb..637a113 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -61,12 +61,6 @@ usb_moded_SOURCES += \ usb_moded-appsync-dbus-private.h endif -if UPSTART -usb_moded_SOURCES += \ - usb_moded-upstart.h \ - usb_moded-upstart.c -endif - usb_moded_util_CPPFLAGS = \ $(USB_MODED_CFLAGS) diff --git a/src/usb_moded-appsync.c b/src/usb_moded-appsync.c index 7c179aa..babf8f3 100644 --- a/src/usb_moded-appsync.c +++ b/src/usb_moded-appsync.c @@ -38,7 +38,6 @@ #include "usb_moded-appsync-dbus-private.h" #include "usb_moded-modesetting.h" #include "usb_moded-log.h" -#include "usb_moded-upstart.h" #include "usb_moded-systemd.h" static struct list_elem *read_file(const gchar *filename, int diag); @@ -152,8 +151,6 @@ static struct list_elem *read_file(const gchar *filename, int diag) log_debug("Launch = %s\n", list_item->launch); list_item->mode = g_key_file_get_string(settingsfile, APP_INFO_ENTRY, APP_INFO_MODE_KEY, NULL); log_debug("Launch mode = %s\n", list_item->mode); - list_item->upstart = g_key_file_get_integer(settingsfile, APP_INFO_ENTRY, APP_INFO_UPSTART_KEY, NULL); - log_debug("Upstart control = %d\n", list_item->upstart); list_item->systemd = g_key_file_get_integer(settingsfile, APP_INFO_ENTRY, APP_INFO_SYSTEMD_KEY, NULL); log_debug("Systemd control = %d\n", list_item->systemd); list_item->post = g_key_file_get_integer(settingsfile, APP_INFO_ENTRY, APP_INFO_POST, NULL); @@ -250,15 +247,6 @@ int activate_sync(const char *mode) else goto error; } -#ifdef UPSTART - else if(data->upstart) - { - if(!upstart_control_job(data->name, UPSTART_START)) - mark_active(data->name); - else - goto error; - } -#endif /* UPSTART */ else if(data->launch) { /* skipping if dbus session bus is not available, @@ -319,13 +307,6 @@ int activate_sync_post(const char *mode) if(systemd_control_service(data->name, SYSTEMD_START)) goto error; } -#ifdef UPSTART - else if(data->upstart) - { - if(upstart_control_job(data->name, UPSTART_START)) - goto error; - } -#endif /* UPSTART */ else if(data->launch) { /* skipping if dbus session bus is not available, @@ -432,14 +413,6 @@ int appsync_stop(void) if(!systemd_control_service(data->name, SYSTEMD_STOP)) log_debug("Failed to stop %s\n", data->name); } -#ifdef UPSTART - else if(data->upstart) - { - log_debug("Stopping %s\n", data->launch); - if(upstart_control_job(data->name, UPSTART_STOP)) - log_debug("Failed to stop %s\n", data->name); - } -#endif /* UPSTART */ } return(0); diff --git a/src/usb_moded-appsync.h b/src/usb_moded-appsync.h index e191774..ec8ca60 100644 --- a/src/usb_moded-appsync.h +++ b/src/usb_moded-appsync.h @@ -26,7 +26,6 @@ #define APP_INFO_MODE_KEY "mode" #define APP_INFO_NAME_KEY "name" #define APP_INFO_LAUNCH_KEY "launch" -#define APP_INFO_UPSTART_KEY "upstart" #define APP_INFO_SYSTEMD_KEY "systemd" #define APP_INFO_POST "post" @@ -40,7 +39,6 @@ typedef struct list_elem char *mode; /* mode in which to launch the app */ char *launch; /* dbus launch command/address */ int active; /* marker to check if the app has started sucessfully */ - int upstart; /* marker to know if we start it with upstart or not */ int systemd; /* marker to know if we start it with systemd or not */ int post; /* marker to indicate when to start the app */ /*@}*/ diff --git a/src/usb_moded-modesetting.c b/src/usb_moded-modesetting.c index 28ea911..b5c978d 100644 --- a/src/usb_moded-modesetting.c +++ b/src/usb_moded-modesetting.c @@ -40,7 +40,6 @@ #include "usb_moded-config.h" #include "usb_moded-modesetting.h" #include "usb_moded-network.h" -#include "usb_moded-upstart.h" #include "usb_moded-android.h" static void report_mass_storage_blocker(const char *mountpoint, int try); diff --git a/src/usb_moded-upstart.c b/src/usb_moded-upstart.c deleted file mode 100644 index dfbc9ff..0000000 --- a/src/usb_moded-upstart.c +++ /dev/null @@ -1,145 +0,0 @@ -/** - @file usb_moded-upstart.c - - Copyright (C) 2012 Nokia Corporation. All rights reserved. - - @author: Philippe De Swert - - This program is free software; you can redistribute it and/or - modify it under the terms of the Lesser GNU General Public License - version 2 as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the Lesser GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - 02110-1301 USA -*/ - -#define _GNU_SOURCE -#include -#include - -#include -#include -#include - -#include "usb_moded-dbus.h" -#include "usb_moded-dbus-private.h" -#include "usb_moded.h" -#include "usb_moded-log.h" - -#define SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket" -#define UPSTART_BUS_ADDRESS "unix:abstract=/com/ubuntu/upstart" -#define UPSTART_SERVICE "com.ubuntu.Upstart" -#define UPSTART_REQUEST_PATH "/com/ubuntu/Upstart" -#define UPSTART_INTERFACE "com.ubuntu.Upstart0_6" -#define UPSTART_JOB_INTERFACE "com.ubuntu.Upstart0_6.Job" - -static DBusConnection * get_upstart_dbus_connection(void) -{ - DBusError error; - DBusConnection *conn = 0; - - dbus_error_init(&error); - - conn = dbus_connection_open_private("unix:abstract=/com/ubuntu/upstart", &error); - if (!conn) - { - if (dbus_error_is_set(&error)) - log_err("Cannot connect to upstart: %s", error.message); - else - log_err("Cannot connect to upstart"); - return 0; - } - - return conn; -} - -static char *get_upstart_job_by_name(const char *name) -{ - DBusError error; - DBusConnection *conn = 0; - DBusMessage *msg = NULL, *reply = NULL; - char *ret = 0; - - dbus_error_init(&error); - conn = get_upstart_dbus_connection(); - if(!conn) - return NULL; - if ((msg = dbus_message_new_method_call(UPSTART_SERVICE, UPSTART_REQUEST_PATH, UPSTART_INTERFACE, "GetJobByName")) != NULL) - { - dbus_message_append_args (msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID); - if ((reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, NULL)) != NULL) - { - dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &ret, DBUS_TYPE_INVALID); - /* log_debug("got following path from upstart: %s for job name %s\n", ret, name);*/ - dbus_message_unref(reply); - } - dbus_message_unref(msg); - } - dbus_connection_close(conn); - - return ret; -} - -int upstart_control_job(const char *name, const char * action) -{ - DBusError error; - DBusConnection *conn = 0; - char *job = 0, *arg = 0; - DBusMessageIter iter, iter2; - DBusMessage *msg = NULL, *reply = NULL; - dbus_bool_t wait = FALSE; - - conn = get_upstart_dbus_connection(); - if(!conn) - return 1; - job = get_upstart_job_by_name(name); - if(job) - if ((msg = dbus_message_new_method_call(UPSTART_SERVICE, job, UPSTART_JOB_INTERFACE, action)) != NULL) - { - dbus_message_iter_init_append(msg, &iter); - - if(!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &iter2)) - { - log_err("Could not open dbus container\n"); - goto fail; - } - asprintf(&arg, "NAME=%s", name); - if (!dbus_message_iter_append_basic(&iter2, DBUS_TYPE_STRING, &arg)) - { - log_err("Could not add string array\n"); - dbus_message_iter_abandon_container(&iter, &iter2); - goto fail; - } - if (!dbus_message_iter_close_container(&iter, &iter2)) - { - log_err( "Cannot close container"); - goto fail; - } - if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &wait)) - { - log_err("Could not set wait state\n"); - goto fail; - } - if ((reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, NULL)) != NULL) - { - dbus_message_unref(reply); - } - dbus_message_unref(msg); - } - else - log_err("No upstart path for %s\n", name); - dbus_connection_close(conn); - - return 0; - -fail: - dbus_connection_close(conn); - return 1; -} diff --git a/src/usb_moded-upstart.h b/src/usb_moded-upstart.h deleted file mode 100644 index 23fa2ac..0000000 --- a/src/usb_moded-upstart.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - @file usb_moded-upstart.h - - Copyright (C) 2012 Nokia Corporation. All rights reserved. - - @author: Philippe De Swert - - This program is free software; you can redistribute it and/or - modify it under the terms of the Lesser GNU General Public License - version 2 as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the Lesser GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - 02110-1301 USA -*/ - -#include -#include - -#include -#include -#include - -#define UPSTART_START "Start" -#define UPSTART_STOP "Stop" - -int upstart_control_job(const char *name, const char * action);