summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalle Valo <kalle.valo@canonical.com>2010-06-11 16:30:06 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2010-06-14 23:02:59 +0200
commit168c346239393b4f81f26eb03b9bf8e705be3ee5 (patch)
treec732cab2cf10725a40bd16ef3091f6024262d500
parent54c3f8c48c502c8f46f435820e33ccbfe20319fc (diff)
downloadconnman-168c346239393b4f81f26eb03b9bf8e705be3ee5.tar.gz
ofono: Follow registration name changes
As the Name property in org.ofono.NetworkRegistration is sometimes empty while the network is created, follow the property changes in org.ofono.NetworkRegistration interface and set network name if the name changes. Also the network name might change in certain rare cases, so this needs to be handled in connman side.
-rw-r--r--plugins/ofono.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 6c222e0e..f341ee8d 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -375,9 +375,51 @@ done:
dbus_message_unref(message);
}
+static gboolean registration_changed(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ const char *path = dbus_message_get_path(message);
+ struct connman_network *network = user_data;
+ DBusMessageIter iter, value;
+ const char *key, *name;
+
+ DBG("path %s", path);
+
+ if (dbus_message_iter_init(message, &iter) == FALSE)
+ return TRUE;
+
+ dbus_message_iter_get_basic(&iter, &key);
+
+ DBG("key %s", key);
+
+ dbus_message_iter_next(&iter);
+ dbus_message_iter_recurse(&iter, &value);
+
+ if (g_strcmp0(key, "Name") == 0 ||
+ g_strcmp0(key, "Operator") == 0) {
+ dbus_message_iter_get_basic(&value, &name);
+ DBG("name %s", name);
+ connman_network_set_name(network, name);
+ create_service(network);
+ }
+
+ return TRUE;
+}
+
static int network_probe(struct connman_network *network)
{
const char *path;
+ guint reg_watch;
+
+ reg_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_REGISTRATION_INTERFACE,
+ PROPERTY_CHANGED,
+ registration_changed,
+ network, NULL);
+ if (reg_watch == 0)
+ return -EIO;
+
+ connman_network_set_data(network, GUINT_TO_POINTER(reg_watch));
path = connman_network_get_string(network, "Path");
@@ -587,7 +629,12 @@ static int network_disconnect(struct connman_network *network)
static void network_remove(struct connman_network *network)
{
+ guint reg_watch;
+
DBG("network %p", network);
+
+ reg_watch = GPOINTER_TO_UINT(connman_network_get_data(network));
+ g_dbus_remove_watch(connection, reg_watch);
}
static int network_setup(struct connman_network *network, const char *key)