From 1375f0779312a62ef87a45bdee9769784508b9ba Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 18 May 2009 19:41:05 -0700 Subject: [PATCH] Fix broken network group name handling --- plugins/supplicant.c | 10 ++++------ src/network.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/plugins/supplicant.c b/plugins/supplicant.c index b010968..730fd3d 100644 --- a/plugins/supplicant.c +++ b/plugins/supplicant.c @@ -1110,8 +1110,6 @@ static void properties_reply(DBusPendingCall *call, void *user_data) connman_network_set_string(network, "Address", result.addr); - connman_network_set_group(network, group); - if (result.name != NULL && result.name[0] != '\0') connman_network_set_string(network, "Name", result.name); @@ -1126,10 +1124,6 @@ static void properties_reply(DBusPendingCall *call, void *user_data) } } - connman_network_set_group(network, group); - - g_free(group); - if (result.name != NULL && result.name[0] != '\0') connman_network_set_string(network, "Name", result.name); @@ -1147,6 +1141,10 @@ static void properties_reply(DBusPendingCall *call, void *user_data) connman_network_set_string(network, "WiFi.Security", security); + connman_network_set_group(network, group); + + g_free(group); + done: g_free(result.path); g_free(result.addr); diff --git a/src/network.c b/src/network.c index ceeb0bd..dd935ba 100644 --- a/src/network.c +++ b/src/network.c @@ -571,8 +571,34 @@ void connman_network_set_protocol(struct connman_network *network, void connman_network_set_group(struct connman_network *network, const char *group) { - g_free(network->group); + if (network->secondary == TRUE) + return; + + if (g_strcmp0(network->group, group) == 0) + return; + + switch (network->type) { + case CONNMAN_NETWORK_TYPE_UNKNOWN: + case CONNMAN_NETWORK_TYPE_VENDOR: + case CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN: + case CONNMAN_NETWORK_TYPE_BLUETOOTH_DUN: + case CONNMAN_NETWORK_TYPE_HSO: + return; + case CONNMAN_NETWORK_TYPE_WIFI: + case CONNMAN_NETWORK_TYPE_WIMAX: + break; + } + + if (network->group != NULL) { + __connman_profile_remove_network(network); + + g_free(network->group); + } + network->group = g_strdup(group); + + if (network->group != NULL) + __connman_profile_add_network(network); } const char *__connman_network_get_group(struct connman_network *network) @@ -1044,7 +1070,7 @@ static int network_probe(struct connman_element *element) break; case CONNMAN_NETWORK_TYPE_WIFI: case CONNMAN_NETWORK_TYPE_WIMAX: - if (network->secondary == FALSE) + if (network->group != NULL && network->secondary == FALSE) __connman_profile_add_network(network); break; } @@ -1073,8 +1099,12 @@ static void network_remove(struct connman_element *element) break; case CONNMAN_NETWORK_TYPE_WIFI: case CONNMAN_NETWORK_TYPE_WIMAX: - if (network->secondary == FALSE) + if (network->group != NULL && network->secondary == FALSE) { __connman_profile_remove_network(network); + + g_free(network->group); + network->group = NULL; + } break; } -- 2.7.4