[evolution-patches] resubmitting eds proxy patch
- From: Jens Reimann <ctron dentrassi de>
- To: Evolution Patches <evolution-patches ximian com>
- Subject: [evolution-patches] resubmitting eds proxy patch
- Date: Tue, 18 May 2004 18:19:41 +0200
hi,
here is the eds proxy patch again. including the suggested changed from
dan winship.
--
Jens Reimann <ctron dentrassi de>
http://dentrassi.de
ICQ: 119027938
--- calendar/backends/http/e-cal-backend-http.c.orig 2004-05-16 16:43:42.166997064 +0200
+++ calendar/backends/http/e-cal-backend-http.c 2004-05-18 18:18:24.679879272 +0200
@@ -35,6 +35,7 @@
#include <libedata-cal/e-cal-backend-sexp.h>
#include <libsoup/soup-session-async.h>
#include <libsoup/soup-uri.h>
+#include <gconf/gconf-client.h>
#include "e-cal-backend-http.h"
@@ -275,6 +276,94 @@
static gboolean reload_cb (ECalBackendHttp *cbhttp);
static void maybe_start_reload_timeout (ECalBackendHttp *cbhttp);
+static SoupUri *
+get_proxy_uri ()
+{
+ GConfClient * conf_client = NULL;
+ SoupUri * uri = NULL;
+ gchar * uri_string = NULL;
+
+ conf_client = gconf_client_get_default ();
+
+ if ( !gconf_client_get_bool ( conf_client, "/system/http_proxy/use_http_proxy", NULL ) ) {
+ if ( conf_client )
+ g_object_unref ( conf_client );
+ return NULL;
+ }
+
+ /* create a dummy object */
+ uri = g_new0 ( SoupUri, 1 );
+ uri->protocol = SOUP_PROTOCOL_HTTP;
+
+ uri->host = gconf_client_get_string ( conf_client, "/system/http_proxy/host", NULL );
+ uri->port = gconf_client_get_int ( conf_client, "/system/http_proxy/port", NULL );
+
+ if ( gconf_client_get_bool ( conf_client, "/system/http_proxy/use_authentication", NULL ) ) {
+ uri->user = gconf_client_get_string ( conf_client, "/system/http_proxy/authentication_user", NULL );
+ uri->passwd = gconf_client_get_string ( conf_client, "/system/http_proxy/authentication_password", NULL );
+ }
+
+ if ( uri )
+ uri_string = soup_uri_to_string ( uri, FALSE );
+
+ if ( uri_string ) {
+ g_message ( "Proxy URI: %s\n", uri_string );
+ g_free ( uri_string );
+ uri_string = NULL;
+ }
+
+ if ( conf_client )
+ g_object_unref ( conf_client );
+
+ return uri;
+}
+
+static void
+assign_new_proxy ( SoupSession * session, SoupUri * uri )
+{
+ g_object_set (G_OBJECT (session),
+ SOUP_SESSION_PROXY_URI, uri,
+ NULL);
+}
+
+static void
+update_proxy ( ECalBackendHttp *cbhttp )
+{
+ if ( !cbhttp ) return;
+ if ( !cbhttp->priv ) return;
+ if ( !cbhttp->priv->soup_session ) return;
+
+ SoupUri * uri = NULL;
+
+ uri = get_proxy_uri ();
+
+ /* Note: also a NULL proxy uri is ok. It simply means: "no proxy" */
+ assign_new_proxy ( cbhttp->priv->soup_session, uri );
+
+ if ( uri )
+ soup_uri_free ( uri );
+}
+
+static SoupSession *
+create_soup_session ()
+{
+ SoupUri * proxy_uri = NULL;
+ SoupSession * soup_session = NULL;
+
+ proxy_uri = get_proxy_uri ();
+
+ if ( proxy_uri ) {
+ soup_session = soup_session_async_new_with_options ( SOUP_SESSION_PROXY_URI, proxy_uri, NULL );
+ } else {
+ soup_session = soup_session_async_new ();
+ }
+
+ if ( proxy_uri )
+ soup_uri_free ( proxy_uri );
+
+ return soup_session;
+}
+
static gboolean
begin_retrieval_cb (ECalBackendHttp *cbhttp)
{
@@ -297,7 +386,12 @@
/* create the Soup session if not already created */
if (!priv->soup_session) {
- priv->soup_session = soup_session_async_new ();
+ priv->soup_session = create_soup_session ();
+ } else {
+ /* this is a little bit quick and dirty. notification using gconf would
+ * be a lot nicer. Anyway, it works!
+ */
+ update_proxy ( cbhttp );
}
if (priv->uri == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]