From b6079d64606090014fba3b810f484855fab759b1 Mon Sep 17 00:00:00 2001 From: Tobias Baum Date: Mon, 22 Sep 2014 21:52:59 +0200 Subject: [PATCH 1/3] UCDetector warnings: Made things private, deleted unused methods and fields --- src/com/fsck/k9/mail/Address.java | 4 +- src/com/fsck/k9/mail/Message.java | 16 ++++-- src/com/fsck/k9/mail/MessagingException.java | 2 +- src/com/fsck/k9/mail/Multipart.java | 4 +- .../fsck/k9/mail/internet/MimeBodyPart.java | 18 +++++-- src/com/fsck/k9/mail/internet/MimeHeader.java | 11 ++-- .../fsck/k9/mail/internet/MimeMessage.java | 37 ++++++++++--- .../fsck/k9/mail/internet/MimeMultipart.java | 12 ++--- .../fsck/k9/mail/internet/MimeUtility.java | 33 ++---------- src/com/fsck/k9/mail/internet/TextBody.java | 5 +- .../k9/mail/internet/TextBodyBuilder.java | 2 +- src/com/fsck/k9/mail/store/ImapStore.java | 52 +++++++++++-------- src/com/fsck/k9/mail/store/Pop3Store.java | 6 +-- .../fsck/k9/mail/store/StorageManager.java | 13 +++-- .../k9/mail/store/local/LocalMessage.java | 2 +- .../fsck/k9/mail/store/local/LocalStore.java | 10 +--- .../fsck/k9/mail/transport/SmtpTransport.java | 22 ++++---- 17 files changed, 137 insertions(+), 112 deletions(-) diff --git a/src/com/fsck/k9/mail/Address.java b/src/com/fsck/k9/mail/Address.java index a8ef1ee0c..b5bdcc854 100644 --- a/src/com/fsck/k9/mail/Address.java +++ b/src/com/fsck/k9/mail/Address.java @@ -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) { diff --git a/src/com/fsck/k9/mail/Message.java b/src/com/fsck/k9/mail/Message.java index 1c1cf3014..7da6ff1fc 100644 --- a/src/com/fsck/k9/mail/Message.java +++ b/src/com/fsck/k9/mail/Message.java @@ -26,9 +26,9 @@ public abstract class Message implements Part, CompositeBody { protected String mUid; - protected Set mFlags = new HashSet(); + private Set mFlags = new HashSet(); - protected Date mInternalDate; + private Date mInternalDate; protected Folder mFolder; @@ -45,7 +45,7 @@ public abstract class Message implements Part, CompositeBody { } return false; } - + @Override public boolean equals(Object o) { if (o == null || !(o instanceof Message)) { @@ -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 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. *

*/ + @Override public abstract Message clone(); + @Override public abstract void setUsing7bitTransport() throws MessagingException; } diff --git a/src/com/fsck/k9/mail/MessagingException.java b/src/com/fsck/k9/mail/MessagingException.java index d33014603..bdb24ab42 100644 --- a/src/com/fsck/k9/mail/MessagingException.java +++ b/src/com/fsck/k9/mail/MessagingException.java @@ -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); diff --git a/src/com/fsck/k9/mail/Multipart.java b/src/com/fsck/k9/mail/Multipart.java index d971d18a5..7e397f51f 100644 --- a/src/com/fsck/k9/mail/Multipart.java +++ b/src/com/fsck/k9/mail/Multipart.java @@ -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 mParts = new ArrayList(); - protected String mContentType; + private String mContentType; public void addBodyPart(BodyPart part) { mParts.add(part); diff --git a/src/com/fsck/k9/mail/internet/MimeBodyPart.java b/src/com/fsck/k9/mail/internet/MimeBodyPart.java index 1c031df17..c4bca428a 100644 --- a/src/com/fsck/k9/mail/internet/MimeBodyPart.java +++ b/src/com/fsck/k9/mail/internet/MimeBodyPart.java @@ -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); diff --git a/src/com/fsck/k9/mail/internet/MimeHeader.java b/src/com/fsck/k9/mail/internet/MimeHeader.java index 5175f4ad2..dd6445755 100644 --- a/src/com/fsck/k9/mail/internet/MimeHeader.java +++ b/src/com/fsck/k9/mail/internet/MimeHeader.java @@ -36,7 +36,7 @@ public class MimeHeader { HEADER_ANDROID_ATTACHMENT_STORE_DATA }; - protected ArrayList mFields = new ArrayList(); + private ArrayList mFields = new ArrayList(); 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; diff --git a/src/com/fsck/k9/mail/internet/MimeMessage.java b/src/com/fsck/k9/mail/internet/MimeMessage.java index ce0ea76d6..75fa217d8 100644 --- a/src/com/fsck/k9/mail/internet/MimeMessage.java +++ b/src/com/fsck/k9/mail/internet/MimeMessage.java @@ -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; } diff --git a/src/com/fsck/k9/mail/internet/MimeMultipart.java b/src/com/fsck/k9/mail/internet/MimeMultipart.java index e00d4da3e..a63ebad04 100644 --- a/src/com/fsck/k9/mail/internet/MimeMultipart.java +++ b/src/com/fsck/k9/mail/internet/MimeMultipart.java @@ -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); @@ -96,6 +93,7 @@ public class MimeMultipart extends Multipart { writer.flush(); } + @Override public InputStream getInputStream() throws MessagingException { return null; } diff --git a/src/com/fsck/k9/mail/internet/MimeUtility.java b/src/com/fsck/k9/mail/internet/MimeUtility.java index 19770b171..21dad28c7 100644 --- a/src/com/fsck/k9/mail/internet/MimeUtility.java +++ b/src/com/fsck/k9/mail/internet/MimeUtility.java @@ -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 does not return a text representation of HTML. @@ -1466,7 +1441,7 @@ public class MimeUtility { * @throws MessagingException * In case of an error. */ - public static List getViewables(Part part, List attachments) throws MessagingException { + private static List getViewables(Part part, List attachments) throws MessagingException { List viewables = new ArrayList(); 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)) { diff --git a/src/com/fsck/k9/mail/internet/TextBody.java b/src/com/fsck/k9/mail/internet/TextBody.java index 2d15b9ab8..ad6e474ac 100644 --- a/src/com/fsck/k9/mail/internet/TextBody.java +++ b/src/com/fsck/k9/mail/internet/TextBody.java @@ -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; } diff --git a/src/com/fsck/k9/mail/internet/TextBodyBuilder.java b/src/com/fsck/k9/mail/internet/TextBodyBuilder.java index 96e19e9e9..9627e99e6 100644 --- a/src/com/fsck/k9/mail/internet/TextBodyBuilder.java +++ b/src/com/fsck/k9/mail/internet/TextBodyBuilder.java @@ -204,7 +204,7 @@ public class TextBodyBuilder { return mQuotedTextHtml; } - public String textToHtmlFragment(String text) { + private String textToHtmlFragment(String text) { return HtmlConverter.textToHtmlFragment(text); } diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index c830ce1e8..2dba608ea 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -1302,6 +1302,7 @@ public class ImapStore extends Store { protected long getHighestUid() { try { ImapSearcher searcher = new ImapSearcher() { + @Override public List search() throws IOException, MessagingException { return executeSimpleCommand("UID SEARCH *:*"); } @@ -1351,6 +1352,7 @@ public class ImapStore extends Store { ImapSearcher searcher = new ImapSearcher() { + @Override public List 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 mesgSeqs, final boolean includeDeleted, final MessageRetrievalListener listener) throws MessagingException { ImapSearcher searcher = new ImapSearcher() { + @Override public List 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 mesgUids, final boolean includeDeleted, final MessageRetrievalListener listener) throws MessagingException { ImapSearcher searcher = new ImapSearcher() { + @Override public List 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 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 capabilities = new HashSet(); + private Socket mSocket; + private PeekableInputStream mIn; + private OutputStream mOut; + private ImapResponseParser mParser; + private int mNextCommandTag; + private Set capabilities = new HashSet(); 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 storedUntaggedResponses = new ArrayList(); - 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 storedUntaggedResponses = new ArrayList(); + 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 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; } diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index 2fc4fc5f2..e34354b15 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -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; diff --git a/src/com/fsck/k9/mail/store/StorageManager.java b/src/com/fsck/k9/mail/store/StorageManager.java index 27dd266d1..68cc216df 100644 --- a/src/com/fsck/k9/mail/store/StorageManager.java +++ b/src/com/fsck/k9/mail/store/StorageManager.java @@ -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; } diff --git a/src/com/fsck/k9/mail/store/local/LocalMessage.java b/src/com/fsck/k9/mail/store/local/LocalMessage.java index 8f9dda8d3..f7630a364 100644 --- a/src/com/fsck/k9/mail/store/local/LocalMessage.java +++ b/src/com/fsck/k9/mail/store/local/LocalMessage.java @@ -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; } diff --git a/src/com/fsck/k9/mail/store/local/LocalStore.java b/src/com/fsck/k9/mail/store/local/LocalStore.java index 3442aa988..9119831c1 100644 --- a/src/com/fsck/k9/mail/store/local/LocalStore.java +++ b/src/com/fsck/k9/mail/store/local/LocalStore.java @@ -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() { @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)); diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index 8c6d178b4..eb381bd83 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -33,7 +33,7 @@ public class SmtpTransport extends Transport { /** * Decodes a SmtpTransport URI. - * + * * NOTE: In contrast to ImapStore and Pop3Store, the authType is appended at the end! * *

Possible forms:

@@ -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; From 547eb7477479f2e6a0f61e28da9360c7298b480c Mon Sep 17 00:00:00 2001 From: Tobias Baum Date: Mon, 22 Sep 2014 21:54:02 +0200 Subject: [PATCH 2/3] Changed access to mParts in MimeMultipart so that it can be private too --- src/com/fsck/k9/mail/Multipart.java | 2 +- .../fsck/k9/mail/internet/MimeMultipart.java | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/com/fsck/k9/mail/Multipart.java b/src/com/fsck/k9/mail/Multipart.java index 7e397f51f..88651485a 100644 --- a/src/com/fsck/k9/mail/Multipart.java +++ b/src/com/fsck/k9/mail/Multipart.java @@ -13,7 +13,7 @@ import com.fsck.k9.mail.internet.TextBody; public abstract class Multipart implements CompositeBody { private Part mParent; - protected ArrayList mParts = new ArrayList(); + private final ArrayList mParts = new ArrayList(); private String mContentType; diff --git a/src/com/fsck/k9/mail/internet/MimeMultipart.java b/src/com/fsck/k9/mail/internet/MimeMultipart.java index a63ebad04..124ca5e4c 100644 --- a/src/com/fsck/k9/mail/internet/MimeMultipart.java +++ b/src/com/fsck/k9/mail/internet/MimeMultipart.java @@ -71,20 +71,19 @@ 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); - writer.write("--"); - writer.write(mBoundary); - writer.write("\r\n"); - writer.flush(); - bodyPart.writeTo(out); - writer.write("\r\n"); + } else { + for (BodyPart bodyPart : getBodyParts()) { + writer.write("--"); + writer.write(mBoundary); + writer.write("\r\n"); + writer.flush(); + bodyPart.writeTo(out); + writer.write("\r\n"); + } } writer.write("--"); @@ -100,7 +99,7 @@ public class MimeMultipart extends Multipart { @Override public void setUsing7bitTransport() throws MessagingException { - for (BodyPart part : mParts) { + for (BodyPart part : getBodyParts()) { part.setUsing7bitTransport(); } } From 2be10febf96c65a9899c2e1b1728c437d9d99f67 Mon Sep 17 00:00:00 2001 From: Tobias Baum Date: Mon, 22 Sep 2014 21:55:08 +0200 Subject: [PATCH 3/3] Added (still rather shallow) missing Javadocs for classes in BinaryAttachmentBody hierarchy --- src/com/fsck/k9/mail/store/local/BinaryAttachmentBody.java | 4 ++++ src/com/fsck/k9/mail/store/local/LocalAttachmentBody.java | 3 +++ src/com/fsck/k9/mail/store/local/TempFileBody.java | 3 +++ src/com/fsck/k9/mail/store/local/TempFileMessageBody.java | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/src/com/fsck/k9/mail/store/local/BinaryAttachmentBody.java b/src/com/fsck/k9/mail/store/local/BinaryAttachmentBody.java index c03fceb0d..27eeb243e 100644 --- a/src/com/fsck/k9/mail/store/local/BinaryAttachmentBody.java +++ b/src/com/fsck/k9/mail/store/local/BinaryAttachmentBody.java @@ -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; diff --git a/src/com/fsck/k9/mail/store/local/LocalAttachmentBody.java b/src/com/fsck/k9/mail/store/local/LocalAttachmentBody.java index 34772be95..faea07a6c 100644 --- a/src/com/fsck/k9/mail/store/local/LocalAttachmentBody.java +++ b/src/com/fsck/k9/mail/store/local/LocalAttachmentBody.java @@ -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; diff --git a/src/com/fsck/k9/mail/store/local/TempFileBody.java b/src/com/fsck/k9/mail/store/local/TempFileBody.java index f093998d8..82720521e 100644 --- a/src/com/fsck/k9/mail/store/local/TempFileBody.java +++ b/src/com/fsck/k9/mail/store/local/TempFileBody.java @@ -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; diff --git a/src/com/fsck/k9/mail/store/local/TempFileMessageBody.java b/src/com/fsck/k9/mail/store/local/TempFileMessageBody.java index 82188f485..1fdb03e4b 100644 --- a/src/com/fsck/k9/mail/store/local/TempFileMessageBody.java +++ b/src/com/fsck/k9/mail/store/local/TempFileMessageBody.java @@ -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) {