1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-11 20:15:03 -05:00

. Fixed issue 626 and issue 528:

Date header was  not set properly
This commit is contained in:
Bao-Long Nguyen-Trong 2009-09-25 19:12:37 +00:00
parent c2ca739293
commit ac022ce467
4 changed files with 22 additions and 11 deletions

View File

@ -1528,7 +1528,7 @@ public class MessagingController implements Runnable {
Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication); Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication);
LocalFolder localFolder = (LocalFolder)localStore.getFolder(account.getErrorFolderName()); LocalFolder localFolder = (LocalFolder)localStore.getFolder(account.getErrorFolderName());
Message[] messages = new Message[1]; Message[] messages = new Message[1];
Message message = new MimeMessage(); MimeMessage message = new MimeMessage();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos); PrintStream ps = new PrintStream(baos);
t.printStackTrace(ps); t.printStackTrace(ps);
@ -1540,7 +1540,7 @@ public class MessagingController implements Runnable {
long nowTime = System.currentTimeMillis(); long nowTime = System.currentTimeMillis();
Date nowDate = new Date(nowTime); Date nowDate = new Date(nowTime);
message.setInternalDate(nowDate); message.setInternalDate(nowDate);
message.setSentDate(nowDate); message.addSentDate(nowDate);
message.setFrom(new Address(account.getEmail(), "K9mail internal")); message.setFrom(new Address(account.getEmail(), "K9mail internal"));
messages[0] = message; messages[0] = message;
@ -1579,7 +1579,7 @@ public class MessagingController implements Runnable {
Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication); Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication);
LocalFolder localFolder = (LocalFolder)localStore.getFolder(account.getErrorFolderName()); LocalFolder localFolder = (LocalFolder)localStore.getFolder(account.getErrorFolderName());
Message[] messages = new Message[1]; Message[] messages = new Message[1];
Message message = new MimeMessage(); MimeMessage message = new MimeMessage();
message.setBody(new TextBody(body)); message.setBody(new TextBody(body));
@ -1589,7 +1589,7 @@ public class MessagingController implements Runnable {
long nowTime = System.currentTimeMillis(); long nowTime = System.currentTimeMillis();
Date nowDate = new Date(nowTime); Date nowDate = new Date(nowTime);
message.setInternalDate(nowDate); message.setInternalDate(nowDate);
message.setSentDate(nowDate); message.addSentDate(nowDate);
message.setFrom(new Address(account.getEmail(), "K9mail internal")); message.setFrom(new Address(account.getEmail(), "K9mail internal"));
messages[0] = message; messages[0] = message;

View File

@ -630,7 +630,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private MimeMessage createMessage(boolean appendSig) throws MessagingException { private MimeMessage createMessage(boolean appendSig) throws MessagingException {
MimeMessage message = new MimeMessage(); MimeMessage message = new MimeMessage();
message.setSentDate(new Date()); message.addSentDate(new Date());
Address from = new Address(mIdentity.getEmail(), mIdentity.getName()); Address from = new Address(mIdentity.getEmail(), mIdentity.getName());
message.setFrom(from); message.setFrom(from);
message.setRecipients(RecipientType.TO, getAddresses(mToView)); message.setRecipients(RecipientType.TO, getAddresses(mToView));

View File

@ -104,20 +104,31 @@ public class MimeMessage extends Message {
return mSentDate; return mSentDate;
} }
public void setSentDate(Date sentDate) throws MessagingException { /**
* Sets the sent date object member as well as *adds* the 'Date' header
* instead of setting it (for performance reasons).
*
* @see #mSentDate
* @param sentDate
* @throws com.android.email.mail.MessagingException
*/
public void addSentDate(Date sentDate) throws MessagingException {
if (mDateFormat == null) { if (mDateFormat == null) {
mDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US); mDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
} }
setHeader("Date", mDateFormat.format(sentDate)); addHeader("Date", mDateFormat.format(sentDate));
setInternalSentDate(sentDate); setInternalSentDate(sentDate);
} }
public void setSentDate(Date sentDate) throws MessagingException {
removeHeader("Date");
addSentDate(sentDate);
}
public void setInternalSentDate(Date sentDate) throws MessagingException { public void setInternalSentDate(Date sentDate) throws MessagingException {
this.mSentDate = sentDate; this.mSentDate = sentDate;
} }
public String getContentType() throws MessagingException { public String getContentType() throws MessagingException {
String contentType = getFirstHeader(MimeHeader.HEADER_CONTENT_TYPE); String contentType = getFirstHeader(MimeHeader.HEADER_CONTENT_TYPE);
if (contentType == null) { if (contentType == null) {

View File

@ -897,7 +897,7 @@ public class LocalStore extends Store implements Serializable {
if (from.length > 0) { if (from.length > 0) {
message.setFrom(from[0]); message.setFrom(from[0]);
} }
message.setInternalSentDate(new Date(cursor.getLong(2))); message.addSentDate(new Date(cursor.getLong(2)));
message.setUid(cursor.getString(3)); message.setUid(cursor.getString(3));
String flagList = cursor.getString(4); String flagList = cursor.getString(4);
if (flagList != null && flagList.length() > 0) { if (flagList != null && flagList.length() > 0) {