From 0cd7b6fe381ae886d83153c33bb2d3bf1bdcd0b8 Mon Sep 17 00:00:00 2001 From: scullin Date: Tue, 9 Jun 1998 22:50:19 +0000 Subject: [PATCH] Moving client stuff into client. git-svn-id: svn://10.0.0.236/branches/scullin_BRANCH@3572 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/network/client/Makefile | 2 +- mozilla/network/client/cnetinit.c | 275 +++++++++++++++++++++- mozilla/network/client/makefile.win | 29 ++- mozilla/network/macbuild/network.mcp | Bin 72434 -> 80410 bytes mozilla/network/main/makefile.win | 1 - mozilla/network/main/mkgeturl.c | 165 ------------- mozilla/network/module/nsNetStubs.cpp | 83 ------- mozilla/network/protocol/about/abouturl.h | 41 +++- mozilla/network/protocol/about/mkabout.c | 122 ++++++---- mozilla/network/protocol/http/mkaccess.c | 6 +- 10 files changed, 396 insertions(+), 328 deletions(-) diff --git a/mozilla/network/client/Makefile b/mozilla/network/client/Makefile index 68d464abf4e..e93103abbf8 100644 --- a/mozilla/network/client/Makefile +++ b/mozilla/network/client/Makefile @@ -30,6 +30,6 @@ endif EXPORTS= cnetinit.h REQUIRES = netcache network img layer fileurl httpurl ftpurl abouturl \ - gophurl jsurl remoturl dataurl util + gophurl jsurl remoturl dataurl util java jtools include $(DEPTH)/config/rules.mk diff --git a/mozilla/network/client/cnetinit.c b/mozilla/network/client/cnetinit.c index c1bb281bbd1..936c0c48721 100644 --- a/mozilla/network/client/cnetinit.c +++ b/mozilla/network/client/cnetinit.c @@ -1,10 +1,29 @@ - +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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. + */ #include "xp.h" +#include "mkutils.h" #include "netutils.h" #include "mkselect.h" #include "mktcp.h" #include "mkgeturl.h" +#include "plstr.h" +#include "prmem.h" #include "fileurl.h" #include "httpurl.h" @@ -17,26 +36,258 @@ #include "dataurl.h" #include "netcache.h" -#if defined(JAVA) && defined(XP_MAC) +#if defined(JAVA) #include "marimurl.h" #endif +/* For random protocols */ +#include "htmldlgs.h" +#include "libevent.h" +#include "libi18n.h" +#include "secnav.h" +extern int MK_MALFORMED_URL_ERROR; + +/* For about handlers */ +#include "il_strm.h" +#include "glhist.h" + +PRIVATE void net_InitTotallyRandomStuffPeopleAddedProtocols(void); +PRIVATE void net_InitAboutURLs(); PUBLIC void NET_ClientProtocolInitialize(void) { - NET_InitFileProtocol(); - NET_InitHTTPProtocol(); - NET_InitMemCacProtocol(); - NET_InitFTPProtocol(); - NET_InitAboutProtocol(); - NET_InitGopherProtocol(); - NET_InitMochaProtocol(); - NET_InitRemoteProtocol(); - NET_InitDataURLProtocol(); + NET_InitFileProtocol(); + NET_InitHTTPProtocol(); + NET_InitMemCacProtocol(); + NET_InitFTPProtocol(); + NET_InitAboutProtocol(); + NET_InitGopherProtocol(); + NET_InitMochaProtocol(); + NET_InitRemoteProtocol(); + NET_InitDataURLProtocol(); #ifdef JAVA - NET_InitMarimbaProtocol(); + NET_InitMarimbaProtocol(); +#endif + + net_InitTotallyRandomStuffPeopleAddedProtocols(); + + net_InitAboutURLs(); +} + +/* print out security URL + */ +PRIVATE int net_output_security_url(ActiveEntry * cur_entry, MWContext *cx) +{ + NET_StreamClass * stream; + char * content_type; + char * which = cur_entry->URL_s->address; + char * colon = PL_strchr (which, ':'); + + if (colon) + { + /* found the first colon; now find the question mark + (as in "about:security?certs"). */ + which = colon + 1; + colon = PL_strchr (which, '?'); + if (colon) + which = colon + 1; + else + which = which + PL_strlen (which); /* give it "" */ + } + + content_type = SECNAV_SecURLContentType(which); + if (!content_type) { + cur_entry->status = MK_MALFORMED_URL_ERROR; + + } else if (!PL_strcasecmp(content_type, "advisor")) { + cur_entry->status = SECNAV_SecHandleSecurityAdvisorURL(cx, which); + + } else { + int status; + + StrAllocCopy(cur_entry->URL_s->content_type, content_type); + + cur_entry->format_out = CLEAR_CACHE_BIT(cur_entry->format_out); + + stream = NET_StreamBuilder(cur_entry->format_out, + cur_entry->URL_s, cur_entry->window_id); + + if (!stream) + return(MK_UNABLE_TO_CONVERT); + + status = SECNAV_SecURLData(which, stream, cx); + + if (status >= 0) { + (*stream->complete) (stream); + } else { + (*stream->abort) (stream, status); + } + + cur_entry->status = status; + + FREE(stream); + } + + return(-1); +} + +PRIVATE int32 +net_SecurityURLLoad(ActiveEntry *ce) +{ + if(ce->URL_s) + StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet()); + return net_output_security_url(ce, ce->window_id); +} + +PRIVATE int32 +net_SeclibURLLoad(ActiveEntry *ce) +{ + if(ce->URL_s) + StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet()); + SECNAV_HandleInternalSecURL(ce->URL_s, ce->window_id); + return -1; +} + +PRIVATE int32 +net_HTMLPanelLoad(ActiveEntry *ce) +{ + if(ce->URL_s) + StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet()); + XP_HandleHTMLPanel(ce->URL_s); + return -1; +} + +PRIVATE int32 +net_HTMLDialogLoad(ActiveEntry *ce) +{ + if(ce->URL_s) + StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet()); + XP_HandleHTMLDialog(ce->URL_s); + return -1; +} + +PRIVATE int32 +net_WysiwygLoad(ActiveEntry *ce) +{ + const char *real_url = LM_SkipWysiwygURLPrefix(ce->URL_s->address); + char *new_address; + + /* XXX can't use StrAllocCopy because it frees dest first */ + if (real_url && (new_address = PL_strdup(real_url)) != NULL) + { + PR_Free(ce->URL_s->address); + ce->URL_s->address = new_address; + FREE_AND_CLEAR(ce->URL_s->wysiwyg_url); + } + + /* no need to free real_url */ + + ce->status = MK_DO_REDIRECT; + return MK_DO_REDIRECT; +} + +PRIVATE int32 +net_ProtoMainStub(ActiveEntry *ce) +{ +#ifdef DO_ANNOYING_ASSERTS_IN_STUBS + PR_ASSERT(0); +#endif + return -1; +} + +PRIVATE void +net_ProtoCleanupStub(void) +{ +} + +PRIVATE void +net_reg_random_protocol(NET_ProtoInitFunc *LoadRoutine, int type) +{ + NET_ProtoImpl *random_proto_impl; + + random_proto_impl = PR_NEW(NET_ProtoImpl); + + if(!random_proto_impl) + return; + + random_proto_impl->init = LoadRoutine; + random_proto_impl->process = net_ProtoMainStub; + random_proto_impl->interrupt = net_ProtoMainStub; + random_proto_impl->cleanup = net_ProtoCleanupStub; + + NET_RegisterProtocolImplementation(random_proto_impl, type); +} + +/* don't you just hate it when people come along and hack this + * kind of stuff into your code. + * + * @@@ clean this up some time + */ +PRIVATE void +net_InitTotallyRandomStuffPeopleAddedProtocols(void) +{ + net_reg_random_protocol(net_SecurityURLLoad, SECURITY_TYPE_URL); + net_reg_random_protocol(net_SeclibURLLoad, INTERNAL_SECLIB_TYPE_URL); + net_reg_random_protocol(net_HTMLPanelLoad, HTML_PANEL_HANDLER_TYPE_URL); + net_reg_random_protocol(net_HTMLDialogLoad, HTML_DIALOG_HANDLER_TYPE_URL); + net_reg_random_protocol(net_WysiwygLoad, WYSIWYG_TYPE_URL); +} + +#ifdef XP_UNIX +extern void FE_ShowMinibuffer(MWContext *); + +PRBool net_AboutMinibuffer(const char *token, + FO_Present_Types format_out, + URL_Struct *URL_s, + MWContext *window_id) +{ + FE_ShowMinibuffer(window_id); + + return PR_TRUE; +} +#endif + +#ifdef WEBFONTS +PRBool net_AboutFonts(const char *token, + FO_Present_Types format_out, + URL_Struct *URL_s, + MWContext *window_id) +{ + NF_AboutFonts(window_id, which); + return PR_TRUE; +} +#endif /* WEBFONTS */ + +PRBool net_AboutImageCache(const char *token, + FO_Present_Types format_out, + URL_Struct *URL_s, + MWContext *window_id) +{ + IL_DisplayMemCacheInfoAsHTML(format_out, URL_s, window_id); + return PR_TRUE; +} + +PRBool net_AboutGlobalHistory(const char *token, + FO_Present_Types format_out, + URL_Struct *URL_s, + MWContext *window_id) +{ + NET_DisplayGlobalHistoryInfoAsHTML(window_id, URL_s, format_out); + + return PR_TRUE; +} + +PRIVATE void net_InitAboutURLs() +{ + NET_RegisterAboutProtocol("image-cache*", net_AboutImageCache); + NET_RegisterAboutProtocol("global", net_AboutGlobalHistory); +#ifdef XP_UNIX + NET_RegisterAboutProtocol("minibuffer", net_AboutMinibuffer); +#endif +#ifdef WEBFONTS + NET_RegisterAboutProtocol("fonts*", net_AboutFonts); #endif } diff --git a/mozilla/network/client/makefile.win b/mozilla/network/client/makefile.win index 3aed106133a..a248ce4e5f1 100644 --- a/mozilla/network/client/makefile.win +++ b/mozilla/network/client/makefile.win @@ -65,18 +65,23 @@ REQUIRES= network # use LINCS on win32 for now since REQUIRES seems to be broken #!if "$(MOZ_BITS)" != "16" LINCS= \ - -I$(XPDIST)\public\network \ - -I$(XPDIST)\public\netcache \ - -I$(XPDIST)\public\abouturl \ - -I$(XPDIST)\public\dataurl \ - -I$(XPDIST)\public\fileurl \ - -I$(XPDIST)\public\ftpurl \ - -I$(XPDIST)\public\gophurl \ - -I$(XPDIST)\public\httpurl \ - -I$(XPDIST)\public\jsurl \ - -I$(XPDIST)\public\certurl \ - -I$(XPDIST)\public\remoturl \ - -I$(XPDIST)\public\marimurl + -I$(PUBLIC)\java \ + -I$(PUBLIC)\jtools \ + -I$(PUBLIC)\js \ + -I$(PUBLIC)\htmldlgs \ + -I$(PUBLIC)\security \ + -I$(PUBLIC)\network \ + -I$(PUBLIC)\netcache \ + -I$(PUBLIC)\abouturl \ + -I$(PUBLIC)\dataurl \ + -I$(PUBLIC)\fileurl \ + -I$(PUBLIC)\ftpurl \ + -I$(PUBLIC)\gophurl \ + -I$(PUBLIC)\httpurl \ + -I$(PUBLIC)\jsurl \ + -I$(PUBLIC)\certurl \ + -I$(PUBLIC)\remoturl \ + -I$(PUBLIC)\marimurl #!endif !endif diff --git a/mozilla/network/macbuild/network.mcp b/mozilla/network/macbuild/network.mcp index 00d618c5c26c23af1fc4aa6c7cc6a0f6804acc6b..07f96c5d92ebc3393141e44983867d07203bb9b3 100644 GIT binary patch delta 745 zcmY+CT}YEr7{{OIymMP^Br|*Wk?11JKGrmgRfAvyp^P~!3K=Y#`;y_>WNipCx(T~0 zoA1R-QWz|>8>?~1-Gp=#b)#K`7U9fp?IMbb^1}6O?_%|EIEV8;zyEoj^YQJOYU;bH zC6r9Y0YCu21AyJ<0FR{r)Q?CzQ)nr%oq%h!whrK!0XRuAu1TM!jZ%lFRVSblfFOB< z;cYadbp(`N2m_{k!`pJXxImWwqJbN7+nE#)RQ$9$fYLsX^&jKq+pqX7?WEY`7^kgD ziqj!g(&pT4yuVG4xXOLjQN$8o+_S0TZ}#t2Yx1fe0G9@6>rIqC+l`vMa0S59N5XI9 z?Gqo6uXg*~eCv*0&BgmVmg~1wOUPz@dwJr)xI=QyY0UPd^Fm|{ypi;1GBw;231)^A ziJwpVktg53J|zV=?iNopVGrYry?Uk7X{k;%XsGYxuC$REnBDHD7LHv@`$satcuYF_ z(ai&Cj@mK>frt5_FO97EAl+RJ4kZ)O*pUC~V2yo>l?p92-d+cTnOHnr=L%KMRO4)Q zE|v(zGhwMvZl%mCRqAi{Bi#A5k?|YZpk9FK<>K{b^de)wFVcbPJ?NZMUAJ)-< delta 482 zcmbRBh2_&$7MbMy{2T@b24)5ZMhyl=;UES^ktzlTwhEw_>qeQoO!_R0j0}tn5R!rM z4p7|#1_rZM1_leD5)hw(6No{e8Hl+iEBL5R_GQkR%w;Sw`8>0S#Jq^l|NpN%4pxCg zux|d?!NoK=fth8qEn5O3CnL}r29Q;g6_}-&7#Jo;^_|+>%P~o8qPyYd0C^t9%?S!6 zjGJ#LerMTyTuqsceO|Qvb1_qH05OE!Kp!hn7_=LaH=b18!N!`d}U=Zp7%Par<29)0bk!Sib{hTRd zKjXIPab}FmnAqn`XESG9&bVy)I&(&G#$VHqnKSB3u0rU21lc0LP6Ge#yK Kq3Ldxj7tDOV1S+g diff --git a/mozilla/network/main/makefile.win b/mozilla/network/main/makefile.win index 8f71b307b9b..5b2e0c50db5 100644 --- a/mozilla/network/main/makefile.win +++ b/mozilla/network/main/makefile.win @@ -128,7 +128,6 @@ LINCS=-I$(PUBLIC)\jtools \ -I$(PUBLIC)\lay \ -I$(PUBLIC)\style \ -I$(PUBLIC)\pref \ - -I$(PUBLIC)\htmldlgs \ -I$(PUBLIC)\java \ -I$(PUBLIC)\libfont \ -I$(PUBLIC)\netcache \ diff --git a/mozilla/network/main/mkgeturl.c b/mozilla/network/main/mkgeturl.c index c1445c425e0..2a70b07cb32 100644 --- a/mozilla/network/main/mkgeturl.c +++ b/mozilla/network/main/mkgeturl.c @@ -84,9 +84,6 @@ #endif #include "libi18n.h" -#ifndef MODULAR_NETLIB -#include "htmldlgs.h" -#endif #include "np.h" #include "prefapi.h" @@ -319,8 +316,6 @@ PRIVATE NETExitCallbackNode *NETExitCallbackHead = NULL; /* forward decl */ PRIVATE void net_cleanup_reg_protocol_impls(void); -PRIVATE void NET_InitTotallyRandomStuffPeopleAddedProtocols(void); - /* fix Mac warning for missing prototype */ @@ -738,8 +733,6 @@ NET_InitNetLib(int socket_buffer_size, int max_number_of_connections) NET_InitNFSProtocol(); NET_InitURNProtocol(); NET_InitWAISProtocol(); - NET_InitTotallyRandomStuffPeopleAddedProtocols(); - NET_InitMailtoProtocol(); /* has a stub for MOZ_MAIL_NEWS */ #ifdef MOZ_MAIL_NEWS NET_InitNewsProtocol(); @@ -4282,164 +4275,6 @@ PRIVATE void add_slash_to_URL (URL_Struct *URL_s) } #ifdef MOZILLA_CLIENT -/* print out security URL - */ -PRIVATE int net_output_security_url(ActiveEntry * cur_entry, MWContext *cx) -{ - NET_StreamClass * stream; - char * content_type; - char * which = cur_entry->URL_s->address; - char * colon = PL_strchr (which, ':'); - - if (colon) - { - /* found the first colon; now find the question mark - (as in "about:security?certs"). */ - which = colon + 1; - colon = PL_strchr (which, '?'); - if (colon) - which = colon + 1; - else - which = which + PL_strlen (which); /* give it "" */ - } - - content_type = SECNAV_SecURLContentType(which); - if (!content_type) { - cur_entry->status = MK_MALFORMED_URL_ERROR; - - } else if (!PL_strcasecmp(content_type, "advisor")) { - cur_entry->status = SECNAV_SecHandleSecurityAdvisorURL(cx, which); - - } else { - int status; - - StrAllocCopy(cur_entry->URL_s->content_type, content_type); - - cur_entry->format_out = CLEAR_CACHE_BIT(cur_entry->format_out); - - stream = NET_StreamBuilder(cur_entry->format_out, - cur_entry->URL_s, cur_entry->window_id); - - if (!stream) - return(MK_UNABLE_TO_CONVERT); - - status = SECNAV_SecURLData(which, stream, cx); - - if (status >= 0) { - (*stream->complete) (stream); - } else { - (*stream->abort) (stream, status); - } - - cur_entry->status = status; - - FREE(stream); - } - - return(-1); -} - -PRIVATE int32 -net_SecurityURLLoad(ActiveEntry *ce) -{ - if(ce->URL_s) - StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet()); - return net_output_security_url(ce, ce->window_id); -} - -PRIVATE int32 -net_SeclibURLLoad(ActiveEntry *ce) -{ - if(ce->URL_s) - StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet()); - SECNAV_HandleInternalSecURL(ce->URL_s, ce->window_id); - return -1; -} - -PRIVATE int32 -net_HTMLPanelLoad(ActiveEntry *ce) -{ - if(ce->URL_s) - StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet()); - XP_HandleHTMLPanel(ce->URL_s); - return -1; -} - -PRIVATE int32 -net_HTMLDialogLoad(ActiveEntry *ce) -{ - if(ce->URL_s) - StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet()); - XP_HandleHTMLDialog(ce->URL_s); - return -1; -} - -PRIVATE int32 -net_WysiwygLoad(ActiveEntry *ce) -{ - const char *real_url = LM_SkipWysiwygURLPrefix(ce->URL_s->address); - char *new_address; - - /* XXX can't use StrAllocCopy because it frees dest first */ - if (real_url && (new_address = PL_strdup(real_url)) != NULL) - { - PR_Free(ce->URL_s->address); - ce->URL_s->address = new_address; - FREE_AND_CLEAR(ce->URL_s->wysiwyg_url); - } - - /* no need to free real_url */ - - ce->status = MK_DO_REDIRECT; - return MK_DO_REDIRECT; -} - -PRIVATE int32 -net_ProtoMainStub(ActiveEntry *ce) -{ -#ifdef DO_ANNOYING_ASSERTS_IN_STUBS - PR_ASSERT(0); -#endif - return -1; -} - -PRIVATE void -net_ProtoCleanupStub(void) -{ -} - -PRIVATE void -net_reg_random_protocol(NET_ProtoInitFunc *LoadRoutine, int type) -{ - NET_ProtoImpl *random_proto_impl; - - random_proto_impl = PR_NEW(NET_ProtoImpl); - - if(!random_proto_impl) - return; - - random_proto_impl->init = LoadRoutine; - random_proto_impl->process = net_ProtoMainStub; - random_proto_impl->interrupt = net_ProtoMainStub; - random_proto_impl->cleanup = net_ProtoCleanupStub; - - NET_RegisterProtocolImplementation(random_proto_impl, type); -} - -/* don't you just hate it when people come along and hack this - * kind of stuff into your code. - * - * @@@ clean this up some time - */ -PRIVATE void -NET_InitTotallyRandomStuffPeopleAddedProtocols(void) -{ - net_reg_random_protocol(net_SecurityURLLoad, SECURITY_TYPE_URL); - net_reg_random_protocol(net_SeclibURLLoad, INTERNAL_SECLIB_TYPE_URL); - net_reg_random_protocol(net_HTMLPanelLoad, HTML_PANEL_HANDLER_TYPE_URL); - net_reg_random_protocol(net_HTMLDialogLoad, HTML_DIALOG_HANDLER_TYPE_URL); - net_reg_random_protocol(net_WysiwygLoad, WYSIWYG_TYPE_URL); -} #endif /* MOZILLA_CLIENT */ diff --git a/mozilla/network/module/nsNetStubs.cpp b/mozilla/network/module/nsNetStubs.cpp index ee5f170852f..d155e5b5f3c 100644 --- a/mozilla/network/module/nsNetStubs.cpp +++ b/mozilla/network/module/nsNetStubs.cpp @@ -19,7 +19,6 @@ #include "nsNetStubs.h" #include "nspr.h" -#include "xp_hash.h" #include "xp_file.h" #include "libi18n.h" #include "libevent.h" @@ -27,7 +26,6 @@ #include "net.h" extern "C" { -#include "secnav.h" #include "preenc.h" }; @@ -262,29 +260,6 @@ PUBLIC void INTL_CCCReportMetaCharsetTag(MWContext *context, char *charset_tag) MOZ_FUNCTION_STUB; } -/* - *--------------------------------------------------------------------------- - * From ns/cmd/winfe/authdll.cpp - *--------------------------------------------------------------------------- - */ -char * WFE_BuildCompuserveAuthString(URL_Struct *URL_s) -{ - MOZ_FUNCTION_STUB; - return NULL; -} - - -int -WFE_DoCompuserveAuthenticate(MWContext *context, - URL_Struct *URL_s, - char *authenticate_header_value) -{ - MOZ_FUNCTION_STUB; - return NET_AUTH_FAILED_DONT_DISPLAY; -} - - - /* *--------------------------------------------------------------------------- * From ns/cmd/winfe/regproto.cpp @@ -521,19 +496,6 @@ IL_Type(const char *buf, int32 len) *--------------------------------------------------------------------------- */ -/* - * Create an HTML stream and generate HTML describing - * the image cache. Use "about:memory-cache" URL to acess. - */ -int -IL_DisplayMemCacheInfoAsHTML(FO_Present_Types format_out, URL_Struct *urls, - OPAQUE_CONTEXT *cx) -{ - MOZ_FUNCTION_STUB; - return 0; -} - - char * IL_HTMLImageInfo(char *url_address) { @@ -597,22 +559,6 @@ GH_SaveGlobalHistory(void) MOZ_FUNCTION_STUB; } - - -/* create an HTML stream and push a bunch of HTML about - * the global history - */ -MODULE_PRIVATE int -NET_DisplayGlobalHistoryInfoAsHTML(MWContext *context, - URL_Struct *URL_s, - int format_out) -{ - MOZ_FUNCTION_STUB; - return MK_UNABLE_TO_CONVERT; -} - - - /* *--------------------------------------------------------------------------- * From ns/lib/libmisc/shist.c @@ -653,35 +599,6 @@ LM_SkipWysiwygURLPrefix(const char *url_string) return NULL; } - - -/* - *--------------------------------------------------------------------------- - * From ns/lib/htmldlgs/htmldlgs.c - *--------------------------------------------------------------------------- - */ - -void -XP_HandleHTMLPanel(URL_Struct *url) -{ - MOZ_FUNCTION_STUB; -} - - -void -XP_HandleHTMLDialog(URL_Struct *url) -{ - MOZ_FUNCTION_STUB; -} - - -/* - *--------------------------------------------------------------------------- - * From ns/nav-java/netscape/net/netStubs.c - *--------------------------------------------------------------------------- - */ - - /* *--------------------------------------------------------------------------- * From ns/modules/softupdt/src/softupdt.c diff --git a/mozilla/network/protocol/about/abouturl.h b/mozilla/network/protocol/about/abouturl.h index 370bdc52931..7ff0af3cb7c 100644 --- a/mozilla/network/protocol/about/abouturl.h +++ b/mozilla/network/protocol/about/abouturl.h @@ -1,8 +1,47 @@ - +/* -*- 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 ABOUTURL_H #define ABOUTURL_H PUBLIC void NET_InitAboutProtocol(void); +/* + * About protocol registration stuff + */ + +/* Callback for registered about protocols. + * Should return PR_TRUE if the token was handled */ +typedef PRBool (*NET_AboutCB)(const char *token, + FO_Present_Types format_out, + URL_Struct *URL_s, + MWContext *window_id); + +/* Wildcard token for FE about protocol handling + * Otherwise unhandled tokens will match on this */ +#define FE_ABOUT_TOKEN ("FEABOUT") + +/* About protocol registration function. + * Returns PR_TRUE if registration succeeds. + * Registration will fail if token or callback is null, + * or token has already been registered */ +PUBLIC PRBool NET_RegisterAboutProtocol(const char *token, + NET_AboutCB callback); + + #endif /* ABOUTURL_H */ diff --git a/mozilla/network/protocol/about/mkabout.c b/mozilla/network/protocol/about/mkabout.c index 9a56c1ca2c4..053c02b9919 100644 --- a/mozilla/network/protocol/about/mkabout.c +++ b/mozilla/network/protocol/about/mkabout.c @@ -1,3 +1,21 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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. + */ + #include "xp.h" #include "net.h" #include "netutils.h" @@ -9,7 +27,7 @@ #include "xplocale.h" #include "prefapi.h" #include "secnav.h" -#ifndef MODULAR_NETLIB +#ifndef STANDALONE_IMAGE_LIB #include "libimg.h" #endif #include "il_strm.h" @@ -20,6 +38,7 @@ #include "shist.h" #include "prmem.h" #include "plstr.h" +#include "plhash.h" #include "abouturl.h" @@ -52,6 +71,27 @@ extern int XP_DOCUMENT_INFO ; extern int XP_THE_WINDOW_IS_NOW_INACTIVE ; extern int MK_MALFORMED_URL_ERROR; +static PRHashTable *net_AboutTable = NULL; + +PRIVATE PRIntn net_AboutComparator(const void *v1, const void *v2) +{ + char *idx = NULL; + if (idx = PL_strchr((char *) v2, '*')) { + int len = (int)(idx - v2); + return PL_strncasecmp((char *) v1, (char *) v2, len) == 0; + } else { + return PL_strcasecmp((char *) v1, (char *) v2) == 0; + } +} + +PRIVATE PRBool net_DoRegisteredAbout(const char *which, ActiveEntry *entry) +{ + NET_AboutCB cb; + if (cb = (NET_AboutCB) PL_HashTableLookup(net_AboutTable, which)) { + return cb(which, entry->format_out, entry->URL_s, entry->window_id); + } + return PR_FALSE; +} PRIVATE void net_OutputURLDocInfo(MWContext *ctxt, char *which, char **data, int32 *length) @@ -379,17 +419,11 @@ PRIVATE int net_output_about_url(ActiveEntry * cur_entry) NET_RemoveAllAuthorizations(); return(-1); } - else if(!PL_strcasecmp(which, "image-cache")) - { - IL_DisplayMemCacheInfoAsHTML(cur_entry->format_out, cur_entry->URL_s, - cur_entry->window_id); - return(-1); - } #ifdef DEBUG else if(!PL_strcasecmp(which, "streams")) { - NET_DisplayStreamInfoAsHTML(cur_entry); - return(-1); + NET_DisplayStreamInfoAsHTML(cur_entry); + return(-1); } #endif /* DEBUG */ else if(!PL_strcasecmp(which, "document")) @@ -447,18 +481,7 @@ PRIVATE int net_output_about_url(ActiveEntry * cur_entry) if(cur_entry->URL_s->window_chrome) { memset(cur_entry->URL_s->window_chrome, 0, sizeof(Chrome)); - /* it should be MWContextDialog - * but X isn't ready for it yet... - */ -/* X is ready for MWContextDialog now... - *#ifdef XP_UNIX - * cur_entry->URL_s->window_chrome->type = MWContextBrowser; - *#else - */ cur_entry->URL_s->window_chrome->type = MWContextDialog; -/* - *#endif - */ cur_entry->URL_s->window_chrome->show_scrollbar = TRUE; cur_entry->URL_s->window_chrome->allow_resize = TRUE; cur_entry->URL_s->window_chrome->allow_close = TRUE; @@ -497,16 +520,6 @@ PRIVATE int net_output_about_url(ActiveEntry * cur_entry) length = PL_strlen(data); StrAllocCopy(content_type, TEXT_HTML); } - else if(!PL_strncasecmp(which, "Global", 6)) - { - cur_entry->status = NET_DisplayGlobalHistoryInfoAsHTML( - cur_entry->window_id, - cur_entry->URL_s, - cur_entry->format_out); - - return(-1); - - } else if(!PL_strncmp(which, "FeCoNtExT=", 10)) { MWContext *old_ctxt; @@ -557,23 +570,11 @@ PRIVATE int net_output_about_url(ActiveEntry * cur_entry) content_type = PL_strdup(TEXT_HTML); } } -#if defined(XP_UNIX) && !defined(MODULAR_NETLIB) - else if (!PL_strncasecmp(which, "minibuffer", 10)) - { - extern void FE_ShowMinibuffer(MWContext *); - - FE_ShowMinibuffer(cur_entry->window_id); - } -#endif -#ifdef WEBFONTS - else if (!PL_strncasecmp(which, "fonts", 5)) - { - NF_AboutFonts(cur_entry->window_id, which); - return (-1); - } -#endif /* WEBFONTS */ else { + if (net_DoRegisteredAbout(which, cur_entry)) { + return -1; + } fe_data = FE_AboutData(which, &data, &length, &content_type); uses_fe_data=TRUE; } @@ -806,6 +807,18 @@ PRIVATE Bool net_about_kludge(URL_Struct *URL_s) } } +PRBool NET_RegisterAboutProtocol(const char *token, + NET_AboutCB callback) +{ + if (!token || !callback) { + return PR_FALSE; + } + if (PL_HashTableLookup(net_AboutTable, token) != NULL) { + return PR_FALSE; + } + PL_HashTableAdd(net_AboutTable, token, callback); +} + PRIVATE int32 net_AboutLoad(ActiveEntry *ce) { @@ -830,17 +843,24 @@ net_AboutStub(ActiveEntry *ce) PRIVATE void net_CleanupAbout(void) { + PL_HashTableDestroy(net_AboutTable); } PUBLIC void NET_InitAboutProtocol(void) { - static NET_ProtoImpl about_proto_impl; + static NET_ProtoImpl about_proto_impl; - about_proto_impl.init = net_AboutLoad; - about_proto_impl.process = net_AboutStub; - about_proto_impl.interrupt = net_AboutStub; - about_proto_impl.cleanup = net_CleanupAbout; + about_proto_impl.init = net_AboutLoad; + about_proto_impl.process = net_AboutStub; + about_proto_impl.interrupt = net_AboutStub; + about_proto_impl.cleanup = net_CleanupAbout; - NET_RegisterProtocolImplementation(&about_proto_impl, ABOUT_TYPE_URL); + NET_RegisterProtocolImplementation(&about_proto_impl, ABOUT_TYPE_URL); + + net_AboutTable = PL_NewHashTable(32, + PL_HashString, + net_AboutComparator, + PL_CompareValues, + NULL, NULL); } diff --git a/mozilla/network/protocol/http/mkaccess.c b/mozilla/network/protocol/http/mkaccess.c index 17ee4e7a2a9..94d25c90f09 100644 --- a/mozilla/network/protocol/http/mkaccess.c +++ b/mozilla/network/protocol/http/mkaccess.c @@ -230,7 +230,8 @@ NET_BuildAuthString(MWContext * context, URL_Struct *URL_s) net_AuthStruct * auth_s = net_CheckForAuthorization(address, FALSE); if(!auth_s) -#if defined(XP_WIN) && defined(MOZILLA_CLIENT) +/* #if defined(XP_WIN) && defined(MOZILLA_CLIENT) */ +#if 0 return(WFE_BuildCompuserveAuthString(URL_s)); #else return(NULL); @@ -492,7 +493,8 @@ NET_AskForAuthString(MWContext *context, */ PR_FREEIF(host); -#if defined(XP_WIN) && defined(MOZILLA_CLIENT) +/* #if defined(XP_WIN) && defined(MOZILLA_CLIENT) */ +#if 0 return(WFE_DoCompuserveAuthenticate(context, URL_s, authenticate_header_value)); #else return(NET_AUTH_FAILED_DISPLAY_DOCUMENT);