Set the network roaming toggle according to oFono status
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 25 Jun 2010 15:36:12 +0000 (17:36 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 25 Jun 2010 15:38:24 +0000 (17:38 +0200)
oFono's NetworkRegistration interface gives a status propery indicating
(among other things) if we're roaming or not.

plugins/ofono.c

index 2995f2648255f0c6f1ee518b2dfc2b62dcec867e..2f67a99f6aa9feef40089d51adc19ad9ed8a7e34 100644 (file)
@@ -237,6 +237,22 @@ static void set_network_name_reply(DBusPendingCall *call, void *user_data)
                        dbus_message_iter_get_basic(&value, &name);
                        connman_network_set_name(network, name);
                        create_service(network);
+               } else if (g_strcmp0(key, "Status") == 0) {
+                       const char *status;
+                       connman_bool_t roaming;
+
+                       dbus_message_iter_get_basic(&value, &status);
+                       if (g_strcmp0(status, "roaming") == 0)
+                               roaming = TRUE;
+                       else if (g_strcmp0(status, "registered") == 0)
+                               roaming = FALSE;
+                       else {
+                               dbus_message_iter_next(&dict);
+                               continue;
+                       }
+
+                       connman_network_set_roaming(network, roaming);
+                       connman_network_update(network);
                }
 
                dbus_message_iter_next(&dict);
@@ -409,6 +425,20 @@ static gboolean registration_changed(DBusConnection *connection,
                dbus_message_iter_get_basic(&value, &strength);
                connman_network_set_strength(network, strength);
                connman_network_update(network);
+       } else if (g_strcmp0(key, "Status") == 0) {
+               const char *status;
+               connman_bool_t roaming;
+
+               dbus_message_iter_get_basic(&value, &status);
+               if (g_strcmp0(status, "roaming") == 0)
+                       roaming = TRUE;
+               else if (g_strcmp0(status, "registered") == 0)
+                       roaming = FALSE;
+               else
+                       return TRUE;
+
+               connman_network_set_roaming(network, roaming);
+               connman_network_update(network);
        }
 
        return TRUE;