summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert McQueen <robot101@debian.org>2006-02-15 23:45:48 +0000
committerRobert McQueen <robot101@debian.org>2006-02-15 23:45:48 +0000
commit0c04d2c69a65a5006093c5b9a83fcfb369683710 (patch)
treeb51c31e03cfe6a6f951d72ad96eb31c0c0e5d008
parentfa9011d8e91bbb35e9473a7e1bb9cfe57401cb8c (diff)
2006-02-16 Robert McQueen <robot101@debian.org>
* glib/dbus-gmain.c: Make the previous commit compile. * python/_dbus.py, python/matchrules.py: Patch from Ole Andre Ravnaas <ole.andre.ravnaas@collabora.co.uk> to allow you to specify sender_keyword="foo", path_keyword="bar" when adding a signal listener, so that you can bind to signals generically but still do something useful in your callback. * python/dbus_bindings.pyx: Demarshal the byte type as unsigned chars so that they're not cast to chars and made negative. Thanks to Jakub Stachowski for reporting this and testing the fix.
-rw-r--r--ChangeLog14
-rw-r--r--glib/dbus-gmain.c8
-rw-r--r--python/_dbus.py8
-rw-r--r--python/dbus_bindings.pyx6
-rw-r--r--python/matchrules.py17
5 files changed, 42 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index b2fcef2..2b15156 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-02-16 Robert McQueen <robot101@debian.org>
+
+ * glib/dbus-gmain.c: Make the previous commit compile.
+
+ * python/_dbus.py, python/matchrules.py: Patch from Ole Andre
+ Ravnaas <ole.andre.ravnaas@collabora.co.uk> to allow you to
+ specify sender_keyword="foo", path_keyword="bar" when adding
+ a signal listener, so that you can bind to signals generically
+ but still do something useful in your callback.
+
+ * python/dbus_bindings.pyx: Demarshal the byte type as unsigned
+ chars so that they're not cast to chars and made negative. Thanks
+ to Jakub Stachowski for reporting this and testing the fix.
+
2006-02-15 John (J5) Palmieri <johnp@redhat.com>
* dbus/dbus-glib.h:
diff --git a/glib/dbus-gmain.c b/glib/dbus-gmain.c
index d271610..54f868d 100644
--- a/glib/dbus-gmain.c
+++ b/glib/dbus-gmain.c
@@ -698,11 +698,11 @@ dbus_server_setup_with_g_main (DBusServer *server,
/**
* Returns a connection to the given address.
- *
+ *
* (Internally, calls dbus_connection_open() then calls
* dbus_connection_setup_with_g_main() on the result.)
*
- * @param address address of the connection to open
+ * @param address address of the connection to open
* @param error address where an error can be returned.
* @returns a DBusConnection
*/
@@ -716,10 +716,10 @@ dbus_g_connection_open (const gchar *address,
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
_dbus_g_value_types_init ();
-
+
dbus_error_init (&derror);
- connection = dbus_connection_open (socket, &derror);
+ connection = dbus_connection_open (address, &derror);
if (connection == NULL)
{
dbus_set_g_error (error, &derror);
diff --git a/python/_dbus.py b/python/_dbus.py
index 2376f17..7e17d9f 100644
--- a/python/_dbus.py
+++ b/python/_dbus.py
@@ -158,6 +158,8 @@ class Bus(object):
args_dict[num] = value
except ValueError:
raise TypeError("Invalid arg index %s"%snum)
+ elif key in ("sender_keyword", "path_keyword"):
+ pass
else:
raise TypeError("Unknown keyword %s"%(key))
@@ -178,6 +180,12 @@ class Bus(object):
match_rule = SignalMatchRule(signal_name, dbus_interface, named_service, path)
+ for kw in ("sender_keyword", "path_keyword"):
+ if kw in keywords:
+ setattr(match_rule, kw, keywords[kw])
+ else:
+ setattr(match_rule, kw, None)
+
if args_dict:
match_rule.add_args_match(args_dict)
diff --git a/python/dbus_bindings.pyx b/python/dbus_bindings.pyx
index 3bde96a..836dbf8 100644
--- a/python/dbus_bindings.pyx
+++ b/python/dbus_bindings.pyx
@@ -741,10 +741,10 @@ cdef class MessageIter:
return dbus_message_iter_get_element_type(self.iter)
def get_byte(self):
- cdef char c_val
- dbus_message_iter_get_basic(self.iter, <char *>&c_val)
+ cdef unsigned char c_val
+ dbus_message_iter_get_basic(self.iter, <unsigned char *>&c_val)
return c_val
-
+
def get_boolean(self):
cdef dbus_bool_t c_val
dbus_message_iter_get_basic(self.iter, <dbus_bool_t *>&c_val)
diff --git a/python/matchrules.py b/python/matchrules.py
index 3a2fbed..023a5b7 100644
--- a/python/matchrules.py
+++ b/python/matchrules.py
@@ -130,16 +130,25 @@ class SignalMatchRule:
self.args = args
def execute(self, message, args=None):
- #optimization just in case we already extarcted the args
+ keywords = {}
+
+ if self.sender_keyword is not None:
+ keywords[self.sender_keyword] = message.get_sender()
+ if self.path_keyword is not None:
+ keywords[self.path_keyword] = message.get_path()
+
+ # optimization just in case we already extracted the args
if not args:
args = message.get_args_list()
for handler in self.handler_functions:
if getattr(handler, "_dbus_pass_message", False):
- keywords = {"dbus_message": message}
- handler(*args, **keywords)
- else:
+ keywords["dbus_message"] = message
+
+ if len(keywords) == 0:
handler(*args)
+ else:
+ handler(*args, **keywords)
def add_handler(self, handler):
self.handler_functions.append(handler)