Commit 6f6d4fc7 authored by spiiroin's avatar spiiroin

Merge branch 'mer1694_startup_and_exit' into 'master'

Fix issues related to usb-moded startup, exit and dbus usage



See merge request !20
parents 836d79fe f3a01678
......@@ -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
......@@ -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)
{
......@@ -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);
}
......@@ -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 */
......
/*
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
......@@ -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);
/*
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
......@@ -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);
......@@ -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);
......@@ -2,10 +2,11 @@
@file usb_moded-dbus.c
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2012-2015 Jolla. All rights reserved.
Copyright (C) 2012-2016 Jolla. All rights reserved.
@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
......@@ -44,6 +45,8 @@
#define INIT_DONE_MATCH "type='signal',interface='"INIT_DONE_INTERFACE"',member='"INIT_DONE_SIGNAL"'"
static DBusConnection *dbus_connection_sys = NULL;
static gboolean have_service_name = FALSE;
extern gboolean rescue_mode;
/**
......@@ -52,7 +55,12 @@ extern gboolean rescue_mode;
static void usb_moded_send_config_signal(const char *section, const char *key, const char *value)
{
log_debug(USB_MODE_CONFIG_SIGNAL_NAME ": %s %s %s\n", section, key, value);
if (dbus_connection_sys)
if( !have_service_name )
{
log_err("config notification without service: [%s] %s=%s",
section, key, value);
}
else if (dbus_connection_sys)
{
DBusMessage* msg = dbus_message_new_signal(USB_MODE_OBJECT, USB_MODE_INTERFACE, USB_MODE_CONFIG_SIGNAL_NAME);
if (msg) {
......@@ -451,7 +459,6 @@ error_reply:
}
}
EXIT:
if(reply)
......@@ -467,18 +474,25 @@ EXIT:
return status;
}
DBusConnection *usb_moded_dbus_get_connection(void)
{
DBusConnection *connection = 0;
if( dbus_connection_sys )
connection = dbus_connection_ref(dbus_connection_sys);
else
log_err("something asked for connection ref while unconnected");
return connection;
}
/**
* Init dbus for usb_moded
* Establish D-Bus SystemBus connection
*
* @return TRUE when everything went ok
*/
gboolean usb_moded_dbus_init(void)
gboolean usb_moded_dbus_init_connection(void)
{
gboolean status = FALSE;
DBusError error;
int ret;
dbus_error_init(&error);
DBusError error = DBUS_ERROR_INIT;
/* connect to system bus */
if ((dbus_connection_sys = dbus_bus_get(DBUS_BUS_SYSTEM, &error)) == NULL)
......@@ -491,6 +505,35 @@ gboolean usb_moded_dbus_init(void)
if (!dbus_connection_add_filter(dbus_connection_sys, msg_handler, NULL, NULL))
goto EXIT;
/* Listen to init-done signals */
dbus_bus_add_match(dbus_connection_sys, INIT_DONE_MATCH, 0);
/* Connect D-Bus to the mainloop */
dbus_connection_setup_with_g_main(dbus_connection_sys, NULL);
/* everything went fine */
status = TRUE;
EXIT:
dbus_error_free(&error);
return status;
}
/**
* Reserve "com.meego.usb_moded" D-Bus Service Name
*
* @return TRUE when everything went ok
*/
gboolean usb_moded_dbus_init_service(void)
{
gboolean status = FALSE;
DBusError error = DBUS_ERROR_INIT;
int ret;
if( !dbus_connection_sys ) {
goto EXIT;
}
/* Acquire D-Bus service */
ret = dbus_bus_request_name(dbus_connection_sys, USB_MODE_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &error);
if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
......@@ -500,19 +543,8 @@ gboolean usb_moded_dbus_init(void)
log_debug("DBUS ERROR: %s, %s \n", error.name, error.message);
goto EXIT;
}
/* only match on signals/methods we support (if needed)
dbus_bus_add_match(dbus_connection_sys, USB_MODE_INTERFACE, &error);
*/
/* Listen to init-done signals */
dbus_bus_add_match(dbus_connection_sys, INIT_DONE_MATCH, 0);
dbus_threads_init_default();
/* Connect D-Bus to the mainloop */
dbus_connection_setup_with_g_main(dbus_connection_sys, NULL);
log_debug("claimed name %s", USB_MODE_SERVICE);
have_service_name = TRUE;
/* everything went fine */
status = TRUE;
......@@ -521,6 +553,26 @@ EXIT:
return status;
}
/** Release "com.meego.usb_moded" D-Bus Service Name
*/
static void usb_moded_dbus_cleanup_service(void)
{
if( !have_service_name )
goto EXIT;
have_service_name = FALSE;
log_debug("release name %s", USB_MODE_SERVICE);
if( dbus_connection_sys &&
dbus_connection_get_is_connected(dbus_connection_sys) )
{
dbus_bus_release_name(dbus_connection_sys, USB_MODE_SERVICE, NULL);
}
EXIT:
return;
}
/**
* Clean up the dbus connections on exit
*
......@@ -530,9 +582,11 @@ void usb_moded_dbus_cleanup(void)
/* clean up system bus connection */
if (dbus_connection_sys != NULL)
{
dbus_bus_release_name(dbus_connection_sys, USB_MODE_SERVICE, NULL);
usb_moded_dbus_cleanup_service();
dbus_connection_remove_filter(dbus_connection_sys, msg_handler, NULL);
dbus_connection_unref(dbus_connection_sys);
dbus_connection_unref(dbus_connection_sys),
dbus_connection_sys = NULL;
}
}
......@@ -549,6 +603,12 @@ static int usb_moded_dbus_signal(const char *signal_type, const char *content)
int result = 1;
DBusMessage* msg = 0;
if( !have_service_name )
{
log_err("sending signal without service: %s(%s)",
signal_type, content);
goto EXIT;
}
if(!dbus_connection_sys)
{
log_err("Dbus system connection broken!\n");
......@@ -632,3 +692,104 @@ int usb_moded_send_hidden_modes_signal(const char *hidden_modes)
{
return(usb_moded_dbus_signal(USB_MODE_HIDDEN_MODES_SIGNAL_NAME, hidden_modes));
}
/** Async reply handler for usb_moded_get_name_owner_async()
*
* @param pc Pending call object pointer
* @param aptr Notify function to call (as a void pointer)
*/
static void usb_moded_get_name_owner_cb(DBusPendingCall *pc, void *aptr)
{
usb_moded_get_name_owner_fn cb = aptr;
DBusMessage *rsp = 0;
const char *dta = 0;
DBusError err = DBUS_ERROR_INIT;
if( !(rsp = dbus_pending_call_steal_reply(pc)) ) {
log_err("did not get reply");
goto EXIT;
}
if( dbus_set_error_from_message(&err, rsp) )
{
if( strcmp(err.name, DBUS_ERROR_NAME_HAS_NO_OWNER) )
log_err("error reply: %s: %s", err.name, err.message);
goto EXIT;
}
if( !dbus_message_get_args(rsp, &err,
DBUS_TYPE_STRING, &dta,
DBUS_TYPE_INVALID) )
{
if( strcmp(err.name, DBUS_ERROR_NAME_HAS_NO_OWNER) )
log_err("parse error: %s: %s", err.name, err.message);
goto EXIT;
}
EXIT:
/* Allways call the notification function. Equate any error
* situations with "service does not have an owner". */
cb(dta ?: "");
if( rsp ) dbus_message_unref(rsp);
dbus_error_free(&err);
}
/** Helper function for making async dbus name owner queries
*
* @param name D-Bus name to query
* @param cb Function to call when async reply is received
* @param ppc Where to store pending call object, or NULL
*
* @return TRUE if method call was sent, FALSE otherwise
*/
gboolean usb_moded_get_name_owner_async(const char *name,
usb_moded_get_name_owner_fn cb,
DBusPendingCall **ppc)
{
gboolean ack = FALSE;
DBusMessage *req = 0;
DBusPendingCall *pc = 0;
if(!dbus_connection_sys)
goto EXIT;
req = dbus_message_new_method_call(DBUS_INTERFACE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS,
DBUS_GET_NAME_OWNER_REQ);
if( !req ) {
log_err("could not create method call message");
goto EXIT;
}
if( !dbus_message_append_args(req,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID) ) {
log_err("could not add method call parameters");
goto EXIT;
}
if( !dbus_connection_send_with_reply(dbus_connection_sys, req, &pc, -1) )
goto EXIT;
if( !pc )
goto EXIT;
if( !dbus_pending_call_set_notify(pc, usb_moded_get_name_owner_cb, cb, 0) )
goto EXIT;
ack = TRUE;
if( ppc )
*ppc = pc, pc = 0;
EXIT:
if( pc ) dbus_pending_call_unref(pc);
if( req ) dbus_message_unref(req);
return ack;
}
This diff is collapsed.
/*
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2013-2016 Jolla Ltd.
Author: Philippe De Swert <philippe.de-swert@nokia.com>
Author: Vesa Halttunen <vesa.halttunen@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
......@@ -24,14 +27,19 @@
/*============================================================================= */
#define DEVICELOCK_SERVICE "org.nemomobile.lipstick"
#define DEVICELOCK_REQUEST_PATH "/devicelock"
#define DEVICELOCK_REQUEST_IF "org.nemomobile.lipstick.devicelock"
#define DEVICELOCK_STATE_REQ "state"
#define DEVICELOCK_OBJECT "/devicelock"
#define DEVICELOCK_INTERFACE "org.nemomobile.lipstick.devicelock"
#define DEVICELOCK_GET_STATE_REQ "state"
#define DEVICELOCK_STATE_CHANGED_SIG "stateChanged"
#define DEVICELOCK_LOCKED "Locked"
#define MATCH_DEVICELOCK_SIGNALS\
#define DEVICELOCK_STATE_CHANGED_MATCH\
"type='signal'"\
",interface='"DEVICELOCK_REQUEST_IF"'"\
",path='"DEVICELOCK_REQUEST_PATH"'"
",interface='"DEVICELOCK_INTERFACE"'"\
",path='"DEVICELOCK_OBJECT"'"\
",member='"DEVICELOCK_STATE_CHANGED_SIG"'"
#define DEVICELOCK_NAME_OWNER_CHANGED_MATCH\
"type='signal'"\
",interface='"DBUS_INTERFACE_DBUS"'"\
",member='"DBUS_NAME_OWNER_CHANGED_SIG"'"\
",arg0='"DEVICELOCK_SERVICE"'"
This diff is collapsed.
/**
@file usb_moded-dsme.h
Copyright (C) 2013 Jolla. All rights reserved.
Copyright (C) 2013-2016 Jolla. All rights reserved.
@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
......@@ -20,4 +21,6 @@
02110-1301 USA
*/
int is_in_user_state(void);
gboolean is_in_user_state(void);
gboolean dsme_listener_start(void);
void dsme_listener_stop(void);
/*
Copyright (C) 2012 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
......@@ -24,5 +27,5 @@
/*============================================================================= */
int usb_moded_get_export_permission(void);
int start_devicelock_listener(void);
int stop_devicelock_listener(void);
gboolean start_devicelock_listener(void);
void stop_devicelock_listener(void);
......@@ -2,9 +2,12 @@
@file usb_moded-log.c
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2016 Jolla Ltd.
@author: Philippe De Swert <philippe.de-swert@nokia.com>
@author: Simo Piiroinen <simo.piiroinen@nokia.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
......@@ -53,6 +56,14 @@ static char *strip(char *str)
return str;
}
static struct timeval log_begtime = { 0, 0 };
static void log_gettime(struct timeval *tv)
{
gettimeofday(tv, 0);
timersub(tv, &log_begtime, tv);
}
/**
* Print the logged messages to the selected output
*
......@@ -79,10 +90,10 @@ void log_emit_va(int lev, const char *fmt, va_list va)
#if LOG_ENABLE_TIMESTAMPS
{
struct timeval tv;
gettimeofday(&tv, 0);
fprintf(stderr, "%ld.%06ld ",
log_gettime(&tv);
fprintf(stderr, "%3ld.%03ld ",
(long)tv.tv_sec,
(long)tv.tv_usec);
(long)tv.tv_usec/1000);
}
#endif
......@@ -156,3 +167,10 @@ inline void log_set_level(int lev)
log_level = lev;
}
/** Initialize logging */
void log_init(void)
{
/* Get reference time used for verbose logging */
if( !timerisset(&log_begtime) )
gettimeofday(&log_begtime, 0);
}
/*
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2016 Jolla Ltd.
Author: Philippe De Swert <philippe.de-swert@nokia.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
......@@ -44,6 +46,7 @@ enum
void log_set_level(int lev);
int log_get_level(void);
void log_init(void);
void log_emit_va(int lev, const char *fmt, va_list va);
void log_emit(int lev, const char *fmt, ...) __attribute__((format(printf,2,3)));
void log_debugf(const char *fmt, ...) __attribute__((format(printf,1,2)));
......
......@@ -2,8 +2,13 @@
@file usb_moded-modesetting.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: Bernd Wachter <bernd.wachter@jollamobile.com>
@author: Slava Monich <slava.monich@jolla.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
......@@ -567,7 +572,7 @@ int usb_moded_mode_cleanup(const char *module)
#ifdef APP_SYNC
/* Stop applications started due to entering this mode */
appsync_stop(0);
appsync_stop(FALSE);
#endif /* APP_SYNC */
if(!strcmp(module, MODULE_MASS_STORAGE)|| !strcmp(module, MODULE_FILE_STORAGE))
......
......@@ -2,10 +2,12 @@
@file usb_moded-modules.c
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Copyright (C) 2012-2015 Jolla. All rights reserved.
Copyright (C) 2012-2016 Jolla. All rights reserved.
@author: Philippe De Swert <philippe.de-swert@nokia.com>
@author: Philippe De Swert <philippe.deswert@jollamobile.com>
@author: Slava Monich <slava.monich@jolla.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
......@@ -43,7 +45,7 @@
/* kmod context - initialized at start in usb_moded_init by ctx_init()
and cleaned up by ctx_cleanup() functions */
struct kmod_ctx *ctx;
static struct kmod_ctx *ctx = 0;
/* kmod module init */
void usb_moded_module_ctx_init(void)
......@@ -55,7 +57,8 @@ void usb_moded_module_ctx_init(void)
/* kmod module cleanup */
void usb_moded_module_ctx_cleanup(void)
{
kmod_unref(ctx);
if( ctx )
kmod_unref(ctx), ctx = 0;
}
/** load module
......
......@@ -26,6 +26,7 @@
#include "usb_moded-ssu.h"
#include "usb_moded-log.h"
#include "usb_moded-dbus-private.h"
/** SSU D-Bus service name */
#define SSU_DBUS_SERVICE "org.nemo.ssu"
......@@ -74,9 +75,8 @@ usb_moded_get_ssu_display_name(SsuDisplayType type_id)
const char *val = 0;
DBusError err = DBUS_ERROR_INIT;
if( !(con = dbus_bus_get(DBUS_BUS_SYSTEM, &err)) ) {
log_err("could not connect to system bus: %s: %s",
err.name, err.message);
if( !(con = usb_moded_dbus_get_connection()) ) {
log_err("not connected to system bus");
goto EXIT;
}
......
/**
@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: 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
......@@ -34,69 +35,129 @@
#include "usb_moded-log.h"
#include "usb_moded-systemd.h"
static DBusConnection * get_systemd_dbus_connection(void)
{
DBusError error;
DBusConnection *conn = 0;
#define SYSTEMD_DBUS_SERVICE "org.freedesktop.systemd1"
#define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1"
#define SYSTEMD_DBUS_INTERFACE "org.freedesktop.systemd1.Manager"
dbus_error_init(&error);
conn = dbus_connection_open_private("unix:path=/run/systemd/private", &error);
if (!conn)
{
if (dbus_error_is_set(&error))
log_err("Cannot connect to systemd: %s", error.message);
else
log_err("Cannot connect to systemd");
dbus_error_free(&error);
return 0;
}
/* SystemBus connection ref used for systemd control ipc */
static DBusConnection *systemd_con = NULL;
// QDBusObjectPath org.freedesktop.systemd1.Manager.StartUnit(QString name, QString mode)
// QDBusObjectPath org.freedesktop.systemd1.Manager.StopUnit(QString name, QString mode)
return conn;
}
// mode = replace
// method = StartUnit or StopUnit
int systemd_control_service(const char *name, const char *method)
gboolean systemd_control_service(const char *name, const char *method)
{
DBusMessage *req = NULL;
DBusMessage *rsp = NULL;
DBusError err = DBUS_ERROR_INIT;
const char *arg = "replace";
const char *res = 0;
DBusConnection *bus;
DBusError error;
DBusMessage *msg = NULL, *reply = NULL;
int ret = 1;
const char * replace = "replace";
dbus_error_init(&error);
log_debug("%s(%s) ...", method, name);
log_debug("Handling %s, with systemd, method %s\n", name, method);
if( !systemd_con ) {
log_err("not connected to system bus; skip systemd unit control");
goto EXIT;
}
bus = get_systemd_dbus_connection();
if(!bus)
return(ret);
req = dbus_message_new_method_call(SYSTEMD_DBUS_SERVICE,
SYSTEMD_DBUS_PATH,
SYSTEMD_DBUS_INTERFACE,
method);
if( !req ) {
log_err("failed to construct %s.%s request",
SYSTEMD_DBUS_INTERFACE,
method);
goto EXIT;
}
msg = dbus_message_new_method_call("org.freedesktop.systemd1",
"/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", method);
if(msg)
if( !dbus_message_append_args(req,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_STRING, &arg,
DBUS_TYPE_INVALID))
{
if(!dbus_message_append_args (msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &replace, DBUS_TYPE_INVALID))
{
log_debug("error appending arguments\n");
dbus_message_unref(msg);
goto quit;
log_debug("error appending arguments");
goto EXIT;
}
reply = dbus_connection_send_with_reply_and_block(bus, msg, -1, &error);
if(reply)
{
dbus_message_unref(reply);
ret = 0;
rsp = dbus_connection_send_with_reply_and_block(systemd_con, req, -1, &err);
if( !rsp ) {
log_err("no reply to %s.%s request: %s: %s",
SYSTEMD_DBUS_INTERFACE,
method,
err.name, err.message);
goto EXIT;
}
if( dbus_set_error_from_message(&err, rsp) ) {
log_err("got error reply to %s.%s request: %s: %s",
SYSTEMD_DBUS_INTERFACE,
method,
err.name, err.message);
goto EXIT;
}
dbus_message_unref(msg);
if( !dbus_message_get_args(rsp, &err,
DBUS_TYPE_OBJECT_PATH, &res,
DBUS_TYPE_INVALID) ) {
log_err("failed to parse reply to %s.%s request: %s: %s",
SYSTEMD_DBUS_INTERFACE,