From d05347bb91888d3815d1af1f1993a9d3b6734692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Tue, 11 Dec 2012 19:51:38 +0000 Subject: [PATCH] edbus: Keep only one reference of object and proxy of dbus daemon interface per connection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by: José Roberto de Souza SVN revision: 80706 --- legacy/edbus/src/lib/edbus_core.c | 3 +++ legacy/edbus/src/lib/edbus_freedesktop.c | 23 +++++++--------------- legacy/edbus/src/lib/edbus_private_types.h | 1 + 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/legacy/edbus/src/lib/edbus_core.c b/legacy/edbus/src/lib/edbus_core.c index 0d3969a694..e948889cdd 100644 --- a/legacy/edbus/src/lib/edbus_core.c +++ b/legacy/edbus/src/lib/edbus_core.c @@ -921,6 +921,7 @@ _connection_get(EDBus_Connection_Type type) { EDBus_Connection *conn; DBusError err; + EDBus_Object *obj; EINA_SAFETY_ON_FALSE_RETURN_VAL((type < EDBUS_CONNECTION_TYPE_LAST) && (type > EDBUS_CONNECTION_TYPE_UNKNOWN), NULL); @@ -945,6 +946,8 @@ _connection_get(EDBus_Connection_Type type) edbus_signal_handler_add(conn, NULL, DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL, "Disconnected", _disconnected, conn); + obj = edbus_object_get(conn, EDBUS_FDO_BUS, EDBUS_FDO_PATH); + conn->daemon = edbus_proxy_get(obj, EDBUS_FDO_INTERFACE); DBG("Returned new connection at %p", conn); return conn; diff --git a/legacy/edbus/src/lib/edbus_freedesktop.c b/legacy/edbus/src/lib/edbus_freedesktop.c index 65e76b5bfc..50f050637a 100644 --- a/legacy/edbus/src/lib/edbus_freedesktop.c +++ b/legacy/edbus/src/lib/edbus_freedesktop.c @@ -2,22 +2,13 @@ #include "edbus_private_types.h" #include -static EDBus_Proxy * -get_freedesktop_proxy(EDBus_Connection *conn) -{ - EDBus_Object *freedesktop_obj; - - freedesktop_obj = edbus_object_get(conn, EDBUS_FDO_BUS, EDBUS_FDO_PATH); - return edbus_proxy_get(freedesktop_obj, EDBUS_FDO_INTERFACE); -} - EAPI EDBus_Pending * edbus_name_request(EDBus_Connection *conn, const char *name, unsigned int flags, EDBus_Message_Cb cb, const void *cb_data) { EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); - return edbus_proxy_call(get_freedesktop_proxy(conn), "RequestName", cb, + return edbus_proxy_call(conn->daemon, "RequestName", cb, cb_data, -1, "su", name, flags); } @@ -27,7 +18,7 @@ edbus_name_release(EDBus_Connection *conn, const char *name, EDBus_Message_Cb cb EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); - return edbus_proxy_call(get_freedesktop_proxy(conn), "ReleaseName", cb, + return edbus_proxy_call(conn->daemon, "ReleaseName", cb, cb_data, -1, "s", name); } @@ -37,7 +28,7 @@ edbus_name_owner_get(EDBus_Connection *conn, const char *name, EDBus_Message_Cb EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); - return edbus_proxy_call(get_freedesktop_proxy(conn), "GetNameOwner", cb, + return edbus_proxy_call(conn->daemon, "GetNameOwner", cb, cb_data, -1, "s", name); } @@ -47,7 +38,7 @@ edbus_name_owner_has(EDBus_Connection *conn, const char *name, EDBus_Message_Cb EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); - return edbus_proxy_call(get_freedesktop_proxy(conn), "NameHasOwner", cb, + return edbus_proxy_call(conn->daemon, "NameHasOwner", cb, cb_data, -1, "s", name); } @@ -56,7 +47,7 @@ edbus_names_list(EDBus_Connection *conn, EDBus_Message_Cb cb, const void *cb_dat { EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL); - return edbus_proxy_call(get_freedesktop_proxy(conn), "ListNames", cb, + return edbus_proxy_call(conn->daemon, "ListNames", cb, cb_data, -1, ""); } @@ -65,7 +56,7 @@ edbus_names_activatable_list(EDBus_Connection *conn, EDBus_Message_Cb cb, const { EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL); - return edbus_proxy_call(get_freedesktop_proxy(conn), "ListActivatableNames", cb, + return edbus_proxy_call(conn->daemon, "ListActivatableNames", cb, cb_data, -1, ""); } @@ -75,7 +66,7 @@ edbus_name_start(EDBus_Connection *conn, const char *name, unsigned int flags, E EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); - return edbus_proxy_call(get_freedesktop_proxy(conn), "StartServiceByName", cb, + return edbus_proxy_call(conn->daemon, "StartServiceByName", cb, cb_data, -1, "su", name, flags); } diff --git a/legacy/edbus/src/lib/edbus_private_types.h b/legacy/edbus/src/lib/edbus_private_types.h index 1c7b3b30be..4c3d86fd62 100644 --- a/legacy/edbus/src/lib/edbus_private_types.h +++ b/legacy/edbus/src/lib/edbus_private_types.h @@ -61,6 +61,7 @@ struct _EDBus_Connection Ecore_Idler *idler; EDBus_Connection_Context_Event event_handlers[EDBUS_CONNECTION_EVENT_LAST]; Eina_Inlist *root_objs;//service_object + EDBus_Proxy *daemon; }; struct _EDBus_Object