From 720c04999eac0a3ba6785e36ac75bdc3222600e9 Mon Sep 17 00:00:00 2001 From: Jonathan Maw Date: Fri, 20 Jul 2012 11:14:02 +0100 Subject: [PATCH] Update NSM-related D-Bus interfaces and codegen Change all instances of conti to contiautomotive in bus names, object paths and interfaces. Change shutdown consumers' interface to com.contiautomotive.NodeStateManager.LifeCycleConsumer and replace the Shutdown() method with a LifecycleRequest() method which takes arguments "Request", "RequestId" and returns "ErrorCode". In addition, this commit removes the ShutdownConsumerService object and handles all shutdown consumers directly in the legacy app handler. --- boot-manager/Makefile.am | 2 - boot-manager/la-handler-service.c | 272 ++++++++----------- boot-manager/shutdown-consumer-service.c | 288 --------------------- boot-manager/shutdown-consumer-service.h | 37 --- common/Makefile.am | 10 +- common/nsm-consumer-dbus.xml | 16 +- common/nsm-lifecycle-control-dbus.xml | 2 +- common/shutdown-consumer-dbus.xml | 24 +- nsm-dummy/busconf/Makefile.am | 2 +- ...f => com.contiautomotive.NodeStateManager.conf} | 6 +- nsm-dummy/dbus/Makefile.am | 2 +- .../dbus/com.conti.NodeStateManager.service.in | 4 - ...com.contiautomotive.NodeStateManager.service.in | 4 + nsm-dummy/nsm-consumer-service.c | 8 +- nsm-dummy/nsm-dummy-application.c | 5 +- nsm-dummy/nsm-lifecycle-control-service.c | 2 +- nsm-dummy/systemd/Makefile.am | 2 +- ...om.contiautomotive.NodeStateManager.service.in} | 2 +- 18 files changed, 164 insertions(+), 524 deletions(-) delete mode 100644 boot-manager/shutdown-consumer-service.c delete mode 100644 boot-manager/shutdown-consumer-service.h rename nsm-dummy/busconf/{com.conti.NodeStateManager.conf => com.contiautomotive.NodeStateManager.conf} (51%) delete mode 100644 nsm-dummy/dbus/com.conti.NodeStateManager.service.in create mode 100644 nsm-dummy/dbus/com.contiautomotive.NodeStateManager.service.in rename nsm-dummy/systemd/{com.conti.NodeStateManager.service.in => com.contiautomotive.NodeStateManager.service.in} (62%) diff --git a/boot-manager/Makefile.am b/boot-manager/Makefile.am index 08bce99..05c52be 100644 --- a/boot-manager/Makefile.am +++ b/boot-manager/Makefile.am @@ -35,8 +35,6 @@ boot_manager_SOURCES = \ la-handler-service.h \ luc-starter.c \ luc-starter.h \ - shutdown-consumer-service.c \ - shutdown-consumer-service.h \ target-startup-monitor.c \ target-startup-monitor.h \ main.c \ diff --git a/boot-manager/la-handler-service.c b/boot-manager/la-handler-service.c index 081232d..70a0a20 100644 --- a/boot-manager/la-handler-service.c +++ b/boot-manager/la-handler-service.c @@ -17,18 +17,18 @@ #include #include +#include #include #include #include -#include DLT_IMPORT_CONTEXT (la_handler_context); - + /* property identifiers */ enum { @@ -40,45 +40,43 @@ enum typedef struct _LAHandlerServiceConsumerBundle LAHandlerServiceConsumerBundle; - - - -static void la_handler_service_constructed (GObject *object); -static void la_handler_service_finalize (GObject *object); -static void la_handler_service_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void la_handler_service_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static gboolean la_handler_service_handle_register (LAHandler *interface, - GDBusMethodInvocation *invocation, - const gchar *unit, - const gchar *mode, - guint timeout, - LAHandlerService *service); -static void la_handler_service_handle_register_finish (NSMConsumer *nsm_consumer, - GAsyncResult *res, - GDBusMethodInvocation *invocation); -static gboolean la_handler_service_handle_deregister (LAHandler *interface, - GDBusMethodInvocation *invocation, - const gchar *unit, - LAHandlerService *service); -static void la_handler_service_handle_consumer_shutdown (ShutdownConsumerService *interface, - LAHandlerService *service); -static void la_handler_service_handle_consumer_shutdown_finish (JobManager *manager, - const gchar *unit, - const gchar *result, - GError *error, - gpointer user_data); -static LAHandlerServiceConsumerBundle *la_handler_service_consumer_bundle_new (LAHandlerService *la_handler, - ShutdownConsumerService *consumer); -static void la_handler_service_consumer_bundle_unref (LAHandlerServiceConsumerBundle *bundle); -static void la_handler_service_release_shutdown_consumer (ShutdownConsumerService *service); - - +typedef struct _LAHandlerServiceShutdownConsumer LAHandlerServiceShutdownConsumer; + + + +static void la_handler_service_constructed (GObject *object); +static void la_handler_service_finalize (GObject *object); +static void la_handler_service_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void la_handler_service_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static gboolean la_handler_service_handle_register (LAHandler *interface, + GDBusMethodInvocation *invocation, + const gchar *unit, + const gchar *mode, + guint timeout, + LAHandlerService *service); +static void la_handler_service_handle_register_finish (NSMConsumer *nsm_consumer, + GAsyncResult *res, + GDBusMethodInvocation *invocation); +static gboolean la_handler_service_handle_deregister (LAHandler *interface, + GDBusMethodInvocation *invocation, + const gchar *unit, + LAHandlerService *service); +static void la_handler_service_handle_consumer_lifecycle_request (ShutdownConsumer *interface, + GDBusMethodInvocation *invocation, + guint request, + guint request_id, + LAHandlerService *service); +static void la_handler_service_handle_consumer_lifecycle_request_finish (JobManager *manager, + const gchar *unit, + const gchar *result, + GError *error, + gpointer user_data); struct _LAHandlerServiceClass { @@ -93,8 +91,9 @@ struct _LAHandlerService LAHandler *interface; JobManager *job_manager; - /* list of shutdown consumers */ - GList *shutdown_consumers; + /* Associations of shutdown consumers and their units */ + GHashTable *units_to_consumers; + GHashTable *consumers_to_units; const gchar *prefix; guint index; @@ -104,12 +103,6 @@ struct _LAHandlerService NSMConsumer *nsm_consumer; }; -struct _LAHandlerServiceConsumerBundle -{ - LAHandlerService *la_handler; - ShutdownConsumerService *consumer; -}; - G_DEFINE_TYPE (LAHandlerService, la_handler_service, G_TYPE_OBJECT); @@ -160,9 +153,9 @@ la_handler_service_constructed (GObject *object) /* connect to the node state manager */ service->nsm_consumer = nsm_consumer_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, - "com.conti.NodeStateManager", - "/com/conti/NodeStateManager/Consumer", NULL, - &error); + "com.contiautomotive.NodeStateManager", + "/com/contiautomotive/NodeStateManager/Consumer", + NULL, &error); if (error != NULL) { log_text = g_strdup_printf ("Error occurred connecting to NSM Consumer: %s", @@ -187,8 +180,13 @@ la_handler_service_init (LAHandlerService *service) /* the string that precedes the index in the shutdown consumer's object path */ service->prefix = "/org/genivi/BootManager1/ShutdownConsumer"; - /* initialize the list of shutdown consumers */ - service->shutdown_consumers = NULL; + /* initialize the association of shutdown consumers to units */ + service->units_to_consumers = + g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref); + service->consumers_to_units = + g_hash_table_new_full (g_direct_hash, g_direct_equal, + (GDestroyNotify) g_object_unref, (GDestroyNotify) g_free); /* implement the Register() handler */ g_signal_connect (service->interface, "handle-register", @@ -225,8 +223,8 @@ la_handler_service_finalize (GObject *object) g_object_unref (service->job_manager); /* release the shutdown consumers */ - g_list_free_full (service->shutdown_consumers, - (GDestroyNotify) la_handler_service_release_shutdown_consumer); + g_hash_table_destroy (service->units_to_consumers); + g_hash_table_destroy (service->consumers_to_units); (*G_OBJECT_CLASS (la_handler_service_parent_class)->finalize) (object); } @@ -338,113 +336,52 @@ la_handler_service_handle_deregister (LAHandler *object, static void -la_handler_service_handle_consumer_shutdown (ShutdownConsumerService *consumer, - LAHandlerService *service) +la_handler_service_handle_consumer_lifecycle_request (ShutdownConsumer *interface, + GDBusMethodInvocation *invocation, + guint request, + guint request_id, + LAHandlerService *service) { - LAHandlerServiceConsumerBundle *bundle; - const gchar *object_path; - const gchar *unit_name; - - g_return_if_fail (IS_SHUTDOWN_CONSUMER_SERVICE (consumer)); - g_return_if_fail (LA_HANDLER_IS_SERVICE (service)); - - /* check that we are responsible for this shutdown consumer */ - object_path = shutdown_consumer_service_get_object_path (consumer); - if (g_str_has_prefix (object_path, service->prefix)) - { - /* tell job manager to stop the unit */ - unit_name = shutdown_consumer_service_get_unit_name (consumer); - bundle = la_handler_service_consumer_bundle_new (service, consumer); - - job_manager_stop (service->job_manager, unit_name, NULL, - la_handler_service_handle_consumer_shutdown_finish, bundle); - } + GVariant *return_type; + gchar *unit_name = g_hash_table_lookup (service->consumers_to_units, interface); + + /* call job_manager_stop */ + job_manager_stop (service->job_manager, unit_name, NULL, + la_handler_service_handle_consumer_lifecycle_request_finish, + GUINT_TO_POINTER (request_id)); + + /* returns for the invocation (with error code) */ + return_type = g_variant_new_int32 (1); /* bare number because enum comes later */ + g_dbus_method_invocation_return_value (invocation, return_type); + g_variant_unref (return_type); } static void -la_handler_service_handle_consumer_shutdown_finish (JobManager *manager, - const gchar *unit, - const gchar *result, - GError *error, - gpointer user_data) +la_handler_service_handle_consumer_lifecycle_request_finish (JobManager *manager, + const gchar *unit, + const gchar *result, + GError *error, + gpointer user_data) { - LAHandlerServiceConsumerBundle *bundle = user_data; - gchar *log_text; - - g_return_if_fail (IS_JOB_MANAGER (manager)); - g_return_if_fail (user_data != NULL); + gchar *log_text; - /* log any potential errors */ + /* log any errors */ if (error != NULL) { - log_text = g_strdup_printf ("Failed to stop unit \"%s\": %s", unit, error->message); + log_text = g_strdup_printf ("Error occurred handling lifecycle request: %s", + error->message); DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text)); g_free (log_text); } - else if (g_strcmp0 (result, "failed") == 0) + + if (g_strcmp0 (result, "failed") == 0) { - log_text = g_strdup_printf ("Failed to stop unit \"%s\"", unit); - DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text)); - g_free (log_text); + DLT_LOG (la_handler_context, DLT_LOG_ERROR, + DLT_STRING ("Error occurred handling lifecycle request")); } - /* remove the shutdown consumer */ - bundle->la_handler->shutdown_consumers = - g_list_remove (bundle->la_handler->shutdown_consumers, bundle->consumer); - la_handler_service_release_shutdown_consumer (bundle->consumer); - - /* clean up */ - if (error != NULL) - g_error_free (error); - la_handler_service_consumer_bundle_unref (bundle); -} - - -static void -la_handler_service_release_shutdown_consumer (ShutdownConsumerService *service) -{ - g_return_if_fail (IS_SHUTDOWN_CONSUMER_SERVICE (service)); - - /* remove all signal handlers that handle events from this shutdown consumer */ - g_signal_handlers_disconnect_matched (service, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, - la_handler_service_handle_consumer_shutdown, - NULL); - g_object_unref (service); -} - - - -static LAHandlerServiceConsumerBundle * -la_handler_service_consumer_bundle_new (LAHandlerService *la_handler, - ShutdownConsumerService *consumer) -{ - LAHandlerServiceConsumerBundle *bundle; - - g_return_val_if_fail (LA_HANDLER_IS_SERVICE (la_handler), NULL); - g_return_val_if_fail (IS_SHUTDOWN_CONSUMER_SERVICE (consumer), NULL); - - /* allocate a new bundle struct */ - bundle = g_slice_new0 (LAHandlerServiceConsumerBundle); - bundle->la_handler = g_object_ref (la_handler); - bundle->consumer = g_object_ref (consumer); - - return bundle; -} - - - -static void -la_handler_service_consumer_bundle_unref (LAHandlerServiceConsumerBundle *bundle) -{ - if (bundle == NULL) - return; - - /* release all memory and references held by the bundle */ - g_object_unref (bundle->la_handler); - g_object_unref (bundle->consumer); - g_slice_free (LAHandlerServiceConsumerBundle, bundle); } @@ -463,7 +400,6 @@ la_handler_service_new (GDBusConnection *connection, } - gboolean la_handler_service_start (LAHandlerService *service, GError **error) @@ -488,31 +424,39 @@ la_handler_service_register (LAHandlerService *service, GAsyncReadyCallback callback, gpointer user_data) { - ShutdownConsumerService *consumer; - GError *error = NULL; - gchar *log_text; - gchar *object_path; + ShutdownConsumer *consumer; + GError *error = NULL; + gchar *log_text; + gchar *object_path; g_return_if_fail (LA_HANDLER_IS_SERVICE (service)); g_return_if_fail (unit != NULL && *unit != '\0'); g_return_if_fail (mode != NULL && *mode != '\0'); - /* create a new ShutdownConsumerService and put it in service->shutdown_consumers */ - object_path = g_strdup_printf ("%s/%u", service->prefix, service->index); - consumer = shutdown_consumer_service_new (service->connection, object_path, unit); - service->shutdown_consumers = g_list_append (service->shutdown_consumers, consumer); - service->index++; + /* find out if this unit is already registered with a shutdown consumer */ + if (g_hash_table_lookup (service->units_to_consumers, unit)) + return; - /* connect a signal to that shutdown consumer */ - g_signal_connect (consumer, "shutdown-requested", - G_CALLBACK (la_handler_service_handle_consumer_shutdown), service); + /* create a new ShutdownConsumer and store it in service */ + consumer = shutdown_consumer_skeleton_new (); + g_hash_table_insert (service->units_to_consumers, g_strdup (unit), + g_object_ref (consumer)); + g_hash_table_insert (service->consumers_to_units, g_object_ref (consumer), + g_strdup (unit)); + service->index++; - /* start the shutdown consumer */ - shutdown_consumer_service_start (consumer, &error); + /* set up signal handling and skeleton exporting */ + object_path = g_strdup_printf ("%s/%u", service->prefix, service->index); + g_signal_connect (consumer, "handle-lifecycle-request", + G_CALLBACK (la_handler_service_handle_consumer_lifecycle_request), + service); + g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (consumer), + service->connection, object_path, &error); if (error != NULL) { - log_text = g_strdup_printf ("Failed to start the shutdown consumer \"%s\": %s", - object_path, error->message); + log_text = + g_strdup_printf ("Error exporting shutdown consumer interface skeleton: %s", + error->message); DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text)); g_free (log_text); g_error_free (error); diff --git a/boot-manager/shutdown-consumer-service.c b/boot-manager/shutdown-consumer-service.c deleted file mode 100644 index 5ce2281..0000000 --- a/boot-manager/shutdown-consumer-service.c +++ /dev/null @@ -1,288 +0,0 @@ -/* vi:set et ai sw=2 sts=2 ts=2: */ -/* - - * Copyright (c) 2012 GENIVI. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include - -#include - - - -/* property identifiers */ -enum -{ - PROP_0, - PROP_CONNECTION, - PROP_OBJECT_PATH, - PROP_UNIT_NAME, -}; - - - -/* signal identifiers */ -enum -{ - SIGNAL_SHUTDOWN_REQUESTED, - LAST_SIGNAL, -}; - - - -static void shutdown_consumer_service_finalize (GObject *object); -static void shutdown_consumer_service_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void shutdown_consumer_service_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static gboolean shutdown_consumer_service_handle_shutdown (ShutdownConsumer *interface, - GDBusMethodInvocation *invocation, - ShutdownConsumerService *service); - - - -struct _ShutdownConsumerServiceClass -{ - GObjectClass __parent__; -}; - -struct _ShutdownConsumerService -{ - GObject __parent__; - - /* properties */ - ShutdownConsumer *interface; - GDBusConnection *connection; - gchar *object_path; - gchar *unit_name; -}; - - - -G_DEFINE_TYPE (ShutdownConsumerService, shutdown_consumer_service, G_TYPE_OBJECT); - - - -static guint shutdown_consumer_signals[LAST_SIGNAL]; - - - -static void -shutdown_consumer_service_class_init (ShutdownConsumerServiceClass *klass) -{ - GObjectClass *gobject_class; - - gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = shutdown_consumer_service_finalize; - gobject_class->get_property = shutdown_consumer_service_get_property; - gobject_class->set_property = shutdown_consumer_service_set_property; - - g_object_class_install_property (gobject_class, - PROP_CONNECTION, - g_param_spec_object ("connection", - "connection", - "The D-Bus connection", - G_TYPE_DBUS_CONNECTION, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, - PROP_OBJECT_PATH, - g_param_spec_string ("object-path", - "object path", - "The object path to the shutdown" - " consumer", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, - PROP_UNIT_NAME, - g_param_spec_string ("unit-name", - "unit name", - "The name of the unit the " - "shutdown consumer is " - "responsible for", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - /* create the 'shutdown-consumer-reply' signal */ - shutdown_consumer_signals[SIGNAL_SHUTDOWN_REQUESTED] = - g_signal_new ("shutdown-requested", TYPE_SHUTDOWN_CONSUMER_SERVICE, - G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - - - -static void -shutdown_consumer_service_init (ShutdownConsumerService *service) -{ - service->interface = shutdown_consumer_skeleton_new (); - - /* implement the Shutdown() handler */ - g_signal_connect (service->interface, "handle-shutdown", - G_CALLBACK (shutdown_consumer_service_handle_shutdown), - service); -} - - - -static void -shutdown_consumer_service_finalize (GObject *object) -{ - ShutdownConsumerService *service = SHUTDOWN_CONSUMER_SERVICE (object); - - /* release the D-Bus connection object */ - if (service->connection != NULL) - g_object_unref (service->connection); - - /* release the interface skeleton */ - g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (service->interface)); - g_signal_handlers_disconnect_matched (service->interface, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, service); - g_object_unref (service->interface); - - (*G_OBJECT_CLASS (shutdown_consumer_service_parent_class)->finalize) (object); -} - - - -static void -shutdown_consumer_service_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ShutdownConsumerService *service = SHUTDOWN_CONSUMER_SERVICE (object); - - switch (prop_id) - { - case PROP_CONNECTION: - g_value_set_object (value, service->connection); - break; - case PROP_OBJECT_PATH: - g_value_set_string (value, service->object_path); - break; - case PROP_UNIT_NAME: - g_value_set_string (value, service->unit_name); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - - -static void -shutdown_consumer_service_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ShutdownConsumerService *service = SHUTDOWN_CONSUMER_SERVICE (object); - - switch (prop_id) - { - case PROP_CONNECTION: - service->connection = g_value_dup_object (value); - break; - case PROP_OBJECT_PATH: - service->object_path = g_value_dup_string (value); - break; - case PROP_UNIT_NAME: - service->unit_name = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - - -static gboolean -shutdown_consumer_service_handle_shutdown (ShutdownConsumer *interface, - GDBusMethodInvocation *invocation, - ShutdownConsumerService *service) -{ - /* Signal that this Shutdown Consumer has been told to shut down */ - g_signal_emit (service, shutdown_consumer_signals[SIGNAL_SHUTDOWN_REQUESTED], 0); - - /* notify the caller that we have handled the shutdown request */ - g_dbus_method_invocation_return_value (invocation, NULL); - - return TRUE; -} - - - -const gchar * -shutdown_consumer_service_get_object_path (ShutdownConsumerService *service) -{ - g_return_val_if_fail (IS_SHUTDOWN_CONSUMER_SERVICE (service), NULL); - - return service->object_path; -} - - - -const gchar * -shutdown_consumer_service_get_unit_name (ShutdownConsumerService *service) -{ - g_return_val_if_fail (IS_SHUTDOWN_CONSUMER_SERVICE (service), NULL); - - return service->unit_name; -} - - - - -ShutdownConsumerService * -shutdown_consumer_service_new (GDBusConnection *connection, - const gchar *object_path, - const gchar *unit_name) -{ - g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL); - g_return_val_if_fail (object_path != NULL && *object_path != '\0', NULL); - g_return_val_if_fail (unit_name != NULL && *unit_name != '\0', NULL); - - return g_object_new (TYPE_SHUTDOWN_CONSUMER_SERVICE, - "connection", connection, - "object-path", object_path, - "unit-name", unit_name, - NULL); -} - - - -gboolean -shutdown_consumer_service_start (ShutdownConsumerService *service, - GError **error) -{ - g_return_val_if_fail (IS_SHUTDOWN_CONSUMER_SERVICE (service), FALSE); - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - /* announce the shutdown consumer on the bus */ - return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service->interface), - service->connection, - service->object_path, - error); -} diff --git a/boot-manager/shutdown-consumer-service.h b/boot-manager/shutdown-consumer-service.h deleted file mode 100644 index 30bb261..0000000 --- a/boot-manager/shutdown-consumer-service.h +++ /dev/null @@ -1,37 +0,0 @@ -/* vi:set et ai sw=2 sts=2 ts=2: */ -/* - - * Copyright (c) 2012 GENIVI. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef __SHUTDOWN_CONSUMER_SERVICE_H__ -#define __SHUTDOWN_CONSUMER_SERVICE_H__ - -#include - -G_BEGIN_DECLS - -#define TYPE_SHUTDOWN_CONSUMER_SERVICE (shutdown_consumer_service_get_type()) -#define SHUTDOWN_CONSUMER_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SHUTDOWN_CONSUMER_SERVICE, ShutdownConsumerService)) -#define SHUTDOWN_CONSUMER_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SHUTDOWN_CONSUMER_SERVICE, ShutdownConsumerServiceClass)) -#define IS_SHUTDOWN_CONSUMER_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SHUTDOWN_CONSUMER_SERVICE)) -#define IS_SHUTDOWN_CONSUMER_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SHUTDOWN_CONSUMER_SERVICE)) -#define SHUTDOWN_CONSUMER_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SHUTDOWN_CONSUMER_SERVICE, ShutdownConsumerServiceClass)) - -typedef struct _ShutdownConsumerServiceClass ShutdownConsumerServiceClass; -typedef struct _ShutdownConsumerService ShutdownConsumerService; - -GType shutdown_consumer_service_get_type (void) G_GNUC_CONST; - -const gchar *shutdown_consumer_service_get_object_path (ShutdownConsumerService *service); -const gchar *shutdown_consumer_service_get_unit_name (ShutdownConsumerService *service); -ShutdownConsumerService *shutdown_consumer_service_new (GDBusConnection *connection, - const gchar *object_path, - const gchar *unit_name) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; -gboolean shutdown_consumer_service_start (ShutdownConsumerService *service, - GError **error); - -#endif /* !__SHUTDOWN_CONSUMER_SERVICE_H__ */ diff --git a/common/Makefile.am b/common/Makefile.am index 8ce5f22..e1bec8a 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -51,18 +51,18 @@ BUILT_SOURCES = \ nsm-consumer-dbus.h: nsm-consumer-dbus.xml Makefile $(AM_V_GEN) $(GDBUS_CODEGEN) \ - --interface-prefix com.conti.NodeStateManager \ + --interface-prefix com.contiautomotive.NodeStateManager \ --c-namespace "" \ --generate-c-code nsm-consumer-dbus \ - --annotate com.conti.NodeStateManager.Consumer org.gtk.GDBus.C.Name \ + --annotate com.contiautomotive.NodeStateManager.Consumer org.gtk.GDBus.C.Name \ NSM_Consumer $< nsm-lifecycle-control-dbus.h: nsm-lifecycle-control-dbus.xml Makefile $(AM_V_GEN) $(GDBUS_CODEGEN) \ - --interface-prefix com.conti.NodeStateManager \ + --interface-prefix com.contiautomotive.NodeStateManager \ --c-namespace "" \ --generate-c-code nsm-lifecycle-control-dbus \ - --annotate com.conti.NodeStateManager.LifecycleControl org.gtk.GDBus.C.Name \ + --annotate com.contiautomotive.NodeStateManager.LifecycleControl org.gtk.GDBus.C.Name \ NSM_Lifecycle_Control $< shutdown-consumer-dbus.h: shutdown-consumer-dbus.xml Makefile @@ -70,5 +70,5 @@ shutdown-consumer-dbus.h: shutdown-consumer-dbus.xml Makefile --interface-prefix org.genivi \ --c-namespace "" \ --generate-c-code shutdown-consumer-dbus \ - --annotate org.genivi.BootManager1.ShutdownConsumer org.gtk.GDBus.C.Name \ + --annotate com.contiautomotive.NodeStateManager.LifeCycleConsumer org.gtk.GDBus.C.Name \ Shutdown_Consumer $< diff --git a/common/nsm-consumer-dbus.xml b/common/nsm-consumer-dbus.xml index 9333c2d..9ea9eb4 100644 --- a/common/nsm-consumer-dbus.xml +++ b/common/nsm-consumer-dbus.xml @@ -8,7 +8,7 @@ "com.conti.NodeStateManager.LifecycleControl" using only the methods needed to test Boot Manager. --> - + + + + + + + diff --git a/common/nsm-lifecycle-control-dbus.xml b/common/nsm-lifecycle-control-dbus.xml index 3155eef..4db0f38 100644 --- a/common/nsm-lifecycle-control-dbus.xml +++ b/common/nsm-lifecycle-control-dbus.xml @@ -8,7 +8,7 @@ "com.conti.NodeStateManager.LifecycleControl" using only the methods needed to test Boot Manager. --> - + - + - + + + + diff --git a/nsm-dummy/busconf/Makefile.am b/nsm-dummy/busconf/Makefile.am index 5af02f3..ae8c470 100644 --- a/nsm-dummy/busconf/Makefile.am +++ b/nsm-dummy/busconf/Makefile.am @@ -3,4 +3,4 @@ nsm_dummy_confdir = /etc/dbus-1/system.d nsm_dummy_conf_DATA = \ - com.conti.NodeStateManager.conf + com.contiautomotive.NodeStateManager.conf diff --git a/nsm-dummy/busconf/com.conti.NodeStateManager.conf b/nsm-dummy/busconf/com.contiautomotive.NodeStateManager.conf similarity index 51% rename from nsm-dummy/busconf/com.conti.NodeStateManager.conf rename to nsm-dummy/busconf/com.contiautomotive.NodeStateManager.conf index 6651636..240a0a0 100644 --- a/nsm-dummy/busconf/com.conti.NodeStateManager.conf +++ b/nsm-dummy/busconf/com.contiautomotive.NodeStateManager.conf @@ -2,8 +2,8 @@ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> - - - + + + diff --git a/nsm-dummy/dbus/Makefile.am b/nsm-dummy/dbus/Makefile.am index f2ac65c..39f663d 100644 --- a/nsm-dummy/dbus/Makefile.am +++ b/nsm-dummy/dbus/Makefile.am @@ -3,7 +3,7 @@ bus_servicedir = $(datadir)/dbus-1/system-services bus_service_in_files = \ - com.conti.NodeStateManager.service.in + com.contiautomotive.NodeStateManager.service.in bus_service_DATA = $(bus_service_in_files:.service.in=.service) diff --git a/nsm-dummy/dbus/com.conti.NodeStateManager.service.in b/nsm-dummy/dbus/com.conti.NodeStateManager.service.in deleted file mode 100644 index 4c34a74..0000000 --- a/nsm-dummy/dbus/com.conti.NodeStateManager.service.in +++ /dev/null @@ -1,4 +0,0 @@ -[D-BUS Service] -Name=com.conti.NodeStateManager -SystemdService = com.conti.NodeStateManager.service -Exec=@libdir@/nsm-dummy-@BOOT_MANAGER_VERSION_API@/nsm-dummy diff --git a/nsm-dummy/dbus/com.contiautomotive.NodeStateManager.service.in b/nsm-dummy/dbus/com.contiautomotive.NodeStateManager.service.in new file mode 100644 index 0000000..b2035a4 --- /dev/null +++ b/nsm-dummy/dbus/com.contiautomotive.NodeStateManager.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=com.contiautomotive.NodeStateManager +SystemdService = com.contiautomotive.NodeStateManager.service +Exec=@libdir@/nsm-dummy-@BOOT_MANAGER_VERSION_API@/nsm-dummy diff --git a/nsm-dummy/nsm-consumer-service.c b/nsm-dummy/nsm-consumer-service.c index 5e53275..bdd7ce9 100644 --- a/nsm-dummy/nsm-consumer-service.c +++ b/nsm-dummy/nsm-consumer-service.c @@ -332,7 +332,7 @@ nsm_consumer_service_start (NSMConsumerService *service, /* announce the Consumer service on the bus */ return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service->interface), service->connection, - "/com/conti/NodeStateManager/Consumer", + "/com/contiautomotive/NodeStateManager/Consumer", error); } @@ -361,6 +361,7 @@ nsm_shutdown_consumers (NSMConsumerService *service) gchar *message; GList *clients; GList *shutdown_consumers; + gint error_code; g_return_if_fail (NSM_CONSUMER_IS_SERVICE (service)); @@ -390,8 +391,9 @@ nsm_shutdown_consumers (NSMConsumerService *service) g_error_free (error); } - /* call the shutdown method */ - shutdown_consumer_call_shutdown_sync (proxy, NULL, &error); + /* call the shutdown method (temporarily using bald numbers instead of enums) */ + shutdown_consumer_call_lifecycle_request_sync (proxy, 1, 1234, &error_code, NULL, + &error); if (error != NULL) { message = diff --git a/nsm-dummy/nsm-dummy-application.c b/nsm-dummy/nsm-dummy-application.c index 1238953..2bca474 100644 --- a/nsm-dummy/nsm-dummy-application.c +++ b/nsm-dummy/nsm-dummy-application.c @@ -186,7 +186,8 @@ nsm_dummy_application_constructed (GObject *object) /* get a bus name on the given connection */ application->bus_name_id = - g_bus_own_name_on_connection (application->connection, "com.conti.NodeStateManager", + g_bus_own_name_on_connection (application->connection, + "com.contiautomotive.NodeStateManager", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL); } @@ -285,7 +286,7 @@ nsm_dummy_application_new (GDBusConnection *connection, g_return_val_if_fail (NSM_LIFECYCLE_CONTROL_IS_SERVICE (lifecycle_control_service), NULL); return g_object_new (NSM_DUMMY_TYPE_APPLICATION, - "application-id", "com.conti.NodeStateManager", + "application-id", "com.contiautomotive.NodeStateManager", "flags", G_APPLICATION_IS_SERVICE, "connection", connection, "nsm-consumer-service", consumer_service, diff --git a/nsm-dummy/nsm-lifecycle-control-service.c b/nsm-dummy/nsm-lifecycle-control-service.c index 625ceb2..79c159d 100644 --- a/nsm-dummy/nsm-lifecycle-control-service.c +++ b/nsm-dummy/nsm-lifecycle-control-service.c @@ -245,6 +245,6 @@ nsm_lifecycle_control_service_start (NSMLifecycleControlService *service, /* announce the LifecycleControl service on the bus */ return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service->interface), service->connection, - "/com/conti/NodeStateManager/LifecycleControl", + "/com/contiautomotive/NodeStateManager/LifecycleControl", error); } diff --git a/nsm-dummy/systemd/Makefile.am b/nsm-dummy/systemd/Makefile.am index a0ea41e..30971e5 100644 --- a/nsm-dummy/systemd/Makefile.am +++ b/nsm-dummy/systemd/Makefile.am @@ -3,7 +3,7 @@ systemd_servicedir = /lib/systemd/system systemd_service_in_files = \ - com.conti.NodeStateManager.service.in + com.contiautomotive.NodeStateManager.service.in systemd_service_DATA = $(systemd_service_in_files:.service.in=.service) diff --git a/nsm-dummy/systemd/com.conti.NodeStateManager.service.in b/nsm-dummy/systemd/com.contiautomotive.NodeStateManager.service.in similarity index 62% rename from nsm-dummy/systemd/com.conti.NodeStateManager.service.in rename to nsm-dummy/systemd/com.contiautomotive.NodeStateManager.service.in index b3888c4..718dc44 100644 --- a/nsm-dummy/systemd/com.conti.NodeStateManager.service.in +++ b/nsm-dummy/systemd/com.contiautomotive.NodeStateManager.service.in @@ -1,4 +1,4 @@ [Service] Type = notify -BusName = com.conti.NodeStateManager.service +BusName = com.contiautomotive.NodeStateManager.service ExecStart = @libdir@/nsm-dummy-@BOOT_MANAGER_VERSION_API@/nsm-dummy -- 2.7.4