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

Unified the types of extra information under "documentation".

This commit is contained in:
dzan 2011-07-28 15:27:34 +02:00 committed by Andrew Chen
parent 71c7a5c9ef
commit 9e99acd9c9
2 changed files with 27 additions and 12 deletions

View File

@ -55,6 +55,7 @@ public class AutoconfigInfo implements Parcelable {
public static enum AuthenticationType { plain, secure, NTLM, GSSAPI, clientIPaddress, TLSclientcert, none, UNSET };
public static enum SocketType { plain, SSL, STARTTLS, UNSET};
public static enum RestrictionType { clientIPAddress };
public static enum InformationType { ENABLE, INSTRUCTION, DOCUMENTATION }
public static enum ServerType{ IMAP(0), POP3(1), SMTP(2), UNSET(3), NO_VALUE(4), WRONG_TAG(5);
@ -303,12 +304,15 @@ public class AutoconfigInfo implements Parcelable {
// fields
public String url;
public InformationType type;
// first one is the language, second the text
public ArrayList<ParcelableMutablePair<String, String>> descriptions = new ArrayList<ParcelableMutablePair<String, String>>();
public InformationBlock(Parcel parcel){
url = parcel.readString();
descriptions = parcel.readArrayList(ParcelableMutablePair.class.getClassLoader());
type = InformationType.valueOf(parcel.readString());
}
// keep the default constructor too
@ -321,6 +325,13 @@ public class AutoconfigInfo implements Parcelable {
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(url);
parcel.writeList(descriptions);
parcel.writeString(type.name());
}
public boolean isEmpty(){
if( !!url.isEmpty() || descriptions.size() > 0 )
return true;
else return false;
}
}
@ -359,6 +370,8 @@ public class AutoconfigInfo implements Parcelable {
public void setFirst(K val){ this.first = val; }
public void setSecond(V val){ this.second = val; }
public K getFirst(){ return first; }
public V getSecond(){ return second; }
@Override
public int describeContents() {return hashCode();}
@ -393,9 +406,7 @@ public class AutoconfigInfo implements Parcelable {
// Configuration help/information
public String identity;
public List<InputField> inputFields;
public InformationBlock enable;
public InformationBlock instruction;
public InformationBlock documentation;
public List<InformationBlock> documentation;
/*
@ -406,6 +417,7 @@ public class AutoconfigInfo implements Parcelable {
incomingServer = new ArrayList<IncomingServer>();
outgoingServer = new ArrayList<OutgoingServer>();
domains = new ArrayList<String>();
documentation = new ArrayList<InformationBlock>();
inputFields = new ArrayList<InputField>();
}
@ -423,9 +435,7 @@ public class AutoconfigInfo implements Parcelable {
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());
documentation = parcel.readArrayList(InformationBlock.class.getClassLoader());
}
@ -507,6 +517,10 @@ public class AutoconfigInfo implements Parcelable {
}
public boolean hasExtraInfo() {
return( documentation.size() > 0 );
}
/*
What's left of the parcelable interface
*/
@ -528,9 +542,7 @@ public class AutoconfigInfo implements Parcelable {
parcel.writeString(identity);
parcel.writeList(inputFields);
parcel.writeValue(enable);
parcel.writeValue(instruction);
parcel.writeValue(documentation);
parcel.writeList(documentation);
}
}

View File

@ -50,6 +50,7 @@ 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;
import com.fsck.k9.helper.configxmlparser.AutoconfigInfo.InformationType;
// Other
import java.util.HashMap;
@ -367,7 +368,8 @@ public class ConfigurationXMLHandler extends DefaultHandler {
mIsEnable = true;
mInformationBlockInProgress = new InformationBlock();
mInformationBlockInProgress.url = attributes.getValue(ATTRIBUTE.VISITURL.getXMLStringVersion());
mAutoconfigInfo.enable = mInformationBlockInProgress;
mInformationBlockInProgress.type = InformationType.ENABLE;
mAutoconfigInfo.documentation.add(mInformationBlockInProgress);
break;
case INSTRUCTION: // Documentation and stand-alone instruction are exactly the same
case DOCUMENTATION: // Nested instruction and description are exactly the same
@ -386,11 +388,12 @@ public class ConfigurationXMLHandler extends DefaultHandler {
mInformationBlockInProgress = new InformationBlock();
mInformationBlockInProgress.url = attributes.getValue(ATTRIBUTE.URL.getXMLStringVersion());
if( TAG.toTag(localName) == TAG.INSTRUCTION )
mAutoconfigInfo.instruction = mInformationBlockInProgress;
mInformationBlockInProgress.type = InformationType.INSTRUCTION;
else if ( TAG.toTag(localName) == TAG.DOCUMENTATION )
mAutoconfigInfo.documentation = mInformationBlockInProgress;
mInformationBlockInProgress.type = InformationType.DOCUMENTATION;
else // this should never happen!
throw new SAXParseException("Unknown tag passed through in parser.", mLocator);
mAutoconfigInfo.documentation.add(mInformationBlockInProgress);
}
break;