Get rid of common base class RemoteStore
This also allows removing some unnecessary methods in former subclasses.
This commit is contained in:
parent
2afacbc498
commit
9335080545
9 changed files with 38 additions and 150 deletions
|
@ -0,0 +1,6 @@
|
||||||
|
package com.fsck.k9.mail
|
||||||
|
|
||||||
|
object NetworkTimeouts {
|
||||||
|
const val SOCKET_CONNECT_TIMEOUT = 30000
|
||||||
|
const val SOCKET_READ_TIMEOUT = 60000
|
||||||
|
}
|
|
@ -1,52 +0,0 @@
|
||||||
package com.fsck.k9.mail.store;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.fsck.k9.mail.Folder;
|
|
||||||
import com.fsck.k9.mail.Message;
|
|
||||||
import com.fsck.k9.mail.MessagingException;
|
|
||||||
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class RemoteStore {
|
|
||||||
public static final int SOCKET_CONNECT_TIMEOUT = 30000;
|
|
||||||
public static final int SOCKET_READ_TIMEOUT = 60000;
|
|
||||||
|
|
||||||
protected StoreConfig mStoreConfig;
|
|
||||||
protected TrustedSocketFactory mTrustedSocketFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public RemoteStore(StoreConfig storeConfig, TrustedSocketFactory trustedSocketFactory) {
|
|
||||||
mStoreConfig = storeConfig;
|
|
||||||
mTrustedSocketFactory = trustedSocketFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Folder<? extends Message> getFolder(String name);
|
|
||||||
|
|
||||||
public abstract List<? extends Folder > getPersonalNamespaces() throws MessagingException;
|
|
||||||
|
|
||||||
public abstract void checkSettings() throws MessagingException;
|
|
||||||
|
|
||||||
public boolean isCopyCapable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMoveCapable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPushCapable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExpungeCapable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSeenFlagSupported() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessages(List<? extends Message> messages) throws MessagingException { }
|
|
||||||
}
|
|
|
@ -51,8 +51,8 @@ import timber.log.Timber;
|
||||||
|
|
||||||
import static com.fsck.k9.mail.ConnectionSecurity.STARTTLS_REQUIRED;
|
import static com.fsck.k9.mail.ConnectionSecurity.STARTTLS_REQUIRED;
|
||||||
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP;
|
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP;
|
||||||
import static com.fsck.k9.mail.store.RemoteStore.SOCKET_CONNECT_TIMEOUT;
|
import static com.fsck.k9.mail.NetworkTimeouts.SOCKET_CONNECT_TIMEOUT;
|
||||||
import static com.fsck.k9.mail.store.RemoteStore.SOCKET_READ_TIMEOUT;
|
import static com.fsck.k9.mail.NetworkTimeouts.SOCKET_READ_TIMEOUT;
|
||||||
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;
|
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@ import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.PushReceiver;
|
import com.fsck.k9.mail.PushReceiver;
|
||||||
import com.fsck.k9.mail.power.PowerManager;
|
import com.fsck.k9.mail.power.PowerManager;
|
||||||
import com.fsck.k9.mail.power.WakeLock;
|
import com.fsck.k9.mail.power.WakeLock;
|
||||||
import com.fsck.k9.mail.store.RemoteStore;
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static com.fsck.k9.mail.K9MailLib.PUSH_WAKE_LOCK_TIMEOUT;
|
import static com.fsck.k9.mail.K9MailLib.PUSH_WAKE_LOCK_TIMEOUT;
|
||||||
|
import static com.fsck.k9.mail.NetworkTimeouts.SOCKET_READ_TIMEOUT;
|
||||||
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;
|
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;
|
||||||
|
|
||||||
|
|
||||||
|
@ -718,7 +718,7 @@ class ImapFolderPusher extends ImapFolder {
|
||||||
|
|
||||||
private void sendDone() {
|
private void sendDone() {
|
||||||
try {
|
try {
|
||||||
imapConnection.setReadTimeout(RemoteStore.SOCKET_READ_TIMEOUT);
|
imapConnection.setReadTimeout(SOCKET_READ_TIMEOUT);
|
||||||
imapConnection.sendContinuation("DONE");
|
imapConnection.sendContinuation("DONE");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
imapConnection.close();
|
imapConnection.close();
|
||||||
|
|
|
@ -24,7 +24,6 @@ import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.NetworkType;
|
import com.fsck.k9.mail.NetworkType;
|
||||||
import com.fsck.k9.mail.oauth.OAuth2TokenProvider;
|
import com.fsck.k9.mail.oauth.OAuth2TokenProvider;
|
||||||
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
||||||
import com.fsck.k9.mail.store.RemoteStore;
|
|
||||||
import com.fsck.k9.mail.store.StoreConfig;
|
import com.fsck.k9.mail.store.StoreConfig;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
@ -35,7 +34,9 @@ import timber.log.Timber;
|
||||||
* TODO Need a default response handler for things like folder updates
|
* TODO Need a default response handler for things like folder updates
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class ImapStore extends RemoteStore {
|
public class ImapStore {
|
||||||
|
private final StoreConfig storeConfig;
|
||||||
|
private final TrustedSocketFactory trustedSocketFactory;
|
||||||
private Set<Flag> permanentFlagsIndex = EnumSet.noneOf(Flag.class);
|
private Set<Flag> permanentFlagsIndex = EnumSet.noneOf(Flag.class);
|
||||||
private ConnectivityManager connectivityManager;
|
private ConnectivityManager connectivityManager;
|
||||||
private OAuth2TokenProvider oauthTokenProvider;
|
private OAuth2TokenProvider oauthTokenProvider;
|
||||||
|
@ -65,7 +66,8 @@ public class ImapStore extends RemoteStore {
|
||||||
public ImapStore(ImapStoreSettings serverSettings, StoreConfig storeConfig,
|
public ImapStore(ImapStoreSettings serverSettings, StoreConfig storeConfig,
|
||||||
TrustedSocketFactory trustedSocketFactory, ConnectivityManager connectivityManager,
|
TrustedSocketFactory trustedSocketFactory, ConnectivityManager connectivityManager,
|
||||||
OAuth2TokenProvider oauthTokenProvider) {
|
OAuth2TokenProvider oauthTokenProvider) {
|
||||||
super(storeConfig, trustedSocketFactory);
|
this.storeConfig = storeConfig;
|
||||||
|
this.trustedSocketFactory = trustedSocketFactory;
|
||||||
|
|
||||||
host = serverSettings.host;
|
host = serverSettings.host;
|
||||||
port = serverSettings.port;
|
port = serverSettings.port;
|
||||||
|
@ -85,7 +87,6 @@ public class ImapStore extends RemoteStore {
|
||||||
folderNameCodec = FolderNameCodec.newInstance();
|
folderNameCodec = FolderNameCodec.newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ImapFolder getFolder(String name) {
|
public ImapFolder getFolder(String name) {
|
||||||
ImapFolder folder;
|
ImapFolder folder;
|
||||||
synchronized (folderCache) {
|
synchronized (folderCache) {
|
||||||
|
@ -119,14 +120,13 @@ public class ImapStore extends RemoteStore {
|
||||||
return combinedPrefix;
|
return combinedPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ImapFolder> getPersonalNamespaces() throws MessagingException {
|
public List<ImapFolder> getPersonalNamespaces() throws MessagingException {
|
||||||
ImapConnection connection = getConnection();
|
ImapConnection connection = getConnection();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<FolderListItem> folders = listFolders(connection, false);
|
List<FolderListItem> folders = listFolders(connection, false);
|
||||||
|
|
||||||
if (!mStoreConfig.isSubscribedFoldersOnly()) {
|
if (!storeConfig.isSubscribedFoldersOnly()) {
|
||||||
return getFolders(folders);
|
return getFolders(folders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ public class ImapStore extends RemoteStore {
|
||||||
|
|
||||||
if (ImapFolder.INBOX.equalsIgnoreCase(folder)) {
|
if (ImapFolder.INBOX.equalsIgnoreCase(folder)) {
|
||||||
continue;
|
continue;
|
||||||
} else if (folder.equals(mStoreConfig.getOutboxFolder())) {
|
} else if (folder.equals(storeConfig.getOutboxFolder())) {
|
||||||
/*
|
/*
|
||||||
* There is a folder on the server with the same name as our local
|
* There is a folder on the server with the same name as our local
|
||||||
* outbox. Until we have a good plan to deal with this situation
|
* outbox. Until we have a good plan to deal with this situation
|
||||||
|
@ -265,7 +265,6 @@ public class ImapStore extends RemoteStore {
|
||||||
return folderName.substring(prefixLength);
|
return folderName.substring(prefixLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkSettings() throws MessagingException {
|
public void checkSettings() throws MessagingException {
|
||||||
try {
|
try {
|
||||||
ImapConnection connection = createImapConnection();
|
ImapConnection connection = createImapConnection();
|
||||||
|
@ -312,7 +311,7 @@ public class ImapStore extends RemoteStore {
|
||||||
ImapConnection createImapConnection() {
|
ImapConnection createImapConnection() {
|
||||||
return new ImapConnection(
|
return new ImapConnection(
|
||||||
new StoreImapSettings(),
|
new StoreImapSettings(),
|
||||||
mTrustedSocketFactory,
|
trustedSocketFactory,
|
||||||
connectivityManager,
|
connectivityManager,
|
||||||
oauthTokenProvider);
|
oauthTokenProvider);
|
||||||
}
|
}
|
||||||
|
@ -333,28 +332,8 @@ public class ImapStore extends RemoteStore {
|
||||||
return imapFolders;
|
return imapFolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMoveCapable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCopyCapable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPushCapable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isExpungeCapable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
StoreConfig getStoreConfig() {
|
StoreConfig getStoreConfig() {
|
||||||
return mStoreConfig;
|
return storeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Flag> getPermanentFlagsIndex() {
|
Set<Flag> getPermanentFlagsIndex() {
|
||||||
|
@ -400,7 +379,7 @@ public class ImapStore extends RemoteStore {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useCompression(final NetworkType type) {
|
public boolean useCompression(final NetworkType type) {
|
||||||
return mStoreConfig.useCompression(type);
|
return storeConfig.useCompression(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,12 +27,13 @@ import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.filter.Base64;
|
import com.fsck.k9.mail.filter.Base64;
|
||||||
import com.fsck.k9.mail.filter.Hex;
|
import com.fsck.k9.mail.filter.Hex;
|
||||||
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
||||||
import com.fsck.k9.mail.store.RemoteStore;
|
|
||||||
import javax.net.ssl.SSLException;
|
import javax.net.ssl.SSLException;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static com.fsck.k9.mail.CertificateValidationException.Reason.MissingCapability;
|
import static com.fsck.k9.mail.CertificateValidationException.Reason.MissingCapability;
|
||||||
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_POP3;
|
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_POP3;
|
||||||
|
import static com.fsck.k9.mail.NetworkTimeouts.SOCKET_CONNECT_TIMEOUT;
|
||||||
|
import static com.fsck.k9.mail.NetworkTimeouts.SOCKET_READ_TIMEOUT;
|
||||||
import static com.fsck.k9.mail.store.pop3.Pop3Commands.*;
|
import static com.fsck.k9.mail.store.pop3.Pop3Commands.*;
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,11 +69,11 @@ class Pop3Connection {
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.connect(socketAddress, RemoteStore.SOCKET_CONNECT_TIMEOUT);
|
socket.connect(socketAddress, SOCKET_CONNECT_TIMEOUT);
|
||||||
in = new BufferedInputStream(socket.getInputStream(), 1024);
|
in = new BufferedInputStream(socket.getInputStream(), 1024);
|
||||||
out = new BufferedOutputStream(socket.getOutputStream(), 512);
|
out = new BufferedOutputStream(socket.getOutputStream(), 512);
|
||||||
|
|
||||||
socket.setSoTimeout(RemoteStore.SOCKET_READ_TIMEOUT);
|
socket.setSoTimeout(SOCKET_READ_TIMEOUT);
|
||||||
|
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
throw new MessagingException("Unable to connect socket");
|
throw new MessagingException("Unable to connect socket");
|
||||||
|
@ -118,7 +119,7 @@ class Pop3Connection {
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
clientCertificateAlias);
|
clientCertificateAlias);
|
||||||
socket.setSoTimeout(RemoteStore.SOCKET_READ_TIMEOUT);
|
socket.setSoTimeout(SOCKET_READ_TIMEOUT);
|
||||||
in = new BufferedInputStream(socket.getInputStream(), 1024);
|
in = new BufferedInputStream(socket.getInputStream(), 1024);
|
||||||
out = new BufferedOutputStream(socket.getOutputStream(), 512);
|
out = new BufferedOutputStream(socket.getOutputStream(), 512);
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.fsck.k9.mail.store.pop3;
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -14,11 +12,12 @@ import com.fsck.k9.mail.Folder;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.ServerSettings;
|
import com.fsck.k9.mail.ServerSettings;
|
||||||
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
||||||
import com.fsck.k9.mail.store.RemoteStore;
|
|
||||||
import com.fsck.k9.mail.store.StoreConfig;
|
import com.fsck.k9.mail.store.StoreConfig;
|
||||||
|
|
||||||
|
|
||||||
public class Pop3Store extends RemoteStore {
|
public class Pop3Store {
|
||||||
|
private final StoreConfig storeConfig;
|
||||||
|
private final TrustedSocketFactory trustedSocketFactory;
|
||||||
private final String host;
|
private final String host;
|
||||||
private final int port;
|
private final int port;
|
||||||
private final String username;
|
private final String username;
|
||||||
|
@ -30,8 +29,8 @@ public class Pop3Store extends RemoteStore {
|
||||||
private Map<String, Pop3Folder> mFolders = new HashMap<>();
|
private Map<String, Pop3Folder> mFolders = new HashMap<>();
|
||||||
|
|
||||||
public Pop3Store(ServerSettings serverSettings, StoreConfig storeConfig, TrustedSocketFactory socketFactory) {
|
public Pop3Store(ServerSettings serverSettings, StoreConfig storeConfig, TrustedSocketFactory socketFactory) {
|
||||||
super(storeConfig, socketFactory);
|
this.storeConfig = storeConfig;
|
||||||
|
trustedSocketFactory = socketFactory;
|
||||||
host = serverSettings.host;
|
host = serverSettings.host;
|
||||||
port = serverSettings.port;
|
port = serverSettings.port;
|
||||||
connectionSecurity = serverSettings.connectionSecurity;
|
connectionSecurity = serverSettings.connectionSecurity;
|
||||||
|
@ -41,7 +40,6 @@ public class Pop3Store extends RemoteStore {
|
||||||
authType = serverSettings.authenticationType;
|
authType = serverSettings.authenticationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public Pop3Folder getFolder(String name) {
|
public Pop3Folder getFolder(String name) {
|
||||||
Pop3Folder folder = mFolders.get(name);
|
Pop3Folder folder = mFolders.get(name);
|
||||||
|
@ -52,14 +50,6 @@ public class Pop3Store extends RemoteStore {
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Pop3Folder> getPersonalNamespaces() {
|
|
||||||
List<Pop3Folder> folders = new LinkedList<>();
|
|
||||||
folders.add(getFolder(Pop3Folder.INBOX));
|
|
||||||
return folders;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkSettings() throws MessagingException {
|
public void checkSettings() throws MessagingException {
|
||||||
Pop3Folder folder = new Pop3Folder(this, Pop3Folder.INBOX);
|
Pop3Folder folder = new Pop3Folder(this, Pop3Folder.INBOX);
|
||||||
try {
|
try {
|
||||||
|
@ -71,18 +61,12 @@ public class Pop3Store extends RemoteStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSeenFlagSupported() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
StoreConfig getConfig() {
|
StoreConfig getConfig() {
|
||||||
return mStoreConfig;
|
return storeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pop3Connection createConnection() throws MessagingException {
|
public Pop3Connection createConnection() throws MessagingException {
|
||||||
return new Pop3Connection(new StorePop3Settings(), mTrustedSocketFactory);
|
return new Pop3Connection(new StorePop3Settings(), trustedSocketFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StorePop3Settings implements Pop3Settings {
|
private class StorePop3Settings implements Pop3Settings {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.fsck.k9.mail.AuthType;
|
import com.fsck.k9.mail.AuthType;
|
||||||
import com.fsck.k9.mail.AuthenticationFailedException;
|
import com.fsck.k9.mail.AuthenticationFailedException;
|
||||||
|
@ -21,7 +20,6 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
|
@ -88,21 +86,6 @@ public class Pop3StoreTest {
|
||||||
assertEquals("TestFolder", folder.getServerId());
|
assertEquals("TestFolder", folder.getServerId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getPersonalNamespace_shouldReturnListConsistingOfInbox() throws Exception {
|
|
||||||
List<Pop3Folder> folders = store.getPersonalNamespaces();
|
|
||||||
|
|
||||||
assertEquals(1, folders.size());
|
|
||||||
assertEquals("INBOX", folders.get(0).getServerId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isSeenFlagSupported_shouldReturnFalse() throws Exception {
|
|
||||||
boolean result = store.isSeenFlagSupported();
|
|
||||||
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = MessagingException.class)
|
@Test(expected = MessagingException.class)
|
||||||
public void checkSetting_whenConnectionThrowsException_shouldThrowMessagingException()
|
public void checkSetting_whenConnectionThrowsException_shouldThrowMessagingException()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import com.fsck.k9.mail.Message;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.filter.Base64;
|
import com.fsck.k9.mail.filter.Base64;
|
||||||
import com.fsck.k9.mail.ssl.TrustManagerFactory;
|
import com.fsck.k9.mail.ssl.TrustManagerFactory;
|
||||||
import com.fsck.k9.mail.store.RemoteStore;
|
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
||||||
import com.fsck.k9.mail.store.StoreConfig;
|
import com.fsck.k9.mail.store.StoreConfig;
|
||||||
import com.fsck.k9.mail.store.webdav.WebDavHttpClient.WebDavHttpClientFactory;
|
import com.fsck.k9.mail.store.webdav.WebDavHttpClient.WebDavHttpClientFactory;
|
||||||
import javax.net.ssl.SSLException;
|
import javax.net.ssl.SSLException;
|
||||||
|
@ -61,7 +61,8 @@ import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class WebDavStore extends RemoteStore {
|
public class WebDavStore {
|
||||||
|
private final StoreConfig storeConfig;
|
||||||
private ConnectionSecurity mConnectionSecurity;
|
private ConnectionSecurity mConnectionSecurity;
|
||||||
private String username;
|
private String username;
|
||||||
private String alias;
|
private String alias;
|
||||||
|
@ -91,7 +92,7 @@ public class WebDavStore extends RemoteStore {
|
||||||
|
|
||||||
public WebDavStore(TrustManagerFactory trustManagerFactory, WebDavStoreSettings serverSettings, StoreConfig storeConfig,
|
public WebDavStore(TrustManagerFactory trustManagerFactory, WebDavStoreSettings serverSettings, StoreConfig storeConfig,
|
||||||
WebDavHttpClientFactory clientFactory) {
|
WebDavHttpClientFactory clientFactory) {
|
||||||
super(storeConfig, null);
|
this.storeConfig = storeConfig;
|
||||||
httpClientFactory = clientFactory;
|
httpClientFactory = clientFactory;
|
||||||
this.trustManagerFactory = trustManagerFactory;
|
this.trustManagerFactory = trustManagerFactory;
|
||||||
|
|
||||||
|
@ -154,15 +155,13 @@ public class WebDavStore extends RemoteStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
StoreConfig getStoreConfig() {
|
StoreConfig getStoreConfig() {
|
||||||
return mStoreConfig;
|
return storeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkSettings() throws MessagingException {
|
public void checkSettings() throws MessagingException {
|
||||||
authenticate();
|
authenticate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Folder> getPersonalNamespaces() throws MessagingException {
|
public List<? extends Folder> getPersonalNamespaces() throws MessagingException {
|
||||||
List<Folder> folderList = new LinkedList<>();
|
List<Folder> folderList = new LinkedList<>();
|
||||||
/*
|
/*
|
||||||
|
@ -272,7 +271,6 @@ public class WebDavStore extends RemoteStore {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public WebDavFolder getFolder(String name) {
|
public WebDavFolder getFolder(String name) {
|
||||||
WebDavFolder folder = this.folderList.get(name);
|
WebDavFolder folder = this.folderList.get(name);
|
||||||
|
|
||||||
|
@ -292,16 +290,6 @@ public class WebDavStore extends RemoteStore {
|
||||||
return sendFolder;
|
return sendFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMoveCapable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCopyCapable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSpecialFoldersList() {
|
private String getSpecialFoldersList() {
|
||||||
return "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" +
|
return "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" +
|
||||||
"<propfind xmlns=\"DAV:\">" +
|
"<propfind xmlns=\"DAV:\">" +
|
||||||
|
@ -948,9 +936,8 @@ public class WebDavStore extends RemoteStore {
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessages(List<? extends Message> messages) throws MessagingException {
|
public void sendMessages(List<? extends Message> messages) throws MessagingException {
|
||||||
WebDavFolder tmpFolder = getFolder(mStoreConfig.getDraftsFolder());
|
WebDavFolder tmpFolder = getFolder(storeConfig.getDraftsFolder());
|
||||||
try {
|
try {
|
||||||
tmpFolder.open(Folder.OPEN_MODE_RW);
|
tmpFolder.open(Folder.OPEN_MODE_RW);
|
||||||
List<? extends Message> retMessages = tmpFolder.appendWebDavMessages(messages);
|
List<? extends Message> retMessages = tmpFolder.appendWebDavMessages(messages);
|
||||||
|
|
Loading…
Reference in a new issue