summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorHenri Bragge <henri.bragge@ixonos.com>2011-02-07 12:33:15 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2011-02-08 01:09:19 +0100
commit3af2ef02aae2c014cbb008196ba6a75746977c22 (patch)
treeeeaaaa9ea5c58dcc83b6cbf9f3b8bdb7ef1a4b19 /plugins
parent6a4734af1afd44156c5d4862987a6b8fc5ebd3a8 (diff)
downloadconnman-3af2ef02aae2c014cbb008196ba6a75746977c22.tar.gz
connman-3af2ef02aae2c014cbb008196ba6a75746977c22.tar.bz2
connman-3af2ef02aae2c014cbb008196ba6a75746977c22.zip
ofono: Handle ContextAdded/ContextRemoved signals
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ofono.c78
1 files changed, 77 insertions, 1 deletions
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 480f7f75..43872ffc 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -1456,6 +1456,63 @@ static gboolean gprs_changed(DBusConnection *connection, DBusMessage *message,
return TRUE;
}
+static gboolean context_added(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ const char *path = dbus_message_get_path(message);
+ const char *network_path;
+ struct modem_data *modem;
+ DBusMessageIter iter, properties;
+
+ DBG("path %s", path);
+
+ modem = g_hash_table_lookup(modem_hash, path);
+ if (modem == NULL || modem->device == NULL)
+ return TRUE;
+
+ if (dbus_message_iter_init(message, &iter) == FALSE)
+ return TRUE;
+
+ dbus_message_iter_get_basic(&iter, &network_path);
+
+ dbus_message_iter_next(&iter);
+ dbus_message_iter_recurse(&iter, &properties);
+
+ add_network(modem->device, network_path, &properties);
+
+ return TRUE;
+}
+
+static gboolean context_removed(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ const char *path = dbus_message_get_path(message);
+ const char *network_path, *identifier;
+ struct modem_data *modem;
+ struct connman_network *network;
+ DBusMessageIter iter;
+
+ DBG("path %s", path);
+
+ modem = g_hash_table_lookup(modem_hash, path);
+ if (modem == NULL || modem->device == NULL)
+ return TRUE;
+
+ if (dbus_message_iter_init(message, &iter) == FALSE)
+ return TRUE;
+
+ dbus_message_iter_get_basic(&iter, &network_path);
+
+ network = g_hash_table_lookup(network_hash, network_path);
+ if (network == NULL)
+ return TRUE;
+
+ identifier = connman_network_get_identifier(network);
+ connman_device_remove_network(modem->device, identifier);
+
+ return TRUE;
+}
+
static gboolean modem_added(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
@@ -1716,6 +1773,8 @@ static guint watch;
static guint reg_watch;
static guint sim_watch;
static guint gprs_watch;
+static guint context_added_watch;
+static guint context_removed_watch;
static guint modem_watch;
static guint modem_added_watch;
static guint modem_removed_watch;
@@ -1744,6 +1803,18 @@ static int ofono_init(void)
gprs_changed,
NULL, NULL);
+ context_added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_GPRS_INTERFACE,
+ CONTEXT_ADDED,
+ context_added,
+ NULL, NULL);
+
+ context_removed_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_GPRS_INTERFACE,
+ CONTEXT_REMOVED,
+ context_removed,
+ NULL, NULL);
+
modem_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
OFONO_MODEM_INTERFACE,
PROPERTY_CHANGED,
@@ -1774,7 +1845,8 @@ static int ofono_init(void)
context_changed,
NULL, NULL);
- if (watch == 0 || gprs_watch == 0 || modem_watch == 0 ||
+ if (watch == 0 || gprs_watch == 0 || context_added_watch == 0 ||
+ context_removed_watch == 0 || modem_watch == 0 ||
reg_watch == 0 || sim_watch == 0 ||
modem_added_watch == 0 || modem_removed_watch == 0 ||
context_watch == 0) {
@@ -1799,6 +1871,8 @@ remove:
g_dbus_remove_watch(connection, sim_watch);
g_dbus_remove_watch(connection, reg_watch);
g_dbus_remove_watch(connection, gprs_watch);
+ g_dbus_remove_watch(connection, context_added_watch);
+ g_dbus_remove_watch(connection, context_removed_watch);
g_dbus_remove_watch(connection, modem_watch);
g_dbus_remove_watch(connection, modem_added_watch);
g_dbus_remove_watch(connection, modem_removed_watch);
@@ -1815,6 +1889,8 @@ static void ofono_exit(void)
g_dbus_remove_watch(connection, sim_watch);
g_dbus_remove_watch(connection, reg_watch);
g_dbus_remove_watch(connection, gprs_watch);
+ g_dbus_remove_watch(connection, context_added_watch);
+ g_dbus_remove_watch(connection, context_removed_watch);
g_dbus_remove_watch(connection, modem_watch);
g_dbus_remove_watch(connection, modem_added_watch);
g_dbus_remove_watch(connection, modem_removed_watch);