diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-04-14 14:41:42 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-04-14 14:41:42 +0000 |
commit | f390a1c27da2b89f521960dfe9945bcc9039caa6 (patch) | |
tree | a9113449dc5a4fcb86d9c352d81757fa46d5abe2 /audio | |
parent | 80d5fbd121aebd4643afa7715d5d2e9b52b12bca (diff) |
Use internal call when possible to authorize incoming connections.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/manager.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/audio/manager.c b/audio/manager.c index 7da74be6..869557ca 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -63,6 +63,7 @@ #include "control.h" #include "manager.h" #include "sdpd.h" +#include "plugin.h" typedef enum { HEADSET = 1 << 0, @@ -1286,11 +1287,9 @@ static sdp_record_t *hfp_ag_record(uint8_t ch, uint32_t feat) return record; } -static void auth_cb(DBusPendingCall *call, void *data) +static void auth_cb(DBusError *derr, void *user_data) { - struct device *device = data; - DBusMessage *reply = dbus_pending_call_steal_reply(call); - DBusError err; + struct device *device = user_data; const char *uuid; if (get_hfp_active(device)) @@ -1298,14 +1297,14 @@ static void auth_cb(DBusPendingCall *call, void *data) else uuid = HSP_AG_UUID; - dbus_error_init(&err); - if (dbus_set_error_from_message(&err, reply)) { - error("Access denied: %s", err.message); - if (dbus_error_has_name(&err, DBUS_ERROR_NO_REPLY)) { + if (derr && dbus_error_is_set(derr)) { + error("Access denied: %s", derr->message); + if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) { debug("Canceling authorization request"); - manager_cancel_authorize(&device->dst, uuid, NULL); + if (plugin_cancel_auth(&device->dst) < 0) + manager_cancel_authorize(&device->dst, uuid, + NULL); } - dbus_error_free(&err); headset_set_state(device, HEADSET_STATE_DISCONNECTED); } else { @@ -1318,6 +1317,17 @@ static void auth_cb(DBusPendingCall *call, void *data) debug("Accepted headset connection from %s for %s", hs_address, device->path); } +} + +static void auth_cb_old(DBusPendingCall *call, void *data) +{ + DBusMessage *reply = dbus_pending_call_steal_reply(call); + DBusError err; + + dbus_error_init(&err); + dbus_set_error_from_message(&err, reply); + auth_cb(&err, data); + dbus_error_free(&err); dbus_message_unref(reply); } @@ -1378,9 +1388,14 @@ static gboolean ag_io_cb(GIOChannel *chan, GIOCondition cond, void *data) return TRUE; } - if (!manager_authorize(&device->dst, uuid, auth_cb, device, NULL)) + if (plugin_req_auth(&device->src, &device->dst, uuid, auth_cb, + device) == 0) + goto proceed; + else if (!manager_authorize(&device->dst, uuid, auth_cb_old, device, + NULL)) goto failed; +proceed: headset_set_state(device, HEADSET_STATE_CONNECT_IN_PROGRESS); return TRUE; |