Author: saces
Date: 2008-07-27 11:02:41 +0000 (Sun, 27 Jul 2008)
New Revision: 21435
Modified:
trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
trunk/freenet/src/freenet/clients/http/QueueToadlet.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/pluginmanager/PluginManager.java
Log:
if the ThawIndexBrowser plugin is installed provide a "open with" link on the
warning page
Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2008-07-27
09:16:02 UTC (rev 21434)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2008-07-27
11:02:41 UTC (rev 21435)
@@ -109,7 +109,7 @@
}
- public static void handleDownload(ToadletContext context, Bucket data,
BucketFactory bucketFactory, String mimeType, String requestedMimeType, String
forceString, boolean forceDownload, String basePath, FreenetURI key, String
extras, String referrer, boolean downloadLink, ToadletContext ctx) throws
ToadletContextClosedException, IOException {
+ public static void handleDownload(ToadletContext context, Bucket data,
BucketFactory bucketFactory, String mimeType, String requestedMimeType, String
forceString, boolean forceDownload, String basePath, FreenetURI key, String
extras, String referrer, boolean downloadLink, ToadletContext ctx,
NodeClientCore core) throws ToadletContextClosedException, IOException {
if(Logger.shouldLog(Logger.MINOR, FProxyToadlet.class))
Logger.minor(FProxyToadlet.class,
"handleDownload(data.size="+data.size()+", mimeType="+mimeType+",
requestedMimeType="+requestedMimeType+", forceDownload="+forceDownload+",
basePath="+basePath+", key="+key);
String extrasNoMime = extras; // extras will not include MIME
type to start with - REDFLAG maybe it should be an array
@@ -224,6 +224,11 @@
HTMLNode option = optionList.addChild("li");
L10n.addL10nSubstitution(option,
"FProxyToadlet.openAsText", new String[] { "link", "/link" }, new String[] {
"<a href=\""+basePath+key.toString()+"?type=text/plain"+extrasNoMime+"\">",
"</a>" });
// FIXME: is this safe? See bug #131
+
+ if((mimeType.equals("application/x-freenet-index")) &&
(core.node.pluginManager.isPluginLoaded("plugins.ThawIndexBrowser.ThawIndexBrowser")))
{
+ option = optionList.addChild("li");
+ L10n.addL10nSubstitution(option,
"FProxyToadlet.openAsThawIndex", new String[] { "link", "/link" }, new String[]
{ "<a href=\""+basePath +
"plugins/plugins.ThawIndexBrowser.ThawIndexBrowser/?key=" + key.toString() +
"\">", "</a>" });
+ }
option = optionList.addChild("li");
L10n.addL10nSubstitution(option,
"FProxyToadlet.openForceDisk", new String[] { "link", "/link" }, new String[] {
"<a href=\""+basePath+key.toString()+"?forcedownload"+extras+"\">", "</a>" });
if(!(mimeType.equals("application/octet-stream") ||
mimeType.equals("application/x-msdownload"))) {
@@ -436,8 +441,9 @@
String referer = sanitizeReferer(ctx);
- handleDownload(ctx, data, ctx.getBucketFactory(),
mimeType, requestedMimeType, httprequest.getParam("force", null),
httprequest.isParameterSet("forcedownload"), "/", key, maxSize != MAX_LENGTH ?
"&max-size="+maxSize : "", referer, true, ctx);
+ handleDownload(ctx, data, ctx.getBucketFactory(),
mimeType, requestedMimeType, httprequest.getParam("force", null),
httprequest.isParameterSet("forcedownload"), "/", key, maxSize != MAX_LENGTH ?
"&max-size="+maxSize : "", referer, true, ctx, core);
+
} catch (FetchException e) {
String msg = e.getMessage();
if(Logger.shouldLog(Logger.MINOR, this))
Modified: trunk/freenet/src/freenet/clients/http/QueueToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2008-07-27
09:16:02 UTC (rev 21434)
+++ trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2008-07-27
11:02:41 UTC (rev 21435)
@@ -509,7 +509,7 @@
String mimeType =
clientGet.getMIMEType();
String
requestedMimeType = request.getParam("type", null);
String forceString =
request.getParam("force");
-
FProxyToadlet.handleDownload(ctx, data, ctx.getBucketFactory(), mimeType,
requestedMimeType, forceString, request.isParameterSet("forcedownload"),
"/queue/", key, "", "/queue/", false, ctx);
+
FProxyToadlet.handleDownload(ctx, data, ctx.getBucketFactory(), mimeType,
requestedMimeType, forceString, request.isParameterSet("forcedownload"),
"/queue/", key, "", "/queue/", false, ctx, core);
return;
}
}
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-07-27
09:16:02 UTC (rev 21434)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-07-27
11:02:41 UTC (rev 21435)
@@ -330,6 +330,7 @@
FProxyToadlet.notEnoughMetaStrings=Not enough meta-strings
FProxyToadlet.notFoundTitle=Not Found
FProxyToadlet.openAsText=${link}Click here${/link} to open the file as plain
text (this should not be dangerous but it may be garbled).
+FProxyToadlet.openAsThawIndex=${link}Click here${/link} to open the file with
thaw index browser (read warning above!).
FProxyToadlet.openForce=${link}Click here${/link} to open the file as ${mime}
(read warning above!).
FProxyToadlet.openForceDisk=${link}Click here${/link} to force your browser to
download the file to disk.
FProxyToadlet.openPossRSSForceDisk=${link}Click here${/link} to try to force
your browser to download the file to disk (this ${bold}this may also be
dangerous${/bold} if you run Firefox 2.0.0, 2.0.1 should fix this).
Modified: trunk/freenet/src/freenet/pluginmanager/PluginManager.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginManager.java 2008-07-27
09:16:02 UTC (rev 21434)
+++ trunk/freenet/src/freenet/pluginmanager/PluginManager.java 2008-07-27
11:02:41 UTC (rev 21435)
@@ -369,6 +369,22 @@
}
return null;
}
+
+ /**
+ * look for a Plugin with given classname
+ * @param plugname
+ * @return the true if not found
+ */
+ public boolean isPluginLoaded(String plugname) {
+ synchronized (pluginWrappers) {
+ for(int i=0;i<pluginWrappers.size();i++) {
+ PluginInfoWrapper pi = (PluginInfoWrapper)
pluginWrappers.get(i);
+ if (pi.getPluginClassName().equals(plugname))
+ return true;
+ }
+ }
+ return false;
+ }
public String handleHTTPGet(String plugin, HTTPRequest request) throws
PluginHTTPException {
FredPlugin handler = null;