mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Implement References/In-Reply-To/X-User-Agen. Fixes issue 42. Patch from e.w.stemle
This commit is contained in:
parent
690505ea73
commit
fcd8ee9aeb
@ -127,6 +127,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
private View mQuotedTextBar;
|
||||
private ImageButton mQuotedTextDelete;
|
||||
private EditText mQuotedText;
|
||||
|
||||
private String mReferences;
|
||||
private String mInReplyTo;
|
||||
|
||||
private boolean mDraftNeedsSaving = false;
|
||||
|
||||
@ -640,8 +643,16 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
message.setRecipients(RecipientType.CC, getAddresses(mCcView));
|
||||
message.setRecipients(RecipientType.BCC, getAddresses(mBccView));
|
||||
message.setSubject(mSubjectView.getText().toString());
|
||||
// XXX TODO - not sure why this won't add header
|
||||
// message.setHeader("X-User-Agent", getString(R.string.message_header_mua));
|
||||
message.setHeader("X-User-Agent", getString(R.string.message_header_mua));
|
||||
|
||||
if (mInReplyTo != null) {
|
||||
message.setInReplyTo(mInReplyTo);
|
||||
}
|
||||
|
||||
if (mReferences != null) {
|
||||
message.setReferences(mReferences);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Build the Body that will contain the text of the message. We'll decide where to
|
||||
@ -1085,6 +1096,26 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
addAddresses(mToView, replyToAddresses = message.getFrom());
|
||||
}
|
||||
|
||||
if (message.getMessageId() != null && message.getMessageId().length() > 0) {
|
||||
String messageId = message.getMessageId();
|
||||
mInReplyTo = messageId;
|
||||
|
||||
if (message.getReferences() != null && message.getReferences().length > 0) {
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
for (int i=0; i < message.getReferences().length; i++)
|
||||
buffy.append(message.getReferences()[i]);
|
||||
|
||||
mReferences = buffy.toString() + " " + mInReplyTo;
|
||||
}
|
||||
else {
|
||||
mReferences = mInReplyTo;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Log.d(Email.LOG_TAG, "could not get Message-ID.");
|
||||
}
|
||||
|
||||
Part part = MimeUtility.findFirstPartByMimeType(mSourceMessage,
|
||||
"text/plain");
|
||||
if (part != null) {
|
||||
|
@ -66,6 +66,14 @@ public abstract class Message implements Part, Body {
|
||||
|
||||
public abstract void setReplyTo(Address[] from) throws MessagingException;
|
||||
|
||||
public abstract String getMessageId() throws MessagingException;
|
||||
|
||||
public abstract void setInReplyTo(String inReplyTo) throws MessagingException;
|
||||
|
||||
public abstract String[] getReferences() throws MessagingException;
|
||||
|
||||
public abstract void setReferences(String references) throws MessagingException;
|
||||
|
||||
public abstract Body getBody() throws MessagingException;
|
||||
|
||||
public abstract String getContentType() throws MessagingException;
|
||||
|
@ -19,6 +19,9 @@ import org.apache.james.mime4j.MimeStreamParser;
|
||||
import org.apache.james.mime4j.field.DateTimeField;
|
||||
import org.apache.james.mime4j.field.Field;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.mail.Address;
|
||||
import com.android.email.mail.Body;
|
||||
import com.android.email.mail.BodyPart;
|
||||
@ -37,6 +40,11 @@ public class MimeMessage extends Message {
|
||||
protected Address[] mCc;
|
||||
protected Address[] mBcc;
|
||||
protected Address[] mReplyTo;
|
||||
|
||||
protected String mMessageId;
|
||||
protected String[] mReferences;
|
||||
protected String[] mInReplyTo;
|
||||
|
||||
protected Date mSentDate;
|
||||
protected SimpleDateFormat mDateFormat;
|
||||
|
||||
@ -56,6 +64,7 @@ public class MimeMessage extends Message {
|
||||
sb.append(".");
|
||||
sb.append(Long.toString(System.currentTimeMillis()));
|
||||
sb.append("@email.android.com>");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@ -77,6 +86,11 @@ public class MimeMessage extends Message {
|
||||
mCc = null;
|
||||
mBcc = null;
|
||||
mReplyTo = null;
|
||||
|
||||
mMessageId = null;
|
||||
mReferences = null;
|
||||
mInReplyTo = null;
|
||||
|
||||
mSentDate = null;
|
||||
|
||||
mBody = null;
|
||||
@ -259,6 +273,28 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
}
|
||||
|
||||
public String getMessageId() throws MessagingException {
|
||||
if (mMessageId == null) {
|
||||
mMessageId = getFirstHeader("Message-ID");
|
||||
}
|
||||
return mMessageId;
|
||||
}
|
||||
|
||||
public void setInReplyTo(String inReplyTo) throws MessagingException {
|
||||
setHeader("In-Reply-To", inReplyTo);
|
||||
}
|
||||
|
||||
public String[] getReferences() throws MessagingException {
|
||||
if (mReferences == null) {
|
||||
mReferences = getHeader("References");
|
||||
}
|
||||
return mReferences;
|
||||
}
|
||||
|
||||
public void setReferences(String references) throws MessagingException {
|
||||
setHeader("References", references);
|
||||
}
|
||||
|
||||
public void saveChanges() throws MessagingException {
|
||||
throw new MessagingException("saveChanges not yet implemented");
|
||||
}
|
||||
|
@ -80,6 +80,9 @@ public class LocalStore extends Store implements Serializable {
|
||||
static
|
||||
{
|
||||
HEADERS_TO_SAVE.add(Email.K9MAIL_IDENTITY);
|
||||
HEADERS_TO_SAVE.add("In-Reply-To");
|
||||
HEADERS_TO_SAVE.add("References");
|
||||
HEADERS_TO_SAVE.add("X-User-Agent");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user