From 7605e6c8092c8826bb04e170665c44ba8319562c Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 12 Aug 2011 11:45:07 +0300 Subject: [PATCH] obexd: add target module vtable New targets/profiles can be introduced by just adding an entry to the table and register their drivers similarly to a plugin. --- obexd/client/manager.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/obexd/client/manager.c b/obexd/client/manager.c index e7eb70d33..b13dd78e4 100644 --- a/obexd/client/manager.c +++ b/obexd/client/manager.c @@ -554,9 +554,18 @@ static GDBusMethodTable client_methods[] = { static DBusConnection *conn = NULL; +static struct target_module { + const char *name; + int (*init) (void); + void (*exit) (void); +} targets[] = { + { } +}; + int manager_init(void) { DBusError derr; + struct target_module *target; dbus_error_init(&derr); @@ -576,14 +585,26 @@ int manager_init(void) return -1; } + for (target = targets; target && target->init; target++) { + if (target->init() < 0) + continue; + + DBG("Target %s loaded", target->name); + } + return 0; } void manager_exit(void) { + struct target_module *target; + if (conn == NULL) return; + for (target = targets; target && target->exit; target++) + target->exit(); + g_dbus_unregister_interface(conn, CLIENT_PATH, CLIENT_INTERFACE); dbus_connection_unref(conn); } -- 2.47.3