diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-11-12 14:07:44 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-11-23 12:58:52 +0200 |
commit | 8730704d87dc27f8b9c0300f733d6ffdea8abf58 (patch) | |
tree | e7bac4fe001dcc270a2cc08ccfd820df6d660a84 /src | |
parent | 9c1129aa6a665f7663fcbf73b20994c8592e46d5 (diff) | |
download | connman-8730704d87dc27f8b9c0300f733d6ffdea8abf58.tar.gz connman-8730704d87dc27f8b9c0300f733d6ffdea8abf58.tar.bz2 connman-8730704d87dc27f8b9c0300f733d6ffdea8abf58.zip |
storage: Add function to remove provider files
Diffstat (limited to 'src')
-rw-r--r-- | src/connman.h | 1 | ||||
-rw-r--r-- | src/storage.c | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/connman.h b/src/connman.h index 90ffd352..67c16361 100644 --- a/src/connman.h +++ b/src/connman.h @@ -212,6 +212,7 @@ GKeyFile *__connman_storage_open_service(const char *ident); int __connman_storage_save_service(GKeyFile *keyfile, const char *ident); GKeyFile *__connman_storage_load_provider(const char *identifier); void __connman_storage_save_provider(GKeyFile *keyfile, const char *identifier); +gboolean __connman_storage_remove_provider(const char *identifier); char **__connman_storage_get_providers(void); gboolean __connman_storage_remove_service(const char *service_id); diff --git a/src/storage.c b/src/storage.c index 8c06ffe2..3c3ce41f 100644 --- a/src/storage.c +++ b/src/storage.c @@ -372,6 +372,46 @@ void __connman_storage_save_provider(GKeyFile *keyfile, const char *identifier) g_free(pathname); } +static gboolean remove_all(const char *id) +{ + gboolean removed; + + remove_file(id, SETTINGS); + remove_file(id, "data"); + + removed = remove_dir(id); + if (removed == FALSE) + return FALSE; + + return TRUE; +} + +gboolean __connman_storage_remove_provider(const char *identifier) +{ + gboolean removed; + gchar *id; + + id = g_strdup_printf("%s_%s", "provider", identifier); + if (id == NULL) + return FALSE; + + if (remove_all(id) == TRUE) + DBG("Removed provider dir %s/%s", STORAGEDIR, id); + + g_free(id); + + id = g_strdup_printf("%s_%s", "vpn", identifier); + if (id == NULL) + return FALSE; + + if ((removed = remove_all(id)) == TRUE) + DBG("Removed vpn dir %s/%s", STORAGEDIR, id); + + g_free(id); + + return removed; +} + gchar **__connman_storage_get_providers(void) { GSList *list = NULL; |