[PATCH] Add new function to specify the default timeout for a proxy

David Zeuthen davidz at redhat.com
Sat Mar 15 12:32:56 PDT 2008


Without a function like this the generated client glue code is
unusable for D-Bus methods that take a long time to complete (such as
disk operations like mkfs and partitioning).

Also add some missing _with_timeout functions on DBusGProxy to the gtk
docs.
---
 dbus/dbus-glib.h                         |    3 ++
 dbus/dbus-gproxy.c                       |   35 ++++++++++++++++++++++++++++-
 doc/reference/dbus-glib-sections.txt     |    3 ++
 doc/reference/dbus-glib-undocumented.txt |   15 +++++++++---
 4 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h
index 633c173..b1084ba 100644
--- a/dbus/dbus-glib.h
+++ b/dbus/dbus-glib.h
@@ -252,6 +252,9 @@ DBusGProxyCall * dbus_g_proxy_begin_call_with_timeout (DBusGProxy        *proxy,
                                                        GType             first_arg_type,
 				                       ...);
 
+void              dbus_g_proxy_set_default_timeout   (DBusGProxy        *proxy,
+                                                      int                timeout);
+
 gboolean          dbus_g_proxy_end_call              (DBusGProxy        *proxy,
                                                       DBusGProxyCall    *call,
                                                       GError           **error,
diff --git a/dbus/dbus-gproxy.c b/dbus/dbus-gproxy.c
index 1244151..b6c9ce6 100644
--- a/dbus/dbus-gproxy.c
+++ b/dbus/dbus-gproxy.c
@@ -73,6 +73,8 @@ struct _DBusGProxyPrivate
   GData *signal_signatures;   /**< D-BUS signatures for each signal */
 
   GHashTable *pending_calls;  /**< Calls made on this proxy which have not yet returned */
+
+  int default_timeout; /**< Default timeout to use, see dbus_g_proxy_set_default_timeout */
 };
 
 static void dbus_g_proxy_init               (DBusGProxy      *proxy);
@@ -1315,6 +1317,7 @@ dbus_g_proxy_init (DBusGProxy *proxy)
 				(GDestroyNotify) dbus_pending_call_unref);
   priv->name_call = 0;
   priv->associated = FALSE;
+  priv->default_timeout = -1;
 }
 
 static GObject *
@@ -2377,6 +2380,7 @@ dbus_g_proxy_begin_call (DBusGProxy          *proxy,
   guint call_id;
   va_list args;
   GValueArray *arg_values;
+  DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
   
   g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
   g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL);
@@ -2385,7 +2389,7 @@ dbus_g_proxy_begin_call (DBusGProxy          *proxy,
 
   DBUS_G_VALUE_ARRAY_COLLECT_ALL (arg_values, first_arg_type, args);
   
-  call_id = dbus_g_proxy_begin_call_internal (proxy, method, notify, user_data, destroy, arg_values,-1);
+  call_id = dbus_g_proxy_begin_call_internal (proxy, method, notify, user_data, destroy, arg_values, priv->default_timeout);
 
   g_value_array_free (arg_values);
 
@@ -2515,15 +2519,18 @@ dbus_g_proxy_call (DBusGProxy        *proxy,
   guint call_id;
   va_list args;
   GValueArray *in_args;
+  DBusGProxyPrivate *priv;
 
   g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), FALSE);
   g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), FALSE);
 
+  priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
+
   va_start (args, first_arg_type);
 
   DBUS_G_VALUE_ARRAY_COLLECT_ALL (in_args, first_arg_type, args);
 
-  call_id = dbus_g_proxy_begin_call_internal (proxy, method, NULL, NULL, NULL, in_args,-1);
+  call_id = dbus_g_proxy_begin_call_internal (proxy, method, NULL, NULL, NULL, in_args, priv->default_timeout);
 
   g_value_array_free (in_args);
 
@@ -2889,6 +2896,30 @@ dbus_g_proxy_disconnect_signal (DBusGProxy             *proxy,
   g_free (name);
 }
 
+/**
+ * dbus_g_proxy_set_default_timeout:
+ * @proxy: a proxy for a remote interface
+ * @timeout: specify the timeout in milliseconds
+ *
+ * Sets the default timeout to use for a proxy. This timeout will be
+ * used in calls where the timeout is not specified.
+ *
+ * Since: 0.75
+ */
+void
+dbus_g_proxy_set_default_timeout (DBusGProxy        *proxy,
+                                  int                timeout)
+{
+  DBusGProxyPrivate *priv;
+
+  g_return_if_fail (DBUS_IS_G_PROXY (proxy));
+  g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
+
+  priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
+  priv->default_timeout = timeout;
+}
+
+
 /** @} End of DBusGLib public */
 
 #ifdef DBUS_BUILD_TESTS
diff --git a/doc/reference/dbus-glib-sections.txt b/doc/reference/dbus-glib-sections.txt
index 67beb77..b1ce190 100644
--- a/doc/reference/dbus-glib-sections.txt
+++ b/doc/reference/dbus-glib-sections.txt
@@ -80,10 +80,13 @@ dbus_g_proxy_connect_signal
 dbus_g_proxy_disconnect_signal
 dbus_g_proxy_send
 dbus_g_proxy_call
+dbus_g_proxy_call_with_timeout
 dbus_g_proxy_call_no_reply
 dbus_g_proxy_begin_call
+dbus_g_proxy_begin_call_with_timeout
 dbus_g_proxy_end_call
 dbus_g_proxy_cancel_call
+dbus_g_proxy_set_default_timeout
 <SUBSECTION Standard>
 DBUS_G_PROXY
 DBUS_IS_G_PROXY
diff --git a/doc/reference/dbus-glib-undocumented.txt b/doc/reference/dbus-glib-undocumented.txt
index f3c4775..225377c 100644
--- a/doc/reference/dbus-glib-undocumented.txt
+++ b/doc/reference/dbus-glib-undocumented.txt
@@ -1,7 +1,7 @@
-77% symbol docs coverage.
-90 symbols documented.
-18 symbols incomplete.
-27 not documented.
+73% symbol docs coverage.
+88 symbols documented.
+20 symbols incomplete.
+32 not documented.
 
 
 DBUS_TYPE_G_OBJECT_PATH
@@ -37,8 +37,10 @@ dbus_g_object_path_get_g_type
 dbus_g_object_register_marshaller (Varargs)
 dbus_g_proxy_add_signal (Varargs)
 dbus_g_proxy_begin_call (data, Varargs)
+dbus_g_proxy_begin_call_with_timeout (Varargs)
 dbus_g_proxy_call (Varargs)
 dbus_g_proxy_call_no_reply (Varargs)
+dbus_g_proxy_call_with_timeout (Varargs)
 dbus_g_proxy_end_call (Varargs)
 dbus_g_proxy_get_path
 dbus_g_proxy_new_for_name (path, interface)
@@ -46,6 +48,11 @@ dbus_g_proxy_new_for_name_owner (path, interface)
 dbus_g_proxy_new_from_proxy (path_name)
 dbus_g_type_collection_get_fixed (value, data, len, Returns)
 dbus_g_type_collection_peek_vtable (Returns)
+dbus_g_type_get_collection_specialization
+dbus_g_type_get_map_key_specialization
+dbus_g_type_get_map_value_specialization
+dbus_g_type_get_struct_member_type
+dbus_g_type_get_struct_size
 dbus_g_type_map_peek_vtable (Returns)
 dbus_g_type_specialized_init
 dbus_set_g_error (derror)
-- 
1.5.4.3


--=-2MP/ilBGLPAXWe181a7+
Content-Disposition: attachment; filename=0003-Export-the-recently-added-GetAll-method-on-org.fd.patch
Content-Type: application/mbox; name=0003-Export-the-recently-added-GetAll-method-on-org.fd.patch
Content-Transfer-Encoding: 7bit



More information about the dbus mailing list