Remove obsolete file.
[connman] / src / storage.c
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
6  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include "connman.h"
27
28 static GSList *storage_list = NULL;
29
30 static gint compare_priority(gconstpointer a, gconstpointer b)
31 {
32         const struct connman_storage *storage1 = a;
33         const struct connman_storage *storage2 = b;
34
35         return storage2->priority - storage1->priority;
36 }
37
38 /**
39  * connman_storage_register:
40  * @storage: storage module
41  *
42  * Register a new storage module
43  *
44  * Returns: %0 on success
45  */
46 int connman_storage_register(struct connman_storage *storage)
47 {
48         DBG("storage %p name %s", storage, storage->name);
49
50         storage_list = g_slist_insert_sorted(storage_list, storage,
51                                                         compare_priority);
52
53         return 0;
54 }
55
56 /**
57  * connman_storage_unregister:
58  * @storage: storage module
59  *
60  * Remove a previously registered storage module
61  */
62 void connman_storage_unregister(struct connman_storage *storage)
63 {
64         DBG("storage %p name %s", storage, storage->name);
65
66         storage_list = g_slist_remove(storage_list, storage);
67 }
68
69 int __connman_storage_init_device(void)
70 {
71         GSList *list;
72
73         DBG("");
74
75         for (list = storage_list; list; list = list->next) {
76                 struct connman_storage *storage = list->data;
77
78                 if (storage->device_init) {
79                         if (storage->device_init() == 0)
80                                 return 0;
81                 }
82         }
83
84         return -ENOENT;
85 }
86
87 int __connman_storage_load_device(struct connman_device *device)
88 {
89         GSList *list;
90
91         DBG("device %p", device);
92
93         for (list = storage_list; list; list = list->next) {
94                 struct connman_storage *storage = list->data;
95
96                 if (storage->device_load) {
97                         if (storage->device_load(device) == 0)
98                                 return 0;
99                 }
100         }
101
102         return -ENOENT;
103 }
104
105 int __connman_storage_save_device(struct connman_device *device)
106 {
107         GSList *list;
108
109         DBG("device %p", device);
110
111         for (list = storage_list; list; list = list->next) {
112                 struct connman_storage *storage = list->data;
113
114                 if (storage->device_save) {
115                         if (storage->device_save(device) == 0)
116                                 return 0;
117                 }
118         }
119
120         return -ENOENT;
121 }
122
123 int __connman_storage_init_network(struct connman_device *device)
124 {
125         GSList *list;
126
127         DBG("device %p", device);
128
129         for (list = storage_list; list; list = list->next) {
130                 struct connman_storage *storage = list->data;
131
132                 if (storage->network_init) {
133                         if (storage->network_init(device) == 0)
134                                 return 0;
135                 }
136         }
137
138         return -ENOENT;
139 }
140
141 int __connman_storage_load_network(struct connman_network *network)
142 {
143         GSList *list;
144
145         DBG("network %p", network);
146
147         for (list = storage_list; list; list = list->next) {
148                 struct connman_storage *storage = list->data;
149
150                 if (storage->network_load) {
151                         if (storage->network_load(network) == 0)
152                                 return 0;
153                 }
154         }
155
156         return -ENOENT;
157 }
158
159 int __connman_storage_save_network(struct connman_network *network)
160 {
161         GSList *list;
162
163         DBG("network %p", network);
164
165         for (list = storage_list; list; list = list->next) {
166                 struct connman_storage *storage = list->data;
167
168                 if (storage->network_save) {
169                         if (storage->network_save(network) == 0)
170                                 return 0;
171                 }
172         }
173
174         return -ENOENT;
175 }
176
177 int __connman_storage_init_service(void)
178 {
179         DBG("");
180
181         return -ENOENT;
182 }
183
184 int __connman_storage_load_service(struct connman_service *service)
185 {
186         GSList *list;
187
188         DBG("service %p", service);
189
190         for (list = storage_list; list; list = list->next) {
191                 struct connman_storage *storage = list->data;
192
193                 if (storage->service_load) {
194                         if (storage->service_load(service) == 0)
195                                 return 0;
196                 }
197         }
198
199         return -ENOENT;
200 }
201
202 int __connman_storage_save_service(struct connman_service *service)
203 {
204         GSList *list;
205
206         DBG("service %p", service);
207
208         for (list = storage_list; list; list = list->next) {
209                 struct connman_storage *storage = list->data;
210
211                 if (storage->service_save) {
212                         if (storage->service_save(service) == 0)
213                                 return 0;
214                 }
215         }
216
217         return -ENOENT;
218 }
219
220 int __connman_storage_init(void)
221 {
222         DBG("");
223
224         return 0;
225 }
226
227 void __connman_storage_cleanup(void)
228 {
229         DBG("");
230 }