|
David Zeuthen |
036dffd |
From: David Zeuthen <davidz@redhat.com>
|
|
David Zeuthen |
036dffd |
Date: Sat, 15 Mar 2008 19:32:56 +0000 (-0400)
|
|
David Zeuthen |
036dffd |
Subject: Add new function to specify the default timeout for a proxy
|
|
David Zeuthen |
036dffd |
X-Git-Url: http://gitweb.freedesktop.org/?p=dbus/dbus-glib.git;a=commitdiff;h=bf0c9b3d6adc95863d5b5a4ce6ca994fd7fdc137
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
Add new function to specify the default timeout for a proxy
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
Without a function like this the generated client glue code is
|
|
David Zeuthen |
036dffd |
unusable for D-Bus methods that take a long time to complete (such as
|
|
David Zeuthen |
036dffd |
disk operations like mkfs and partitioning).
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
Also add some missing _with_timeout functions on DBusGProxy to the gtk
|
|
David Zeuthen |
036dffd |
docs.
|
|
David Zeuthen |
036dffd |
---
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
--- a/dbus/dbus-glib.h
|
|
David Zeuthen |
036dffd |
+++ b/dbus/dbus-glib.h
|
|
David Zeuthen |
036dffd |
@@ -252,6 +252,9 @@ DBusGProxyCall * dbus_g_proxy_begin_call
|
|
David Zeuthen |
036dffd |
GType first_arg_type,
|
|
David Zeuthen |
036dffd |
...);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
+void dbus_g_proxy_set_default_timeout (DBusGProxy *proxy,
|
|
David Zeuthen |
036dffd |
+ int timeout);
|
|
David Zeuthen |
036dffd |
+
|
|
David Zeuthen |
036dffd |
gboolean dbus_g_proxy_end_call (DBusGProxy *proxy,
|
|
David Zeuthen |
036dffd |
DBusGProxyCall *call,
|
|
David Zeuthen |
036dffd |
GError **error,
|
|
David Zeuthen |
036dffd |
--- a/dbus/dbus-gproxy.c
|
|
David Zeuthen |
036dffd |
+++ b/dbus/dbus-gproxy.c
|
|
David Zeuthen |
036dffd |
@@ -73,6 +73,8 @@ struct _DBusGProxyPrivate
|
|
David Zeuthen |
036dffd |
GData *signal_signatures; /**< D-BUS signatures for each signal */
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
GHashTable *pending_calls; /**< Calls made on this proxy which have not yet returned */
|
|
David Zeuthen |
036dffd |
+
|
|
David Zeuthen |
036dffd |
+ int default_timeout; /**< Default timeout to use, see dbus_g_proxy_set_default_timeout */
|
|
David Zeuthen |
036dffd |
};
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
static void dbus_g_proxy_init (DBusGProxy *proxy);
|
|
David Zeuthen |
036dffd |
@@ -1315,6 +1317,7 @@ dbus_g_proxy_init (DBusGProxy *proxy)
|
|
David Zeuthen |
036dffd |
(GDestroyNotify) dbus_pending_call_unref);
|
|
David Zeuthen |
036dffd |
priv->name_call = 0;
|
|
David Zeuthen |
036dffd |
priv->associated = FALSE;
|
|
David Zeuthen |
036dffd |
+ priv->default_timeout = -1;
|
|
David Zeuthen |
036dffd |
}
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
static GObject *
|
|
David Zeuthen |
036dffd |
@@ -2377,6 +2380,7 @@ dbus_g_proxy_begin_call (DBusGProxy
|
|
David Zeuthen |
036dffd |
guint call_id;
|
|
David Zeuthen |
036dffd |
va_list args;
|
|
David Zeuthen |
036dffd |
GValueArray *arg_values;
|
|
David Zeuthen |
036dffd |
+ DBusGProxyPrivate *priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL);
|
|
David Zeuthen |
036dffd |
g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), NULL);
|
|
David Zeuthen |
036dffd |
@@ -2385,7 +2389,7 @@ dbus_g_proxy_begin_call (DBusGProxy
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
DBUS_G_VALUE_ARRAY_COLLECT_ALL (arg_values, first_arg_type, args);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
- call_id = dbus_g_proxy_begin_call_internal (proxy, method, notify, user_data, destroy, arg_values,-1);
|
|
David Zeuthen |
036dffd |
+ call_id = dbus_g_proxy_begin_call_internal (proxy, method, notify, user_data, destroy, arg_values, priv->default_timeout);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
g_value_array_free (arg_values);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
@@ -2515,15 +2519,18 @@ dbus_g_proxy_call (DBusGProxy *pr
|
|
David Zeuthen |
036dffd |
guint call_id;
|
|
David Zeuthen |
036dffd |
va_list args;
|
|
David Zeuthen |
036dffd |
GValueArray *in_args;
|
|
David Zeuthen |
036dffd |
+ DBusGProxyPrivate *priv;
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), FALSE);
|
|
David Zeuthen |
036dffd |
g_return_val_if_fail (!DBUS_G_PROXY_DESTROYED (proxy), FALSE);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
+ priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
|
|
David Zeuthen |
036dffd |
+
|
|
David Zeuthen |
036dffd |
va_start (args, first_arg_type);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
DBUS_G_VALUE_ARRAY_COLLECT_ALL (in_args, first_arg_type, args);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
- call_id = dbus_g_proxy_begin_call_internal (proxy, method, NULL, NULL, NULL, in_args,-1);
|
|
David Zeuthen |
036dffd |
+ call_id = dbus_g_proxy_begin_call_internal (proxy, method, NULL, NULL, NULL, in_args, priv->default_timeout);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
g_value_array_free (in_args);
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
@@ -2889,6 +2896,30 @@ dbus_g_proxy_disconnect_signal (DBusGPro
|
|
David Zeuthen |
036dffd |
g_free (name);
|
|
David Zeuthen |
036dffd |
}
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
+/**
|
|
David Zeuthen |
036dffd |
+ * dbus_g_proxy_set_default_timeout:
|
|
David Zeuthen |
036dffd |
+ * @proxy: a proxy for a remote interface
|
|
David Zeuthen |
036dffd |
+ * @timeout: specify the timeout in milliseconds
|
|
David Zeuthen |
036dffd |
+ *
|
|
David Zeuthen |
036dffd |
+ * Sets the default timeout to use for a proxy. This timeout will be
|
|
David Zeuthen |
036dffd |
+ * used in calls where the timeout is not specified.
|
|
David Zeuthen |
036dffd |
+ *
|
|
David Zeuthen |
036dffd |
+ * Since: 0.75
|
|
David Zeuthen |
036dffd |
+ */
|
|
David Zeuthen |
036dffd |
+void
|
|
David Zeuthen |
036dffd |
+dbus_g_proxy_set_default_timeout (DBusGProxy *proxy,
|
|
David Zeuthen |
036dffd |
+ int timeout)
|
|
David Zeuthen |
036dffd |
+{
|
|
David Zeuthen |
036dffd |
+ DBusGProxyPrivate *priv;
|
|
David Zeuthen |
036dffd |
+
|
|
David Zeuthen |
036dffd |
+ g_return_if_fail (DBUS_IS_G_PROXY (proxy));
|
|
David Zeuthen |
036dffd |
+ g_return_if_fail (!DBUS_G_PROXY_DESTROYED (proxy));
|
|
David Zeuthen |
036dffd |
+
|
|
David Zeuthen |
036dffd |
+ priv = DBUS_G_PROXY_GET_PRIVATE(proxy);
|
|
David Zeuthen |
036dffd |
+ priv->default_timeout = timeout;
|
|
David Zeuthen |
036dffd |
+}
|
|
David Zeuthen |
036dffd |
+
|
|
David Zeuthen |
036dffd |
+
|
|
David Zeuthen |
036dffd |
/** @} End of DBusGLib public */
|
|
David Zeuthen |
036dffd |
|
|
David Zeuthen |
036dffd |
#ifdef DBUS_BUILD_TESTS
|