1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Added a 'converter" method to the ServerType enum.

This commit is contained in:
Sander Bogaert 2011-07-05 13:15:31 +02:00 committed by Andrew Chen
parent 6f36e90995
commit f652f6bf61

View File

@ -36,7 +36,8 @@ public class AutoconfigInfo {
public static enum SocketType { plain, SSL, STARTTLS}; public static enum SocketType { plain, SSL, STARTTLS};
public static enum RestrictionType { clientIPAddress }; public static enum RestrictionType { clientIPAddress };
public static enum ServerType{ IMAP(0), POP3(1), SMTP(2); public static enum ServerType{ IMAP(0), POP3(1), SMTP(2), UNSET(3), NO_VALUE(4), WRONG_TAG(5);
private int type; private int type;
ServerType(int type){this.type = type;} ServerType(int type){this.type = type;}
public Server getServerObject(){ public Server getServerObject(){
@ -47,6 +48,16 @@ public class AutoconfigInfo {
default: return null; default: return null;
} }
} }
public static ServerType toType(String str){
try{
return valueOf(str.toUpperCase());
}catch (IllegalArgumentException ex){
return WRONG_TAG;
}catch (NullPointerException ex){
return NO_VALUE;
}
}
} }
@ -54,6 +65,7 @@ public class AutoconfigInfo {
Server types hierarchy Server types hierarchy
*******************************************************************************/ *******************************************************************************/
public static abstract class Server{ public static abstract class Server{
public ServerType type = ServerType.UNSET;
public String hostname; public String hostname;
public int port; public int port;
public SocketType socketType; public SocketType socketType;
@ -127,8 +139,8 @@ public class AutoconfigInfo {
public String displayShortName; public String displayShortName;
// Possible servers for this ISP // Possible servers for this ISP
public List<IncomingServer> incomingServer; public List<Server> incomingServer;
public List<OutgoingServer> outgoingServer; public List<Server> outgoingServer;
// Configuration help/information // Configuration help/information
public String identity; public String identity;
@ -142,8 +154,8 @@ public class AutoconfigInfo {
*/ */
public AutoconfigInfo(){ public AutoconfigInfo(){
// initialise the fields // initialise the fields
incomingServer = new ArrayList<IncomingServer>(); incomingServer = new ArrayList<Server>();
outgoingServer = new ArrayList<OutgoingServer>(); outgoingServer = new ArrayList<Server>();
domains = new ArrayList<String>(); domains = new ArrayList<String>();
inputFields = new ArrayList<InputField>(); inputFields = new ArrayList<InputField>();
} }