mirror of
https://github.com/i2p/i2p.i2p.git
synced 2024-12-06 19:27:00 +01:00
Susimail: Show size and thumbnail of draft attachments
This commit is contained in:
@@ -166,6 +166,7 @@ public class WebMail extends HttpServlet
|
||||
private static final String SHOW = "show";
|
||||
private static final String DOWNLOAD = "download";
|
||||
private static final String RAW_ATTACHMENT = "att";
|
||||
private static final String DRAFT_ATTACHMENT = "datt";
|
||||
|
||||
private static final String MARKALL = "markall";
|
||||
private static final String CLEAR = "clearselection";
|
||||
@@ -1616,6 +1617,50 @@ public class WebMail extends HttpServlet
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process thumbnail link in compose view
|
||||
* Draft attachments are stored in the SessionObject and identified by hashcode only.
|
||||
*
|
||||
* @since 0.9.62
|
||||
*/
|
||||
private static void processDraftAttachmentLink(SessionObject sessionObject,
|
||||
RequestWrapper request, HttpServletResponse response)
|
||||
{
|
||||
String str = request.getParameter(DRAFT_ATTACHMENT);
|
||||
if (str != null) {
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
if (sessionObject.attachments != null) {
|
||||
int hc = Integer.parseInt(str);
|
||||
for (Attachment att : sessionObject.attachments) {
|
||||
if (hc == att.hashCode()) {
|
||||
String ct = att.getContentType();
|
||||
if (ct != null)
|
||||
response.setContentType(ct);
|
||||
response.setContentLength((int) att.getSize());
|
||||
response.setHeader("Cache-Control", "public, max-age=3600");
|
||||
in = att.getData();
|
||||
out = response.getOutputStream();
|
||||
DataHelper.copy(in, out);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException nfe ) {
|
||||
} catch (IOException ioe ) {
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
if (out != null) try { out.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
// error if we get here
|
||||
try {
|
||||
response.sendError(404, _t("Attachment not found."));
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process save-as link in message view
|
||||
*
|
||||
@@ -2183,6 +2228,10 @@ public class WebMail extends HttpServlet
|
||||
sendRedirect(httpRequest, response, q);
|
||||
return;
|
||||
}
|
||||
if (request.getParameter(DRAFT_ATTACHMENT) != null) {
|
||||
processDraftAttachmentLink(sessionObject, request, response);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ?show= links - this forces State.SHOW
|
||||
@@ -3101,7 +3150,13 @@ public class WebMail extends HttpServlet
|
||||
} else {
|
||||
out.println("<tr><td align=\"right\"> </td>");
|
||||
}
|
||||
out.println("<td id=\"attachedfile\" align=\"left\"><label><input type=\"checkbox\" class=\"optbox\" name=\"check" + attachment.hashCode() + "\" value=\"1\"> " + quoteHTML(attachment.getFileName()) + "</label></td></tr>");
|
||||
out.println("<td id=\"attachedfile\" align=\"left\"><label><input type=\"checkbox\" class=\"optbox\" name=\"check" + attachment.hashCode() + "\" value=\"1\"> " + quoteHTML(attachment.getFileName()) + "</label>");
|
||||
out.println(DataHelper.formatSize2(attachment.getSize()) + 'B');
|
||||
String type = attachment.getContentType();
|
||||
if (type != null && type.startsWith("image/")) {
|
||||
out.println("<img class=\"thumb\" alt=\"\" src=\"" + myself + '?' + DRAFT_ATTACHMENT + '=' + attachment.hashCode() + "\">");
|
||||
}
|
||||
out.println("</td></tr>");
|
||||
}
|
||||
// TODO disable in JS if none selected
|
||||
out.println("<tr class=\"bottombuttons\"><td> </td><td align=\"left\" id=\"deleteattached\">" +
|
||||
|
||||
@@ -995,6 +995,12 @@ div.attached {
|
||||
background: none;
|
||||
}
|
||||
|
||||
img.thumb {
|
||||
margin: 0px 8px;
|
||||
max-height: 64px;
|
||||
max-width: 128px;
|
||||
}
|
||||
|
||||
div#emptymailbox {
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
@@ -1413,6 +1413,12 @@ td p.error {
|
||||
margin: 8px 3px 0 0;
|
||||
}
|
||||
|
||||
img.thumb {
|
||||
margin: 0px 8px;
|
||||
max-height: 64px;
|
||||
max-width: 128px;
|
||||
}
|
||||
|
||||
#prefsave {
|
||||
margin-top: 4px;
|
||||
padding-top: 10px;
|
||||
|
||||
Reference in New Issue
Block a user