summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-01-07 20:24:16 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-01-07 20:24:16 +0100
commitb1d822465166dba78f8ad54837f106c3ec513631 (patch)
treeba492f89aeeb870359eb82c08b3bae3fb19be8af
parentcecbeca745ed26cd6742dc897135c28778008ef6 (diff)
downloadconnman-b1d822465166dba78f8ad54837f106c3ec513631.tar.gz
connman-b1d822465166dba78f8ad54837f106c3ec513631.tar.bz2
connman-b1d822465166dba78f8ad54837f106c3ec513631.zip
Add support for storage setup callbacks
-rw-r--r--include/storage.h2
-rw-r--r--src/connman.h2
-rw-r--r--src/device.c10
-rw-r--r--src/element.c2
-rw-r--r--src/network.c8
-rw-r--r--src/storage.c36
6 files changed, 60 insertions, 0 deletions
diff --git a/include/storage.h b/include/storage.h
index 9182675a..cd31b691 100644
--- a/include/storage.h
+++ b/include/storage.h
@@ -43,9 +43,11 @@ struct connman_storage {
const char *name;
int priority;
enum connman_device_type device_type;
+ int (*device_init) (void);
int (*device_load) (struct connman_device *device);
int (*device_save) (struct connman_device *device);
enum connman_network_type network_type;
+ int (*network_init) (struct connman_device *device);
int (*network_load) (struct connman_network *network);
int (*network_save) (struct connman_network *network);
};
diff --git a/src/connman.h b/src/connman.h
index f98fc790..cca7ea8a 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -87,8 +87,10 @@ int __connman_resolver_selftest(void);
int __connman_storage_init(void);
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_load_network(struct connman_network *network);
int __connman_storage_save_network(struct connman_network *network);
diff --git a/src/device.c b/src/device.c
index 4575dd22..2a65e69a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1250,6 +1250,16 @@ int connman_device_register(struct connman_device *device)
{
__connman_storage_load_device(device);
+ switch (device->mode) {
+ case CONNMAN_DEVICE_MODE_UNKNOWN:
+ case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
+ break;
+ case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
+ case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
+ __connman_storage_init_network(device);
+ break;
+ }
+
return connman_element_register(&device->element, NULL);
}
diff --git a/src/element.c b/src/element.c
index 57c25665..fb11f79c 100644
--- a/src/element.c
+++ b/src/element.c
@@ -1455,6 +1455,8 @@ void __connman_element_start(void)
started = TRUE;
+ __connman_storage_init_device();
+
__connman_connection_init();
__connman_ipv4_init();
__connman_detect_init();
diff --git a/src/network.c b/src/network.c
index 2c6d6b88..7b3d49b1 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1008,6 +1008,13 @@ static struct connman_driver network_driver = {
.remove = network_remove,
};
+static int network_init(struct connman_device *device)
+{
+ DBG("device %p", device);
+
+ return 0;
+}
+
static int network_load(struct connman_network *network)
{
GKeyFile *keyfile;
@@ -1131,6 +1138,7 @@ done:
static struct connman_storage network_storage = {
.name = "network",
.priority = CONNMAN_STORAGE_PRIORITY_LOW,
+ .network_init = network_init,
.network_load = network_load,
.network_save = network_save,
};
diff --git a/src/storage.c b/src/storage.c
index d881a5cc..b63c43b5 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -66,6 +66,24 @@ void connman_storage_unregister(struct connman_storage *storage)
storage_list = g_slist_remove(storage_list, storage);
}
+int __connman_storage_init_device(void)
+{
+ GSList *list;
+
+ DBG("");
+
+ for (list = storage_list; list; list = list->next) {
+ struct connman_storage *storage = list->data;
+
+ if (storage->device_init) {
+ if (storage->device_init() == 0)
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+
int __connman_storage_load_device(struct connman_device *device)
{
GSList *list;
@@ -102,6 +120,24 @@ int __connman_storage_save_device(struct connman_device *device)
return -ENOENT;
}
+int __connman_storage_init_network(struct connman_device *device)
+{
+ GSList *list;
+
+ DBG("device %p", device);
+
+ for (list = storage_list; list; list = list->next) {
+ struct connman_storage *storage = list->data;
+
+ if (storage->network_init) {
+ if (storage->network_init(device) == 0)
+ return 0;
+ }
+ }
+
+ return -ENOENT;
+}
+
int __connman_storage_load_network(struct connman_network *network)
{
GSList *list;