5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 static GSList *storage_list = NULL;
30 static gint compare_priority(gconstpointer a, gconstpointer b)
32 const struct connman_storage *storage1 = a;
33 const struct connman_storage *storage2 = b;
35 return storage2->priority - storage1->priority;
39 * connman_storage_register:
40 * @storage: storage module
42 * Register a new storage module
44 * Returns: %0 on success
46 int connman_storage_register(struct connman_storage *storage)
48 DBG("storage %p name %s", storage, storage->name);
50 storage_list = g_slist_insert_sorted(storage_list, storage,
57 * connman_storage_unregister:
58 * @storage: storage module
60 * Remove a previously registered storage module
62 void connman_storage_unregister(struct connman_storage *storage)
64 DBG("storage %p name %s", storage, storage->name);
66 storage_list = g_slist_remove(storage_list, storage);
69 int __connman_storage_load_global(void)
75 for (list = storage_list; list; list = list->next) {
76 struct connman_storage *storage = list->data;
78 if (storage->global_load) {
79 if (storage->global_load() == 0)
87 int __connman_storage_save_global(void)
93 for (list = storage_list; list; list = list->next) {
94 struct connman_storage *storage = list->data;
96 if (storage->global_save) {
97 if (storage->global_save() == 0)
105 int __connman_storage_init_device(void)
111 for (list = storage_list; list; list = list->next) {
112 struct connman_storage *storage = list->data;
114 if (storage->device_init) {
115 if (storage->device_init() == 0)
123 int __connman_storage_load_device(struct connman_device *device)
127 DBG("device %p", device);
129 for (list = storage_list; list; list = list->next) {
130 struct connman_storage *storage = list->data;
132 if (storage->device_load) {
133 if (storage->device_load(device) == 0)
141 int __connman_storage_save_device(struct connman_device *device)
145 DBG("device %p", device);
147 for (list = storage_list; list; list = list->next) {
148 struct connman_storage *storage = list->data;
150 if (storage->device_save) {
151 if (storage->device_save(device) == 0)
159 int __connman_storage_init_network(struct connman_device *device)
163 DBG("device %p", device);
165 for (list = storage_list; list; list = list->next) {
166 struct connman_storage *storage = list->data;
168 if (storage->network_init) {
169 if (storage->network_init(device) == 0)
177 int __connman_storage_load_network(struct connman_network *network)
181 DBG("network %p", network);
183 for (list = storage_list; list; list = list->next) {
184 struct connman_storage *storage = list->data;
186 if (storage->network_load) {
187 if (storage->network_load(network) == 0)
195 int __connman_storage_save_network(struct connman_network *network)
199 DBG("network %p", network);
201 for (list = storage_list; list; list = list->next) {
202 struct connman_storage *storage = list->data;
204 if (storage->network_save) {
205 if (storage->network_save(network) == 0)
213 int __connman_storage_init_service(void)
220 int __connman_storage_load_service(struct connman_service *service)
224 DBG("service %p", service);
226 for (list = storage_list; list; list = list->next) {
227 struct connman_storage *storage = list->data;
229 if (storage->service_load) {
230 if (storage->service_load(service) == 0)
238 int __connman_storage_save_service(struct connman_service *service)
242 DBG("service %p", service);
244 for (list = storage_list; list; list = list->next) {
245 struct connman_storage *storage = list->data;
247 if (storage->service_save) {
248 if (storage->service_save(service) == 0)
256 int __connman_storage_init(void)
263 void __connman_storage_cleanup(void)