зеркало из https://github.com/mozilla/gecko-dev.git
Bug 388195 - Remove gopher support. r=jduell,gavin sr=bz
This commit is contained in:
Родитель
2d9fa26437
Коммит
308e5cd202
|
@ -928,7 +928,7 @@ function makePreview(row)
|
||||||
var imageContainer = document.getElementById("theimagecontainer");
|
var imageContainer = document.getElementById("theimagecontainer");
|
||||||
var oldImage = document.getElementById("thepreviewimage");
|
var oldImage = document.getElementById("thepreviewimage");
|
||||||
|
|
||||||
const regex = /^(https?|ftp|file|gopher|about|chrome|resource):/;
|
const regex = /^(https?|ftp|file|about|chrome|resource):/;
|
||||||
var isProtocolAllowed = regex.test(url);
|
var isProtocolAllowed = regex.test(url);
|
||||||
if (/^data:/.test(url) && /^image\//.test(mimeType))
|
if (/^data:/.test(url) && /^image\//.test(mimeType))
|
||||||
isProtocolAllowed = true;
|
isProtocolAllowed = true;
|
||||||
|
|
|
@ -407,8 +407,6 @@ nsDogbertProfileMigrator::PrefTransform gTransforms[] = {
|
||||||
{ "network.proxy.autoconfig_url", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
{ "network.proxy.autoconfig_url", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||||
{ "network.proxy.ftp", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
{ "network.proxy.ftp", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||||
{ "network.proxy.ftp_port", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
{ "network.proxy.ftp_port", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||||
{ "network.proxy.gopher", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
|
||||||
{ "network.proxy.gopher_port", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
|
||||||
{ "network.proxy.http", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
{ "network.proxy.http", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||||
{ "network.proxy.http_port", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
{ "network.proxy.http_port", 0, F(GetInt), F(SetInt), PR_FALSE, { -1 } },
|
||||||
{ "network.proxy.ssl", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
{ "network.proxy.ssl", 0, F(GetString), F(SetString), PR_FALSE, { -1 } },
|
||||||
|
|
|
@ -2151,8 +2151,6 @@ nsIEProfileMigrator::CopyProxyPreferences(nsIPrefBranch* aPrefs)
|
||||||
ProxyData data[] = {
|
ProxyData data[] = {
|
||||||
{ "ftp=", 4, PR_FALSE, "network.proxy.ftp",
|
{ "ftp=", 4, PR_FALSE, "network.proxy.ftp",
|
||||||
"network.proxy.ftp_port" },
|
"network.proxy.ftp_port" },
|
||||||
{ "gopher=", 7, PR_FALSE, "network.proxy.gopher",
|
|
||||||
"network.proxy.gopher_port" },
|
|
||||||
{ "http=", 5, PR_FALSE, "network.proxy.http",
|
{ "http=", 5, PR_FALSE, "network.proxy.http",
|
||||||
"network.proxy.http_port" },
|
"network.proxy.http_port" },
|
||||||
{ "https=", 6, PR_FALSE, "network.proxy.ssl",
|
{ "https=", 6, PR_FALSE, "network.proxy.ssl",
|
||||||
|
@ -2163,7 +2161,7 @@ nsIEProfileMigrator::CopyProxyPreferences(nsIPrefBranch* aPrefs)
|
||||||
|
|
||||||
PRInt32 startIndex = 0, count = 0;
|
PRInt32 startIndex = 0, count = 0;
|
||||||
PRBool foundSpecificProxy = PR_FALSE;
|
PRBool foundSpecificProxy = PR_FALSE;
|
||||||
for (PRUint32 i = 0; i < 5; ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(data); ++i) {
|
||||||
PRInt32 offset = buf.Find(NS_ConvertASCIItoUTF16(data[i].prefix));
|
PRInt32 offset = buf.Find(NS_ConvertASCIItoUTF16(data[i].prefix));
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
foundSpecificProxy = PR_TRUE;
|
foundSpecificProxy = PR_TRUE;
|
||||||
|
@ -2186,7 +2184,7 @@ nsIEProfileMigrator::CopyProxyPreferences(nsIPrefBranch* aPrefs)
|
||||||
// No proxy config for any specific type was found, assume
|
// No proxy config for any specific type was found, assume
|
||||||
// the ProxyServer value is of the form host:port and that
|
// the ProxyServer value is of the form host:port and that
|
||||||
// it applies to all protocols.
|
// it applies to all protocols.
|
||||||
for (PRUint32 i = 0; i < 5; ++i)
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(data); ++i)
|
||||||
SetProxyPref(buf, data[i].hostPref, data[i].portPref, aPrefs);
|
SetProxyPref(buf, data[i].hostPref, data[i].portPref, aPrefs);
|
||||||
aPrefs->SetBoolPref("network.proxy.share_proxy_settings", PR_TRUE);
|
aPrefs->SetBoolPref("network.proxy.share_proxy_settings", PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,12 +486,12 @@ nsOperaProfileMigrator::CopyProxySettings(nsINIParser &aParser,
|
||||||
|
|
||||||
PRInt32 networkProxyType = 0;
|
PRInt32 networkProxyType = 0;
|
||||||
|
|
||||||
const char* protocols[4] = { "HTTP", "HTTPS", "FTP", "GOPHER" };
|
const char* protocols[] = { "HTTP", "HTTPS", "FTP" };
|
||||||
const char* protocols_l[4] = { "http", "https", "ftp", "gopher" };
|
const char* protocols_l[] = { "http", "https", "ftp" };
|
||||||
char toggleBuf[15], serverBuf[20], serverPrefBuf[20],
|
char toggleBuf[15], serverBuf[20], serverPrefBuf[20],
|
||||||
serverPortPrefBuf[25];
|
serverPortPrefBuf[25];
|
||||||
PRInt32 enabled;
|
PRInt32 enabled;
|
||||||
for (PRUint32 i = 0; i < 4; ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(protocols); ++i) {
|
||||||
sprintf(toggleBuf, "Use %s", protocols[i]);
|
sprintf(toggleBuf, "Use %s", protocols[i]);
|
||||||
GetInteger(aParser, "Proxy", toggleBuf, &enabled);
|
GetInteger(aParser, "Proxy", toggleBuf, &enabled);
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|
|
@ -386,8 +386,6 @@ nsSeamonkeyProfileMigrator::PrefTransform gTransforms[] = {
|
||||||
MAKESAMETYPEPREFTRANSFORM("network.proxy.ssl_port", Int),
|
MAKESAMETYPEPREFTRANSFORM("network.proxy.ssl_port", Int),
|
||||||
MAKESAMETYPEPREFTRANSFORM("network.proxy.socks", String),
|
MAKESAMETYPEPREFTRANSFORM("network.proxy.socks", String),
|
||||||
MAKESAMETYPEPREFTRANSFORM("network.proxy.socks_port", Int),
|
MAKESAMETYPEPREFTRANSFORM("network.proxy.socks_port", Int),
|
||||||
MAKESAMETYPEPREFTRANSFORM("network.proxy.gopher", String),
|
|
||||||
MAKESAMETYPEPREFTRANSFORM("network.proxy.gopher_port", Int),
|
|
||||||
MAKESAMETYPEPREFTRANSFORM("network.proxy.no_proxies_on", String),
|
MAKESAMETYPEPREFTRANSFORM("network.proxy.no_proxies_on", String),
|
||||||
MAKESAMETYPEPREFTRANSFORM("network.proxy.autoconfig_url", String),
|
MAKESAMETYPEPREFTRANSFORM("network.proxy.autoconfig_url", String),
|
||||||
MAKESAMETYPEPREFTRANSFORM("browser.display.foreground_color", String),
|
MAKESAMETYPEPREFTRANSFORM("browser.display.foreground_color", String),
|
||||||
|
|
|
@ -52,7 +52,7 @@ var gConnectionsDialog = {
|
||||||
var httpProxyPortPref = document.getElementById("network.proxy.http_port");
|
var httpProxyPortPref = document.getElementById("network.proxy.http_port");
|
||||||
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
|
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
|
||||||
if (shareProxiesPref.value) {
|
if (shareProxiesPref.value) {
|
||||||
var proxyPrefs = ["ssl", "ftp", "socks", "gopher"];
|
var proxyPrefs = ["ssl", "ftp", "socks"];
|
||||||
for (var i = 0; i < proxyPrefs.length; ++i) {
|
for (var i = 0; i < proxyPrefs.length; ++i) {
|
||||||
var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]);
|
var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]);
|
||||||
var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port");
|
var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port");
|
||||||
|
@ -134,7 +134,7 @@ var gConnectionsDialog = {
|
||||||
{
|
{
|
||||||
var proxyTypePref = document.getElementById("network.proxy.type");
|
var proxyTypePref = document.getElementById("network.proxy.type");
|
||||||
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
|
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
|
||||||
var proxyPrefs = ["ssl", "ftp", "socks", "gopher"];
|
var proxyPrefs = ["ssl", "ftp", "socks"];
|
||||||
for (var i = 0; i < proxyPrefs.length; ++i) {
|
for (var i = 0; i < proxyPrefs.length; ++i) {
|
||||||
var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]);
|
var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]);
|
||||||
var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port");
|
var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port");
|
||||||
|
|
|
@ -70,8 +70,6 @@
|
||||||
<preference id="network.proxy.ssl_port" name="network.proxy.ssl_port" type="int"/>
|
<preference id="network.proxy.ssl_port" name="network.proxy.ssl_port" type="int"/>
|
||||||
<preference id="network.proxy.socks" name="network.proxy.socks" type="string"/>
|
<preference id="network.proxy.socks" name="network.proxy.socks" type="string"/>
|
||||||
<preference id="network.proxy.socks_port" name="network.proxy.socks_port" type="int"/>
|
<preference id="network.proxy.socks_port" name="network.proxy.socks_port" type="int"/>
|
||||||
<preference id="network.proxy.gopher" name="network.proxy.gopher" type="string"/>
|
|
||||||
<preference id="network.proxy.gopher_port" name="network.proxy.gopher_port" type="int"/>
|
|
||||||
<preference id="network.proxy.socks_version" name="network.proxy.socks_version" type="int"/>
|
<preference id="network.proxy.socks_version" name="network.proxy.socks_version" type="int"/>
|
||||||
<preference id="network.proxy.no_proxies_on" name="network.proxy.no_proxies_on" type="string"/>
|
<preference id="network.proxy.no_proxies_on" name="network.proxy.no_proxies_on" type="string"/>
|
||||||
<preference id="network.proxy.autoconfig_url" name="network.proxy.autoconfig_url" type="string"/>
|
<preference id="network.proxy.autoconfig_url" name="network.proxy.autoconfig_url" type="string"/>
|
||||||
|
@ -89,8 +87,6 @@
|
||||||
<preference id="network.proxy.backup.ssl_port" name="network.proxy.backup.ssl_port" type="int"/>
|
<preference id="network.proxy.backup.ssl_port" name="network.proxy.backup.ssl_port" type="int"/>
|
||||||
<preference id="network.proxy.backup.socks" name="network.proxy.backup.socks" type="string"/>
|
<preference id="network.proxy.backup.socks" name="network.proxy.backup.socks" type="string"/>
|
||||||
<preference id="network.proxy.backup.socks_port" name="network.proxy.backup.socks_port" type="int"/>
|
<preference id="network.proxy.backup.socks_port" name="network.proxy.backup.socks_port" type="int"/>
|
||||||
<preference id="network.proxy.backup.gopher" name="network.proxy.backup.gopher" type="string"/>
|
|
||||||
<preference id="network.proxy.backup.gopher_port" name="network.proxy.backup.gopher_port" type="int"/>
|
|
||||||
</preferences>
|
</preferences>
|
||||||
|
|
||||||
<script type="application/javascript" src="chrome://browser/content/preferences/connection.js"/>
|
<script type="application/javascript" src="chrome://browser/content/preferences/connection.js"/>
|
||||||
|
@ -156,18 +152,6 @@
|
||||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('ftp', true);"/>
|
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('ftp', true);"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
</row>
|
</row>
|
||||||
<row align="center">
|
|
||||||
<hbox pack="end">
|
|
||||||
<label value="&gopher.label;" accesskey="&gopher.accesskey;" control="networkProxyGopher"/>
|
|
||||||
</hbox>
|
|
||||||
<hbox align="center">
|
|
||||||
<textbox id="networkProxyGopher" flex="1" preference="network.proxy.gopher"
|
|
||||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('gopher', false);"/>
|
|
||||||
<label value="&port.label;" accesskey="&gopherPort.accesskey;" control="networkProxyGopher_Port"/>
|
|
||||||
<textbox id="networkProxyGopher_Port" type="number" max="65535" size="5" preference="network.proxy.gopher_port"
|
|
||||||
onsyncfrompreference="return gConnectionsDialog.readProxyProtocolPref('gopher', true);"/>
|
|
||||||
</hbox>
|
|
||||||
</row>
|
|
||||||
<row align="center">
|
<row align="center">
|
||||||
<hbox pack="end">
|
<hbox pack="end">
|
||||||
<label value="&socks.label;" accesskey="&socks.accesskey;" control="networkProxySOCKS"/>
|
<label value="&socks.label;" accesskey="&socks.accesskey;" control="networkProxySOCKS"/>
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
<!ENTITY reload.accesskey "e">
|
<!ENTITY reload.accesskey "e">
|
||||||
<!ENTITY ftp.label "FTP Proxy:">
|
<!ENTITY ftp.label "FTP Proxy:">
|
||||||
<!ENTITY ftp.accesskey "F">
|
<!ENTITY ftp.accesskey "F">
|
||||||
<!ENTITY gopher.label "Gopher Proxy:">
|
|
||||||
<!ENTITY gopher.accesskey "G">
|
|
||||||
<!ENTITY http.label "HTTP Proxy:">
|
<!ENTITY http.label "HTTP Proxy:">
|
||||||
<!ENTITY http.accesskey "x">
|
<!ENTITY http.accesskey "x">
|
||||||
<!ENTITY ssl.label "SSL Proxy:">
|
<!ENTITY ssl.label "SSL Proxy:">
|
||||||
|
@ -34,8 +32,6 @@
|
||||||
<!ENTITY HTTPport.accesskey "P">
|
<!ENTITY HTTPport.accesskey "P">
|
||||||
<!ENTITY SSLport.accesskey "o">
|
<!ENTITY SSLport.accesskey "o">
|
||||||
<!ENTITY FTPport.accesskey "r">
|
<!ENTITY FTPport.accesskey "r">
|
||||||
<!-- No accesskey for gopher (':' doesn't go well) - mpt's going to redesign the window -->
|
|
||||||
<!ENTITY gopherPort.accesskey "">
|
|
||||||
<!ENTITY SOCKSport.accesskey "t">
|
<!ENTITY SOCKSport.accesskey "t">
|
||||||
<!ENTITY noproxy.label "No Proxy for:">
|
<!ENTITY noproxy.label "No Proxy for:">
|
||||||
<!ENTITY noproxy.accesskey "n">
|
<!ENTITY noproxy.accesskey "n">
|
||||||
|
|
|
@ -4950,7 +4950,7 @@ NSS_DISABLE_DBM=
|
||||||
NECKO_WIFI=1
|
NECKO_WIFI=1
|
||||||
NECKO_COOKIES=1
|
NECKO_COOKIES=1
|
||||||
NECKO_DISK_CACHE=1
|
NECKO_DISK_CACHE=1
|
||||||
NECKO_PROTOCOLS_DEFAULT="about data file ftp gopher http res viewsource"
|
NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource"
|
||||||
USE_ARM_KUSER=
|
USE_ARM_KUSER=
|
||||||
BUILD_CTYPES=1
|
BUILD_CTYPES=1
|
||||||
XPC_IDISPATCH_SUPPORT=
|
XPC_IDISPATCH_SUPPORT=
|
||||||
|
|
|
@ -56,7 +56,6 @@ var reporterListener = {
|
||||||
case "http":
|
case "http":
|
||||||
case "https":
|
case "https":
|
||||||
case "ftp":
|
case "ftp":
|
||||||
case "gopher":
|
|
||||||
isEnabled = true;
|
isEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -710,8 +710,6 @@ pref("network.http.prompt-temp-redirect", true);
|
||||||
// in a DSCP environment this should be 40 (0x28, or AF11), per RFC-4594,
|
// in a DSCP environment this should be 40 (0x28, or AF11), per RFC-4594,
|
||||||
// Section 4.8 "High-Throughput Data Service Class"
|
// Section 4.8 "High-Throughput Data Service Class"
|
||||||
pref("network.http.qos", 0);
|
pref("network.http.qos", 0);
|
||||||
// ditto for Gopher
|
|
||||||
pref("network.gopher.qos", 0);
|
|
||||||
|
|
||||||
// default values for FTP
|
// default values for FTP
|
||||||
// in a DSCP environment this should be 40 (0x28, or AF11), per RFC-4594,
|
// in a DSCP environment this should be 40 (0x28, or AF11), per RFC-4594,
|
||||||
|
@ -907,8 +905,6 @@ pref("permissions.default.image", 1); // 1-Accept, 2-Deny, 3-dontAccep
|
||||||
pref("network.proxy.type", 5);
|
pref("network.proxy.type", 5);
|
||||||
pref("network.proxy.ftp", "");
|
pref("network.proxy.ftp", "");
|
||||||
pref("network.proxy.ftp_port", 0);
|
pref("network.proxy.ftp_port", 0);
|
||||||
pref("network.proxy.gopher", "");
|
|
||||||
pref("network.proxy.gopher_port", 0);
|
|
||||||
pref("network.proxy.http", "");
|
pref("network.proxy.http", "");
|
||||||
pref("network.proxy.http_port", 0);
|
pref("network.proxy.http_port", 0);
|
||||||
pref("network.proxy.ssl", "");
|
pref("network.proxy.ssl", "");
|
||||||
|
|
|
@ -301,7 +301,6 @@ nsProtocolProxyService::nsProtocolProxyService()
|
||||||
, mProxyConfig(eProxyConfig_Direct)
|
, mProxyConfig(eProxyConfig_Direct)
|
||||||
, mHTTPProxyPort(-1)
|
, mHTTPProxyPort(-1)
|
||||||
, mFTPProxyPort(-1)
|
, mFTPProxyPort(-1)
|
||||||
, mGopherProxyPort(-1)
|
|
||||||
, mHTTPSProxyPort(-1)
|
, mHTTPSProxyPort(-1)
|
||||||
, mSOCKSProxyPort(-1)
|
, mSOCKSProxyPort(-1)
|
||||||
, mSOCKSProxyVersion(4)
|
, mSOCKSProxyVersion(4)
|
||||||
|
@ -430,12 +429,6 @@ nsProtocolProxyService::PrefsChanged(nsIPrefBranch *prefBranch,
|
||||||
if (!pref || !strcmp(pref, PROXY_PREF("ftp_port")))
|
if (!pref || !strcmp(pref, PROXY_PREF("ftp_port")))
|
||||||
proxy_GetIntPref(prefBranch, PROXY_PREF("ftp_port"), mFTPProxyPort);
|
proxy_GetIntPref(prefBranch, PROXY_PREF("ftp_port"), mFTPProxyPort);
|
||||||
|
|
||||||
if (!pref || !strcmp(pref, PROXY_PREF("gopher")))
|
|
||||||
proxy_GetStringPref(prefBranch, PROXY_PREF("gopher"), mGopherProxyHost);
|
|
||||||
|
|
||||||
if (!pref || !strcmp(pref, PROXY_PREF("gopher_port")))
|
|
||||||
proxy_GetIntPref(prefBranch, PROXY_PREF("gopher_port"), mGopherProxyPort);
|
|
||||||
|
|
||||||
if (!pref || !strcmp(pref, PROXY_PREF("socks")))
|
if (!pref || !strcmp(pref, PROXY_PREF("socks")))
|
||||||
proxy_GetStringPref(prefBranch, PROXY_PREF("socks"), mSOCKSProxyHost);
|
proxy_GetStringPref(prefBranch, PROXY_PREF("socks"), mSOCKSProxyHost);
|
||||||
|
|
||||||
|
@ -1299,12 +1292,6 @@ nsProtocolProxyService::Resolve_Internal(nsIURI *uri,
|
||||||
type = kProxyType_HTTP;
|
type = kProxyType_HTTP;
|
||||||
port = mFTPProxyPort;
|
port = mFTPProxyPort;
|
||||||
}
|
}
|
||||||
else if (!mGopherProxyHost.IsEmpty() && mGopherProxyPort > 0 &&
|
|
||||||
info.scheme.EqualsLiteral("gopher")) {
|
|
||||||
host = &mGopherProxyHost;
|
|
||||||
type = kProxyType_HTTP;
|
|
||||||
port = mGopherProxyPort;
|
|
||||||
}
|
|
||||||
else if (!mSOCKSProxyHost.IsEmpty() && mSOCKSProxyPort > 0) {
|
else if (!mSOCKSProxyHost.IsEmpty() && mSOCKSProxyPort > 0) {
|
||||||
host = &mSOCKSProxyHost;
|
host = &mSOCKSProxyHost;
|
||||||
if (mSOCKSProxyVersion == 4)
|
if (mSOCKSProxyVersion == 4)
|
||||||
|
|
|
@ -365,9 +365,6 @@ protected:
|
||||||
nsCString mFTPProxyHost;
|
nsCString mFTPProxyHost;
|
||||||
PRInt32 mFTPProxyPort;
|
PRInt32 mFTPProxyPort;
|
||||||
|
|
||||||
nsCString mGopherProxyHost;
|
|
||||||
PRInt32 mGopherProxyPort;
|
|
||||||
|
|
||||||
nsCString mHTTPSProxyHost;
|
nsCString mHTTPSProxyHost;
|
||||||
PRInt32 mHTTPSProxyPort;
|
PRInt32 mHTTPSProxyPort;
|
||||||
|
|
||||||
|
|
|
@ -250,11 +250,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsResProtocolHandler, Init)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsResURL)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsResURL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NECKO_PROTOCOL_gopher
|
|
||||||
#include "nsGopherHandler.h"
|
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsGopherHandler)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NECKO_PROTOCOL_viewsource
|
#ifdef NECKO_PROTOCOL_viewsource
|
||||||
#include "nsViewSourceHandler.h"
|
#include "nsViewSourceHandler.h"
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSourceHandler)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSourceHandler)
|
||||||
|
@ -307,11 +302,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMaemoNetworkLinkService, Init)
|
||||||
nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result);
|
nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NECKO_PROTOCOL_gopher
|
|
||||||
#include "nsGopherDirListingConv.h"
|
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsGopherDirListingConv)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "nsMultiMixedConv.h"
|
#include "nsMultiMixedConv.h"
|
||||||
#include "nsHTTPCompressConv.h"
|
#include "nsHTTPCompressConv.h"
|
||||||
#include "mozTXTToHTMLConv.h"
|
#include "mozTXTToHTMLConv.h"
|
||||||
|
@ -329,7 +319,6 @@ nsresult NS_NewNSTXTToHTMLConv(nsTXTToHTMLConv** result);
|
||||||
nsresult NS_NewStreamConv(nsStreamConverterService **aStreamConv);
|
nsresult NS_NewStreamConv(nsStreamConverterService **aStreamConv);
|
||||||
|
|
||||||
#define FTP_TO_INDEX "?from=text/ftp-dir&to=application/http-index-format"
|
#define FTP_TO_INDEX "?from=text/ftp-dir&to=application/http-index-format"
|
||||||
#define GOPHER_TO_INDEX "?from=text/gopher-dir&to=application/http-index-format"
|
|
||||||
#define INDEX_TO_HTML "?from=application/http-index-format&to=text/html"
|
#define INDEX_TO_HTML "?from=application/http-index-format&to=text/html"
|
||||||
#define MULTI_MIXED_X "?from=multipart/x-mixed-replace&to=*/*"
|
#define MULTI_MIXED_X "?from=multipart/x-mixed-replace&to=*/*"
|
||||||
#define MULTI_MIXED "?from=multipart/mixed&to=*/*"
|
#define MULTI_MIXED "?from=multipart/mixed&to=*/*"
|
||||||
|
@ -348,7 +337,6 @@ nsresult NS_NewStreamConv(nsStreamConverterService **aStreamConv);
|
||||||
|
|
||||||
static const char *const sStreamConverterArray[] = {
|
static const char *const sStreamConverterArray[] = {
|
||||||
FTP_TO_INDEX,
|
FTP_TO_INDEX,
|
||||||
GOPHER_TO_INDEX,
|
|
||||||
INDEX_TO_HTML,
|
INDEX_TO_HTML,
|
||||||
MULTI_MIXED_X,
|
MULTI_MIXED_X,
|
||||||
MULTI_MIXED,
|
MULTI_MIXED,
|
||||||
|
@ -841,14 +829,6 @@ static const nsModuleComponentInfo gNetModuleInfo[] = {
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NECKO_PROTOCOL_gopher
|
|
||||||
{ "GopherDirListingConverter",
|
|
||||||
NS_GOPHERDIRLISTINGCONVERTER_CID,
|
|
||||||
NS_ISTREAMCONVERTER_KEY GOPHER_TO_INDEX,
|
|
||||||
nsGopherDirListingConvConstructor
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{ "Indexed to HTML Converter",
|
{ "Indexed to HTML Converter",
|
||||||
NS_NSINDEXEDTOHTMLCONVERTER_CID,
|
NS_NSINDEXEDTOHTMLCONVERTER_CID,
|
||||||
NS_ISTREAMCONVERTER_KEY INDEX_TO_HTML,
|
NS_ISTREAMCONVERTER_KEY INDEX_TO_HTML,
|
||||||
|
@ -1125,15 +1105,6 @@ static const nsModuleComponentInfo gNetModuleInfo[] = {
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NECKO_PROTOCOL_gopher
|
|
||||||
//gopher:
|
|
||||||
{ "The Gopher Protocol Handler",
|
|
||||||
NS_GOPHERHANDLER_CID,
|
|
||||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "gopher",
|
|
||||||
nsGopherHandlerConstructor
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NECKO_PROTOCOL_data
|
#ifdef NECKO_PROTOCOL_data
|
||||||
// from netwerk/protocol/data:
|
// from netwerk/protocol/data:
|
||||||
{ "Data Protocol Handler",
|
{ "Data Protocol Handler",
|
||||||
|
|
|
@ -64,10 +64,6 @@ DirColSize=Size
|
||||||
DirColMTime=Last Modified
|
DirColMTime=Last Modified
|
||||||
DirFileLabel=File:
|
DirFileLabel=File:
|
||||||
|
|
||||||
#Gopher Search Prompt
|
|
||||||
GopherPromptTitle=Search
|
|
||||||
GopherPromptText=Enter a search term:
|
|
||||||
|
|
||||||
PhishingAuth=You are about to visit "%1$S". This site may be attempting to trick you into thinking you are visiting a different site. Use extreme caution.
|
PhishingAuth=You are about to visit "%1$S". This site may be attempting to trick you into thinking you are visiting a different site. Use extreme caution.
|
||||||
PhishingAuthAccept=I understand and will be very careful
|
PhishingAuthAccept=I understand and will be very careful
|
||||||
SuperfluousAuth=You are about to log in to the site "%1$S" with the username "%2$S", but the website does not require authentication. This may be an attempt to trick you.\n\nIs "%1$S" the site you want to visit?
|
SuperfluousAuth=You are about to log in to the site "%1$S" with the username "%2$S", but the website does not require authentication. This may be an attempt to trick you.\n\nIs "%1$S" the site you want to visit?
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
#undef NECKO_PROTOCOL_data
|
#undef NECKO_PROTOCOL_data
|
||||||
#undef NECKO_PROTOCOL_file
|
#undef NECKO_PROTOCOL_file
|
||||||
#undef NECKO_PROTOCOL_ftp
|
#undef NECKO_PROTOCOL_ftp
|
||||||
#undef NECKO_PROTOCOL_gopher
|
|
||||||
#undef NECKO_PROTOCOL_http
|
#undef NECKO_PROTOCOL_http
|
||||||
#undef NECKO_PROTOCOL_res
|
#undef NECKO_PROTOCOL_res
|
||||||
#undef NECKO_PROTOCOL_viewsource
|
#undef NECKO_PROTOCOL_viewsource
|
||||||
|
|
|
@ -47,7 +47,6 @@ PARALLEL_DIRS = \
|
||||||
data \
|
data \
|
||||||
file \
|
file \
|
||||||
ftp \
|
ftp \
|
||||||
gopher \
|
|
||||||
http \
|
http \
|
||||||
res \
|
res \
|
||||||
viewsource \
|
viewsource \
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
#
|
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
|
||||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
#
|
|
||||||
# The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
# the License. You may obtain a copy of the License at
|
|
||||||
# http://www.mozilla.org/MPL/
|
|
||||||
#
|
|
||||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
# for the specific language governing rights and limitations under the
|
|
||||||
# License.
|
|
||||||
#
|
|
||||||
# The Original Code is mozilla.org code.
|
|
||||||
#
|
|
||||||
# The Initial Developer of the Original Code is
|
|
||||||
# Bradley Baetz.
|
|
||||||
# Portions created by the Initial Developer are Copyright (C) 2000
|
|
||||||
# the Initial Developer. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Contributor(s):
|
|
||||||
# Bradley Baetz <bbaetz@student.usyd.edu.au>
|
|
||||||
#
|
|
||||||
# Alternatively, the contents of this file may be used under the terms of
|
|
||||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
# of those above. If you wish to allow use of your version of this file only
|
|
||||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
# use your version of this file under the terms of the MPL, indicate your
|
|
||||||
# decision by deleting the provisions above and replace them with the notice
|
|
||||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
# the provisions above, a recipient may use your version of this file under
|
|
||||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
#
|
|
||||||
# ***** END LICENSE BLOCK *****
|
|
||||||
|
|
||||||
DEPTH = ../../..
|
|
||||||
topsrcdir = @top_srcdir@
|
|
||||||
srcdir = @srcdir@
|
|
||||||
VPATH = @srcdir@
|
|
||||||
|
|
||||||
include $(DEPTH)/config/autoconf.mk
|
|
||||||
|
|
||||||
MODULE = necko
|
|
||||||
LIBRARY_NAME = nkgopher_s
|
|
||||||
LIBXUL_LIBRARY = 1
|
|
||||||
|
|
||||||
FORCE_STATIC_LIB = 1
|
|
||||||
|
|
||||||
CPPSRCS = \
|
|
||||||
nsGopherHandler.cpp \
|
|
||||||
nsGopherChannel.cpp \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
LOCAL_INCLUDES = \
|
|
||||||
-I$(srcdir)/../../base/src \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
|
|
@ -1,498 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
||||||
/* vim:set ts=4 sw=4 sts=4 cin et:
|
|
||||||
*
|
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is the Gopher protocol code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Bradley Baetz.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Bradley Baetz <bbaetz@student.usyd.edu.au>
|
|
||||||
* Darin Fisher <darin@netscape.com>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
#include "nsGopherChannel.h"
|
|
||||||
#include "nsGopherHandler.h"
|
|
||||||
#include "nsBaseContentStream.h"
|
|
||||||
#include "nsIAsyncInputStream.h"
|
|
||||||
#include "nsIAsyncOutputStream.h"
|
|
||||||
#include "nsISocketTransportService.h"
|
|
||||||
#include "nsISocketTransport.h"
|
|
||||||
#include "nsIStringBundle.h"
|
|
||||||
#include "nsITXTToHTMLConv.h"
|
|
||||||
#include "nsIPrompt.h"
|
|
||||||
#include "nsServiceManagerUtils.h"
|
|
||||||
#include "nsThreadUtils.h"
|
|
||||||
#include "nsStreamUtils.h"
|
|
||||||
#include "nsMimeTypes.h"
|
|
||||||
#include "nsNetCID.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsAutoPtr.h"
|
|
||||||
#include "nsEscape.h"
|
|
||||||
#include "nsCRT.h"
|
|
||||||
#include "netCore.h"
|
|
||||||
|
|
||||||
// Specifies the maximum number of output stream buffer segments that we can
|
|
||||||
// allocate before giving up. At 4k per segment, this corresponds to a max
|
|
||||||
// gopher request of 400k, which should be plenty.
|
|
||||||
#define GOPHER_MAX_WRITE_SEGMENT_COUNT 100
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class nsGopherContentStream : public nsBaseContentStream
|
|
||||||
, public nsIInputStreamCallback
|
|
||||||
, public nsIOutputStreamCallback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
NS_DECL_NSIINPUTSTREAMCALLBACK
|
|
||||||
NS_DECL_NSIOUTPUTSTREAMCALLBACK
|
|
||||||
|
|
||||||
// stream methods that we override:
|
|
||||||
NS_IMETHOD Available(PRUint32 *result);
|
|
||||||
NS_IMETHOD ReadSegments(nsWriteSegmentFun writer, void *closure,
|
|
||||||
PRUint32 count, PRUint32 *result);
|
|
||||||
NS_IMETHOD CloseWithStatus(nsresult status);
|
|
||||||
|
|
||||||
nsGopherContentStream(nsGopherChannel *channel)
|
|
||||||
: nsBaseContentStream(PR_TRUE) // non-blocking
|
|
||||||
, mChannel(channel) {
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult OpenSocket(nsIEventTarget *target);
|
|
||||||
nsresult OnSocketWritable();
|
|
||||||
nsresult ParseTypeAndSelector(char &type, nsCString &selector);
|
|
||||||
nsresult PromptForQueryString(nsCString &result);
|
|
||||||
void UpdateContentType(char type);
|
|
||||||
nsresult SendRequest();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void OnCallbackPending();
|
|
||||||
|
|
||||||
private:
|
|
||||||
nsRefPtr<nsGopherChannel> mChannel;
|
|
||||||
nsCOMPtr<nsISocketTransport> mSocket;
|
|
||||||
nsCOMPtr<nsIAsyncOutputStream> mSocketOutput;
|
|
||||||
nsCOMPtr<nsIAsyncInputStream> mSocketInput;
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED2(nsGopherContentStream,
|
|
||||||
nsBaseContentStream,
|
|
||||||
nsIInputStreamCallback,
|
|
||||||
nsIOutputStreamCallback)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherContentStream::Available(PRUint32 *result)
|
|
||||||
{
|
|
||||||
if (mSocketInput)
|
|
||||||
return mSocketInput->Available(result);
|
|
||||||
|
|
||||||
return nsBaseContentStream::Available(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherContentStream::ReadSegments(nsWriteSegmentFun writer, void *closure,
|
|
||||||
PRUint32 count, PRUint32 *result)
|
|
||||||
{
|
|
||||||
// Insert a thunk here so that the input stream passed to the writer is
|
|
||||||
// this input stream instead of mSocketInput.
|
|
||||||
if (mSocketInput) {
|
|
||||||
nsWriteSegmentThunk thunk = { this, writer, closure };
|
|
||||||
return mSocketInput->ReadSegments(NS_WriteSegmentThunk, &thunk, count,
|
|
||||||
result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nsBaseContentStream::ReadSegments(writer, closure, count, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherContentStream::CloseWithStatus(nsresult status)
|
|
||||||
{
|
|
||||||
if (mSocket) {
|
|
||||||
mSocket->Close(status);
|
|
||||||
mSocket = nsnull;
|
|
||||||
mSocketInput = nsnull;
|
|
||||||
mSocketOutput = nsnull;
|
|
||||||
}
|
|
||||||
return nsBaseContentStream::CloseWithStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherContentStream::OnInputStreamReady(nsIAsyncInputStream *stream)
|
|
||||||
{
|
|
||||||
// Forward this notification
|
|
||||||
DispatchCallbackSync();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherContentStream::OnOutputStreamReady(nsIAsyncOutputStream *stream)
|
|
||||||
{
|
|
||||||
// If we're already closed, mSocketOutput is going to be null and we'll
|
|
||||||
// just be getting notified that it got closed (by outselves). In that
|
|
||||||
// case, nothing to do here.
|
|
||||||
if (!mSocketOutput) {
|
|
||||||
NS_ASSERTION(NS_FAILED(Status()), "How did that happen?");
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We have to close ourselves if we hit an error here in order to propagate
|
|
||||||
// the error to our consumer. Otherwise, just forward the notification so
|
|
||||||
// that the consumer will know to start reading.
|
|
||||||
|
|
||||||
nsresult rv = OnSocketWritable();
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
CloseWithStatus(rv);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsGopherContentStream::OnCallbackPending()
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
// We have a callback, so failure means we should close the stream.
|
|
||||||
if (!mSocket) {
|
|
||||||
rv = OpenSocket(CallbackTarget());
|
|
||||||
} else if (mSocketInput) {
|
|
||||||
rv = mSocketInput->AsyncWait(this, 0, 0, CallbackTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
CloseWithStatus(rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsGopherContentStream::OpenSocket(nsIEventTarget *target)
|
|
||||||
{
|
|
||||||
// This function is called to get things started.
|
|
||||||
|
|
||||||
// We begin by opening a socket to the specified host and wait for the
|
|
||||||
// socket to become writable.
|
|
||||||
|
|
||||||
nsCAutoString host;
|
|
||||||
nsresult rv = mChannel->URI()->GetAsciiHost(host);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
if (host.IsEmpty())
|
|
||||||
return NS_ERROR_MALFORMED_URI;
|
|
||||||
|
|
||||||
// For security reasons, don't allow anything expect the default
|
|
||||||
// gopher port (70). See bug 71916 - bbaetz@cs.mcgill.ca
|
|
||||||
PRInt32 port = GOPHER_PORT;
|
|
||||||
|
|
||||||
// Create socket tranport
|
|
||||||
nsCOMPtr<nsISocketTransportService> sts =
|
|
||||||
do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
rv = sts->CreateTransport(nsnull, 0, host, port, mChannel->ProxyInfo(),
|
|
||||||
getter_AddRefs(mSocket));
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
mSocket->SetQoSBits(gGopherHandler->GetQoSBits());
|
|
||||||
|
|
||||||
// Setup progress and status notifications
|
|
||||||
rv = mSocket->SetEventSink(mChannel, target);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIOutputStream> output;
|
|
||||||
rv = mSocket->OpenOutputStream(0, 0, GOPHER_MAX_WRITE_SEGMENT_COUNT,
|
|
||||||
getter_AddRefs(output));
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
mSocketOutput = do_QueryInterface(output);
|
|
||||||
NS_ENSURE_STATE(mSocketOutput);
|
|
||||||
|
|
||||||
return mSocketOutput->AsyncWait(this, 0, 0, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsGopherContentStream::OnSocketWritable()
|
|
||||||
{
|
|
||||||
// Write to output stream (we can do this in one big chunk)
|
|
||||||
nsresult rv = SendRequest();
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
// Open input stream
|
|
||||||
nsCOMPtr<nsIInputStream> input;
|
|
||||||
rv = mSocket->OpenInputStream(0, 0, 0, getter_AddRefs(input));
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
mSocketInput = do_QueryInterface(input, &rv);
|
|
||||||
|
|
||||||
NS_ASSERTION(CallbackTarget(), "where is my pending callback?");
|
|
||||||
rv = mSocketInput->AsyncWait(this, 0, 0, CallbackTarget());
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsGopherContentStream::ParseTypeAndSelector(char &type, nsCString &selector)
|
|
||||||
{
|
|
||||||
nsCAutoString buffer;
|
|
||||||
nsresult rv = mChannel->URI()->GetPath(buffer); // unescaped down below
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
// No path given
|
|
||||||
if (buffer[0] == '\0' || (buffer[0] == '/' && buffer[1] == '\0')) {
|
|
||||||
type = '1';
|
|
||||||
selector.Truncate();
|
|
||||||
} else {
|
|
||||||
NS_ENSURE_STATE(buffer[1] != '\0');
|
|
||||||
|
|
||||||
type = buffer[1]; // Ignore leading '/'
|
|
||||||
|
|
||||||
// Do it this way in case selector contains embedded nulls after
|
|
||||||
// unescaping.
|
|
||||||
char *sel = buffer.BeginWriting() + 2;
|
|
||||||
PRInt32 count = nsUnescapeCount(sel);
|
|
||||||
selector.Assign(sel, count);
|
|
||||||
|
|
||||||
// NOTE: FindCharInSet cannot be used to search for a null byte.
|
|
||||||
if (selector.FindCharInSet("\t\n\r") != kNotFound ||
|
|
||||||
selector.FindChar('\0') != kNotFound) {
|
|
||||||
// gopher selectors cannot containt tab, cr, lf, or \0
|
|
||||||
return NS_ERROR_MALFORMED_URI;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsGopherContentStream::PromptForQueryString(nsCString &result)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIPrompt> prompter;
|
|
||||||
mChannel->GetCallback(prompter);
|
|
||||||
if (!prompter) {
|
|
||||||
NS_ERROR("We need a prompter!");
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIStringBundle> bundle;
|
|
||||||
nsCOMPtr<nsIStringBundleService> bundleSvc =
|
|
||||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
|
||||||
if (bundleSvc)
|
|
||||||
bundleSvc->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
|
|
||||||
|
|
||||||
nsXPIDLString promptTitle, promptText;
|
|
||||||
if (bundle) {
|
|
||||||
bundle->GetStringFromName(NS_LITERAL_STRING("GopherPromptTitle").get(),
|
|
||||||
getter_Copies(promptTitle));
|
|
||||||
bundle->GetStringFromName(NS_LITERAL_STRING("GopherPromptText").get(),
|
|
||||||
getter_Copies(promptText));
|
|
||||||
}
|
|
||||||
if (promptTitle.IsEmpty())
|
|
||||||
promptTitle.AssignLiteral("Search");
|
|
||||||
if (promptText.IsEmpty())
|
|
||||||
promptText.AssignLiteral("Enter a search term:");
|
|
||||||
|
|
||||||
nsXPIDLString value;
|
|
||||||
PRBool res = PR_FALSE;
|
|
||||||
PRBool checkState;
|
|
||||||
prompter->Prompt(promptTitle.get(), promptText.get(),
|
|
||||||
getter_Copies(value), NULL, &checkState, &res);
|
|
||||||
if (!res || value.IsEmpty())
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
CopyUTF16toUTF8(value, result); // XXX Is UTF-8 the right thing?
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsGopherContentStream::UpdateContentType(char type)
|
|
||||||
{
|
|
||||||
const char *contentType = nsnull;
|
|
||||||
|
|
||||||
switch(type) {
|
|
||||||
case '0':
|
|
||||||
case 'h':
|
|
||||||
case '2': // CSO search - unhandled, should not be selectable
|
|
||||||
case '3': // "Error" - should not be selectable
|
|
||||||
case 'i': // info line- should not be selectable
|
|
||||||
contentType = TEXT_HTML;
|
|
||||||
break;
|
|
||||||
case '1':
|
|
||||||
case '7': // search - returns a directory listing
|
|
||||||
contentType = APPLICATION_HTTP_INDEX_FORMAT;
|
|
||||||
break;
|
|
||||||
case 'g':
|
|
||||||
case 'I':
|
|
||||||
contentType = IMAGE_GIF;
|
|
||||||
break;
|
|
||||||
case 'T': // tn3270 - type doesn't make sense
|
|
||||||
case '8': // telnet - type doesn't make sense
|
|
||||||
contentType = TEXT_PLAIN;
|
|
||||||
break;
|
|
||||||
case '5': // "DOS binary archive of some sort" - is the mime-type correct?
|
|
||||||
case '9': // "Binary file!"
|
|
||||||
contentType = APPLICATION_OCTET_STREAM;
|
|
||||||
break;
|
|
||||||
case '4': // "BinHexed Macintosh file"
|
|
||||||
contentType = APPLICATION_BINHEX;
|
|
||||||
break;
|
|
||||||
case '6':
|
|
||||||
contentType = APPLICATION_UUENCODE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentType)
|
|
||||||
mChannel->SetContentType(nsDependentCString(contentType));
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsGopherContentStream::SendRequest()
|
|
||||||
{
|
|
||||||
char type;
|
|
||||||
nsCAutoString request; // used to build request data
|
|
||||||
|
|
||||||
nsresult rv = ParseTypeAndSelector(type, request);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
// So, we use the selector as is unless it is a search url
|
|
||||||
if (type == '7') {
|
|
||||||
// Note that we don't use the "standard" nsIURL parsing stuff here
|
|
||||||
// because the only special character is ?, and its possible to search
|
|
||||||
// for a string containing a #, and so on
|
|
||||||
|
|
||||||
// XXX - should this find the last or first entry?
|
|
||||||
// '?' is valid in both the search string and the url
|
|
||||||
// so no matter what this does, it may be incorrect
|
|
||||||
// This only affects people codeing the query directly into the URL
|
|
||||||
PRInt32 pos = request.RFindChar('?');
|
|
||||||
if (pos != kNotFound) {
|
|
||||||
// Just replace it with a tab
|
|
||||||
request.SetCharAt('\t', pos);
|
|
||||||
} else {
|
|
||||||
// We require a query string here - if we don't have one,
|
|
||||||
// then we need to ask the user
|
|
||||||
nsCAutoString search;
|
|
||||||
rv = PromptForQueryString(search);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
request.Append('\t');
|
|
||||||
request.Append(search);
|
|
||||||
|
|
||||||
// and update our uri (XXX should probably redirect instead to avoid
|
|
||||||
// confusing consumers of the channel)
|
|
||||||
nsCAutoString spec;
|
|
||||||
rv = mChannel->URI()->GetAsciiSpec(spec);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
spec.Append('?');
|
|
||||||
spec.Append(search);
|
|
||||||
rv = mChannel->URI()->SetSpec(spec);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
request.Append(CRLF);
|
|
||||||
|
|
||||||
PRUint32 n;
|
|
||||||
rv = mSocketOutput->Write(request.get(), request.Length(), &n);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
NS_ENSURE_STATE(n == request.Length());
|
|
||||||
|
|
||||||
// Now, push stream converters appropriately based on our 'type'
|
|
||||||
if (type == '1' || type == '7') {
|
|
||||||
rv = mChannel->PushStreamConverter("text/gopher-dir",
|
|
||||||
APPLICATION_HTTP_INDEX_FORMAT);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
} else if (type == '0') {
|
|
||||||
nsCOMPtr<nsIStreamListener> converter;
|
|
||||||
rv = mChannel->PushStreamConverter(TEXT_PLAIN, TEXT_HTML, PR_TRUE,
|
|
||||||
getter_AddRefs(converter));
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
nsCOMPtr<nsITXTToHTMLConv> config = do_QueryInterface(converter);
|
|
||||||
if (config) {
|
|
||||||
nsCAutoString spec;
|
|
||||||
mChannel->URI()->GetSpec(spec);
|
|
||||||
config->SetTitle(NS_ConvertUTF8toUTF16(spec).get());
|
|
||||||
config->PreFormatHTML(PR_TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateContentType(type);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED1(nsGopherChannel,
|
|
||||||
nsBaseChannel,
|
|
||||||
nsIProxiedChannel)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherChannel::GetProxyInfo(nsIProxyInfo** aProxyInfo)
|
|
||||||
{
|
|
||||||
*aProxyInfo = ProxyInfo();
|
|
||||||
NS_IF_ADDREF(*aProxyInfo);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsGopherChannel::OpenContentStream(PRBool async, nsIInputStream **result,
|
|
||||||
nsIChannel** channel)
|
|
||||||
{
|
|
||||||
// Implement nsIChannel::Open in terms of nsIChannel::AsyncOpen
|
|
||||||
if (!async)
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
|
|
||||||
nsRefPtr<nsIInputStream> stream = new nsGopherContentStream(this);
|
|
||||||
if (!stream)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
*result = nsnull;
|
|
||||||
stream.swap(*result);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
nsGopherChannel::GetStatusArg(nsresult status, nsString &statusArg)
|
|
||||||
{
|
|
||||||
nsCAutoString host;
|
|
||||||
URI()->GetHost(host);
|
|
||||||
CopyUTF8toUTF16(host, statusArg);
|
|
||||||
return PR_TRUE;
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
||||||
*
|
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is the Gopher protocol code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Bradley Baetz.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Bradley Baetz <bbaetz@student.usyd.edu.au>
|
|
||||||
* Darin Fisher <darin@netscape.com>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
#ifndef nsGopherChannel_h__
|
|
||||||
#define nsGopherChannel_h__
|
|
||||||
|
|
||||||
#include "nsBaseChannel.h"
|
|
||||||
#include "nsIProxyInfo.h"
|
|
||||||
#include "nsIProxiedChannel.h"
|
|
||||||
|
|
||||||
class nsGopherChannel : public nsBaseChannel, public nsIProxiedChannel {
|
|
||||||
public:
|
|
||||||
nsGopherChannel(nsIURI *uri, nsIProxyInfo *pi) : mProxyInfo(pi) {
|
|
||||||
SetURI(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
NS_DECL_NSIPROXIEDCHANNEL
|
|
||||||
|
|
||||||
nsIProxyInfo *ProxyInfo() { return mProxyInfo; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~nsGopherChannel() {}
|
|
||||||
|
|
||||||
virtual nsresult OpenContentStream(PRBool async, nsIInputStream **result,
|
|
||||||
nsIChannel** channel);
|
|
||||||
virtual PRBool GetStatusArg(nsresult status, nsString &statusArg);
|
|
||||||
|
|
||||||
private:
|
|
||||||
nsresult SendRequest(nsIOutputStream *stream);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIProxyInfo> mProxyInfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // !nsGopherChannel_h__
|
|
|
@ -1,159 +0,0 @@
|
||||||
|
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
||||||
*
|
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is the Gopher protocol code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Bradley Baetz.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Bradley Baetz <bbaetz@student.usyd.edu.au>
|
|
||||||
* Darin Fisher <darin@meer.net>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
#include "nsGopherChannel.h"
|
|
||||||
#include "nsGopherHandler.h"
|
|
||||||
#include "nsIURL.h"
|
|
||||||
#include "nsIComponentManager.h"
|
|
||||||
#include "nsIServiceManager.h"
|
|
||||||
#include "nsIStandardURL.h"
|
|
||||||
#include "nsStandardURL.h"
|
|
||||||
#include "nsIPrefService.h"
|
|
||||||
#include "nsIPrefBranch2.h"
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsGopherHandler,
|
|
||||||
nsIProxiedProtocolHandler,
|
|
||||||
nsIProtocolHandler)
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
nsGopherHandler *gGopherHandler = nsnull;
|
|
||||||
|
|
||||||
nsGopherHandler::nsGopherHandler()
|
|
||||||
{
|
|
||||||
gGopherHandler = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsGopherHandler::~nsGopherHandler()
|
|
||||||
{
|
|
||||||
gGopherHandler = nsnull;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRUint8
|
|
||||||
nsGopherHandler::GetQoSBits()
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIPrefBranch2> branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
|
||||||
PRInt32 val;
|
|
||||||
rv = branch->GetIntPref("network.gopher.qos", &val);
|
|
||||||
if (NS_SUCCEEDED(rv))
|
|
||||||
return NS_CLAMP(val, 0, 0xff);
|
|
||||||
}
|
|
||||||
return 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherHandler::GetScheme(nsACString &result)
|
|
||||||
{
|
|
||||||
result.AssignLiteral("gopher");
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherHandler::GetDefaultPort(PRInt32 *result)
|
|
||||||
{
|
|
||||||
*result = GOPHER_PORT;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherHandler::GetProtocolFlags(PRUint32 *result)
|
|
||||||
{
|
|
||||||
*result = URI_NORELATIVE | ALLOWS_PROXY | ALLOWS_PROXY_HTTP |
|
|
||||||
URI_LOADABLE_BY_ANYONE;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherHandler::NewURI(const nsACString &spec, const char *originCharset,
|
|
||||||
nsIURI *baseURI, nsIURI **result)
|
|
||||||
{
|
|
||||||
nsStandardURL *url = new nsStandardURL();
|
|
||||||
if (!url)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
NS_ADDREF(url);
|
|
||||||
|
|
||||||
nsresult rv = url->Init(nsIStandardURL::URLTYPE_STANDARD, GOPHER_PORT,
|
|
||||||
spec, originCharset, baseURI);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
NS_RELEASE(url);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
*result = url; // no QI needed
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherHandler::NewProxiedChannel(nsIURI *uri, nsIProxyInfo *proxyInfo,
|
|
||||||
nsIChannel **result)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(uri);
|
|
||||||
nsGopherChannel *chan = new nsGopherChannel(uri, proxyInfo);
|
|
||||||
if (!chan)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
NS_ADDREF(chan);
|
|
||||||
|
|
||||||
nsresult rv = chan->Init();
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
NS_RELEASE(chan);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
*result = chan;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherHandler::NewChannel(nsIURI *uri, nsIChannel **result)
|
|
||||||
{
|
|
||||||
return NewProxiedChannel(uri, nsnull, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *result)
|
|
||||||
{
|
|
||||||
*result = (port == GOPHER_PORT);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
||||||
*
|
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is the Gopher protocol code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Bradley Baetz.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Bradley Baetz <bbaetz@student.usyd.edu.au>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
#ifndef nsGopherHandler_h___
|
|
||||||
#define nsGopherHandler_h___
|
|
||||||
|
|
||||||
#include "nsIProxiedProtocolHandler.h"
|
|
||||||
#include "nsIProtocolProxyService.h"
|
|
||||||
#include "nsString.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
|
|
||||||
#define GOPHER_PORT 70
|
|
||||||
|
|
||||||
// {0x44588c1f-2ce8-4ad8-9b16-dfb9d9d513a7}
|
|
||||||
|
|
||||||
#define NS_GOPHERHANDLER_CID \
|
|
||||||
{ 0x44588c1f, 0x2ce8, 0x4ad8, \
|
|
||||||
{0x9b, 0x16, 0xdf, 0xb9, 0xd9, 0xd5, 0x13, 0xa7} }
|
|
||||||
|
|
||||||
class nsGopherHandler : public nsIProxiedProtocolHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSIPROTOCOLHANDLER
|
|
||||||
NS_DECL_NSIPROXIEDPROTOCOLHANDLER
|
|
||||||
|
|
||||||
// nsGopherHandler methods:
|
|
||||||
nsGopherHandler();
|
|
||||||
virtual ~nsGopherHandler();
|
|
||||||
|
|
||||||
PRUint8 GetQoSBits();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
nsCOMPtr<nsIProtocolProxyService> mProxySvc;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern nsGopherHandler *gGopherHandler;
|
|
||||||
|
|
||||||
#endif /* nsGopherHandler_h___ */
|
|
|
@ -4620,7 +4620,6 @@ nsHttpChannel::SetReferrer(nsIURI *referrer)
|
||||||
"http",
|
"http",
|
||||||
"https",
|
"https",
|
||||||
"ftp",
|
"ftp",
|
||||||
"gopher",
|
|
||||||
nsnull
|
nsnull
|
||||||
};
|
};
|
||||||
match = PR_FALSE;
|
match = PR_FALSE;
|
||||||
|
|
|
@ -67,14 +67,6 @@ CPPSRCS += \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# only include Gopher directory listing support if the Gopher
|
|
||||||
# protocol is being built.
|
|
||||||
ifneq (,$(filter gopher,$(NECKO_PROTOCOLS)))
|
|
||||||
CPPSRCS += \
|
|
||||||
nsGopherDirListingConv.cpp \
|
|
||||||
$(NULL)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||||
CPPSRCS += \
|
CPPSRCS += \
|
||||||
nsBinHexDecoder.cpp \
|
nsBinHexDecoder.cpp \
|
||||||
|
|
|
@ -1,350 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
||||||
*
|
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is the gopher-directory to http-index code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Bradley Baetz.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Bradley Baetz <bbaetz@student.usyd.edu.au>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
/* This code is based on the ftp directory translation code */
|
|
||||||
|
|
||||||
#include "plstr.h"
|
|
||||||
#include "nsMemory.h"
|
|
||||||
#include "nsCRT.h"
|
|
||||||
#include "nsIServiceManager.h"
|
|
||||||
#include "nsIGenericFactory.h"
|
|
||||||
#include "nsString.h"
|
|
||||||
#include "nsReadableUtils.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsIURI.h"
|
|
||||||
#include "nsEscape.h"
|
|
||||||
#include "nsIStreamListener.h"
|
|
||||||
#include "nsIStreamConverter.h"
|
|
||||||
#include "nsStringStream.h"
|
|
||||||
#include "nsIRequestObserver.h"
|
|
||||||
#include "nsNetUtil.h"
|
|
||||||
#include "nsMimeTypes.h"
|
|
||||||
|
|
||||||
#include "nsGopherDirListingConv.h"
|
|
||||||
|
|
||||||
// nsISupports implementation
|
|
||||||
NS_IMPL_ISUPPORTS3(nsGopherDirListingConv,
|
|
||||||
nsIStreamConverter,
|
|
||||||
nsIStreamListener,
|
|
||||||
nsIRequestObserver)
|
|
||||||
|
|
||||||
// nsIStreamConverter implementation
|
|
||||||
|
|
||||||
#define CONV_BUF_SIZE (4*1024)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherDirListingConv::Convert(nsIInputStream *aFromStream,
|
|
||||||
const char *aFromType,
|
|
||||||
const char *aToType,
|
|
||||||
nsISupports *aCtxt, nsIInputStream **_retval) {
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stream converter service calls this to initialize the actual
|
|
||||||
// stream converter (us).
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherDirListingConv::AsyncConvertData(const char *aFromType,
|
|
||||||
const char *aToType,
|
|
||||||
nsIStreamListener *aListener,
|
|
||||||
nsISupports *aCtxt) {
|
|
||||||
NS_ASSERTION(aListener && aFromType && aToType,
|
|
||||||
"null pointer passed into gopher dir listing converter");
|
|
||||||
|
|
||||||
// hook up our final listener. this guy gets the various On*() calls
|
|
||||||
// we want to throw at him.
|
|
||||||
mFinalListener = aListener;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// nsIStreamListener implementation
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherDirListingConv::OnDataAvailable(nsIRequest *request,
|
|
||||||
nsISupports *ctxt,
|
|
||||||
nsIInputStream *inStr,
|
|
||||||
PRUint32 sourceOffset,
|
|
||||||
PRUint32 count) {
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
PRUint32 read, streamLen;
|
|
||||||
nsCAutoString indexFormat;
|
|
||||||
|
|
||||||
rv = inStr->Available(&streamLen);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
char *buffer = (char*)nsMemory::Alloc(streamLen + 1);
|
|
||||||
if (!buffer)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
rv = inStr->Read(buffer, streamLen, &read);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
// the dir listings are ascii text, null terminate this sucker.
|
|
||||||
buffer[streamLen] = '\0';
|
|
||||||
|
|
||||||
if (!mBuffer.IsEmpty()) {
|
|
||||||
// we have data left over from a previous OnDataAvailable() call.
|
|
||||||
// combine the buffers so we don't lose any data.
|
|
||||||
mBuffer.Append(buffer);
|
|
||||||
nsMemory::Free(buffer);
|
|
||||||
buffer = ToNewCString(mBuffer);
|
|
||||||
mBuffer.Truncate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mSentHeading) {
|
|
||||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
|
||||||
NS_ENSURE_STATE(channel);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
|
||||||
channel->GetURI(getter_AddRefs(uri));
|
|
||||||
NS_ENSURE_STATE(uri);
|
|
||||||
|
|
||||||
// build up the 300: line
|
|
||||||
nsCAutoString spec;
|
|
||||||
rv = uri->GetAsciiSpec(spec);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
//printf("spec is %s\n",spec.get());
|
|
||||||
|
|
||||||
indexFormat.AppendLiteral("300: ");
|
|
||||||
indexFormat.Append(spec);
|
|
||||||
indexFormat.Append(char(nsCRT::LF));
|
|
||||||
// END 300:
|
|
||||||
|
|
||||||
// build up the column heading; 200:
|
|
||||||
indexFormat.AppendLiteral("200: description filename file-type\n");
|
|
||||||
// END 200:
|
|
||||||
|
|
||||||
mSentHeading = PR_TRUE;
|
|
||||||
}
|
|
||||||
char *line = DigestBufferLines(buffer, indexFormat);
|
|
||||||
// if there's any data left over, buffer it.
|
|
||||||
if (line && *line) {
|
|
||||||
mBuffer.Append(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsMemory::Free(buffer);
|
|
||||||
|
|
||||||
// send the converted data out.
|
|
||||||
nsCOMPtr<nsIInputStream> inputData;
|
|
||||||
|
|
||||||
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), indexFormat);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
rv = mFinalListener->OnDataAvailable(request, ctxt, inputData, 0,
|
|
||||||
indexFormat.Length());
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// nsIRequestObserver implementation
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherDirListingConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) {
|
|
||||||
// we don't care about start. move along... but start masqeurading
|
|
||||||
// as the http-index channel now.
|
|
||||||
return mFinalListener->OnStartRequest(request, ctxt);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGopherDirListingConv::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
|
|
||||||
nsresult aStatus) {
|
|
||||||
return mFinalListener->OnStopRequest(request, ctxt, aStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
// nsGopherDirListingConv methods
|
|
||||||
nsGopherDirListingConv::nsGopherDirListingConv() {
|
|
||||||
mSentHeading = PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
char*
|
|
||||||
nsGopherDirListingConv::DigestBufferLines(char* aBuffer, nsCAutoString& aString) {
|
|
||||||
char *line = aBuffer;
|
|
||||||
char *eol;
|
|
||||||
PRBool cr = PR_FALSE;
|
|
||||||
|
|
||||||
// while we have new lines, parse 'em into application/http-index-format.
|
|
||||||
while (line && (eol = PL_strchr(line, nsCRT::LF)) ) {
|
|
||||||
// yank any carriage returns too.
|
|
||||||
if (eol > line && *(eol-1) == nsCRT::CR) {
|
|
||||||
eol--;
|
|
||||||
*eol = '\0';
|
|
||||||
cr = PR_TRUE;
|
|
||||||
} else {
|
|
||||||
*eol = '\0';
|
|
||||||
cr = PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line[0]=='.' && line[1]=='\0') {
|
|
||||||
if (cr)
|
|
||||||
line = eol+2;
|
|
||||||
else
|
|
||||||
line = eol+1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
char type;
|
|
||||||
nsCAutoString desc, selector, host;
|
|
||||||
PRInt32 port = GOPHER_PORT;
|
|
||||||
|
|
||||||
type = line[0];
|
|
||||||
line++;
|
|
||||||
char* tabPos = PL_strchr(line,'\t');
|
|
||||||
|
|
||||||
/* Get the description */
|
|
||||||
if (tabPos) {
|
|
||||||
/* if the description is not empty */
|
|
||||||
if (tabPos != line) {
|
|
||||||
char* descStr = PL_strndup(line,tabPos-line);
|
|
||||||
if (!descStr)
|
|
||||||
return nsnull;
|
|
||||||
char* escName = nsEscape(descStr,url_Path);
|
|
||||||
if (!escName) {
|
|
||||||
PL_strfree(descStr);
|
|
||||||
return nsnull;
|
|
||||||
}
|
|
||||||
desc = escName;
|
|
||||||
NS_Free(escName);
|
|
||||||
PL_strfree(descStr);
|
|
||||||
} else {
|
|
||||||
desc = "%20";
|
|
||||||
}
|
|
||||||
line = tabPos+1;
|
|
||||||
tabPos = PL_strchr(line,'\t');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get selector */
|
|
||||||
if (tabPos) {
|
|
||||||
char* sel = PL_strndup(line,tabPos-line);
|
|
||||||
if (!sel)
|
|
||||||
return nsnull;
|
|
||||||
char* escName = nsEscape(sel,url_Path);
|
|
||||||
if (!escName) {
|
|
||||||
PL_strfree(sel);
|
|
||||||
return nsnull;
|
|
||||||
}
|
|
||||||
selector = escName;
|
|
||||||
NS_Free(escName);
|
|
||||||
PL_strfree(sel);
|
|
||||||
line = tabPos+1;
|
|
||||||
tabPos = PL_strchr(line,'\t');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Host and Port - put together because there is
|
|
||||||
no tab after the port */
|
|
||||||
if (tabPos) {
|
|
||||||
host.Assign(line, tabPos - line);
|
|
||||||
line = tabPos+1;
|
|
||||||
tabPos = PL_strchr(line,'\t');
|
|
||||||
if (tabPos == NULL)
|
|
||||||
tabPos = PL_strchr(line,'\0');
|
|
||||||
|
|
||||||
/* Port */
|
|
||||||
nsCAutoString portStr(line, tabPos - line);
|
|
||||||
port = atol(portStr.get());
|
|
||||||
line = tabPos+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now create the url
|
|
||||||
nsCAutoString filename;
|
|
||||||
if (type != '8' && type != 'T') {
|
|
||||||
filename.AssignLiteral("gopher://");
|
|
||||||
filename.Append(host);
|
|
||||||
if (port != GOPHER_PORT) {
|
|
||||||
filename.Append(':');
|
|
||||||
filename.AppendInt(port);
|
|
||||||
}
|
|
||||||
filename.Append('/');
|
|
||||||
filename.Append(type);
|
|
||||||
filename.Append(selector);
|
|
||||||
} else {
|
|
||||||
// construct telnet/tn3270 url.
|
|
||||||
// Moz doesn't support these, so this is UNTESTED!!!!!
|
|
||||||
// (I do get the correct error message though)
|
|
||||||
if (type == '8')
|
|
||||||
// telnet
|
|
||||||
filename.AssignLiteral("telnet://");
|
|
||||||
else
|
|
||||||
// tn3270
|
|
||||||
filename.AssignLiteral("tn3270://");
|
|
||||||
if (!selector.IsEmpty()) {
|
|
||||||
filename.Append(selector);
|
|
||||||
filename.Append('@');
|
|
||||||
}
|
|
||||||
filename.Append(host);
|
|
||||||
if (port != 23) { // telnet port
|
|
||||||
filename.Append(':');
|
|
||||||
filename.AppendInt(port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tabPos) {
|
|
||||||
/* Don't display error messages or informative messages
|
|
||||||
because they could be selected, and they'll be sorted
|
|
||||||
out of order.
|
|
||||||
If FTP displays .messages/READMEs ever, then I could use the
|
|
||||||
same method to display these
|
|
||||||
*/
|
|
||||||
if (type != '3' && type != 'i') {
|
|
||||||
aString.AppendLiteral("201: ");
|
|
||||||
aString.Append(desc);
|
|
||||||
aString.Append(' ');
|
|
||||||
aString.Append(filename);
|
|
||||||
aString.Append(' ');
|
|
||||||
if (type == '1')
|
|
||||||
aString.AppendLiteral("DIRECTORY");
|
|
||||||
else
|
|
||||||
aString.AppendLiteral("FILE");
|
|
||||||
aString.Append(char(nsCRT::LF));
|
|
||||||
} else if(type == 'i'){
|
|
||||||
aString.AppendLiteral("101: ");
|
|
||||||
aString.Append(desc);
|
|
||||||
aString.Append(char(nsCRT::LF));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
NS_WARNING("Error parsing gopher directory response.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cr)
|
|
||||||
line = eol+2;
|
|
||||||
else
|
|
||||||
line = eol+1;
|
|
||||||
}
|
|
||||||
return line;
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
||||||
*
|
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is the gopher-directory to http-index code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Bradley Baetz.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Bradley Baetz <bbaetz@student.usyd.edu.au>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
/* This code is heavily based on nsFTPDirListingConv.{cpp,h} */
|
|
||||||
|
|
||||||
#ifndef __nsgopherdirlistingconv__h__
|
|
||||||
#define __nsgopherdirlistingconv__h__
|
|
||||||
|
|
||||||
#include "nspr.h"
|
|
||||||
#include "prtypes.h"
|
|
||||||
#include "nsIStreamConverter.h"
|
|
||||||
#include "nsIChannel.h"
|
|
||||||
#include "nsString.h"
|
|
||||||
#include "nsIChannel.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsIURI.h"
|
|
||||||
|
|
||||||
#include "nsIFactory.h"
|
|
||||||
|
|
||||||
#define NS_GOPHERDIRLISTINGCONVERTER_CID \
|
|
||||||
{ /* ea617873-3b73-4efd-a2c4-fc39bfab809d */ \
|
|
||||||
0xea617873, \
|
|
||||||
0x3b73, \
|
|
||||||
0x4efd, \
|
|
||||||
{ 0xa2, 0xc4, 0xfc, 0x39, 0xbf, 0xab, 0x80, 0x9d} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GOPHER_PORT 70
|
|
||||||
|
|
||||||
class nsGopherDirListingConv : public nsIStreamConverter {
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSISTREAMCONVERTER
|
|
||||||
NS_DECL_NSISTREAMLISTENER
|
|
||||||
NS_DECL_NSIREQUESTOBSERVER
|
|
||||||
|
|
||||||
nsGopherDirListingConv();
|
|
||||||
|
|
||||||
private:
|
|
||||||
char* DigestBufferLines(char *aBuffer, nsCAutoString& aString);
|
|
||||||
|
|
||||||
nsCString mBuffer; // buffered data.
|
|
||||||
PRBool mSentHeading;
|
|
||||||
nsCOMPtr<nsIStreamListener> mFinalListener; // this guy gets the converted data via his OnDataAvailable()
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __nsgopherdirlistingdconv__h__ */
|
|
|
@ -185,7 +185,6 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
|
||||||
|
|
||||||
PRBool isScheme = PR_FALSE;
|
PRBool isScheme = PR_FALSE;
|
||||||
PRBool isSchemeFile = PR_FALSE;
|
PRBool isSchemeFile = PR_FALSE;
|
||||||
PRBool isSchemeGopher = PR_FALSE;
|
|
||||||
if (NS_SUCCEEDED(uri->SchemeIs("ftp", &isScheme)) && isScheme) {
|
if (NS_SUCCEEDED(uri->SchemeIs("ftp", &isScheme)) && isScheme) {
|
||||||
|
|
||||||
// strip out the password here, so it doesn't show in the page title
|
// strip out the password here, so it doesn't show in the page title
|
||||||
|
@ -240,8 +239,6 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
|
||||||
rv = mParser->SetEncoding("UTF-8");
|
rv = mParser->SetEncoding("UTF-8");
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
} else if (NS_SUCCEEDED(uri->SchemeIs("gopher", &isSchemeGopher)) && isSchemeGopher) {
|
|
||||||
mExpectAbsLoc = PR_TRUE;
|
|
||||||
} else if (NS_SUCCEEDED(uri->SchemeIs("jar", &isScheme)) && isScheme) {
|
} else if (NS_SUCCEEDED(uri->SchemeIs("jar", &isScheme)) && isScheme) {
|
||||||
nsCAutoString path;
|
nsCAutoString path;
|
||||||
rv = uri->GetPath(path);
|
rv = uri->GetPath(path);
|
||||||
|
@ -363,15 +360,6 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
|
||||||
" -moz-padding-start: .5em;\n"
|
" -moz-padding-start: .5em;\n"
|
||||||
" white-space: nowrap;\n"
|
" white-space: nowrap;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"@-moz-document url-prefix(gopher://) {\n"
|
|
||||||
" td {\n"
|
|
||||||
" white-space: pre !important;\n"
|
|
||||||
" font-family: monospace;\n"
|
|
||||||
" }\n"
|
|
||||||
" table {\n"
|
|
||||||
" direction: ltr;\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n"
|
|
||||||
".symlink {\n"
|
".symlink {\n"
|
||||||
" font-style: italic;\n"
|
" font-style: italic;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
@ -391,89 +379,87 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
|
||||||
"}\n"
|
"}\n"
|
||||||
"]]></style>\n"
|
"]]></style>\n"
|
||||||
"<link rel=\"stylesheet\" media=\"screen, projection\" type=\"text/css\""
|
"<link rel=\"stylesheet\" media=\"screen, projection\" type=\"text/css\""
|
||||||
" href=\"chrome://global/skin/dirListing/dirListing.css\" />\n");
|
" href=\"chrome://global/skin/dirListing/dirListing.css\" />\n"
|
||||||
|
"<script type=\"application/javascript\"><![CDATA[\n"
|
||||||
|
"var gTable, gOrderBy, gTBody, gRows, gUI_showHidden;\n"
|
||||||
|
"document.addEventListener(\"DOMContentLoaded\", function() {\n"
|
||||||
|
" gTable = document.getElementsByTagName(\"table\")[0];\n"
|
||||||
|
" gTBody = gTable.tBodies[0];\n"
|
||||||
|
" if (gTBody.rows.length < 2)\n"
|
||||||
|
" return;\n"
|
||||||
|
" gUI_showHidden = document.getElementById(\"UI_showHidden\");\n"
|
||||||
|
" var headCells = gTable.tHead.rows[0].cells,\n"
|
||||||
|
" hiddenObjects = false;\n"
|
||||||
|
" function rowAction(i) {\n"
|
||||||
|
" return function(event) {\n"
|
||||||
|
" event.preventDefault();\n"
|
||||||
|
" orderBy(i);\n"
|
||||||
|
" }\n"
|
||||||
|
" }\n"
|
||||||
|
" for (var i = headCells.length - 1; i >= 0; i--) {\n"
|
||||||
|
" var anchor = document.createElement(\"a\");\n"
|
||||||
|
" anchor.href = \"\";\n"
|
||||||
|
" anchor.appendChild(headCells[i].firstChild);\n"
|
||||||
|
" headCells[i].appendChild(anchor);\n"
|
||||||
|
" headCells[i].addEventListener(\"click\", rowAction(i), true);\n"
|
||||||
|
" }\n"
|
||||||
|
" if (gUI_showHidden) {\n"
|
||||||
|
" gRows = Array.slice(gTBody.rows);\n"
|
||||||
|
" hiddenObjects = gRows.some(function (row) row.className == \"hidden-object\");\n"
|
||||||
|
" }\n"
|
||||||
|
" gTable.setAttribute(\"order\", \"\");\n"
|
||||||
|
" if (hiddenObjects) {\n"
|
||||||
|
" gUI_showHidden.style.display = \"block\";\n"
|
||||||
|
" updateHidden();\n"
|
||||||
|
" }\n"
|
||||||
|
"}, \"false\");\n"
|
||||||
|
"function compareRows(rowA, rowB) {\n"
|
||||||
|
" var a = rowA.cells[gOrderBy].getAttribute(\"sortable-data\") || \"\";\n"
|
||||||
|
" var b = rowB.cells[gOrderBy].getAttribute(\"sortable-data\") || \"\";\n"
|
||||||
|
" var intA = +a;\n"
|
||||||
|
" var intB = +b;\n"
|
||||||
|
" if (a == intA && b == intB) {\n"
|
||||||
|
" a = intA;\n"
|
||||||
|
" b = intB;\n"
|
||||||
|
" } else {\n"
|
||||||
|
" a = a.toLowerCase();\n"
|
||||||
|
" b = b.toLowerCase();\n"
|
||||||
|
" }\n"
|
||||||
|
" if (a < b)\n"
|
||||||
|
" return -1;\n"
|
||||||
|
" if (a > b)\n"
|
||||||
|
" return 1;\n"
|
||||||
|
" return 0;\n"
|
||||||
|
"}\n"
|
||||||
|
"function orderBy(column) {\n"
|
||||||
|
" if (!gRows)\n"
|
||||||
|
" gRows = Array.slice(gTBody.rows);\n"
|
||||||
|
" var order;\n"
|
||||||
|
" if (gOrderBy == column) {\n"
|
||||||
|
" order = gTable.getAttribute(\"order\") == \"asc\" ? \"desc\" : \"asc\";\n"
|
||||||
|
" } else {\n"
|
||||||
|
" order = \"asc\";\n"
|
||||||
|
" gOrderBy = column;\n"
|
||||||
|
" gTable.setAttribute(\"order-by\", column);\n"
|
||||||
|
" gRows.sort(compareRows);\n"
|
||||||
|
" }\n"
|
||||||
|
" gTable.removeChild(gTBody);\n"
|
||||||
|
" gTable.setAttribute(\"order\", order);\n"
|
||||||
|
" if (order == \"asc\")\n"
|
||||||
|
" for (var i = 0; i < gRows.length; i++)\n"
|
||||||
|
" gTBody.appendChild(gRows[i]);\n"
|
||||||
|
" else\n"
|
||||||
|
" for (var i = gRows.length - 1; i >= 0; i--)\n"
|
||||||
|
" gTBody.appendChild(gRows[i]);\n"
|
||||||
|
" gTable.appendChild(gTBody);\n"
|
||||||
|
"}\n"
|
||||||
|
"function updateHidden() {\n"
|
||||||
|
" gTable.className = gUI_showHidden.getElementsByTagName(\"input\")[0].checked ?\n"
|
||||||
|
" \"\" :\n"
|
||||||
|
" \"remove-hidden\";\n"
|
||||||
|
"}\n"
|
||||||
|
"]]></script>\n");
|
||||||
|
|
||||||
if (!isSchemeGopher) {
|
|
||||||
buffer.AppendLiteral("<script type=\"application/javascript\"><![CDATA[\n"
|
|
||||||
"var gTable, gOrderBy, gTBody, gRows, gUI_showHidden;\n"
|
|
||||||
"document.addEventListener(\"DOMContentLoaded\", function() {\n"
|
|
||||||
" gTable = document.getElementsByTagName(\"table\")[0];\n"
|
|
||||||
" gTBody = gTable.tBodies[0];\n"
|
|
||||||
" if (gTBody.rows.length < 2)\n"
|
|
||||||
" return;\n"
|
|
||||||
" gUI_showHidden = document.getElementById(\"UI_showHidden\");\n"
|
|
||||||
" var headCells = gTable.tHead.rows[0].cells,\n"
|
|
||||||
" hiddenObjects = false;\n"
|
|
||||||
" function rowAction(i) {\n"
|
|
||||||
" return function(event) {\n"
|
|
||||||
" event.preventDefault();\n"
|
|
||||||
" orderBy(i);\n"
|
|
||||||
" }\n"
|
|
||||||
" }\n"
|
|
||||||
" for (var i = headCells.length - 1; i >= 0; i--) {\n"
|
|
||||||
" var anchor = document.createElement(\"a\");\n"
|
|
||||||
" anchor.href = \"\";\n"
|
|
||||||
" anchor.appendChild(headCells[i].firstChild);\n"
|
|
||||||
" headCells[i].appendChild(anchor);\n"
|
|
||||||
" headCells[i].addEventListener(\"click\", rowAction(i), true);\n"
|
|
||||||
" }\n"
|
|
||||||
" if (gUI_showHidden) {\n"
|
|
||||||
" gRows = Array.slice(gTBody.rows);\n"
|
|
||||||
" hiddenObjects = gRows.some(function (row) row.className == \"hidden-object\");\n"
|
|
||||||
" }\n"
|
|
||||||
" gTable.setAttribute(\"order\", \"\");\n"
|
|
||||||
" if (hiddenObjects) {\n"
|
|
||||||
" gUI_showHidden.style.display = \"block\";\n"
|
|
||||||
" updateHidden();\n"
|
|
||||||
" }\n"
|
|
||||||
"}, \"false\");\n"
|
|
||||||
"function compareRows(rowA, rowB) {\n"
|
|
||||||
" var a = rowA.cells[gOrderBy].getAttribute(\"sortable-data\") || \"\";\n"
|
|
||||||
" var b = rowB.cells[gOrderBy].getAttribute(\"sortable-data\") || \"\";\n"
|
|
||||||
" var intA = +a;\n"
|
|
||||||
" var intB = +b;\n"
|
|
||||||
" if (a == intA && b == intB) {\n"
|
|
||||||
" a = intA;\n"
|
|
||||||
" b = intB;\n"
|
|
||||||
" } else {\n"
|
|
||||||
" a = a.toLowerCase();\n"
|
|
||||||
" b = b.toLowerCase();\n"
|
|
||||||
" }\n"
|
|
||||||
" if (a < b)\n"
|
|
||||||
" return -1;\n"
|
|
||||||
" if (a > b)\n"
|
|
||||||
" return 1;\n"
|
|
||||||
" return 0;\n"
|
|
||||||
"}\n"
|
|
||||||
"function orderBy(column) {\n"
|
|
||||||
" if (!gRows)\n"
|
|
||||||
" gRows = Array.slice(gTBody.rows);\n"
|
|
||||||
" var order;\n"
|
|
||||||
" if (gOrderBy == column) {\n"
|
|
||||||
" order = gTable.getAttribute(\"order\") == \"asc\" ? \"desc\" : \"asc\";\n"
|
|
||||||
" } else {\n"
|
|
||||||
" order = \"asc\";\n"
|
|
||||||
" gOrderBy = column;\n"
|
|
||||||
" gTable.setAttribute(\"order-by\", column);\n"
|
|
||||||
" gRows.sort(compareRows);\n"
|
|
||||||
" }\n"
|
|
||||||
" gTable.removeChild(gTBody);\n"
|
|
||||||
" gTable.setAttribute(\"order\", order);\n"
|
|
||||||
" if (order == \"asc\")\n"
|
|
||||||
" for (var i = 0; i < gRows.length; i++)\n"
|
|
||||||
" gTBody.appendChild(gRows[i]);\n"
|
|
||||||
" else\n"
|
|
||||||
" for (var i = gRows.length - 1; i >= 0; i--)\n"
|
|
||||||
" gTBody.appendChild(gRows[i]);\n"
|
|
||||||
" gTable.appendChild(gTBody);\n"
|
|
||||||
"}\n"
|
|
||||||
"function updateHidden() {\n"
|
|
||||||
" gTable.className = gUI_showHidden.getElementsByTagName(\"input\")[0].checked ?\n"
|
|
||||||
" \"\" :\n"
|
|
||||||
" \"remove-hidden\";\n"
|
|
||||||
"}\n"
|
|
||||||
"]]></script>\n");
|
|
||||||
}
|
|
||||||
buffer.AppendLiteral("<link rel=\"icon\" type=\"image/png\" href=\"");
|
buffer.AppendLiteral("<link rel=\"icon\" type=\"image/png\" href=\"");
|
||||||
nsCOMPtr<nsIURI> innerUri = NS_GetInnermostURI(uri);
|
nsCOMPtr<nsIURI> innerUri = NS_GetInnermostURI(uri);
|
||||||
if (!innerUri)
|
if (!innerUri)
|
||||||
|
@ -525,7 +511,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
|
||||||
}
|
}
|
||||||
buffer.AppendLiteral("\" />\n<title>");
|
buffer.AppendLiteral("\" />\n<title>");
|
||||||
|
|
||||||
// Anything but a gopher url needs to end in a /,
|
// Everything needs to end in a /,
|
||||||
// otherwise we end up linking to file:///foo/dirfile
|
// otherwise we end up linking to file:///foo/dirfile
|
||||||
|
|
||||||
if (!mTextToSubURI) {
|
if (!mTextToSubURI) {
|
||||||
|
@ -644,35 +630,33 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
|
||||||
|
|
||||||
buffer.AppendLiteral("<table>\n");
|
buffer.AppendLiteral("<table>\n");
|
||||||
|
|
||||||
if (!isSchemeGopher) {
|
nsXPIDLString columnText;
|
||||||
nsXPIDLString columnText;
|
|
||||||
|
|
||||||
buffer.AppendLiteral(" <thead>\n"
|
buffer.AppendLiteral(" <thead>\n"
|
||||||
" <tr>\n"
|
" <tr>\n"
|
||||||
" <th>");
|
" <th>");
|
||||||
|
|
||||||
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("DirColName").get(),
|
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("DirColName").get(),
|
||||||
getter_Copies(columnText));
|
getter_Copies(columnText));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
AppendNonAsciiToNCR(columnText, buffer);
|
AppendNonAsciiToNCR(columnText, buffer);
|
||||||
buffer.AppendLiteral("</th>\n"
|
buffer.AppendLiteral("</th>\n"
|
||||||
" <th>");
|
" <th>");
|
||||||
|
|
||||||
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("DirColSize").get(),
|
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("DirColSize").get(),
|
||||||
getter_Copies(columnText));
|
getter_Copies(columnText));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
AppendNonAsciiToNCR(columnText, buffer);
|
AppendNonAsciiToNCR(columnText, buffer);
|
||||||
buffer.AppendLiteral("</th>\n"
|
buffer.AppendLiteral("</th>\n"
|
||||||
" <th colspan=\"2\">");
|
" <th colspan=\"2\">");
|
||||||
|
|
||||||
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("DirColMTime").get(),
|
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("DirColMTime").get(),
|
||||||
getter_Copies(columnText));
|
getter_Copies(columnText));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
AppendNonAsciiToNCR(columnText, buffer);
|
AppendNonAsciiToNCR(columnText, buffer);
|
||||||
buffer.AppendLiteral("</th>\n"
|
buffer.AppendLiteral("</th>\n"
|
||||||
" </tr>\n"
|
" </tr>\n"
|
||||||
" </thead>\n");
|
" </thead>\n");
|
||||||
}
|
|
||||||
buffer.AppendLiteral(" <tbody>\n");
|
buffer.AppendLiteral(" <tbody>\n");
|
||||||
|
|
||||||
// Push buffer to the listener now, so the initial HTML will not
|
// Push buffer to the listener now, so the initial HTML will not
|
||||||
|
@ -845,32 +829,28 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
|
||||||
rv = channel->GetURI(getter_AddRefs(uri));
|
rv = channel->GetURI(getter_AddRefs(uri));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// No need to do this for Gopher, as the table has only one column in that case
|
//XXX this potentially truncates after a combining char (bug 391472)
|
||||||
PRBool isSchemeGopher = PR_FALSE;
|
nsXPIDLString descriptionAffix;
|
||||||
if (!(NS_SUCCEEDED(uri->SchemeIs("gopher", &isSchemeGopher)) && isSchemeGopher)) {
|
descriptionAffix.Assign(description);
|
||||||
//XXX this potentially truncates after a combining char (bug 391472)
|
descriptionAffix.Cut(0, descriptionAffix.Length() - 25);
|
||||||
nsXPIDLString descriptionAffix;
|
if (NS_IS_LOW_SURROGATE(descriptionAffix.First()))
|
||||||
descriptionAffix.Assign(description);
|
descriptionAffix.Cut(0, 1);
|
||||||
descriptionAffix.Cut(0, descriptionAffix.Length() - 25);
|
description.Truncate(PR_MIN(71, description.Length() - 28));
|
||||||
if (NS_IS_LOW_SURROGATE(descriptionAffix.First()))
|
if (NS_IS_HIGH_SURROGATE(description.Last()))
|
||||||
descriptionAffix.Cut(0, 1);
|
description.Truncate(description.Length() - 1);
|
||||||
description.Truncate(PR_MIN(71, description.Length() - 28));
|
|
||||||
if (NS_IS_HIGH_SURROGATE(description.Last()))
|
|
||||||
description.Truncate(description.Length() - 1);
|
|
||||||
|
|
||||||
escapedShort.Adopt(nsEscapeHTML2(description.get(), description.Length()));
|
escapedShort.Adopt(nsEscapeHTML2(description.get(), description.Length()));
|
||||||
|
|
||||||
escapedShort.Append(mEscapedEllipsis);
|
escapedShort.Append(mEscapedEllipsis);
|
||||||
// add ZERO WIDTH SPACE (U+200B) for wrapping
|
// add ZERO WIDTH SPACE (U+200B) for wrapping
|
||||||
escapedShort.AppendLiteral("​");
|
escapedShort.AppendLiteral("​");
|
||||||
nsString tmp;
|
nsString tmp;
|
||||||
tmp.Adopt(nsEscapeHTML2(descriptionAffix.get(), descriptionAffix.Length()));
|
tmp.Adopt(nsEscapeHTML2(descriptionAffix.get(), descriptionAffix.Length()));
|
||||||
escapedShort.Append(tmp);
|
escapedShort.Append(tmp);
|
||||||
|
|
||||||
pushBuffer.AppendLiteral(" title=\"");
|
pushBuffer.AppendLiteral(" title=\"");
|
||||||
pushBuffer.Append(escaped);
|
pushBuffer.Append(escaped);
|
||||||
pushBuffer.AppendLiteral("\"");
|
pushBuffer.AppendLiteral("\"");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (escapedShort.IsEmpty())
|
if (escapedShort.IsEmpty())
|
||||||
escapedShort.Assign(escaped);
|
escapedShort.Assign(escaped);
|
||||||
|
@ -908,7 +888,7 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
|
||||||
|
|
||||||
// now minimally re-escape the location...
|
// now minimally re-escape the location...
|
||||||
PRUint32 escFlags;
|
PRUint32 escFlags;
|
||||||
// for some protocols, like gopher, we expect the location to be absolute.
|
// for some protocols, we expect the location to be absolute.
|
||||||
// if so, and if the location indeed appears to be a valid URI, then go
|
// if so, and if the location indeed appears to be a valid URI, then go
|
||||||
// ahead and treat it like one.
|
// ahead and treat it like one.
|
||||||
if (mExpectAbsLoc &&
|
if (mExpectAbsLoc &&
|
||||||
|
|
|
@ -374,7 +374,6 @@ MAKEFILES_netwerk="
|
||||||
netwerk/protocol/data/Makefile
|
netwerk/protocol/data/Makefile
|
||||||
netwerk/protocol/file/Makefile
|
netwerk/protocol/file/Makefile
|
||||||
netwerk/protocol/ftp/Makefile
|
netwerk/protocol/ftp/Makefile
|
||||||
netwerk/protocol/gopher/Makefile
|
|
||||||
netwerk/protocol/http/Makefile
|
netwerk/protocol/http/Makefile
|
||||||
netwerk/protocol/res/Makefile
|
netwerk/protocol/res/Makefile
|
||||||
netwerk/protocol/viewsource/Makefile
|
netwerk/protocol/viewsource/Makefile
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
http://www.mozilla.org/projects/netlib/dirindexformat.html
|
http://www.mozilla.org/projects/netlib/dirindexformat.html
|
||||||
|
|
||||||
One added change is for a description entry, for when the
|
One added change is for a description entry, for when the
|
||||||
target does not match the filename (ie gopher)
|
target does not match the filename
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -107,7 +107,6 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||||
|
|
||||||
// Various protocols we have to special case
|
// Various protocols we have to special case
|
||||||
static const char kFTPProtocol[] = "ftp://";
|
static const char kFTPProtocol[] = "ftp://";
|
||||||
static const char kGopherProtocol[] = "gopher://";
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -428,19 +427,12 @@ nsHTTPIndex::OnIndexAvailable(nsIRequest* aRequest, nsISupports *aContext,
|
||||||
// we found the filename; construct a resource for its entry
|
// we found the filename; construct a resource for its entry
|
||||||
nsCAutoString entryuriC(baseStr);
|
nsCAutoString entryuriC(baseStr);
|
||||||
|
|
||||||
// gopher resources don't point to an entry in the same directory
|
|
||||||
// like ftp uris. So the entryuriC is just a unique string, while
|
|
||||||
// the URL attribute is the destination of this element
|
|
||||||
// The naming scheme for the attributes is taken from the bookmarks
|
|
||||||
nsXPIDLCString filename;
|
nsXPIDLCString filename;
|
||||||
nsresult rv = aIndex->GetLocation(getter_Copies(filename));
|
nsresult rv = aIndex->GetLocation(getter_Copies(filename));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
entryuriC.Append(filename);
|
entryuriC.Append(filename);
|
||||||
|
|
||||||
// if its a directory, make sure it ends with a trailing slash.
|
// if its a directory, make sure it ends with a trailing slash.
|
||||||
// This doesn't matter for gopher, (where directories don't have
|
|
||||||
// to end in a trailing /), because the filename is used for the URL
|
|
||||||
// attribute.
|
|
||||||
PRUint32 type;
|
PRUint32 type;
|
||||||
rv = aIndex->GetType(&type);
|
rv = aIndex->GetType(&type);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
|
@ -464,14 +456,7 @@ nsHTTPIndex::OnIndexAvailable(nsIRequest* aRequest, nsISupports *aContext,
|
||||||
nsCOMPtr<nsIRDFLiteral> lit;
|
nsCOMPtr<nsIRDFLiteral> lit;
|
||||||
nsString str;
|
nsString str;
|
||||||
|
|
||||||
// For gopher, the target is the filename. We still have to do all
|
str.AssignWithConversion(entryuriC.get());
|
||||||
// the above string manipulation though, because we need the entryuric
|
|
||||||
// as the key for the RDF data source
|
|
||||||
if (!strncmp(entryuriC.get(), kGopherProtocol, sizeof(kGopherProtocol)-1))
|
|
||||||
str.AssignWithConversion(filename);
|
|
||||||
else {
|
|
||||||
str.AssignWithConversion(entryuriC.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = mDirRDF->GetLiteral(str.get(), getter_AddRefs(lit));
|
rv = mDirRDF->GetLiteral(str.get(), getter_AddRefs(lit));
|
||||||
|
|
||||||
|
@ -789,7 +774,6 @@ void nsHTTPIndex::GetDestination(nsIRDFResource* r, nsXPIDLCString& dest) {
|
||||||
// get double the # of answers we really want... also, "rdf:file" is
|
// get double the # of answers we really want... also, "rdf:file" is
|
||||||
// less expensive in terms of both memory usage as well as speed
|
// less expensive in terms of both memory usage as well as speed
|
||||||
|
|
||||||
// We also handle gopher now
|
|
||||||
|
|
||||||
|
|
||||||
// We use an rdf attribute to mark if this is a container or not.
|
// We use an rdf attribute to mark if this is a container or not.
|
||||||
|
@ -809,8 +793,6 @@ nsHTTPIndex::isWellknownContainerURI(nsIRDFResource *r)
|
||||||
} else {
|
} else {
|
||||||
nsXPIDLCString uri;
|
nsXPIDLCString uri;
|
||||||
|
|
||||||
// For gopher, we need to follow the URL attribute to get the
|
|
||||||
// real destination
|
|
||||||
GetDestination(r,uri);
|
GetDestination(r,uri);
|
||||||
|
|
||||||
if ((uri.get()) && (!strncmp(uri, kFTPProtocol, sizeof(kFTPProtocol) - 1))) {
|
if ((uri.get()) && (!strncmp(uri, kFTPProtocol, sizeof(kFTPProtocol) - 1))) {
|
||||||
|
@ -818,23 +800,6 @@ nsHTTPIndex::isWellknownContainerURI(nsIRDFResource *r)
|
||||||
isContainerFlag = PR_TRUE;
|
isContainerFlag = PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A gopher url is of the form:
|
|
||||||
// gopher://example.com/xFileNameToGet
|
|
||||||
// where x is a single character representing the type of file
|
|
||||||
// 1 is a directory, and 7 is a search.
|
|
||||||
// Searches will cause a dialog to be popped up (asking the user what
|
|
||||||
// to search for), and so even though searches return a directory as a
|
|
||||||
// result, don't treat it as a directory here.
|
|
||||||
|
|
||||||
// The isContainerFlag test above will correctly handle this when a
|
|
||||||
// search url is passed in as the baseuri
|
|
||||||
if ((uri.get()) &&
|
|
||||||
(!strncmp(uri,kGopherProtocol, sizeof(kGopherProtocol)-1))) {
|
|
||||||
char* pos = PL_strchr(uri+sizeof(kGopherProtocol)-1, '/');
|
|
||||||
if (!pos || pos[1] == '\0' || pos[1] == '1')
|
|
||||||
isContainerFlag = PR_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return isContainerFlag;
|
return isContainerFlag;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче