connman_bool_t registered;
+ char *last_network;
struct connman_network *network;
GHashTable *networks;
};
g_free(device->name);
g_free(device->interface);
+ g_free(device->last_network);
+
g_hash_table_destroy(device->networks);
device->networks = NULL;
}
while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
connman_uint8_t old_priority, new_priority;
connman_uint8_t old_strength, new_strength;
+ const char *name;
count++;
+ name = connman_network_get_string(value, "Name");
+ if (name != NULL && device->last_network != NULL) {
+ if (g_str_equal(name, device->last_network) == TRUE) {
+ network = value;
+ break;
+ }
+ }
+
if (connman_network_get_remember(value) == FALSE)
continue;
void __connman_device_set_network(struct connman_device *device,
struct connman_network *network)
{
+ const char *name;
+
+ if (network != NULL) {
+ name = connman_network_get_string(network, "Name");
+ device->last_network = g_strdup(name);
+ }
+
device->network = network;
}
if (val > 0)
device->priority = val;
+ str = g_key_file_get_string(keyfile, "Configuration",
+ "LastNetwork", NULL);
+ if (str != NULL)
+ device->last_network = str;
+
g_key_file_free(keyfile);
return 0;
g_key_file_set_integer(keyfile, "Configuration",
"Priority", device->priority);
+ if (device->last_network != NULL)
+ g_key_file_set_string(keyfile, "Configuration",
+ "LastNetwork", device->last_network);
+
data = g_key_file_to_data(keyfile, &length, NULL);
g_file_set_contents(pathname, data, length, NULL);
g_free(pathname);
+ if (device->network != NULL)
+ __connman_storage_save_network(device->network);
+
return 0;
}
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);
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);