summaryrefslogtreecommitdiff
path: root/src/server.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2011-11-02 15:09:52 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2011-11-03 10:29:48 +0200
commit96d4961ee7dcaae768c4156ecd38f5e68d6923c7 (patch)
tree982cf773c1ba76c8cf14c025a41a7c62b0865a84 /src/server.c
parentc28595bcea05b0aec3b5e62580dea3be5c52a562 (diff)
downloadobexd-96d4961ee7dcaae768c4156ecd38f5e68d6923c7.tar.gz
Make obex_server_init to initialized all services registered
This way we don't have to keep adding new entries to main.c everytime a new service is introduced.
Diffstat (limited to 'src/server.c')
-rw-r--r--src/server.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/server.c b/src/server.c
index bf234ea..f91a622 100644
--- a/src/server.c
+++ b/src/server.c
@@ -47,24 +47,10 @@
static GSList *servers = NULL;
-int obex_server_init(uint16_t service)
+static void init_server(uint16_t service, GSList *transports)
{
- GSList *drivers;
- GSList *transports;
GSList *l;
- drivers = obex_service_driver_list(service);
- if (drivers == NULL) {
- DBG("No service driver registered");
- return -EINVAL;
- }
-
- transports = obex_transport_driver_list();
- if (transports == NULL) {
- DBG("No transport driver registered");
- return -EINVAL;
- }
-
for (l = transports; l; l = l->next) {
struct obex_transport_driver *transport = l->data;
struct obex_server *server;
@@ -76,7 +62,7 @@ int obex_server_init(uint16_t service)
server = g_new0(struct obex_server, 1);
server->transport = transport;
- server->drivers = drivers;
+ server->drivers = obex_service_driver_list(service);
server->transport_data = transport->start(server, &err);
if (server->transport_data == NULL) {
@@ -88,6 +74,31 @@ int obex_server_init(uint16_t service)
servers = g_slist_prepend(servers, server);
}
+}
+
+int obex_server_init(void)
+{
+ GSList *drivers;
+ GSList *transports;
+ GSList *l;
+
+ drivers = obex_service_driver_list(0);
+ if (drivers == NULL) {
+ DBG("No service driver registered");
+ return -EINVAL;
+ }
+
+ transports = obex_transport_driver_list();
+ if (transports == NULL) {
+ DBG("No transport driver registered");
+ return -EINVAL;
+ }
+
+ for (l = drivers; l; l = l->next) {
+ struct obex_service_driver *driver = l->data;
+
+ init_server(driver->service, transports);
+ }
return 0;
}