From: Patrik Flykt <[email protected]>

Define a save function for struct connman_provider_driver
specific settings that need to be saved. Call the provided
function when the provider struct is saved. The save
function is given a GKeyFile pointer in order to access
the proper save file.

No corresponding load function is defined since all saved
settings are already loaded by 'provider_load'.
---
 include/provider.h |    2 ++
 src/provider.c     |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/provider.h b/include/provider.h
index d0e8c35..af121d0 100644
--- a/include/provider.h
+++ b/include/provider.h
@@ -22,6 +22,7 @@
 #ifndef __CONNMAN_PROVIDER_H
 #define __CONNMAN_PROVIDER_H
 
+#include <glib.h>
 #include <connman/types.h>
 
 #ifdef __cplusplus
@@ -97,6 +98,7 @@ struct connman_provider_driver {
        int (*remove) (struct connman_provider *provider);
        int (*connect) (struct connman_provider *provider);
        int (*disconnect) (struct connman_provider *provider);
+       int (*save) (struct connman_provider *provider, GKeyFile *keyfile);
 };
 
 int connman_provider_driver_register(struct connman_provider_driver *driver);
diff --git a/src/provider.c b/src/provider.c
index a627fff..91b0b5a 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -1023,6 +1023,9 @@ static int provider_save(struct connman_provider 
*provider)
        g_key_file_set_string(keyfile, group, "Host", provider->host);
        g_key_file_set_string(keyfile, group, "VPN.Domain", provider->domain);
 
+       if (provider->driver != NULL && provider->driver->save != NULL)
+               provider->driver->save(provider, keyfile);
+
        data = g_key_file_to_data(keyfile, &length, NULL);
        if (g_file_set_contents(pathname, data, length, NULL) == FALSE)
                connman_error("Failed to store provider information");
-- 
1.7.2.5

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to