@@ -1483,8 +1483,28 @@ int pbap_init(void)
void pbap_exit(void)
{
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ char *uuid = PBAP_CLIENT_UUID;
+
DBG("");
+ client_path = g_strconcat("/org/bluez/obex/", uuid, NULL);
+ g_strdelimit(client_path, "-", '_');
+
+ msg = dbus_message_new_method_call("org.bluez", "/org/bluez",
+ "org.bluez.ProfileManager1",
+ "UnregisterProfile");
+
+ dbus_message_iter_init_append(msg, &iter);
+
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+ &client_path);
+
+ g_dbus_send_message(system_conn, msg);
+
+ unregister_profile();
+
dbus_connection_unref(conn);
conn = NULL;
pbap_exit() didn't previously unregister itself thoroughly. That was fine if it was only called when the service was about to exit, because everything was implicitly unregistered when the process ended. But we need to be more scrupulous if this can be called throughout the program's lifecycle. Send the UnregisterProfile message directly from pbap_exit(), then call unregister_profile(). The UnregisterProfile message can't be sent directly from unregister_profile(), because that also needs to be called when register_profile() fails halfway through. Signed-off-by: Andrew Sayers <kernel.org@pileofstuff.org> --- obexd/client/pbap.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)