1 package SnowMailClient.model; 2 3 import SnowMailClient.model.accounts.MailAccount; 4 import SnowMailClient.utils.MailMessageUtils; 5 import snow.concurrent.*; 6 import java.util.concurrent.*; 7 import java.util.Date ; 8 9 19 public final class PreviewHeader extends Header 20 { 21 final private MailAccount account; 22 final private String uidl; 23 final private String size; 24 final private long intSize; 25 26 public enum State { MessageNotDownloaded, DownloadingMessage, MessageDownloaded, 27 DownloadInterrupted, DownloadError, Deleted, Deleting } 28 public State state = State.MessageNotDownloaded; 29 public Throwable error = null; 30 public long alreadyDownloadedSize = 0; 31 public boolean forceKeep = false; 33 public boolean forceDelete = false; 34 35 public InterruptableTask downloadTask = null; 36 37 public PreviewHeader(MailAccount account, String uidl, long intSize) 38 { 39 this.account = account; 40 this.uidl = uidl; 41 this.size = MailMessageUtils.formatSize(intSize); 42 this.intSize = intSize; 43 } 44 45 46 public final MailAccount getAccount() { return account; } 47 public final String getSize() { return size; } 48 public final long getSizeInBytes() { return intSize; } 49 public final String getUIDL() { return uidl; } 50 51 53 public long getParsedDate() 54 { 55 try 56 { 57 Date d = MailMessageUtils.parseDateFromString( getEntryValue("date", "?") ); 58 if(d==null) return -1; 59 return d.getTime(); 60 } 61 catch(Exception e) 62 { 63 String de = getEntryValue("date", null); 64 if(de!=null) 65 { 66 System.out.println("Invalid date in header : "+de); 67 } 68 return -1; 69 } 70 } 71 72 } | Popular Tags |