Update NSM-related D-Bus interfaces and codegen
authorJonathan Maw <jonathan.maw@codethink.co.uk>
Fri, 20 Jul 2012 10:14:02 +0000 (11:14 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Mon, 23 Jul 2012 14:02:28 +0000 (15:02 +0100)
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.

18 files changed:
boot-manager/Makefile.am
boot-manager/la-handler-service.c
boot-manager/shutdown-consumer-service.c [deleted file]
boot-manager/shutdown-consumer-service.h [deleted file]
common/Makefile.am
common/nsm-consumer-dbus.xml
common/nsm-lifecycle-control-dbus.xml
common/shutdown-consumer-dbus.xml
nsm-dummy/busconf/Makefile.am
nsm-dummy/busconf/com.contiautomotive.NodeStateManager.conf [moved from nsm-dummy/busconf/com.conti.NodeStateManager.conf with 51% similarity]
nsm-dummy/dbus/Makefile.am
nsm-dummy/dbus/com.conti.NodeStateManager.service.in [deleted file]
nsm-dummy/dbus/com.contiautomotive.NodeStateManager.service.in [new file with mode: 0644]
nsm-dummy/nsm-consumer-service.c
nsm-dummy/nsm-dummy-application.c
nsm-dummy/nsm-lifecycle-control-service.c
nsm-dummy/systemd/Makefile.am
nsm-dummy/systemd/com.contiautomotive.NodeStateManager.service.in [moved from nsm-dummy/systemd/com.conti.NodeStateManager.service.in with 62% similarity]

index 08bce99..05c52be 100644 (file)
@@ -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                                                          \
index 081232d..70a0a20 100644 (file)
 #include <dlt/dlt.h>
 
 #include <common/nsm-consumer-dbus.h>
+#include <common/shutdown-consumer-dbus.h>
 
 #include <boot-manager/job-manager.h>
 #include <boot-manager/la-handler-dbus.h>
 #include <boot-manager/la-handler-service.h>
-#include <boot-manager/shutdown-consumer-service.h>
 
 
 
 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 (file)
index 5ce2281..0000000
+++ /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 <config.h>
-#endif
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-#include <common/shutdown-consumer-dbus.h>
-
-#include <boot-manager/shutdown-consumer-service.h>
-
-
-
-/* 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 (file)
index 30bb261..0000000
+++ /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 <gio/gio.h>
-
-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__ */
index 8ce5f22..e1bec8a 100644 (file)
@@ -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 $<
index 9333c2d..9ea9eb4 100644 (file)
@@ -8,7 +8,7 @@
                         "com.conti.NodeStateManager.LifecycleControl" using
                         only the methods needed to test Boot Manager.
   -->
-  <interface name="com.conti.NodeStateManager.Consumer">
+  <interface name="com.contiautomotive.NodeStateManager.Consumer">
     <!--
       RegisterShutdownClient:
       @BusName: Bus name of remote application.
       <arg name="ErrorCode" direction="out" type="i"/>
     </method>
 
+    <!--    
+        LifecycleRequestComplete:
+        @RequestId: The request Id of the called life cycle client. The value has been passed when "LifecycleRequest" was called.
+        @Status:    The result of the call to "LifecycleRequest". NsmErrorStatus_Ok: Request successfully processed. NsmErrorStatus_Error: An error occured while processing the "LifecycleRequest".
+        @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+        
+        The function has to be called by a "asynchrounous" lifecycle client, when he processed the "LifecycleRequest".
+    --> 
+    <method name="LifecycleRequestComplete">
+      <arg name="RequestId" direction="in" type="u"/>
+      <arg name="Status"    direction="in" type="i"/>
+      <arg name="ErrorCode" direction="out" type="i"/>
+    </method>
+
   </interface>
 </node>
index 3155eef..4db0f38 100644 (file)
@@ -8,7 +8,7 @@
                         "com.conti.NodeStateManager.LifecycleControl" using
                         only the methods needed to test Boot Manager.
   -->
-  <interface name="com.conti.NodeStateManager.LifecycleControl">
+  <interface name="com.contiautomotive.NodeStateManager.LifecycleControl">
     <!--
       SetNodeState:
       @NodeStateId: The passed value will be based upon the enum
index fb3fd01..ae41676 100644 (file)
@@ -1,21 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <node>
   <!--
-    org.genivi.lifecycle.ShutdownConsumer1:
-    @short_description: Interface for receiving Shutdown commands from the NSM
+    com.contiautomotive.NodeStateManager.LifeCycleConsumer:
+    @short_description: Interface for receiving LifecycleRequest commands from the NSM
 
-    Shutdown Consumers are D-Bus object which are created to shut down apps
-    which do not have a Shutdown() D-Bus method to call. These are registered
-    with the Node State Manager (NSM) instead of the apps and shut down those
-    apps when Shutdown() is called on the Shutdown Consumer.
+    Lifecycle Consumers are D-Bus object which are created to shut down apps
+    which do not have a LifecycleRequest() D-Bus method to call. These are registered
+    with the Node State Manager (NSM) instead of the apps and respond to any 
+    LifecycleRequest() in the app's place.
   -->
-  <interface name="org.genivi.BootManager1.ShutdownConsumer">
+  <interface name="com.contiautomotive.NodeStateManager.LifeCycleConsumer">
     <!--
       Shutdown:
+      @Request: The code for this request, either normal, fast or runup.
+      @RequestId: A unique identifier for this lifecycle consumer, used in the 
+                  LifecycleRequestComplete signal which replies to the NSM.
 
-      Shuts down the app the ShutdownConsumer is associated with.
+      Shuts down or starts up the app the LifecycleConsumer is associated with.
     -->
-    <method name="Shutdown">
+    <method name="LifecycleRequest">
+      <arg name="Request"   direction="in"  type="u"/>
+      <arg name="RequestId" direction="in"  type="u"/>
+      <arg name="ErrorCode" direction="out" type="i"/>
       <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
     </method>
 
index 5af02f3..ae8c470 100644 (file)
@@ -3,4 +3,4 @@
 nsm_dummy_confdir = /etc/dbus-1/system.d
 
 nsm_dummy_conf_DATA =                                          \
-       com.conti.NodeStateManager.conf
+       com.contiautomotive.NodeStateManager.conf
@@ -2,8 +2,8 @@
  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
 <busconfig>
   <policy user="root">
-    <allow own="com.conti.NodeStateManager"/>
-    <allow send_destination="com.conti.NodeStateManager" />
-    <allow receive_sender="com.conti.NodeStateManager" />
+    <allow own="com.contiautomotive.NodeStateManager"/>
+    <allow send_destination="com.contiautomotive.NodeStateManager" />
+    <allow receive_sender="com.contiautomotive.NodeStateManager" />
   </policy>
 </busconfig>
index f2ac65c..39f663d 100644 (file)
@@ -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 (file)
index 4c34a74..0000000
+++ /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 (file)
index 0000000..b2035a4
--- /dev/null
@@ -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
index 5e53275..bdd7ce9 100644 (file)
@@ -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 = 
index 1238953..2bca474 100644 (file)
@@ -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,
index 625ceb2..79c159d 100644 (file)
@@ -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);
 }
index a0ea41e..30971e5 100644 (file)
@@ -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)
 
@@ -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