From: Marcel Holtmann Date: Fri, 4 Apr 2008 04:14:31 +0000 (+0200) Subject: On successful connect store the network identifier X-Git-Tag: 2.0_alpha~4864 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5cc1f98aff5fa7f36ab38d0536ba32ab706ffe8d;p=framework%2Fconnectivity%2Fconnman.git On successful connect store the network identifier --- diff --git a/src/connman.h b/src/connman.h index e8ca3e7..4232616 100644 --- a/src/connman.h +++ b/src/connman.h @@ -79,6 +79,7 @@ char *__connman_iface_find_passphrase(struct connman_iface *iface, const char *network); int __connman_iface_load(struct connman_iface *iface); int __connman_iface_store(struct connman_iface *iface); +int __connman_iface_store_current_network(struct connman_iface *iface); const char *__connman_iface_type2string(enum connman_iface_type type); const char *__connman_iface_state2string(enum connman_iface_state state); diff --git a/src/iface-storage.c b/src/iface-storage.c index 8d2895f..d73ef6a 100644 --- a/src/iface-storage.c +++ b/src/iface-storage.c @@ -211,3 +211,50 @@ done: return 0; } + +int __connman_iface_store_current_network(struct connman_iface *iface) +{ + GKeyFile *keyfile; + gchar *pathname, *data = NULL; + gsize length; + + DBG("iface %p", iface); + + if (iface->identifier == NULL) + return -EIO; + + pathname = g_strdup_printf("%s/%s.conf", STORAGEDIR, + iface->identifier); + if (pathname == NULL) + return -ENOMEM; + + keyfile = g_key_file_new(); + + if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE) + goto update; + + if (length > 0) { + if (g_key_file_load_from_data(keyfile, data, length, + G_KEY_FILE_KEEP_COMMENTS, NULL) == FALSE) + goto done; + } + + g_free(data); + +update: + g_key_file_set_string(keyfile, GROUP_CONFIG, + "LastNetwork", iface->network.identifier); + + data = g_key_file_to_data(keyfile, &length, NULL); + + g_file_set_contents(pathname, data, length, NULL); + +done: + g_free(data); + + g_key_file_free(keyfile); + + g_free(pathname); + + return 0; +} diff --git a/src/iface.c b/src/iface.c index f5753d8..a1e136d 100644 --- a/src/iface.c +++ b/src/iface.c @@ -306,6 +306,7 @@ void connman_iface_indicate_configured(struct connman_iface *iface) case CONNMAN_IFACE_STATE_CONFIGURE: iface->state = CONNMAN_IFACE_STATE_READY; state_changed(iface); + __connman_iface_store_current_network(iface); break; default: break;