diff options
author | Seth Nickell <seth@gnome.org> | 2003-09-26 10:27:59 +0000 |
---|---|---|
committer | Seth Nickell <seth@gnome.org> | 2003-09-26 10:27:59 +0000 |
commit | c5cf3857b114d0008a6d8191abf389064b5a66fc (patch) | |
tree | e89751f02010ba858424769d2cb9f501ea51099c /python/dbus_bindings.pyx.in | |
parent | 9f2ff915a181585ddeaca079a7cfe057d10a3aed (diff) |
2003-09-26 Seth Nickell <seth@gnome.org>
* python/dbus.py:
* python/examples/example-signals.py:
Start implementing some notions of signals. The API
is really terrible, but they sort of work (with the
exception of being able to filter by service, and to
transmit signals *as* a particular service). Need to
figure out how to make messages come from the service
we registered :-(
* python/dbus_bindings.pyx.in:
Removed duplicate message_handler callbacks.
Diffstat (limited to 'python/dbus_bindings.pyx.in')
-rw-r--r-- | python/dbus_bindings.pyx.in | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/python/dbus_bindings.pyx.in b/python/dbus_bindings.pyx.in index 8feb8678..4ae056c5 100644 --- a/python/dbus_bindings.pyx.in +++ b/python/dbus_bindings.pyx.in @@ -65,7 +65,7 @@ cdef void cunregister_function_handler (DBusConnection *connection, void *user_data): tup = <object>user_data assert (type(tup) == list) - function = tup[0] + function = tup[1] args = [Connection(_conn=<object>connection)] function(*args) @@ -74,7 +74,7 @@ cdef DBusHandlerResult cmessage_function_handler (DBusConnection *connection, void *user_data): tup = <object>user_data assert (type(tup) == list) - function = tup[1] + function = tup[0] message = Message(_create=0) message._set_msg(<object>msg) args = [Connection(_conn=<object>connection), @@ -84,20 +84,6 @@ cdef DBusHandlerResult cmessage_function_handler (DBusConnection *connection, retval = DBUS_HANDLER_RESULT_HANDLED return retval -cdef DBusHandlerResult chandle_message_function_handler (DBusConnection *connection, - DBusMessage *msg, - void *user_data): - function = <object>user_data - assert (type(function) == function) - messagein = Message(_create=0) - messagein._set_msg(<object>msg) - args = [Connection(_conn=<object>connection), - messagein] - retval = function(*args) - if (retval == None): - retval = DBUS_HANDLER_RESULT_HANDLED - return retval - cdef class Connection: cdef DBusConnection *conn @@ -258,10 +244,14 @@ cdef class Connection: # FIXME: set_dispatch_status_function, get_unix_user, set_unix_user_function - def add_filter(self, function): + def add_filter(self, filter_function): + user_data = [ filter_function ] + global _user_data_references + _user_data_references.append(user_data) + return dbus_connection_add_filter(self.conn, - chandle_message_function_handler, - <void*>function, + cmessage_function_handler, + <void*>user_data, NULL) @@ -298,7 +288,7 @@ cdef class Connection: cvtable.unregister_function = cunregister_function_handler cvtable.message_function = cmessage_function_handler - user_data = [unregister_cb, message_cb] + user_data = [message_cb, unregister_cb] global _user_data_references _user_data_references.append(user_data) @@ -314,7 +304,7 @@ cdef class Connection: cvtable.unregister_function = cunregister_function_handler cvtable.message_function = cmessage_function_handler - user_data = [unregister_cb, message_cb] + user_data = [message_cb, unregister_cb] global _user_data_references _user_data_references.append(user_data) @@ -906,4 +896,22 @@ def bus_service_exists(connection, service_name): raise DBusException, error.message return retval +def bus_add_match(connection, rule): + cdef DBusError error + dbus_error_init(&error) + + conn = connection._get_conn() + dbus_bus_add_match (<DBusConnection*>conn, rule, &error) + + if dbus_error_is_set(&error): + raise DBusException, error.message + +def bus_remove_match(connection, rule): + cdef DBusError error + dbus_error_init(&error) + conn = connection._get_conn() + dbus_bus_remove_match (<DBusConnection*>conn, rule, &error) + + if dbus_error_is_set(&error): + raise DBusException, error.message |