aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2013-02-28 20:33:29 +0100
committerdavemds <dave@gurumeditation.it>2013-02-28 20:33:29 +0100
commit8ecd30d578ebac46bbdf5f6d5c0b7cad1187f84f (patch)
treeb629f6fa84333521949238a0503d6d6ba03172f3
parent5dc2d7c126b8e353e016a4687686d545648086ae (diff)
downloadefl-8ecd30d578ebac46bbdf5f6d5c0b7cad1187f84f.tar.gz
efl-8ecd30d578ebac46bbdf5f6d5c0b7cad1187f84f.tar.xz
efl-8ecd30d578ebac46bbdf5f6d5c0b7cad1187f84f.zip
Add a new API to edbus to let it create an EDbus session from
an existing DBus connection. This is needed by the python bindings, was done the same way in edbus1, so it should fit here also NOTE: I did not test this yet, and I'm not into the edbus code, so I please who know the code to give a look. thanks NOTE2: I don't think this need Changelog and stuff as we are probably the only users of this function, let me know if i'm wrong
-rw-r--r--src/lib/edbus/edbus_connection.h11
-rw-r--r--src/lib/edbus/edbus_core.c28
2 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/edbus/edbus_connection.h b/src/lib/edbus/edbus_connection.h
index 5573f204a..72152321c 100644
--- a/src/lib/edbus/edbus_connection.h
+++ b/src/lib/edbus/edbus_connection.h
@@ -59,6 +59,17 @@ EAPI EDBus_Connection *edbus_connection_ref(EDBus_Connection *conn) EINA_ARG_NON
EAPI void edbus_connection_unref(EDBus_Connection *conn) EINA_ARG_NONNULL(1);
/**
+ * Integrate an existing DBus connection with the ecore main loop
+ *
+ * @param type - type of bus
+ * @param conn - a dbus connection (must be a DBusConnection *)
+ *
+ * @note this is a low-level function, it is meant to be used by language
+ * bindings, don't use unless you know what are you doing!
+ */
+EAPI EDBus_Connection *edbus_connection_from_dbus_connection(EDBus_Connection_Type type, void *conn);
+
+/**
* @brief Add a callback function to be called when connection is freed
*
* @param conn The connection object to add the callback to.
diff --git a/src/lib/edbus/edbus_core.c b/src/lib/edbus/edbus_core.c
index 2fb5c6dc3..6f8daf8d7 100644
--- a/src/lib/edbus/edbus_core.c
+++ b/src/lib/edbus/edbus_core.c
@@ -976,6 +976,34 @@ _connection_get(EDBus_Connection_Type type)
}
EAPI EDBus_Connection *
+edbus_connection_from_dbus_connection(EDBus_Connection_Type type, void *conn)
+{
+ EDBus_Connection *econn;
+ EDBus_Object *obj;
+
+ EINA_SAFETY_ON_FALSE_RETURN_VAL((type < EDBUS_CONNECTION_TYPE_LAST) &&
+ (type > EDBUS_CONNECTION_TYPE_UNKNOWN), NULL);
+
+ econn = calloc(1, sizeof(EDBus_Connection));
+ EINA_SAFETY_ON_NULL_RETURN_VAL(econn, NULL);
+
+ econn->dbus_conn = (DBusConnection*) conn;
+ edbus_connection_setup(econn);
+ econn->type = type;
+ econn->refcount = 1;
+ EINA_MAGIC_SET(econn, EDBUS_CONNECTION_MAGIC);
+ econn->names = eina_hash_string_superfast_new(NULL);
+
+ edbus_signal_handler_add(econn, NULL, DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL,
+ "Disconnected", _disconnected, econn);
+ obj = edbus_object_get(econn, EDBUS_FDO_BUS, EDBUS_FDO_PATH);
+ econn->fdo_proxy = edbus_proxy_get(obj, EDBUS_FDO_INTERFACE);
+
+ DBG("Attached to connection at %p", conn);
+ return econn;
+}
+
+EAPI EDBus_Connection *
edbus_private_connection_get(EDBus_Connection_Type type)
{
return _connection_get(type);