Include signal strength property
[connman] / plugins / wifi.c
index 6793eb4..5462bf2 100644 (file)
@@ -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,
@@ -185,7 +192,11 @@ static void scan_result(struct connman_element *parent,
        temp = g_strdup(network->identifier);
 
        for (i = 0; i < strlen(temp); i++) {
-               if (temp[i] == ' ' || temp[i] == '.' || temp[i] == '-')
+               if (temp[i] == ' ' || temp[i] == '.')
+                       temp[i] = '_';
+               else if (temp[i] == '-' || temp[i] == '+')
+                       temp[i] = '_';
+               else if (temp[i] == '!' || temp[i] == '?')
                        temp[i] = '_';
                else if (temp[i] == '(' || temp[i] == ')')
                        temp[i] = '_';
@@ -228,8 +239,8 @@ static void scan_result(struct connman_element *parent,
 
                strength = network->quality;
 
-               //connman_element_add_static_property(element, "WiFi.Strength",
-               //                              DBUS_TYPE_BYTE, &strength);
+               connman_element_add_static_property(element, "WiFi.Strength",
+                                               DBUS_TYPE_BYTE, &strength);
 
                //connman_element_add_static_property(element, "WiFi.Noise",
                //                      DBUS_TYPE_INT32, &network->noise);
@@ -258,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;
@@ -494,5 +507,5 @@ static void wifi_exit(void)
        dbus_connection_unref(connection);
 }
 
-CONNMAN_PLUGIN_DEFINE("wifi", "WiFi interface plugin", VERSION,
+CONNMAN_PLUGIN_DEFINE(wifi, "WiFi interface plugin", VERSION,
                                                        wifi_init, wifi_exit)