Hi,
I created a python module to be able to use dbus-python with an ecore
main loop using e_dbus. However, I had to fix the handling of D-Bus
signals in e_dbus. We were returning to D-Bus that all signals were
handled and this was preventing other filters from being called. IOW,
we don't need to handle signals because they're for everyone who cares
about them, so we just do what we want and return
DBUS_HANDLER_RESULT_NOT_YET_HANDLED to D-Bus so other filters can be
run.
This patch also uses dbus_connection_ref (and later
dbus_connection_unref) for storing a pointer to the DBusConnection
structure and dbus_message_ref / dbus_message_unref to manage a
reference to the D-Bus message.
Best regards,
-- Ulisses
Index: proto/e_dbus/src/lib/dbus/e_dbus.c
===================================================================
RCS file: /var/cvs/e/e17/proto/e_dbus/src/lib/dbus/e_dbus.c,v
retrieving revision 1.7
diff -u -r1.7 e_dbus.c
--- proto/e_dbus/src/lib/dbus/e_dbus.c 25 Jul 2007 17:01:01 -0000 1.7
+++ proto/e_dbus/src/lib/dbus/e_dbus.c 17 Sep 2007 18:14:30 -0000
@@ -138,6 +138,26 @@
if (hd->enabled) e_dbus_fd_handler_add(hd);
}
+static E_DBus_Connection *
+_e_dbus_connection_new(DBusConnection *conn)
+{
+ E_DBus_Connection *cd;
+
+ cd = calloc(1, sizeof(E_DBus_Connection));
+ if (!cd) return NULL;
+
+ cd->conn = dbus_connection_ref(conn);
+ cd->conn_name = strdup(dbus_bus_get_unique_name(conn));
+
+ DEBUG(1, "Connected! Name: %s\n", cd->conn_name);
+
+ cd->shared_type = -1;
+ cd->fd_handlers = ecore_list_new();
+ cd->timeouts = ecore_list_new();
+
+ return cd;
+}
+
static void
_e_dbus_connection_free(void *data)
{
@@ -146,8 +166,6 @@
Ecore_Timer *timer;
DEBUG(5, "_e_dbus_connection free!\n");
- if (cd->conn_name) free(cd->conn_name);
-
ecore_list_first_goto(cd->fd_handlers);
while ((fd_handler = ecore_list_next(cd->fd_handlers)))
ecore_main_fd_handler_del(fd_handler);
@@ -161,6 +179,9 @@
if (cd->shared_type != -1)
shared_connections[cd->shared_type] = NULL;
+ if (cd->conn_name) free(cd->conn_name);
+ dbus_connection_unref(cd->conn);
+
free(cd);
}
@@ -333,7 +354,7 @@
static void
e_dbus_message_free(void *data, void *message)
{
- //dbus_message_unref(message);
+ dbus_message_unref(message);
}
static DBusHandlerResult
@@ -359,15 +380,16 @@
DEBUG(3, "error: %s\n", dbus_message_get_error_name(message));
break;
case DBUS_MESSAGE_TYPE_SIGNAL:
- ecore_event_add(E_DBUS_EVENT_SIGNAL, message, e_dbus_message_free, NULL);
- return DBUS_HANDLER_RESULT_HANDLED;
+ ecore_event_add(E_DBUS_EVENT_SIGNAL, dbus_message_ref(message),
+ e_dbus_message_free, NULL);
+ /* don't need to handle signals, they're for everyone who wants them */
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
break;
default:
break;
}
DEBUG(3, "-----------------\n\n");
-
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
@@ -449,17 +471,10 @@
E_DBus_Connection *
e_dbus_connection_setup(DBusConnection *conn)
{
- E_DBus_Connection *cd = NULL;
+ E_DBus_Connection *cd;
- cd = calloc(1, sizeof(E_DBus_Connection));
+ cd = _e_dbus_connection_new(conn);
if (!cd) return NULL;
- cd->shared_type = -1;
- cd->conn = conn;
-
- cd->fd_handlers = ecore_list_new();
- cd->timeouts = ecore_list_new();
- cd->conn_name = strdup(dbus_bus_get_unique_name(cd->conn));
- DEBUG(1, "Connected! Name: %s\n", cd->conn_name);
/* connection_setup */
dbus_connection_set_exit_on_disconnect(cd->conn, FALSE);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel