From 9ce8952b117226ddda6b60e676dc9c6c7f9072b1 Mon Sep 17 00:00:00 2001 From: Jonathan Maw Date: Wed, 8 Aug 2012 17:42:03 +0100 Subject: Add callbacks that log when bus names are acquired or lost Callbacks added to both the Node Startup Controller and the NSM Dummy --- .../node-startup-controller-application.c | 35 ++++++++++++- nsm-dummy/nsm-dummy-application.c | 57 +++++++++++++++++----- 2 files changed, 78 insertions(+), 14 deletions(-) diff --git a/node-startup-controller/node-startup-controller-application.c b/node-startup-controller/node-startup-controller-application.c index d8396ce..bbd70fb 100644 --- a/node-startup-controller/node-startup-controller-application.c +++ b/node-startup-controller/node-startup-controller-application.c @@ -77,6 +77,12 @@ static void node_startup_controller_application_luc_groups_started NodeStartupControllerApplication *application); static gboolean node_startup_controller_application_handle_sigterm (gpointer user_data); static void node_startup_controller_application_unregister_shutdown_consumer (NodeStartupControllerApplication *application); +static void node_startup_controller_application_bus_name_acquired (GDBusConnection *connection, + const gchar *name, + gpointer user_data); +static void node_startup_controller_application_bus_name_lost (GDBusConnection *connection, + const gchar *name, + gpointer user_data); @@ -355,7 +361,10 @@ node_startup_controller_application_constructed (GObject *object) /* get a bus name on the given connection */ application->bus_name_id = g_bus_own_name_on_connection (application->connection, "org.genivi.NodeStartupController1", - G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL); + G_BUS_NAME_OWNER_FLAGS_NONE, + node_startup_controller_application_bus_name_acquired, + node_startup_controller_application_bus_name_lost, NULL, + NULL); /* create a shutdown client for the node startup controller itself */ object_path = "/org/genivi/NodeStartupController1/ShutdownConsumer/0"; @@ -634,6 +643,30 @@ node_startup_controller_application_unregister_shutdown_consumer (NodeStartupCon +static void +node_startup_controller_application_bus_name_acquired (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + DLT_LOG (controller_context, DLT_LOG_INFO, + DLT_STRING ("Successfully acquired bus name:"), + DLT_STRING (name)); +} + + + +static void +node_startup_controller_application_bus_name_lost (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + DLT_LOG (controller_context, DLT_LOG_INFO, + DLT_STRING ("Lost bus name:"), + DLT_STRING (name)); +} + + + /** * node_startup_controller_application_new: * @main_loop: The application's main loop. diff --git a/nsm-dummy/nsm-dummy-application.c b/nsm-dummy/nsm-dummy-application.c index 55e90fb..41847c1 100644 --- a/nsm-dummy/nsm-dummy-application.c +++ b/nsm-dummy/nsm-dummy-application.c @@ -45,18 +45,23 @@ enum -static void nsm_dummy_application_constructed (GObject *object); -static void nsm_dummy_application_finalize (GObject *object); -static void nsm_dummy_application_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void nsm_dummy_application_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static gboolean nsm_dummy_application_handle_sighup (gpointer user_data); - +static void nsm_dummy_application_constructed (GObject *object); +static void nsm_dummy_application_finalize (GObject *object); +static void nsm_dummy_application_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void nsm_dummy_application_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static gboolean nsm_dummy_application_handle_sighup (gpointer user_data); +static void nsm_dummy_application_bus_name_acquired (GDBusConnection *connection, + const gchar *name, + gpointer user_data); +static void nsm_dummy_application_bus_name_lost (GDBusConnection *connection, + const gchar *name, + gpointer user_data); struct _NSMDummyApplicationClass @@ -227,7 +232,9 @@ nsm_dummy_application_constructed (GObject *object) application->bus_name_id = g_bus_own_name_on_connection (application->connection, "com.contiautomotive.NodeStateManager", - G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL); + G_BUS_NAME_OWNER_FLAGS_NONE, + nsm_dummy_application_bus_name_acquired, + nsm_dummy_application_bus_name_lost, NULL, NULL); /* inform systemd that this process has started */ sd_notify (0, "READY=1"); @@ -308,6 +315,30 @@ nsm_dummy_application_handle_sighup (gpointer user_data) +static void +nsm_dummy_application_bus_name_acquired (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, + DLT_STRING ("Successfully acquired bus name:"), + DLT_STRING (name)); +} + + + +static void +nsm_dummy_application_bus_name_lost (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + DLT_LOG (nsm_dummy_context, DLT_LOG_INFO, + DLT_STRING ("Lost bus name:"), + DLT_STRING (name)); +} + + + NSMDummyApplication * nsm_dummy_application_new (GMainLoop *main_loop, GDBusConnection *connection, -- cgit v1.2.1