mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-11 20:15:03 -05:00
Fixed bug in parser and made autoconfiginfo class more robust ( by being more strict on server types ).
This commit is contained in:
parent
c8f14ecfe4
commit
925da1029c
@ -13,6 +13,8 @@ import java.util.List;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Pair;
|
||||
import com.fsck.k9.K9;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
/*
|
||||
NOTE: We assume here there is one emailprovider in a file with the data version information in a one-on-one relation
|
||||
@ -349,8 +351,8 @@ public class AutoconfigInfo implements Parcelable {
|
||||
public String displayShortName;
|
||||
|
||||
// Possible servers for this ISP
|
||||
public List<Server> incomingServer;
|
||||
public List<Server> outgoingServer;
|
||||
public List<IncomingServer> incomingServer;
|
||||
public List<OutgoingServer> outgoingServer;
|
||||
|
||||
// Configuration help/information
|
||||
public String identity;
|
||||
@ -365,8 +367,8 @@ public class AutoconfigInfo implements Parcelable {
|
||||
*/
|
||||
public AutoconfigInfo(){
|
||||
// initialise the fields
|
||||
incomingServer = new ArrayList<Server>();
|
||||
outgoingServer = new ArrayList<Server>();
|
||||
incomingServer = new ArrayList<IncomingServer>();
|
||||
outgoingServer = new ArrayList<OutgoingServer>();
|
||||
domains = new ArrayList<String>();
|
||||
inputFields = new ArrayList<InputField>();
|
||||
}
|
||||
@ -380,6 +382,14 @@ public class AutoconfigInfo implements Parcelable {
|
||||
displayName = parcel.readString();
|
||||
displayShortName = parcel.readString();
|
||||
|
||||
incomingServer = parcel.readArrayList(IncomingServer.class.getClassLoader());
|
||||
outgoingServer = parcel.readArrayList(OutgoingServer.class.getClassLoader());
|
||||
|
||||
identity = parcel.readString();
|
||||
inputFields = parcel.readArrayList(InputField.class.getClassLoader());
|
||||
enable = (InformationBlock) parcel.readValue(InformationBlock.class.getClassLoader());
|
||||
instruction = (InformationBlock) parcel.readValue(InformationBlock.class.getClassLoader());
|
||||
documentation = (InformationBlock) parcel.readValue(InformationBlock.class.getClassLoader());
|
||||
|
||||
}
|
||||
|
||||
@ -407,20 +417,21 @@ public class AutoconfigInfo implements Parcelable {
|
||||
}
|
||||
|
||||
// filters the list of servers according to the arguments ( list of allowed specifications )
|
||||
private List<Server> getFilteredServerList
|
||||
(List<Server> serverList, List<ServerType> serverTypes, List<AuthenticationType> authenticationTypes, List<SocketType> socketTypes){
|
||||
ArrayList<Server> servers = new ArrayList<Server>();
|
||||
ArrayList<Server> toBeRemoved = new ArrayList<Server>();
|
||||
private <T extends Server> List<T> getFilteredServerList
|
||||
(List<T> serverList, List<ServerType> serverTypes, List<AuthenticationType> authenticationTypes, List<SocketType> socketTypes)
|
||||
{
|
||||
ArrayList<T> servers = new ArrayList<T>();
|
||||
ArrayList<T> toBeRemoved = new ArrayList<T>();
|
||||
|
||||
// filter for servertypes
|
||||
if( serverTypes != null && !serverTypes.isEmpty() )
|
||||
for( Server serv : serverList )
|
||||
for( T serv : serverList )
|
||||
if( serverTypes.contains(serv.type))
|
||||
servers.add(serv);
|
||||
|
||||
// filter for autenticationtype
|
||||
if( authenticationTypes != null & !authenticationTypes.isEmpty() ){
|
||||
for( Server serv : servers )
|
||||
for( T serv : servers )
|
||||
if( !authenticationTypes.contains(serv.authentication) )
|
||||
toBeRemoved.add(serv);
|
||||
}
|
||||
@ -429,7 +440,7 @@ public class AutoconfigInfo implements Parcelable {
|
||||
|
||||
// filter for sockettype
|
||||
if( socketTypes != null & !socketTypes.isEmpty() )
|
||||
for( Server serv : servers )
|
||||
for( T serv : servers )
|
||||
if( !socketTypes.contains(serv.socketType) )
|
||||
toBeRemoved.add(serv);
|
||||
servers.removeAll(toBeRemoved);
|
||||
@ -438,12 +449,12 @@ public class AutoconfigInfo implements Parcelable {
|
||||
}
|
||||
|
||||
// public wrappers for the filter method
|
||||
public List<Server> getOutgoingServers
|
||||
public List<OutgoingServer> getOutgoingServers
|
||||
(List<ServerType> serverTypes, List<AuthenticationType> authenticationTypes, List<SocketType> socketTypes){
|
||||
return getFilteredServerList(outgoingServer, serverTypes, authenticationTypes, socketTypes);
|
||||
}
|
||||
|
||||
public List<Server> getIncomingServers
|
||||
public List<IncomingServer> getIncomingServers
|
||||
(List<ServerType> serverTypes, List<AuthenticationType> authenticationTypes, List<SocketType> socketTypes){
|
||||
return getFilteredServerList(incomingServer, serverTypes, authenticationTypes, socketTypes);
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.IncomingServerPOP3;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.OutgoingServerSMTP;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.InputField;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.InformationBlock;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.IncomingServer;
|
||||
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.OutgoingServer;
|
||||
|
||||
// Other
|
||||
import java.util.HashMap;
|
||||
@ -288,7 +290,10 @@ public class ConfigurationXMLHandler extends DefaultHandler {
|
||||
String type = attributes.getValue(ATTRIBUTE.TYPE.getXMLStringVersion());
|
||||
if( type != null ){
|
||||
mServerInProgress = ServerType.toType(type).getServerObject(null);
|
||||
mAutoconfigInfo.incomingServer.add(mServerInProgress);
|
||||
if( TAG.toTag(localName) == TAG.INCOMINGSERVER )
|
||||
mAutoconfigInfo.incomingServer.add((IncomingServer)mServerInProgress);
|
||||
else if( TAG.toTag(localName) == TAG.OUTGOINGSERVER )
|
||||
mAutoconfigInfo.outgoingServer.add((OutgoingServer)mServerInProgress);
|
||||
}else{ // this should never happen, this file is not formed correctly ( check the relaxng scheme )
|
||||
throw new SAXParseException("Incoming|Outgoing-Server tag has no type attribute!", mLocator);
|
||||
}break;
|
||||
|
Loading…
Reference in New Issue
Block a user