use of i2p.susi.util.EscapeHTMLOutputStream in project i2p.i2p by i2p.
the class WebMail method showMessage.
/**
* @param out
* @param sessionObject
* @param reallyDelete was the delete button pushed, if so, show the really delete? message
*/
private static void showMessage(PrintWriter out, SessionObject sessionObject, String showUIDL, boolean reallyDelete) {
if (reallyDelete) {
out.println("<p class=\"error\">" + _t("Really delete this message?") + ' ' + button(REALLYDELETE, _t("Yes, really delete it!")) + ' ' + button(CANCEL, _t("Cancel")) + "</p>");
}
Mail mail = sessionObject.mailCache.getMail(showUIDL, MailCache.FetchMode.ALL);
if (!RELEASE && mail != null && mail.hasBody() && mail.getSize() < 16384) {
out.println("<!--");
out.println("Debug: Mail header and body follow");
Buffer body = mail.getBody();
InputStream in = null;
OutputStream sout = null;
try {
in = body.getInputStream();
sout = new EscapeHTMLOutputStream(new WriterOutputStream(out));
DataHelper.copy(in, sout);
} catch (IOException ioe) {
} finally {
if (in != null)
try {
in.close();
} catch (IOException ioe) {
}
if (sout != null)
try {
sout.close();
} catch (IOException ioe) {
}
body.readComplete(true);
}
out.println("-->");
}
out.println("<div class=\"topbuttons\">");
out.println(button(NEW, _t("New")) + spacer);
boolean hasHeader = mail != null && mail.hasHeader();
if (hasHeader) {
out.println(button(REPLY, _t("Reply")) + button(REPLYALL, _t("Reply All")) + button(FORWARD, _t("Forward")) + spacer + button(SAVE_AS, _t("Save As")) + spacer);
if (sessionObject.reallyDelete)
out.println(button2(DELETE, _t("Delete")));
else
out.println(button(DELETE, _t("Delete")));
}
out.println(button(LOGOUT, _t("Logout")));
// processRequest() will P-R-G the PREV and NEXT so we have a consistent URL
out.println("<div id=\"messagenav\">");
Folder<String> folder = sessionObject.folder;
if (hasHeader) {
String uidl = folder.getPreviousElement(showUIDL);
String text = _t("Previous");
if (uidl == null || folder.isFirstElement(showUIDL)) {
out.println(button2(PREV, text));
} else {
String b64UIDL = Base64.encode(uidl);
out.println("<input type=\"hidden\" name=\"" + PREV_B64UIDL + "\" value=\"" + b64UIDL + "\">");
out.println(button(PREV, text));
}
out.print(spacer);
}
int page = folder.getPageOf(showUIDL);
out.println("<input type=\"hidden\" name=\"" + CUR_PAGE + "\" value=\"" + page + "\">");
out.println(button(LIST, _t("Back to Folder")) + spacer);
if (hasHeader) {
String uidl = folder.getNextElement(showUIDL);
String text = _t("Next");
if (uidl == null || folder.isLastElement(showUIDL)) {
out.println(button2(NEXT, text));
} else {
String b64UIDL = Base64.encode(uidl);
out.println("<input type=\"hidden\" name=\"" + NEXT_B64UIDL + "\" value=\"" + b64UIDL + "\">");
out.println(button(NEXT, text));
}
out.print(spacer);
}
out.println("</div></div>");
// if (Config.hasConfigFile())
// out.println(button( RELOAD, _t("Reload Config") ) + spacer);
out.println("<div id=\"viewmail\"><table id=\"message_full\" cellspacing=\"0\" cellpadding=\"5\">\n");
if (hasHeader) {
String subj = mail.subject;
if (subj.length() > 0)
subj = quoteHTML(subj);
else
subj = "<i>" + _t("no subject") + "</i>";
out.println("<tr><td colspan=\"2\"><table id=\"mailhead\">\n" + "<tr><td colspan=\"2\" align=\"center\"><hr></td></tr>\n" + "<tr><td align=\"right\">" + _t("From") + ":</td><td align=\"left\">" + quoteHTML(mail.sender) + "</td></tr>\n" + "<tr><td align=\"right\">" + _t("Subject") + ":</td><td align=\"left\"><b>" + subj + "</b></td></tr>\n");
if (mail.to != null) {
out.println("<tr><td align=\"right\">" + _t("To") + ":</td><td align=\"left\">" + buildRecipientLine(mail.to) + "</td></tr>\n");
}
if (mail.cc != null) {
out.println("<tr><td align=\"right\">" + _t("Cc") + ":</td><td align=\"left\">" + buildRecipientLine(mail.cc) + "</td></tr>\n");
}
out.println("<tr><td align=\"right\">" + _t("Date") + ":</td><td align=\"left\">" + mail.quotedDate + "</td></tr>\n" + "<tr><td colspan=\"2\" align=\"center\"><hr></td></tr>" + "</table></td></tr>\n");
if (mail.hasPart()) {
mail.setNew(false);
showPart(out, mail.getPart(), 0, SHOW_HTML);
} else {
out.println("<tr class=\"mailbody\"><td colspan=\"2\" align=\"center\"><p class=\"error\">" + _t("Could not fetch mail body.") + "</p></td></tr>\n");
}
} else {
out.println("<tr class=\"mailbody\"><td colspan=\"2\" align=\"center\"><p class=\"error\">" + _t("Message not found.") + "</p></td></tr>\n");
}
out.println("</table></div>");
}
Aggregations