From 945d455f33391c22303217545ecd66a86b702e43 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Thu, 24 Apr 2014 21:33:43 +0000 Subject: [PATCH] * SusiMail: - Different colors for new mail and spam --- apps/susimail/src/src/i2p/susi/webmail/Mail.java | 16 ++++++++++++++++ .../src/src/i2p/susi/webmail/MailCache.java | 2 ++ .../src/src/i2p/susi/webmail/WebMail.java | 14 ++++++++++++-- .../resources/themes/susimail/light/susimail.css | 12 ++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/apps/susimail/src/src/i2p/susi/webmail/Mail.java b/apps/susimail/src/src/i2p/susi/webmail/Mail.java index 79bd287cb7..0d3c231276 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/Mail.java +++ b/apps/susimail/src/src/i2p/susi/webmail/Mail.java @@ -69,6 +69,7 @@ class Mail { private ReadBuffer header, body; private MailPart part; String[] to, cc; // addresses only, enclosed by <> + private boolean isNew, isSpam; public String error; @@ -141,6 +142,18 @@ class Mail { this.size = size; } + public boolean isSpam() { + return isSpam; + } + + public boolean isNew() { + return isNew; + } + + public void setNew(boolean isNew) { + this.isNew = isNew; + } + /** * * @param address E-mail address to be validated @@ -332,6 +345,9 @@ class Mail { ArrayList<String> list = new ArrayList<String>(); getRecipientsFromList( list, line.substring( 3 ).trim(), true ); cc = list.toArray(new String[list.size()]); + } else if(line.equals( "X-Spam-Flag: YES" )) { + // TODO trust.spam.headers config + isSpam = true; } } } diff --git a/apps/susimail/src/src/i2p/susi/webmail/MailCache.java b/apps/susimail/src/src/i2p/susi/webmail/MailCache.java index 17fef14b27..e79c5c797d 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/MailCache.java +++ b/apps/susimail/src/src/i2p/susi/webmail/MailCache.java @@ -227,6 +227,8 @@ class MailCache { ReadBuffer rb = pr.buf; if (rb != null) { Mail mail = pr.mail; + if (!mail.hasHeader()) + mail.setNew(true); if (pr.getHeaderOnly()) { mail.setHeader(rb); } else { diff --git a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java index 6ca5206232..babeffbcf5 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java +++ b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java @@ -1916,9 +1916,18 @@ public class WebMail extends HttpServlet for( Iterator<String> it = sessionObject.folder.currentPageIterator(); it != null && it.hasNext(); ) { String uidl = it.next(); Mail mail = sessionObject.mailCache.getMail( uidl, MailCache.FETCH_HEADER ); - if (mail == null) + if (mail == null) { + i++; continue; - String link = "<a href=\"" + myself + "?" + SHOW + "=" + i + "\">"; + } + String type; + if (mail.isSpam()) + type = "linkspam"; + else if (mail.isNew()) + type = "linknew"; + else + type = "linkold"; + String link = "<a href=\"" + myself + "?" + SHOW + "=" + i + "\" class=\"" + type + "\">"; boolean idChecked = false; String checkId = sessionObject.pageChanged ? null : request.getParameter( "check" + i ); @@ -2001,6 +2010,7 @@ public class WebMail extends HttpServlet ":</td><td align=\"left\">" + mail.quotedDate + "</td></tr>\n" + "<tr><td colspan=\"2\" align=\"center\"><hr></td></tr>" ); if( mail.hasPart()) { + mail.setNew(false); showPart( out, mail.getPart(), 0, SHOW_HTML ); } else { diff --git a/installer/resources/themes/susimail/light/susimail.css b/installer/resources/themes/susimail/light/susimail.css index 9094966cf1..94634134f6 100644 --- a/installer/resources/themes/susimail/light/susimail.css +++ b/installer/resources/themes/susimail/light/susimail.css @@ -87,6 +87,18 @@ a { font-weight: bold; } +a.linkspam { + color:#927B40; +} + +a.linknew { + color:#327B40; +} + +a.linkold { + color:#327BBF; +} + a:hover { text-decoration:underline; } -- GitLab