[glibmm] DBus::Proxy: Add call(), call_sync() and call_finish() for unix_fd_list.



commit 66703486a401170afa2cac33abeb3c88940ddd14
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Oct 1 10:22:46 2012 +0200

    DBus::Proxy: Add call(), call_sync() and call_finish() for unix_fd_list.
    
    * gio/src/dbusproxy.[hg|ccg]: Add method overloads for the call methods
    that take a GUnixFDList. This is based on the similar methods in
    dbusconnection.[hg|ccg].

 ChangeLog             |    8 +++++
 gio/src/dbusproxy.ccg |   44 ++++++++++++++++++++++++++++++
 gio/src/dbusproxy.hg  |   72 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 124 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ecdc7f3..1cbabe4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-10-01  Murray Cumming  <murrayc murrayc-desktop>
+
+	DBus::Proxy: Add call(), call_sync() and call_finish() for unix_fd_list.
+
+	* gio/src/dbusproxy.[hg|ccg]: Add method overloads for the call methods
+	that take a GUnixFDList. This is based on the similar methods in
+	dbusconnection.[hg|ccg].
+
 2012-10-01  Murray Cumming  <murrayc murrayc com>
 
 	DBusConnection: Fix a typo in implementation.
diff --git a/gio/src/dbusproxy.ccg b/gio/src/dbusproxy.ccg
index a97fc49..260dd14 100644
--- a/gio/src/dbusproxy.ccg
+++ b/gio/src/dbusproxy.ccg
@@ -364,6 +364,50 @@ Glib::VariantContainerBase Proxy::call_sync(
   return Glib::VariantContainerBase(gvariant, false); //Dont' take an extra reference.
 }
 
+#ifdef G_OS_LINUX
+// With a UnixFDList.
+void Connection::call(
+  const Glib::ustring&                method_name,
+  const Glib::VariantContainerBase&   parameters,
+  const SlotAsyncReady&               slot,
+  const Glib::RefPtr<Cancellable>&    cancellable,
+  const Glib::RefPtr<UnixFDList>&     fd_list,
+  int                                 timeout_msec,
+  CallFlags                           flags)
+{
+  // Create a copy of the slot.
+  // A pointer to it will be passed through the callback's data parameter
+  // and deleted in the callback.
+  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+  g_dbus_proxy_call_with_unix_fd_list(gobj(), method_name.c_str(),
+    const_cast<GVariant*>(parameters.gobj()),
+    static_cast<GDBusCallFlags>(flags), timeout_msec, Glib::unwrap(fd_list),
+    Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy);
+}
+
+// Non-cancellable version (with a UnixFDList).
+void Connection::call(
+  const Glib::ustring&                method_name,
+  const Glib::VariantContainerBase&   parameters,
+  const SlotAsyncReady&               slot,
+  const Glib::RefPtr<UnixFDList>&     fd_list,
+  int                                 timeout_msec,
+  CallFlags                           flags,
+  const Glib::VariantType&            reply_type)
+{
+  // Create a copy of the slot.
+  // A pointer to it will be passed through the callback's data parameter
+  // and deleted in the callback.
+  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+  g_dbus_proxy_call_with_unix_fd_list(gobj(), method_name.c_str(),
+    const_cast<GVariant*>(parameters.gobj()),
+    static_cast<GDBusCallFlags>(flags), timeout_msec, Glib::unwrap(fd_list),
+    0, &SignalProxy_async_callback, slot_copy);
+}
+#endif // G_OS_LINUX
+
 } //namespace DBus
 
 } // namespace Gio
diff --git a/gio/src/dbusproxy.hg b/gio/src/dbusproxy.hg
index a17db05..156fdfb 100644
--- a/gio/src/dbusproxy.hg
+++ b/gio/src/dbusproxy.hg
@@ -291,6 +291,7 @@ public:
    */
   _WRAP_METHOD(Glib::VariantContainerBase call_finish(const Glib::RefPtr<AsyncResult>& res), g_dbus_proxy_call_finish, errthrow)
 
+//TODO: Use _WRAP_METHOD() for this?
   /** Synchronously invokes the method_name method on proxy.
    * See call(), the asynchronous version of this method for more information.
    *
@@ -322,6 +323,77 @@ public:
     CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
   );
 
+
+#ifdef G_OS_LINUX
+//TODO: Use _WRAP_METHOD() for this?
+  /** Like call() but also takes a GUnixFDList object.
+   * This method is only available on UNIX.
+   *
+   * This is an asynchronous method. When the operation is finished, callback
+   * will be invoked in the thread-default main loop of the thread you are
+   * calling this method from. You can then call call_with_unix_fd_finish() to
+   * get the result of the operation. See call_sync() for the synchronous
+   * version of this function.
+   *
+   * @param method_name The name of the method to invoke.
+   * @param parameters A Glib::VariantContainerBase tuple with parameters for the
+   * method or <tt>0</tt> if not passing parameters.
+   * @param slot A SlotAsyncReady to call when the request is satisfied.
+   * @param cancellable A Cancellable.
+   * @param fd_list A UnixFDList.
+   * @param timeout_msec The timeout in milliseconds, -1 to use the default
+   * timeout or G_MAXINT for no timeout.
+   * @param flags Flags from the Gio::DBus::CallFlags enumeration.
+   * @newin{2,34}
+   */
+  void call(
+    const Glib::ustring&                method_name,
+    const Glib::VariantContainerBase&   parameters,
+    const SlotAsyncReady&               slot,
+    const Glib::RefPtr<Cancellable>&    cancellable,
+    const Glib::RefPtr<UnixFDList>&     fd_list,
+    int                                 timeout_msec = -1,
+    CallFlags                           flags = Gio::DBus::CALL_FLAGS_NONE);
+  _IGNORE(g_dbus_proxy_call_with_unix_fd_list)
+
+  /** A non-cancellable version of call() (with a UnixFDList).
+   * @newin{2,34}
+   */
+  void call(
+    const Glib::ustring&                object_path,
+    const Glib::ustring&                interface_name,
+    const Glib::ustring&                method_name,
+    const Glib::VariantContainerBase&   parameters,
+    const SlotAsyncReady&               slot,
+    const Glib::RefPtr<UnixFDList>&     fd_list,
+    const Glib::ustring&                bus_name = Glib::ustring(),
+    int                                 timeout_msec = -1,
+    CallFlags                           flags = Gio::DBus::CALL_FLAGS_NONE,
+    const Glib::VariantType&            reply_type = Glib::VariantType());
+#endif // G_OS_LINUX
+
+  /** Finishes an operation started with call() (with a UnixFDList).
+   * @param res A AsyncResult obtained from the SlotAsyncReady passed to
+   * call().
+   * @result A Variant tuple with return values.
+   * @throw Glib::Error.
+   * @newin{2,34}
+   */
+  _WRAP_METHOD(Glib::VariantContainerBase call_finish(const Glib::RefPtr<AsyncResult>& res{.}, Glib::RefPtr<UnixFDList>& out_fd_list{.>>}), g_dbus_proxy_call_with_unix_fd_list_finish, errthrow)
+
+  _WRAP_METHOD(
+    Glib::VariantContainerBase call_sync(
+      const Glib::ustring&                method_name{.},
+      const Glib::VariantContainerBase&   parameters{.},
+      const Glib::RefPtr<Cancellable>&    cancellable{.?},
+      const Glib::RefPtr<UnixFDList>&     fd_list{.},
+      Glib::RefPtr<UnixFDList>&           out_fd_list{.>>},
+      int                                 timeout_msec{.} = -1,
+      CallFlags                           flags{.} = Gio::DBus::CALL_FLAGS_NONE
+    ),
+    g_dbus_proxy_call_with_unix_fd_list_sync, errthrow
+  )
+
  //_WRAP_PROPERTY("g-bus-type", BusType) // write-only construct-only
  _WRAP_PROPERTY("g-connection", Glib::RefPtr<Connection>)
  _WRAP_PROPERTY("g-default-timeout", int)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]