storage: Add function to remove provider files
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Mon, 12 Nov 2012 12:07:44 +0000 (14:07 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 23 Nov 2012 10:58:52 +0000 (12:58 +0200)
src/connman.h
src/storage.c

index 90ffd35..67c1636 100644 (file)
@@ -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);
 
index 8c06ffe..3c3ce41 100644 (file)
@@ -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;