SUBDIRS = \
boot-manager \
+ legacy-app-handler \
luc-handler \
tests
AC_OUTPUT([
Makefile
boot-manager/Makefile
+legacy-app-handler/Makefile
luc-handler/Makefile
luc-handler/org.genivi.LUCHandler1.gschema.xml
tests/Makefile
--- /dev/null
+# vi:set ts=8 sw=8 noet ai nocindent:
+
+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 = \
+ ../common/glib-extensions.c \
+ ../common/glib-extensions.h \
+ ../common/watchdog-client.c \
+ ../common/watchdog-client.h \
+ 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) \
+ $(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_LDADD = \
+ $(GIO_LIBS) \
+ $(GIO_UNIX_LIBS) \
+ $(GLIB_LIBS) \
+ $(SYSTEMD_DAEMON_LIBS)
+
+servicedir = $(datadir)/dbus-1/services
+service_in_files = \
+ org.genivi.LAHandler1.service.in
+
+service_DATA = $(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 = \
+ $(service_DATA)
+
+EXTRA_DIST = \
+ $(service_in_files) \
+ $(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 $<
--- /dev/null
+/* 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/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>
+
+
+
+/* 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 */
+ 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);
+
+ /* update systemd's watchdog timestamp every 120 seconds */
+ application->watchdog_client = watchdog_client_new (120);
+}
+
+
+
+LAHandlerApplication *
+la_handler_application_new (LAHandlerService *service)
+{
+ return g_object_new (LA_HANDLER_TYPE_APPLICATION,
+ "application-id", "org.genivi.LegacyAppHandler1",
+ "flags", G_APPLICATION_IS_SERVICE,
+ "la-handler-service", service,
+ NULL);
+}
--- /dev/null
+/* 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) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
+G_END_DECLS
+
+#endif /* !__LA_HANDLER_APPLICATION_H__ */
+
--- /dev/null
+<?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>
--- /dev/null
+/* 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/glib-extensions.h>
+
+#include <legacy-app-handler/la-handler-dbus.h>
+#include <legacy-app-handler/la-handler-service.h>
+
+
+
+/* property identifiers */
+enum
+{
+ PROP_0,
+ PROP_CONNECTION,
+};
+
+
+
+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,
+ GVariant *apps,
+ LAHandlerService *service);
+static gboolean la_handler_service_handle_deregister (LAHandler *interface,
+ GDBusMethodInvocation *invocation,
+ GVariant *apps,
+ LAHandlerService *service);
+
+
+
+struct _LAHandlerServiceClass
+{
+ GObjectClass __parent__;
+};
+
+struct _LAHandlerService
+{
+ GObject __parent__;
+
+ GDBusConnection *connection;
+ LAHandler *interface;
+};
+
+
+
+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->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_init (LAHandlerService *service)
+{
+ service->interface = la_handler_skeleton_new ();
+
+ /* 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 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);
+
+ (*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 *object,
+ GDBusMethodInvocation *invocation,
+ GVariant *apps,
+ LAHandlerService *service)
+{
+ g_debug ("Register called:");
+
+ /* 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,
+ GVariant *apps,
+ LAHandlerService *service)
+{
+ g_debug ("Deregister called:");
+
+ /* Notify the caller that we have handled the registration request */
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ return TRUE;
+}
+
+
+
+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);
+}
--- /dev/null
+/* 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);
+
+G_END_DECLS
+
+#endif /* !__LA_HANDLER_SERVICE_H__ */
+
--- /dev/null
+/* 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 <legacy-app-handler/la-handler-application.h>
+#include <legacy-app-handler/la-handler-service.h>
+
+
+
+int
+main (int argc,
+ char **argv)
+{
+ LAHandlerApplication *application;
+ LAHandlerService *service;
+ GDBusConnection *connection;
+ GError *error = NULL;
+ gint exit_status = EXIT_SUCCESS;
+
+ /* initialize the GType type system */
+ g_type_init ();
+
+ /* attempt to connect to D-Bus */
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ if (connection == NULL)
+ {
+ g_warning ("Failed to connect to D-Bus: %s", error->message);
+
+ /* clean up */
+ g_error_free (error);
+
+ return EXIT_FAILURE;
+ }
+
+ /* Instantiate the LegacyAppHandler service implementation */
+ service = la_handler_service_new (connection);
+ if (!la_handler_service_start (service, &error))
+ {
+ g_warning ("Failed to start the LegacyAppHandler service: %s", error->message);
+
+ /* clean up */
+ 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);
+ exit_status = g_application_run (G_APPLICATION (application), 0, NULL);
+ g_object_unref (application);
+
+ /* release allocated objects */
+ g_object_unref (service);
+ g_object_unref (connection);
+
+ return exit_status;
+}
--- /dev/null
+[D-BUS Service]
+Name=org.genivi.LegacyAppHandler1
+Exec=/usr/local/lib/legacy-app-handler-1/legacy-app-handler
--- /dev/null
+[D-BUS Service]
+Name=org.genivi.LAHandler1
+Exec=@libdir@/legacy-app-handler-@BOOT_MANAGER_VERSION_API@/legacy-app-handler