edbus: Add Disconnected event in connection
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>
Tue, 11 Dec 2012 19:50:29 +0000 (19:50 +0000)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 11 Dec 2012 19:50:29 +0000 (19:50 +0000)
Patch by: José Roberto de Souza  <zehortigoza@profusion.mobi>

SVN revision: 80693

legacy/edbus/src/lib/edbus_connection.h
legacy/edbus/src/lib/edbus_core.c

index 5cbf76d..0b2b44a 100644 (file)
@@ -101,6 +101,7 @@ EAPI void             *edbus_connection_data_del(EDBus_Connection *conn, const c
 typedef enum
 {
    EDBUS_CONNECTION_EVENT_DEL,
+   EDBUS_CONNECTION_DISCONNECTED,
    EDBUS_CONNECTION_EVENT_LAST    /**< sentinel, not a real event type */
 } EDBus_Connection_Event_Type;
 
index 067422c..0d3969a 100644 (file)
@@ -908,6 +908,14 @@ edbus_connection_setup(EDBus_Connection *conn)
                       conn);
 }
 
+static void
+_disconnected(void *data, const EDBus_Message *msg)
+{
+   EDBus_Connection *conn = data;
+   _edbus_connection_event_callback_call(conn, EDBUS_CONNECTION_DISCONNECTED,
+                                         NULL);
+}
+
 static EDBus_Connection *
 _connection_get(EDBus_Connection_Type type)
 {
@@ -935,6 +943,9 @@ _connection_get(EDBus_Connection_Type type)
    EINA_MAGIC_SET(conn, EDBUS_CONNECTION_MAGIC);
    conn->names = eina_hash_string_superfast_new(NULL);
 
+   edbus_signal_handler_add(conn, NULL, DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL,
+                            "Disconnected", _disconnected, conn);
+
    DBG("Returned new connection at %p", conn);
    return conn;
 }