[glibmm] Gio::DBus::Connection: Add



commit edca3b3b3da20baf9d79b4820a02bc15a08c207f
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Sep 16 13:55:18 2012 +0200

    Gio::DBus::Connection: Add
    
            * gio/src/dbusconnection.[hg|ccg]: Add call(), call_with_unix_fd_finish(),
    and call_finishcall_sync() method overloads that wrap
    g_dbus_connection_call_with_unix_fd_list(),
    g_dbus_connection_call_with_unix_fd_list_finish() and
    g_dbus_connection_call_with_unix_fd_list_sync()
            * tools/m4/convert_gio.m4: Add a necessary conversion.

 ChangeLog                  |   11 ++++++
 gio/src/dbusconnection.ccg |   70 ++++++++++++++++++++++++++++++++++----
 gio/src/dbusconnection.hg  |   80 ++++++++++++++++++++++++++++++++++----------
 tools/m4/convert_gio.m4    |    1 +
 4 files changed, 136 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 66ed1cf..60c4914 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-09-16  Murray Cumming  <murrayc murrayc com>
+
+        Gio::DBus::Connection: Add 
+
+        * gio/src/dbusconnection.[hg|ccg]: Add call(), call_with_unix_fd_finish(), 
+	and call_finishcall_sync() method overloads that wrap 
+	g_dbus_connection_call_with_unix_fd_list(), 
+	g_dbus_connection_call_with_unix_fd_list_finish() and 
+	g_dbus_connection_call_with_unix_fd_list_sync()
+        * tools/m4/convert_gio.m4: Add a necessary conversion.
+
 2012-09-15  Murray Cumming  <murrayc murrayc com>
 
         Simplified lots of code by using the {?} _WRAP_METHOD() syntax.
diff --git a/gio/src/dbusconnection.ccg b/gio/src/dbusconnection.ccg
index 930097e..5ae3ef4 100644
--- a/gio/src/dbusconnection.ccg
+++ b/gio/src/dbusconnection.ccg
@@ -725,9 +725,6 @@ Glib::VariantContainerBase Connection::call_sync(
   return Glib::VariantContainerBase(gvariant, false); //Dont' take an extra reference.
 }
 
-//TODO: Re-add the following two methods when the call_finish() method with a
-//UnixFDList exists.
-#if 0
 #ifdef G_OS_LINUX
 // With a UnixFDList.
 void Connection::call(
@@ -741,8 +738,7 @@ void Connection::call(
   const Glib::ustring&                bus_name,
   int                                 timeout_msec,
   CallFlags                           flags,
-  const Glib::VariantType&            reply_type
-)
+  const Glib::VariantType&            reply_type)
 {
   // Create a copy of the slot.
   // A pointer to it will be passed through the callback's data parameter
@@ -767,8 +763,7 @@ void Connection::call(
   const Glib::ustring&                bus_name,
   int                                 timeout_msec,
   CallFlags                           flags,
-  const Glib::VariantType&            reply_type
-)
+  const Glib::VariantType&            reply_type)
 {
   // Create a copy of the slot.
   // A pointer to it will be passed through the callback's data parameter
@@ -782,7 +777,6 @@ void Connection::call(
     0, &SignalProxy_async_callback, slot_copy);
 }
 #endif // G_OS_LINUX
-#endif // 0
 
 void Connection::emit_signal(
   const Glib::ustring&                object_path,
@@ -884,6 +878,66 @@ guint Connection::register_subtree(const Glib::ustring& object_path,
   return result;
 }
 
+
+Glib::VariantContainerBase Connection::call_sync(const Glib::ustring& object_path, const Glib::ustring& interface_name, 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, const Glib::ustring& bus_name, int timeout_msec, CallFlags flags, const Glib::VariantType& reply_type)
+{
+  GError* gerror = 0;
+  GUnixFDList* cunixfdlist = 0;
+  Glib::VariantContainerBase retvalue = Glib::VariantContainerBase(g_dbus_connection_call_with_unix_fd_list_sync(gobj(), bus_name.c_str(), object_path.c_str(), interface_name.c_str(), method_name.c_str(), const_cast<GVariant*>((parameters).gobj()), (reply_type).gobj(), ((GDBusCallFlags)(flags)), timeout_msec, Glib::unwrap(fd_list), &cunixfdlist, const_cast<GCancellable*>(Glib::unwrap(cancellable)), &(gerror)), false);
+
+  if(cunixfdlist)
+     out_fd_list = Glib::wrap(cunixfdlist);
+
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+
+  return retvalue;
+
+}
+
+Glib::VariantContainerBase Connection::call_sync(const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const Glib::RefPtr<UnixFDList>& fd_list, Glib::RefPtr<UnixFDList>& out_fd_list, const Glib::ustring& bus_name, int timeout_msec, CallFlags flags, const Glib::VariantType& reply_type)
+{
+  GError* gerror = 0;
+  GUnixFDList* cunixfdlist = 0;
+  Glib::VariantContainerBase retvalue = Glib::VariantContainerBase(g_dbus_connection_call_with_unix_fd_list_sync(gobj(), bus_name.c_str(), object_path.c_str(), interface_name.c_str(), method_name.c_str(), const_cast<GVariant*>((parameters).gobj()), (reply_type).gobj(), ((GDBusCallFlags)(flags)), timeout_msec, Glib::unwrap(fd_list), &cunixfdlist, 0, &(gerror)), false);
+
+  if(cunixfdlist)
+     out_fd_list = Glib::wrap(cunixfdlist);
+
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+
+  return retvalue;
+
+}
+
+Glib::VariantContainerBase Connection::call_with_unix_fd_finish(const Glib::RefPtr<AsyncResult>& res, Glib::RefPtr<UnixFDList>& out_fd_list)
+{
+  GError* gerror = 0;
+  GUnixFDList* cunixfdlist = 0;
+  Glib::VariantContainerBase retvalue = Glib::VariantContainerBase(g_dbus_connection_call_with_unix_fd_list_finish(gobj(), &cunixfdlist, Glib::unwrap(res), &(gerror)), false);
+
+  if(cunixfdlist)
+     out_fd_list = Glib::wrap(cunixfdlist);
+
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+
+
+  return retvalue;
+}
+
+Glib::VariantContainerBase Connection::call_with_unix_fd_finish(const Glib::RefPtr<AsyncResult>& res)
+{
+  GError* gerror = 0;
+  Glib::VariantContainerBase retvalue = Glib::VariantContainerBase(g_dbus_connection_call_with_unix_fd_list_finish(gobj(), 0, Glib::unwrap(res), &(gerror)), false);
+
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+
+  return retvalue;
+}
+
 } //namespace DBus
 
 } // namespace Gio
diff --git a/gio/src/dbusconnection.hg b/gio/src/dbusconnection.hg
index d4ab3cd..1be60e7 100644
--- a/gio/src/dbusconnection.hg
+++ b/gio/src/dbusconnection.hg
@@ -732,13 +732,16 @@ public:
     const Glib::VariantType&            reply_type = Glib::VariantType()
   );
 
-// TODO: Re-add the following two methods when the call_finish() method with a
-// UnixFDList is wrapped.
-#if 0
 #ifdef G_OS_LINUX
   /** 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 object_path Path of remote object.
    * @param interface_name D-Bus interface to invoke method on.
    * @param method_name The name of the method to invoke.
@@ -753,7 +756,7 @@ public:
    * timeout or G_MAXINT for no timeout.
    * @param flags Flags from the Gio::DBus::CallFlags enumeration.
    * @param reply_type The expected type of the reply, or <tt>0</tt>.
-   * @newin{2,32}
+   * @newin{2,34}
    */
   void call(
     const Glib::ustring&                object_path,
@@ -768,9 +771,11 @@ public:
     CallFlags                           flags = Gio::DBus::CALL_FLAGS_NONE,
     const Glib::VariantType&            reply_type = Glib::VariantType()
   );
-  _IGNORE(g_dbus_connection_call_with_uinx_fd_list)
+  _IGNORE(g_dbus_connection_call_with_unix_fd_list)
 
-  /// A non-cancellable version of call() (with a UnixFDList).
+  /** A non-cancellable version of call() (with a UnixFDList).
+   * @newin{2,34}
+   */
   void call(
     const Glib::ustring&                object_path,
     const Glib::ustring&                interface_name,
@@ -784,18 +789,27 @@ public:
     const Glib::VariantType&            reply_type = Glib::VariantType()
   );
 #endif // G_OS_LINUX
-#endif // 0
-
-  ///** 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,32}
-   //*/
-  //TODO: _WRAP_METHOD(Glib::VariantContainerBase call_with_unix_fd_finish(const Glib::RefPtr<AsyncResult>& res{.}, Glib::RefPtr<UnixFDList>& out_fd_list{.?}), g_dbus_connection_call_with_unix_fd_list_finish, errthrow)
-
-  /* TODO:
+
+
+  //We do not use _WRAP_METHOD() because it cannot (yet) handle the out_fd_list output parameter:
+  //_WRAP_METHOD(Glib::VariantContainerBase call_with_unix_fd_finish(const Glib::RefPtr<AsyncResult>& res{.}, Glib::RefPtr<UnixFDList>& out_fd_list{.?}), g_dbus_connection_call_with_unix_fd_list_finish, errthrow)
+
+  /** 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,32}
+   */
+  Glib::VariantContainerBase call_with_unix_fd_finish(const Glib::RefPtr<AsyncResult>& res, Glib::RefPtr<UnixFDList>& out_fd_list);
+
+  /// A call_with_unix_fd_finish() convenience overload.
+  Glib::VariantContainerBase call_with_unix_fd_finish(const Glib::RefPtr<AsyncResult>& res);
+  _IGNORE(g_dbus_connection_call_with_unix_fd_list_finish)
+
+
+  //We do not use _WRAP_METHOD() because it cannot (yet) handle the out_fd_list output parameter:
+  /*
   _WRAP_METHOD(
     Glib::VariantContainerBase call_sync(
       const Glib::ustring&                object_path{.},
@@ -814,6 +828,36 @@ public:
   )
   */
 
+  /** Like call_sync() but also takes and returns UnixFDList objects.
+   * 
+   * This method is only available on UNIX.
+   * 
+   * @newin{2,34}
+   * @param bus_name A unique or well-known bus name.
+   * @param object_path Path of remote object.
+   * @param interface_name D-Bus interface to invoke method on.
+   * @param method_name The name of the method to invoke.
+   * @param parameters A Variant tuple with parameters for the method
+   * or <tt>0</tt> if not passing parameters.
+   * @param reply_type The expected type of the reply, or <tt>0</tt>.
+   * @param flags Flags from the DBusCallFlags enumeration.
+   * @param timeout_msec The timeout in milliseconds, -1 to use the default
+   * timeout or MAXINT for no timeout.
+   * @param fd_list A UnixFDList or <tt>0</tt>.
+   * @param out_fd_list Return location for a UnixFDList or <tt>0</tt>.
+   * @param cancellable A Cancellable or <tt>0</tt>.
+   * @return <tt>0</tt> if @a error is set. Otherwise a Variant tuple with
+   * return values. Free with Glib::variant_unref().
+   */
+  Glib::VariantContainerBase call_sync(const Glib::ustring& object_path, const Glib::ustring& interface_name, 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, 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());
+
+  /** A call_sync() convenience overload.
+   * @newin{2,34}
+   */
+  Glib::VariantContainerBase call_sync(const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const Glib::RefPtr<UnixFDList>& fd_list, Glib::RefPtr<UnixFDList>& out_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());
+  _IGNORE(g_dbus_connection_call_with_unix_fd_list_sync)
+
+
   /** Emits a signal.
    *
    * This can only fail if @a parameters is not compatible with the D-Bus
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index e8a6780..4ae5d9f 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -7,6 +7,7 @@ _CONV_ENUM(G,ConverterResult)
 _CONV_ENUM(G,CredentialsType)
 _CONV_ENUM(G,DataStreamByteOrder)
 _CONV_ENUM(G,DataStreamNewlineType)
+_CONV_ENUM(GDBus,CallFlags)
 _CONV_ENUM(GDBus,CapabilityFlags)
 _CONV_ENUM(GDBus,MessageFlags)
 _CONV_ENUM(GDBus,MessageHeaderField)



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