From 9e99acd9c909cd1a32ab0978264f52262c17e3d0 Mon Sep 17 00:00:00 2001 From: dzan Date: Thu, 28 Jul 2011 15:27:34 +0200 Subject: [PATCH] Unified the types of extra information under "documentation". --- .../configxmlparser/AutoconfigInfo.java | 30 +++++++++++++------ .../ConfigurationXMLHandler.java | 9 ++++-- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/com/fsck/k9/helper/configxmlparser/AutoconfigInfo.java b/src/com/fsck/k9/helper/configxmlparser/AutoconfigInfo.java index 00f62571e..9310fe27a 100644 --- a/src/com/fsck/k9/helper/configxmlparser/AutoconfigInfo.java +++ b/src/com/fsck/k9/helper/configxmlparser/AutoconfigInfo.java @@ -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> descriptions = new ArrayList>(); 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 inputFields; - public InformationBlock enable; - public InformationBlock instruction; - public InformationBlock documentation; + public List documentation; /* @@ -406,6 +417,7 @@ public class AutoconfigInfo implements Parcelable { incomingServer = new ArrayList(); outgoingServer = new ArrayList(); domains = new ArrayList(); + documentation = new ArrayList(); inputFields = new ArrayList(); } @@ -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); } } diff --git a/src/com/fsck/k9/helper/configxmlparser/ConfigurationXMLHandler.java b/src/com/fsck/k9/helper/configxmlparser/ConfigurationXMLHandler.java index c1fd9dd7e..5b26ec485 100644 --- a/src/com/fsck/k9/helper/configxmlparser/ConfigurationXMLHandler.java +++ b/src/com/fsck/k9/helper/configxmlparser/ConfigurationXMLHandler.java @@ -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;