From: Marcel Holtmann Date: Fri, 5 Dec 2008 21:07:26 +0000 (+0100) Subject: Track global connection state X-Git-Tag: 2.0_alpha~4528 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=afc80b971146277e4befc173ef61cfcb375a3b0f;p=framework%2Fconnectivity%2Fconnman.git Track global connection state --- diff --git a/plugins/wifi.c b/plugins/wifi.c index 5104586..0ae20f5 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -44,6 +44,7 @@ struct wifi_data { GSList *list; gchar *identifier; + gboolean connected; }; static int network_probe(struct connman_element *element) @@ -77,6 +78,9 @@ static int network_enable(struct connman_element *element) if (element->parent != NULL) { struct wifi_data *data = connman_element_get_data(element->parent); + if (data->connected == TRUE) + return -EBUSY; + if (data != NULL) { g_free(data->identifier); data->identifier = g_strdup(identifier); @@ -154,13 +158,16 @@ static void state_change(struct connman_element *parent, if (state == STATE_COMPLETED) { struct connman_element *dhcp; + data->connected = TRUE; + dhcp = connman_element_create(NULL); dhcp->type = CONNMAN_ELEMENT_TYPE_DHCP; dhcp->index = element->index; connman_element_register(dhcp, element); - } + } else if (state == STATE_DISCONNECTED || state == STATE_INACTIVE) + data->connected = FALSE; } static void scan_result(struct connman_element *parent, @@ -262,6 +269,8 @@ static int wifi_probe(struct connman_element *element) if (data == NULL) return -ENOMEM; + data->connected = FALSE; + connman_element_set_data(element, data); return 0;