Remove ImapStore.createUri/decodeUri
This commit is contained in:
parent
766b463274
commit
4e22b1c509
6 changed files with 29 additions and 36 deletions
|
@ -6,7 +6,8 @@ import com.fsck.k9.backend.BackendFactory
|
|||
import com.fsck.k9.backend.BackendManager
|
||||
import com.fsck.k9.backend.api.Backend
|
||||
import com.fsck.k9.mail.ServerSettings
|
||||
import com.fsck.k9.mail.store.imap.ImapStore
|
||||
import com.fsck.k9.mail.store.imap.ImapStoreUriCreator
|
||||
import com.fsck.k9.mail.store.imap.ImapStoreUriDecoder
|
||||
import com.fsck.k9.mail.transport.smtp.SmtpTransportUriCreator
|
||||
import com.fsck.k9.mail.transport.smtp.SmtpTransportUriDecoder
|
||||
import org.koin.dsl.module.applicationContext
|
||||
|
@ -21,11 +22,11 @@ fun setUpBackendManager() {
|
|||
}
|
||||
|
||||
override fun decodeStoreUri(storeUri: String): ServerSettings {
|
||||
return ImapStore.decodeUri(storeUri)
|
||||
return ImapStoreUriDecoder.decode(storeUri)
|
||||
}
|
||||
|
||||
override fun createStoreUri(serverSettings: ServerSettings): String {
|
||||
return ImapStore.createUri(serverSettings)
|
||||
return ImapStoreUriCreator.create(serverSettings)
|
||||
}
|
||||
|
||||
override fun decodeTransportUri(transportUri: String): ServerSettings {
|
||||
|
|
|
@ -12,6 +12,8 @@ import com.fsck.k9.mail.oauth.OAuth2TokenProvider
|
|||
import com.fsck.k9.mail.power.PowerManager
|
||||
import com.fsck.k9.mail.ssl.DefaultTrustedSocketFactory
|
||||
import com.fsck.k9.mail.store.imap.ImapStore
|
||||
import com.fsck.k9.mail.store.imap.ImapStoreUriCreator
|
||||
import com.fsck.k9.mail.store.imap.ImapStoreUriDecoder
|
||||
import com.fsck.k9.mail.transport.smtp.SmtpTransport
|
||||
import com.fsck.k9.mail.transport.smtp.SmtpTransportUriCreator
|
||||
import com.fsck.k9.mail.transport.smtp.SmtpTransportUriDecoder
|
||||
|
@ -48,11 +50,11 @@ class ImapBackendFactory(
|
|||
}
|
||||
|
||||
override fun decodeStoreUri(storeUri: String): ServerSettings {
|
||||
return ImapStore.decodeUri(storeUri)
|
||||
return ImapStoreUriDecoder.decode(storeUri)
|
||||
}
|
||||
|
||||
override fun createStoreUri(serverSettings: ServerSettings): String {
|
||||
return ImapStore.createUri(serverSettings)
|
||||
return ImapStoreUriCreator.create(serverSettings)
|
||||
}
|
||||
|
||||
override fun decodeTransportUri(transportUri: String): ServerSettings {
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.fsck.k9.mail.Flag;
|
|||
import com.fsck.k9.mail.K9MailLib;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.NetworkType;
|
||||
import com.fsck.k9.mail.ServerSettings;
|
||||
import com.fsck.k9.mail.oauth.OAuth2TokenProvider;
|
||||
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
||||
import com.fsck.k9.mail.store.RemoteStore;
|
||||
|
@ -64,21 +63,13 @@ public class ImapStore extends RemoteStore {
|
|||
private final Map<String, ImapFolder> folderCache = new HashMap<String, ImapFolder>();
|
||||
|
||||
|
||||
public static ImapStoreSettings decodeUri(String uri) {
|
||||
return ImapStoreUriDecoder.decode(uri);
|
||||
}
|
||||
|
||||
public static String createUri(ServerSettings server) {
|
||||
return ImapStoreUriCreator.create(server);
|
||||
}
|
||||
|
||||
public ImapStore(StoreConfig storeConfig, TrustedSocketFactory trustedSocketFactory,
|
||||
ConnectivityManager connectivityManager, OAuth2TokenProvider oauthTokenProvider) throws MessagingException {
|
||||
super(storeConfig, trustedSocketFactory);
|
||||
|
||||
ImapStoreSettings settings;
|
||||
try {
|
||||
settings = decodeUri(storeConfig.getStoreUri());
|
||||
settings = ImapStoreUriDecoder.decode(storeConfig.getStoreUri());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new MessagingException("Error while decoding store URI", e);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.fsck.k9.mail.ServerSettings;
|
|||
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
|
||||
|
||||
|
||||
class ImapStoreUriCreator {
|
||||
public class ImapStoreUriCreator {
|
||||
/**
|
||||
* Creates an ImapStore URI with the supplied settings.
|
||||
*
|
||||
|
@ -21,7 +21,6 @@ class ImapStoreUriCreator {
|
|||
* @return An ImapStore URI that holds the same information as the {@code server} parameter.
|
||||
*
|
||||
* @see com.fsck.k9.mail.store.StoreConfig#getStoreUri()
|
||||
* @see ImapStore#decodeUri(String)
|
||||
*/
|
||||
public static String create(ServerSettings server) {
|
||||
String userEnc = encodeUtf8(server.username);
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.fsck.k9.mail.ServerSettings.Type;
|
|||
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
|
||||
|
||||
|
||||
class ImapStoreUriDecoder {
|
||||
public class ImapStoreUriDecoder {
|
||||
/**
|
||||
* Decodes an ImapStore URI.
|
||||
*
|
||||
|
|
|
@ -18,7 +18,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapNoAuth() {
|
||||
String uri = "imap://user:pass@server/";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -30,7 +30,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapNoPassword() {
|
||||
String uri = "imap://user:@server/";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -42,7 +42,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapPlainNoPassword() {
|
||||
String uri = "imap://PLAIN:user:@server/";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -54,7 +54,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapExternalAuth() {
|
||||
String uri = "imap://EXTERNAL:user:clientCertAlias@server/";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.EXTERNAL, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -67,7 +67,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapXOAuth2() {
|
||||
String uri = "imap://XOAUTH2:user:@server/";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.XOAUTH2, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -79,7 +79,7 @@ public class ImapStoreUriTest {
|
|||
@Test
|
||||
public void testDecodeStoreUriImapSSL() {
|
||||
String uri = "imap+tls+://PLAIN:user:pass@server/";
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(ConnectionSecurity.STARTTLS_REQUIRED, settings.connectionSecurity);
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
|
@ -92,7 +92,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapTLS() {
|
||||
String uri = "imap+ssl+://PLAIN:user:pass@server/";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(ConnectionSecurity.SSL_TLS_REQUIRED, settings.connectionSecurity);
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
|
@ -105,7 +105,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapAllExtras() {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/0%7CcustomPathPrefix";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -120,7 +120,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapNoExtras() {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -134,7 +134,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapPrefixOnly() {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/customPathPrefix";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -149,7 +149,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapEmptyPrefix() {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/0%7C";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -164,7 +164,7 @@ public class ImapStoreUriTest {
|
|||
public void testDecodeStoreUriImapAutodetectAndPrefix() {
|
||||
String uri = "imap://PLAIN:user:pass@server:143/1%7CcustomPathPrefix";
|
||||
|
||||
ServerSettings settings = ImapStore.decodeUri(uri);
|
||||
ServerSettings settings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals(AuthType.PLAIN, settings.authenticationType);
|
||||
assertEquals("user", settings.username);
|
||||
|
@ -183,7 +183,7 @@ public class ImapStoreUriTest {
|
|||
ServerSettings settings = new ServerSettings(ServerSettings.Type.IMAP, "server", 143,
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", null, extra);
|
||||
|
||||
String uri = ImapStore.createUri(settings);
|
||||
String uri = ImapStoreUriCreator.create(settings);
|
||||
|
||||
assertEquals("imap://PLAIN:user:pass@server:143/0%7CcustomPathPrefix", uri);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class ImapStoreUriTest {
|
|||
ServerSettings settings = new ServerSettings(ServerSettings.Type.IMAP, "server", 143,
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", null, extra);
|
||||
|
||||
String uri = ImapStore.createUri(settings);
|
||||
String uri = ImapStoreUriCreator.create(settings);
|
||||
|
||||
assertEquals("imap://PLAIN:user:pass@server:143/0%7C", uri);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class ImapStoreUriTest {
|
|||
ServerSettings settings = new ServerSettings(ServerSettings.Type.IMAP, "server", 143,
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", null);
|
||||
|
||||
String uri = ImapStore.createUri(settings);
|
||||
String uri = ImapStoreUriCreator.create(settings);
|
||||
|
||||
assertEquals("imap://PLAIN:user:pass@server:143/1%7C", uri);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ public class ImapStoreUriTest {
|
|||
ServerSettings settings = new ServerSettings(ServerSettings.Type.IMAP, "server", 143,
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user", "pass", null, extra);
|
||||
|
||||
String uri = ImapStore.createUri(settings);
|
||||
String uri = ImapStoreUriCreator.create(settings);
|
||||
|
||||
assertEquals("imap://PLAIN:user:pass@server:143/1%7C", uri);
|
||||
}
|
||||
|
@ -229,11 +229,11 @@ public class ImapStoreUriTest {
|
|||
ServerSettings settings = new ServerSettings(ServerSettings.Type.IMAP, "server", 143,
|
||||
ConnectionSecurity.NONE, AuthType.PLAIN, "user@doma:n", "p@ssw:rd%", null, null);
|
||||
|
||||
String uri = ImapStore.createUri(settings);
|
||||
String uri = ImapStoreUriCreator.create(settings);
|
||||
|
||||
assertEquals("imap://PLAIN:user%2540doma%253An:p%2540ssw%253Ard%2525@server:143/1%7C", uri);
|
||||
|
||||
ServerSettings outSettings = ImapStore.decodeUri(uri);
|
||||
ServerSettings outSettings = ImapStoreUriDecoder.decode(uri);
|
||||
|
||||
assertEquals("user@doma:n", outSettings.username);
|
||||
assertEquals("p@ssw:rd%", outSettings.password);
|
||||
|
|
Loading…
Reference in a new issue