Hello devilhorns
Nice work but there some problems, here 2 patches fixing it.
Right now I don't have my ssh key to push this patches, if you want go
ahead and push it.
Thanks
On Thu, Dec 4, 2014 at 12:49 PM, Christopher Michael
<[email protected]> wrote:
> devilhorns pushed a commit to branch master.
>
> http://git.enlightenment.org/core/efl.git/commit/?id=e62dfdd79ee964a8c6617342831b1fd022e8a3bf
>
> commit e62dfdd79ee964a8c6617342831b1fd022e8a3bf
> Author: Chris Michael <[email protected]>
> Date: Thu Dec 4 09:48:21 2014 -0500
>
> eldbus: Add actual API function code for eldbus_proxy_send_and_block
>
> Summary: This adds the actual code to send a dbus message and block
> while waiting for a reply.
>
> @feature
>
> Signed-off-by: Chris Michael <[email protected]>
> ---
> src/lib/eldbus/eldbus_proxy.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/src/lib/eldbus/eldbus_proxy.c b/src/lib/eldbus/eldbus_proxy.c
> index 785caec..ad32732 100644
> --- a/src/lib/eldbus/eldbus_proxy.c
> +++ b/src/lib/eldbus/eldbus_proxy.c
> @@ -546,6 +546,12 @@ _eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Message
> *msg, Eldbus_Message_Cb c
> return pending;
> }
>
> +static Eldbus_Message *
> +_eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg)
> +{
> + return _eldbus_connection_send_and_block(proxy->obj->conn, msg);
> +}
> +
> EAPI Eldbus_Pending *
> eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Message *msg,
> Eldbus_Message_Cb cb, const void *cb_data, double timeout)
> {
> @@ -556,6 +562,15 @@ eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Message
> *msg, Eldbus_Message_Cb cb
> }
>
> EAPI Eldbus_Message *
> +eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg)
> +{
> + ELDBUS_PROXY_CHECK_RETVAL(proxy, NULL);
> + EINA_SAFETY_ON_NULL_RETURN_VAL(msg, NULL);
> +
> + return _eldbus_proxy_send_and_block(proxy, msg);
> +}
> +
> +EAPI Eldbus_Message *
> eldbus_proxy_method_call_new(Eldbus_Proxy *proxy, const char *member)
> {
> Eldbus_Message *msg;
>
> --
>
>
From 855d7ce7bdc1684f4847cc6001b408859e842957 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= <[email protected]>
Date: Fri, 5 Dec 2014 01:01:37 -0200
Subject: [PATCH 1/2] eldbus: Fix _eldbus_connection_send_and_block()
Some problems with the actual implementation:
- the reply should not be writable, as it can only be read.
- if an error happen dbus_connection_send_with_reply_and_block()
will return NULL so we need check before use it
- all other send calls remove one reference of the message
Now also it is creating a error message, so the caller can know why it fail.
---
src/lib/eldbus/eldbus_pending.c | 29 ++++++++++++++++++-----------
src/lib/eldbus/eldbus_proxy.h | 8 +++-----
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/src/lib/eldbus/eldbus_pending.c b/src/lib/eldbus/eldbus_pending.c
index 87049c5..67c478d 100644
--- a/src/lib/eldbus/eldbus_pending.c
+++ b/src/lib/eldbus/eldbus_pending.c
@@ -161,26 +161,33 @@ _eldbus_connection_send(Eldbus_Connection *conn, Eldbus_Message *msg, Eldbus_Mes
Eldbus_Message *
_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg)
{
- Eldbus_Message *reply;
+ Eldbus_Message *reply = NULL;
+ DBusError err;
+ DBusMessage *dbus_msg;
if (ecore_main_loop_nested_get())
WRN("Calling this function may result in dropped frames because the main loop is running");
- reply = eldbus_message_new(EINA_TRUE);
- EINA_SAFETY_ON_NULL_GOTO(reply, fail);
-
- reply->dbus_msg =
- dbus_connection_send_with_reply_and_block(conn->dbus_conn,
- msg->dbus_msg, -1, NULL);
+ dbus_error_init(&err);
+ dbus_msg = dbus_connection_send_with_reply_and_block(conn->dbus_conn,
+ msg->dbus_msg, -1, &err);
+ EINA_SAFETY_ON_TRUE_GOTO(dbus_error_is_set(&err), dbus_error_set);
+ dbus_error_free(&err);
- dbus_message_iter_init_append(reply->dbus_msg,
- &reply->iterator->dbus_iterator);
+ reply = eldbus_message_new(EINA_FALSE);
+ EINA_SAFETY_ON_NULL_GOTO(reply, fail);
+ reply->dbus_msg = dbus_msg;
+ dbus_message_iter_init(reply->dbus_msg, &reply->iterator->dbus_iterator);
+ eldbus_message_unref(msg);
return reply;
+dbus_error_set:
+ reply = eldbus_message_error_new(msg, err.name, err.message);
+ dbus_error_free(&err);
fail:
- eldbus_message_unref(reply);
- return NULL;
+ eldbus_message_unref(msg);
+ return reply;
}
EAPI void
diff --git a/src/lib/eldbus/eldbus_proxy.h b/src/lib/eldbus/eldbus_proxy.h
index 3552378..69f5806 100644
--- a/src/lib/eldbus/eldbus_proxy.h
+++ b/src/lib/eldbus/eldbus_proxy.h
@@ -117,15 +117,13 @@ EAPI Eldbus_Message *eldbus_proxy_method_call_new(Eldbus_Proxy *proxy, co
EAPI Eldbus_Pending *eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Message *msg, Eldbus_Message_Cb cb, const void *cb_data, double timeout) EINA_ARG_NONNULL(1, 2);
/**
- * @brief Send a message and block while waiting for the reply
+ * @brief Send a message and block while waiting for the reply.
*
* @param proxy the msg will be send in connection that proxy belongs
* @param msg message that will be send
- * @param cb if msg is a method call a callback should be passed
- * @param cb_data data passed to callback
- *
- * @return A Eldbus_Pending object on the sent message.
*
+ * @return The reply message, error message or NULL.
+ * The returned Eldbus_Message need to be unref after read.
* @since 1.13
*/
EAPI Eldbus_Message *eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg) EINA_ARG_NONNULL(1, 2);
--
2.1.3
From 5d941762f68c80fecc9735580d743605ff5d96e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= <[email protected]>
Date: Fri, 5 Dec 2014 01:04:20 -0200
Subject: [PATCH 2/2] eldbus: Add timeout parameter to
eldbus_proxy_send_and_block()
As all other send functions have, we need to have here.
---
src/lib/eldbus/eldbus_pending.c | 2 +-
src/lib/eldbus/eldbus_private.h | 2 +-
src/lib/eldbus/eldbus_proxy.c | 8 ++++----
src/lib/eldbus/eldbus_proxy.h | 4 +++-
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/lib/eldbus/eldbus_pending.c b/src/lib/eldbus/eldbus_pending.c
index 67c478d..9db56af 100644
--- a/src/lib/eldbus/eldbus_pending.c
+++ b/src/lib/eldbus/eldbus_pending.c
@@ -159,7 +159,7 @@ _eldbus_connection_send(Eldbus_Connection *conn, Eldbus_Message *msg, Eldbus_Mes
}
Eldbus_Message *
-_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg)
+_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg, double timeout)
{
Eldbus_Message *reply = NULL;
DBusError err;
diff --git a/src/lib/eldbus/eldbus_private.h b/src/lib/eldbus/eldbus_private.h
index 1a75ac3..7b4bdde 100644
--- a/src/lib/eldbus/eldbus_private.h
+++ b/src/lib/eldbus/eldbus_private.h
@@ -73,7 +73,7 @@ Eldbus_Connection_Name *eldbus_connection_name_get(Eldbus_Connection *conn, cons
void eldbus_connection_name_owner_monitor(Eldbus_Connection *conn, Eldbus_Connection_Name *cn, Eina_Bool enable);
Eldbus_Pending *_eldbus_connection_send(Eldbus_Connection *conn, Eldbus_Message *msg, Eldbus_Message_Cb cb, const void *cb_data, double timeout);
-Eldbus_Message *_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg);
+Eldbus_Message *_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg, double timeout);
Eldbus_Message_Iter *eldbus_message_iter_sub_iter_get(Eldbus_Message_Iter *iter);
Eina_Value *_message_iter_struct_to_eina_value(Eldbus_Message_Iter *iter);
diff --git a/src/lib/eldbus/eldbus_proxy.c b/src/lib/eldbus/eldbus_proxy.c
index ad32732..0d2ba15 100644
--- a/src/lib/eldbus/eldbus_proxy.c
+++ b/src/lib/eldbus/eldbus_proxy.c
@@ -547,9 +547,9 @@ _eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Message *msg, Eldbus_Message_Cb c
}
static Eldbus_Message *
-_eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg)
+_eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg, double timeout)
{
- return _eldbus_connection_send_and_block(proxy->obj->conn, msg);
+ return _eldbus_connection_send_and_block(proxy->obj->conn, msg, timeout);
}
EAPI Eldbus_Pending *
@@ -562,12 +562,12 @@ eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Message *msg, Eldbus_Message_Cb cb
}
EAPI Eldbus_Message *
-eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg)
+eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg, double timeout)
{
ELDBUS_PROXY_CHECK_RETVAL(proxy, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(msg, NULL);
- return _eldbus_proxy_send_and_block(proxy, msg);
+ return _eldbus_proxy_send_and_block(proxy, msg, timeout);
}
EAPI Eldbus_Message *
diff --git a/src/lib/eldbus/eldbus_proxy.h b/src/lib/eldbus/eldbus_proxy.h
index 69f5806..b010aee 100644
--- a/src/lib/eldbus/eldbus_proxy.h
+++ b/src/lib/eldbus/eldbus_proxy.h
@@ -121,12 +121,14 @@ EAPI Eldbus_Pending *eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Messag
*
* @param proxy the msg will be send in connection that proxy belongs
* @param msg message that will be send
+ * @param timeout timeout in milliseconds, -1 to default internal value or
+ * ELDBUS_TIMEOUT_INFINITE for no timeout
*
* @return The reply message, error message or NULL.
* The returned Eldbus_Message need to be unref after read.
* @since 1.13
*/
-EAPI Eldbus_Message *eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg) EINA_ARG_NONNULL(1, 2);
+EAPI Eldbus_Message *eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg, double timeout) EINA_ARG_NONNULL(1, 2);
/**
* @brief Call a method in proxy.
--
2.1.3
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel