diff options
-rw-r--r-- | include/storage.h | 2 | ||||
-rw-r--r-- | src/connman.h | 3 | ||||
-rw-r--r-- | src/element.c | 4 | ||||
-rw-r--r-- | src/storage.c | 36 |
4 files changed, 45 insertions, 0 deletions
diff --git a/include/storage.h b/include/storage.h index bb3b3746..d0e48b1f 100644 --- a/include/storage.h +++ b/include/storage.h @@ -43,6 +43,8 @@ extern "C" { struct connman_storage { const char *name; int priority; + int (*global_load) (void); + int (*global_save) (void); enum connman_device_type device_type; int (*device_init) (void); int (*device_load) (struct connman_device *device); diff --git a/src/connman.h b/src/connman.h index aa4c2ee4..63e8a68a 100644 --- a/src/connman.h +++ b/src/connman.h @@ -124,6 +124,9 @@ int __connman_resolver_selftest(void); int __connman_storage_init(void); void __connman_storage_cleanup(void); +int __connman_storage_load_global(); +int __connman_storage_save_global(); + int __connman_storage_init_device(); int __connman_storage_load_device(struct connman_device *device); int __connman_storage_save_device(struct connman_device *device); diff --git a/src/element.c b/src/element.c index c6b97d97..b4ce9b26 100644 --- a/src/element.c +++ b/src/element.c @@ -1607,6 +1607,8 @@ void __connman_element_start(void) started = TRUE; + __connman_storage_load_global(); + __connman_storage_init_device(); __connman_connection_init(); @@ -1621,6 +1623,8 @@ void __connman_element_stop(void) __connman_rfkill_cleanup(); __connman_ipv4_cleanup(); __connman_connection_cleanup(); + + __connman_storage_save_global(); } static gboolean free_driver(GNode *node, gpointer data) diff --git a/src/storage.c b/src/storage.c index 08b7249c..2018cf25 100644 --- a/src/storage.c +++ b/src/storage.c @@ -66,6 +66,42 @@ void connman_storage_unregister(struct connman_storage *storage) storage_list = g_slist_remove(storage_list, storage); } +int __connman_storage_load_global(void) +{ + GSList *list; + + DBG(""); + + for (list = storage_list; list; list = list->next) { + struct connman_storage *storage = list->data; + + if (storage->global_load) { + if (storage->global_load() == 0) + return 0; + } + } + + return -ENOENT; +} + +int __connman_storage_save_global(void) +{ + GSList *list; + + DBG(""); + + for (list = storage_list; list; list = list->next) { + struct connman_storage *storage = list->data; + + if (storage->global_save) { + if (storage->global_save() == 0) + return 0; + } + } + + return -ENOENT; +} + int __connman_storage_init_device(void) { GSList *list; |