From 465e5fa6e209e3f67182e5849abb7c6fd31a4e4f Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 9 Nov 2012 20:23:12 +0100 Subject: [PATCH] core: Move profile registration to Profile Manager interface --- src/bluetooth.conf | 2 +- src/manager.c | 8 ++------ src/profile.c | 35 ++++++++++++++++++++++++++++------- src/profile.h | 6 +----- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/bluetooth.conf b/src/bluetooth.conf index 2db43d937..bd48cf92a 100644 --- a/src/bluetooth.conf +++ b/src/bluetooth.conf @@ -17,7 +17,7 @@ - + diff --git a/src/manager.c b/src/manager.c index a96115be1..4ea7821e0 100644 --- a/src/manager.c +++ b/src/manager.c @@ -163,12 +163,6 @@ static const GDBusMethodTable manager_methods[] = { GDBUS_ARGS({ "pattern", "s" }), GDBUS_ARGS({ "adapter", "o" }), find_adapter) }, - { GDBUS_METHOD("RegisterProfile", - GDBUS_ARGS({ "profile", "o"}, { "UUID", "s" }, - { "options", "a{sv}" }), - NULL, btd_profile_reg_ext) }, - { GDBUS_METHOD("UnregisterProfile", GDBUS_ARGS({ "profile", "o" }), - NULL, btd_profile_unreg_ext) }, { } }; @@ -189,6 +183,8 @@ static const GDBusPropertyTable manager_properties[] = { dbus_bool_t manager_init(const char *path) { + btd_profile_init(); + snprintf(base_path, sizeof(base_path), "/org/bluez/%d", getpid()); return g_dbus_register_interface(btd_get_dbus_connection(), diff --git a/src/profile.c b/src/profile.c index bc76ccabe..7555c8c4d 100644 --- a/src/profile.c +++ b/src/profile.c @@ -168,7 +168,7 @@ static void ext_cancel(struct ext_profile *ext) DBusMessage *msg; msg = dbus_message_new_method_call(ext->owner, ext->path, - "org.bluez.Profile", "Cancel"); + "org.bluez.Profile1", "Cancel"); if (msg) g_dbus_send_message(btd_get_dbus_connection(), msg); } @@ -314,7 +314,7 @@ static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn, int fd; msg = dbus_message_new_method_call(ext->owner, ext->path, - "org.bluez.Profile", + "org.bluez.Profile1", "NewConnection"); if (!msg) { error("Unable to create NewConnection call for %s", ext->name); @@ -1085,8 +1085,8 @@ static void ext_exited(DBusConnection *conn, void *user_data) remove_ext(ext); } -DBusMessage *btd_profile_reg_ext(DBusConnection *conn, DBusMessage *msg, - void *user_data) +static DBusMessage *register_profile(DBusConnection *conn, + DBusMessage *msg, void *user_data) { const char *path, *sender, *uuid; DBusMessageIter args, opts; @@ -1120,8 +1120,8 @@ DBusMessage *btd_profile_reg_ext(DBusConnection *conn, DBusMessage *msg, return dbus_message_new_method_return(msg); } -DBusMessage *btd_profile_unreg_ext(DBusConnection *conn, DBusMessage *msg, - void *user_data) +static DBusMessage *unregister_profile(DBusConnection *conn, + DBusMessage *msg, void *user_data) { const char *path, *sender; struct ext_profile *ext; @@ -1142,6 +1142,16 @@ DBusMessage *btd_profile_unreg_ext(DBusConnection *conn, DBusMessage *msg, return dbus_message_new_method_return(msg); } +static const GDBusMethodTable methods[] = { + { GDBUS_METHOD("RegisterProfile", + GDBUS_ARGS({ "profile", "o"}, { "UUID", "s" }, + { "options", "a{sv}" }), + NULL, register_profile) }, + { GDBUS_METHOD("UnregisterProfile", GDBUS_ARGS({ "profile", "o" }), + NULL, unregister_profile) }, + { } +}; + void btd_profile_add_custom_prop(const char *uuid, const char *type, const char *name, btd_profile_prop_exists exists, @@ -1173,6 +1183,13 @@ static void free_property(gpointer data) g_free(p); } +void btd_profile_init(void) +{ + g_dbus_register_interface(btd_get_dbus_connection(), + "/org/bluez", "org.bluez.ProfileManager1", + methods, NULL, NULL, NULL, NULL); +} + void btd_profile_cleanup(void) { while (ext_profiles) { @@ -1186,7 +1203,7 @@ void btd_profile_cleanup(void) ext->conns = NULL; msg = dbus_message_new_method_call(ext->owner, ext->path, - "org.bluez.Profile", + "org.bluez.Profile1", "Release"); if (msg) g_dbus_send_message(conn, msg); @@ -1198,4 +1215,8 @@ void btd_profile_cleanup(void) g_slist_free_full(custom_props, free_property); custom_props = NULL; + + g_dbus_unregister_interface(btd_get_dbus_connection(), + "/org/bluez", "org.bluez.ProfileManager1"); + } diff --git a/src/profile.h b/src/profile.h index 7ece2bf5c..d7b1ba14a 100644 --- a/src/profile.h +++ b/src/profile.h @@ -74,9 +74,5 @@ void btd_profile_add_custom_prop(const char *uuid, const char *type, btd_profile_prop_get get, void *user_data); +void btd_profile_init(void); void btd_profile_cleanup(void); - -DBusMessage *btd_profile_reg_ext(DBusConnection *conn, DBusMessage *msg, - void *user_data); -DBusMessage *btd_profile_unreg_ext(DBusConnection *conn, DBusMessage *msg, - void *user_data); -- 2.47.3