From 04cabf40b5b40a9921b770d100ec50afad94cbc5 Mon Sep 17 00:00:00 2001 From: zzz Date: Fri, 25 Apr 2014 16:11:35 +0000 Subject: [PATCH] * SusiMail: - Move delete and confirmation button in folder view to bottom left, page size form to bottom right - Attachment finals and cleanup - Increase max size for full download again - Fix repeated re-saves of mail to disk - Enable auto-deletion of downloaded mails - Consolidate check box processing - Button spacing tweaks --- .../src/src/i2p/susi/webmail/Attachment.java | 50 ++----- .../src/src/i2p/susi/webmail/MailCache.java | 19 ++- .../src/src/i2p/susi/webmail/WebMail.java | 123 +++++++++--------- history.txt | 12 ++ .../src/net/i2p/router/RouterVersion.java | 2 +- 5 files changed, 94 insertions(+), 112 deletions(-) diff --git a/apps/susimail/src/src/i2p/susi/webmail/Attachment.java b/apps/susimail/src/src/i2p/susi/webmail/Attachment.java index bb0bf82211..db13617fc1 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/Attachment.java +++ b/apps/susimail/src/src/i2p/susi/webmail/Attachment.java @@ -23,65 +23,35 @@ */ package i2p.susi.webmail; -import i2p.susi.util.ReadBuffer; - /** * @author user */ class Attachment { - private String fileName, contentType, transferEncoding; - private ReadBuffer buffer; - private String data; + private final String fileName, contentType, transferEncoding; + private final String data; + + Attachment(String name, String type, String encoding, String data) { + fileName = name; + contentType = type; + transferEncoding = encoding; + this.data = data; + } + /** * @return Returns the fileName. */ public String getFileName() { return fileName; } - /** - * @param fileName The fileName to set. - */ - public void setFileName(String fileName) { - this.fileName = fileName; - } - /** - * @return Returns the buffer. - */ - public ReadBuffer getBuffer() { - return buffer; - } - /** - * @param buffer The buffer to set. - */ - public void setBuffer(ReadBuffer buffer) { - this.buffer = buffer; - } public String getTransferEncoding() { - // TODO Auto-generated method stub return transferEncoding; } public String getContentType() { - // TODO Auto-generated method stub return contentType; } - /** - * @param contentType The contentType to set. - */ - public void setContentType(String contentType) { - this.contentType = contentType; - } - /** - * @param transferEncoding The transferEncoding to set. - */ - public void setTransferEncoding(String transferEncoding) { - this.transferEncoding = transferEncoding; - } - public void setData(String data ) { - this.data = data; - } /** * @return Returns the data. */ diff --git a/apps/susimail/src/src/i2p/susi/webmail/MailCache.java b/apps/susimail/src/src/i2p/susi/webmail/MailCache.java index e79c5c797d..058fda1e8b 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/MailCache.java +++ b/apps/susimail/src/src/i2p/susi/webmail/MailCache.java @@ -53,7 +53,7 @@ class MailCache { /** Includes header, headers are generally 1KB to 1.5 KB, * and bodies will compress well. */ - private static final int FETCH_ALL_SIZE = 4096; + private static final int FETCH_ALL_SIZE = 8192; /** * @param mailbox non-null @@ -137,14 +137,14 @@ class MailCache { mail.setHeader(mailbox.getHeader(uidl)); } else { if(!mail.hasBody()) { - mail.setBody(mailbox.getBody(uidl)); - } - } - if (disk != null) { - if (disk.saveMail(mail) && mail.hasBody() && - false && // TO ENABLE - !Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) { - mailbox.queueForDeletion(mail.uidl); + ReadBuffer rb = mailbox.getBody(uidl); + if (rb != null) { + mail.setBody(rb); + if (disk != null && disk.saveMail(mail) && + !Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) { + mailbox.queueForDeletion(mail.uidl); + } + } } } return mail; @@ -237,7 +237,6 @@ class MailCache { rv = true; if (disk != null) { if (disk.saveMail(mail) && mail.hasBody() && - false && // TO ENABLE !Boolean.parseBoolean(Config.getProperty(WebMail.CONFIG_LEAVE_ON_SERVER))) { mailbox.queueForDeletion(mail.uidl); } diff --git a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java index 83e71dae32..df029284d6 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java +++ b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java @@ -934,8 +934,13 @@ public class WebMail extends HttpServlet */ String uidl = null; if( sessionObject.state == STATE_LIST ) { - int pos = getCheckedMessage( request ); - uidl = sessionObject.folder.getElementAtPosXonCurrentPage( pos ); + // these buttons are now hidden on the folder page, + // but the idea is to use the first checked message + List items = getCheckedItems(request); + if (!items.isEmpty()) { + int pos = items.get(0).intValue(); + uidl = sessionObject.folder.getElementAtPosXonCurrentPage( pos ); + } } else { uidl = sessionObject.showUIDL; @@ -1067,26 +1072,26 @@ public class WebMail extends HttpServlet } } } + /** + * Returns e.g. 3,5 for ?check3=1&check5=1 (or POST equivalent) * @param request - * @return message number or -1 + * @return non-null */ - private static int getCheckedMessage(RequestWrapper request) { + private static List getCheckedItems(RequestWrapper request) { + List rv = new ArrayList(8); for( Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) { String parameter = e.nextElement(); if( parameter.startsWith( "check" ) && request.getParameter( parameter ).equals("1")) { String number = parameter.substring( 5 ); try { - int n = Integer.parseInt( number ); - return n; - } - catch( NumberFormatException nfe ) { - - } + rv.add(Integer.valueOf(number)); + } catch( NumberFormatException nfe ) {} } } - return -1; + return rv; } + /** * @param sessionObject * @param request @@ -1136,8 +1141,6 @@ public class WebMail extends HttpServlet if( l > 0 ) { byte buf[] = new byte[l]; in.read( buf ); - Attachment attachment = new Attachment(); - attachment.setFileName( filename ); String contentType = request.getContentType( NEW_FILENAME ); Encoding encoding; String encodeTo; @@ -1148,12 +1151,12 @@ public class WebMail extends HttpServlet encoding = EncodingFactory.getEncoding( encodeTo ); try { if( encoding != null ) { - attachment.setData( encoding.encode( buf ) ); - attachment.setTransferEncoding( encodeTo ); - attachment.setContentType( contentType ); + String data = encoding.encode(buf); if( sessionObject.attachments == null ) sessionObject.attachments = new ArrayList(); - sessionObject.attachments.add( attachment ); + sessionObject.attachments.add( + new Attachment(filename, contentType, encodeTo, data) + ); } else { sessionObject.error += _("No Encoding found for {0}", encodeTo) + "
"; @@ -1170,22 +1173,13 @@ public class WebMail extends HttpServlet } } else if( sessionObject.attachments != null && buttonPressed( request, DELETE_ATTACHMENT ) ) { - for( Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) { - String parameter = e.nextElement(); - if( parameter.startsWith( "check" ) && request.getParameter( parameter ).equals("1")) { - String number = parameter.substring( 5 ); - try { - int n = Integer.parseInt( number ); - for( int i = 0; i < sessionObject.attachments.size(); i++ ) { - Attachment attachment = (Attachment)sessionObject.attachments.get( i ); - if( attachment.hashCode() == n ) { - sessionObject.attachments.remove( i ); - break; - } - } - } - catch( NumberFormatException nfe ) { - + for (Integer item : getCheckedItems(request)) { + int n = item.intValue(); + for( int i = 0; i < sessionObject.attachments.size(); i++ ) { + Attachment attachment = (Attachment)sessionObject.attachments.get( i ); + if( attachment.hashCode() == n ) { + sessionObject.attachments.remove( i ); + break; } } } @@ -1331,8 +1325,8 @@ public class WebMail extends HttpServlet sessionObject.folder.lastPage(); } else if( buttonPressed( request, DELETE ) ) { - int m = getCheckedMessage( request ); - if( m != -1 ) + int m = getCheckedItems(request).size(); + if (m > 0) sessionObject.reallyDelete = true; else sessionObject.error += _("No messages marked for deletion.") + "
"; @@ -1340,17 +1334,11 @@ public class WebMail extends HttpServlet else { if( buttonPressed( request, REALLYDELETE ) ) { List toDelete = new ArrayList(); - for( Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) { - String parameter = e.nextElement(); - if( parameter.startsWith( "check" ) && request.getParameter( parameter ).equals("1")) { - String number = parameter.substring( 5 ); - try { - int n = Integer.parseInt( number ); - String uidl = sessionObject.folder.getElementAtPosXonCurrentPage( n ); - if( uidl != null ) - toDelete.add(uidl); - } catch( NumberFormatException nfe ) {} - } + for (Integer item : getCheckedItems(request)) { + int n = item.intValue(); + String uidl = sessionObject.folder.getElementAtPosXonCurrentPage( n ); + if( uidl != null ) + toDelete.add(uidl); } int numberDeleted = toDelete.size(); if (numberDeleted > 0) { @@ -1987,16 +1975,13 @@ public class WebMail extends HttpServlet */ private static void showFolder( PrintWriter out, SessionObject sessionObject, RequestWrapper request ) { - if( sessionObject.reallyDelete ) { - out.println( "

" + _("Really delete the marked messages?") + " " + button( REALLYDELETE, _("Yes, really delete them!") ) + "

" ); - } out.println( button( NEW, _("New") ) + spacer + // In theory, these are valid and will apply to the first checked message, // but that's not obvious and did it work? //button( REPLY, _("Reply") ) + //button( REPLYALL, _("Reply All") ) + //button( FORWARD, _("Forward") ) + spacer + - button( DELETE, _("Delete") ) + spacer + + //button( DELETE, _("Delete") ) + spacer + button( REFRESH, _("Check Mail") ) + spacer); if (Config.hasConfigFile()) out.println(button( RELOAD, _("Reload Config") ) + spacer); @@ -2006,14 +1991,14 @@ public class WebMail extends HttpServlet out.println( "
" + ( sessionObject.folder.isFirstPage() ? - button2( FIRSTPAGE, _("First") ) + button2( PREVPAGE, _("Previous") ) : - button( FIRSTPAGE, _("First") ) + button( PREVPAGE, _("Previous") ) ) + + button2( FIRSTPAGE, _("First") ) + " " + button2( PREVPAGE, _("Previous") ) : + button( FIRSTPAGE, _("First") ) + " " + button( PREVPAGE, _("Previous") ) ) + "      " + _("Page {0} of {1}", sessionObject.folder.getCurrentPage(), sessionObject.folder.getPages()) + "      " + ( sessionObject.folder.isLastPage() ? - button2( NEXTPAGE, _("Next") ) + button2( LASTPAGE, _("Last") ) : - button( NEXTPAGE, _("Next") ) + button( LASTPAGE, _("Last") ) ) + button2( NEXTPAGE, _("Next") ) + " " + button2( LASTPAGE, _("Last") ) : + button( NEXTPAGE, _("Next") ) + " " + button( LASTPAGE, _("Last") ) ) ); } @@ -2078,17 +2063,33 @@ public class WebMail extends HttpServlet } if (i == 0) out.println("" + _("No messages") + "\n"); - out.println( "
\n"); if (i > 0) { - out.println( - button( MARKALL, _("Mark All") ) + - button( INVERT, _("Invert Selection") ) + - button( CLEAR, _("Clear") ) + - "
"); - out.println( + out.println( "
"); + out.println(""); + if( sessionObject.reallyDelete ) { + // TODO ngettext + out.println("

" + _("Really delete the marked messages?") + + "

" + button( REALLYDELETE, _("Yes, really delete them!") ) + + "
" + button( CLEAR, _("Cancel"))); + } else { + // TODO js + out.println(button( DELETE, _("Delete Selected") ) + "
"); + out.print( + button( CLEAR, _("Clear All") ) + + " " + + button( MARKALL, _("Mark All") )); + //"
" + + //button( INVERT, _("Invert Selection") ) + + //"
"); + } + out.print("\n"); + out.print( _("Page Size") + ": " + + " " + button( SETPAGESIZE, _("Set") ) ); + out.println(""); } + out.println( ""); } /** * diff --git a/history.txt b/history.txt index 5d3f865a11..7020a5036a 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,15 @@ +2014-04-25 zzz + * SusiMail: + - Add icons for new messages, attachments, and spam + - Different colors for new mail and spam + - Tweak sort button display based on current sort + - Display image attachments inline + - Don't rezip certain attachment types, just offer link + - Move delete and confirmation buttons + - Increase max size for full download again + - Fix repeated re-saves of mail to disk + - Enable auto-deletion of downloaded mails + 2014-04-24 zzz * SusiMail: - Add background mail checker diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 5a58b19bc2..e36cd3b143 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 11; + public final static long BUILD = 12; /** for example "-test" */ public final static String EXTRA = "";