linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] HCID D-Bus
@ 2005-09-08 19:50 Claudio Takahasi
  2005-09-08 23:07 ` Marcel Holtmann
  0 siblings, 1 reply; 17+ messages in thread
From: Claudio Takahasi @ 2005-09-08 19:50 UTC (permalink / raw)
  To: bluez-devel


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

Hi Marcel,

In the last email about bluetoothd, you suggested send patches to enhance 
hcid. I studied the hcid code and I would like align our ideas before start 
coding. My suggestions are:

1. Develop a common code addressing all D-Bus versions
2. Send signals to connection complete and disconnection
3. Register a D-Bus hci object path as a initial point for bluetoothd and 
provide basic services(inquiry, auth, ...).

Do you agree? Do you have suggestions/comments?

I am sending a patch to solve the problem of D-Bus versions. Sorry, byte 
array is not being handled yet, but I will fix it. This is just a idea of 
how solve the problem of several D-Bus versions. Get the dbus major/minor 
version in the "configure" is a better approach, instead of check if the 
function dbus_message_iter_get_basic belongs to the dbus-1 library. If you 
allow change the makefiles(acinclude.m4, configure.in <http://configure.in>, 
config.h.in <http://config.h.in> ) I can modify it.

Regards,
Claudio.

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

[-- Attachment #2: hcid_dbus_patch00.01 --]
[-- Type: application/octet-stream, Size: 7348 bytes --]

--- bluez-utils-2.20/hcid/dbus.c	2005-08-27 10:37:14.000000000 -0300
+++ bluez-hcid-0.0.1/hcid/dbus.c	2005-09-08 16:08:38.772082600 -0300
@@ -46,6 +46,8 @@
 
 #include "hcid.h"
 
+#include "dbus-compat.h"
+
 static DBusConnection *connection;
 
 #define TIMEOUT (30 * 1000)		/* 30 seconds */
@@ -83,11 +85,7 @@
 	if (type != DBUS_TYPE_STRING)
 		goto error;
 
-#ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
-	dbus_message_iter_get_basic(&iter, &pin);
-#else
-	pin = dbus_message_iter_get_string(&iter);
-#endif
+	DBUS_MSG_ITER_GET_STR(&iter, pin);
 
 	len = strlen(pin);
 
@@ -171,9 +169,7 @@
 void hcid_dbus_inquiry_start(bdaddr_t *local)
 {
 	DBusMessage *message;
-#ifndef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
 	DBusMessageIter iter;
-#endif
 	char *local_addr;	
 	bdaddr_t tmp;
 
@@ -186,15 +182,8 @@
 		goto failed;
 	}
 
-#ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
-	dbus_message_append_args(message,
-					DBUS_TYPE_STRING, &local_addr,
-					DBUS_TYPE_INVALID);
-#else
-	dbus_message_append_iter_init(message, &iter);
-
-	dbus_message_iter_append_string(&iter, local_addr);
-#endif
+	DBUS_MSG_APPEND_ITER_INIT(message, &iter);
+	DBUS_MSG_ITER_APPEND_STR(&iter, local_addr);
 
 	if (dbus_connection_send(connection, message, NULL) == FALSE) {
 		syslog(LOG_ERR, "Can't send D-BUS inquiry start message");
@@ -214,9 +203,7 @@
 void hcid_dbus_inquiry_complete(bdaddr_t *local)
 {
 	DBusMessage *message;
-#ifndef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
 	DBusMessageIter iter;
-#endif
 	char *local_addr;
 	bdaddr_t tmp;
 
@@ -229,15 +216,8 @@
 		goto failed;
 	}
 
-#ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
-	dbus_message_append_args(message,
-					DBUS_TYPE_STRING, &local_addr,
-					DBUS_TYPE_INVALID);
-#else
-	dbus_message_append_iter_init(message, &iter);
-
-	dbus_message_iter_append_string(&iter, local_addr);
-#endif
+	DBUS_MSG_APPEND_ITER_INIT(message, &iter);
+	DBUS_MSG_ITER_APPEND_STR(&iter, local_addr);
 
 	if (dbus_connection_send(connection, message, NULL) == FALSE) {
 		syslog(LOG_ERR, "Can't send D-BUS inquiry complete message");
@@ -257,9 +237,7 @@
 void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, int8_t rssi)
 {
 	DBusMessage *message;
-#ifndef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
 	DBusMessageIter iter;
-#endif
 	char *local_addr, *peer_addr;
 	bdaddr_t tmp;
 
@@ -273,21 +251,11 @@
 		goto failed;
 	}
 
-#ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
-	dbus_message_append_args(message,
-					DBUS_TYPE_STRING, &local_addr,
-					DBUS_TYPE_STRING, &peer_addr,
-					DBUS_TYPE_UINT32, &class,
-					DBUS_TYPE_INT32, &rssi,
-					DBUS_TYPE_INVALID);
-#else
-	dbus_message_append_iter_init(message, &iter);
-
-	dbus_message_iter_append_string(&iter, local_addr);
-	dbus_message_iter_append_string(&iter, peer_addr);
-	dbus_message_iter_append_uint32(&iter, class);
-	dbus_message_iter_append_int32(&iter, rssi);
-#endif
+	DBUS_MSG_APPEND_ITER_INIT(message, &iter);
+	DBUS_MSG_ITER_APPEND_STR(&iter, local_addr);
+	DBUS_MSG_ITER_APPEND_STR(&iter, peer_addr);
+	DBUS_MSG_ITER_APPEND_UINT32(&iter, class);
+	DBUS_MSG_ITER_APPEND_INT32(&iter, rssi);
 
 	if (dbus_connection_send(connection, message, NULL) == FALSE) {
 		syslog(LOG_ERR, "Can't send D-BUS inquiry result message");
@@ -308,9 +276,7 @@
 void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name)
 {
 	DBusMessage *message;
-#ifndef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
 	DBusMessageIter iter;
-#endif
 	char *local_addr, *peer_addr;
 	bdaddr_t tmp;
 
@@ -324,19 +290,10 @@
 		goto failed;
 	}
 
-#ifdef HAVE_DBUS_MESSAGE_ITER_GET_BASIC
-	dbus_message_append_args(message,
-					DBUS_TYPE_STRING, &local_addr,
-					DBUS_TYPE_STRING, &peer_addr,
-					DBUS_TYPE_STRING, &name,
-					DBUS_TYPE_INVALID);
-#else
-	dbus_message_append_iter_init(message, &iter);
-
-	dbus_message_iter_append_string(&iter, local_addr);
-	dbus_message_iter_append_string(&iter, peer_addr);
-	dbus_message_iter_append_string(&iter, name);
-#endif
+	DBUS_MSG_APPEND_ITER_INIT(message, &iter);
+	DBUS_MSG_ITER_APPEND_STR(&iter, local_addr);
+	DBUS_MSG_ITER_APPEND_STR(&iter, peer_addr);
+	DBUS_MSG_ITER_APPEND_STR(&iter, name);
 
 	if (dbus_connection_send(connection, message, NULL) == FALSE) {
 		syslog(LOG_ERR, "Can't send D-BUS remote name message");
--- bluez-utils-2.20/hcid/dbus-compat.h	1969-12-31 21:00:00.000000000 -0300
+++ bluez-hcid-0.0.1/hcid/dbus-compat.h	2005-09-08 16:40:35.856641448 -0300
@@ -0,0 +1,81 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2000-2001  Qualcomm Incorporated
+ *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
+ *  Copyright (C) 2002-2005  Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation;
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+ *  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
+ *  CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 
+ *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 
+ *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
+ *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *  ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 
+ *  COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 
+ *  SOFTWARE IS DISCLAIMED.
+ *
+ *
+ *  $Id: dbus-compat.h,v 1.24 2005/09/08 18:32:41 holtmann Exp $
+ */
+
+#ifndef __H_DBUS_COMPAT_H__
+#define __H_DBUS_COMPAT_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define CHECK_DBUS_VERSION(major, minor) \
+		(DBUS_MAJOR_VER > (major) || \
+		 	(DBUS_MAJOR_VER == (major) && DBUS_MINOR_VER >= (minor)))
+	
+#if CHECK_DBUS_VERSION(0, 30)
+	/* For D-Bus version >= 0.30 */
+	/****** pending, requires chnages in the makefile  *****/
+#else /* < 0.30 */
+	/* For D-Bus version older than 0.30 */
+	
+#endif
+
+#if  HAVE_DBUS_MESSAGE_ITER_GET_BASIC
+	#warning "D-Bus > 0.30"
+	#define DBUS_MSG_ITER_GET_STR(iter, retvar) \
+		dbus_message_iter_get_basic((iter), &(retvar))
+	#define DBUS_MSG_ITER_APPEND_STR(iter, val) \
+		dbus_message_iter_append_basic((iter), DBUS_TYPE_STRING, &(val))
+	#define DBUS_MSG_APPEND_ITER_INIT(a, b) \
+		dbus_message_iter_init_append(a, b)	
+	#define DBUS_MSG_ITER_APPEND_INT32(iter, val) \
+		dbus_message_iter_append_basic((iter), DBUS_TYPE_INT32, &(val))
+	#define DBUS_MSG_ITER_APPEND_UINT32(iter, val) \
+		dbus_message_iter_append_basic((iter), DBUS_TYPE_UINT32, &(val))
+		
+#else
+	#warning "D-Bus < 0.30"
+	#define DBUS_MSG_ITER_GET_STR(iter, retvar) \
+		retvar = dbus_message_iter_get_string(iter)
+	#define DBUS_MSG_ITER_APPEND_STR(iter, val) \
+		dbus_message_iter_append_string((iter), (val))
+	#define DBUS_MSG_APPEND_ITER_INIT(a, b) \
+		dbus_message_append_iter_init(a, b)
+	#define DBUS_MSG_ITER_APPEND_INT32(iter, val) \
+		dbus_message_iter_append_int32((iter), (val))
+	#define DBUS_MSG_ITER_APPEND_UINT32(iter, val) \
+		dbus_message_iter_append_uint32((iter), (val))
+#endif
+
+
+
+
+
+#endif /*__H_DBUS_COMPAT_H__*/

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

end of thread, other threads:[~2005-09-15  8:11 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-08 19:50 [Bluez-devel] HCID D-Bus Claudio Takahasi
2005-09-08 23:07 ` Marcel Holtmann
2005-09-09  8:25   ` Peter Robinson
2005-09-09  9:37     ` Marcel Holtmann
2005-09-09 13:29       ` Sjoerd Simons
2005-09-09 13:40         ` Marcel Holtmann
2005-09-12 21:07           ` [Bluez-devel] HCID D-Bus (Sig Fault) Claudio Takahasi
2005-09-12 21:14             ` [Bluez-devel] HCID D-Bus (Seg Fault) Claudio Takahasi
2005-09-12 21:40             ` [Bluez-devel] HCID D-Bus (Sig Fault) Marcel Holtmann
2005-09-12 23:09               ` Claudio Takahasi
2005-09-12 23:21                 ` Marcel Holtmann
2005-09-13 13:03                   ` [Bluez-devel] HCID D-Bus (Seg Fault) Claudio Takahasi
2005-09-13 18:54                     ` Marcel Holtmann
2005-09-14 12:00                       ` Claudio Takahasi
2005-09-14 15:16                         ` Marcel Holtmann
2005-09-14 16:06                           ` Claudio Takahasi
2005-09-15  8:11                             ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).