From: Marcel Holtmann Date: Wed, 2 Sep 2009 01:29:43 +0000 (-0700) Subject: Add tracking of oFono startup and termination X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~3266 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6be4d7a3cd917ed591ac4de93e5cc15d4d7c57b0;p=profile%2Fivi%2Fconnman.git Add tracking of oFono startup and termination --- 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,