[glibmm] DBusProxy: Add a non-cancellable call_sync() method.



commit d848e3c85561e3183d91934e4afc334817b0c74c
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Thu Dec 9 00:13:37 2010 -0500

    	DBusProxy: Add a non-cancellable call_sync() method.
    
    	* gio/src/dbusproxy.{ccg,hg}: Add a non-cancellable call_sync()
    	method.  Reorder the paramters so that the "timeout_msec" parameter in
    	methods that have it can have a default of '-1' which means a default
    	timeout.

 ChangeLog             |    9 +++++++++
 gio/src/dbusproxy.ccg |   37 +++++++++++++++++++++++++++++++------
 gio/src/dbusproxy.hg  |   40 +++++++++++++++++++++++++++++-----------
 3 files changed, 69 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2f770e9..2024937 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-12-09  José Alburquerque  <jaalburqu svn gnome org>
+
+	DBusProxy: Add a non-cancellable call_sync() method.
+
+	* gio/src/dbusproxy.{ccg,hg}: Add a non-cancellable call_sync()
+	method.  Reorder the paramters so that the "timeout_msec" parameter in
+	methods that have it can have a default of '-1' which means a default
+	timeout.
+
 2010-12-08  José Alburquerque  <jaalburqu svn gnome org>
 
 	DBus: Client Example: Choose a better name for the source file.
diff --git a/gio/src/dbusproxy.ccg b/gio/src/dbusproxy.ccg
index c90140f..e597e0c 100644
--- a/gio/src/dbusproxy.ccg
+++ b/gio/src/dbusproxy.ccg
@@ -295,11 +295,12 @@ void DBusProxy::get_cached_property(Glib::VariantBase& property,
 }
 
 void DBusProxy::call(const Glib::ustring& method_name,
-  int timeout_msec,
   const SlotAsyncReady& slot,
   const Glib::RefPtr<Cancellable>& cancellable,
   const Glib::VariantBase& parameters,
-  DBusCallFlags flags)
+  int timeout_msec,
+  DBusCallFlags flags
+)
 {
   // Create a copy of the slot.
   // A pointer to it will be passed through the callback's data parameter
@@ -313,10 +314,11 @@ void DBusProxy::call(const Glib::ustring& method_name,
 }
 
 void DBusProxy::call(const Glib::ustring& method_name,
-  int timeout_msec,
   const SlotAsyncReady& slot,
   const Glib::VariantBase& parameters,
-  DBusCallFlags flags)
+  int timeout_msec,
+  DBusCallFlags flags
+)
 {
   // Create a copy of the slot.
   // A pointer to it will be passed through the callback's data parameter
@@ -343,9 +345,12 @@ void DBusProxy::call_finish(Glib::VariantBase& ret, const Glib::RefPtr<AsyncResu
 }
 
 void DBusProxy::call_sync(Glib::VariantBase& result,
-  const Glib::ustring& method_name, int timeout_msec, DBusCallFlags flags,
+  const Glib::ustring& method_name,
+  const Glib::RefPtr<Cancellable>& cancellable,
   const Glib::VariantBase& parameters, 
-  const Glib::RefPtr<Cancellable>& cancellable)
+  int timeout_msec,
+  DBusCallFlags flags
+)
 {
   GError *g_error = 0;
 
@@ -361,4 +366,24 @@ void DBusProxy::call_sync(Glib::VariantBase& result,
   result.init(g_variant, false /* don't take extra reference */);
 }
 
+void DBusProxy::call_sync(Glib::VariantBase& result,
+  const Glib::ustring& method_name,
+  const Glib::VariantBase& parameters, 
+  int timeout_msec,
+  DBusCallFlags flags
+)
+{
+  GError *g_error = 0;
+
+  GVariant* const g_variant =
+    g_dbus_proxy_call_sync(gobj(), method_name.c_str(), 
+    const_cast<GVariant*>(parameters.gobj()),
+    static_cast<GDBusCallFlags>(flags), timeout_msec, 0, &g_error);
+
+  if(g_error)
+    ::Glib::Error::throw_exception(g_error);
+
+  result.init(g_variant, false /* don't take extra reference */);
+}
+
 } // namespace Gio
diff --git a/gio/src/dbusproxy.hg b/gio/src/dbusproxy.hg
index c03dd54..cd27199 100644
--- a/gio/src/dbusproxy.hg
+++ b/gio/src/dbusproxy.hg
@@ -232,7 +232,7 @@ public:
   _WRAP_METHOD(Glib::ustring get_interface_name() const, g_dbus_proxy_get_interface_name)
 
   _WRAP_METHOD(int get_default_timeout() const, g_dbus_proxy_get_default_timeout)
-  _WRAP_METHOD(void set_default_timeout(int timeout_msec), g_dbus_proxy_set_default_timeout)
+  _WRAP_METHOD(void set_default_timeout(int timeout_msec = -1), g_dbus_proxy_set_default_timeout)
 
   /** Looks up the value for a property from the cache. This call does no
    * blocking IO.
@@ -260,17 +260,23 @@ public:
   _WRAP_METHOD(Glib::RefPtr<const DBusInterfaceInfo> get_interface_info() const, g_dbus_proxy_get_interface_info, constversion)
 
   _WRAP_METHOD_DOCS_ONLY(g_dbus_proxy_call)
-  void call(const Glib::ustring& method_name,
-    int timeout_msec, const SlotAsyncReady& slot,
+  void call(
+    const Glib::ustring& method_name,
+    const SlotAsyncReady& slot,
     const Glib::RefPtr<Cancellable>& cancellable,
     const Glib::VariantBase& parameters = Glib::VariantBase(),
-    DBusCallFlags flags = Gio::DBUS_CALL_FLAGS_NONE);
+    int timeout_msec = -1,
+    DBusCallFlags flags = Gio::DBUS_CALL_FLAGS_NONE
+  );
 
   /// A non-cancellable version of call().
-  void call(const Glib::ustring& method_name,
-    int timeout_msec, const SlotAsyncReady& slot,
+  void call(
+    const Glib::ustring& method_name,
+    const SlotAsyncReady& slot,
     const Glib::VariantBase& parameters = Glib::VariantBase(),
-    DBusCallFlags flags = Gio::DBUS_CALL_FLAGS_NONE);
+    int timeout_msec = -1,
+    DBusCallFlags flags = Gio::DBUS_CALL_FLAGS_NONE
+  );
 
   /** Finishes an operation started with call().
    *
@@ -297,13 +303,25 @@ public:
    *
    * @throw Glib::Error.
    */
-  void call_sync(Glib::VariantBase& result, const Glib::ustring& method_name,
-    int timeout_msec,
-    DBusCallFlags flags = Gio::DBUS_CALL_FLAGS_NONE,
+  void call_sync(
+    Glib::VariantBase& result,
+    const Glib::ustring& method_name,
+    const Glib::RefPtr<Cancellable>& cancellable,
     const Glib::VariantBase& parameters = Glib::VariantBase(),
-    const Glib::RefPtr<Cancellable>& cancellable = Glib::RefPtr<Cancellable>());
+    int timeout_msec = -1,
+    DBusCallFlags flags = Gio::DBUS_CALL_FLAGS_NONE
+  );
   _IGNORE(g_dbus_proxy_call_sync)
 
+  /// A non-cancellable version of call_sync().
+  void call_sync(
+    Glib::VariantBase& result,
+    const Glib::ustring& method_name,
+    const Glib::VariantBase& parameters = Glib::VariantBase(),
+    int timeout_msec = -1,
+    DBusCallFlags flags = Gio::DBUS_CALL_FLAGS_NONE
+  );
+
  _WRAP_PROPERTY("g-bus-type", BusType)
  _WRAP_PROPERTY("g-connection", Glib::RefPtr<DBusConnection>)
  _WRAP_PROPERTY("g-default-timeout", int)



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