public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] Input Service - Support for hidd configuration
@ 2007-06-08 21:35 Daniel Gollub
  2007-06-09  2:53 ` Mo.Shahin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Gollub @ 2007-06-08 21:35 UTC (permalink / raw)
  To: BlueZ development; +Cc: Stefan Seyfried

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

Hi,

attachted an input service patch which implements support for the hidd 
configuration. This is needed to have a smooth transition from hidd daemon to 
the new shiny input service ...

( ... and especially this is needed to be able to return from vacation back to 
the office - without getting blamed by Seife for not working bluetooth input 
devices ;P )

The patch reads the entries of hidd and stores it with store_device_info() 
function. The hidd doesn't get modified - this means the transition happens 
on every start of the input service. store_device_info() avoids duplicate 
entries. So there is still the possibility to have a working bluetooth input 
device when falling back to hidd.

best regards,
Daniel

[-- Attachment #2: bluez-utils-input-service-hidd-config.diff --]
[-- Type: text/x-diff, Size: 1227 bytes --]

--- input/manager.c	9 May 2007 14:53:34 -0000	1.25
+++ input/manager.c	8 Jun 2007 21:16:25 -0000
@@ -959,6 +959,23 @@ static void stored_input(char *key, char
 	device_paths = g_slist_append(device_paths, g_strdup(path));
 }
 
+/* hidd to input transition function */
+static void stored_hidd(char *key, char *value, void *data)
+{
+	const char *path;
+	struct hidp_connadd_req hidp; 
+	bdaddr_t dst, *src = data;
+
+	str2ba(key, &dst);
+
+	memset(&hidp, 0, sizeof(struct hidp_connadd_req));
+
+	if (parse_stored_device_info(value, &hidp) < 0)
+		return;
+
+	store_device_info(src, &dst, &hidp);
+}
+
 static void register_stored_inputs(void)
 {
 	char dirname[PATH_MAX + 1];
@@ -977,10 +994,16 @@ static void register_stored_inputs(void)
 		if (!isdigit(de->d_name[0]))
 			continue;
 
+		str2ba(de->d_name, &src);
+
+		/* move the hidd entries to the input storage */
 		create_name(filename, PATH_MAX, STORAGEDIR,
-						de->d_name, "input");
+						de->d_name, "hidd");
+		textfile_foreach(filename, stored_hidd, &src);
 
-		str2ba(de->d_name, &src);
+		/* load the input stored devices */
+		create_name(filename, PATH_MAX, STORAGEDIR,
+						de->d_name, "input");
 
 		textfile_foreach(filename, stored_input, &src);
 	}

[-- Attachment #3: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bluez-devel] [PATCH] Input Service - Support for hidd configuration
  2007-06-08 21:35 [Bluez-devel] [PATCH] Input Service - Support for hidd configuration Daniel Gollub
@ 2007-06-09  2:53 ` Mo.Shahin
  2007-06-16  7:50 ` Marcel Holtmann
  2007-06-22 15:41 ` Daniel Gollub
  2 siblings, 0 replies; 4+ messages in thread
From: Mo.Shahin @ 2007-06-09  2:53 UTC (permalink / raw)
  To: BlueZ development


[-- Attachment #1.1: Type: text/plain, Size: 1683 bytes --]

Hi Daniel,
This is Mo from Canada, I was looking for a developer to develop a bluetooth
application over this board (http://acmesystems.it/?id=4)
The target from this project is to build a bluetooth marketing solution
along with interactivity with cell phone users and I was wondering if you
are interested in such project or not, and if you have any contact who might
be interested
Regards,
Mo.

On 6/8/07, Daniel Gollub <dgollub@suse.de> wrote:
>
> Hi,
>
> attachted an input service patch which implements support for the hidd
> configuration. This is needed to have a smooth transition from hidd daemon
> to
> the new shiny input service ...
>
> ( ... and especially this is needed to be able to return from vacation
> back to
> the office - without getting blamed by Seife for not working bluetooth
> input
> devices ;P )
>
> The patch reads the entries of hidd and stores it with store_device_info()
> function. The hidd doesn't get modified - this means the transition
> happens
> on every start of the input service. store_device_info() avoids duplicate
> entries. So there is still the possibility to have a working bluetooth
> input
> device when falling back to hidd.
>
> best regards,
> Daniel
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
>
>
>

[-- Attachment #1.2: Type: text/html, Size: 2220 bytes --]

[-- Attachment #2: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #3: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bluez-devel] [PATCH] Input Service - Support for hidd configuration
  2007-06-08 21:35 [Bluez-devel] [PATCH] Input Service - Support for hidd configuration Daniel Gollub
  2007-06-09  2:53 ` Mo.Shahin
@ 2007-06-16  7:50 ` Marcel Holtmann
  2007-06-22 15:41 ` Daniel Gollub
  2 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2007-06-16  7:50 UTC (permalink / raw)
  To: BlueZ development; +Cc: Stefan Seyfried

Hi Daniel,

> attachted an input service patch which implements support for the hidd 
> configuration. This is needed to have a smooth transition from hidd daemon to 
> the new shiny input service ...
> 
> ( ... and especially this is needed to be able to return from vacation back to 
> the office - without getting blamed by Seife for not working bluetooth input 
> devices ;P )
> 
> The patch reads the entries of hidd and stores it with store_device_info() 
> function. The hidd doesn't get modified - this means the transition happens 
> on every start of the input service. store_device_info() avoids duplicate 
> entries. So there is still the possibility to have a working bluetooth input 
> device when falling back to hidd.

if I read this correctly, then a hidd entry would overwrite a input
entry. We can't let that happen.

Also the format of hidd and input is different, but you are using the
same function to parse it.

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Bluez-devel] [PATCH] Input Service - Support for hidd configuration
  2007-06-08 21:35 [Bluez-devel] [PATCH] Input Service - Support for hidd configuration Daniel Gollub
  2007-06-09  2:53 ` Mo.Shahin
  2007-06-16  7:50 ` Marcel Holtmann
@ 2007-06-22 15:41 ` Daniel Gollub
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Gollub @ 2007-06-22 15:41 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 1043 bytes --]

On Friday 08 June 2007, Daniel Gollub wrote:
> Hi,
>
> attachted an input service patch which implements support for the hidd
> configuration. This is needed to have a smooth transition from hidd daemon
> to the new shiny input service ...
>
> ( ... and especially this is needed to be able to return from vacation back
> to the office - without getting blamed by Seife for not working bluetooth
> input devices ;P )
>
> The patch reads the entries of hidd and stores it with store_device_info()
> function. The hidd doesn't get modified - this means the transition happens
> on every start of the input service. store_device_info() avoids duplicate
> entries. So there is still the possibility to have a working bluetooth
> input device when falling back to hidd.


Fixed some discussed issues of the hidd config patch:

- Only transfer entry from hidd config to input if there isn't already a entry 
of the device in input config
- Added parsing function for hidd config format (input format changed)

Patch attachted.

best regards,
Daniel

[-- Attachment #2: bluez-utils-input-hidd-config-v02.diff --]
[-- Type: text/x-diff, Size: 3945 bytes --]

Index: input/manager.c
===================================================================
RCS file: /cvsroot/bluez/utils/input/manager.c,v
retrieving revision 1.26
diff -u -p -r1.26 manager.c
--- input/manager.c	21 Jun 2007 22:06:33 -0000	1.26
+++ input/manager.c	22 Jun 2007 15:21:02 -0000
@@ -962,6 +962,25 @@ cleanup:
 		g_free(hidp.rd_data);
 }
 
+/* hidd to input transition function */
+static void stored_hidd(char *key, char *value, void *data)
+{
+	struct hidp_connadd_req hidp; 
+	bdaddr_t dst, *src = data;
+
+	str2ba(key, &dst);
+
+	if (input_device_stored(src, &dst) > 0)
+		return;
+
+	memset(&hidp, 0, sizeof(struct hidp_connadd_req));
+
+	if (parse_stored_hidd(value, &hidp) < 0)
+		return;
+
+	store_device_info(src, &dst, &hidp);
+}
+
 static void register_stored_inputs(void)
 {
 	char dirname[PATH_MAX + 1];
@@ -980,10 +999,16 @@ static void register_stored_inputs(void)
 		if (!isdigit(de->d_name[0]))
 			continue;
 
+		str2ba(de->d_name, &src);
+
+		/* move the hidd entries to the input storage */
 		create_name(filename, PATH_MAX, STORAGEDIR,
-						de->d_name, "input");
+						de->d_name, "hidd");
+		textfile_foreach(filename, stored_hidd, &src);
 
-		str2ba(de->d_name, &src);
+		/* load the input stored devices */
+		create_name(filename, PATH_MAX, STORAGEDIR,
+						de->d_name, "input");
 
 		textfile_foreach(filename, stored_input, &src);
 	}
Index: input/storage.c
===================================================================
RCS file: /cvsroot/bluez/utils/input/storage.c,v
retrieving revision 1.10
diff -u -p -r1.10 storage.c
--- input/storage.c	19 Mar 2007 14:58:44 -0000	1.10
+++ input/storage.c	22 Jun 2007 15:21:02 -0000
@@ -59,6 +59,70 @@ static inline int create_filename(char *
 	return create_name(buf, size, STORAGEDIR, addr, name);
 }
 
+int input_device_stored(bdaddr_t *src, bdaddr_t *dst)
+{
+	char filename[PATH_MAX + 1], *str;
+	char peer[18];
+
+	create_filename(filename, PATH_MAX, src, "input");
+
+	ba2str(dst, peer);
+	str = textfile_get(filename, peer);
+	if (!str)
+		return -ENOENT;
+
+	free(str);
+
+	return 1;
+}
+
+int parse_stored_hidd(const char *str, struct hidp_connadd_req *req)
+{
+	char tmp[3];
+	char *desc;
+	unsigned int vendor, product, version, subclass, country, parser, pos;
+	size_t len;
+	int i;
+
+	desc = malloc(4096);
+	if (!desc)
+		return -ENOMEM;
+
+	memset(desc, 0, 4096);
+
+	sscanf(str, "%04X:%04X:%04X %02X %02X %04X %4095s %08X %n",
+			&vendor, &product, &version, &subclass, &country,
+			&parser, desc, &req->flags, &pos);
+
+	len = strlen(desc);
+	if (len <= 0)
+		return -ENOENT;
+
+
+	req->vendor   = vendor;
+	req->product  = product;
+	req->version  = version;
+	req->subclass = subclass;
+	req->country  = country;
+	req->parser   = parser;
+
+	req->rd_size = len / 2;
+	req->rd_data = g_try_malloc0(req->rd_size);
+	if (!req->rd_data) {
+		return -ENOMEM;
+	}
+
+	memset(tmp, 0, sizeof(tmp));
+	for (i = 0; i < req->rd_size; i++) {
+		memcpy(tmp, desc + (i * 2), 2);
+		req->rd_data[i] = (uint8_t) strtol(tmp, NULL, 16);
+	}
+
+	g_free(desc);
+
+	return 0;
+}
+
 int parse_stored_device_info(const char *str, struct hidp_connadd_req *req)
 {
 	char tmp[3];
Index: input/storage.h
===================================================================
RCS file: /cvsroot/bluez/utils/input/storage.h,v
retrieving revision 1.6
diff -u -p -r1.6 storage.h
--- input/storage.h	19 Mar 2007 14:58:44 -0000	1.6
+++ input/storage.h	22 Jun 2007 15:21:02 -0000
@@ -21,6 +21,8 @@
  *
  */
 
+int input_device_stored(bdaddr_t *src, bdaddr_t *dst);
+
 int get_stored_device_info(bdaddr_t *src, bdaddr_t *dst,
 				struct hidp_connadd_req *req);
 
@@ -29,6 +31,7 @@ int del_stored_device_info(bdaddr_t *src
 int store_device_info(bdaddr_t *src, bdaddr_t *dst,
 				struct hidp_connadd_req *req);
 
+int parse_stored_hidd(const char *str, struct hidp_connadd_req *req);
 int parse_stored_device_info(const char *str,
 				struct hidp_connadd_req *req);
 

[-- Attachment #3: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-22 15:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-08 21:35 [Bluez-devel] [PATCH] Input Service - Support for hidd configuration Daniel Gollub
2007-06-09  2:53 ` Mo.Shahin
2007-06-16  7:50 ` Marcel Holtmann
2007-06-22 15:41 ` Daniel Gollub

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox