summaryrefslogtreecommitdiff
path: root/bus/signals.c
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-11-05 14:14:54 -0400
committerWill Thompson <will.thompson@collabora.co.uk>2010-11-21 17:02:31 +0000
commitfe79973f0a39f68a675b7470932d10b1e1262331 (patch)
tree2e8a63d6c5948639283190104903df767dc8ad29 /bus/signals.c
parent7f39b487d116dc61b43254c980bc81822c7a1f5c (diff)
downloaddbus-fe79973f0a39f68a675b7470932d10b1e1262331.tar.gz
Support matching path arguments with argXpath
The existing implementation only matched arguments of type 's', not of type 'o'!
Diffstat (limited to 'bus/signals.c')
-rw-r--r--bus/signals.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/bus/signals.c b/bus/signals.c
index 15a86da2..f059d30f 100644
--- a/bus/signals.c
+++ b/bus/signals.c
@@ -1687,8 +1687,9 @@ match_rule_matches (BusMatchRule *rule,
{
const char *actual_arg;
int actual_length;
-
- if (current_type != DBUS_TYPE_STRING)
+
+ if (current_type != DBUS_TYPE_STRING &&
+ (!is_path || current_type != DBUS_TYPE_OBJECT_PATH))
return FALSE;
actual_arg = NULL;
@@ -2300,14 +2301,17 @@ test_matching (void)
/* This is a list of paths that should be matched by PATH_MATCH_RULE, taken
* from the specification. Notice that not all of them are actually legal D-Bus
- * paths. The author of this test takes no responsibility for the semantics of
+ * paths.
+ *
+ * The author of this test takes no responsibility for the semantics of
* this match rule key.
*/
static const char *paths_that_should_be_matched[] = {
- "/",
"/aa/",
"/aa/bb/",
"/aa/bb/cc/",
+#define FIRST_VALID_PATH_WHICH_SHOULD_MATCH 3
+ "/",
"/aa/bb/cc",
NULL
};
@@ -2322,7 +2326,8 @@ static const char *paths_that_should_not_be_matched[] = {
};
static void
-test_path_match (const char *path,
+test_path_match (int type,
+ const char *path,
const char *rule_text,
BusMatchRule *rule,
dbus_bool_t should_match)
@@ -2335,7 +2340,7 @@ test_path_match (const char *path,
_dbus_assert_not_reached ("oom");
if (!dbus_message_append_args (message,
- DBUS_TYPE_STRING, &path,
+ type, &path,
NULL))
_dbus_assert_not_reached ("oom");
@@ -2343,10 +2348,12 @@ test_path_match (const char *path,
if (matched != should_match)
{
- _dbus_warn ("Expected rule %s to %s message with first arg %s, failed\n",
+ _dbus_warn ("Expected rule %s to %s message "
+ "with first arg %s of type '%c', failed\n",
rule_text,
should_match ? "match" : "not match",
- path);
+ path,
+ (char) type);
exit (1);
}
@@ -2363,10 +2370,17 @@ test_path_matching (void)
_dbus_assert (rule != NULL);
for (s = paths_that_should_be_matched; *s != NULL; s++)
- test_path_match (*s, PATH_MATCH_RULE, rule, TRUE);
+ test_path_match (DBUS_TYPE_STRING, *s, PATH_MATCH_RULE, rule, TRUE);
+
+ for (s = paths_that_should_be_matched + FIRST_VALID_PATH_WHICH_SHOULD_MATCH;
+ *s != NULL; s++)
+ test_path_match (DBUS_TYPE_OBJECT_PATH, *s, PATH_MATCH_RULE, rule, TRUE);
for (s = paths_that_should_not_be_matched; *s != NULL; s++)
- test_path_match (*s, PATH_MATCH_RULE, rule, FALSE);
+ {
+ test_path_match (DBUS_TYPE_STRING, *s, PATH_MATCH_RULE, rule, FALSE);
+ test_path_match (DBUS_TYPE_OBJECT_PATH, *s, PATH_MATCH_RULE, rule, FALSE);
+ }
bus_match_rule_unref (rule);
}