eldbus: Add code for _eldbus_connection_send_and_block function
authorChris Michael <cp.michael@samsung.com>
Thu, 4 Dec 2014 14:47:01 +0000 (09:47 -0500)
committerChris Michael <cp.michael@samsung.com>
Thu, 4 Dec 2014 14:49:02 +0000 (09:49 -0500)
Summary: This function will send a message to dbus and block while
waiting for a reply

NB: This is needed for our 'port to libinput', and for our 'opening up the
drm card without systemd' efforts

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/eldbus/eldbus_pending.c

index bf561bbfd2007a2de5ca59a7ff57350fa8e64f1e..87049c53afc5c583ca4536ffb94daf6589cffb0f 100644 (file)
@@ -158,6 +158,31 @@ _eldbus_connection_send(Eldbus_Connection *conn, Eldbus_Message *msg, Eldbus_Mes
    return NULL;
 }
 
+Eldbus_Message *
+_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg)
+{
+   Eldbus_Message *reply;
+
+   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_message_iter_init_append(reply->dbus_msg, 
+                                 &reply->iterator->dbus_iterator);
+
+   return reply;
+
+fail:
+   eldbus_message_unref(reply);
+   return NULL;
+}
+
 EAPI void
 eldbus_pending_data_set(Eldbus_Pending *pending, const char *key, const void *data)
 {