From 29b7375f5e6f63202b6186bd0e34e0ca925a4910 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 25 Sep 2012 14:39:28 +0300 Subject: [PATCH] core: Add cleanup function for external profiles --- src/manager.c | 2 ++ src/profile.c | 20 ++++++++++++++++++++ src/profile.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/src/manager.c b/src/manager.c index 90e6e6bd7..f1f0f4d06 100644 --- a/src/manager.c +++ b/src/manager.c @@ -291,6 +291,8 @@ void manager_cleanup(const char *path) btd_adapter_unref(adapter); } + btd_profile_cleanup(); + btd_start_exit_timer(); g_dbus_unregister_interface(btd_get_dbus_connection(), diff --git a/src/profile.c b/src/profile.c index aa76a912b..fa1b0a0c1 100644 --- a/src/profile.c +++ b/src/profile.c @@ -27,12 +27,16 @@ #include #include +#include #include #include +#include #include "uuid.h" +#include "log.h" #include "error.h" +#include "dbus-common.h" #include "adapter.h" #include "device.h" #include "profile.h" @@ -186,3 +190,19 @@ DBusMessage *btd_profile_unreg_ext(DBusConnection *conn, DBusMessage *msg, return dbus_message_new_method_return(msg); } + +void btd_profile_cleanup(void) +{ + while (ext_profiles) { + struct ext_profile *ext = ext_profiles->data; + DBusMessage *msg; + + msg = dbus_message_new_method_call(ext->owner, ext->path, + "org.bluez.Profile", + "Release"); + if (msg) + g_dbus_send_message(btd_get_dbus_connection(), msg); + + remove_ext(ext); + } +} diff --git a/src/profile.h b/src/profile.h index 12d2b3ea4..1702901a6 100644 --- a/src/profile.h +++ b/src/profile.h @@ -57,6 +57,8 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data), int btd_profile_register(struct btd_profile *profile); void btd_profile_unregister(struct btd_profile *profile); +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, -- 2.47.3