linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@profusion.mobi>
To: linux-bluetooth@vger.kernel.org
Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Subject: [PATCH BlueZ v6 09/15] gdbus: loop over args to check message signature
Date: Thu, 17 May 2012 15:20:06 -0300	[thread overview]
Message-ID: <1337278812-4837-10-git-send-email-lucas.demarchi@profusion.mobi> (raw)
In-Reply-To: <1337278812-4837-1-git-send-email-lucas.demarchi@profusion.mobi>

---
 gdbus/object.c |   34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/gdbus/object.c b/gdbus/object.c
index 3ac6a0b..b187bb5 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -374,6 +374,27 @@ static struct interface_data *find_interface(GSList *interfaces,
 	return NULL;
 }
 
+static gboolean g_dbus_args_have_signature(const GDBusArgInfo *args,
+							DBusMessage *message)
+{
+	const char *sig = dbus_message_get_signature(message);
+	const char *p = NULL;
+
+	for (; args && args->signature && *sig; args++) {
+		p = args->signature;
+
+		for (; *sig && *p; sig++, p++) {
+			if (*p != *sig)
+				return FALSE;
+		}
+	}
+
+	if (*sig || (p && *p) || (args && args->signature))
+		return FALSE;
+
+	return TRUE;
+}
+
 static DBusHandlerResult generic_message(DBusConnection *connection,
 					DBusMessage *message, void *user_data)
 {
@@ -394,8 +415,8 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
 							method->name) == FALSE)
 			continue;
 
-		if (dbus_message_has_signature(message,
-						method->signature) == FALSE)
+		if (g_dbus_args_have_signature(method->in_args,
+							message) == FALSE)
 			continue;
 
 		if (check_privilege(connection, message, method,
@@ -552,7 +573,7 @@ static void object_path_unref(DBusConnection *connection, const char *path)
 
 static gboolean check_signal(DBusConnection *conn, const char *path,
 				const char *interface, const char *name,
-				const char **args)
+				const GDBusArgInfo **args)
 {
 	struct generic_data *data = NULL;
 	struct interface_data *iface;
@@ -575,7 +596,7 @@ static gboolean check_signal(DBusConnection *conn, const char *path,
 
 	for (signal = iface->signals; signal && signal->name; signal++) {
 		if (!strcmp(signal->name, name)) {
-			*args = signal->signature;
+			*args = signal->args;
 			break;
 		}
 	}
@@ -597,7 +618,7 @@ static dbus_bool_t emit_signal_valist(DBusConnection *conn,
 {
 	DBusMessage *signal;
 	dbus_bool_t ret;
-	const char *signature, *args;
+	const GDBusArgInfo *args;
 
 	if (!check_signal(conn, path, interface, name, &args))
 		return FALSE;
@@ -612,8 +633,7 @@ static dbus_bool_t emit_signal_valist(DBusConnection *conn,
 	if (!ret)
 		goto fail;
 
-	signature = dbus_message_get_signature(signal);
-	if (strcmp(args, signature) != 0) {
+	if (g_dbus_args_have_signature(args, signal) == FALSE) {
 		error("%s.%s: expected signature'%s' but got '%s'",
 				interface, name, args, signature);
 		ret = FALSE;
-- 
1.7.10.2


  parent reply	other threads:[~2012-05-17 18:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-17 18:19 [PATCH BlueZ v6 00/15] gdbus: Better D-Bus introspection Lucas De Marchi
2012-05-17 18:19 ` [PATCH BlueZ v6 01/15] gdbus: return if method signature is malformed Lucas De Marchi
2012-05-18  2:53   ` Marcel Holtmann
2012-05-17 18:19 ` [PATCH BlueZ v6 02/15] gdbus: do not call memset for terminating NUL Lucas De Marchi
2012-05-18  2:54   ` Marcel Holtmann
2012-05-17 18:20 ` [PATCH BlueZ v6 03/15] Constify GDBus method tables Lucas De Marchi
2012-05-18  2:55   ` Marcel Holtmann
2012-05-17 18:20 ` [PATCH BlueZ v6 04/15] Constify GDBus signal tables Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 05/15] gdbus: add argument info to methods and signals Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 06/15] gdbus: add and use helpers for table declarations Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 07/15] Convert GDBus methods to use macro helpers Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 08/15] gdbus: use GDBusArgInfo to generate introspection Lucas De Marchi
2012-05-17 18:20 ` Lucas De Marchi [this message]
2012-05-17 18:20 ` [PATCH BlueZ v6 10/15] Do not set signature and reply in GDBus tables Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 11/15] gdbus: remove signature and reply from tables Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 12/15] gdbus: add Deprecated annotation in introspection Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 13/15] gdbus: add Method.NoReply " Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 14/15] gdbus: do not check signature twice Lucas De Marchi
2012-05-17 18:20 ` [PATCH BlueZ v6 15/15] adapter: " Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337278812-4837-10-git-send-email-lucas.demarchi@profusion.mobi \
    --to=lucas.demarchi@profusion.mobi \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).