1 /* vi:set et ai sw=2 sts=2 ts=2: */
3 * Copyright (c) 2012 GENIVI.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
14 #include <glib-object.h>
17 #include <common/watchdog-client.h>
19 #include <boot-manager/boot-manager-dbus.h>
20 #include <boot-manager/boot-manager-application.h>
21 #include <boot-manager/boot-manager-service.h>
25 /* property identifiers */
29 PROP_BOOT_MANAGER_SERVICE,
34 static void boot_manager_application_finalize (GObject *object);
35 static void boot_manager_application_get_property (GObject *object,
39 static void boot_manager_application_set_property (GObject *object,
43 static void boot_manager_application_startup (GApplication *application);
47 struct _BootManagerApplicationClass
49 GApplicationClass __parent__;
52 struct _BootManagerApplication
54 GApplication __parent__;
56 /* systemd watchdog client that repeatedly asks systemd to update
57 * the watchdog timestamp */
58 WatchdogClient *watchdog_client;
60 /* service object that implements the boot manager D-Bus interface */
61 BootManagerService *service;
66 G_DEFINE_TYPE (BootManagerApplication, boot_manager_application, G_TYPE_APPLICATION);
71 boot_manager_application_class_init (BootManagerApplicationClass *klass)
73 GApplicationClass *gapplication_class;
74 GObjectClass *gobject_class;
76 gobject_class = G_OBJECT_CLASS (klass);
77 gobject_class->finalize = boot_manager_application_finalize;
78 gobject_class->get_property = boot_manager_application_get_property;
79 gobject_class->set_property = boot_manager_application_set_property;
81 gapplication_class = G_APPLICATION_CLASS (klass);
82 gapplication_class->startup = boot_manager_application_startup;
84 g_object_class_install_property (gobject_class,
85 PROP_BOOT_MANAGER_SERVICE,
86 g_param_spec_object ("boot-manager-service",
87 "boot-manager-service",
88 "boot-manager-service",
89 BOOT_MANAGER_TYPE_SERVICE,
91 G_PARAM_CONSTRUCT_ONLY));
97 boot_manager_application_init (BootManagerApplication *application)
99 /* update systemd's watchdog timestamp every 120 seconds */
100 application->watchdog_client = watchdog_client_new (120);
106 boot_manager_application_finalize (GObject *object)
108 BootManagerApplication *application = BOOT_MANAGER_APPLICATION (object);
110 /* release the watchdog client */
111 g_object_unref (application->watchdog_client);
113 /* release the boot manager service implementation */
114 if (application->service != NULL)
115 g_object_unref (application->service);
117 (*G_OBJECT_CLASS (boot_manager_application_parent_class)->finalize) (object);
123 boot_manager_application_get_property (GObject *object,
128 BootManagerApplication *application = BOOT_MANAGER_APPLICATION (object);
132 case PROP_BOOT_MANAGER_SERVICE:
133 g_value_set_object (value, application->service);
136 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
144 boot_manager_application_set_property (GObject *object,
149 BootManagerApplication *application = BOOT_MANAGER_APPLICATION (object);
153 case PROP_BOOT_MANAGER_SERVICE:
154 application->service = g_value_dup_object (value);
157 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
165 boot_manager_application_startup (GApplication *app)
171 BootManagerApplication *
172 boot_manager_application_new (BootManagerService *service)
174 return g_object_new (BOOT_MANAGER_TYPE_APPLICATION,
175 "application-id", "org.genivi.BootManager1",
176 "flags", G_APPLICATION_IS_SERVICE,
177 "boot-manager-service", service,