View | Details | Raw Unified | Return to bug 132398
Collapse All | Expand All

(-)netwerk/base/public/nsISystemProxySettings.idl (+65 lines)
Added Link Here
1
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is Novell code.
16
 *
17
 * The Initial Developer of the Original Code is Novell.
18
 * Portions created by the Initial Developer are Copyright (C) 2005
19
 * the Initial Developer. All Rights Reserved.
20
 *
21
 * Contributor(s):
22
 *    Robert O'Callahan (rocallahan@novell.com)
23
 *
24
 * Alternatively, the contents of this file may be used under the terms of
25
 * either the GNU General Public License Version 2 or later (the "GPL"), or
26
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 * of those above. If you wish to allow use of your version of this file only
29
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 * use your version of this file under the terms of the MPL, indicate your
31
 * decision by deleting the provisions above and replace them with the notice
32
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 * the provisions above, a recipient may use your version of this file under
34
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 *
36
 * ***** END LICENSE BLOCK ***** */
37
38
#include "nsISupports.idl"
39
#include "nsIURI.idl"
40
41
%{C++
42
#define NS_SYSTEMPROXYSETTINGS_CONTRACTID "@mozilla.org/system-proxy-settings;1"
43
%}
44
45
/** 
46
 * This interface allows the proxy code to use platform-specific proxy
47
 * settings when the proxy preference is set to "automatic discovery". If it can
48
 * load a service with the above contract ID, it will use it to determine the
49
 * PAC file name. If no PAC file is specified then the service itself will behave
50
 * like a PAC file.
51
 */
52
[scriptable, uuid(a9f3ae38-b769-4e0b-9317-578388e326c9)]
53
interface nsISystemProxySettings : nsISupports
54
{
55
    /**
56
     * If non-empty, use this PAC file. If empty, call getProxyForURI instead.
57
     */
58
    readonly attribute AUTF8String PACURI;
59
    
60
    /**
61
     * See nsIProxyAutoConfig::getProxyForURI; this function behaves exactly
62
     * the same way.
63
     */
64
    ACString getProxyForURI(in nsIURI aURI);
65
};
(-)netwerk/base/src/nsPACMan.h (-8 / +8 lines)
Lines 119-142 public: Link Here
119
   * processed once the PAC file finishes loading.
119
   * processed once the PAC file finishes loading.
120
   *
120
   *
121
   * @param pacURI
121
   * @param pacURI
122
   *        The nsIURI of the PAC file to load.
122
   *        The nsIURI of the PAC file to load.
123
   */
123
   */
124
  nsresult LoadPACFromURI(nsIURI *pacURI);
124
  nsresult LoadPACFromURI(nsIURI *pacURI);
125
125
126
  /**
126
  /**
127
   * Returns true if we are currently loading the PAC file.
127
   * Returns true if we are currently loading the PAC file.
128
   */
128
   */
129
  PRBool IsLoading() { return mLoader != nsnull; }
129
  PRBool IsLoading() { return mLoader != nsnull; }
130
130
131
  /**
132
   * Returns true if the given URI matches the URI of our PAC file.
133
   */
134
  PRBool IsPACURI(nsIURI *uri) {
135
    PRBool result;
136
    return mPACURI && NS_SUCCEEDED(mPACURI->Equals(uri, &result)) && result;
137
  }
138
131
private:
139
private:
132
  NS_DECL_NSISTREAMLOADEROBSERVER
140
  NS_DECL_NSISTREAMLOADEROBSERVER
133
  NS_DECL_NSIINTERFACEREQUESTOR
141
  NS_DECL_NSIINTERFACEREQUESTOR
134
  NS_DECL_NSICHANNELEVENTSINK
142
  NS_DECL_NSICHANNELEVENTSINK
135
143
136
  ~nsPACMan();
144
  ~nsPACMan();
137
145
138
  /**
146
  /**
139
   * Cancel any existing load if any.
147
   * Cancel any existing load if any.
140
   */
148
   */
141
  void CancelExistingLoad();
149
  void CancelExistingLoad();
142
150
Lines 144-175 private: Link Here
144
   * Process mPendingQ.  If status is a failure code, then the pending queue
152
   * Process mPendingQ.  If status is a failure code, then the pending queue
145
   * will be emptied.  If status is a success code, then the pending requests
153
   * will be emptied.  If status is a success code, then the pending requests
146
   * will be processed (i.e., their Start method will be called).
154
   * will be processed (i.e., their Start method will be called).
147
   */
155
   */
148
  void ProcessPendingQ(nsresult status);
156
  void ProcessPendingQ(nsresult status);
149
157
150
  /**
158
  /**
151
   * Start loading the PAC file.
159
   * Start loading the PAC file.
152
   */
160
   */
153
  nsresult StartLoading();
161
  nsresult StartLoading();
154
162
155
  /**
163
  /**
156
   * Returns true if the given URI matches the URI of our PAC file.
157
   */
158
  PRBool IsPACURI(nsIURI *uri) {
159
    PRBool result;
160
    return mPACURI && NS_SUCCEEDED(mPACURI->Equals(uri, &result)) && result;
161
  }
162
163
  /**
164
   * Event fu for calling StartLoading asynchronously.
164
   * Event fu for calling StartLoading asynchronously.
165
   */
165
   */
166
  PR_STATIC_CALLBACK(void *) LoadEvent_Handle(PLEvent *);
166
  PR_STATIC_CALLBACK(void *) LoadEvent_Handle(PLEvent *);
167
  PR_STATIC_CALLBACK(void) LoadEvent_Destroy(PLEvent *);
167
  PR_STATIC_CALLBACK(void) LoadEvent_Destroy(PLEvent *);
168
168
169
private:
169
private:
170
  nsCOMPtr<nsIProxyAutoConfig> mPAC;
170
  nsCOMPtr<nsIProxyAutoConfig> mPAC;
171
  nsCOMPtr<nsIURI>             mPACURI;
171
  nsCOMPtr<nsIURI>             mPACURI;
172
  PRCList                      mPendingQ;
172
  PRCList                      mPendingQ;
173
  nsCOMPtr<nsIStreamLoader>    mLoader;
173
  nsCOMPtr<nsIStreamLoader>    mLoader;
174
  PLEvent                     *mLoadEvent;
174
  PLEvent                     *mLoadEvent;
175
  PRBool                       mShutdown;
175
  PRBool                       mShutdown;
(-)netwerk/base/src/nsProtocolProxyService.cpp (-11 / +48 lines)
Lines 402-425 nsProtocolProxyService::PrefsChanged(nsI Link Here
402
                // don't have to handle this case everywhere else
402
                // don't have to handle this case everywhere else
403
                // I'm paranoid about a loop of some sort - only do this
403
                // I'm paranoid about a loop of some sort - only do this
404
                // if we're enumerating all prefs, and ignore any error
404
                // if we're enumerating all prefs, and ignore any error
405
                if (!pref)
405
                if (!pref)
406
                    prefBranch->SetIntPref("network.proxy.type", type);
406
                    prefBranch->SetIntPref("network.proxy.type", type);
407
            } else if (type >= eProxyConfig_Last) {
407
            } else if (type >= eProxyConfig_Last) {
408
                LOG(("unknown proxy type: %lu; assuming direct\n", type));
408
                LOG(("unknown proxy type: %lu; assuming direct\n", type));
409
                type = eProxyConfig_Direct;
409
                type = eProxyConfig_Direct;
410
            }
410
            }
411
            mProxyConfig = NS_STATIC_CAST(ProxyConfig, type);
411
            mProxyConfig = NS_STATIC_CAST(ProxyConfig, type);
412
            reloadPAC = PR_TRUE;
412
            reloadPAC = PR_TRUE;
413
        }
413
        }
414
415
        if (mProxyConfig == eProxyConfig_WPAD) {
416
            mSystemProxySettings = do_GetService(NS_SYSTEMPROXYSETTINGS_CONTRACTID);
417
        } else {
418
            mSystemProxySettings = nsnull;
419
        }
414
    }
420
    }
415
421
416
    if (!pref || !strcmp(pref, "network.proxy.http"))
422
    if (!pref || !strcmp(pref, "network.proxy.http"))
417
        proxy_GetStringPref(prefBranch, "network.proxy.http", mHTTPProxyHost);
423
        proxy_GetStringPref(prefBranch, "network.proxy.http", mHTTPProxyHost);
418
424
419
    if (!pref || !strcmp(pref, "network.proxy.http_port"))
425
    if (!pref || !strcmp(pref, "network.proxy.http_port"))
420
        proxy_GetIntPref(prefBranch, "network.proxy.http_port", mHTTPProxyPort);
426
        proxy_GetIntPref(prefBranch, "network.proxy.http_port", mHTTPProxyPort);
421
427
422
    if (!pref || !strcmp(pref, "network.proxy.ssl"))
428
    if (!pref || !strcmp(pref, "network.proxy.ssl"))
423
        proxy_GetStringPref(prefBranch, "network.proxy.ssl", mHTTPSProxyHost);
429
        proxy_GetStringPref(prefBranch, "network.proxy.ssl", mHTTPSProxyHost);
424
430
425
    if (!pref || !strcmp(pref, "network.proxy.ssl_port"))
431
    if (!pref || !strcmp(pref, "network.proxy.ssl_port"))
Lines 475-507 nsProtocolProxyService::PrefsChanged(nsI Link Here
475
    //  2) network.proxy.autoconfig_url changed and PAC is configured
481
    //  2) network.proxy.autoconfig_url changed and PAC is configured
476
482
477
    if (!pref || !strcmp(pref, "network.proxy.autoconfig_url"))
483
    if (!pref || !strcmp(pref, "network.proxy.autoconfig_url"))
478
        reloadPAC = PR_TRUE;
484
        reloadPAC = PR_TRUE;
479
485
480
    if (reloadPAC) {
486
    if (reloadPAC) {
481
        tempString.Truncate();
487
        tempString.Truncate();
482
        if (mProxyConfig == eProxyConfig_PAC) {
488
        if (mProxyConfig == eProxyConfig_PAC) {
483
            prefBranch->GetCharPref("network.proxy.autoconfig_url",
489
            prefBranch->GetCharPref("network.proxy.autoconfig_url",
484
                                    getter_Copies(tempString));
490
                                    getter_Copies(tempString));
485
        }
491
        }
486
        else if (mProxyConfig == eProxyConfig_WPAD) {
492
        else if (mProxyConfig == eProxyConfig_WPAD) {
487
            // We diverge from the WPAD spec here in that we don't walk the
493
            rv = NS_ERROR_FAILURE;
488
            // hosts's FQDN, stripping components until we hit a TLD.  Doing so
494
            if (mSystemProxySettings) {
489
            // is dangerous in the face of an incomplete list of TLDs, and TLDs
495
                rv = mSystemProxySettings->GetPACURI(tempString);
490
            // get added over time.  We could consider doing only a single
496
            }
491
            // substitution of the first component, if that proves to help
497
            if (NS_FAILED(rv)) {
492
            // compatibility.
498
                // We diverge from the WPAD spec here in that we don't walk the
493
            tempString.AssignLiteral("http://wpad/wpad.dat");
499
                // hosts's FQDN, stripping components until we hit a TLD.  Doing so
500
                // is dangerous in the face of an incomplete list of TLDs, and TLDs
501
                // get added over time.  We could consider doing only a single
502
                // substitution of the first component, if that proves to help
503
                // compatibility.
504
                tempString.AssignLiteral("http://wpad/wpad.dat");
505
            }
506
        }
507
        if (!tempString.IsEmpty()) {
508
            ConfigureFromPAC(tempString);
494
        }
509
        }
495
        ConfigureFromPAC(tempString);
496
    }
510
    }
497
}
511
}
498
512
499
PRBool
513
PRBool
500
nsProtocolProxyService::CanUseProxy(nsIURI *aURI, PRInt32 defaultPort) 
514
nsProtocolProxyService::CanUseProxy(nsIURI *aURI, PRInt32 defaultPort) 
501
{
515
{
502
    if (mHostFiltersArray.Count() == 0)
516
    if (mHostFiltersArray.Count() == 0)
503
        return PR_TRUE;
517
        return PR_TRUE;
504
518
505
    PRInt32 port;
519
    PRInt32 port;
506
    nsCAutoString host;
520
    nsCAutoString host;
507
 
521
 
Lines 892-922 nsProtocolProxyService::NewProxyInfo(con Link Here
892
                                 aFailoverProxy, aResult);
906
                                 aFailoverProxy, aResult);
893
}
907
}
894
908
895
NS_IMETHODIMP
909
NS_IMETHODIMP
896
nsProtocolProxyService::ConfigureFromPAC(const nsACString &spec)
910
nsProtocolProxyService::ConfigureFromPAC(const nsACString &spec)
897
{
911
{
898
    if (!mPACMan) {
912
    if (!mPACMan) {
899
        mPACMan = new nsPACMan();
913
        mPACMan = new nsPACMan();
900
        if (!mPACMan)
914
        if (!mPACMan)
901
            return NS_ERROR_OUT_OF_MEMORY;
915
            return NS_ERROR_OUT_OF_MEMORY;
902
    }
916
    }
903
917
904
    mFailedProxies.Clear();
905
906
    nsCOMPtr<nsIURI> pacURI;
918
    nsCOMPtr<nsIURI> pacURI;
907
    nsresult rv = NS_NewURI(getter_AddRefs(pacURI), spec);
919
    nsresult rv = NS_NewURI(getter_AddRefs(pacURI), spec);
908
    if (NS_FAILED(rv))
920
    if (NS_FAILED(rv))
909
        return rv;
921
        return rv;
910
922
923
    if (mPACMan->IsPACURI(pacURI))
924
        return NS_OK;
925
926
    mFailedProxies.Clear();
927
911
    return mPACMan->LoadPACFromURI(pacURI);
928
    return mPACMan->LoadPACFromURI(pacURI);
912
}
929
}
913
930
914
NS_IMETHODIMP
931
NS_IMETHODIMP
915
nsProtocolProxyService::GetFailoverForProxy(nsIProxyInfo  *aProxy,
932
nsProtocolProxyService::GetFailoverForProxy(nsIProxyInfo  *aProxy,
916
                                            nsIURI        *aURI,
933
                                            nsIURI        *aURI,
917
                                            nsresult       aStatus,
934
                                            nsresult       aStatus,
918
                                            nsIProxyInfo **aResult)
935
                                            nsIProxyInfo **aResult)
919
{
936
{
920
    // We only support failover when a PAC file is configured.
937
    // We only support failover when a PAC file is configured.
921
    if (mProxyConfig != eProxyConfig_PAC && mProxyConfig != eProxyConfig_WPAD)
938
    if (mProxyConfig != eProxyConfig_PAC && mProxyConfig != eProxyConfig_WPAD)
922
        return NS_ERROR_NOT_AVAILABLE;
939
        return NS_ERROR_NOT_AVAILABLE;
Lines 1205-1235 nsProtocolProxyService::Resolve_Internal Link Here
1205
                                         const nsProtocolInfo &info,
1222
                                         const nsProtocolInfo &info,
1206
                                         PRBool *usePAC,
1223
                                         PRBool *usePAC,
1207
                                         nsIProxyInfo **result)
1224
                                         nsIProxyInfo **result)
1208
{
1225
{
1209
    NS_ENSURE_ARG_POINTER(uri);
1226
    NS_ENSURE_ARG_POINTER(uri);
1210
1227
1211
    *usePAC = PR_FALSE;
1228
    *usePAC = PR_FALSE;
1212
    *result = nsnull;
1229
    *result = nsnull;
1213
1230
1214
    if (!(info.flags & nsIProtocolHandler::ALLOWS_PROXY))
1231
    if (!(info.flags & nsIProtocolHandler::ALLOWS_PROXY))
1215
        return NS_OK;  // Can't proxy this (filters may not override)
1232
        return NS_OK;  // Can't proxy this (filters may not override)
1216
1233
1234
    if (mSystemProxySettings) {
1235
        nsCAutoString PACURI;
1236
        if (NS_SUCCEEDED(mSystemProxySettings->GetPACURI(PACURI)) &&
1237
            !PACURI.IsEmpty()) {
1238
            // Switch to new PAC file if that setting has changed. If the setting
1239
            // hasn't changed, ConfigureFromPAC will exit early.
1240
            nsresult rv = ConfigureFromPAC(PACURI);
1241
            if (NS_FAILED(rv))
1242
                return rv;
1243
        } else {
1244
            nsCAutoString proxy;
1245
            nsresult rv = mSystemProxySettings->GetProxyForURI(uri, proxy);
1246
            if (NS_SUCCEEDED(rv)) {
1247
                ProcessPACString(proxy, result);
1248
                return NS_OK;
1249
            }
1250
            // Otherwise, allow the WPAD PAC lookup to go ahead
1251
        }
1252
    }
1253
1217
    // if proxies are enabled and this host:port combo is supposed to use a
1254
    // if proxies are enabled and this host:port combo is supposed to use a
1218
    // proxy, check for a proxy.
1255
    // proxy, check for a proxy.
1219
    if (mProxyConfig == eProxyConfig_Direct ||
1256
    if (mProxyConfig == eProxyConfig_Direct ||
1220
            (mProxyConfig == eProxyConfig_Manual &&
1257
            (mProxyConfig == eProxyConfig_Manual &&
1221
             !CanUseProxy(uri, info.defaultPort)))
1258
             !CanUseProxy(uri, info.defaultPort)))
1222
        return NS_OK;
1259
        return NS_OK;
1223
    
1260
1224
    // Proxy auto config magic...
1261
    // Proxy auto config magic...
1225
    if (mProxyConfig == eProxyConfig_PAC || mProxyConfig == eProxyConfig_WPAD) {
1262
    if (mProxyConfig == eProxyConfig_PAC || mProxyConfig == eProxyConfig_WPAD) {
1226
        // Do not query PAC now.
1263
        // Do not query PAC now.
1227
        *usePAC = PR_TRUE;
1264
        *usePAC = PR_TRUE;
1228
        return NS_OK;
1265
        return NS_OK;
1229
    }
1266
    }
1230
1267
1231
    // proxy info values
1268
    // proxy info values
1232
    const char *type = nsnull;
1269
    const char *type = nsnull;
1233
    const nsACString *host = nsnull;
1270
    const nsACString *host = nsnull;
1234
    PRInt32 port = -1;
1271
    PRInt32 port = -1;
1235
1272
(-)netwerk/base/src/nsProtocolProxyService.h (+2 lines)
Lines 39-62 Link Here
39
#ifndef nsProtocolProxyService_h__
39
#ifndef nsProtocolProxyService_h__
40
#define nsProtocolProxyService_h__
40
#define nsProtocolProxyService_h__
41
41
42
#include "plevent.h"
42
#include "plevent.h"
43
#include "nsString.h"
43
#include "nsString.h"
44
#include "nsCOMPtr.h"
44
#include "nsCOMPtr.h"
45
#include "nsAutoPtr.h"
45
#include "nsAutoPtr.h"
46
#include "nsVoidArray.h"
46
#include "nsVoidArray.h"
47
#include "nsIPrefBranch.h"
47
#include "nsIPrefBranch.h"
48
#include "nsPIProtocolProxyService.h"
48
#include "nsPIProtocolProxyService.h"
49
#include "nsIProtocolProxyFilter.h"
49
#include "nsIProtocolProxyFilter.h"
50
#include "nsIProxyAutoConfig.h"
50
#include "nsIProxyAutoConfig.h"
51
#include "nsISystemProxySettings.h"
51
#include "nsIProxyInfo.h"
52
#include "nsIProxyInfo.h"
52
#include "nsIObserver.h"
53
#include "nsIObserver.h"
53
#include "nsDataHashtable.h"
54
#include "nsDataHashtable.h"
54
#include "nsHashKeys.h"
55
#include "nsHashKeys.h"
55
#include "nsPACMan.h"
56
#include "nsPACMan.h"
56
#include "prtime.h"
57
#include "prtime.h"
57
#include "prmem.h"
58
#include "prmem.h"
58
#include "prio.h"
59
#include "prio.h"
59
60
60
typedef nsDataHashtable<nsCStringHashKey, PRUint32> nsFailedProxyTable;
61
typedef nsDataHashtable<nsCStringHashKey, PRUint32> nsFailedProxyTable;
61
62
62
class nsProxyInfo;
63
class nsProxyInfo;
Lines 362-380 protected: Link Here
362
    nsCString                    mGopherProxyHost;
363
    nsCString                    mGopherProxyHost;
363
    PRInt32                      mGopherProxyPort;
364
    PRInt32                      mGopherProxyPort;
364
365
365
    nsCString                    mHTTPSProxyHost;
366
    nsCString                    mHTTPSProxyHost;
366
    PRInt32                      mHTTPSProxyPort;
367
    PRInt32                      mHTTPSProxyPort;
367
    
368
    
368
    nsCString                    mSOCKSProxyHost;
369
    nsCString                    mSOCKSProxyHost;
369
    PRInt32                      mSOCKSProxyPort;
370
    PRInt32                      mSOCKSProxyPort;
370
    PRInt32                      mSOCKSProxyVersion;
371
    PRInt32                      mSOCKSProxyVersion;
371
    PRBool                       mSOCKSProxyRemoteDNS;
372
    PRBool                       mSOCKSProxyRemoteDNS;
372
373
373
    nsRefPtr<nsPACMan>           mPACMan;  // non-null if we are using PAC
374
    nsRefPtr<nsPACMan>           mPACMan;  // non-null if we are using PAC
375
    nsCOMPtr<nsISystemProxySettings> mSystemProxySettings;
374
376
375
    PRTime                       mSessionStart;
377
    PRTime                       mSessionStart;
376
    nsFailedProxyTable           mFailedProxies;
378
    nsFailedProxyTable           mFailedProxies;
377
    PRInt32                      mFailedProxyTimeout;
379
    PRInt32                      mFailedProxyTimeout;
378
};
380
};
379
381
380
#endif // !nsProtocolProxyService_h__
382
#endif // !nsProtocolProxyService_h__
(-)toolkit/components/gnome/nsGConfService.cpp (+33 lines)
Lines 30-53 Link Here
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
31
 * use your version of this file under the terms of the MPL, indicate your
31
 * use your version of this file under the terms of the MPL, indicate your
32
 * decision by deleting the provisions above and replace them with the notice
32
 * decision by deleting the provisions above and replace them with the notice
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
34
 * the provisions above, a recipient may use your version of this file under
34
 * the provisions above, a recipient may use your version of this file under
35
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 * the terms of any one of the MPL, the GPL or the LGPL.
36
 *
36
 *
37
 * ***** END LICENSE BLOCK ***** */
37
 * ***** END LICENSE BLOCK ***** */
38
38
39
#include "nsGConfService.h"
39
#include "nsGConfService.h"
40
#include "nsCRT.h"
40
#include "nsCRT.h"
41
#include "nsString.h"
41
#include "nsString.h"
42
#include "nsSupportsPrimitives.h"
43
#include "nsArray.h"
42
44
43
#include <gconf/gconf-client.h>
45
#include <gconf/gconf-client.h>
44
46
45
nsGConfService::~nsGConfService()
47
nsGConfService::~nsGConfService()
46
{
48
{
47
  if (mClient)
49
  if (mClient)
48
    g_object_unref(mClient);
50
    g_object_unref(mClient);
49
}
51
}
50
52
51
nsresult
53
nsresult
52
nsGConfService::Init()
54
nsGConfService::Init()
53
{
55
{
Lines 116-139 nsGConfService::GetFloat(const nsACStrin Link Here
116
  *aResult = gconf_client_get_float(mClient, PromiseFlatCString(aKey).get(),
118
  *aResult = gconf_client_get_float(mClient, PromiseFlatCString(aKey).get(),
117
                                    &error);
119
                                    &error);
118
120
119
  if (error) {
121
  if (error) {
120
    g_error_free(error);
122
    g_error_free(error);
121
    return NS_ERROR_FAILURE;
123
    return NS_ERROR_FAILURE;
122
  }
124
  }
123
125
124
  return NS_OK;
126
  return NS_OK;
125
}
127
}
126
128
127
NS_IMETHODIMP
129
NS_IMETHODIMP
130
nsGConfService::GetStringList(const nsACString &aKey, nsIArray** aResult)
131
{
132
  nsCOMPtr<nsIMutableArray> items;
133
  NS_NewArray(getter_AddRefs(items));
134
  if (!items)
135
    return NS_ERROR_OUT_OF_MEMORY;
136
    
137
  GError* error = nsnull;
138
  GSList* list = gconf_client_get_list(mClient, PromiseFlatCString(aKey).get(),
139
                                       GCONF_VALUE_STRING, &error);
140
  if (error) {
141
    g_error_free(error);
142
    return NS_ERROR_FAILURE;
143
  }
144
145
  for (GSList* l = list; l; l = l->next) {
146
    nsSupportsCStringImpl* obj = new nsSupportsCStringImpl();
147
    if (!obj) {
148
      g_slist_free(list);
149
      return NS_ERROR_OUT_OF_MEMORY;
150
    }
151
    obj->SetData(nsDependentCString((const char*)l->data));
152
    items->AppendElement(obj, PR_FALSE);
153
  }
154
  
155
  g_slist_free(list);
156
  NS_ADDREF(*aResult = items);
157
  return NS_OK;
158
}
159
160
NS_IMETHODIMP
128
nsGConfService::SetBool(const nsACString &aKey, PRBool aValue)
161
nsGConfService::SetBool(const nsACString &aKey, PRBool aValue)
129
{
162
{
130
  PRBool res = gconf_client_set_bool(mClient, PromiseFlatCString(aKey).get(),
163
  PRBool res = gconf_client_set_bool(mClient, PromiseFlatCString(aKey).get(),
131
                                     aValue, nsnull);
164
                                     aValue, nsnull);
132
165
133
  return res ? NS_OK : NS_ERROR_FAILURE;
166
  return res ? NS_OK : NS_ERROR_FAILURE;
134
}
167
}
135
168
136
NS_IMETHODIMP
169
NS_IMETHODIMP
137
nsGConfService::SetString(const nsACString &aKey, const nsACString &aValue)
170
nsGConfService::SetString(const nsACString &aKey, const nsACString &aValue)
138
{
171
{
139
  PRBool res = gconf_client_set_string(mClient, PromiseFlatCString(aKey).get(),
172
  PRBool res = gconf_client_set_string(mClient, PromiseFlatCString(aKey).get(),
(-)toolkit/components/gnome/nsIGConfService.idl (+2 lines)
Lines 28-60 Link Here
28
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 * in which case the provisions of the GPL or the LGPL are applicable instead
29
 * of those above. If you wish to allow use of your version of this file only
29
 * of those above. If you wish to allow use of your version of this file only
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
31
 * use your version of this file under the terms of the MPL, indicate your
31
 * use your version of this file under the terms of the MPL, indicate your
32
 * decision by deleting the provisions above and replace them with the notice
32
 * decision by deleting the provisions above and replace them with the notice
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
34
 * the provisions above, a recipient may use your version of this file under
34
 * the provisions above, a recipient may use your version of this file under
35
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 * the terms of any one of the MPL, the GPL or the LGPL.
36
 *
36
 *
37
 * ***** END LICENSE BLOCK ***** */
37
 * ***** END LICENSE BLOCK ***** */
38
38
39
#include "nsISupports.idl"
39
#include "nsISupports.idl"
40
#include "nsIArray.idl"
40
41
41
[scriptable, uuid(01ac7b2e-c07c-465f-b35c-542eaef420a9)]
42
[scriptable, uuid(01ac7b2e-c07c-465f-b35c-542eaef420a9)]
42
interface nsIGConfService : nsISupports
43
interface nsIGConfService : nsISupports
43
{
44
{
44
  /* Basic registry access */
45
  /* Basic registry access */
45
  boolean       getBool(in AUTF8String key);
46
  boolean       getBool(in AUTF8String key);
46
  AUTF8String   getString(in AUTF8String key);
47
  AUTF8String   getString(in AUTF8String key);
47
  long          getInt(in AUTF8String key);
48
  long          getInt(in AUTF8String key);
48
  float         getFloat(in AUTF8String key);
49
  float         getFloat(in AUTF8String key);
50
  nsIArray      getStringList(in AUTF8String key);
49
51
50
  void setBool(in AUTF8String key, in boolean value);
52
  void setBool(in AUTF8String key, in boolean value);
51
  void setString(in AUTF8String key, in AUTF8String value);
53
  void setString(in AUTF8String key, in AUTF8String value);
52
  void setInt(in AUTF8String key, in long value);
54
  void setInt(in AUTF8String key, in long value);
53
  void setFloat(in AUTF8String key, in float value);
55
  void setFloat(in AUTF8String key, in float value);
54
56
55
  /*
57
  /*
56
   * Look up the handler for a protocol under the
58
   * Look up the handler for a protocol under the
57
   * /desktop/gnome/url-handlers hierarchy.
59
   * /desktop/gnome/url-handlers hierarchy.
58
   */
60
   */
59
  AUTF8String getAppForProtocol(in AUTF8String scheme, out boolean enabled);
61
  AUTF8String getAppForProtocol(in AUTF8String scheme, out boolean enabled);
60
62
(-)toolkit/components/unixproxy/Makefile.in (+63 lines)
Added Link Here
1
# ***** BEGIN LICENSE BLOCK *****
2
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
#
4
# The contents of this file are subject to the Mozilla Public License Version
5
# 1.1 (the "License"); you may not use this file except in compliance with
6
# the License. You may obtain a copy of the License at
7
# http://www.mozilla.org/MPL/
8
#
9
# Software distributed under the License is distributed on an "AS IS" basis,
10
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
# for the specific language governing rights and limitations under the
12
# License.
13
#
14
# The Original Code is the Mozilla GNOME integration code.
15
#
16
# The Initial Developer of the Original Code is
17
# IBM Corporation.
18
# Portions created by the Initial Developer are Copyright (C) 2004
19
# the Initial Developer. All Rights Reserved.
20
#
21
# Contributor(s):
22
#  Brian Ryner <bryner@brianryner.com>
23
#
24
# Alternatively, the contents of this file may be used under the terms of
25
# either the GNU General Public License Version 2 or later (the "GPL"), or
26
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
# in which case the provisions of the GPL or the LGPL are applicable instead
28
# of those above. If you wish to allow use of your version of this file only
29
# under the terms of either the GPL or the LGPL, and not to allow others to
30
# use your version of this file under the terms of the MPL, indicate your
31
# decision by deleting the provisions above and replace them with the notice
32
# and other provisions required by the GPL or the LGPL. If you do not delete
33
# the provisions above, a recipient may use your version of this file under
34
# the terms of any one of the MPL, the GPL or the LGPL.
35
#
36
# ***** END LICENSE BLOCK *****
37
38
DEPTH     = ../../..
39
topsrcdir = @top_srcdir@
40
srcdir    = @srcdir@
41
VPATH     = @srcdir@
42
43
include $(DEPTH)/config/autoconf.mk
44
45
MODULE          = unixproxy
46
MOZILLA_INTERNAL_API = 1
47
48
REQUIRES = \
49
        xpcom \
50
        string \
51
        necko \
52
        mozgnome \
53
        $(NULL)
54
55
CPPSRCS = \
56
        nsUnixSystemProxySettings.cpp \
57
        $(NULL)
58
59
LIBRARY_NAME    = unixproxy
60
IS_COMPONENT    = 1
61
FORCE_SHARED_LIB = 1
62
63
include $(topsrcdir)/config/rules.mk
(-)toolkit/components/unixproxy/nsUnixSystemProxySettings.cpp (+425 lines)
Added Link Here
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is mozilla.org code.
16
 *
17
 * The Initial Developer of the Original Code is
18
 * Netscape Communications Corporation.
19
 * Portions created by the Initial Developer are Copyright (C) 1998
20
 * the Initial Developer. All Rights Reserved.
21
 *
22
 * Contributor(s):
23
 *    Robert O'Callahan (rocallahan@novell.com)
24
 *
25
 * Alternatively, the contents of this file may be used under the terms of
26
 * either the GNU General Public License Version 2 or later (the "GPL"), or
27
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
 * in which case the provisions of the GPL or the LGPL are applicable instead
29
 * of those above. If you wish to allow use of your version of this file only
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
31
 * use your version of this file under the terms of the MPL, indicate your
32
 * decision by deleting the provisions above and replace them with the notice
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
34
 * the provisions above, a recipient may use your version of this file under
35
 * the terms of any one of the MPL, the GPL or the LGPL.
36
 *
37
 * ***** END LICENSE BLOCK ***** */
38
39
#include "nsISystemProxySettings.h"
40
#include "nsIGenericFactory.h"
41
#include "nsIServiceManager.h"
42
#include "nsIGConfService.h"
43
#include "nsIURI.h"
44
#include "nsReadableUtils.h"
45
#include "nsArray.h"
46
#include "prnetdb.h"
47
#include "prenv.h"
48
#include "nsPrintfCString.h"
49
#include "nsNetUtil.h"
50
#include "nsISupportsPrimitives.h"
51
52
class nsUnixSystemProxySettings : public nsISystemProxySettings {
53
public:
54
  NS_DECL_ISUPPORTS
55
  NS_DECL_NSISYSTEMPROXYSETTINGS
56
57
  nsUnixSystemProxySettings() {}
58
  nsresult Init();
59
60
private:
61
  ~nsUnixSystemProxySettings() {}
62
  
63
  nsCOMPtr<nsIGConfService> mGConf;
64
};
65
66
NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
67
68
nsresult
69
nsUnixSystemProxySettings::Init()
70
{
71
  // If this is a GNOME session, load gconf and try to use its preferences.
72
  // If gconf is not available (which would be stupid) we'll proceed as if this
73
  // was not a GNOME session, using *_PROXY environment variables.
74
  const char* sessionType = PR_GetEnv("DESKTOP_SESSION");
75
  if (sessionType && !strcmp(sessionType, "gnome")) {
76
    mGConf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
77
  }
78
  return NS_OK;
79
}
80
81
static PRBool
82
IsProxyMode(nsIGConfService* aGConf, const char* aMode)
83
{
84
  nsCAutoString mode;
85
  return NS_SUCCEEDED(aGConf->GetString(NS_LITERAL_CSTRING("/system/proxy/mode"), mode)) &&
86
      mode.EqualsASCII(aMode);
87
}
88
89
nsresult
90
nsUnixSystemProxySettings::GetPACURI(nsACString& aResult)
91
{
92
  if (!mGConf || !IsProxyMode(mGConf, "auto"))
93
    return NS_ERROR_FAILURE;
94
  return mGConf->GetString(NS_LITERAL_CSTRING("/system/proxy/autoconfig_url"),
95
                           aResult);
96
}
97
98
static PRBool
99
IsInNoProxyList(const nsACString& aHost, PRInt32 aPort, const char* noProxyVal)
100
{
101
  NS_ASSERTION(aPort >= 0, "Negative port?");
102
  
103
  nsCAutoString noProxy(noProxyVal);
104
  if (noProxy.EqualsLiteral("*"))
105
    return PR_TRUE;
106
    
107
  noProxy.StripWhitespace();
108
  
109
  nsReadingIterator<char> pos;
110
  nsReadingIterator<char> end;
111
  noProxy.BeginReading(pos);
112
  noProxy.EndReading(end);
113
  while (pos != end) {
114
    nsReadingIterator<char> last = pos;
115
    nsReadingIterator<char> nextPos;
116
    if (FindCharInReadable(',', last, end)) {
117
      nextPos = last;
118
      ++nextPos;
119
    } else {
120
      last = end;
121
      nextPos = end;
122
    }
123
    
124
    nsReadingIterator<char> colon = pos;
125
    PRInt32 port = -1;
126
    if (FindCharInReadable(':', colon, last)) {
127
      ++colon;
128
      nsDependentCSubstring portStr(colon, last);
129
      nsCAutoString portStr2(portStr);
130
      PRInt32 err;
131
      port = portStr2.ToInteger(&err);
132
      if (err != 0) {
133
        port = -2; // don't match any port, so we ignore this pattern
134
      }
135
      --colon;
136
    } else {
137
      colon = last;
138
    }
139
    
140
    if (port == -1 || port == aPort) {
141
      nsDependentCSubstring hostStr(pos, colon);
142
      if (StringEndsWith(aHost, hostStr, nsCaseInsensitiveCStringComparator()))
143
        return PR_TRUE;
144
    }
145
    
146
    pos = nextPos;
147
  }
148
  
149
  return PR_FALSE;
150
}
151
152
static void SetProxyResult(const char* aType, const nsACString& aHost,
153
                               PRInt32 aPort, nsACString& aResult)
154
{
155
  aResult.AppendASCII(aType);
156
  aResult.Append(' ');
157
  aResult.Append(aHost);
158
  aResult.Append(':');
159
  aResult.Append(nsPrintfCString("%d", aPort));
160
}
161
162
static nsresult
163
GetProxyForURIFromEnvironment(const nsACString& aScheme,
164
                              const nsACString& aHost,
165
                              PRInt32 aPort,
166
                              nsACString& aResult)
167
{
168
  nsCAutoString envVar;
169
  envVar.Append(aScheme);
170
  envVar.AppendLiteral("_proxy");
171
  const char* proxyVal = PR_GetEnv(envVar.get());
172
  if (!proxyVal) {
173
    proxyVal = PR_GetEnv("all_proxy");
174
    if (!proxyVal) {
175
      // Return failure so that the caller can detect the failure and
176
      // fall back to other proxy detection (e.g., WPAD)
177
      return NS_ERROR_FAILURE;
178
    }
179
  }
180
  
181
  const char* noProxyVal = PR_GetEnv("no_proxy");
182
  if (noProxyVal && IsInNoProxyList(aHost, aPort, noProxyVal)) {
183
    aResult.AppendLiteral("DIRECT");
184
    return NS_OK;
185
  }
186
  
187
  // Use our URI parser to crack the proxy URI
188
  nsCOMPtr<nsIURI> proxyURI;
189
  nsresult rv = NS_NewURI(getter_AddRefs(proxyURI), proxyVal);
190
  if (NS_FAILED(rv))
191
    return rv;
192
193
  // Is there a way to specify "socks://" or something in these environment
194
  // variables? I can't find any documentation.
195
  PRBool isHTTP;
196
  rv = proxyURI->SchemeIs("http", &isHTTP);
197
  if (NS_FAILED(rv))
198
    return rv;
199
  if (!isHTTP)
200
    return NS_ERROR_FAILURE;
201
202
  nsCAutoString proxyHost;
203
  rv = proxyURI->GetHost(proxyHost);
204
  if (NS_FAILED(rv))
205
    return rv;
206
  PRInt32 proxyPort;
207
  rv = proxyURI->GetPort(&proxyPort);
208
  if (NS_FAILED(rv))
209
    return rv;
210
211
  SetProxyResult("PROXY", proxyHost, proxyPort, aResult);
212
  return NS_OK;
213
}
214
215
static nsresult
216
SetProxyResultFromGConf(nsIGConfService* aGConf, const char* aKeyBase,
217
                        const char* aType, nsACString& aResult)
218
{
219
  nsCAutoString hostKey;
220
  hostKey.AppendASCII(aKeyBase);
221
  hostKey.AppendLiteral("host");
222
  nsCAutoString host;
223
  nsresult rv = aGConf->GetString(hostKey, host);
224
  if (NS_FAILED(rv))
225
    return rv;
226
  if (host.IsEmpty())
227
    return NS_ERROR_FAILURE;
228
  
229
  nsCAutoString portKey;
230
  portKey.AppendASCII(aKeyBase);
231
  portKey.AppendLiteral("port");
232
  PRInt32 port;
233
  rv = aGConf->GetInt(portKey, &port);
234
  if (NS_FAILED(rv))
235
    return rv;
236
    
237
  SetProxyResult(aType, host, port, aResult);
238
  return NS_OK;
239
}
240
241
/* copied from nsProtocolProxyService.cpp --- we should share this! */
242
static void
243
proxy_MaskIPv6Addr(PRIPv6Addr &addr, PRUint16 mask_len)
244
{
245
    if (mask_len == 128)
246
        return;
247
248
    if (mask_len > 96) {
249
        addr.pr_s6_addr32[3] = PR_htonl(
250
                PR_ntohl(addr.pr_s6_addr32[3]) & (~0L << (128 - mask_len)));
251
    }
252
    else if (mask_len > 64) {
253
        addr.pr_s6_addr32[3] = 0;
254
        addr.pr_s6_addr32[2] = PR_htonl(
255
                PR_ntohl(addr.pr_s6_addr32[2]) & (~0L << (96 - mask_len)));
256
    }
257
    else if (mask_len > 32) {
258
        addr.pr_s6_addr32[3] = 0;
259
        addr.pr_s6_addr32[2] = 0;
260
        addr.pr_s6_addr32[1] = PR_htonl(
261
                PR_ntohl(addr.pr_s6_addr32[1]) & (~0L << (64 - mask_len)));
262
    }
263
    else {
264
        addr.pr_s6_addr32[3] = 0;
265
        addr.pr_s6_addr32[2] = 0;
266
        addr.pr_s6_addr32[1] = 0;
267
        addr.pr_s6_addr32[0] = PR_htonl(
268
                PR_ntohl(addr.pr_s6_addr32[0]) & (~0L << (32 - mask_len)));
269
    }
270
}
271
272
static PRBool ConvertToIPV6Addr(const nsACString& aName,
273
                                PRIPv6Addr* aAddr)
274
{
275
  PRNetAddr addr;
276
  if (PR_StringToNetAddr(PromiseFlatCString(aName).get(), &addr) != PR_SUCCESS)
277
    return PR_FALSE;
278
279
  PRIPv6Addr ipv6;
280
  // convert parsed address to IPv6
281
  if (addr.raw.family == PR_AF_INET) {
282
    // convert to IPv4-mapped address
283
    PR_ConvertIPv4AddrToIPv6(addr.inet.ip, &ipv6);
284
  } else if (addr.raw.family == PR_AF_INET6) {
285
    // copy the address
286
    memcpy(&ipv6, &addr.ipv6.ip, sizeof(PRIPv6Addr));
287
  } else {
288
    return PR_FALSE;
289
  }
290
  
291
  return PR_TRUE;
292
}
293
294
static PRBool GConfIgnoreHost(const nsACString& aIgnore,
295
                              const nsACString& aHost)
296
{
297
  if (aIgnore.Equals(aHost, nsCaseInsensitiveCStringComparator()))
298
    return PR_TRUE;
299
300
  if (StringBeginsWith(aIgnore, NS_LITERAL_CSTRING("*")) &&
301
      StringEndsWith(aHost, nsDependentCSubstring(aIgnore, 1),
302
                     nsCaseInsensitiveCStringComparator()))
303
    return PR_TRUE;
304
305
  PRInt32 mask = 128;
306
  nsReadingIterator<char> start;
307
  nsReadingIterator<char> slash;
308
  nsReadingIterator<char> end;
309
  aIgnore.BeginReading(start);
310
  aIgnore.BeginReading(slash);
311
  aIgnore.EndReading(end);
312
  if (FindCharInReadable('/', slash, end)) {
313
    ++slash;
314
    nsDependentCSubstring maskStr(slash, end);
315
    nsCAutoString maskStr2(maskStr);
316
    PRInt32 err;
317
    mask = maskStr2.ToInteger(&err);
318
    if (err != 0) {
319
      mask = 128;
320
    }
321
    --slash;
322
  } else {
323
    slash = end;
324
  }
325
326
  PRIPv6Addr ignoreAddr, hostAddr;
327
  if (!ConvertToIPV6Addr(aIgnore, &ignoreAddr) ||
328
      !ConvertToIPV6Addr(aHost, &hostAddr))
329
    return PR_FALSE;
330
331
  proxy_MaskIPv6Addr(ignoreAddr, mask);
332
  proxy_MaskIPv6Addr(hostAddr, mask);
333
  
334
  return memcmp(&ignoreAddr, &hostAddr, sizeof(PRIPv6Addr)) == 0;
335
}
336
337
static nsresult
338
GetProxyForURIFromGConf(nsIGConfService* aGConf,
339
                        const nsACString& aScheme,
340
                        const nsACString& aHost,
341
                        PRInt32 aPort,
342
                        nsACString& aResult)
343
{
344
  if (!IsProxyMode(aGConf, "manual")) {
345
    aResult.AppendLiteral("DIRECT");
346
    return NS_OK;
347
  }
348
  
349
  nsCOMPtr<nsIArray> ignoreList;
350
  if (NS_SUCCEEDED(aGConf->GetStringList(NS_LITERAL_CSTRING("/system/http_proxy/ignore_hosts"),
351
                                         getter_AddRefs(ignoreList))) && ignoreList) {
352
    PRUint32 len = 0;
353
    ignoreList->GetLength(&len);
354
    for (PRUint32 i = 0; i < len; ++i) {
355
      nsCOMPtr<nsISupportsCString> str = do_QueryElementAt(ignoreList, i);
356
      if (str) {
357
        nsCAutoString s;
358
        if (NS_SUCCEEDED(str->GetData(s)) && !s.IsEmpty()) {
359
          if (GConfIgnoreHost(s, aHost)) {
360
            aResult.AppendLiteral("DIRECT");
361
            return NS_OK;
362
          }
363
        }
364
      }
365
    }
366
  }
367
  
368
  nsresult rv = SetProxyResultFromGConf(aGConf, "/system/proxy/socks_", "SOCKS", aResult);
369
  if (NS_SUCCEEDED(rv))
370
    return rv;
371
  
372
  if (aScheme.LowerCaseEqualsLiteral("http")) {
373
    rv = SetProxyResultFromGConf(aGConf, "/system/http_proxy/", "PROXY", aResult);
374
  } else if (aScheme.LowerCaseEqualsLiteral("https")) {
375
    rv = SetProxyResultFromGConf(aGConf, "/system/proxy/secure_", "PROXY", aResult);
376
  } else if (aScheme.LowerCaseEqualsLiteral("ftp")) {
377
    rv = SetProxyResultFromGConf(aGConf, "/system/proxy/ftp_", "PROXY", aResult);
378
  } else {
379
    rv = NS_ERROR_FAILURE;
380
  }
381
  
382
  if (NS_FAILED(rv)) {
383
    aResult.AppendLiteral("DIRECT");
384
  }
385
  return NS_OK;
386
}
387
388
nsresult
389
nsUnixSystemProxySettings::GetProxyForURI(nsIURI* aURI, nsACString& aResult)
390
{
391
  nsCAutoString scheme;
392
  nsresult rv = aURI->GetScheme(scheme);
393
  if (NS_FAILED(rv))
394
    return rv;
395
396
  nsCAutoString host;
397
  rv = aURI->GetHost(host);
398
  if (NS_FAILED(rv))
399
    return rv;
400
401
  PRInt32 port;
402
  rv = aURI->GetPort(&port);
403
  if (NS_FAILED(rv))
404
    return rv;
405
406
  if (!mGConf)
407
    return GetProxyForURIFromEnvironment(scheme, host, port, aResult);
408
409
  return GetProxyForURIFromGConf(mGConf, scheme, host, port, aResult);
410
}
411
412
#define NS_UNIXSYSTEMPROXYSERVICE_CID  /* 0fa3158c-d5a7-43de-9181-a285e74cf1d4 */\
413
     { 0x0fa3158c, 0xd5a7, 0x43de, \
414
       {0x91, 0x81, 0xa2, 0x85, 0xe7, 0x4c, 0xf1, 0xd4 } }
415
416
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUnixSystemProxySettings, Init)
417
418
static const nsModuleComponentInfo components[] = {
419
  { "Unix System Proxy Settings Service",
420
    NS_UNIXSYSTEMPROXYSERVICE_CID,
421
    NS_SYSTEMPROXYSETTINGS_CONTRACTID,
422
    nsUnixSystemProxySettingsConstructor }
423
};
424
425
NS_IMPL_NSGETMODULE(unixproxy, components)
(-)netwerk/base/public/Makefile.in (+1 lines)
Lines 93-104 XPIDLSRCS = \ Link Here
93
		nsIStreamListenerProxy.idl \
93
		nsIStreamListenerProxy.idl \
94
		nsIStreamListenerTee.idl \
94
		nsIStreamListenerTee.idl \
95
		nsISimpleStreamListener.idl \
95
		nsISimpleStreamListener.idl \
96
		nsIStreamTransportService.idl \
96
		nsIStreamTransportService.idl \
97
		nsIStreamLoader.idl \
97
		nsIStreamLoader.idl \
98
		nsISyncStreamListener.idl \
98
		nsISyncStreamListener.idl \
99
		nsISystemProxySettings.idl \
99
		nsIUnicharStreamLoader.idl \
100
		nsIUnicharStreamLoader.idl \
100
		nsIStandardURL.idl \
101
		nsIStandardURL.idl \
101
		nsIURLParser.idl \
102
		nsIURLParser.idl \
102
		nsIURIChecker.idl \
103
		nsIURIChecker.idl \
103
		nsISecurityEventSink.idl \
104
		nsISecurityEventSink.idl \
104
		nsISecretDecoderRing.idl \
105
		nsISecretDecoderRing.idl \
(-)Makefile.in (-1 / +2 lines)
Lines 292-304 endif Link Here
292
ifdef MOZ_LDAP_XPCOM
292
ifdef MOZ_LDAP_XPCOM
293
tier_50_dirs	+= directory/xpcom
293
tier_50_dirs	+= directory/xpcom
294
endif
294
endif
295
295
296
ifdef MOZ_XUL_APP
296
ifdef MOZ_XUL_APP
297
ifdef MOZ_ENABLE_GTK2
297
ifdef MOZ_ENABLE_GTK2
298
tier_50_dirs    += toolkit/components/gnome
298
tier_50_dirs    += toolkit/components/gnome \
299
		   toolkit/components/unixproxy
299
endif
300
endif
300
endif
301
endif
301
302
302
ifdef MOZ_LEAKY
303
ifdef MOZ_LEAKY
303
tier_50_dirs        += tools/leaky
304
tier_50_dirs        += tools/leaky
304
endif
305
endif
(-)allmakefiles.sh (+1 lines)
Lines 971-982 toolkit/components/console/Makefile Link Here
971
toolkit/components/cookie/Makefile
971
toolkit/components/cookie/Makefile
972
toolkit/components/downloads/public/Makefile
972
toolkit/components/downloads/public/Makefile
973
toolkit/components/downloads/Makefile
973
toolkit/components/downloads/Makefile
974
toolkit/components/downloads/src/Makefile
974
toolkit/components/downloads/src/Makefile
975
toolkit/components/filepicker/Makefile
975
toolkit/components/filepicker/Makefile
976
toolkit/components/gnome/Makefile
976
toolkit/components/gnome/Makefile
977
toolkit/components/unixproxy/Makefile
977
toolkit/components/help/Makefile
978
toolkit/components/help/Makefile
978
toolkit/components/history/Makefile
979
toolkit/components/history/Makefile
979
toolkit/components/history/public/Makefile
980
toolkit/components/history/public/Makefile
980
toolkit/components/history/src/Makefile
981
toolkit/components/history/src/Makefile
981
toolkit/components/passwordmgr/Makefile
982
toolkit/components/passwordmgr/Makefile
982
toolkit/components/passwordmgr/base/Makefile
983
toolkit/components/passwordmgr/base/Makefile
(-)browser/installer/unix/packages-static (+1 lines)
Lines 50-55 Link Here
50
bin/xpicleanup
50
bin/xpicleanup
51
51
52
; [Components]
52
; [Components]
53
bin/components/libunixproxy.so
53
bin/components/accessibility.xpt
54
bin/components/accessibility.xpt
54
bin/components/accessibility-atk.xpt
55
bin/components/accessibility-atk.xpt
55
bin/components/appshell.xpt
56
bin/components/appshell.xpt

Return to bug 132398