edbus: Keep only one reference of object and proxy of dbus daemon interface per conne...
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>
Tue, 11 Dec 2012 19:51:38 +0000 (19:51 +0000)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 11 Dec 2012 19:51:38 +0000 (19:51 +0000)
Patch by: José Roberto de Souza  <zehortigoza@profusion.mobi>

SVN revision: 80706

legacy/edbus/src/lib/edbus_core.c
legacy/edbus/src/lib/edbus_freedesktop.c
legacy/edbus/src/lib/edbus_private_types.h

index 0d3969a6944850fb09de2b0ba873a49616384679..e948889cdd5787f7bd2865280723e35184bbbf39 100644 (file)
@@ -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;
index 65e76b5bfcd733d44d7c83f301499eeb74feeb1c..50f050637a98e749d08472584d5d3786d95a79b1 100644 (file)
@@ -2,22 +2,13 @@
 #include "edbus_private_types.h"
 #include <dbus/dbus.h>
 
-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);
 }
 
index 1c7b3b30bebcd156f8effcb7bc06b1a09bd7c90a..4c3d86fd62ead5c89242a6bc08fe32c3b266da34 100644 (file)
@@ -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