summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-01-23 16:45:29 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-01-23 16:45:29 +0000
commit86ac7d918622db3423e4acfaa71a65f2f1a86da6 (patch)
tree12666c176056789139f71a47eab4b4db26e0c335 /input
parent4ddff0e350fe0139b7c9fe306fedbe81061d65e2 (diff)
Added L2CAP HID control channel connect callback
Diffstat (limited to 'input')
-rw-r--r--input/input-service.c67
1 files changed, 60 insertions, 7 deletions
diff --git a/input/input-service.c b/input/input-service.c
index 06dcad77..cc6a05c5 100644
--- a/input/input-service.c
+++ b/input/input-service.c
@@ -420,13 +420,6 @@ static const char *create_input_path(uint8_t minor)
return path;
}
-static gboolean control_connect_cb(GIOChannel *chan, GIOCondition cond,
- struct pending_connect *pc)
-{
- info("FIXME: Control connect callback");
- return FALSE;
-}
-
/* FIXME: Move to a common file. It is already used by audio and rfcomm */
static int set_nonblocking(int fd)
{
@@ -509,6 +502,66 @@ failed:
return -1;
}
+static gboolean interrupt_connect_cb(GIOChannel *chan, GIOCondition cond,
+ struct pending_connect *pc)
+{
+ info("FIXME: interrupt connect callback");
+ return FALSE;
+}
+
+static gboolean control_connect_cb(GIOChannel *chan, GIOCondition cond,
+ struct pending_connect *pc)
+{
+ struct input_device *idev;
+ int csk, ret, err = EHOSTDOWN;
+ socklen_t len;
+ const char *path;
+
+ if (cond & G_IO_NVAL)
+ goto failed;
+
+ csk = g_io_channel_unix_get_fd(chan);
+
+ len = sizeof(ret);
+ if (getsockopt(csk, SOL_SOCKET, SO_ERROR, &ret, &len) < 0) {
+ err = errno;
+ error("getsockopt(SO_ERROR): %s (%d)", strerror(err), err);
+ goto failed;
+ }
+
+ if (ret != 0) {
+ err = ret;
+ error("connect(): %s (%d)", strerror(ret), ret);
+ goto failed;
+ }
+
+ path = dbus_message_get_path(pc->msg);
+ dbus_connection_get_object_path_data(pc->conn, path, (void *) &idev);
+
+ /* Set HID control channel */
+ idev->hidp.ctrl_sock = csk;
+
+ /* Connect to the HID interrupt channel */
+ if (l2cap_connect(pc, L2CAP_PSM_HIDP_INTR,
+ (GIOFunc) interrupt_connect_cb) < 0) {
+
+ error("L2CAP connect failed:%s (%d)", strerror(errno), errno);
+ err = errno;
+ close(csk);
+ idev->hidp.ctrl_sock = -1;
+ goto failed;
+ }
+
+ return FALSE;
+
+failed:
+
+ err_connection_failed(pc->conn, pc->msg, strerror(err));
+ pending_connect_free(pc);
+
+ return FALSE;
+}
+
/*
* Input Device methods
*/