ofono: Remove 3G network after disabled 3G modem
authorYu A Wang <yu.a.wang@intel.com>
Tue, 6 Sep 2011 09:06:34 +0000 (05:06 -0400)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 12 Sep 2011 18:23:21 +0000 (20:23 +0200)
Fixes BMC#22745

plugins/ofono.c

index 060cd8e..6652077 100644 (file)
@@ -253,6 +253,36 @@ static void update_modem_online(struct modem_data *modem,
                connman_device_set_powered(modem->device, online);
 }
 
+static void remove_device_networks(struct connman_device *device)
+{
+       GHashTableIter iter;
+       gpointer key, value;
+       GSList *info_list = NULL;
+       GSList *list;
+
+       if (network_hash == NULL)
+               return;
+
+       g_hash_table_iter_init(&iter, network_hash);
+
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               struct network_info *info = value;
+
+               if (connman_network_get_device(info->network) != device)
+                       continue;
+
+               info_list = g_slist_append(info_list, info);
+       }
+
+       for (list = info_list; list != NULL; list = list->next) {
+               struct network_info *info = list->data;
+
+               connman_device_remove_network(device, info->network);
+       }
+
+       g_slist_free(info_list);
+}
+
 static void set_online_reply(DBusPendingCall *call, void *user_data)
 {
        struct modem_data *modem;
@@ -285,6 +315,9 @@ static void set_online_reply(DBusPendingCall *call, void *user_data)
        if (modem->pending_online)
                update_modem_online(modem, result);
 
+       if (result == FALSE)
+               remove_device_networks(modem->device);
+
        dbus_message_unref(reply);
 
        dbus_pending_call_unref(call);
@@ -335,36 +368,6 @@ static struct connman_device_driver modem_driver = {
        .disable        = modem_disable,
 };
 
-static void remove_device_networks(struct connman_device *device)
-{
-       GHashTableIter iter;
-       gpointer key, value;
-       GSList *info_list = NULL;
-       GSList *list;
-
-       if (network_hash == NULL)
-               return;
-
-       g_hash_table_iter_init(&iter, network_hash);
-
-       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-               struct network_info *info = value;
-
-               if (connman_network_get_device(info->network) != device)
-                       continue;
-
-               info_list = g_slist_append(info_list, info);
-       }
-
-       for (list = info_list; list != NULL; list = list->next) {
-               struct network_info *info = list->data;
-
-               connman_device_remove_network(device, info->network);
-       }
-
-       g_slist_free(info_list);
-}
-
 static void modem_remove_device(struct modem_data *modem)
 {
        DBG("modem %p path %s device %p", modem, modem->path, modem->device);