From c3d4dfaee40b0c8817c38117ae08a47c4ec7f1f2 Mon Sep 17 00:00:00 2001 From: Yu A Wang Date: Tue, 6 Sep 2011 05:06:34 -0400 Subject: [PATCH] ofono: Remove 3G network after disabled 3G modem Fixes BMC#22745 --- plugins/ofono.c | 63 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/plugins/ofono.c b/plugins/ofono.c index 060cd8e..6652077 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -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); -- 2.7.4