session: Hook into notifier session changes
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 31 Mar 2011 08:02:35 +0000 (10:02 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 31 Mar 2011 10:41:00 +0000 (12:41 +0200)
src/session.c

index 9b40303b8044d3ec9940f24ffabfa2753f3ccf4e..fc91b9ec4e64c270ef80a8d290171504744462ff 100644 (file)
@@ -691,14 +691,40 @@ void __connman_session_set_mode(connman_bool_t enable)
                __connman_service_disconnect_all();
 }
 
+static void service_state_changed(struct connman_service *service,
+                                       enum connman_service_state state)
+{
+       DBG("service %p state %d", service, state);
+}
+
+static void ipconfig_changed(struct connman_service *service,
+                               struct connman_ipconfig *ipconfig)
+{
+       DBG("service %p ipconfig %p", service, ipconfig);
+}
+
+static struct connman_notifier session_notifier = {
+       .name                   = "session",
+       .service_state_changed  = service_state_changed,
+       .ipconfig_changed       = ipconfig_changed,
+};
+
 int __connman_session_init(void)
 {
+       int err;
+
        DBG("");
 
        connection = connman_dbus_get_connection();
        if (connection == NULL)
                return -1;
 
+       err = connman_notifier_register(&session_notifier);
+       if (err < 0) {
+               dbus_connection_unref(connection);
+               return err;
+       }
+
        session_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
                                                NULL, cleanup_session);
 
@@ -713,6 +739,8 @@ void __connman_session_cleanup(void)
        if (connection == NULL)
                return;
 
+       connman_notifier_unregister(&session_notifier);
+
        g_hash_table_foreach(session_hash, release_session, NULL);
        g_hash_table_destroy(session_hash);