From cea5b8a6ec5d4e8a0f3a82d493a653ededdccdbb Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Tue, 22 Sep 1998 22:41:27 +0000 Subject: [PATCH] mozilla - added mkprefs.h to the builds and replaced "*" pref strings with #defines. nglayout - added get & set methods for http proxies to nsINetService. git-svn-id: svn://10.0.0.236/trunk@10714 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/network/main/MANIFEST | 1 + mozilla/network/main/Makefile | 2 +- mozilla/network/main/makefile.win | 1 + mozilla/network/main/mkconect.c | 8 +- mozilla/network/main/mkgeturl.c | 95 ++++++++++++------------ mozilla/network/main/mkhelp.c | 7 +- mozilla/network/main/mkpadpac.h | 5 +- mozilla/network/main/mkprefs.h | 55 ++++++++++++++ mozilla/network/main/mkutils.c | 5 +- mozilla/network/module/nsINetService.h | 18 +++++ mozilla/network/module/nsNetService.cpp | 95 ++++++++++++++++++++++++ mozilla/network/module/nsNetService.h | 3 + mozilla/network/protocol/http/mkaccess.c | 6 +- mozilla/network/protocol/http/mkhttp.c | 11 ++- 14 files changed, 240 insertions(+), 72 deletions(-) create mode 100644 mozilla/network/main/mkprefs.h diff --git a/mozilla/network/main/MANIFEST b/mozilla/network/main/MANIFEST index 7ddf2115b29..a56154d11c3 100644 --- a/mozilla/network/main/MANIFEST +++ b/mozilla/network/main/MANIFEST @@ -17,3 +17,4 @@ mkutils.h mktrace.h mkhelp.h net_xp_file.h +mkprefs.h \ No newline at end of file diff --git a/mozilla/network/main/Makefile b/mozilla/network/main/Makefile index 003983006fb..362761bcea4 100644 --- a/mozilla/network/main/Makefile +++ b/mozilla/network/main/Makefile @@ -56,7 +56,7 @@ endif EXPORTS= mkstream.h mkparse.h mkfsort.h mksort.h mkgeturl.h \ netstream.h mkselect.h mktcp.h netutils.h mkpadpac.h mkautocf.h mkhelp.h \ - mkutils.h mktrace.h net_xp_file.h autoupdt.h + mkutils.h mktrace.h net_xp_file.h autoupdt.h mkprefs.h ifdef MOZ_MAIL_NEWS EXPORTS += mkldap.h diff --git a/mozilla/network/main/makefile.win b/mozilla/network/main/makefile.win index 029e1dc8074..f4b9d8ae9a8 100644 --- a/mozilla/network/main/makefile.win +++ b/mozilla/network/main/makefile.win @@ -113,6 +113,7 @@ REQUIRES= foo parse jtools java zlib nspr dbm util network js security mimetype !endif EXPORTS= mkstream.h \ net_xp_file.h \ + mkprefs.h \ mkparse.h \ mkfsort.h \ mksort.h \ diff --git a/mozilla/network/main/mkconect.c b/mozilla/network/main/mkconect.c index fe80d4d8a19..52daabaa95f 100644 --- a/mozilla/network/main/mkconect.c +++ b/mozilla/network/main/mkconect.c @@ -31,6 +31,7 @@ #include "prsystem.h" #include "prefapi.h" #include "mkpadpac.h" +#include "mkprefs.h" #if defined(XP_WIN) #define ASYNC_DNS @@ -159,7 +160,6 @@ typedef struct _DNSEntry { PRIVATE char * net_local_hostname=0; /* The name of this host */ PRIVATE XP_List * dns_list=0; -#define pref_dnsExpiration "network.dnsCacheExpiration" PRIVATE int32 dnsCacheExpiration=0; #define DEFAULT_TCP_CONNECT_TIMEOUT 35 /* seconds */ @@ -1098,11 +1098,11 @@ NET_BeginConnect (CONST char *url, if(!setupSocks) { setupSocks=TRUE; if (NET_GetProxyStyle() == PROXY_STYLE_MANUAL) { - if ( (PREF_OK != PREF_CopyCharPref("network.hosts.socks_server",&proxy)) + if ( (PREF_OK != PREF_CopyCharPref(pref_socksServer,&proxy)) || !proxy || !*proxy ) { NET_SetSocksHost(NULL); /* NULL is ok */ } else { - if ( PREF_OK == PREF_GetIntPref("network.hosts.socks_serverport",&iPort) ) { + if ( PREF_OK == PREF_GetIntPref(pref_socksPort,&iPort) ) { PR_snprintf(text, sizeof(text), "%s:%d", proxy, iPort); NET_SetSocksHost(text); } @@ -1187,7 +1187,7 @@ HG28879 /* Tell the FE about the failure */ int32 len = PL_strlen(XP_GetString(XP_PROGRESS_UNABLELOCATE)); char * buf; - if( (PREF_OK == PREF_CopyCharPref("network.hosts.socks_server",&prefSocksHost)) + if( (PREF_OK == PREF_CopyCharPref(pref_socksServer,&prefSocksHost)) && prefSocksHost) { len += PL_strlen(prefSocksHost); diff --git a/mozilla/network/main/mkgeturl.c b/mozilla/network/main/mkgeturl.c index 49cc51775f7..a774e6781cb 100644 --- a/mozilla/network/main/mkgeturl.c +++ b/mozilla/network/main/mkgeturl.c @@ -32,6 +32,7 @@ #include "mkstream.h" #include "mkpadpac.h" #include "netcache.h" +#include "mkprefs.h" #ifdef NU_CACHE #include "CacheStubs.h" #endif @@ -409,11 +410,11 @@ NET_UpdateManualProxyInfo(const char * prefChanged) { if (!prefChanged) bSetupAll = TRUE; - if (bSetupAll || !PL_strcmp(prefChanged, "network.proxy.ftp") || - !PL_strcmp(prefChanged, "network.proxy.ftp_port")) { - if( (PREF_OK == PREF_CopyCharPref("network.proxy.ftp",&proxy)) + if (bSetupAll || !PL_strcmp(prefChanged, pref_proxyFtpServer) || + !PL_strcmp(prefChanged, pref_proxyFtpPort)) { + if( (PREF_OK == PREF_CopyCharPref(pref_proxyFtpServer,&proxy)) && proxy && *proxy) { - if ( (PREF_OK == PREF_GetIntPref("network.proxy.ftp_port",&iPort)) ) { + if ( (PREF_OK == PREF_GetIntPref(pref_proxyFtpPort,&iPort)) ) { sprintf(text,"%s:%d", proxy, iPort); StrAllocCopy(MKftp_proxy, text); iPort=0; @@ -426,11 +427,11 @@ NET_UpdateManualProxyInfo(const char * prefChanged) { } if (proxy) FREE_AND_CLEAR(proxy); - if (bSetupAll || !PL_strcmp(prefChanged, "network.proxy.gopher") || - !PL_strcmp(prefChanged, "network.proxy.gopher_port")) { - if( (PREF_OK == PREF_CopyCharPref("network.proxy.ftp",&proxy)) + if (bSetupAll || !PL_strcmp(prefChanged, pref_proxyGopherServer) || + !PL_strcmp(prefChanged, pref_proxyGopherPort)) { + if( (PREF_OK == PREF_CopyCharPref(pref_proxyGopherServer,&proxy)) && proxy && *proxy) { - if ( (PREF_OK == PREF_GetIntPref("network.proxy.gopher_port",&iPort)) ) { + if ( (PREF_OK == PREF_GetIntPref(pref_proxyGopherPort,&iPort)) ) { sprintf(text,"%s:%d", proxy, iPort); StrAllocCopy(MKgopher_proxy, text); iPort=0; @@ -443,13 +444,15 @@ NET_UpdateManualProxyInfo(const char * prefChanged) { } if (proxy) FREE_AND_CLEAR(proxy); - if (bSetupAll || !PL_strcmp(prefChanged, "network.proxy.http") || - !PL_strcmp(prefChanged, "network.proxy.http_port")) { - if( (PREF_OK == PREF_CopyCharPref("network.proxy.http",&proxy)) + if (bSetupAll || !PL_strcmp(prefChanged, pref_proxyHttpServer) || + !PL_strcmp(prefChanged, pref_proxyHttpPort)) { + if( (PREF_OK == PREF_CopyCharPref(pref_proxyHttpServer,&proxy)) && proxy && *proxy) { - if ( (PREF_OK == PREF_GetIntPref("network.proxy.http_port",&iPort)) ) { - sprintf(text,"%s:%d", proxy, iPort); - StrAllocCopy(MKhttp_proxy, text); + if ( (PREF_OK == PREF_GetIntPref(pref_proxyHttpPort,&iPort)) ) { + sprintf(text,"%s:%d", proxy, iPort); + /* Don't change the proxy info unless necessary. */ + if (PL_strcmp(MKhttp_proxy, text)) + StrAllocCopy(MKhttp_proxy, text); iPort=0; } else { FREE_AND_CLEAR(MKhttp_proxy); @@ -463,11 +466,11 @@ NET_UpdateManualProxyInfo(const char * prefChanged) { HG24324 if (proxy) FREE_AND_CLEAR(proxy); - if (bSetupAll || !PL_strcmp(prefChanged, "network.proxy.news") || - !PL_strcmp(prefChanged, "network.proxy.news_port")) { - if( (PREF_OK == PREF_CopyCharPref("network.proxy.news",&proxy)) + if (bSetupAll || !PL_strcmp(prefChanged, pref_proxyNewsServer) || + !PL_strcmp(prefChanged, pref_proxyNewsPort)) { + if( (PREF_OK == PREF_CopyCharPref(pref_proxyNewsServer,&proxy)) && proxy && *proxy) { - if ( (PREF_OK == PREF_GetIntPref("network.proxy.news_port",&iPort)) ) { + if ( (PREF_OK == PREF_GetIntPref(pref_proxyNewsPort,&iPort)) ) { sprintf(text,"%s:%d", proxy, iPort); StrAllocCopy(MKnews_proxy, text); iPort=0; @@ -480,11 +483,11 @@ NET_UpdateManualProxyInfo(const char * prefChanged) { } if (proxy) FREE_AND_CLEAR(proxy); - if (bSetupAll || !PL_strcmp(prefChanged, "network.proxy.wais") || - !PL_strcmp(prefChanged, "network.proxy.wais_port")) { - if( (PREF_OK == PREF_CopyCharPref("network.proxy.wais",&proxy)) + if (bSetupAll || !PL_strcmp(prefChanged, pref_proxyWaisServer) || + !PL_strcmp(prefChanged, pref_proxyWaisPort)) { + if( (PREF_OK == PREF_CopyCharPref(pref_proxyWaisServer,&proxy)) && proxy && *proxy) { - if ( (PREF_OK == PREF_GetIntPref("network.proxy.wais_port",&iPort)) ) { + if ( (PREF_OK == PREF_GetIntPref(pref_proxyWaisPort,&iPort)) ) { sprintf(text,"%s:%d", proxy, iPort); StrAllocCopy(MKwais_proxy, text); iPort=0; @@ -497,11 +500,11 @@ NET_UpdateManualProxyInfo(const char * prefChanged) { } if (proxy) FREE_AND_CLEAR(proxy); - if (bSetupAll || !PL_strcmp(prefChanged, "network.hosts.socks_server") || - !PL_strcmp(prefChanged, "network.hosts.socks_serverport")) { - if ( (PREF_OK == PREF_CopyCharPref("network.hosts.socks_server",&proxy)) + if (bSetupAll || !PL_strcmp(prefChanged, pref_socksServer) || + !PL_strcmp(prefChanged, pref_socksPort)) { + if ( (PREF_OK == PREF_CopyCharPref(pref_socksServer,&proxy)) && proxy && *proxy) { - if ( (PREF_OK == PREF_GetIntPref("network.hosts.socks_serverport",&iPort)) ) { + if ( (PREF_OK == PREF_GetIntPref(pref_socksPort,&iPort)) ) { PR_snprintf(text, sizeof(text), "%s:%d", proxy, iPort); NET_SetSocksHost(text); } else { @@ -515,8 +518,8 @@ NET_UpdateManualProxyInfo(const char * prefChanged) { } if (proxy) FREE_AND_CLEAR(proxy); - if (bSetupAll || !PL_strcmp(prefChanged, "network.proxy.no_proxies_on")) { - if( (PREF_OK == PREF_CopyCharPref("network.proxy.no_proxies_on",&proxy)) + if (bSetupAll || !PL_strcmp(prefChanged, pref_proxyNoProxiesOn)) { + if( (PREF_OK == PREF_CopyCharPref(pref_proxyNoProxiesOn,&proxy)) && proxy && *proxy) { StrAllocCopy(MKno_proxy, proxy); } else { @@ -570,7 +573,7 @@ NET_SelectProxyStyle(NET_ProxyStyle style) if (MKproxy_style == PROXY_STYLE_AUTOMATIC) { /* Get the autoconfig url */ - if ( (PREF_OK == PREF_CopyCharPref("network.proxy.autoconfig_url",&proxy)) + if ( (PREF_OK == PREF_CopyCharPref(pref_proxyACUrl,&proxy)) && proxy && *proxy) { StrAllocCopy(MKproxy_ac_url, proxy); NET_ProxyAcLoaded = FALSE; @@ -617,41 +620,41 @@ NET_SetupPrefs(const char * prefChanged) if (!prefChanged) bSetupAll = TRUE; - if (bSetupAll || !PL_strcmp(prefChanged, "network.dnsCacheExpiration")) { + if (bSetupAll || !PL_strcmp(prefChanged, pref_dnsExpiration)) { int32 n; - if ( (PREF_OK != PREF_GetIntPref("network.dnsCacheExpiration",&n)) ) { + if ( (PREF_OK != PREF_GetIntPref(pref_dnsExpiration,&n)) ) { n = DEF_DNS_EXPIRATION; } NET_SetDNSExpirationPref(n); } - if (bSetupAll || !PL_strcmp(prefChanged,"browser.prefetch")) { + if (bSetupAll || !PL_strcmp(prefChanged, pref_browserPrefetch)) { int32 n; - if ( (PREF_OK != PREF_GetIntPref("browser.prefetch",&n)) ) { + if ( (PREF_OK != PREF_GetIntPref(pref_browserPrefetch,&n)) ) { n = 0; } PRE_Enable((PRUint8)n); } - if (bSetupAll || !PL_strcmp(prefChanged,"browser.cache.memory_cache_size")) { + if (bSetupAll || !PL_strcmp(prefChanged,pref_browserCacheMemSize)) { int32 nMemCache; - if ( (PREF_OK != PREF_GetIntPref("browser.cache.memory_cache_size",&nMemCache)) ) { + if ( (PREF_OK != PREF_GetIntPref(pref_browserCacheMemSize,&nMemCache)) ) { nMemCache = DEF_MEM_CACHE_SIZE; } NET_SetMemoryCacheSize(nMemCache * 1024); } - if (bSetupAll || !PL_strcmp(prefChanged,"browser.cache.disk_cache_size")) { + if (bSetupAll || !PL_strcmp(prefChanged,pref_browserCacheDiskSize)) { int32 nDiskCache; - if ( (PREF_OK != PREF_GetIntPref("browser.cache.disk_cache_size",&nDiskCache)) ) { + if ( (PREF_OK != PREF_GetIntPref(pref_browserCacheDiskSize,&nDiskCache)) ) { nDiskCache = DEF_DISK_CACHE_SIZE; } NET_SetDiskCacheSize(nDiskCache * 1024); } - if (bSetupAll || !PL_strcmp(prefChanged, "browser.cache.check_doc_frequency")) { + if (bSetupAll || !PL_strcmp(prefChanged, pref_browserCacheDocFreq)) { int32 nDocReqFreq; - if ( (PREF_OK != PREF_GetIntPref("browser.cache.check_doc_frequency" ,&nDocReqFreq)) ) { + if ( (PREF_OK != PREF_GetIntPref(pref_browserCacheDocFreq,&nDocReqFreq)) ) { nDocReqFreq = DEF_CHECK_DOC_FREQ; } NET_SetCacheUseMethod((CacheUseEnum)nDocReqFreq); @@ -659,17 +662,17 @@ NET_SetupPrefs(const char * prefChanged) HG42422 #ifdef MOZ_MAIL_NEWS - if (bSetupAll || !PL_strcmp(prefChanged,"mail.allow_at_sign_in_user_name")) { + if (bSetupAll || !PL_strcmp(prefChanged,pref_mailAllowSignInUName)) { XP_Bool prefBool; - if ( (PREF_OK != PREF_GetBoolPref("mail.allow_at_sign_in_user_name",&prefBool)) ) { + if ( (PREF_OK != PREF_GetBoolPref(pref_mailAllowSignInUName,&prefBool)) ) { prefBool = DEF_ALLOW_AT_SIGN_UNAME; } NET_SetAllowAtSignInMailUserName (prefBool); } #endif /* MOZ_MAIL_NEWS */ - if (bSetupAll || !PL_strcmp(prefChanged,"network.proxy.autoconfig_url")) { - if ( (PREF_OK == PREF_CopyCharPref("network.proxy.autoconfig_url",&proxy)) + if (bSetupAll || !PL_strcmp(prefChanged,pref_proxyACUrl)) { + if ( (PREF_OK == PREF_CopyCharPref(pref_proxyACUrl,&proxy)) && proxy && *proxy) { StrAllocCopy(MKproxy_ac_url, proxy); NET_ProxyAcLoaded = FALSE; @@ -681,9 +684,9 @@ NET_SetupPrefs(const char * prefChanged) NET_UpdateManualProxyInfo(prefChanged); - if (bSetupAll || !PL_strcmp(prefChanged, "network.proxy.type")) { + if (bSetupAll || !PL_strcmp(prefChanged, pref_proxyType)) { int32 iType; - if ( (PREF_OK != PREF_GetIntPref("network.proxy.type",&iType)) ) { + if ( (PREF_OK != PREF_GetIntPref(pref_proxyType,&iType)) ) { iType = DEF_PROXY_TYPE; } NET_SelectProxyStyle((NET_ProxyStyle)iType); @@ -2405,7 +2408,7 @@ NET_GetURL (URL_Struct *URL_s, { char *pUrl; FREE(munged); - if ( (PREF_OK == PREF_CopyCharPref("network.search.url",&pUrl)) + if ( (PREF_OK == PREF_CopyCharPref(pref_searchUrl,&pUrl)) && pUrl) { munged = PR_smprintf("%s%s", pUrl, escaped); FREE(escaped); diff --git a/mozilla/network/main/mkhelp.c b/mozilla/network/main/mkhelp.c index 9f573511782..67365ce7af1 100644 --- a/mozilla/network/main/mkhelp.c +++ b/mozilla/network/main/mkhelp.c @@ -30,6 +30,7 @@ #include "libmocha.h" /* For the onHelp handler */ #include "prefapi.h" /* For the onHelp handler */ #include "fe_proto.h" +#include "mkprefs.h" extern char * INTL_ResourceCharSet(void); @@ -43,8 +44,6 @@ extern int MK_CANT_LOAD_HELP_TOPIC; #define DEFAULT_HELP_WINDOW_WIDTH 400 #define PREF_NSCP_HELP_URL "http://help.netscape.com/nethelp/" /* This must include the trailing slash */ -#define PREF_DEFAULT_HELP_LOC_ID "general.help_source.site" /* FIXME: Shouldn't this be defined somewhere else? */ -#define PREF_DEFAULT_HELP_URL_ID "general.help_source.url" /* FIXME: Shouldn't this be defined somewhere else? */ /* Tokens within the .hpf file to parse for */ @@ -201,7 +200,7 @@ net_get_default_help_URL(char **pHelpBase) int success; int32 helpType; - if ((success = PREF_GetIntPref(PREF_DEFAULT_HELP_LOC_ID, &helpType)) + if ((success = PREF_GetIntPref(pref_generalHelpSource, &helpType)) == PREF_NOERROR) { switch (helpType) { @@ -213,7 +212,7 @@ net_get_default_help_URL(char **pHelpBase) *pHelpBase = FE_GetNetHelpDir(); break; case 2: - success = PREF_CopyCharPref(PREF_DEFAULT_HELP_URL_ID, pHelpBase); + success = PREF_CopyCharPref(pref_generalHelpSourceUrl, pHelpBase); break; default: success = PREF_ERROR; diff --git a/mozilla/network/main/mkpadpac.h b/mozilla/network/main/mkpadpac.h index 73fcb59f74c..230e35be3d7 100644 --- a/mozilla/network/main/mkpadpac.h +++ b/mozilla/network/main/mkpadpac.h @@ -43,10 +43,7 @@ #define MKPADPAC_H #include "xp.h" - -/* Pad js pref names */ -#define pref_padPacURL "network.padPacURL" -#define pref_enablePad "network.enablePad" +#include "mkprefs.h" /* Global pad variables */ extern PRBool foundPADPAC; diff --git a/mozilla/network/main/mkprefs.h b/mozilla/network/main/mkprefs.h new file mode 100644 index 00000000000..f11d5600087 --- /dev/null +++ b/mozilla/network/main/mkprefs.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef __mkprefs_h_ +#define __mkprefs_h_ + +#define pref_browserPrefetch "browser.prefetch" +#define pref_browserCacheMemSize "browser.cache.memory_cache_size" +#define pref_browserCacheDiskSize "browser.cache.disk_cache_size" +#define pref_browserCacheDocFreq "browser.cache.check_doc_frequency" +#define pref_mailAllowSignInUName "mail.allow_at_sign_in_user_name" +#define pref_dnsExpiration "network.dnsCacheExpiration" +#define pref_socksPort "network.hosts.socks_serverport" +#define pref_socksServer "network.hosts.socks_server" +#define pref_proxyACUrl "network.proxy.autoconfig_url" +#define pref_proxyType "network.proxy.type" +#define pref_proxyFtpPort "network.proxy.ftp_port" +#define pref_proxyFtpServer "network.proxy.ftp" +#define pref_proxyGopherPort "network.proxy.gopher_port" +#define pref_proxyGopherServer "network.proxy.gopher" +#define pref_proxyHttpPort "network.proxy.http_port" +#define pref_proxyHttpServer "network.proxy.http" +#define pref_proxyNewsPort "network.proxy.news_port" +#define pref_proxyNewsServer "network.proxy.news" +#define pref_proxyWaisPort "network.proxy.wais_port" +#define pref_proxyWaisServer "network.proxy.wais" +#define pref_proxyNoProxiesOn "network.proxy.no_proxies_on" +#define pref_generalHelpSource "general.help_source.site" +#define pref_generalHelpSourceUrl "general.help_source.url" +#define pref_padPacURL "network.padPacURL" +#define pref_enablePad "network.enablePad" +#define pref_mailQuotedStyle "mail.quoted_style" +#define pref_cookieBehavior "network.cookie.cookieBehavior" +#define pref_warnAboutCookies "network.cookie.warnAboutCookies" +#define pref_scriptName "network.cookie.filterName" +#define pref_goBrowsingEnabled "browser.goBrowsing.enabled" +#define pref_sendRefererHeader "network.sendRefererHeader" +#define pref_searchUrl "network.search.url" + +#endif /* __mkprefs_h_ */ diff --git a/mozilla/network/main/mkutils.c b/mozilla/network/main/mkutils.c index 230a2ce8744..13da7e6abe2 100644 --- a/mozilla/network/main/mkutils.c +++ b/mozilla/network/main/mkutils.c @@ -30,6 +30,7 @@ #include "rosetta.h" #include "mkutils.h" #include "net_xp_file.h" +#include "mkprefs.h" #include "gui.h" #include "mkparse.h" #include "mkgeturl.h" @@ -1792,14 +1793,14 @@ NET_ScanForURLs(MSG_Pane* pane, const char *input, int32 input_size, net_citation_style_changed, NULL); } - if ( (PREF_OK == PREF_GetIntPref("mail.quoted_style", &value)) ) { + if ( (PREF_OK == PREF_GetIntPref(pref_mailQuotedStyle, &value)) ) { CitationFont = (MSG_FONT) value; } else { CitationFont = MSG_ItalicFont; } CitationSize = 0; - if ( (PREF_OK != PREF_GetIntPref("mail.quoted_size", &CitationSize)) ) { + if ( (PREF_OK != PREF_GetIntPref(pref_mailQuotedStyle, &CitationSize)) ) { CitationSize = 0; } FREEIF(CitationColor); diff --git a/mozilla/network/module/nsINetService.h b/mozilla/network/module/nsINetService.h index 04368b97912..f4388c512ac 100644 --- a/mozilla/network/module/nsINetService.h +++ b/mozilla/network/module/nsINetService.h @@ -101,6 +101,24 @@ struct nsINetService : public nsISupports * @return Returns NS_OK if successful, or NS_FALSE if an error occurred. */ NS_IMETHOD SetCookieString(nsIURL *aURL, const nsString& aCookie)=0; + + /** + * Get the http proxy used for http transactions. + * + * @param aProxyHTTP The url used as a proxy. The url is of the form + * "host.server:port". + * @return Returns NS_OK if successful, or NS_FALSE if an error occurred. + */ + NS_IMETHOD GetProxyHTTP(nsString& aProxyHTTP)=0; + + /** + * Set the http proxy to be used for http transactions. + * + * @param aProxyHTTP The url to use as a proxy. The url is of the form + * "host.server:port". + * @return Returns NS_OK if successful, or NS_FALSE if an error occurred. + */ + NS_IMETHOD SetProxyHTTP(nsString& aProxyHTTP)=0; }; diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp index 6f331c40a4d..1ef513c9996 100644 --- a/mozilla/network/module/nsNetService.cpp +++ b/mozilla/network/module/nsNetService.cpp @@ -22,6 +22,8 @@ #include "nsNetService.h" #include "nsNetStream.h" #include "nsNetFile.h" +#include "prefapi.h" +#include "mkprefs.h" extern "C" { #include "mkutils.h" #include "mkgeturl.h" @@ -108,6 +110,28 @@ nsNetlibService::nsNetlibService(nsINetContainerApplication *aContainerApp) mNetlibThread->Start(); } + /* Setup our default prefs. Eventually these will come out of a default + * all.js file, but, for now each module needs to address their own + * default settings. */ + + PREF_SetDefaultIntPref(pref_proxyType, 3); + PREF_SetDefaultCharPref(pref_proxyACUrl, ""); + PREF_SetDefaultCharPref(pref_socksServer, ""); + PREF_SetDefaultIntPref(pref_socksPort, 0); + PREF_SetDefaultCharPref(pref_proxyFtpServer, ""); + PREF_SetDefaultIntPref(pref_proxyFtpPort, 0); + PREF_SetDefaultCharPref(pref_proxyGopherServer, ""); + PREF_SetDefaultIntPref(pref_proxyGopherPort, 0); + PREF_SetDefaultCharPref(pref_proxyHttpServer, ""); + PREF_SetDefaultIntPref(pref_proxyHttpPort, 0); + PREF_SetDefaultCharPref(pref_proxyNewsServer, ""); + PREF_SetDefaultIntPref(pref_proxyNewsPort, 0); + PREF_SetDefaultCharPref(pref_proxyWaisServer, ""); + PREF_SetDefaultIntPref(pref_proxyWaisPort, 0); + PREF_SetDefaultCharPref(pref_proxyNoProxiesOn, ""); + PREF_SetDefaultCharPref(pref_padPacURL, ""); + PREF_SetDefaultCharPref(pref_scriptName, ""); + if (NULL != aContainerApp) { XP_AppCodeName = NULL; XP_AppVersion = NULL; @@ -562,6 +586,77 @@ nsNetlibService::SetCookieString(nsIURL *aURL, const nsString& aCookie) return NS_OK; } + +NS_IMETHODIMP +nsNetlibService::GetProxyHTTP(nsString& aProxyHTTP) { + char *proxy = nsnull; + int32 port; + char outBuf[MAXHOSTNAMELEN + 8]; + *outBuf = '\0'; + + if ( PREF_OK != PREF_CopyCharPref(pref_proxyHttpServer,&proxy) ) { + return NS_FALSE; + } + + if ( PREF_OK != PREF_GetIntPref(pref_proxyHttpPort,&port) ) { + PR_FREEIF(proxy); + return NS_FALSE; + } + + sprintf(outBuf,"%s:%d", proxy, port); + PR_FREEIF(proxy); + aProxyHTTP.SetString(outBuf); + + return NS_OK; +} + +NS_IMETHODIMP +nsNetlibService::SetProxyHTTP(nsString& aProxyHTTP) { + nsresult rv = NS_OK; + PRInt32 port; + nsString nsSPort; + char *csPort = nsnull; + char *proxy = nsnull; + nsString nsSProxy; + PRInt32 colonIdx; + PRUnichar colon = ':'; + + if (aProxyHTTP.Length() < 1) { + NET_SelectProxyStyle(PROXY_STYLE_NONE); + return NS_OK; + } + + if ( (colonIdx = aProxyHTTP.Find(colon)) < 0 ) + return NS_FALSE; + + aProxyHTTP.Left(nsSProxy, colonIdx); + aProxyHTTP.Mid(nsSPort, colonIdx+1, aProxyHTTP.Length() - colonIdx); + + proxy = nsSProxy.ToNewCString(); + if (!proxy) + return NS_FALSE; + csPort = nsSPort.ToNewCString(); + if (!csPort) { + delete proxy; + return NS_FALSE; + } + + port = atoi(csPort); + + if ( PREF_OK != PREF_SetCharPref(pref_proxyHttpServer, proxy) ) { + rv = NS_FALSE; + } + if ( PREF_OK != PREF_SetIntPref(pref_proxyHttpPort, port) ) { + rv = NS_FALSE; + } + delete proxy; + delete csPort; + + NET_SelectProxyStyle(PROXY_STYLE_MANUAL); + + return rv; +} + void nsNetlibService::SchedulePollingTimer() { #if !defined(NETLIB_THREAD) diff --git a/mozilla/network/module/nsNetService.h b/mozilla/network/module/nsNetService.h index a9f47fd0163..eff72a58514 100644 --- a/mozilla/network/module/nsNetService.h +++ b/mozilla/network/module/nsNetService.h @@ -49,6 +49,9 @@ public: NS_IMETHOD GetCookieString(nsIURL *aURL, nsString& aCookie); NS_IMETHOD SetCookieString(nsIURL *aURL, const nsString& aCookie); + NS_IMETHOD GetProxyHTTP(nsString& aProxyHTTP); + NS_IMETHOD SetProxyHTTP(nsString& aProxyHTTP); + protected: virtual ~nsNetlibService(); diff --git a/mozilla/network/protocol/http/mkaccess.c b/mozilla/network/protocol/http/mkaccess.c index aa3c11a04b6..f3f05b8fb54 100644 --- a/mozilla/network/protocol/http/mkaccess.c +++ b/mozilla/network/protocol/http/mkaccess.c @@ -32,6 +32,7 @@ #define alphabetize 1 #include "rosetta.h" #include "xp.h" +#include "mkprefs.h" #include "netutils.h" #include "mkselect.h" #include "mktcp.h" @@ -153,11 +154,6 @@ PRIVATE NET_CookieBehaviorEnum net_CookieBehavior = NET_Accept; PRIVATE Bool net_WarnAboutCookies = FALSE; PRIVATE char *net_scriptName = (char *)0; -static const char *pref_cookieBehavior = "network.cookie.cookieBehavior"; -static const char *pref_warnAboutCookies = "network.cookie.warnAboutCookies"; -static const char *pref_scriptName = "network.cookie.filterName"; - - /* * Different schemes supported by the client. * Order means the order of preference between authentication schemes. diff --git a/mozilla/network/protocol/http/mkhttp.c b/mozilla/network/protocol/http/mkhttp.c index 38ce030046c..8a59dd2e171 100644 --- a/mozilla/network/protocol/http/mkhttp.c +++ b/mozilla/network/protocol/http/mkhttp.c @@ -34,6 +34,7 @@ #include "mkpadpac.h" #include "prerror.h" #include "net_xp_file.h" +#include "mkprefs.h" #include "merrors.h" @@ -366,7 +367,7 @@ net_check_for_company_hostname(ActiveEntry *ce) Bool add_com = FALSE; Bool goBrowsing = FALSE; - if (PREF_GetBoolPref("browser.goBrowsing.enabled", &goBrowsing) != PREF_OK) goBrowsing = 0; + if (PREF_GetBoolPref(pref_goBrowsingEnabled, &goBrowsing) != PREF_OK) goBrowsing = 0; if(!cd->orig_host) { char *dot=NULL; @@ -398,7 +399,7 @@ net_check_for_company_hostname(ActiveEntry *ce) /* no dots in hostname */ if (goBrowsing && !PL_strchr(ce->URL_s->address, '/')) { char *pUrl; - if ( (PREF_OK == PREF_CopyCharPref("network.search.url",&pUrl)) + if ( (PREF_OK == PREF_CopyCharPref(pref_searchUrl,&pUrl)) && pUrl) { char *tmp = NET_ParseURL(ce->URL_s->address, GET_HOST_PART); char* new_address = PR_smprintf("%sgo+%s", pUrl, tmp); @@ -3677,13 +3678,11 @@ net_CleanupHTTP(void) return; } -#define REFERER_HEADER_PREF "network.sendRefererHeader" - PRIVATE void HTTP_ReadPrefs(void) { XP_Bool b; - if ( (PREF_OK != PREF_GetBoolPref("network.sendRefererHeader", &b)) ) { + if ( (PREF_OK != PREF_GetBoolPref(pref_sendRefererHeader, &b)) ) { b = TRUE; } NET_SetSendRefererHeader(b); @@ -3699,7 +3698,7 @@ PRIVATE void HTTP_InitPrefs(void) { HTTP_ReadPrefs(); - PREF_RegisterCallback(REFERER_HEADER_PREF ,HTTP_PrefChangedFunc,NULL); + PREF_RegisterCallback(pref_sendRefererHeader ,HTTP_PrefChangedFunc,NULL); } #define HTTP_SCHEME "http:"