diff options
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/manager.c | 19 | ||||
-rw-r--r-- | daemon/service.c | 57 | ||||
-rw-r--r-- | daemon/service.h | 4 |
3 files changed, 65 insertions, 15 deletions
diff --git a/daemon/manager.c b/daemon/manager.c index 29a4947e..c919dc28 100644 --- a/daemon/manager.c +++ b/daemon/manager.c @@ -31,6 +31,7 @@ #include "logging.h" #include "system.h" +#include "service.h" #include "manager.h" #define MANAGER_INTERFACE "org.bluez.Manager" @@ -95,20 +96,12 @@ static DBusHandlerResult default_adapter(DBusConnection *conn, static DBusHandlerResult list_services(DBusConnection *conn, DBusMessage *msg, void *data) { - DBusMessageIter iter, array; DBusMessage *reply; - reply = dbus_message_new_method_return(msg); + reply = service_list(msg); if (!reply) return DBUS_HANDLER_RESULT_NEED_MEMORY; - dbus_message_iter_init_append(reply, &iter); - - dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, - DBUS_TYPE_STRING_AS_STRING, &array); - - dbus_message_iter_close_container(&iter, &array); - return dbus_connection_send_and_unref(conn, reply); } @@ -117,12 +110,10 @@ static DBusHandlerResult find_service(DBusConnection *conn, { DBusMessage *reply; - reply = dbus_message_new_method_return(msg); + reply = service_find(msg); if (!reply) return DBUS_HANDLER_RESULT_NEED_MEMORY; - dbus_message_append_args(reply, DBUS_TYPE_INVALID); - return dbus_connection_send_and_unref(conn, reply); } @@ -131,12 +122,10 @@ static DBusHandlerResult activate_service(DBusConnection *conn, { DBusMessage *reply; - reply = dbus_message_new_method_return(msg); + reply = service_activate(msg); if (!reply) return DBUS_HANDLER_RESULT_NEED_MEMORY; - dbus_message_append_args(reply, DBUS_TYPE_INVALID); - return dbus_connection_send_and_unref(conn, reply); } diff --git a/daemon/service.c b/daemon/service.c index 95b5e1ed..f3f43a0d 100644 --- a/daemon/service.c +++ b/daemon/service.c @@ -38,6 +38,63 @@ static DBusConnection *connection = NULL; +DBusMessage *service_list(DBusMessage *msg) +{ + DBusMessage *reply; + DBusMessageIter iter, array; + + reply = dbus_message_new_method_return(msg); + if (!reply) + return NULL; + + dbus_message_iter_init_append(reply, &iter); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &array); + + dbus_message_iter_close_container(&iter, &array); + + return reply; +} + +DBusMessage *service_find(DBusMessage *msg) +{ + DBusMessage *reply; + const char *pattern; + + dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &pattern, DBUS_TYPE_INVALID); + + debug("Searching service with pattern \"%s\"", pattern); + + reply = dbus_message_new_method_return(msg); + if (!reply) + return NULL; + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + return 0; +} + +DBusMessage *service_activate(DBusMessage *msg) +{ + DBusMessage *reply; + const char *pattern; + + dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &pattern, DBUS_TYPE_INVALID); + + debug("Activating service with pattern \"%s\"", pattern); + + reply = dbus_message_new_method_return(msg); + if (!reply) + return NULL; + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + return 0; +} + static void config_notify(int action, const char *name, void *data) { switch (action) { diff --git a/daemon/service.h b/daemon/service.h index 65e5ab84..396a6841 100644 --- a/daemon/service.h +++ b/daemon/service.h @@ -23,3 +23,7 @@ int service_init(DBusConnection *conn); void service_exit(void); + +DBusMessage *service_list(DBusMessage *msg); +DBusMessage *service_find(DBusMessage *msg); +DBusMessage *service_activate(DBusMessage *msg); |