Enlightenment CVS committal

Author  : barbieri
Project : e17
Module  : proto/e_dbus

Dir     : e17/proto/e_dbus/src/lib/dbus


Modified Files:
        e_dbus.c 


Log Message:
Fix e_dbus signal handling.

In order to be able to integrate ecore and dbus-python using e_dbus we
need to change e_dbus signal handling.

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.

Patch by Ulisses Furquim.

===================================================================
RCS file: /cvs/e/e17/proto/e_dbus/src/lib/dbus/e_dbus.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- e_dbus.c    25 Jul 2007 17:01:01 -0000      1.7
+++ e_dbus.c    26 Sep 2007 14:08:44 -0000      1.8
@@ -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-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to