summaryrefslogtreecommitdiff
path: root/lib/bluetooth-agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bluetooth-agent.c')
-rw-r--r--lib/bluetooth-agent.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index b005b9ba..d12aa96b 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -513,42 +513,29 @@ gboolean bluetooth_agent_register(BluetoothAgent *agent)
return TRUE;
}
-static gboolean
-error_matches_remote_error (GError *error,
- const char *remote_error)
+static void
+agent_unregister_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- g_autofree char *str = NULL;
- gboolean ret;
-
- if (error == NULL)
- return FALSE;
-
- str = g_dbus_error_get_remote_error (error);
- ret = (g_strcmp0 (str, remote_error) == 0);
+ g_autoptr(GError) error = NULL;
- return ret;
+ if (!agent_manager1_call_unregister_agent_finish (AGENT_MANAGER1 (object), res, &error))
+ g_debug ("Failed to unregister agent: %s", error->message);
+ else
+ g_debug ("Unregistered agent successfully");
}
gboolean bluetooth_agent_unregister(BluetoothAgent *agent)
{
- g_autoptr(GError) error = NULL;
-
g_return_val_if_fail (BLUETOOTH_IS_AGENT (agent), FALSE);
if (agent->agent_manager == NULL)
return FALSE;
- if (agent_manager1_call_unregister_agent_sync (agent->agent_manager,
- agent->path,
- NULL, &error) == FALSE) {
- /* Ignore errors if the adapter is gone */
- if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD) == FALSE &&
- error_matches_remote_error (error, "org.bluez.Error.DoesNotExist") == FALSE) {
- g_printerr ("Agent unregistration failed: %s '%s'\n",
- error->message,
- g_quark_to_string (error->domain));
- }
- }
+ agent_manager1_call_unregister_agent (agent->agent_manager,
+ agent->path,
+ NULL, agent_unregister_cb, NULL);
g_clear_object (&agent->agent_manager);
g_clear_pointer (&agent->path, g_free);