mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-24 08:38:51 -05:00
Save name of the store type in StoreSettings
This commit is contained in:
parent
25c1a565e7
commit
f6de6f8e42
@ -120,6 +120,11 @@ public abstract class Store {
|
||||
* @see Account#getStoreUri()
|
||||
*/
|
||||
public static class StoreSettings {
|
||||
/**
|
||||
* Name of the store type (e.g. "IMAP").
|
||||
*/
|
||||
public final String type;
|
||||
|
||||
/**
|
||||
* The host name of the incoming server.
|
||||
*/
|
||||
@ -162,6 +167,8 @@ public abstract class Store {
|
||||
/**
|
||||
* Creates a new {@code StoreSettings} object.
|
||||
*
|
||||
* @param type
|
||||
* see {@link StoreSettings#type}
|
||||
* @param host
|
||||
* see {@link StoreSettings#host}
|
||||
* @param port
|
||||
@ -175,8 +182,10 @@ public abstract class Store {
|
||||
* @param password
|
||||
* see {@link StoreSettings#password}
|
||||
*/
|
||||
public StoreSettings(String host, int port, ConnectionSecurity connectionSecurity,
|
||||
String authenticationType, String username, String password) {
|
||||
public StoreSettings(String type, String host, int port,
|
||||
ConnectionSecurity connectionSecurity, String authenticationType, String username,
|
||||
String password) {
|
||||
this.type = type;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.connectionSecurity = connectionSecurity;
|
||||
@ -193,6 +202,12 @@ public abstract class Store {
|
||||
public Map<String, String> getExtra() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void putIfNotNull(Map<String, String> map, String key, String value) {
|
||||
if (value != null) {
|
||||
map.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -223,20 +223,22 @@ public class ImapStore extends Store {
|
||||
* @see ImapStore#decodeUri(String)
|
||||
*/
|
||||
private static class ImapStoreSettings extends StoreSettings {
|
||||
private static final String PATH_PREFIX_KEY = "path_prefix";
|
||||
private static final String STORE_TYPE = "IMAP";
|
||||
private static final String PATH_PREFIX_KEY = "pathPrefix";
|
||||
|
||||
public final String pathPrefix;
|
||||
|
||||
protected ImapStoreSettings(String host, int port, ConnectionSecurity connectionSecurity,
|
||||
String authenticationType, String username, String password, String pathPrefix) {
|
||||
super(host, port, connectionSecurity, authenticationType, username, password);
|
||||
super(STORE_TYPE, host, port, connectionSecurity, authenticationType, username,
|
||||
password);
|
||||
this.pathPrefix = pathPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getExtra() {
|
||||
Map<String, String> extra = new HashMap<String, String>();
|
||||
extra.put(PATH_PREFIX_KEY, pathPrefix);
|
||||
putIfNotNull(extra, PATH_PREFIX_KEY, pathPrefix);
|
||||
return extra;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Pop3Store extends Store {
|
||||
private static final String STORE_TYPE = "POP3";
|
||||
|
||||
public static final int CONNECTION_SECURITY_NONE = 0;
|
||||
public static final int CONNECTION_SECURITY_TLS_OPTIONAL = 1;
|
||||
public static final int CONNECTION_SECURITY_TLS_REQUIRED = 2;
|
||||
@ -99,7 +101,8 @@ public class Pop3Store extends Store {
|
||||
}
|
||||
}
|
||||
|
||||
return new StoreSettings(host, port, connectionSecurity, null, username, password);
|
||||
return new StoreSettings(STORE_TYPE, host, port, connectionSecurity, null, username,
|
||||
password);
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,6 +191,7 @@ public class WebDavStore extends Store {
|
||||
* @see WebDavStore#decodeUri(String)
|
||||
*/
|
||||
private static class WebDavStoreSettings extends StoreSettings {
|
||||
private static final String STORE_TYPE = "WebDAV";
|
||||
private static final String ALIAS_KEY = "alias";
|
||||
private static final String PATH_KEY = "path";
|
||||
private static final String AUTH_PATH_KEY = "authPath";
|
||||
@ -204,7 +205,8 @@ public class WebDavStore extends Store {
|
||||
protected WebDavStoreSettings(String host, int port, ConnectionSecurity connectionSecurity,
|
||||
String authenticationType, String username, String password, String alias,
|
||||
String path, String authPath, String mailboxPath) {
|
||||
super(host, port, connectionSecurity, authenticationType, username, password);
|
||||
super(STORE_TYPE, host, port, connectionSecurity, authenticationType, username,
|
||||
password);
|
||||
this.alias = alias;
|
||||
this.path = path;
|
||||
this.authPath = authPath;
|
||||
@ -214,10 +216,10 @@ public class WebDavStore extends Store {
|
||||
@Override
|
||||
public Map<String, String> getExtra() {
|
||||
Map<String, String> extra = new HashMap<String, String>();
|
||||
extra.put(ALIAS_KEY, alias);
|
||||
extra.put(PATH_KEY, path);
|
||||
extra.put(AUTH_PATH_KEY, authPath);
|
||||
extra.put(MAILBOX_PATH_KEY, mailboxPath);
|
||||
putIfNotNull(extra, ALIAS_KEY, alias);
|
||||
putIfNotNull(extra, PATH_KEY, path);
|
||||
putIfNotNull(extra, AUTH_PATH_KEY, authPath);
|
||||
putIfNotNull(extra, MAILBOX_PATH_KEY, mailboxPath);
|
||||
return extra;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user