summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-02-22 20:12:27 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-02-22 20:12:27 +0000
commit86fa3713b108d19fcf8add8ce109de337ede94c7 (patch)
treeeb8cc7379155e4e22d4abf4e6afeb51c73e6c3a7 /input
parentc90bdcc8c0c7659b2bb31bbbe5eb7e16fd7e9b5a (diff)
Fake input: added code to request the headset service record
Diffstat (limited to 'input')
-rw-r--r--input/device.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/input/device.c b/input/device.c
index a1d4e1f5..fd448768 100644
--- a/input/device.c
+++ b/input/device.c
@@ -1182,22 +1182,77 @@ done:
dbus_pending_call_unref(call);
}
+static void headset_record_reply(DBusPendingCall *call, void *data)
+{
+ DBusMessage *reply = dbus_pending_call_steal_reply(call);
+ DBusMessage *pr_reply;
+ struct pending_req *pr = data;
+ DBusError derr;
+ const char *path = "/org/bluez/input/headset0";
+
+ dbus_error_init(&derr);
+ if (dbus_set_error_from_message(&derr, reply)) {
+ err_generic(pr->conn, pr->msg, derr.name, derr.message);
+ error("%s: %s", derr.name, derr.message);
+ dbus_error_free(&derr);
+ goto fail;
+ }
+
+ /* FIXME: extract the record */
+ /* FIXME: Register the fake input path */
+
+ pr_reply = dbus_message_new_method_return(pr->msg);
+ dbus_message_append_args(pr_reply,
+ DBUS_TYPE_STRING, &path,
+ DBUS_TYPE_INVALID);
+ send_message_and_unref(pr->conn, pr_reply);
+fail:
+ pending_req_free(pr);
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(call);
+}
+
static void headset_handle_reply(DBusPendingCall *call, void *data)
{
DBusMessage *reply = dbus_pending_call_steal_reply(call);
struct pending_req *pr = data;
DBusError derr;
+ uint32_t *phandle;
+ int len;
dbus_error_init(&derr);
if (dbus_set_error_from_message(&derr, reply)) {
+ err_generic(pr->conn, pr->msg, derr.name, derr.message);
error("%s: %s", derr.name, derr.message);
+ goto fail;
+ }
+
+ if (!dbus_message_get_args(reply, &derr,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &phandle, &len,
+ DBUS_TYPE_INVALID)) {
err_not_supported(pr->conn, pr->msg);
- dbus_error_free(&derr);
+ error("%s: %s", derr.name, derr.message);
+ goto fail;
}
- /*FIXME: Parse the content */
+ if (len == 0) {
+ err_not_supported(pr->conn, pr->msg);
+ error("headset record handle not found");
+ goto fail;
+ }
+ if (get_record(pr, *phandle, headset_record_reply) < 0) {
+ err_not_supported(pr->conn, pr->msg);
+ error("headset service attribute request failed");
+ goto fail;
+ }
+
+ /* Wait record reply */
+ goto done;
+fail:
+ dbus_error_free(&derr);
pending_req_free(pr);
+done:
dbus_message_unref(reply);
dbus_pending_call_unref(call);
}