? core.6824
? foo.patch
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/Makefile.am,v
retrieving revision 1.109
diff -u -p -r1.109 Makefile.am
--- Makefile.am	15 Apr 2006 08:56:06 -0000	1.109
+++ Makefile.am	27 Oct 2006 01:14:38 -0000
@@ -98,6 +98,8 @@ gnome_session_SOURCES =		\
 	gsm-multiscreen.h	\
 	gsm-typebuiltins.c	\
 	gsm-typebuiltins.h	\
+	gsm-proxy.h		\
+	gsm-proxy.c		\
 	gdm-logout-action.c	\
 	gdm-logout-action.h	\
 	headers.h		\
Index: gsm-proxy.c
===================================================================
RCS file: gsm-proxy.c
diff -N gsm-proxy.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gsm-proxy.c	27 Oct 2006 01:14:38 -0000
@@ -0,0 +1,113 @@
+/* gsm-proxy.c - utility function for providing legacy http_proxy 
+                 support
+
+   Copyright (C) 2006 Red Hat, Inc.
+   Written by Ray Strode <rstrode@redhat.com>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.  */
+
+#include <config.h>
+#include "gsm-proxy.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
+
+#include "manager.h"
+#include "util.h"
+
+/* Set up the environment such that apps run from the session get
+ * gnome's http proxy settings when possible
+ */ 
+void
+gsm_set_up_legacy_proxy_environment (void)
+{
+  static gboolean run_before = FALSE;
+  gboolean use_proxy, use_authentication;
+  char *host, *user_name, *password, *http_proxy;
+  gint port;
+  GConfClient *gconf_client;
+
+  gconf_client = gsm_get_conf_client ();
+
+  if (!run_before) 
+    {
+      gconf_client_add_dir (gconf_client, HTTP_PROXY_PREFIX, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); 
+      gconf_client_notify_add (gconf_client,
+                               HTTP_PROXY_PREFIX,
+                               (GConfClientNotifyFunc) gsm_set_up_legacy_proxy_environment,
+                               NULL, NULL, NULL);
+      run_before = TRUE;
+    }
+
+  use_proxy = gconf_client_get_bool (gconf_client, HTTP_PROXY_KEY, NULL);
+
+  if (!use_proxy)
+    {
+      g_unsetenv ("http_proxy"); 
+      return;
+    }
+
+  host = gconf_client_get_string (gconf_client, HTTP_PROXY_HOST_KEY, NULL);
+
+  if (host == NULL || host[0] == '\0')
+    {
+      g_unsetenv ("http_proxy");
+      return;
+    }
+
+  port = gconf_client_get_int (gconf_client, HTTP_PROXY_PORT_KEY, NULL);
+
+  use_authentication = gconf_client_get_bool (gconf_client, HTTP_PROXY_AUTHENTICATION_KEY, NULL);
+
+  user_name = NULL;
+  password = NULL;
+  if (use_authentication)
+    {
+      user_name = gconf_client_get_string (gconf_client, HTTP_PROXY_USER_NAME_KEY, 
+                                           NULL);
+      if (user_name != NULL && user_name[0] == '\0')
+        {
+          g_free (user_name);
+          user_name = NULL;
+        }
+      else 
+        password = gconf_client_get_string (gconf_client, HTTP_PROXY_PASSWORD_KEY, 
+                                          NULL);
+    }
+
+  if (port <= 0)
+    http_proxy = g_strdup_printf ("http://%s%s%s%s%s",
+                                  user_name != NULL? user_name : "",
+                                  user_name != NULL && password != NULL? "@" : "",
+                                  user_name != NULL && password != NULL? password : "",
+                                  user_name != NULL? ":" : "",
+                                  host); 
+  else
+    http_proxy = g_strdup_printf ("http://%s%s%s%s%s:%d",
+                                  user_name != NULL? user_name : "",
+                                  user_name != NULL && password != NULL? "@" : "",
+                                  user_name != NULL && password != NULL? password : "",
+                                  user_name != NULL? ":" : "",
+                                  host, port); 
+  g_setenv ("http_proxy", http_proxy, TRUE);
+
+  g_free (http_proxy);
+  g_free (password);
+  g_free (user_name);
+  g_free (host);
+}
Index: gsm-proxy.h
===================================================================
RCS file: gsm-proxy.h
diff -N gsm-proxy.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gsm-proxy.h	27 Oct 2006 01:14:38 -0000
@@ -0,0 +1,6 @@
+#ifndef GSM_PROXY_H
+#define GSM_PROXY_H
+
+void gsm_set_up_legacy_proxy_environment (void);
+
+#endif /* GSM_PROXY_H */
Index: headers.h
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/headers.h,v
retrieving revision 1.16
diff -u -p -r1.16 headers.h
--- headers.h	26 Jul 2006 12:46:36 -0000	1.16
+++ headers.h	27 Oct 2006 01:14:38 -0000
@@ -74,6 +74,15 @@
 /* Assistive Technology support is turned on */
 #define ACCESSIBILITY_KEY         "/desktop/gnome/interface/accessibility"
 
+/* Proxy information */
+#define HTTP_PROXY_PREFIX             "/system/http_proxy"
+#define HTTP_PROXY_KEY                HTTP_PROXY_PREFIX "/use_http_proxy"
+#define HTTP_PROXY_AUTHENTICATION_KEY HTTP_PROXY_PREFIX "/use_authentication"
+#define HTTP_PROXY_USER_NAME_KEY      HTTP_PROXY_PREFIX "/authentication_user"
+#define HTTP_PROXY_PASSWORD_KEY       HTTP_PROXY_PREFIX "/authentication_password"
+#define HTTP_PROXY_HOST_KEY           HTTP_PROXY_PREFIX "/host"
+#define HTTP_PROXY_PORT_KEY           HTTP_PROXY_PREFIX "/port"
+
 /* Convenience macros: */
 #define APPEND(List,Elt) ((List) = (g_slist_append ((List), (Elt))))
 #define PREPEND(List,Elt) ((List) = (g_slist_prepend ((List), (Elt))))
Index: main.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/main.c,v
retrieving revision 1.80
diff -u -p -r1.80 main.c
--- main.c	26 Jul 2006 12:46:36 -0000	1.80
+++ main.c	27 Oct 2006 01:14:38 -0000
@@ -45,6 +45,7 @@
 #include "util.h"
 #include "gsm-sound.h"
 #include "gsm-gsd.h"
+#include "gsm-proxy.h"
 #include "gsm-keyring.h"
 #include "gsm-xrandr.h"
 #include "gsm-at-startup.h"
@@ -428,6 +429,8 @@ main (int argc, char *argv[])
   putenv (ep);
 
   ignore (SIGPIPE);
+
+  gsm_set_up_legacy_proxy_environment ();
 
   /* Need DISPLAY set */
   gsm_keyring_daemon_start ();
