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/.
23 #include <nsm-dummy/nsm-consumer-service.h>
24 #include <nsm-dummy/nsm-dummy-application.h>
25 #include <nsm-dummy/nsm-lifecycle-control-service.h>
29 DLT_DECLARE_CONTEXT (nsm_dummy_context);
37 NSMLifecycleControlService *lifecycle_control_service;
38 NSMDummyApplication *application;
39 NSMConsumerService *consumer_service;
40 GDBusConnection *connection;
44 /* register the application and context in DLT */
45 DLT_REGISTER_APP ("NSMD", "GENIVI Node State Manager Dummy");
46 DLT_REGISTER_CONTEXT (nsm_dummy_context, "NSMC",
47 "Context of the node state manager dummy itself");
49 /* initialize the GType type system */
52 /* attempt to connect to D-Bus */
53 connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
54 if (connection == NULL)
56 g_warning ("Failed to connect to D-Bus: %s", error->message);
64 /* instantiate the NSMLifecycleControlService implementation */
65 lifecycle_control_service = nsm_lifecycle_control_service_new (connection);
66 if (!nsm_lifecycle_control_service_start (lifecycle_control_service, &error))
68 g_warning ("Failed to start the LifecycleControl service: %s", error->message);
72 g_object_unref (lifecycle_control_service);
73 g_object_unref (connection);
78 /* instantiate the NSMConsumerService implementation */
79 consumer_service = nsm_consumer_service_new (connection);
80 if (!nsm_consumer_service_start (consumer_service, &error))
82 g_warning ("Failed to start the Consumer service: %s", error->message);
86 g_object_unref (consumer_service);
87 g_object_unref (connection);
92 /* create the main loop */
93 main_loop = g_main_loop_new (NULL, FALSE);
95 /* create the main application */
96 application = nsm_dummy_application_new (main_loop, connection, consumer_service,
97 lifecycle_control_service);
99 /* run the main loop */
100 g_main_loop_run (main_loop);
101 g_main_loop_unref (main_loop);
103 /* release allocated objects */
104 g_object_unref (application);
105 g_object_unref (lifecycle_control_service);
106 g_object_unref (consumer_service);
107 g_object_unref (connection);
109 /* unregister the application and context with DLT */
110 DLT_UNREGISTER_CONTEXT (nsm_dummy_context);
111 DLT_UNREGISTER_APP ();