mozilla-nongnome-proxies.patch
author Wolfgang Rosenauer <wr@rosenauer.org>
Wed, 08 Feb 2012 08:34:20 +0100
changeset 382 67f876aafae8
parent 367 3fabd9f66322
child 419 f6b055dd94bc
permissions -rw-r--r--
lift up to Gecko 11beta

From: Wolfgang Rosenauer
Subject: Do not use gconf for proxy settings if not running within Gnome

Index: toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
===================================================================
RCS file: /cvsroot/mozilla/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp,v
retrieving revision 1.1

diff --git a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
--- a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
+++ b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
@@ -71,18 +71,24 @@ private:
   nsresult SetProxyResultFromGSettings(const char* aKeyBase, const char* aType, nsACString& aResult);
 };
 
 NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
 
 nsresult
 nsUnixSystemProxySettings::Init()
 {
-  mGConf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
-  mGSettings = do_GetService(NS_GSETTINGSSERVICE_CONTRACTID);
+  // If this is a GNOME session, load gconf and try to use its preferences.
+  // If gconf is not available (which would be stupid) we'll proceed as if
+  // this was not a GNOME session, using *_PROXY environment variables.
+  const char* sessionType = PR_GetEnv("DESKTOP_SESSION");
+  if (sessionType && !strcmp(sessionType, "gnome")) {
+    mGConf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
+    mGSettings = do_GetService(NS_GSETTINGSSERVICE_CONTRACTID);
+  }
   return NS_OK;
 }
 
 bool
 nsUnixSystemProxySettings::IsProxyMode(const char* aMode)
 {
   nsCAutoString mode;
   return NS_SUCCEEDED(mGConf->GetString(NS_LITERAL_CSTRING("/system/proxy/mode"), mode)) &&