forked from I2P_Developers/i2p.i2p
* 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
This commit is contained in:
@ -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.
|
||||
*/
|
||||
|
@ -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,16 +137,16 @@ 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
|
||||
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);
|
||||
}
|
||||
|
@ -934,9 +934,14 @@ public class WebMail extends HttpServlet
|
||||
*/
|
||||
String uidl = null;
|
||||
if( sessionObject.state == STATE_LIST ) {
|
||||
int pos = getCheckedMessage( request );
|
||||
// these buttons are now hidden on the folder page,
|
||||
// but the idea is to use the first checked message
|
||||
List<Integer> 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<Integer> getCheckedItems(RequestWrapper request) {
|
||||
List<Integer> rv = new ArrayList<Integer>(8);
|
||||
for( Enumeration<String> 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;
|
||||
rv.add(Integer.valueOf(number));
|
||||
} catch( NumberFormatException nfe ) {}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
catch( NumberFormatException nfe ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/**
|
||||
* @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<Attachment>();
|
||||
sessionObject.attachments.add( attachment );
|
||||
sessionObject.attachments.add(
|
||||
new Attachment(filename, contentType, encodeTo, data)
|
||||
);
|
||||
}
|
||||
else {
|
||||
sessionObject.error += _("No Encoding found for {0}", encodeTo) + "<br>";
|
||||
@ -1170,12 +1173,8 @@ public class WebMail extends HttpServlet
|
||||
}
|
||||
}
|
||||
else if( sessionObject.attachments != null && buttonPressed( request, DELETE_ATTACHMENT ) ) {
|
||||
for( Enumeration<String> 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 (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 ) {
|
||||
@ -1184,11 +1183,6 @@ public class WebMail extends HttpServlet
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( NumberFormatException nfe ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.") + "<br>";
|
||||
@ -1340,17 +1334,11 @@ public class WebMail extends HttpServlet
|
||||
else {
|
||||
if( buttonPressed( request, REALLYDELETE ) ) {
|
||||
List<String> toDelete = new ArrayList<String>();
|
||||
for( Enumeration<String> 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 (Integer item : getCheckedItems(request)) {
|
||||
int n = item.intValue();
|
||||
String uidl = sessionObject.folder.getElementAtPosXonCurrentPage( n );
|
||||
if( uidl != null )
|
||||
toDelete.add(uidl);
|
||||
} catch( NumberFormatException nfe ) {}
|
||||
}
|
||||
}
|
||||
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( "<p class=\"error\">" + _("Really delete the marked messages?") + " " + button( REALLYDELETE, _("Yes, really delete them!") ) + "</p>" );
|
||||
}
|
||||
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(
|
||||
"<br>" +
|
||||
( 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("<tr><td colspan=\"9\" align=\"center\"><i>" + _("No messages") + "</i></td></tr>\n</table>");
|
||||
out.println( "<tr><td colspan=\"9\"><hr></td></tr>\n</table>");
|
||||
if (i > 0) {
|
||||
out.println(
|
||||
button( MARKALL, _("Mark All") ) +
|
||||
button( INVERT, _("Invert Selection") ) +
|
||||
button( CLEAR, _("Clear") ) +
|
||||
"<br>");
|
||||
out.println(
|
||||
_("Page Size") + ": <input type=\"text\" style=\"text-align: right;\" name=\"" + PAGESIZE + "\" size=\"4\" value=\"" + sessionObject.folder.getPageSize() + "\">" +
|
||||
button( SETPAGESIZE, _("Set") ) );
|
||||
out.println( "<tr><td colspan=\"9\"><hr></td></tr>");
|
||||
out.println("<tr><td colspan=\"5\" align=\"left\">");
|
||||
if( sessionObject.reallyDelete ) {
|
||||
// TODO ngettext
|
||||
out.println("<p class=\"error\">" + _("Really delete the marked messages?") +
|
||||
"</p>" + button( REALLYDELETE, _("Yes, really delete them!") ) +
|
||||
"<br>" + button( CLEAR, _("Cancel")));
|
||||
} else {
|
||||
// TODO js
|
||||
out.println(button( DELETE, _("Delete Selected") ) + "<br>");
|
||||
out.print(
|
||||
button( CLEAR, _("Clear All") ) +
|
||||
" " +
|
||||
button( MARKALL, _("Mark All") ));
|
||||
//"<br>" +
|
||||
//button( INVERT, _("Invert Selection") ) +
|
||||
//"<br>");
|
||||
}
|
||||
out.print("</td>\n<td colspan=\"4\" align=\"right\">");
|
||||
out.print(
|
||||
_("Page Size") + ": <input type=\"text\" style=\"text-align: right;\" name=\"" + PAGESIZE + "\" size=\"4\" value=\"" + sessionObject.folder.getPageSize() + "\">" +
|
||||
" " +
|
||||
button( SETPAGESIZE, _("Set") ) );
|
||||
out.println("</td>");
|
||||
}
|
||||
out.println( "</table>");
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
12
history.txt
12
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
|
||||
|
@ -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 = "";
|
||||
|
Reference in New Issue
Block a user