mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Fix some warnings in ImapStore / Pop3Store / WebDavStore
This commit is contained in:
parent
e214dbbd99
commit
6ed52ac551
@ -506,7 +506,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
* @throws MessagingException uh oh!
|
* @throws MessagingException uh oh!
|
||||||
*/
|
*/
|
||||||
private void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException {
|
private void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException {
|
||||||
String commandResponse = null;
|
String commandResponse;
|
||||||
String commandOptions = "";
|
String commandOptions = "";
|
||||||
|
|
||||||
if (connection.getCapabilities().contains("XLIST")) {
|
if (connection.getCapabilities().contains("XLIST")) {
|
||||||
@ -581,10 +581,6 @@ public class ImapStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a connection if one is available for reuse, or creates a new one if not.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private ImapConnection getConnection() throws MessagingException {
|
private ImapConnection getConnection() throws MessagingException {
|
||||||
synchronized (mConnections) {
|
synchronized (mConnections) {
|
||||||
ImapConnection connection;
|
ImapConnection connection;
|
||||||
@ -669,7 +665,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ImapFolder extends Folder<ImapMessage> {
|
protected class ImapFolder extends Folder<ImapMessage> {
|
||||||
private String mName;
|
private String mName;
|
||||||
protected volatile int mMessageCount = -1;
|
protected volatile int mMessageCount = -1;
|
||||||
protected volatile long uidNext = -1L;
|
protected volatile long uidNext = -1L;
|
||||||
@ -689,7 +685,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
public String getPrefixedName() throws MessagingException {
|
public String getPrefixedName() throws MessagingException {
|
||||||
String prefixedName = "";
|
String prefixedName = "";
|
||||||
if (!mStoreConfig.getInboxFolderName().equalsIgnoreCase(mName)) {
|
if (!mStoreConfig.getInboxFolderName().equalsIgnoreCase(mName)) {
|
||||||
ImapConnection connection = null;
|
ImapConnection connection;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mConnection == null) {
|
if (mConnection == null) {
|
||||||
connection = getConnection();
|
connection = getConnection();
|
||||||
@ -737,10 +733,9 @@ public class ImapStore extends RemoteStore {
|
|||||||
// Make sure the connection is valid. If it's not we'll close it down and continue
|
// Make sure the connection is valid. If it's not we'll close it down and continue
|
||||||
// on to get a new one.
|
// on to get a new one.
|
||||||
try {
|
try {
|
||||||
List<ImapResponse> responses = executeSimpleCommand("NOOP");
|
return executeSimpleCommand("NOOP");
|
||||||
return responses;
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioExceptionHandler(mConnection, ioe);
|
/* don't throw */ ioExceptionHandler(mConnection, ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
releaseConnection(mConnection);
|
releaseConnection(mConnection);
|
||||||
@ -909,7 +904,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
* so we must get the connection ourselves if it's not there. We are specifically
|
* so we must get the connection ourselves if it's not there. We are specifically
|
||||||
* not calling checkOpen() since we don't care if the folder is open.
|
* not calling checkOpen() since we don't care if the folder is open.
|
||||||
*/
|
*/
|
||||||
ImapConnection connection = null;
|
ImapConnection connection;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mConnection == null) {
|
if (mConnection == null) {
|
||||||
connection = getConnection();
|
connection = getConnection();
|
||||||
@ -941,7 +936,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
* so we must get the connection ourselves if it's not there. We are specifically
|
* so we must get the connection ourselves if it's not there. We are specifically
|
||||||
* not calling checkOpen() since we don't care if the folder is open.
|
* not calling checkOpen() since we don't care if the folder is open.
|
||||||
*/
|
*/
|
||||||
ImapConnection connection = null;
|
ImapConnection connection;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mConnection == null) {
|
if (mConnection == null) {
|
||||||
connection = getConnection();
|
connection = getConnection();
|
||||||
@ -1191,12 +1186,12 @@ public class ImapStore extends RemoteStore {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ImapMessage> getMessages(int start, int end, Date earliestDate, MessageRetrievalListener listener)
|
public List<ImapMessage> getMessages(int start, int end, Date earliestDate, MessageRetrievalListener<ImapMessage> listener)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
return getMessages(start, end, earliestDate, false, listener);
|
return getMessages(start, end, earliestDate, false, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<ImapMessage> getMessages(final int start, final int end, Date earliestDate, final boolean includeDeleted, final MessageRetrievalListener listener)
|
protected List<ImapMessage> getMessages(final int start, final int end, Date earliestDate, final boolean includeDeleted, final MessageRetrievalListener<ImapMessage> listener)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
if (start < 1 || end < 1 || end < start) {
|
if (start < 1 || end < 1 || end < start) {
|
||||||
throw new MessagingException(
|
throw new MessagingException(
|
||||||
@ -1223,7 +1218,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
protected List<ImapMessage> getMessages(final List<Long> mesgSeqs,
|
protected List<ImapMessage> getMessages(final List<Long> mesgSeqs,
|
||||||
final boolean includeDeleted,
|
final boolean includeDeleted,
|
||||||
final MessageRetrievalListener listener)
|
final MessageRetrievalListener<ImapMessage> listener)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
ImapSearcher searcher = new ImapSearcher() {
|
ImapSearcher searcher = new ImapSearcher() {
|
||||||
@Override
|
@Override
|
||||||
@ -1236,7 +1231,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
|
|
||||||
protected List<? extends Message> getMessagesFromUids(final List<String> mesgUids,
|
protected List<? extends Message> getMessagesFromUids(final List<String> mesgUids,
|
||||||
final boolean includeDeleted,
|
final boolean includeDeleted,
|
||||||
final MessageRetrievalListener listener) throws MessagingException {
|
final MessageRetrievalListener<ImapMessage> listener) throws MessagingException {
|
||||||
ImapSearcher searcher = new ImapSearcher() {
|
ImapSearcher searcher = new ImapSearcher() {
|
||||||
@Override
|
@Override
|
||||||
public List<ImapResponse> search() throws IOException, MessagingException {
|
public List<ImapResponse> search() throws IOException, MessagingException {
|
||||||
@ -1606,7 +1601,6 @@ public class ImapStore extends RemoteStore {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle any untagged responses that the caller doesn't care to handle themselves.
|
* Handle any untagged responses that the caller doesn't care to handle themselves.
|
||||||
* @param responses
|
|
||||||
*/
|
*/
|
||||||
protected List<ImapResponse> handleUntaggedResponses(List<ImapResponse> responses) {
|
protected List<ImapResponse> handleUntaggedResponses(List<ImapResponse> responses) {
|
||||||
for (ImapResponse response : responses) {
|
for (ImapResponse response : responses) {
|
||||||
@ -1640,7 +1634,6 @@ public class ImapStore extends RemoteStore {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an untagged response that the caller doesn't care to handle themselves.
|
* Handle an untagged response that the caller doesn't care to handle themselves.
|
||||||
* @param response
|
|
||||||
*/
|
*/
|
||||||
protected void handleUntaggedResponse(ImapResponse response) {
|
protected void handleUntaggedResponse(ImapResponse response) {
|
||||||
if (response.getTag() == null && response.size() > 1) {
|
if (response.getTag() == null && response.size() > 1) {
|
||||||
@ -2205,7 +2198,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ImapMessage extends MimeMessage {
|
protected static class ImapMessage extends MimeMessage {
|
||||||
ImapMessage(String uid, Folder folder) {
|
ImapMessage(String uid, Folder folder) {
|
||||||
this.mUid = uid;
|
this.mUid = uid;
|
||||||
this.mFolder = folder;
|
this.mFolder = folder;
|
||||||
@ -2232,7 +2225,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ImapFolderPusher extends ImapFolder implements UntaggedHandler {
|
protected class ImapFolderPusher extends ImapFolder implements UntaggedHandler {
|
||||||
private final PushReceiver receiver;
|
private final PushReceiver receiver;
|
||||||
private Thread listeningThread = null;
|
private Thread listeningThread = null;
|
||||||
private final AtomicBoolean stop = new AtomicBoolean(false);
|
private final AtomicBoolean stop = new AtomicBoolean(false);
|
||||||
@ -2395,7 +2388,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
doneSent.set(false);
|
doneSent.set(false);
|
||||||
|
|
||||||
conn.setReadTimeout((mStoreConfig.getIdleRefreshMinutes() * 60 * 1000) + IDLE_READ_TIMEOUT_INCREMENT);
|
conn.setReadTimeout((mStoreConfig.getIdleRefreshMinutes() * 60 * 1000) + IDLE_READ_TIMEOUT_INCREMENT);
|
||||||
untaggedResponses = executeSimpleCommand(ImapCommands.COMMAND_IDLE, false, ImapFolderPusher.this);
|
executeSimpleCommand(ImapCommands.COMMAND_IDLE, false, ImapFolderPusher.this);
|
||||||
idling.set(false);
|
idling.set(false);
|
||||||
delayTime.set(NORMAL_DELAY_TIME);
|
delayTime.set(NORMAL_DELAY_TIME);
|
||||||
idleFailureCount.set(0);
|
idleFailureCount.set(0);
|
||||||
|
@ -747,12 +747,12 @@ public class Pop3Store extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Message> getMessages(MessageRetrievalListener listener) throws MessagingException {
|
public List<Pop3Message> getMessages(MessageRetrievalListener listener) throws MessagingException {
|
||||||
throw new UnsupportedOperationException("Pop3: No getMessages");
|
throw new UnsupportedOperationException("Pop3: No getMessages");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Message> getMessages(String[] uids, MessageRetrievalListener listener)
|
public List<Pop3Message> getMessages(String[] uids, MessageRetrievalListener listener)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
throw new UnsupportedOperationException("Pop3: No getMessages by uids");
|
throw new UnsupportedOperationException("Pop3: No getMessages by uids");
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
*
|
*
|
||||||
* @return A WebDavStore URI that holds the same information as the {@code server} parameter.
|
* @return A WebDavStore URI that holds the same information as the {@code server} parameter.
|
||||||
*
|
*
|
||||||
* @see Account#getStoreUri()
|
* @see StoreConfig#getStoreUri()
|
||||||
* @see WebDavStore#decodeUri(String)
|
* @see WebDavStore#decodeUri(String)
|
||||||
*/
|
*/
|
||||||
public static String createUri(ServerSettings server) {
|
public static String createUri(ServerSettings server) {
|
||||||
@ -374,10 +374,9 @@ public class WebDavStore extends RemoteStore {
|
|||||||
* and setup the account accordingly
|
* and setup the account accordingly
|
||||||
*/
|
*/
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
DataSet dataset = new DataSet();
|
|
||||||
headers.put("Depth", "0");
|
headers.put("Depth", "0");
|
||||||
headers.put("Brief", "t");
|
headers.put("Brief", "t");
|
||||||
dataset = processRequest(this.mUrl, "PROPFIND", getSpecialFoldersList(), headers);
|
DataSet dataset = processRequest(this.mUrl, "PROPFIND", getSpecialFoldersList(), headers);
|
||||||
|
|
||||||
Map<String, String> specialFoldersMap = dataset.getSpecialFolderToUrl();
|
Map<String, String> specialFoldersMap = dataset.getSpecialFolderToUrl();
|
||||||
String folderName = getFolderName(specialFoldersMap.get(DAV_MAIL_INBOX_FOLDER));
|
String folderName = getFolderName(specialFoldersMap.get(DAV_MAIL_INBOX_FOLDER));
|
||||||
@ -413,7 +412,6 @@ public class WebDavStore extends RemoteStore {
|
|||||||
* Next we get all the folders (including "special" ones)
|
* Next we get all the folders (including "special" ones)
|
||||||
*/
|
*/
|
||||||
headers = new HashMap<String, String>();
|
headers = new HashMap<String, String>();
|
||||||
dataset = new DataSet();
|
|
||||||
headers.put("Brief", "t");
|
headers.put("Brief", "t");
|
||||||
dataset = processRequest(this.mUrl, "SEARCH", getFolderListXml(), headers);
|
dataset = processRequest(this.mUrl, "SEARCH", getFolderListXml(), headers);
|
||||||
String[] folderUrls = dataset.getHrefs();
|
String[] folderUrls = dataset.getHrefs();
|
||||||
@ -512,50 +510,50 @@ public class WebDavStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getSpecialFoldersList() {
|
private String getSpecialFoldersList() {
|
||||||
StringBuilder buffer = new StringBuilder(200);
|
StringBuilder builder = new StringBuilder(200);
|
||||||
buffer.append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
|
builder.append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
|
||||||
buffer.append("<propfind xmlns=\"DAV:\">");
|
builder.append("<propfind xmlns=\"DAV:\">");
|
||||||
buffer.append("<prop>");
|
builder.append("<prop>");
|
||||||
buffer.append("<").append(DAV_MAIL_INBOX_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
builder.append("<").append(DAV_MAIL_INBOX_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
||||||
buffer.append("<").append(DAV_MAIL_DRAFTS_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
builder.append("<").append(DAV_MAIL_DRAFTS_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
||||||
buffer.append("<").append(DAV_MAIL_OUTBOX_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
builder.append("<").append(DAV_MAIL_OUTBOX_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
||||||
buffer.append("<").append(DAV_MAIL_SENT_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
builder.append("<").append(DAV_MAIL_SENT_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
||||||
buffer.append("<").append(DAV_MAIL_TRASH_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
builder.append("<").append(DAV_MAIL_TRASH_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
||||||
// This should always be ##DavMailSubmissionURI## for which we already have a constant
|
// This should always be ##DavMailSubmissionURI## for which we already have a constant
|
||||||
// buffer.append("<sendmsg xmlns=\"urn:schemas:httpmail:\"/>");
|
// buffer.append("<sendmsg xmlns=\"urn:schemas:httpmail:\"/>");
|
||||||
|
|
||||||
buffer.append("<").append(DAV_MAIL_SPAM_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
builder.append("<").append(DAV_MAIL_SPAM_FOLDER).append(" xmlns=\"urn:schemas:httpmail:\"/>");
|
||||||
|
|
||||||
buffer.append("</prop>");
|
builder.append("</prop>");
|
||||||
buffer.append("</propfind>");
|
builder.append("</propfind>");
|
||||||
return buffer.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
* WebDAV XML Request body retrieval functions
|
* WebDAV XML Request body retrieval functions
|
||||||
*/
|
*/
|
||||||
private String getFolderListXml() {
|
private String getFolderListXml() {
|
||||||
StringBuilder buffer = new StringBuilder(200);
|
StringBuilder builder = new StringBuilder(200);
|
||||||
buffer.append("<?xml version='1.0' ?>");
|
builder.append("<?xml version='1.0' ?>");
|
||||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
builder.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||||
buffer.append("SELECT \"DAV:uid\", \"DAV:ishidden\"\r\n");
|
builder.append("SELECT \"DAV:uid\", \"DAV:ishidden\"\r\n");
|
||||||
buffer.append(" FROM SCOPE('hierarchical traversal of \"").append(this.mUrl).append("\"')\r\n");
|
builder.append(" FROM SCOPE('hierarchical traversal of \"").append(this.mUrl).append("\"')\r\n");
|
||||||
buffer.append(" WHERE \"DAV:ishidden\"=False AND \"DAV:isfolder\"=True\r\n");
|
builder.append(" WHERE \"DAV:ishidden\"=False AND \"DAV:isfolder\"=True\r\n");
|
||||||
buffer.append("</a:sql></a:searchrequest>\r\n");
|
builder.append("</a:sql></a:searchrequest>\r\n");
|
||||||
return buffer.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMessageCountXml(String messageState) {
|
private String getMessageCountXml(String messageState) {
|
||||||
StringBuilder buffer = new StringBuilder(200);
|
StringBuilder builder = new StringBuilder(200);
|
||||||
buffer.append("<?xml version='1.0' ?>");
|
builder.append("<?xml version='1.0' ?>");
|
||||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
builder.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||||
buffer.append("SELECT \"DAV:visiblecount\"\r\n");
|
builder.append("SELECT \"DAV:visiblecount\"\r\n");
|
||||||
buffer.append(" FROM \"\"\r\n");
|
builder.append(" FROM \"\"\r\n");
|
||||||
buffer.append(" WHERE \"DAV:ishidden\"=False AND \"DAV:isfolder\"=False AND \"urn:schemas:httpmail:read\"=")
|
builder.append(" WHERE \"DAV:ishidden\"=False AND \"DAV:isfolder\"=False AND \"urn:schemas:httpmail:read\"=")
|
||||||
.append(messageState).append("\r\n");
|
.append(messageState).append("\r\n");
|
||||||
buffer.append(" GROUP BY \"DAV:ishidden\"\r\n");
|
builder.append(" GROUP BY \"DAV:ishidden\"\r\n");
|
||||||
buffer.append("</a:sql></a:searchrequest>\r\n");
|
builder.append("</a:sql></a:searchrequest>\r\n");
|
||||||
return buffer.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMessageEnvelopeXml(String[] uids) {
|
private String getMessageEnvelopeXml(String[] uids) {
|
||||||
@ -589,14 +587,14 @@ public class WebDavStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getMessagesXml() {
|
private String getMessagesXml() {
|
||||||
StringBuilder buffer = new StringBuilder(200);
|
StringBuilder builder = new StringBuilder(200);
|
||||||
buffer.append("<?xml version='1.0' ?>");
|
builder.append("<?xml version='1.0' ?>");
|
||||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
builder.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||||
buffer.append("SELECT \"DAV:uid\"\r\n");
|
builder.append("SELECT \"DAV:uid\"\r\n");
|
||||||
buffer.append(" FROM \"\"\r\n");
|
builder.append(" FROM \"\"\r\n");
|
||||||
buffer.append(" WHERE \"DAV:ishidden\"=False AND \"DAV:isfolder\"=False\r\n");
|
builder.append(" WHERE \"DAV:ishidden\"=False AND \"DAV:isfolder\"=False\r\n");
|
||||||
buffer.append("</a:sql></a:searchrequest>\r\n");
|
builder.append("</a:sql></a:searchrequest>\r\n");
|
||||||
return buffer.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMessageUrlsXml(String[] uids) {
|
private String getMessageUrlsXml(String[] uids) {
|
||||||
@ -926,7 +924,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
// Read line by line until we find something like: <form action="owaauth.dll"...>.
|
// Read line by line until we find something like: <form action="owaauth.dll"...>.
|
||||||
while ((tempText = reader.readLine()) != null &&
|
while ((tempText = reader.readLine()) != null &&
|
||||||
formAction == null) {
|
formAction == null) {
|
||||||
if (tempText.indexOf(" action=") > -1) {
|
if (tempText.contains(" action=")) {
|
||||||
String[] actionParts = tempText.split(" action=");
|
String[] actionParts = tempText.split(" action=");
|
||||||
if (actionParts.length > 1 && actionParts[1].length() > 1) {
|
if (actionParts.length > 1 && actionParts[1].length() > 1) {
|
||||||
char openQuote = actionParts[1].charAt(0);
|
char openQuote = actionParts[1].charAt(0);
|
||||||
@ -1039,27 +1037,25 @@ public class WebDavStore extends RemoteStore {
|
|||||||
private InputStream sendRequest(String url, String method, StringEntity messageBody,
|
private InputStream sendRequest(String url, String method, StringEntity messageBody,
|
||||||
Map<String, String> headers, boolean tryAuth)
|
Map<String, String> headers, boolean tryAuth)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
InputStream istream = null;
|
|
||||||
|
|
||||||
if (url == null || method == null) {
|
if (url == null || method == null) {
|
||||||
return istream;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebDavHttpClient httpclient = getHttpClient();
|
WebDavHttpClient httpClient = getHttpClient();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int statusCode = -1;
|
int statusCode;
|
||||||
HttpGeneric httpmethod = new HttpGeneric(url);
|
HttpGeneric httpMethod = new HttpGeneric(url);
|
||||||
HttpResponse response;
|
HttpResponse response;
|
||||||
HttpEntity entity;
|
HttpEntity entity;
|
||||||
|
|
||||||
if (messageBody != null) {
|
if (messageBody != null) {
|
||||||
httpmethod.setEntity(messageBody);
|
httpMethod.setEntity(messageBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headers != null) {
|
if (headers != null) {
|
||||||
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||||
httpmethod.setHeader(entry.getKey(), entry.getValue());
|
httpMethod.setHeader(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1068,11 +1064,11 @@ public class WebDavStore extends RemoteStore {
|
|||||||
throw new MessagingException("Unable to authenticate in sendRequest().");
|
throw new MessagingException("Unable to authenticate in sendRequest().");
|
||||||
}
|
}
|
||||||
} else if (mAuthentication == AUTH_TYPE_BASIC) {
|
} else if (mAuthentication == AUTH_TYPE_BASIC) {
|
||||||
httpmethod.setHeader("Authorization", mAuthString);
|
httpMethod.setHeader("Authorization", mAuthString);
|
||||||
}
|
}
|
||||||
|
|
||||||
httpmethod.setMethod(method);
|
httpMethod.setMethod(method);
|
||||||
response = httpclient.executeOverride(httpmethod, mContext);
|
response = httpClient.executeOverride(httpMethod, mContext);
|
||||||
statusCode = response.getStatusLine().getStatusCode();
|
statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
|
||||||
entity = response.getEntity();
|
entity = response.getEntity();
|
||||||
@ -1093,7 +1089,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
istream = WebDavHttpClient.getUngzippedContent(entity);
|
return WebDavHttpClient.getUngzippedContent(entity);
|
||||||
}
|
}
|
||||||
} catch (UnsupportedEncodingException uee) {
|
} catch (UnsupportedEncodingException uee) {
|
||||||
Log.e(LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + processException(uee));
|
Log.e(LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + processException(uee));
|
||||||
@ -1103,7 +1099,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
throw new MessagingException("IOException", ioe);
|
throw new MessagingException("IOException", ioe);
|
||||||
}
|
}
|
||||||
|
|
||||||
return istream;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthString() {
|
public String getAuthString() {
|
||||||
@ -1235,7 +1231,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
store = nStore;
|
store = nStore;
|
||||||
this.mName = name;
|
this.mName = name;
|
||||||
|
|
||||||
String encodedName = "";
|
String encodedName;
|
||||||
String[] urlParts = name.split("/");
|
String[] urlParts = name.split("/");
|
||||||
String url = "";
|
String url = "";
|
||||||
for (int i = 0, count = urlParts.length; i < count; i++) {
|
for (int i = 0, count = urlParts.length; i < count; i++) {
|
||||||
@ -1293,7 +1289,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
for (int i = 0, count = messages.size(); i < count; i++) {
|
for (int i = 0, count = messages.size(); i < count; i++) {
|
||||||
uids[i] = messages.get(i).getUid();
|
uids[i] = messages.get(i).getUid();
|
||||||
}
|
}
|
||||||
String messageBody = "";
|
String messageBody;
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
Map<String, String> uidToUrl = getMessageUrls(uids);
|
Map<String, String> uidToUrl = getMessageUrls(uids);
|
||||||
String[] urls = new String[uids.length];
|
String[] urls = new String[uids.length];
|
||||||
@ -1404,12 +1400,12 @@ public class WebDavStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Message> getMessages(int start, int end, Date earliestDate, MessageRetrievalListener listener)
|
public List<WebDavMessage> getMessages(int start, int end, Date earliestDate, MessageRetrievalListener<WebDavMessage> listener)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
List<Message> messages = new ArrayList<Message>();
|
List<WebDavMessage> messages = new ArrayList<WebDavMessage>();
|
||||||
String[] uids;
|
String[] uids;
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
int uidsLength = -1;
|
int uidsLength;
|
||||||
|
|
||||||
String messageBody;
|
String messageBody;
|
||||||
int prevStart = start;
|
int prevStart = start;
|
||||||
@ -1454,7 +1450,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Message> getMessages(MessageRetrievalListener listener) throws MessagingException {
|
public List<WebDavMessage> getMessages(MessageRetrievalListener<WebDavMessage> listener) throws MessagingException {
|
||||||
return getMessages(null, listener);
|
return getMessages(null, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1645,9 +1641,9 @@ public class WebDavStore extends RemoteStore {
|
|||||||
* Fetches and sets the message flags for the supplied messages. The idea is to have this be recursive so that
|
* Fetches and sets the message flags for the supplied messages. The idea is to have this be recursive so that
|
||||||
* we do a series of medium calls instead of one large massive call or a large number of smaller calls.
|
* we do a series of medium calls instead of one large massive call or a large number of smaller calls.
|
||||||
*/
|
*/
|
||||||
private void fetchFlags(List<? extends Message> startMessages, MessageRetrievalListener listener) throws MessagingException {
|
private void fetchFlags(List<WebDavMessage> startMessages, MessageRetrievalListener<WebDavMessage> listener) throws MessagingException {
|
||||||
HashMap<String, String> headers = new HashMap<String, String>();
|
HashMap<String, String> headers = new HashMap<String, String>();
|
||||||
String messageBody = "";
|
String messageBody;
|
||||||
List<Message> messages = new ArrayList<Message>(20);
|
List<Message> messages = new ArrayList<Message>(20);
|
||||||
String[] uids;
|
String[] uids;
|
||||||
|
|
||||||
@ -1657,7 +1653,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (startMessages.size() > 20) {
|
if (startMessages.size() > 20) {
|
||||||
List<Message> newMessages = new ArrayList<Message>(startMessages.size() - 20);
|
List<WebDavMessage> newMessages = new ArrayList<WebDavMessage>(startMessages.size() - 20);
|
||||||
for (int i = 0, count = startMessages.size(); i < count; i++) {
|
for (int i = 0, count = startMessages.size(); i < count; i++) {
|
||||||
if (i < 20) {
|
if (i < 20) {
|
||||||
messages.set(i, startMessages.get(i));
|
messages.set(i, startMessages.get(i));
|
||||||
@ -1717,7 +1713,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
private void fetchEnvelope(List<WebDavMessage> startMessages, MessageRetrievalListener<WebDavMessage> listener)
|
private void fetchEnvelope(List<WebDavMessage> startMessages, MessageRetrievalListener<WebDavMessage> listener)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
String messageBody = "";
|
String messageBody;
|
||||||
String[] uids;
|
String[] uids;
|
||||||
List<WebDavMessage> messages = new ArrayList<WebDavMessage>(10);
|
List<WebDavMessage> messages = new ArrayList<WebDavMessage>(10);
|
||||||
|
|
||||||
@ -2426,7 +2422,7 @@ public class WebDavStore extends RemoteStore {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
InputStream responseStream = entity.getContent();
|
InputStream responseStream = entity.getContent();
|
||||||
if (responseStream == null)
|
if (responseStream == null)
|
||||||
return responseStream;
|
return null;
|
||||||
Header header = entity.getContentEncoding();
|
Header header = entity.getContentEncoding();
|
||||||
if (header == null)
|
if (header == null)
|
||||||
return responseStream;
|
return responseStream;
|
||||||
|
Loading…
Reference in New Issue
Block a user