mozilla-libproxy.patch
author Wolfgang Rosenauer <wr@rosenauer.org>
Wed, 13 Jan 2010 23:53:53 +0100
changeset 50 00ee07727e73
parent 0 ad87c5e85a41
child 59 604517bb16d8
permissions -rw-r--r--
Files managed by update-alternatives should be packaged as %ghost files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     1
From: Wolfgang Rosenauer <wr@rosenauer.org>
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     2
Subject: Add the option to use libproxy for system proxy settings
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     3
References:
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     4
https://bugzilla.mozilla.org/show_bug.cgi?id=517655
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     5
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     6
diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     7
--- a/config/autoconf.mk.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     8
+++ b/config/autoconf.mk.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     9
@@ -537,16 +537,20 @@ FT2_CFLAGS             = @FT2_CFLAGS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    10
 FT2_LIBS               = @FT2_LIBS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    11
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    12
 MOZ_PANGO_CFLAGS        = @MOZ_PANGO_CFLAGS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    13
 MOZ_PANGO_LIBS          = @MOZ_PANGO_LIBS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    14
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    15
 MOZ_XIE_LIBS		= @MOZ_XIE_LIBS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    16
 XT_LIBS			= @XT_LIBS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    17
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    18
+MOZ_LIBPROXY_CFLAGS     = @MOZ_LIBPROXY_CFLAGS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    19
+MOZ_LIBPROXY_LIBS       = @MOZ_LIBPROXY_LIBS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    20
+MOZ_ENABLE_LIBPROXY     = @MOZ_ENABLE_LIBPROXY@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    21
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    22
 MOZ_LIBNOTIFY_CFLAGS	= @MOZ_LIBNOTIFY_CFLAGS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    23
 MOZ_LIBNOTIFY_LIBS	= @MOZ_LIBNOTIFY_LIBS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    24
 MOZ_ENABLE_LIBNOTIFY	= @MOZ_ENABLE_LIBNOTIFY@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    25
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    26
 GLIB_CFLAGS	= @GLIB_CFLAGS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    27
 GLIB_LIBS	= @GLIB_LIBS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    28
 GLIB_GMODULE_LIBS	= @GLIB_GMODULE_LIBS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    29
 LIBIDL_CFLAGS = @LIBIDL_CFLAGS@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    30
diff --git a/config/system-headers b/config/system-headers
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    31
--- a/config/system-headers
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    32
+++ b/config/system-headers
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    33
@@ -1007,15 +1007,19 @@ libsn/sn-monitor.h
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    34
 libsn/sn-util.h
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    35
 #endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    36
 #if MOZ_NATIVE_HUNSPELL==1
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    37
 hunspell.hxx
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    38
 #endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    39
 #if MOZ_NATIVE_BZ2==1
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    40
 bzlib.h
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    41
 #endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    42
+#ifdef MOZ_ENABLE_LIBPROXY
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    43
+proxy.h
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    44
+#endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    45
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    46
 #ifdef MOZ_PLATFORM_HILDON
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    47
 hildon-uri.h
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    48
 hildon-mime.h
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    49
 #endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    50
 #ifdef NS_OSSO
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    51
 libosso.h
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    52
 #endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    53
diff --git a/configure.in b/configure.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    54
--- a/configure.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    55
+++ b/configure.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    56
@@ -5280,16 +5280,39 @@ then
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    57
         AC_DEFINE(MOZ_ENABLE_DBUS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    58
     fi
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    59
 fi
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    60
 AC_SUBST(MOZ_ENABLE_DBUS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    61
 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    62
 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    63
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    64
 dnl ========================================================
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    65
+dnl = libproxy support
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    66
+dnl ========================================================
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    67
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    68
+if test "$MOZ_ENABLE_GTK2"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    69
+then
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    70
+    MOZ_ENABLE_LIBPROXY=
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    71
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    72
+    MOZ_ARG_ENABLE_BOOL(libproxy,
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    73
+    [  --enable-libproxy         Enable libproxy support ],
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    74
+    MOZ_ENABLE_LIBPROXY=1,
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    75
+    MOZ_ENABLE_LIBPROXY=)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    76
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    77
+    if test "$MOZ_ENABLE_LIBPROXY"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    78
+    then
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    79
+        PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    80
+        AC_DEFINE(MOZ_ENABLE_LIBPROXY)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    81
+    fi
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    82
+fi
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    83
+AC_SUBST(MOZ_ENABLE_LIBPROXY)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    84
+AC_SUBST(MOZ_LIBPROXY_CFLAGS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    85
+AC_SUBST(MOZ_LIBPROXY_LIBS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    86
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    87
+dnl ========================================================
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    88
 dnl = libnotify support
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    89
 dnl ========================================================
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    90
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    91
 if test "$MOZ_ENABLE_GTK2"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    92
 then
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    93
     MOZ_ENABLE_LIBNOTIFY=1
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    94
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    95
     MOZ_ARG_DISABLE_BOOL(libnotify,
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    96
diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    97
--- a/toolkit/library/Makefile.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    98
+++ b/toolkit/library/Makefile.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    99
@@ -247,16 +247,20 @@ endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   100
 ifdef MOZ_TREE_FREETYPE
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   101
 EXTRA_DSO_LDOPTS += $(FT2_LIBS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   102
 endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   103
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   104
 ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   105
 EXTRA_DSO_LDOPTS += $(MOZ_STARTUP_NOTIFICATION_LIBS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   106
 endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   107
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   108
+ifdef MOZ_ENABLE_LIBPROXY
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   109
+EXTRA_DSO_LDOPTS += $(MOZ_LIBPROXY_LIBS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   110
+endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   111
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   112
 ifeq ($(OS_ARCH),BeOS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   113
 EXTRA_DSO_LDOPTS += -lbe -ltracker
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   114
 endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   115
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   116
 ifeq ($(OS_ARCH),SunOS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   117
 EXTRA_DSO_LDOPTS += -lelf -ldemangle -lCstd
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   118
 endif
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   119
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   120
diff --git a/toolkit/system/unixproxy/Makefile.in b/toolkit/system/unixproxy/Makefile.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   121
--- a/toolkit/system/unixproxy/Makefile.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   122
+++ b/toolkit/system/unixproxy/Makefile.in
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   123
@@ -15,16 +15,17 @@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   124
 #
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   125
 # The Initial Developer of the Original Code is
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   126
 # IBM Corporation.
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   127
 # Portions created by the Initial Developer are Copyright (C) 2004
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   128
 # the Initial Developer. All Rights Reserved.
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   129
 #
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   130
 # Contributor(s):
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   131
 #  Brian Ryner <bryner@brianryner.com>
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   132
+#  Wolfgang Rosenauer <wr@rosenauer.org>
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   133
 #
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   134
 # Alternatively, the contents of this file may be used under the terms of
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   135
 # either the GNU General Public License Version 2 or later (the "GPL"), or
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   136
 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   137
 # in which case the provisions of the GPL or the LGPL are applicable instead
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   138
 # of those above. If you wish to allow use of your version of this file only
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   139
 # under the terms of either the GPL or the LGPL, and not to allow others to
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   140
 # use your version of this file under the terms of the MPL, indicate your
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   141
@@ -53,15 +54,30 @@ LIBXUL_LIBRARY  = 1
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   142
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   143
 REQUIRES = \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   144
         xpcom \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   145
         string \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   146
         necko \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   147
         mozgnome \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   148
         $(NULL)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   149
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   150
-EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   151
+EXTRA_DSO_LDOPTS += \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   152
+               $(MOZ_LIBPROXY_LIBS) \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   153
+               $(MOZ_COMPONENT_LIBS) \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   154
+               $(NULL)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   155
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   156
+ifdef MOZ_ENABLE_LIBPROXY
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   157
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   158
+CPPSRCS = \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   159
+       nsLibProxySettings.cpp \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   160
+        $(NULL)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   161
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   162
+CXXFLAGS += $(MOZ_LIBPROXY_CFLAGS)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   163
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   164
+else # MOZ_ENABLE_LIBPROXY
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   165
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   166
 CPPSRCS = \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   167
         nsUnixSystemProxySettings.cpp \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   168
         $(NULL)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   169
 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   170
+endif # MOZ_ENABLE_LIBPROXY
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   171
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   172
 include $(topsrcdir)/config/rules.mk
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   173
diff --git a/toolkit/system/unixproxy/nsLibProxySettings.cpp b/toolkit/system/unixproxy/nsLibProxySettings.cpp
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   174
new file mode 100644
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   175
--- /dev/null
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   176
+++ b/toolkit/system/unixproxy/nsLibProxySettings.cpp
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   177
@@ -0,0 +1,162 @@
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   178
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   179
+/* ***** BEGIN LICENSE BLOCK *****
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   180
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   181
+ *
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   182
+ * The contents of this file are subject to the Mozilla Public License Version
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   183
+ * 1.1 (the "License"); you may not use this file except in compliance with
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   184
+ * the License. You may obtain a copy of the License at
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   185
+ * http://www.mozilla.org/MPL/
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   186
+ *
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   187
+ * Software distributed under the License is distributed on an "AS IS" basis,
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   188
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   189
+ * for the specific language governing rights and limitations under the
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   190
+ * License.
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   191
+ *
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   192
+ * The Original Code is Mozilla libproxy integration code.
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   193
+ *
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   194
+ * The Initial Developer of the Original Code is
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   195
+ * Wolfgang Rosenauer <wr@rosenauer.org>.
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   196
+ * Portions created by the Initial Developer are Copyright (C) 2009
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   197
+ * the Initial Developer. All Rights Reserved.
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   198
+ *
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   199
+ * Contributor(s):
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   200
+ *
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   201
+ * Alternatively, the contents of this file may be used under the terms of
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   202
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   203
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   204
+ * in which case the provisions of the GPL or the LGPL are applicable instead
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   205
+ * of those above. If you wish to allow use of your version of this file only
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   206
+ * under the terms of either the GPL or the LGPL, and not to allow others to
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   207
+ * use your version of this file under the terms of the MPL, indicate your
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   208
+ * decision by deleting the provisions above and replace them with the notice
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   209
+ * and other provisions required by the GPL or the LGPL. If you do not delete
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   210
+ * the provisions above, a recipient may use your version of this file under
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   211
+ * the terms of any one of the MPL, the GPL or the LGPL.
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   212
+ *
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   213
+ * ***** END LICENSE BLOCK ***** */
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   214
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   215
+#include "nsISystemProxySettings.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   216
+#include "nsIGenericFactory.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   217
+#include "nsIServiceManager.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   218
+#include "nsIIOService.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   219
+#include "nsIURI.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   220
+#include "nsString.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   221
+#include "nsNetUtil.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   222
+#include "nsCOMPtr.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   223
+#include "nspr.h"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   224
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   225
+#include <proxy.h>
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   226
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   227
+class nsUnixSystemProxySettings : public nsISystemProxySettings {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   228
+public:
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   229
+  NS_DECL_ISUPPORTS
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   230
+  NS_DECL_NSISYSTEMPROXYSETTINGS
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   231
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   232
+  nsUnixSystemProxySettings() {}
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   233
+  nsresult Init();
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   234
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   235
+private:
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   236
+  ~nsUnixSystemProxySettings() {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   237
+    if (mProxyFactory) 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   238
+      px_proxy_factory_free(mProxyFactory); 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   239
+  }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   240
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   241
+  pxProxyFactory *mProxyFactory;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   242
+  nsCOMPtr<nsIIOService> mIOService;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   243
+};
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   244
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   245
+NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   246
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   247
+nsresult
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   248
+nsUnixSystemProxySettings::Init()
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   249
+{
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   250
+  mProxyFactory = nsnull;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   251
+  return NS_OK;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   252
+}
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   253
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   254
+nsresult
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   255
+nsUnixSystemProxySettings::GetPACURI(nsACString& aResult)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   256
+{
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   257
+  // Make sure we return an empty result.
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   258
+  aResult.Truncate();
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   259
+  return NS_OK;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   260
+}
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   261
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   262
+nsresult
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   263
+nsUnixSystemProxySettings::GetProxyForURI(nsIURI* aURI, nsACString& aResult)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   264
+{
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   265
+  nsresult rv;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   266
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   267
+  if (!mProxyFactory) {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   268
+    mProxyFactory = px_proxy_factory_new();
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   269
+  }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   270
+  NS_ENSURE_TRUE(mProxyFactory, NS_ERROR_OUT_OF_MEMORY);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   271
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   272
+  if (!mIOService) {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   273
+    mIOService = do_GetIOService();
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   274
+  }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   275
+  NS_ENSURE_TRUE(mIOService, NS_ERROR_FAILURE);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   276
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   277
+  nsCAutoString spec;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   278
+  rv = aURI->GetSpec(spec);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   279
+  NS_ENSURE_SUCCESS(rv, rv);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   280
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   281
+  char **proxyArray = nsnull;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   282
+  proxyArray = px_proxy_factory_get_proxies(mProxyFactory, (char*)(spec.get()));
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   283
+  NS_ENSURE_TRUE(proxyArray, NS_ERROR_FAILURE);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   284
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   285
+  // PAC string accepts
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   286
+  // http, proxy, socks, socks4, socks5, direct, unknown
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   287
+  // example: "PROXY proxy1.foo.com:8080; PROXY proxy2.foo.com:8080; DIRECT"
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   288
+  int c = 0;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   289
+  while (proxyArray[c] != NULL) {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   290
+    if (c != 0) {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   291
+      aResult.AppendLiteral("; ");
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   292
+    }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   293
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   294
+    PRBool isScheme = PR_FALSE;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   295
+    nsXPIDLCString schemeString;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   296
+    nsXPIDLCString hostPortString;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   297
+    nsCOMPtr<nsIURI> proxyURI;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   298
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   299
+    rv = mIOService->NewURI(nsDependentCString(proxyArray[c]), 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   300
+                                               nsnull, 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   301
+                                               nsnull, 
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   302
+                                               getter_AddRefs(proxyURI));
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   303
+    NS_ENSURE_SUCCESS(rv, rv);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   304
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   305
+    proxyURI->GetScheme(schemeString);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   306
+    if (NS_SUCCEEDED(proxyURI->SchemeIs("http", &isScheme)) && isScheme) {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   307
+      schemeString.AssignLiteral("proxy");
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   308
+    }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   309
+    aResult.Append(schemeString);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   310
+    if (NS_SUCCEEDED(proxyURI->SchemeIs("direct", &isScheme)) && !isScheme) {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   311
+      // Add the proxy URI only if it's not DIRECT
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   312
+      proxyURI->GetHostPort(hostPortString);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   313
+      aResult.AppendLiteral(" ");
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   314
+      aResult.Append(hostPortString);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   315
+    }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   316
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   317
+    c++;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   318
+  }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   319
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   320
+printf("returned PAC proxy string: %s\n", PromiseFlatCString(aResult).get());
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   321
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   322
+  PR_Free(proxyArray);
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   323
+  return NS_OK;
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   324
+}
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   325
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   326
+#define NS_UNIXSYSTEMPROXYSERVICE_CID  /* 0fa3158c-d5a7-43de-9181-a285e74cf1d4 */\
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   327
+     { 0x0fa3158c, 0xd5a7, 0x43de, \
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   328
+       {0x91, 0x81, 0xa2, 0x85, 0xe7, 0x4c, 0xf1, 0xd4 } }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   329
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   330
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUnixSystemProxySettings, Init)
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   331
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   332
+static const nsModuleComponentInfo components[] = {
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   333
+  { "Unix System Proxy Settings Service",
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   334
+    NS_UNIXSYSTEMPROXYSERVICE_CID,
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   335
+    NS_SYSTEMPROXYSETTINGS_CONTRACTID,
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   336
+    nsUnixSystemProxySettingsConstructor }
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   337
+};
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   338
+
ad87c5e85a41 patch status 20091128
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   339
+NS_IMPL_NSGETMODULE(nsUnixProxyModule, components)