diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-04-23 16:29:24 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-04-23 16:29:24 +0100 |
commit | 56060fa05d883c16e4235b3f0cf1441d0a0b58a3 (patch) | |
tree | c5f2b45fe7e703e68c04eb9d913d8a774ab48d81 | |
parent | 6d6df9a7a4c1dfb794830c08629a9f89a1dea68c (diff) | |
download | connman-56060fa05d883c16e4235b3f0cf1441d0a0b58a3.tar.gz connman-56060fa05d883c16e4235b3f0cf1441d0a0b58a3.tar.bz2 connman-56060fa05d883c16e4235b3f0cf1441d0a0b58a3.zip |
Add callbacks for service storage functions
-rw-r--r-- | include/storage.h | 4 | ||||
-rw-r--r-- | src/connman.h | 5 | ||||
-rw-r--r-- | src/service.c | 26 | ||||
-rw-r--r-- | src/storage.c | 43 |
4 files changed, 77 insertions, 1 deletions
diff --git a/include/storage.h b/include/storage.h index cd31b691..61cbf9a4 100644 --- a/include/storage.h +++ b/include/storage.h @@ -24,6 +24,7 @@ #include <connman/device.h> #include <connman/network.h> +#include <connman/service.h> #ifdef __cplusplus extern "C" { @@ -50,6 +51,9 @@ struct connman_storage { int (*network_init) (struct connman_device *device); int (*network_load) (struct connman_network *network); int (*network_save) (struct connman_network *network); + enum connman_service_type service_type; + int (*service_load) (struct connman_service *service); + int (*service_save) (struct connman_service *service); }; extern int connman_storage_register(struct connman_storage *storage); diff --git a/src/connman.h b/src/connman.h index b941185c..43392513 100644 --- a/src/connman.h +++ b/src/connman.h @@ -98,9 +98,12 @@ void __connman_storage_cleanup(void); int __connman_storage_init_device(); int __connman_storage_load_device(struct connman_device *device); int __connman_storage_save_device(struct connman_device *device); -int __connman_storage_init_network(); +int __connman_storage_init_network(struct connman_device *device); int __connman_storage_load_network(struct connman_network *network); int __connman_storage_save_network(struct connman_network *network); +int __connman_storage_init_service(); +int __connman_storage_load_service(struct connman_service *service); +int __connman_storage_save_service(struct connman_service *service); #include <connman/driver.h> diff --git a/src/service.c b/src/service.c index 77618146..2b607833 100644 --- a/src/service.c +++ b/src/service.c @@ -978,12 +978,36 @@ done: return service; } +static int service_load(struct connman_service *service) +{ + DBG("service %p", service); + + return 0; +} + +static int service_save(struct connman_service *service) +{ + DBG("service %p", service); + + return 0; +} + +static struct connman_storage service_storage = { + .name = "service", + .priority = CONNMAN_STORAGE_PRIORITY_LOW, + .service_load = service_load, + .service_save = service_save, +}; + int __connman_service_init(void) { DBG(""); connection = connman_dbus_get_connection(); + if (connman_storage_register(&service_storage) < 0) + connman_error("Failed to register service storage"); + service_hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); @@ -1002,5 +1026,7 @@ void __connman_service_cleanup(void) g_hash_table_destroy(service_hash); service_hash = NULL; + connman_storage_unregister(&service_storage); + dbus_connection_unref(connection); } diff --git a/src/storage.c b/src/storage.c index b63c43b5..08b7249c 100644 --- a/src/storage.c +++ b/src/storage.c @@ -174,6 +174,49 @@ int __connman_storage_save_network(struct connman_network *network) return -ENOENT; } +int __connman_storage_init_service(void) +{ + DBG(""); + + return -ENOENT; +} + +int __connman_storage_load_service(struct connman_service *service) +{ + GSList *list; + + DBG("service %p", service); + + for (list = storage_list; list; list = list->next) { + struct connman_storage *storage = list->data; + + if (storage->service_load) { + if (storage->service_load(service) == 0) + return 0; + } + } + + return -ENOENT; +} + +int __connman_storage_save_service(struct connman_service *service) +{ + GSList *list; + + DBG("service %p", service); + + for (list = storage_list; list; list = list->next) { + struct connman_storage *storage = list->data; + + if (storage->service_save) { + if (storage->service_save(service) == 0) + return 0; + } + } + + return -ENOENT; +} + int __connman_storage_init(void) { DBG(""); |