[evolution-ews] EEwsConnection: Add a "proxy-resolver" property.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] EEwsConnection: Add a "proxy-resolver" property.
- Date: Fri, 25 Oct 2013 17:29:07 +0000 (UTC)
commit dd1f947419ea94261da37f983d82325aa4fcc94c
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Oct 10 10:58:47 2013 -0400
EEwsConnection: Add a "proxy-resolver" property.
This property is bound to the internal SoupSession's "proxy-resolver".
The EEwsConnection's "proxy-resolver" property can then be bound to
the "proxy-resolver" property of one of the EDS base backend classes.
src/server/e-ews-connection.c | 82 +++++++++++++++++++++++++++++++++++++++++
src/server/e-ews-connection.h | 6 +++
2 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 6d3af70..8c7bb66 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -81,6 +81,7 @@ struct _EEwsConnectionPrivate {
GThread *soup_thread;
GMainLoop *soup_loop;
GMainContext *soup_context;
+ GProxyResolver *proxy_resolver;
CamelEwsSettings *settings;
GMutex property_lock;
@@ -103,6 +104,7 @@ struct _EEwsConnectionPrivate {
enum {
PROP_0,
PROP_PASSWORD,
+ PROP_PROXY_RESOLVER,
PROP_SETTINGS
};
@@ -1448,6 +1450,12 @@ ews_connection_set_property (GObject *object,
g_value_get_string (value));
return;
+ case PROP_PROXY_RESOLVER:
+ e_ews_connection_set_proxy_resolver (
+ E_EWS_CONNECTION (object),
+ g_value_get_object (value));
+ return;
+
case PROP_SETTINGS:
ews_connection_set_settings (
E_EWS_CONNECTION (object),
@@ -1472,6 +1480,13 @@ ews_connection_get_property (GObject *object,
E_EWS_CONNECTION (object)));
return;
+ case PROP_PROXY_RESOLVER:
+ g_value_take_object (
+ value,
+ e_ews_connection_ref_proxy_resolver (
+ E_EWS_CONNECTION (object)));
+ return;
+
case PROP_SETTINGS:
g_value_take_object (
value,
@@ -1519,6 +1534,8 @@ ews_connection_dispose (GObject *object)
priv->soup_context = NULL;
}
+ g_clear_object (&priv->proxy_resolver);
+
if (priv->settings != NULL) {
g_object_unref (priv->settings);
priv->settings = NULL;
@@ -1633,6 +1650,17 @@ e_ews_connection_class_init (EEwsConnectionClass *class)
g_object_class_install_property (
object_class,
+ PROP_PROXY_RESOLVER,
+ g_param_spec_object (
+ "proxy-resolver",
+ "Proxy Resolver",
+ "The proxy resolver for this backend",
+ G_TYPE_PROXY_RESOLVER,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_SETTINGS,
g_param_spec_object (
"settings",
@@ -1731,6 +1759,13 @@ e_ews_connection_init (EEwsConnection *cnc)
cnc->priv->soup_context,
NULL);
+ /* Do not use G_BINDING_SYNC_CREATE because the property_lock is
+ * not initialized and we don't have a GProxyResolver yet anyway. */
+ g_object_bind_property (
+ cnc, "proxy-resolver",
+ cnc->priv->soup_session, "proxy-resolver",
+ G_BINDING_DEFAULT);
+
cnc->priv->version = E_EWS_EXCHANGE_UNKNOWN;
log_level = e_ews_debug_get_log_level ();
@@ -2187,6 +2222,53 @@ e_ews_connection_get_impersonate_user (EEwsConnection *cnc)
return cnc->priv->impersonate_user;
}
+GProxyResolver *
+e_ews_connection_ref_proxy_resolver (EEwsConnection *cnc)
+{
+ GProxyResolver *proxy_resolver = NULL;
+
+ g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), NULL);
+
+ g_mutex_lock (&cnc->priv->property_lock);
+
+ if (cnc->priv->proxy_resolver != NULL)
+ proxy_resolver = g_object_ref (cnc->priv->proxy_resolver);
+
+ g_mutex_unlock (&cnc->priv->property_lock);
+
+ return proxy_resolver;
+}
+
+void
+e_ews_connection_set_proxy_resolver (EEwsConnection *cnc,
+ GProxyResolver *proxy_resolver)
+{
+ gboolean notify = FALSE;
+
+ g_return_if_fail (E_IS_EWS_CONNECTION (cnc));
+
+ g_mutex_lock (&cnc->priv->property_lock);
+
+ /* Emitting a "notify" signal unnecessarily might have
+ * unwanted side effects like cancelling a SoupMessage.
+ * Only emit if we now have a different GProxyResolver. */
+
+ if (proxy_resolver != cnc->priv->proxy_resolver) {
+ g_clear_object (&cnc->priv->proxy_resolver);
+ cnc->priv->proxy_resolver = proxy_resolver;
+
+ if (proxy_resolver != NULL)
+ g_object_ref (proxy_resolver);
+
+ notify = TRUE;
+ }
+
+ g_mutex_unlock (&cnc->priv->property_lock);
+
+ if (notify)
+ g_object_notify (G_OBJECT (cnc), "proxy-resolver");
+}
+
CamelEwsSettings *
e_ews_connection_ref_settings (EEwsConnection *cnc)
{
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index a460f5e..288c824 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -224,6 +224,12 @@ void e_ews_connection_set_password (EEwsConnection *cnc,
const gchar *password);
const gchar * e_ews_connection_get_impersonate_user
(EEwsConnection *cnc);
+GProxyResolver *
+ e_ews_connection_ref_proxy_resolver
+ (EEwsConnection *cnc);
+void e_ews_connection_set_proxy_resolver
+ (EEwsConnection *cnc,
+ GProxyResolver *proxy_resolver);
CamelEwsSettings *
e_ews_connection_ref_settings (EEwsConnection *cnc);
SoupSession * e_ews_connection_ref_soup_session
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]