mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
commit
b8870493cd
@ -44,9 +44,9 @@ public class Address {
|
||||
*/
|
||||
private static final Address[] EMPTY_ADDRESS_ARRAY = new Address[0];
|
||||
|
||||
String mAddress;
|
||||
private String mAddress;
|
||||
|
||||
String mPersonal;
|
||||
private String mPersonal;
|
||||
|
||||
|
||||
public Address(Address address) {
|
||||
|
@ -26,9 +26,9 @@ public abstract class Message implements Part, CompositeBody {
|
||||
|
||||
protected String mUid;
|
||||
|
||||
protected Set<Flag> mFlags = new HashSet<Flag>();
|
||||
private Set<Flag> mFlags = new HashSet<Flag>();
|
||||
|
||||
protected Date mInternalDate;
|
||||
private Date mInternalDate;
|
||||
|
||||
protected Folder mFolder;
|
||||
|
||||
@ -124,20 +124,27 @@ public abstract class Message implements Part, CompositeBody {
|
||||
|
||||
public abstract void setReferences(String references) throws MessagingException;
|
||||
|
||||
@Override
|
||||
public abstract Body getBody();
|
||||
|
||||
@Override
|
||||
public abstract String getContentType() throws MessagingException;
|
||||
|
||||
@Override
|
||||
public abstract void addHeader(String name, String value) throws MessagingException;
|
||||
|
||||
@Override
|
||||
public abstract void setHeader(String name, String value) throws MessagingException;
|
||||
|
||||
@Override
|
||||
public abstract String[] getHeader(String name) throws MessagingException;
|
||||
|
||||
public abstract Set<String> getHeaderNames() throws UnavailableStorageException;
|
||||
|
||||
@Override
|
||||
public abstract void removeHeader(String name) throws MessagingException;
|
||||
|
||||
@Override
|
||||
public abstract void setBody(Body body) throws MessagingException;
|
||||
|
||||
public abstract long getId();
|
||||
@ -239,6 +246,7 @@ public abstract class Message implements Part, CompositeBody {
|
||||
|
||||
public void destroy() throws MessagingException {}
|
||||
|
||||
@Override
|
||||
public abstract void setEncoding(String encoding) throws UnavailableStorageException, MessagingException;
|
||||
|
||||
public abstract void setCharset(String charset) throws MessagingException;
|
||||
@ -296,6 +304,8 @@ public abstract class Message implements Part, CompositeBody {
|
||||
* for more information.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public abstract Message clone();
|
||||
@Override
|
||||
public abstract void setUsing7bitTransport() throws MessagingException;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ package com.fsck.k9.mail;
|
||||
public class MessagingException extends Exception {
|
||||
public static final long serialVersionUID = -1;
|
||||
|
||||
boolean permanentFailure = false;
|
||||
private boolean permanentFailure = false;
|
||||
|
||||
public MessagingException(String message) {
|
||||
super(message);
|
||||
|
@ -11,11 +11,11 @@ import com.fsck.k9.mail.internet.MimeUtility;
|
||||
import com.fsck.k9.mail.internet.TextBody;
|
||||
|
||||
public abstract class Multipart implements CompositeBody {
|
||||
protected Part mParent;
|
||||
private Part mParent;
|
||||
|
||||
protected ArrayList<BodyPart> mParts = new ArrayList<BodyPart>();
|
||||
private final ArrayList<BodyPart> mParts = new ArrayList<BodyPart>();
|
||||
|
||||
protected String mContentType;
|
||||
private String mContentType;
|
||||
|
||||
public void addBodyPart(BodyPart part) {
|
||||
mParts.add(part);
|
||||
|
@ -20,8 +20,8 @@ import org.apache.james.mime4j.util.MimeUtil;
|
||||
* Message.
|
||||
*/
|
||||
public class MimeBodyPart extends BodyPart {
|
||||
protected final MimeHeader mHeader = new MimeHeader();
|
||||
protected Body mBody;
|
||||
private final MimeHeader mHeader = new MimeHeader();
|
||||
private Body mBody;
|
||||
|
||||
public MimeBodyPart() throws MessagingException {
|
||||
this(null);
|
||||
@ -38,30 +38,36 @@ public class MimeBodyPart extends BodyPart {
|
||||
setBody(body);
|
||||
}
|
||||
|
||||
protected String getFirstHeader(String name) {
|
||||
private String getFirstHeader(String name) {
|
||||
return mHeader.getFirstHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHeader(String name, String value) throws MessagingException {
|
||||
mHeader.addHeader(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(String name, String value) {
|
||||
mHeader.setHeader(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeader(String name) throws MessagingException {
|
||||
return mHeader.getHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHeader(String name) throws MessagingException {
|
||||
mHeader.removeHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Body getBody() {
|
||||
return mBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBody(Body body) throws MessagingException {
|
||||
this.mBody = body;
|
||||
if (body instanceof Multipart) {
|
||||
@ -93,15 +99,18 @@ public class MimeBodyPart extends BodyPart {
|
||||
setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, encoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() throws MessagingException {
|
||||
String contentType = getFirstHeader(MimeHeader.HEADER_CONTENT_TYPE);
|
||||
return (contentType == null) ? "text/plain" : contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisposition() throws MessagingException {
|
||||
return getFirstHeader(MimeHeader.HEADER_CONTENT_DISPOSITION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentId() throws MessagingException {
|
||||
String contentId = getFirstHeader(MimeHeader.HEADER_CONTENT_ID);
|
||||
if (contentId == null) {
|
||||
@ -116,10 +125,12 @@ public class MimeBodyPart extends BodyPart {
|
||||
contentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMimeType() throws MessagingException {
|
||||
return MimeUtility.getHeaderParameter(getContentType(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMimeType(String mimeType) throws MessagingException {
|
||||
return getMimeType().equalsIgnoreCase(mimeType);
|
||||
}
|
||||
@ -127,6 +138,7 @@ public class MimeBodyPart extends BodyPart {
|
||||
/**
|
||||
* Write the MimeMessage out in MIME format.
|
||||
*/
|
||||
@Override
|
||||
public void writeTo(OutputStream out) throws IOException, MessagingException {
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);
|
||||
mHeader.writeTo(out);
|
||||
|
@ -36,7 +36,7 @@ public class MimeHeader {
|
||||
HEADER_ANDROID_ATTACHMENT_STORE_DATA
|
||||
};
|
||||
|
||||
protected ArrayList<Field> mFields = new ArrayList<Field>();
|
||||
private ArrayList<Field> mFields = new ArrayList<Field>();
|
||||
private String mCharset = null;
|
||||
|
||||
public void clear() {
|
||||
@ -119,7 +119,7 @@ public class MimeHeader {
|
||||
}
|
||||
|
||||
// encode non printable characters except LF/CR/TAB codes.
|
||||
public boolean hasToBeEncoded(String text) {
|
||||
private boolean hasToBeEncoded(String text) {
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
if ((c < 0x20 || 0x7e < c) && // non printable
|
||||
@ -131,10 +131,10 @@ public class MimeHeader {
|
||||
return false;
|
||||
}
|
||||
|
||||
static class Field {
|
||||
final String name;
|
||||
private static class Field {
|
||||
private final String name;
|
||||
|
||||
final String value;
|
||||
private final String value;
|
||||
|
||||
public Field(String name, String value) {
|
||||
this.name = name;
|
||||
@ -153,6 +153,7 @@ public class MimeHeader {
|
||||
mCharset = charset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MimeHeader clone() {
|
||||
MimeHeader header = new MimeHeader();
|
||||
header.mCharset = mCharset;
|
||||
|
@ -25,7 +25,6 @@ import org.apache.james.mime4j.stream.Field;
|
||||
import org.apache.james.mime4j.stream.MimeConfig;
|
||||
import org.apache.james.mime4j.util.MimeUtil;
|
||||
|
||||
import com.fsck.k9.BuildConfig;
|
||||
import com.fsck.k9.mail.Address;
|
||||
import com.fsck.k9.mail.Body;
|
||||
import com.fsck.k9.mail.BodyPart;
|
||||
@ -42,7 +41,7 @@ import com.fsck.k9.K9;
|
||||
* RFC 2045 style headers.
|
||||
*/
|
||||
public class MimeMessage extends Message {
|
||||
protected MimeHeader mHeader = new MimeHeader();
|
||||
private MimeHeader mHeader = new MimeHeader();
|
||||
protected Address[] mFrom;
|
||||
protected Address[] mTo;
|
||||
protected Address[] mCc;
|
||||
@ -50,13 +49,13 @@ public class MimeMessage extends Message {
|
||||
protected Address[] mReplyTo;
|
||||
|
||||
protected String mMessageId;
|
||||
protected String[] mReferences;
|
||||
protected String[] mInReplyTo;
|
||||
private String[] mReferences;
|
||||
private String[] mInReplyTo;
|
||||
|
||||
protected Date mSentDate;
|
||||
protected SimpleDateFormat mDateFormat;
|
||||
private Date mSentDate;
|
||||
private SimpleDateFormat mDateFormat;
|
||||
|
||||
protected Body mBody;
|
||||
private Body mBody;
|
||||
protected int mSize;
|
||||
|
||||
public MimeMessage() {
|
||||
@ -168,20 +167,25 @@ public class MimeMessage extends Message {
|
||||
return (contentType == null) ? "text/plain" : contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisposition() throws MessagingException {
|
||||
return getFirstHeader(MimeHeader.HEADER_CONTENT_DISPOSITION);
|
||||
}
|
||||
@Override
|
||||
public String getContentId() throws MessagingException {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getMimeType() throws MessagingException {
|
||||
return MimeUtility.getHeaderParameter(getContentType(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMimeType(String mimeType) throws MessagingException {
|
||||
return getMimeType().equalsIgnoreCase(mimeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return mSize;
|
||||
}
|
||||
@ -410,7 +414,7 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
}
|
||||
|
||||
protected String getFirstHeader(String name) {
|
||||
private String getFirstHeader(String name) {
|
||||
return mHeader.getFirstHeader(name);
|
||||
}
|
||||
|
||||
@ -439,6 +443,7 @@ public class MimeMessage extends Message {
|
||||
return mHeader.getHeaderNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(OutputStream out) throws IOException, MessagingException {
|
||||
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);
|
||||
@ -450,6 +455,7 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws MessagingException {
|
||||
return null;
|
||||
}
|
||||
@ -486,6 +492,7 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMessage() {
|
||||
if (stack.isEmpty()) {
|
||||
stack.addFirst(MimeMessage.this);
|
||||
@ -501,19 +508,23 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endMessage() {
|
||||
expect(MimeMessage.class);
|
||||
stack.removeFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startHeader() {
|
||||
expect(Part.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endHeader() {
|
||||
expect(Part.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMultipart(BodyDescriptor bd) {
|
||||
expect(Part.class);
|
||||
|
||||
@ -527,6 +538,7 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void body(BodyDescriptor bd, InputStream in) throws IOException {
|
||||
expect(Part.class);
|
||||
try {
|
||||
@ -538,10 +550,12 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endMultipart() {
|
||||
stack.removeFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startBodyPart() {
|
||||
expect(MimeMultipart.class);
|
||||
|
||||
@ -554,11 +568,13 @@ public class MimeMessage extends Message {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endBodyPart() {
|
||||
expect(BodyPart.class);
|
||||
stack.removeFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preamble(InputStream is) throws IOException {
|
||||
expect(MimeMultipart.class);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -569,9 +585,11 @@ public class MimeMessage extends Message {
|
||||
((MimeMultipart)stack.peek()).setPreamble(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void epilogue(InputStream is) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void raw(InputStream is) throws IOException {
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
}
|
||||
@ -621,14 +639,17 @@ public class MimeMessage extends Message {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return Long.parseLong(mUid); //or maybe .mMessageId?
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreview() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttachments() {
|
||||
return false;
|
||||
}
|
||||
|
@ -10,13 +10,11 @@ import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
public class MimeMultipart extends Multipart {
|
||||
protected String mPreamble;
|
||||
private String mPreamble;
|
||||
|
||||
protected String mContentType;
|
||||
private String mContentType;
|
||||
|
||||
protected String mBoundary;
|
||||
|
||||
protected String mSubType;
|
||||
private final String mBoundary;
|
||||
|
||||
public MimeMultipart() throws MessagingException {
|
||||
mBoundary = generateBoundary();
|
||||
@ -26,7 +24,6 @@ public class MimeMultipart extends Multipart {
|
||||
public MimeMultipart(String contentType) throws MessagingException {
|
||||
this.mContentType = contentType;
|
||||
try {
|
||||
mSubType = MimeUtility.getHeaderParameter(contentType, null).split("/")[1];
|
||||
mBoundary = MimeUtility.getHeaderParameter(contentType, "boundary");
|
||||
if (mBoundary == null) {
|
||||
throw new MessagingException("MultiPart does not contain boundary: " + contentType);
|
||||
@ -62,10 +59,10 @@ public class MimeMultipart extends Multipart {
|
||||
}
|
||||
|
||||
public void setSubType(String subType) {
|
||||
this.mSubType = subType;
|
||||
mContentType = String.format("multipart/%s; boundary=\"%s\"", subType, mBoundary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(OutputStream out) throws IOException, MessagingException {
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);
|
||||
|
||||
@ -74,14 +71,12 @@ public class MimeMultipart extends Multipart {
|
||||
writer.write("\r\n");
|
||||
}
|
||||
|
||||
if (mParts.isEmpty()) {
|
||||
if (getBodyParts().isEmpty()) {
|
||||
writer.write("--");
|
||||
writer.write(mBoundary);
|
||||
writer.write("\r\n");
|
||||
}
|
||||
|
||||
for (int i = 0, count = mParts.size(); i < count; i++) {
|
||||
BodyPart bodyPart = mParts.get(i);
|
||||
} else {
|
||||
for (BodyPart bodyPart : getBodyParts()) {
|
||||
writer.write("--");
|
||||
writer.write(mBoundary);
|
||||
writer.write("\r\n");
|
||||
@ -89,6 +84,7 @@ public class MimeMultipart extends Multipart {
|
||||
bodyPart.writeTo(out);
|
||||
writer.write("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
writer.write("--");
|
||||
writer.write(mBoundary);
|
||||
@ -96,13 +92,14 @@ public class MimeMultipart extends Multipart {
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws MessagingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsing7bitTransport() throws MessagingException {
|
||||
for (BodyPart part : mParts) {
|
||||
for (BodyPart part : getBodyParts()) {
|
||||
part.setUsing7bitTransport();
|
||||
}
|
||||
}
|
||||
|
@ -927,11 +927,7 @@ public class MimeUtility {
|
||||
return s.replaceAll("\r|\n", "");
|
||||
}
|
||||
|
||||
public static String decode(String s) {
|
||||
return decode(s, null);
|
||||
}
|
||||
|
||||
public static String decode(String s, Message message) {
|
||||
private static String decode(String s, Message message) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
@ -1005,27 +1001,6 @@ public class MimeUtility {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Part findPartByContentId(Part part, String contentId) throws Exception {
|
||||
if (part.getBody() instanceof Multipart) {
|
||||
Multipart multipart = (Multipart)part.getBody();
|
||||
for (BodyPart bodyPart : multipart.getBodyParts()) {
|
||||
Part ret = findPartByContentId(bodyPart, contentId);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
String[] header = part.getHeader(MimeHeader.HEADER_CONTENT_ID);
|
||||
if (header != null) {
|
||||
for (String s : header) {
|
||||
if (s.equals(contentId)) {
|
||||
return part;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the Part's body and returns a String based on any charset conversion that needed
|
||||
* to be done. Note, this <b>does not</b> return a text representation of HTML.
|
||||
@ -1466,7 +1441,7 @@ public class MimeUtility {
|
||||
* @throws MessagingException
|
||||
* In case of an error.
|
||||
*/
|
||||
public static List<Viewable> getViewables(Part part, List<Part> attachments) throws MessagingException {
|
||||
private static List<Viewable> getViewables(Part part, List<Part> attachments) throws MessagingException {
|
||||
List<Viewable> viewables = new ArrayList<Viewable>();
|
||||
|
||||
Body body = part.getBody();
|
||||
@ -2039,7 +2014,7 @@ public class MimeUtility {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Boolean isPartTextualBody(Part part) throws MessagingException {
|
||||
private static Boolean isPartTextualBody(Part part) throws MessagingException {
|
||||
String disposition = part.getDisposition();
|
||||
String dispositionType = null;
|
||||
String dispositionFilename = null;
|
||||
@ -2127,7 +2102,7 @@ public class MimeUtility {
|
||||
*
|
||||
* @see #MIME_TYPE_REPLACEMENT_MAP
|
||||
*/
|
||||
public static String canonicalizeMimeType(String mimeType) {
|
||||
private static String canonicalizeMimeType(String mimeType) {
|
||||
String lowerCaseMimeType = mimeType.toLowerCase(Locale.US);
|
||||
for (String[] mimeTypeMapEntry : MIME_TYPE_REPLACEMENT_MAP) {
|
||||
if (mimeTypeMapEntry[0].equals(lowerCaseMimeType)) {
|
||||
|
@ -16,7 +16,7 @@ public class TextBody implements Body {
|
||||
*/
|
||||
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
|
||||
|
||||
private String mBody;
|
||||
private final String mBody;
|
||||
private String mEncoding;
|
||||
private String mCharset = "UTF-8";
|
||||
// Length of the message composed (as opposed to quoted). I don't like the name of this variable and am open to
|
||||
@ -29,6 +29,7 @@ public class TextBody implements Body {
|
||||
this.mBody = body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(OutputStream out) throws IOException, MessagingException {
|
||||
if (mBody != null) {
|
||||
byte[] bytes = mBody.getBytes(mCharset);
|
||||
@ -54,6 +55,7 @@ public class TextBody implements Body {
|
||||
/**
|
||||
* Returns an InputStream that reads this body's text.
|
||||
*/
|
||||
@Override
|
||||
public InputStream getInputStream() throws MessagingException {
|
||||
try {
|
||||
byte[] b;
|
||||
@ -68,6 +70,7 @@ public class TextBody implements Body {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncoding(String encoding) {
|
||||
mEncoding = encoding;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ public class TextBodyBuilder {
|
||||
return mQuotedTextHtml;
|
||||
}
|
||||
|
||||
public String textToHtmlFragment(String text) {
|
||||
private String textToHtmlFragment(String text) {
|
||||
return HtmlConverter.textToHtmlFragment(text);
|
||||
}
|
||||
|
||||
|
@ -1302,6 +1302,7 @@ public class ImapStore extends Store {
|
||||
protected long getHighestUid() {
|
||||
try {
|
||||
ImapSearcher searcher = new ImapSearcher() {
|
||||
@Override
|
||||
public List<ImapResponse> search() throws IOException, MessagingException {
|
||||
return executeSimpleCommand("UID SEARCH *:*");
|
||||
}
|
||||
@ -1351,6 +1352,7 @@ public class ImapStore extends Store {
|
||||
|
||||
|
||||
ImapSearcher searcher = new ImapSearcher() {
|
||||
@Override
|
||||
public List<ImapResponse> search() throws IOException, MessagingException {
|
||||
return executeSimpleCommand(String.format(Locale.US, "UID SEARCH %d:%d%s%s", start, end, dateSearchString, includeDeleted ? "" : " NOT DELETED"));
|
||||
}
|
||||
@ -1361,6 +1363,7 @@ public class ImapStore extends Store {
|
||||
protected Message[] getMessages(final List<Long> mesgSeqs, final boolean includeDeleted, final MessageRetrievalListener listener)
|
||||
throws MessagingException {
|
||||
ImapSearcher searcher = new ImapSearcher() {
|
||||
@Override
|
||||
public List<ImapResponse> search() throws IOException, MessagingException {
|
||||
return executeSimpleCommand(String.format("UID SEARCH %s%s", Utility.combine(mesgSeqs.toArray(), ','), includeDeleted ? "" : " NOT DELETED"));
|
||||
}
|
||||
@ -1371,6 +1374,7 @@ public class ImapStore extends Store {
|
||||
protected Message[] getMessagesFromUids(final List<String> mesgUids, final boolean includeDeleted, final MessageRetrievalListener listener)
|
||||
throws MessagingException {
|
||||
ImapSearcher searcher = new ImapSearcher() {
|
||||
@Override
|
||||
public List<ImapResponse> search() throws IOException, MessagingException {
|
||||
return executeSimpleCommand(String.format("UID SEARCH UID %s%s", Utility.combine(mesgUids.toArray(), ','), includeDeleted ? "" : " NOT DELETED"));
|
||||
}
|
||||
@ -2246,6 +2250,7 @@ public class ImapStore extends Store {
|
||||
|
||||
// Setup the searcher
|
||||
final ImapSearcher searcher = new ImapSearcher() {
|
||||
@Override
|
||||
public List<ImapResponse> search() throws IOException, MessagingException {
|
||||
String imapQuery = "UID SEARCH ";
|
||||
if (requiredFlags != null) {
|
||||
@ -2341,12 +2346,12 @@ public class ImapStore extends Store {
|
||||
* A cacheable class that stores the details for a single IMAP connection.
|
||||
*/
|
||||
public static class ImapConnection {
|
||||
protected Socket mSocket;
|
||||
protected PeekableInputStream mIn;
|
||||
protected OutputStream mOut;
|
||||
protected ImapResponseParser mParser;
|
||||
protected int mNextCommandTag;
|
||||
protected Set<String> capabilities = new HashSet<String>();
|
||||
private Socket mSocket;
|
||||
private PeekableInputStream mIn;
|
||||
private OutputStream mOut;
|
||||
private ImapResponseParser mParser;
|
||||
private int mNextCommandTag;
|
||||
private Set<String> capabilities = new HashSet<String>();
|
||||
|
||||
private ImapSettings mSettings;
|
||||
|
||||
@ -2946,7 +2951,7 @@ public class ImapStore extends Store {
|
||||
|
||||
static class ImapException extends MessagingException {
|
||||
private static final long serialVersionUID = 3725007182205882394L;
|
||||
String mAlertText;
|
||||
private final String mAlertText;
|
||||
|
||||
public ImapException(String message, String alertText) {
|
||||
super(message, true);
|
||||
@ -2957,22 +2962,19 @@ public class ImapStore extends Store {
|
||||
return mAlertText;
|
||||
}
|
||||
|
||||
public void setAlertText(String alertText) {
|
||||
mAlertText = alertText;
|
||||
}
|
||||
}
|
||||
|
||||
public class ImapFolderPusher extends ImapFolder implements UntaggedHandler {
|
||||
final PushReceiver receiver;
|
||||
Thread listeningThread = null;
|
||||
final AtomicBoolean stop = new AtomicBoolean(false);
|
||||
final AtomicBoolean idling = new AtomicBoolean(false);
|
||||
final AtomicBoolean doneSent = new AtomicBoolean(false);
|
||||
final AtomicInteger delayTime = new AtomicInteger(NORMAL_DELAY_TIME);
|
||||
final AtomicInteger idleFailureCount = new AtomicInteger(0);
|
||||
final AtomicBoolean needsPoll = new AtomicBoolean(false);
|
||||
List<ImapResponse> storedUntaggedResponses = new ArrayList<ImapResponse>();
|
||||
TracingWakeLock wakeLock = null;
|
||||
private final PushReceiver receiver;
|
||||
private Thread listeningThread = null;
|
||||
private final AtomicBoolean stop = new AtomicBoolean(false);
|
||||
private final AtomicBoolean idling = new AtomicBoolean(false);
|
||||
private final AtomicBoolean doneSent = new AtomicBoolean(false);
|
||||
private final AtomicInteger delayTime = new AtomicInteger(NORMAL_DELAY_TIME);
|
||||
private final AtomicInteger idleFailureCount = new AtomicInteger(0);
|
||||
private final AtomicBoolean needsPoll = new AtomicBoolean(false);
|
||||
private List<ImapResponse> storedUntaggedResponses = new ArrayList<ImapResponse>();
|
||||
private TracingWakeLock wakeLock = null;
|
||||
|
||||
public ImapFolderPusher(ImapStore store, String name, PushReceiver nReceiver) {
|
||||
super(store, name);
|
||||
@ -3010,6 +3012,7 @@ public class ImapStore extends Store {
|
||||
|
||||
public void start() {
|
||||
Runnable runner = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
wakeLock.acquire(K9.PUSH_WAKE_LOCK_TIMEOUT);
|
||||
if (K9.DEBUG)
|
||||
@ -3409,6 +3412,7 @@ public class ImapStore extends Store {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleAsyncUntaggedResponse(ImapResponse response) {
|
||||
if (K9.DEBUG)
|
||||
Log.v(K9.LOG_TAG, "Got async response: " + response);
|
||||
@ -3459,7 +3463,7 @@ public class ImapStore extends Store {
|
||||
}
|
||||
|
||||
public class ImapPusher implements Pusher {
|
||||
final ImapStore mStore;
|
||||
private final ImapStore mStore;
|
||||
final PushReceiver mReceiver;
|
||||
private long lastRefresh = -1;
|
||||
|
||||
@ -3470,6 +3474,7 @@ public class ImapStore extends Store {
|
||||
mReceiver = receiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(List<String> folderNames) {
|
||||
stop();
|
||||
synchronized (folderPushers) {
|
||||
@ -3485,6 +3490,7 @@ public class ImapStore extends Store {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
synchronized (folderPushers) {
|
||||
for (ImapFolderPusher folderPusher : folderPushers.values()) {
|
||||
@ -3497,6 +3503,7 @@ public class ImapStore extends Store {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (K9.DEBUG)
|
||||
Log.i(K9.LOG_TAG, "Requested stop of IMAP pusher");
|
||||
@ -3515,14 +3522,17 @@ public class ImapStore extends Store {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshInterval() {
|
||||
return (getAccount().getIdleRefreshMinutes() * 60 * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastRefresh() {
|
||||
return lastRefresh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastRefresh(long lastRefresh) {
|
||||
this.lastRefresh = lastRefresh;
|
||||
}
|
||||
|
@ -1235,9 +1235,9 @@ public class Pop3Store extends Store {
|
||||
}
|
||||
|
||||
static class Pop3ResponseInputStream extends InputStream {
|
||||
InputStream mIn;
|
||||
boolean mStartOfLine = true;
|
||||
boolean mFinished;
|
||||
private InputStream mIn;
|
||||
private boolean mStartOfLine = true;
|
||||
private boolean mFinished;
|
||||
|
||||
public Pop3ResponseInputStream(InputStream in) {
|
||||
mIn = in;
|
||||
|
@ -176,12 +176,12 @@ public class StorageManager {
|
||||
/**
|
||||
* The root of the denoted storage. Used for mount points checking.
|
||||
*/
|
||||
protected File mRoot;
|
||||
private File mRoot;
|
||||
|
||||
/**
|
||||
* Choosen base directory
|
||||
*/
|
||||
protected File mApplicationDir;
|
||||
private File mApplicationDir;
|
||||
|
||||
@Override
|
||||
public void init(final Context context) {
|
||||
@ -258,7 +258,7 @@ public class StorageManager {
|
||||
|
||||
public static final String ID = "InternalStorage";
|
||||
|
||||
protected File mRoot;
|
||||
private File mRoot;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
@ -328,13 +328,14 @@ public class StorageManager {
|
||||
/**
|
||||
* Root of the denoted storage.
|
||||
*/
|
||||
protected File mRoot;
|
||||
private File mRoot;
|
||||
|
||||
/**
|
||||
* Choosen base directory.
|
||||
*/
|
||||
protected File mApplicationDirectory;
|
||||
private File mApplicationDirectory;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
@ -392,6 +393,7 @@ public class StorageManager {
|
||||
|
||||
public static final String ID = "HtcIncredibleStorage";
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
@ -428,6 +430,7 @@ public class StorageManager {
|
||||
|
||||
public static final String ID = "SamsungGalaxySStorage";
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
@ -12,6 +12,10 @@ import com.fsck.k9.mail.Body;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.filter.Base64OutputStream;
|
||||
|
||||
/**
|
||||
* Superclass for attachments that contain binary data.
|
||||
* The source for the data differs for the subclasses.
|
||||
*/
|
||||
public abstract class BinaryAttachmentBody implements Body {
|
||||
protected String mEncoding;
|
||||
|
||||
|
@ -9,6 +9,9 @@ import android.net.Uri;
|
||||
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
|
||||
/**
|
||||
* An attachment whose contents are loaded from an URI.
|
||||
*/
|
||||
public class LocalAttachmentBody extends BinaryAttachmentBody {
|
||||
private Application mApplication;
|
||||
private Uri mUri;
|
||||
|
@ -39,7 +39,7 @@ public class LocalMessage extends MimeMessage {
|
||||
private long mThreadId;
|
||||
private long mRootId;
|
||||
|
||||
public LocalMessage(LocalStore localStore) {
|
||||
private LocalMessage(LocalStore localStore) {
|
||||
this.localStore = localStore;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ import com.fsck.k9.mail.store.LockableDatabase;
|
||||
import com.fsck.k9.mail.store.StorageManager;
|
||||
import com.fsck.k9.mail.store.UnavailableStorageException;
|
||||
import com.fsck.k9.mail.store.LockableDatabase.DbCallback;
|
||||
import com.fsck.k9.mail.store.LockableDatabase.SchemaDefinition;
|
||||
import com.fsck.k9.mail.store.LockableDatabase.WrappedException;
|
||||
import com.fsck.k9.mail.store.StorageManager.StorageProvider;
|
||||
import com.fsck.k9.provider.EmailProvider;
|
||||
@ -348,15 +347,12 @@ public class LocalStore extends Store implements Serializable {
|
||||
database.recreate();
|
||||
}
|
||||
|
||||
public void pruneCachedAttachments() throws MessagingException {
|
||||
pruneCachedAttachments(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all cached attachments for the entire store.
|
||||
* @param force
|
||||
* @throws com.fsck.k9.mail.MessagingException
|
||||
*/
|
||||
//TODO this method seems to be only called with force=true, simplify accordingly
|
||||
private void pruneCachedAttachments(final boolean force) throws MessagingException {
|
||||
database.execute(false, new DbCallback<Void>() {
|
||||
@Override
|
||||
@ -418,10 +414,6 @@ public class LocalStore extends Store implements Serializable {
|
||||
});
|
||||
}
|
||||
|
||||
public void resetVisibleLimits() throws UnavailableStorageException {
|
||||
resetVisibleLimits(mAccount.getDisplayCount());
|
||||
}
|
||||
|
||||
public void resetVisibleLimits(int visibleLimit) throws UnavailableStorageException {
|
||||
final ContentValues cv = new ContentValues();
|
||||
cv.put("visible_limit", Integer.toString(visibleLimit));
|
||||
|
@ -8,6 +8,9 @@ import java.io.InputStream;
|
||||
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
|
||||
/**
|
||||
* An attachment whose contents are contained in a file.
|
||||
*/
|
||||
public class TempFileBody extends BinaryAttachmentBody {
|
||||
private final File mFile;
|
||||
|
||||
|
@ -8,6 +8,10 @@ import org.apache.james.mime4j.util.MimeUtil;
|
||||
import com.fsck.k9.mail.CompositeBody;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
|
||||
/**
|
||||
* An attachment containing a body of type message/rfc822
|
||||
* whose contents are contained in a file.
|
||||
*/
|
||||
public class TempFileMessageBody extends TempFileBody implements CompositeBody {
|
||||
|
||||
public TempFileMessageBody(String filename) {
|
||||
|
@ -183,16 +183,16 @@ public class SmtpTransport extends Transport {
|
||||
}
|
||||
|
||||
|
||||
String mHost;
|
||||
int mPort;
|
||||
String mUsername;
|
||||
String mPassword;
|
||||
String mClientCertificateAlias;
|
||||
AuthType mAuthType;
|
||||
ConnectionSecurity mConnectionSecurity;
|
||||
Socket mSocket;
|
||||
PeekableInputStream mIn;
|
||||
OutputStream mOut;
|
||||
private String mHost;
|
||||
private int mPort;
|
||||
private String mUsername;
|
||||
private String mPassword;
|
||||
private String mClientCertificateAlias;
|
||||
private AuthType mAuthType;
|
||||
private ConnectionSecurity mConnectionSecurity;
|
||||
private Socket mSocket;
|
||||
private PeekableInputStream mIn;
|
||||
private OutputStream mOut;
|
||||
private boolean m8bitEncodingAllowed;
|
||||
private int mLargestAcceptableMessage;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user