summaryrefslogtreecommitdiff
path: root/legacy-app-handler
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2012-07-09 12:53:25 +0100
committerJonathan Maw <jonathan.maw@codethink.co.uk>2012-07-17 15:26:01 +0100
commite9866eb5348e1131edbf6ed9427eb05cab3c700e (patch)
tree5d453dbb8587fb5f22c50d956b9703c923fe932a /legacy-app-handler
parentbbb6eb400cf336bcbae844159f9ba989fd06aee4 (diff)
downloadnode-startup-controller-e9866eb5348e1131edbf6ed9427eb05cab3c700e.tar.gz
Merge into one process, change D-Bus interfaces and write LUC to file
The following changes were made: - Restructure the D-Bus interfaces: -- The old boot manager interface is removed, we are no longer interested in being a remote controller of systemd. -- The LUC Handler has been rewritten and renamed to org.genivi.BootManager1.BootManager. It has the following methods: --- BeginLUCRegistration() initializes the LUC registration sequence at shutdown. --- RegisterWithLUC(a{ias}) registers one or more apps with different LUC types. --- FinishLUCRegistration() finishes the LUC registration sequence and atomically replaces the previous LUC. -- The legacy application handler has been renamed to org.genivi.BootManager1.LegacyAppHandler. This interface is not for external use. It is meant only for the command- line interface to communicate with the boot manager. -- The LastUserContext property has been removed. - The last user context is now stored in a file rather than with GSettings. This was requested after the Gothenburg F2F, but is included because it is easier to make the change now than modify GSettings only to remove it later. - All services run as part of the same process (i.e. boot-manager). - All services run on the system bus. Because of this, the boot manager's command-line interface is handled differently, as the previous implementation, using GApplication, does not work on the system bus. The command-line interface now works by making a D-Bus call to the boot manager service, instead of using GApplication's remote command-line functionality. - The LUC Handler tests have been renamed to the boot manager tests, and are changed in line with the new interface methods. Note: The legacy app handler tests have not yet been modified to work with these changes.
Diffstat (limited to 'legacy-app-handler')
-rw-r--r--legacy-app-handler/Makefile.am76
-rw-r--r--legacy-app-handler/dbus/Makefile.am20
-rw-r--r--legacy-app-handler/dbus/org.genivi.LegacyAppHandler1.service.in4
-rw-r--r--legacy-app-handler/la-handler-application.c201
-rw-r--r--legacy-app-handler/la-handler-application.h35
-rw-r--r--legacy-app-handler/la-handler-dbus.xml44
-rw-r--r--legacy-app-handler/la-handler-service.c479
-rw-r--r--legacy-app-handler/la-handler-service.h40
-rw-r--r--legacy-app-handler/main.c297
-rw-r--r--legacy-app-handler/org.genivi.LegacyAppHandler1.conf9
-rw-r--r--legacy-app-handler/systemd/Makefile.am20
-rw-r--r--legacy-app-handler/systemd/org.genivi.LegacyAppHandler1.service.in3
12 files changed, 0 insertions, 1228 deletions
diff --git a/legacy-app-handler/Makefile.am b/legacy-app-handler/Makefile.am
deleted file mode 100644
index 0e037bc..0000000
--- a/legacy-app-handler/Makefile.am
+++ /dev/null
@@ -1,76 +0,0 @@
-# vi:set ts=8 sw=8 noet ai nocindent:
-
-SUBDIRS = \
- dbus \
- systemd
-
-legacy_app_handler_confdir = /etc/dbus-1/system.d
-
-legacy_app_handler_conf_DATA = \
- org.genivi.LegacyAppHandler1.conf
-
-legacy_app_handlerdir = \
- $(libdir)/legacy-app-handler-$(BOOT_MANAGER_VERSION_API)
-
-legacy_app_handler_PROGRAMS = \
- legacy-app-handler
-
-legacy_app_handler_built_headers = \
- la-handler-dbus.h
-
-legacy_app_handler_built_sources = \
- la-handler-dbus.c \
- $(legacy_app_handler_built_headers)
-
-legacy_app_handler_SOURCES = \
- la-handler-application.c \
- la-handler-application.h \
- la-handler-service.c \
- la-handler-service.h \
- main.c \
- $(legacy_app_handler_built_sources)
-
-legacy_app_handler_CFLAGS = \
- -DG_LOG_DOMAIN=\"legacy-app-handler\" \
- -I$(top_srcdir) \
- $(DLT_CFLAGS) \
- $(GIO_CFLAGS) \
- $(GIO_UNIX_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(PLATFORM_CFLAGS) \
- $(PLATFORM_CPPFLAGS) \
- $(SYSTEMD_DAEMON_CFLAGS)
-
-legacy_app_handler_LDFLAGS = \
- -no-undefined \
- $(PLATFORM_LDFLAGS)
-
-legacy_app_handler_DEPENDENCIES = \
- $(top_builddir)/common/libcommon.la
-
-legacy_app_handler_LDADD = \
- $(DLT_LIBS) \
- $(GIO_LIBS) \
- $(GIO_UNIX_LIBS) \
- $(GLIB_LIBS) \
- $(SYSTEMD_DAEMON_LIBS) \
- $(top_builddir)/common/libcommon.la
-
-EXTRA_DIST = \
- $(gsettingsschema_in_files) \
- la-handler-dbus.xml
-
-DISTCLEANFILES = \
- $(legacy_app_handler_built_sources) \
- $(gsettings_SCHEMAS)
-
-BUILT_SOURCES = \
- $(legacy_app_handler_built_headers)
-
-la-handler-dbus.h: la-handler-dbus.xml Makefile
- $(AM_V_GEN) $(GDBUS_CODEGEN) \
- --interface-prefix org.genivi \
- --c-namespace "" \
- --generate-c-code la-handler-dbus \
- --annotate org.genivi.LegacyAppHandler1 org.gtk.GDBus.C.Name \
- LA_Handler $<
diff --git a/legacy-app-handler/dbus/Makefile.am b/legacy-app-handler/dbus/Makefile.am
deleted file mode 100644
index 1ba7717..0000000
--- a/legacy-app-handler/dbus/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-# vi:set ts=8 sw=8 noet ai nocindent:
-
-bus_servicedir = $(datadir)/dbus-1/system-services
-
-bus_service_in_files = \
- org.genivi.LegacyAppHandler1.service.in
-
-bus_service_DATA = $(bus_service_in_files:.service.in=.service)
-
-%.service: %.service.in
- sed -e "s,\@libdir\@,$(libdir),g" \
- -e "s,\@BOOT_MANAGER_VERSION_API\@,$(BOOT_MANAGER_VERSION_API),g" < $< > $@
-
-CLEANFILES = \
- $(bus_service_DATA)
-
-EXTRA_DIST = \
- $(bus_service_in_files)
-
-
diff --git a/legacy-app-handler/dbus/org.genivi.LegacyAppHandler1.service.in b/legacy-app-handler/dbus/org.genivi.LegacyAppHandler1.service.in
deleted file mode 100644
index 3d84a65..0000000
--- a/legacy-app-handler/dbus/org.genivi.LegacyAppHandler1.service.in
+++ /dev/null
@@ -1,4 +0,0 @@
-[D-BUS Service]
-Name=org.genivi.LegacyAppHandler1
-SystemdService = org.genivi.LegacyAppHandler1.service
-Exec=@libdir@/legacy-app-handler-@BOOT_MANAGER_VERSION_API@/legacy-app-handler
diff --git a/legacy-app-handler/la-handler-application.c b/legacy-app-handler/la-handler-application.c
deleted file mode 100644
index 05b9167..0000000
--- a/legacy-app-handler/la-handler-application.c
+++ /dev/null
@@ -1,201 +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
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-#include <dlt/dlt.h>
-
-#include <common/watchdog-client.h>
-
-#include <legacy-app-handler/la-handler-dbus.h>
-#include <legacy-app-handler/la-handler-application.h>
-#include <legacy-app-handler/la-handler-service.h>
-
-
-
-DLT_IMPORT_CONTEXT (la_handler_context);
-
-
-
-/* property identifiers */
-enum
-{
- PROP_0,
- PROP_LA_HANDLER_SERVICE,
-};
-
-
-
-static void la_handler_application_finalize (GObject *object);
-static void la_handler_application_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void la_handler_application_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void la_handler_application_startup (GApplication *application);
-
-
-
-struct _LAHandlerApplicationClass
-{
- GApplicationClass __parent__;
-};
-
-struct _LAHandlerApplication
-{
- GApplication __parent__;
-
- /* systemd watchdog client that repeatedly asks systemd to update
- * the watchdog timestamp */
- WatchdogClient *watchdog_client;
-
- /* service object that implements the Legacy App Handler D-Bus interface */
- LAHandlerService *service;
-};
-
-
-
-G_DEFINE_TYPE (LAHandlerApplication, la_handler_application, G_TYPE_APPLICATION);
-
-
-
-static void
-la_handler_application_class_init (LAHandlerApplicationClass *klass)
-{
- GApplicationClass *gapplication_class;
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = la_handler_application_finalize;
- gobject_class->get_property = la_handler_application_get_property;
- gobject_class->set_property = la_handler_application_set_property;
-
- gapplication_class = G_APPLICATION_CLASS (klass);
- gapplication_class->startup = la_handler_application_startup;
-
- g_object_class_install_property (gobject_class,
- PROP_LA_HANDLER_SERVICE,
- g_param_spec_object ("la-handler-service",
- "la-handler-service",
- "la-handler-service",
- LA_HANDLER_TYPE_SERVICE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-}
-
-
-
-static void
-la_handler_application_init (LAHandlerApplication *application)
-{
-}
-
-
-
-static void
-la_handler_application_finalize (GObject *object)
-{
- LAHandlerApplication *application = LA_HANDLER_APPLICATION (object);
-
- /* release the watchdog client */
- if (application->watchdog_client != NULL)
- g_object_unref (application->watchdog_client);
-
- /* release the Legacy App Handler service implementation */
- if (application->service != NULL)
- g_object_unref (application->service);
-
- (*G_OBJECT_CLASS (la_handler_application_parent_class)->finalize) (object);
-}
-
-
-
-static void
-la_handler_application_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- LAHandlerApplication *application = LA_HANDLER_APPLICATION (object);
-
- switch (prop_id)
- {
- case PROP_LA_HANDLER_SERVICE:
- g_value_set_object (value, application->service);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static void
-la_handler_application_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- LAHandlerApplication *application = LA_HANDLER_APPLICATION (object);
-
- switch (prop_id)
- {
- case PROP_LA_HANDLER_SERVICE:
- application->service = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static void
-la_handler_application_startup (GApplication *app)
-{
- LAHandlerApplication *application = LA_HANDLER_APPLICATION (app);
-
- /* chain up to the parent class */
- (*G_APPLICATION_CLASS (la_handler_application_parent_class)->startup) (app);
-
- /* update systemd's watchdog timestamp every 120 seconds */
- application->watchdog_client = watchdog_client_new (120);
-
- /* the Legacy Application Handler should keep running until it is shut down by the Node
- * State Manager. */
- g_application_hold (app);
-}
-
-
-
-LAHandlerApplication *
-la_handler_application_new (LAHandlerService *service,
- GApplicationFlags flags)
-{
- return g_object_new (LA_HANDLER_TYPE_APPLICATION,
- "application-id", "org.genivi.LegacyAppHandler1",
- "flags", flags,
- "la-handler-service", service,
- NULL);
-}
diff --git a/legacy-app-handler/la-handler-application.h b/legacy-app-handler/la-handler-application.h
deleted file mode 100644
index 57160e2..0000000
--- a/legacy-app-handler/la-handler-application.h
+++ /dev/null
@@ -1,35 +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 __LA_HANDLER_APPLICATION_H__
-#define __LA_HANDLER_APPLICATION_H__
-
-#include <legacy-app-handler/la-handler-service.h>
-
-G_BEGIN_DECLS
-
-#define LA_HANDLER_TYPE_APPLICATION (la_handler_application_get_type ())
-#define LA_HANDLER_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LA_HANDLER_TYPE_APPLICATION, LAHandlerApplication))
-#define LA_HANDLER_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LA_HANDLER_TYPE_APPLICATION, LAHandlerApplicationClass))
-#define LA_HANDLER_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LA_HANDLER_TYPE_APPLICATION))
-#define LA_HANDLER_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LA_HANDLER_TYPE_APPLICATION)
-#define LA_HANDLER_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LA_HANDLER_TYPE_APPLICATION, LAHandlerApplicationClass))
-
-typedef struct _LAHandlerApplicationClass LAHandlerApplicationClass;
-typedef struct _LAHandlerApplication LAHandlerApplication;
-
-GType la_handler_application_get_type (void) G_GNUC_CONST;
-
-LAHandlerApplication *la_handler_application_new (LAHandlerService *service,
- GApplicationFlags flags) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-
-G_END_DECLS
-
-#endif /* !__LA_HANDLER_APPLICATION_H__ */
-
diff --git a/legacy-app-handler/la-handler-dbus.xml b/legacy-app-handler/la-handler-dbus.xml
deleted file mode 100644
index c7cf713..0000000
--- a/legacy-app-handler/la-handler-dbus.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<node name="/org/genivi/LegacyAppHandler1">
- <!--
- org.genivi.LegacyAppHandler1:
- @short_description: Interface for registering legacy apps with the NSM
-
- Legacy applications are applications that provide a systemd unit
- file but are unaware or do not make use of any GENIVI components.
-
- The GENIVI Legacy App Handler registers these apps with the NSM
- (Node State Manager) as shutdown consumers, so that when the NSM
- performs a shutdown it can shut down the application in reverse
- order of their creation.
- -->
- <interface name="org.genivi.LegacyAppHandler1">
- <!--
- Register:
- @unit: An application unit filename.
- @mode: Shutdown mode for which to register.
- @timeout: Timeout used by the NSM to wait for the legacy
- app to shut down.
-
- Registers a legacy application with the NSM as a shutdown
- consumer.
- -->
- <method name="Register">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg name="unit" type="s" direction="in"/>
- <arg name="mode" type="s" direction="in"/>
- <arg name="timeout" type="u" direction="in"/>
- </method>
-
- <!--
- Deregister:
- @unit: An application unit filename.
-
- Removes the shutdown consumer for an app from the NSM.
- -->
- <method name="Deregister">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg name="unit" type="s" direction="in"/>
- </method>
- </interface>
-</node>
diff --git a/legacy-app-handler/la-handler-service.c b/legacy-app-handler/la-handler-service.c
deleted file mode 100644
index d042bf8..0000000
--- a/legacy-app-handler/la-handler-service.c
+++ /dev/null
@@ -1,479 +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 <dlt/dlt.h>
-
-#include <common/boot-manager-dbus.h>
-#include <common/glib-extensions.h>
-#include <common/shutdown-consumer-service.h>
-
-#include <legacy-app-handler/la-handler-dbus.h>
-#include <legacy-app-handler/la-handler-service.h>
-
-
-
-DLT_IMPORT_CONTEXT (la_handler_context);
-
-
-
-/* property identifiers */
-enum
-{
- PROP_0,
- PROP_CONNECTION,
-};
-
-
-
-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 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 (GObject *object,
- GAsyncResult *res,
- 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);
-
-
-
-struct _LAHandlerServiceClass
-{
- GObjectClass __parent__;
-};
-
-struct _LAHandlerService
-{
- GObject __parent__;
-
- GDBusConnection *connection;
- LAHandler *interface;
- BootManager *boot_manager;
-
- /* list of shutdown consumers */
- GList *shutdown_consumers;
-
- const gchar *prefix;
- guint index;
- guint bus_name_id;
-
-};
-
-struct _LAHandlerServiceConsumerBundle
-{
- LAHandlerService *la_handler;
- ShutdownConsumerService *consumer;
-};
-
-
-G_DEFINE_TYPE (LAHandlerService, la_handler_service, G_TYPE_OBJECT);
-
-
-
-static void
-la_handler_service_class_init (LAHandlerServiceClass *klass)
-{
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->constructed = la_handler_service_constructed;
- gobject_class->finalize = la_handler_service_finalize;
- gobject_class->get_property = la_handler_service_get_property;
- gobject_class->set_property = la_handler_service_set_property;
-
- g_object_class_install_property (gobject_class,
- PROP_CONNECTION,
- g_param_spec_object ("connection",
- "connection",
- "connection",
- G_TYPE_DBUS_CONNECTION,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-}
-
-
-
-static void
-la_handler_service_constructed (GObject *object)
-{
- LAHandlerService *service = LA_HANDLER_SERVICE (object);
- GError *error = NULL;
- gchar *log_text;
-
- /* connect to the boot manager */
- service->boot_manager = boot_manager_proxy_new_sync (service->connection,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.genivi.BootManager1",
- "/org/genivi/BootManager1",
- NULL,
- &error);
- if (error != NULL)
- {
- log_text = g_strdup_printf ("Failed to connect to the boot manager service: %s",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
- g_error_free (error);
- }
-
- /* get a bus name on the system bus */
- service->bus_name_id =
- g_bus_own_name_on_connection (service->connection, "org.genivi.LegacyAppHandler1",
- G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL);
-}
-
-
-
-static void
-la_handler_service_init (LAHandlerService *service)
-{
- service->interface = la_handler_skeleton_new ();
-
- /* the number that follows the prefix in the shutdown consumer's object path, making
- * every shutdown consumer unique */
- service->index = 1;
-
- /* the string that precedes the index in the shutdown consumer's object path */
- service->prefix = "/org/genivi/lifecycle/LegacyAppHandler1";
-
- /* initialize the list of shutdown consumers */
- service->shutdown_consumers = NULL;
-
- /* implement the Register() handler */
- g_signal_connect (service->interface, "handle-register",
- G_CALLBACK (la_handler_service_handle_register),
- service);
-
- /* implement the Deregister() handler */
- g_signal_connect (service->interface, "handle-deregister",
- G_CALLBACK (la_handler_service_handle_deregister),
- service);
-}
-
-
-
-
-static void
-la_handler_service_finalize (GObject *object)
-{
- LAHandlerService *service = LA_HANDLER_SERVICE (object);
-
- /* release the bus name */
- g_bus_unown_name (service->bus_name_id);
-
- /* release the D-Bus connection object */
- if (service->connection != NULL)
- g_object_unref (service->connection);
-
- /* release the interface skeleton */
- g_signal_handlers_disconnect_matched (service->interface,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, service);
- g_object_unref (service->interface);
-
- /* release the boot manager skeleton */
- g_object_unref (service->boot_manager);
-
- /* release the shutdown consumers */
- g_list_free_full (service->shutdown_consumers,
- (GDestroyNotify) la_handler_service_release_shutdown_consumer);
-
- (*G_OBJECT_CLASS (la_handler_service_parent_class)->finalize) (object);
-}
-
-
-
-static void
-la_handler_service_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- LAHandlerService *service = LA_HANDLER_SERVICE (object);
-
- switch (prop_id)
- {
- case PROP_CONNECTION:
- g_value_set_object (value, service->connection);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static void
-la_handler_service_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- LAHandlerService *service = LA_HANDLER_SERVICE (object);
-
- switch (prop_id)
- {
- case PROP_CONNECTION:
- service->connection = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-
-static gboolean
-la_handler_service_handle_register (LAHandler *interface,
- GDBusMethodInvocation *invocation,
- const gchar *unit,
- const gchar *mode,
- guint timeout,
- LAHandlerService *service)
-{
- la_handler_service_register (service, unit, mode, timeout);
-
- /* notify the caller that we have handled the registration request */
- g_dbus_method_invocation_return_value (invocation, NULL);
- return TRUE;
-}
-
-
-
-static gboolean
-la_handler_service_handle_deregister (LAHandler *object,
- GDBusMethodInvocation *invocation,
- const gchar *unit,
- LAHandlerService *service)
-{
- /* notify the caller that we have handled the registration request */
- g_dbus_method_invocation_return_value (invocation, NULL);
- return TRUE;
-}
-
-
-
-static void
-la_handler_service_handle_consumer_shutdown (ShutdownConsumerService *consumer,
- 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 boot manager to stop the unit */
- unit_name = shutdown_consumer_service_get_unit_name (consumer);
-
- bundle = la_handler_service_consumer_bundle_new (service, consumer);
-
- boot_manager_call_stop (service->boot_manager, unit_name, NULL,
- la_handler_service_handle_consumer_shutdown_finish,
- bundle);
- }
-}
-
-
-
-static void
-la_handler_service_handle_consumer_shutdown_finish (GObject *object,
- GAsyncResult *res,
- gpointer user_data)
-{
- LAHandlerServiceConsumerBundle *bundle = user_data;
- BootManager *proxy = BOOT_MANAGER (object);
- GError *error = NULL;
- gchar *result;
- gchar *log_text;
- const gchar *unit_name;
-
- g_return_if_fail (IS_BOOT_MANAGER (object));
- g_return_if_fail (G_IS_ASYNC_RESULT (res));
- g_return_if_fail (user_data != NULL);
-
- boot_manager_call_stop_finish (proxy, &result, res, &error);
-
- unit_name = shutdown_consumer_service_get_unit_name (bundle->consumer);
-
- /* log any potential errors */
- if (error != NULL)
- {
- log_text =
- g_strdup_printf ("Failed to stop unit \"%s\": %s", unit_name, 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)
- {
- log_text = g_strdup_printf ("Failed to stop unit \"%s\"", unit_name);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
- }
-
- /* 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);
-}
-
-
-
-LAHandlerService *
-la_handler_service_new (GDBusConnection *connection)
-{
- g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
- return g_object_new (LA_HANDLER_TYPE_SERVICE, "connection", connection, NULL);
-}
-
-
-
-gboolean
-la_handler_service_start (LAHandlerService *service,
- GError **error)
-{
- g_return_val_if_fail (LA_HANDLER_IS_SERVICE (service), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* announce the org.genivi.LegacyAppHandler1 service on the bus */
- return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service->interface),
- service->connection,
- "/org/genivi/LegacyAppHandler1",
- error);
-}
-
-void
-la_handler_service_register (LAHandlerService *service,
- const gchar *unit,
- const gchar *mode,
- guint timeout)
-{
- ShutdownConsumerService *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++;
-
- /* connect a signal to that shutdown consumer */
- g_signal_connect (consumer, "shutdown-requested",
- G_CALLBACK (la_handler_service_handle_consumer_shutdown), service);
-
- /* start the shutdown consumer */
- shutdown_consumer_service_start (consumer, &error);
- if (error != NULL)
- {
- log_text = g_strdup_printf ("Failed to start the shutdown consumer \"%s\": %s",
- object_path, error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
- g_free (log_text);
- g_error_free (error);
- }
-
- g_free (object_path);
-}
diff --git a/legacy-app-handler/la-handler-service.h b/legacy-app-handler/la-handler-service.h
deleted file mode 100644
index 6aac1e9..0000000
--- a/legacy-app-handler/la-handler-service.h
+++ /dev/null
@@ -1,40 +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 __LA_HANDLER_SERVICE_H__
-#define __LA_HANDLER_SERVICE_H__
-
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-#define LA_HANDLER_TYPE_SERVICE (la_handler_service_get_type ())
-#define LA_HANDLER_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LA_HANDLER_TYPE_SERVICE, LAHandlerService))
-#define LA_HANDLER_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LA_HANDLER_TYPE_SERVICE, LAHandlerServiceClass))
-#define LA_HANDLER_IS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LA_HANDLER_TYPE_SERVICE))
-#define LA_HANDLER_IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LA_HANDLER_TYPE_SERVICE)
-#define LA_HANDLER_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LA_HANDLER_TYPE_SERVICE, LAHandlerServiceClass))
-
-typedef struct _LAHandlerServiceClass LAHandlerServiceClass;
-typedef struct _LAHandlerService LAHandlerService;
-
-GType la_handler_service_get_type (void) G_GNUC_CONST;
-
-LAHandlerService *la_handler_service_new (GDBusConnection *connection) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-gboolean la_handler_service_start (LAHandlerService *service,
- GError **error);
-void la_handler_service_register (LAHandlerService *service,
- const gchar *unit,
- const gchar *mode,
- guint timeout);
-
-G_END_DECLS
-
-#endif /* !__LA_HANDLER_SERVICE_H__ */
-
diff --git a/legacy-app-handler/main.c b/legacy-app-handler/main.c
deleted file mode 100644
index 398ac04..0000000
--- a/legacy-app-handler/main.c
+++ /dev/null
@@ -1,297 +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
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <dlt/dlt.h>
-
-#include <legacy-app-handler/la-handler-application.h>
-#include <legacy-app-handler/la-handler-dbus.h>
-#include <legacy-app-handler/la-handler-service.h>
-
-
-
-DLT_DECLARE_CONTEXT (la_handler_context);
-
-
-
-static void
-dlt_cleanup (void)
-{
- DLT_UNREGISTER_CONTEXT (la_handler_context);
- DLT_UNREGISTER_APP ();
-}
-
-
-
-static gboolean
-handle_command_line (int argc,
- char **argv,
- GDBusConnection *connection)
-{
- GOptionContext *context = g_option_context_new (NULL);
- LAHandler *legacy_app_handler;
- gboolean do_register = FALSE;
- gboolean do_deregister = FALSE;
- GError *error = NULL;
- gchar *unit = NULL;
- gchar *log_message = NULL;
- gchar *mode = NULL;
- gint timeout = 0;
-
- GOptionEntry entries[] = {
- {"deregister", 0, 0, G_OPTION_ARG_NONE, &do_deregister, NULL, NULL},
- {"register", 0, 0, G_OPTION_ARG_NONE, &do_register, NULL, NULL},
- {"unit", 0, 0, G_OPTION_ARG_STRING, &unit, NULL, NULL},
- {"timeout", 0, 0, G_OPTION_ARG_INT, &timeout, NULL, NULL},
- {"shutdown-mode", 0, 0, G_OPTION_ARG_STRING, &mode, NULL, NULL},
- {NULL},
- };
-
- /* set up the option context */
- g_option_context_set_help_enabled (context, FALSE);
- g_option_context_add_main_entries (context, entries, NULL);
-
- /* parse the arguments into argument data */
- if (!g_option_context_parse (context, &argc, &argv, &error) || error != NULL)
- {
- /* an error occurred */
- log_message =
- g_strdup_printf ("Error occurred parsing arguments: %s\n", error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_message));
-
- g_error_free (error);
- g_free (log_message);
-
- return FALSE;
- }
- else if (do_register && !do_deregister)
- {
- if (unit == NULL || *unit == '\0' || timeout < 0)
- {
- /* register was called incorrectly */
- log_message =
- g_strdup_printf ("Invalid arguments for --register. A unit must be specified"
- " and the timeout must be positive.");
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_message));
-
- g_free (log_message);
-
- return FALSE;
- }
-
- /* get a legacy app handler interface */
- legacy_app_handler =
- la_handler_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE,
- "org.genivi.LegacyAppHandler1",
- "/org/genivi/LegacyAppHandler1", NULL, &error);
- if (error != NULL)
- {
- /* failed to connect to the legacy app handler */
- log_message =
- g_strdup_printf ("Error occurred connecting to legacy app handler "
- "interface: %s", error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_message));
-
- g_free (log_message);
- g_error_free (error);
-
- return FALSE;
- }
-
- /* call the legacy app handler's Register() method */
- la_handler_call_register_sync (legacy_app_handler, unit,
- mode ? mode : "normal", (guint) timeout, NULL,
- &error);
- if (error != NULL)
- {
- /* failed to register the legacy app */
- log_message = g_strdup_printf ("Error occurred registering legacy app: %s",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_message));
-
- g_object_unref (legacy_app_handler);
- g_free (log_message);
- g_error_free (error);
-
- return FALSE;
- }
-
- g_object_unref (legacy_app_handler);
-
- return TRUE;
-
- }
- else if (do_deregister && !do_register)
- {
- if (unit == NULL || *unit == '\0')
- {
- /* deregister was called incorrectly */
- log_message =
- g_strdup_printf ("Invalid arguments for --deregister. A unit must be "
- "specified.");
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_message));
-
- g_free (log_message);
-
- return FALSE;
- }
-
- /* get a legacy app handler interface */
- legacy_app_handler =
- la_handler_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE,
- "org.genivi.LegacyAppHandler1",
- "/org/genivi/LegacyAppHandler1", NULL, &error);
- if (error != NULL)
- {
- log_message =
- g_strdup_printf ("Error occurred connecting to legacy app handler "
- "interface: %s", error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_message));
-
- g_free (log_message);
- g_error_free (error);
-
- return FALSE;
- }
-
- /* call the legacy app handler's Deregister() method */
- la_handler_call_deregister_sync (legacy_app_handler, unit, NULL, &error);
- if (error != NULL)
- {
- log_message = g_strdup_printf ("Error occurred deregistering legacy "
- "app: %s", error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_message));
-
- g_object_unref (legacy_app_handler);
- g_free (log_message);
- g_error_free (error);
-
- return FALSE;
- }
-
- g_object_unref (legacy_app_handler);
-
- return TRUE;
- }
- else if (do_register && do_deregister)
- {
- log_message =
- g_strdup_printf ("Invalid arguments. Please choose either --register or "
- "--deregister.");
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_message));
-
- g_free (log_message);
-
- return FALSE;
- }
- else
- {
- DLT_LOG (la_handler_context, DLT_LOG_ERROR,
- DLT_STRING ("No arguments recognised"));
- return FALSE;
- }
-}
-
-
-
-int
-main (int argc,
- char **argv)
-{
- LAHandlerApplication *application;
- LAHandlerService *service;
- GDBusConnection *connection;
- gboolean is_remote;
- GError *error = NULL;
- gchar *log_text;
- int exit_status;
-
- /* check if this program execution is meant as a remote application.
- * if it is a remote application, then it will be called with command-line arguments. */
- is_remote = (argc > 1) ? TRUE : FALSE;
-
- /* register the application and context in DLT */
- if (!is_remote)
- {
- DLT_REGISTER_APP ("BMGR", "GENIVI Boot Manager");
- DLT_REGISTER_CONTEXT (la_handler_context, "LAH",
- "Context of the legacy application handler that hooks legacy "
- "applications up with the shutdown concept of the Node State "
- "Manager");
- atexit (dlt_cleanup);
- }
-
- /* initialize the GType type system */
- g_type_init ();
-
- /* attempt to connect to D-Bus */
- connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
- if (connection == NULL || error != NULL || !G_IS_DBUS_CONNECTION (connection))
- {
- log_text = g_strdup_printf ("Failed to connect to D-Bus: %s", error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
-
- /* clean up */
- g_free (log_text);
- g_error_free (error);
-
- return EXIT_FAILURE;
- }
-
- if (is_remote)
- {
- if (!handle_command_line (argc, argv, connection))
- exit_status = EXIT_FAILURE;
- else
- exit_status = EXIT_SUCCESS;
- }
- else
- {
- /* instantiate the LegacyAppHandler service implementation */
- service = la_handler_service_new (connection);
- if (!la_handler_service_start (service, &error))
- {
- log_text = g_strdup_printf ("Failed to start the legacy app handler service: %s",
- error->message);
- DLT_LOG (la_handler_context, DLT_LOG_ERROR, DLT_STRING (log_text));
-
- /* clean up */
- g_free (log_text);
- g_error_free (error);
- g_object_unref (service);
- g_object_unref (connection);
-
- return EXIT_FAILURE;
- }
-
- /* create and run the main application */
- application =
- la_handler_application_new (service, G_APPLICATION_IS_SERVICE);
-
- exit_status = g_application_run (G_APPLICATION (application), argc, argv);
- g_object_unref (application);
-
- /* release allocated objects */
- g_object_unref (service);
- }
-
- g_object_unref (connection);
-
- return exit_status;
-}
diff --git a/legacy-app-handler/org.genivi.LegacyAppHandler1.conf b/legacy-app-handler/org.genivi.LegacyAppHandler1.conf
deleted file mode 100644
index d418d23..0000000
--- a/legacy-app-handler/org.genivi.LegacyAppHandler1.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
- <policy user="root">
- <allow own="org.genivi.LegacyAppHandler1"/>
- <allow send_destination="org.genivi.LegacyAppHandler1" />
- <allow receive_sender="org.genivi.LegacyAppHandler1" />
- </policy>
-</busconfig>
diff --git a/legacy-app-handler/systemd/Makefile.am b/legacy-app-handler/systemd/Makefile.am
deleted file mode 100644
index 874d9e6..0000000
--- a/legacy-app-handler/systemd/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-# vi:set ts=8 sw=8 noet ai nocindent:
-
-systemd_servicedir = $(libdir)/systemd/system
-
-systemd_service_in_files = \
- org.genivi.LegacyAppHandler1.service.in
-
-systemd_service_DATA = $(systmd_service_in_files:.service.in=.service)
-
-%.service: %.service.in
- sed -e "s,\@libdir\@,$(libdir),g" \
- -e "s,\@BOOT_MANAGER_VERSION_API\@,$(BOOT_MANAGER_VERSION_API),g" < $< > $@
-
-CLEANFILES = \
- $(systemd_service_DATA)
-
-EXTRA_DIST = \
- $(systemd_service_in_files)
-
-
diff --git a/legacy-app-handler/systemd/org.genivi.LegacyAppHandler1.service.in b/legacy-app-handler/systemd/org.genivi.LegacyAppHandler1.service.in
deleted file mode 100644
index bc1f4b4..0000000
--- a/legacy-app-handler/systemd/org.genivi.LegacyAppHandler1.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[Service]
-BusName = org.genivi.LegacyAppHandler1.service
-ExecStart = @libdir@/legacy-app-handler-@BOOT_MANAGER_VERSION_API@/legacy-app-handler