Add initial classes for the boot manager service implementation
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 13 Jun 2012 12:37:06 +0000 (13:37 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 13 Jun 2012 12:37:06 +0000 (13:37 +0100)
This includes BootManagerApplication, BootManagerService (which at this
point does not implement any of the D-Bus method handlers yet) and the
classes generated by gdbus-codegen from the XML interface specification.

This commit also introduces the .service file for the boot manager.

Makefile.am
boot-manager/Makefile.am [new file with mode: 0644]
boot-manager/boot-manager-application.c [new file with mode: 0644]
boot-manager/boot-manager-application.h [new file with mode: 0644]
boot-manager/boot-manager-dbus.xml [new file with mode: 0644]
boot-manager/boot-manager-service.c [new file with mode: 0644]
boot-manager/boot-manager-service.h [new file with mode: 0644]
boot-manager/main.c [new file with mode: 0644]
boot-manager/org.genivi.BootManager1.service.in [new file with mode: 0644]
configure.ac

index b769f29..e636c2b 100644 (file)
@@ -1,6 +1,7 @@
 # vi:set ts=8 sw=8 noet ai nocindent:
 
 SUBDIRS =                                                              \
+       boot-manager                                                    \
        luc-handler                                                     \
        tests
 
diff --git a/boot-manager/Makefile.am b/boot-manager/Makefile.am
new file mode 100644 (file)
index 0000000..7b2c13b
--- /dev/null
@@ -0,0 +1,75 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+
+boot_managerdir =                                                      \
+       $(libdir)/boot-manager-$(BOOT_MANAGER_VERSION_API)
+
+boot_manager_PROGRAMS =                                                        \
+       boot-manager
+
+boot_manager_built_headers =                                           \
+       boot-manager-dbus.h
+
+boot_manager_built_sources =                                           \
+       boot-manager-dbus.c                                             \
+       $(boot_manager_built_headers)
+
+boot_manager_SOURCES =                                                 \
+       ../common/watchdog-client.c                                     \
+       ../common/watchdog-client.h                                     \
+       boot-manager-application.c                                      \
+       boot-manager-application.h                                      \
+       boot-manager-service.c                                          \
+       boot-manager-service.h                                          \
+       main.c                                                          \
+       $(boot_manager_built_sources)
+
+boot_manager_CFLAGS =                                                  \
+       -DG_LOG_DOMAIN=\"boot-manager\"                                 \
+       -I$(top_srcdir)                                                 \
+       $(GIO_CFLAGS)                                                   \
+       $(GIO_UNIX_CFLAGS)                                              \
+       $(GLIB_CFLAGS)                                                  \
+       $(PLATFORM_CFLAGS)                                              \
+       $(PLATFORM_CPPFLAGS)                                            \
+       $(SYSTEMD_DAEMON_CFLAGS)
+
+boot_manager_LDFLAGS =                                                 \
+       -no-undefined                                                   \
+       $(PLATFORM_LDFLAGS)
+
+boot_manager_LDADD =                                                   \
+       $(GIO_LIBS)                                                     \
+       $(GIO_UNIX_LIBS)                                                \
+       $(GLIB_LIBS)                                                    \
+       $(SYSTEMD_DAEMON_LIBS)
+
+servicedir = $(datadir)/dbus-1/services
+service_in_files =                                                     \
+       org.genivi.BootManager1.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)                                             \
+       boot-manager-dbus.xml
+
+DISTCLEANFILES =                                                       \
+       $(boot_manager_built_sources)
+
+BUILT_SOURCES =                                                                \
+       $(boot_manager_built_headers)
+
+boot-manager-dbus.h: boot-manager-dbus.xml Makefile
+       $(AM_V_GEN) $(GDBUS_CODEGEN)                                    \
+           --interface-prefix org.genivi                               \
+           --c-namespace ""                                            \
+           --generate-c-code boot-manager-dbus                         \
+           --annotate org.genivi.BootManager1 org.gtk.GDBus.C.Name     \
+             BootManager $<
diff --git a/boot-manager/boot-manager-application.c b/boot-manager/boot-manager-application.c
new file mode 100644 (file)
index 0000000..e167c91
--- /dev/null
@@ -0,0 +1,181 @@
+/* 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 <boot-manager/boot-manager-dbus.h>
+#include <boot-manager/boot-manager-application.h>
+#include <boot-manager/boot-manager-service.h>
+
+
+
+/* property identifiers */
+enum
+{
+  PROP_0,
+  PROP_BOOT_MANAGER_SERVICE,
+};
+
+
+
+static void boot_manager_application_finalize     (GObject      *object);
+static void boot_manager_application_get_property (GObject      *object,
+                                                   guint         prop_id,
+                                                   GValue       *value,
+                                                   GParamSpec   *pspec);
+static void boot_manager_application_set_property (GObject      *object,
+                                                   guint         prop_id,
+                                                   const GValue *value,
+                                                   GParamSpec   *pspec);
+static void boot_manager_application_startup      (GApplication *application);
+
+
+
+struct _BootManagerApplicationClass
+{
+  GApplicationClass __parent__;
+};
+
+struct _BootManagerApplication
+{
+  GApplication       __parent__;
+
+  /* systemd watchdog client that repeatedly asks systemd to update
+   * the watchdog timestamp */
+  WatchdogClient    *watchdog_client;
+
+  /* service object that implements the boot manager D-Bus interface */
+  BootManagerService *service;
+};
+
+
+
+G_DEFINE_TYPE (BootManagerApplication, boot_manager_application, G_TYPE_APPLICATION);
+
+
+
+static void
+boot_manager_application_class_init (BootManagerApplicationClass *klass)
+{
+  GApplicationClass *gapplication_class;
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = boot_manager_application_finalize;
+  gobject_class->get_property = boot_manager_application_get_property;
+  gobject_class->set_property = boot_manager_application_set_property;
+
+  gapplication_class = G_APPLICATION_CLASS (klass);
+  gapplication_class->startup = boot_manager_application_startup;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_BOOT_MANAGER_SERVICE,
+                                   g_param_spec_object ("boot-manager-service",
+                                                        "boot-manager-service",
+                                                        "boot-manager-service",
+                                                        BOOT_MANAGER_TYPE_SERVICE,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+}
+
+
+
+static void
+boot_manager_application_init (BootManagerApplication *application)
+{
+}
+
+
+
+static void
+boot_manager_application_finalize (GObject *object)
+{
+  BootManagerApplication *application = BOOT_MANAGER_APPLICATION (object);
+
+  /* release the watchdog client */
+  g_object_unref (application->watchdog_client);
+
+  /* release the boot manager service implementation */
+  if (application->service != NULL)
+    g_object_unref (application->service);
+
+  (*G_OBJECT_CLASS (boot_manager_application_parent_class)->finalize) (object);
+}
+
+
+
+static void
+boot_manager_application_get_property (GObject    *object,
+                                       guint       prop_id,
+                                       GValue     *value,
+                                       GParamSpec *pspec)
+{
+  BootManagerApplication *application = BOOT_MANAGER_APPLICATION (object);
+
+  switch (prop_id)
+    {
+    case PROP_BOOT_MANAGER_SERVICE:
+      g_value_set_object (value, application->service);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
+static void
+boot_manager_application_set_property (GObject      *object,
+                                       guint         prop_id,
+                                       const GValue *value,
+                                       GParamSpec   *pspec)
+{
+  BootManagerApplication *application = BOOT_MANAGER_APPLICATION (object);
+
+  switch (prop_id)
+    {
+    case PROP_BOOT_MANAGER_SERVICE:
+      application->service = g_value_dup_object (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
+static void
+boot_manager_application_startup (GApplication *app)
+{
+  BootManagerApplication *application = BOOT_MANAGER_APPLICATION (app);
+
+  /* update systemd's watchdog timestamp every 120 seconds */
+  application->watchdog_client = watchdog_client_new (120);
+}
+
+
+
+BootManagerApplication *
+boot_manager_application_new (BootManagerService *service)
+{
+  return g_object_new (BOOT_MANAGER_TYPE_APPLICATION,
+                       "application-id", "org.genivi.BootManager1",
+                       "flags", G_APPLICATION_IS_SERVICE,
+                       "boot-manager-service", service,
+                       NULL);
+}
diff --git a/boot-manager/boot-manager-application.h b/boot-manager/boot-manager-application.h
new file mode 100644 (file)
index 0000000..5fd3639
--- /dev/null
@@ -0,0 +1,34 @@
+/* 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 __BOOT_MANAGER_APPLICATION_H__
+#define __BOOT_MANAGER_APPLICATION_H__
+
+#include <boot-manager/boot-manager-service.h>
+
+G_BEGIN_DECLS
+
+#define BOOT_MANAGER_TYPE_APPLICATION            (boot_manager_application_get_type ())
+#define BOOT_MANAGER_APPLICATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOOT_MANAGER_TYPE_APPLICATION, BootManagerApplication))
+#define BOOT_MANAGER_APPLICATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), BOOT_MANAGER_TYPE_APPLICATION, BootManagerApplicationClass))
+#define BOOT_MANAGER_IS_APPLICATION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOOT_MANAGER_TYPE_APPLICATION))
+#define BOOT_MANAGER_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOOT_MANAGER_TYPE_APPLICATION)
+#define BOOT_MANAGER_APPLICATION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), BOOT_MANAGER_TYPE_APPLICATION, BootManagerApplicationClass))
+
+typedef struct _BootManagerApplicationClass BootManagerApplicationClass;
+typedef struct _BootManagerApplication      BootManagerApplication;
+
+GType                          boot_manager_application_get_type (void) G_GNUC_CONST;
+
+BootManagerApplication *boot_manager_application_new      (BootManagerService *service) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
+G_END_DECLS
+
+#endif /* !__BOOT_MANAGER_APPLICATION_H__ */
+
diff --git a/boot-manager/boot-manager-dbus.xml b/boot-manager/boot-manager-dbus.xml
new file mode 100644 (file)
index 0000000..9419ad6
--- /dev/null
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/org/genivi/BootManager1">
+  <!--
+    org.genivi.BootManager1:
+    @short_description: Interface for simplified control over systemd units.
+
+    The GENIVI Boot Manager service allows other components in the system to
+    control the lifetime of systemd units, e.g. by starting and stopping them
+    during system runtime.
+
+    It's goal is to safe-guard the access to systemd and provide a simplified
+    interface to controling units based on asynchronous D-Bus methods.
+  -->
+  <interface name="org.genivi.BootManager1">
+    <!--
+      Start:
+      @unit: A unit filename (e.g. "app1.unit").
+      @result: The result of the unit start request.
+
+      Attempts to start a unit through systemd. Possible values for the
+      result are:
+
+      done - the unit was started successfully.
+      failed - the unit startup failed.
+      timeout - the unit startup job timed out.
+      canceled - the unit startup was canceled by someone else.
+      dependency - a dependency or non-dependency could not be started or stopped.
+      skipped - the unit startup was skipped.
+
+      These values are identical to the possible job results systemd implements.
+
+    -->
+    <method name="Start">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+      <arg name="unit" type="s" direction="in"/>
+      <arg name="result" type="s" direction="out"/>
+    </method>
+
+    <!--
+      Stop:
+      @unit: A unit filename (e.g. "app1.unit").
+      @result: The result of the unit stop request.
+
+      Attempts to stop a running unit through systemd. The possible result
+      values are the same as for the Start() method.
+    -->
+    <method name="Stop">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+      <arg name="unit" type="s" direction="in"/>
+      <arg name="result" type="s" direction="out"/>
+    </method>
+
+    <!--
+      Kill:
+      @unit: A unit filename (e.g. "app1.unit").
+      @result: The result of the unit kill request.
+
+      Attempts to kill a running unit through systemd. The possible result
+      values are the same as for the Start() method.
+    -->
+    <method name="Kill">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+      <arg name="unit" type="s" direction="in"/>
+      <arg name="result" type="s" direction="out"/>
+    </method>
+
+    <!--
+      Restart:
+      @unit: A unit filename (e.g. "app1.unit").
+      @result: The result of the unit stop request.
+
+      Attempts to restart a running unit through systemd. The possible result
+      values are the same as for the Start() method.
+    -->
+    <method name="Restart">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+      <arg name="unit" type="s" direction="in"/>
+      <arg name="result" type="s" direction="out"/>
+    </method>
+
+    <!--
+      Isolate:
+      @unit: A unit filename (e.g. "transport-mode.target").
+      @result: The result of the unit isolate request.
+
+      Attempts to isolate a running unit through systemd. The possible result
+      values are the same as for the Start() method.
+
+      Isolating a unit (usually a target) is similar to switching to a
+      certain runlevel in traditional Linux systems. In IVI systems it can be
+      used to switch between system modes such as user mode, transport mode,
+      loading mode etc.
+    -->
+    <method name="Isolate">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+      <arg name="unit" type="s" direction="in"/>
+      <arg name="result" type="s" direction="out"/>
+    </method>
+
+    <!--
+      List:
+      @apps: Return parameter that is an array of all available unit filenames.
+
+      Lists all unit filenames currently known to systemd.
+    -->
+    <method name="List">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+      <arg name="apps" type="as" direction="out"/>
+    </method>
+  </interface>
+</node>
diff --git a/boot-manager/boot-manager-service.c b/boot-manager/boot-manager-service.c
new file mode 100644 (file)
index 0000000..69233f9
--- /dev/null
@@ -0,0 +1,175 @@
+/* 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 <boot-manager/boot-manager-dbus.h>
+#include <boot-manager/boot-manager-service.h>
+
+
+
+/* property identifiers */
+enum
+{
+  PROP_0,
+  PROP_CONNECTION,
+};
+
+
+
+static void boot_manager_service_finalize     (GObject      *object);
+static void boot_manager_service_get_property (GObject      *object,
+                                               guint         prop_id,
+                                               GValue       *value,
+                                               GParamSpec   *pspec);
+static void boot_manager_service_set_property (GObject      *object,
+                                               guint         prop_id,
+                                               const GValue *value,
+                                               GParamSpec   *pspec);
+
+
+
+struct _BootManagerServiceClass
+{
+  GObjectClass __parent__;
+};
+
+struct _BootManagerService
+{
+  GObject          __parent__;
+
+  GDBusConnection *connection;
+  BootManager     *interface;
+};
+
+
+
+G_DEFINE_TYPE (BootManagerService, boot_manager_service, G_TYPE_OBJECT);
+
+
+
+static void
+boot_manager_service_class_init (BootManagerServiceClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = boot_manager_service_finalize;
+  gobject_class->get_property = boot_manager_service_get_property;
+  gobject_class->set_property = boot_manager_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));
+}
+
+
+
+static void
+boot_manager_service_init (BootManagerService *service)
+{
+  service->interface = boot_manager_skeleton_new ();
+}
+
+
+
+static void
+boot_manager_service_finalize (GObject *object)
+{
+  BootManagerService *service = BOOT_MANAGER_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 (boot_manager_service_parent_class)->finalize) (object);
+}
+
+
+
+static void
+boot_manager_service_get_property (GObject    *object,
+                                   guint       prop_id,
+                                   GValue     *value,
+                                   GParamSpec *pspec)
+{
+  BootManagerService *service = BOOT_MANAGER_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
+boot_manager_service_set_property (GObject      *object,
+                                   guint         prop_id,
+                                   const GValue *value,
+                                   GParamSpec   *pspec)
+{
+  BootManagerService *service = BOOT_MANAGER_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;
+    }
+}
+
+
+
+BootManagerService *
+boot_manager_service_new (GDBusConnection *connection)
+{
+  g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
+  return g_object_new (BOOT_MANAGER_TYPE_SERVICE, "connection", connection, NULL);
+}
+
+
+
+gboolean
+boot_manager_service_start (BootManagerService *service,
+                            GError             **error)
+{
+  g_return_val_if_fail (BOOT_MANAGER_IS_SERVICE (service), FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  /* announce the org.genivi.BootManager1 service on the bus */
+  return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service->interface),
+                                           service->connection,
+                                           "/org/genivi/BootManager1",
+                                           error);
+}
diff --git a/boot-manager/boot-manager-service.h b/boot-manager/boot-manager-service.h
new file mode 100644 (file)
index 0000000..bb299fb
--- /dev/null
@@ -0,0 +1,36 @@
+/* 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 __BOOT_MANAGER_SERVICE_H__
+#define __BOOT_MANAGER_SERVICE_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define BOOT_MANAGER_TYPE_SERVICE            (boot_manager_service_get_type ())
+#define BOOT_MANAGER_SERVICE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOOT_MANAGER_TYPE_SERVICE, BootManagerService))
+#define BOOT_MANAGER_SERVICE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), BOOT_MANAGER_TYPE_SERVICE, BootManagerServiceClass))
+#define BOOT_MANAGER_IS_SERVICE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOOT_MANAGER_TYPE_SERVICE))
+#define BOOT_MANAGER_IS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOOT_MANAGER_TYPE_SERVICE)
+#define BOOT_MANAGER_SERVICE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), BOOT_MANAGER_TYPE_SERVICE, BootManagerServiceClass))
+
+typedef struct _BootManagerServiceClass BootManagerServiceClass;
+typedef struct _BootManagerService      BootManagerService;
+
+GType               boot_manager_service_get_type (void) G_GNUC_CONST;
+
+BootManagerService *boot_manager_service_new      (GDBusConnection    *connection) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+gboolean            boot_manager_service_start    (BootManagerService *service,
+                                                   GError            **error);
+
+G_END_DECLS
+
+#endif /* !__BOOT_MANAGER_SERVICE_H__ */
+
diff --git a/boot-manager/main.c b/boot-manager/main.c
new file mode 100644 (file)
index 0000000..474996d
--- /dev/null
@@ -0,0 +1,75 @@
+/* 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 <boot-manager/boot-manager-application.h>
+#include <boot-manager/boot-manager-service.h>
+
+
+
+int
+main (int    argc,
+      char **argv)
+{
+  BootManagerApplication *application;
+  BootManagerService     *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 BootManager service implementation */
+  service = boot_manager_service_new (connection);
+  if (!boot_manager_service_start (service, &error))
+    {
+      g_warning ("Failed to start the BootManager 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 = boot_manager_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;
+}
diff --git a/boot-manager/org.genivi.BootManager1.service.in b/boot-manager/org.genivi.BootManager1.service.in
new file mode 100644 (file)
index 0000000..7185fee
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.genivi.BootManager1
+Exec=@libdir@/boot-manager-@BOOT_MANAGER_VERSION_API@/boot-manager
index e79defd..61a1e53 100644 (file)
@@ -95,6 +95,7 @@ GLIB_GSETTINGS
 
 AC_OUTPUT([
 Makefile
+boot-manager/Makefile
 luc-handler/Makefile
 luc-handler/org.genivi.LUCHandler1.gschema.xml
 tests/Makefile