From 6be4d7a3cd917ed591ac4de93e5cc15d4d7c57b0 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 1 Sep 2009 18:29:43 -0700 Subject: [PATCH] Add tracking of oFono startup and termination --- plugins/ofono.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/plugins/ofono.c b/plugins/ofono.c index 2055c05..d8af4b9 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -23,16 +23,77 @@ #include #endif +#include + +#include + #define CONNMAN_API_SUBJECT_TO_CHANGE #include +#include +#include + +#define OFONO_SERVICE "org.ofono" + +static DBusConnection *connection; + +static GHashTable *ofono_modems = NULL; + +static void unregister_modem(gpointer data) +{ + DBG(""); +} + +static void ofono_connect(DBusConnection *connection, void *user_data) +{ + DBG("connection %p", connection); + + ofono_modems = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, unregister_modem); +} + +static void ofono_disconnect(DBusConnection *connection, void *user_data) +{ + DBG("connection %p", connection); + + if (ofono_modems == NULL) + return; + + g_hash_table_destroy(ofono_modems); + ofono_modems = NULL; +} + +static guint watch; static int ofono_init(void) { + int err; + + connection = connman_dbus_get_connection(); + if (connection == NULL) + return -EIO; + + watch = g_dbus_add_service_watch(connection, OFONO_SERVICE, + ofono_connect, ofono_disconnect, NULL, NULL); + if (watch == 0) { + err = -EIO; + goto unref; + } + return 0; + +unref: + dbus_connection_unref(connection); + + return err; } static void ofono_exit(void) { + g_dbus_remove_watch(connection, watch); + + ofono_disconnect(connection, NULL); + + dbus_connection_unref(connection); } CONNMAN_PLUGIN_DEFINE(ofono, "oFono telephony plugin", VERSION, -- 2.7.4