linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] [DBUS Patch] Device Property
@ 2005-11-04 14:03 Eduardo Rocha
  2005-11-04 15:44 ` Marcel Holtmann
  0 siblings, 1 reply; 37+ messages in thread
From: Eduardo Rocha @ 2005-11-04 14:03 UTC (permalink / raw)
  To: bluez-devel

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

Hi Marcel,

here is the patch with the initial development of setproperty and
getproperty for /org/bluez/Device/hciX. As this is only the fundation,
I didn't update the python script.

BR,
Eduardo.

--
Eduardo Rocha
Instituto Nokia de Tecnologia - INdT

[-- Attachment #2: dbus_devices_prop.patch --]
[-- Type: text/x-patch, Size: 8716 bytes --]

--- utils.orig/hcid/dbus.h	2005-11-03 14:34:02.798246064 -0300
+++ utils/hcid/dbus.h	2005-11-04 10:30:18.051748984 -0300
@@ -120,15 +120,49 @@
 /* Control interface methods */
 #define DEV_UP				"Up"
 #define DEV_DOWN			"Down"
-#define DEV_RESET			"Reset"
 #define DEV_SET_PROPERTY		"SetProperty"
 #define DEV_GET_PROPERTY		"GetProperty"
 
+#define DEV_PROPERTY_AUTH		"auth"
+#define DEV_PROPERTY_ENCRYPT		"encrypt"
+#define DEV_PROPERTY_SECMGR		"secmgr"
+#define DEV_PROPERTY_PISCAN		"piscan"
+#define DEV_PROPERTY_PSCAN		"pscan"
+#define DEV_PROPERTY_ISCAN		"iscan"
+#define DEV_PROPERTY_PTYPE		"ptype"
+#define DEV_PROPERTY_LM			"lm"
+#define DEV_PROPERTY_LP			"lp"
+#define DEV_PROPERTY_NAME		"name"
+#define DEV_PROPERTY_CLASS		"class"
+#define DEV_PROPERTY_VOICE		"voice"
+#define DEV_PROPERTY_IAC		"iac"
+#define DEV_PROPERTY_INCMODE		"incmode"
+#define DEV_PROPERTY_INCTYPE		"inctype"
+#define DEV_PROPERTY_INCPARMS		"incparms"
+#define DEV_PROPERTY_PAGEPARMS		"pageparms"
+#define DEV_PROPERTY_PAGETO		"pageto"
+#define DEV_PROPERTY_AFHMODE		"afhmode"
+#define DEV_PROPERTY_ACLMTU		"aclmtu"
+#define DEV_PROPERTY_SCOMTU		"scomtu"
+#define DEV_PROPERTY_PUTKEY		"putkey"
+#define DEV_PROPERTY_DELKEY		"delkey"
+#define DEV_PROPERTY_DEV_INFO		"info"
+
 #define DEV_UP_SIGNATURE			__END_SIG__
 #define DEV_DOWN_SIGNATURE			__END_SIG__
 #define DEV_RESET_SIGNATURE			__END_SIG__
-#define DEV_SET_PROPERTY_SIGNATURE		__END_SIG__
-#define DEV_GET_PROPERTY_SIGNATURE		__END_SIG__
+#define DEV_SET_PROPERTY_SIGNATURE_1		DBUS_TYPE_STRING_AS_STRING \
+						DBUS_TYPE_BOOLEAN_AS_STRING \
+						__END_SIG__
+#define DEV_SET_PROPERTY_SIGNATURE_2		DBUS_TYPE_STRING_AS_STRING \
+						DBUS_TYPE_STRING_AS_STRING \
+						__END_SIG__
+#define DEV_SET_PROPERTY_SIGNATURE_3		DBUS_TYPE_STRING_AS_STRING \
+						DBUS_TYPE_UINT16_AS_STRING \
+						__END_SIG__
+
+#define DEV_GET_PROPERTY_SIGNATURE		DBUS_TYPE_STRING_AS_STRING \
+						__END_SIG__
 
 
 #define HCI_PERIODIC_INQ_SIGNATURE			DBUS_TYPE_BYTE_AS_STRING \
--- utils.orig/hcid/dbus.c	2005-11-03 14:34:02.798246064 -0300
+++ utils/hcid/dbus.c	2005-11-04 10:36:19.361821504 -0300
@@ -268,13 +268,61 @@
  */
 static DBusMessage* handle_device_up_req(DBusMessage *msg, void *data);
 static DBusMessage* handle_device_down_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_device_set_propety_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_device_get_propety_req(DBusMessage *msg, void *data);
 
 static const struct service_data device_services[] = {
 	{ DEV_UP,		handle_device_up_req,		DEV_UP_SIGNATURE		},
 	{ DEV_DOWN,		handle_device_down_req,		DEV_DOWN_SIGNATURE		},
-	{ DEV_RESET,		handle_not_implemented_req,	DEV_RESET_SIGNATURE		},
-	{ DEV_SET_PROPERTY,	handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE	},
-	{ DEV_GET_PROPERTY,	handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE	},
+	{ DEV_SET_PROPERTY,	handle_device_set_propety_req,	DEV_SET_PROPERTY_SIGNATURE_1	},
+	{ DEV_SET_PROPERTY,	handle_device_set_propety_req,	DEV_SET_PROPERTY_SIGNATURE_2	},
+	{ DEV_SET_PROPERTY,	handle_device_set_propety_req,	DEV_SET_PROPERTY_SIGNATURE_3	},
+	{ DEV_GET_PROPERTY,	handle_device_get_propety_req,	DEV_GET_PROPERTY_SIGNATURE	},
+	{ NULL, NULL, NULL}
+};
+
+static const struct service_data set_property_services[] = {
+	{ DEV_PROPERTY_AUTH,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_ENCRYPT,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_SECMGR,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_PISCAN,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_PSCAN,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_ISCAN,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_PTYPE,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_LM,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_LP,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_NAME,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_CLASS,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_VOICE,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_IAC,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_INCMODE,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_INCTYPE,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_INCPARMS,	handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_PAGEPARMS,	handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_PAGETO,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_AFHMODE,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_ACLMTU,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_SCOMTU,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_PUTKEY,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ DEV_PROPERTY_DELKEY,		handle_not_implemented_req,	DEV_SET_PROPERTY_SIGNATURE_1 	},
+	{ NULL, NULL, NULL}
+};
+
+static const struct service_data get_property_services[] = {
+	{ DEV_PROPERTY_DEV_INFO,	handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_PTYPE,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_LM,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_LP,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_NAME,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_CLASS,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_VOICE,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_IAC,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_INCMODE,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_INCTYPE,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_INCPARMS,	handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_PAGEPARMS,	handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_PAGETO,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
+	{ DEV_PROPERTY_AFHMODE,		handle_not_implemented_req,	DEV_GET_PROPERTY_SIGNATURE 	},
 	{ NULL, NULL, NULL}
 };
 
@@ -1174,16 +1222,16 @@
 	}
 
 	if (handlers) {
+		error = BLUEZ_EDBUS_WRONG_SIGNATURE;
 		for (; handlers->name != NULL; handlers++) {
 			if (strcmp(handlers->name, method) == 0) {
-				if (strcmp(handlers->signature, signature) != 0)
-					error = BLUEZ_EDBUS_WRONG_SIGNATURE;
-				else {
+				if (strcmp(handlers->signature, signature) == 0) {
 					reply = handlers->handler_func(msg, data);
 					error = 0;
+					ret = DBUS_HANDLER_RESULT_HANDLED;
+					break;
 				}
 
-				ret = DBUS_HANDLER_RESULT_HANDLED;
 			}
 		}
 	}
@@ -1768,6 +1816,66 @@
 	return reply;
 }
 
+static DBusMessage* handle_device_set_propety_req(DBusMessage *msg, void *data)
+{
+	const struct service_data *handlers = set_property_services;
+	DBusMessageIter iter;
+	DBusMessage *reply = NULL;
+	const char *signature;
+	char *str_name;
+	uint32_t error = BLUEZ_EDBUS_UNKNOWN_METHOD;
+
+	signature = dbus_message_get_signature(msg);
+
+	dbus_message_iter_init(msg, &iter);
+	dbus_message_iter_get_basic(&iter, &str_name);
+
+	for (; handlers->name != NULL; handlers++) {
+		if (strcasecmp(handlers->name, str_name) == 0) {
+			if (strcmp(handlers->signature, signature) == 0) {
+				reply = handlers->handler_func(msg, data);
+				error = 0;
+				break;
+			} else {
+				error = BLUEZ_EDBUS_WRONG_SIGNATURE;
+				break;
+			}
+
+		}
+	}
+
+	if (error)
+		reply = bluez_new_failure_msg(msg, error);
+
+	return reply;
+}
+
+static DBusMessage* handle_device_get_propety_req(DBusMessage *msg, void *data)
+{
+	const struct service_data *handlers = get_property_services;
+	DBusMessageIter iter;
+	DBusMessage *reply = NULL;
+	char *str_name;
+	uint32_t error = BLUEZ_EDBUS_UNKNOWN_METHOD;
+
+
+	dbus_message_iter_init(msg, &iter);
+	dbus_message_iter_get_basic(&iter, &str_name);
+
+	for (; handlers->name != NULL; handlers++) {
+		if (strcasecmp(handlers->name, str_name) == 0) {
+			reply = handlers->handler_func(msg, data);
+			error = 0;
+			break;
+		}
+	}
+
+	if (error)
+		reply = bluez_new_failure_msg(msg, error);
+
+	return reply;
+}
+
 static DBusMessage* handle_device_list_req(DBusMessage *msg, void *data)
 {
 	DBusMessageIter iter;

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

end of thread, other threads:[~2005-12-16 18:40 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-04 14:03 [Bluez-devel] [DBUS Patch] Device Property Eduardo Rocha
2005-11-04 15:44 ` Marcel Holtmann
2005-11-08 20:41   ` Claudio Takahasi
2005-11-08 22:20     ` Marcel Holtmann
2005-11-08 22:20     ` Johan Hedberg
2005-11-08 22:38       ` Marcel Holtmann
2005-11-17 19:16         ` Eduardo Rocha
2005-11-17 20:52           ` Eduardo Rocha
2005-11-18  8:28             ` Johan Hedberg
2005-11-18 10:51               ` Eduardo Rocha
2005-11-18 11:26                 ` Johan Hedberg
2005-11-18 13:00                   ` Eduardo Rocha
2005-11-22 11:51                     ` Marcel Holtmann
2005-11-22 19:52                       ` Eduardo Rocha
2005-11-24  4:17                         ` Marcel Holtmann
2005-11-24 18:50                           ` Eduardo Rocha
2005-11-24 22:54                             ` Marcel Holtmann
2005-11-25 13:47                               ` Claudio Takahasi
2005-11-25 14:32                                 ` Eduardo Rocha
2005-11-25 18:08                                 ` Marcel Holtmann
2005-11-25 18:34                                   ` Eduardo Rocha
2005-11-25 18:41                                     ` Marcel Holtmann
2005-11-25 19:52                                       ` Claudio Takahasi
2005-11-25 20:06                                         ` Marcel Holtmann
2005-12-01 16:55                                           ` Eduardo Rocha
2005-12-01 21:05                                             ` Marcel Holtmann
2005-12-07 12:29                                               ` Eduardo Rocha
2005-12-07 12:55                                                 ` Johan Hedberg
2005-12-07 13:02                                                   ` Marcel Holtmann
2005-12-07 16:01                                                     ` Eduardo Rocha
2005-12-13 17:27                                                       ` Eduardo Rocha
2005-12-13 22:03                                                         ` Marcel Holtmann
2005-12-14 19:02                                                           ` Eduardo Rocha
2005-12-16 18:37                                                             ` Eduardo Rocha
2005-12-16 18:40                                                               ` Marcel Holtmann
2005-11-25 16:51                               ` Johan Hedberg
2005-11-25 18:12                                 ` 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).