Reconnecting to last selected network by default
[connman] / src / network.c
index 6571da6..4a7b8f2 100644 (file)
@@ -462,10 +462,10 @@ struct connman_network *connman_network_create(const char *identifier,
 
        str = type2string(type);
        if (str != NULL)
-               connman_element_add_static_property(&network->element,
+               connman_element_set_static_property(&network->element,
                                        "Type", DBUS_TYPE_STRING, &str);
 
-       connman_element_add_static_property(&network->element,
+       connman_element_set_static_property(&network->element,
                                        "Strength", DBUS_TYPE_BYTE, &strength);
 
        network->type = type;
@@ -581,7 +581,10 @@ int connman_network_set_available(struct connman_network *network,
        if (network->registered == FALSE)
                return 0;
 
-       if (network->connected == FALSE && network->remember == FALSE)
+       if (network->connected == TRUE)
+               return 0;
+
+       if (network->remember == FALSE)
                return 0;
 
        signal = dbus_message_new_signal(network->element.path,
@@ -671,6 +674,8 @@ int connman_network_set_connected(struct connman_network *network,
 
                __connman_device_increase_connections(network->device);
 
+               __connman_device_set_network(network->device, network);
+
                element = connman_element_create(NULL);
                if (element != NULL) {
                        element->type  = type;
@@ -683,6 +688,8 @@ int connman_network_set_connected(struct connman_network *network,
        } else {
                connman_element_unregister_children(&network->element);
 
+               __connman_device_set_network(network->device, NULL);
+
                __connman_device_decrease_connections(network->device);
        }
 
@@ -1102,15 +1109,13 @@ static int network_load(struct connman_network *network)
        if (val > 0)
                network->priority = val;
 
-       if (network->remember == TRUE) {
-               g_free(network->wifi.security);
-               network->wifi.security = g_key_file_get_string(keyfile,
+       g_free(network->wifi.security);
+       network->wifi.security = g_key_file_get_string(keyfile,
                                network->identifier, "WiFi.Security", NULL);
 
-               g_free(network->wifi.passphrase);
-               network->wifi.passphrase = g_key_file_get_string(keyfile,
+       g_free(network->wifi.passphrase);
+       network->wifi.passphrase = g_key_file_get_string(keyfile,
                                network->identifier, "WiFi.Passphrase", NULL);
-       }
 
        g_key_file_free(keyfile);
 
@@ -1155,7 +1160,7 @@ update:
                g_key_file_set_integer(keyfile, network->identifier,
                                                "Priority", network->priority);
 
-       if (network->remember == TRUE) {
+       if (network->remember == TRUE || network->connected == TRUE) {
                if (network->wifi.security != NULL)
                        g_key_file_set_string(keyfile, network->identifier,
                                "WiFi.Security", network->wifi.security);