summaryrefslogtreecommitdiff
path: root/src/org/noreply/fancydress/directory/ServerDescriptor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/noreply/fancydress/directory/ServerDescriptor.java')
-rw-r--r--src/org/noreply/fancydress/directory/ServerDescriptor.java72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/org/noreply/fancydress/directory/ServerDescriptor.java b/src/org/noreply/fancydress/directory/ServerDescriptor.java
index 020d31b..4c0cba1 100644
--- a/src/org/noreply/fancydress/directory/ServerDescriptor.java
+++ b/src/org/noreply/fancydress/directory/ServerDescriptor.java
@@ -23,6 +23,11 @@ import java.text.ParseException;
* @see Server
*/
public class ServerDescriptor {
+ /*
+ปญญญญญญญ * descriptor version we understand.
+ปญญญญญญญ */
+ private static final String DESCRIPTOR_VERSION = "0.2";
+
/* Required */
private String descriptorVersion;
private String nickname;
@@ -46,7 +51,7 @@ public class ServerDescriptor {
private String whyInsecure;
private IncomingMMTPSection incomingMMTPSection;
- private Object outgoingMMTPSection;
+ private OutgoingMMTPSection outgoingMMTPSection;
private DeliveryMBOXSection deliveryMBOXSection;
private DeliverySMTPSection deliverySMTPSection;
private Object deliveryFragmentedSection;
@@ -82,6 +87,11 @@ public class ServerDescriptor {
incomingMMTPSection = section == null ? null : new IncomingMMTPSection(section);
} catch (Mix3BadServerFormatException e) { System.err.println(e); };
+ section = m.getSection("Outgoing/MMTP");
+ try {
+ outgoingMMTPSection = section == null ? null : new OutgoingMMTPSection(section);
+ } catch (Mix3BadServerFormatException e) { System.err.println(e); };
+
section = m.getSection("Delivery/MBOX");
try {
deliveryMBOXSection = section == null ? null : new DeliveryMBOXSection(section);
@@ -120,46 +130,18 @@ public class ServerDescriptor {
* Whitespace is trimmed off each Packet-Version.
*
* @param s the comma separated list of Packet-Versions
- * @param onlySupported only include Packet-Versions that we can handle
* @return array of Packet-Versions.
*/
- public static String[] parsePacketVersions(String s, boolean onlySupported) {
+ public static String[] parsePacketVersions(String s) {
ArrayList versions = new ArrayList();
int indexFrom = 0;
int indexOf;
- while ((indexOf = s.indexOf(',', indexFrom)) != -1) {
- String v = s.substring(indexFrom, indexOf).trim();
- if (!v.equals("") && (Packet.isPacketVersionSupported(v) || !onlySupported ))
- versions.add( v );
- indexFrom = indexOf + 1;
- }
- String v = s.substring(indexFrom).trim();
- if (!v.equals("") && (Packet.isPacketVersionSupported(v) || !onlySupported ))
- versions.add( v );
-
- String[] result = new String[versions.size()];
- for (int i=0; i<result.length; i++)
- result[i] = (String) versions.get(i);
-
- return result;
- }
- /**
- * Tokenize a Packet-Versions string into single Packet-Versions.
- *
- * The Packet-Versions is a comma separated list of Packet-Versions.
- * This method parses a Packet-Versions value and returns an array of
- * Strings, holding one Packet-Version each.
- *
- * Whitespace is trimmed off each Packet-Version.
- *
- * Only Packet-Versions that we know to handle are included n the result.
- *
- * @param s the comma separated list of Packet-Versions
- * @return array of Packet-Versions.
- */
- public static String[] parsePacketVersions(String s) {
- return parsePacketVersions(s, true);
+ String[] tokens = Util.tokenize(s, ',');
+ for (int i=0; i<tokens.length; i++)
+ if (Packet.isPacketVersionSupported(tokens[i]))
+ versions.add( tokens[i] );
+ return (String[]) versions.toArray( new String[versions.size()] );
}
/**
@@ -173,7 +155,7 @@ public class ServerDescriptor {
if (entryDescriptorVersion == null)
throw new Mix3BadServerFormatException("Descriptor-Version not in Server Descriptor");
descriptorVersion = entryDescriptorVersion.getValue();
- if (! descriptorVersion.equals("0.2"))
+ if (! descriptorVersion.equals(DESCRIPTOR_VERSION))
/* We have to ignore unknown Descriptor-Versions */
throw new Mix3BadServerUnrecognizedVersionException("Unrecognized Descriptor-Version "+descriptorVersion);
@@ -319,6 +301,15 @@ public class ServerDescriptor {
}
/**
+ * Get this server descriptor's supported packet versions.
+ *
+ * @return supported packet versions
+ */
+ public String[] getPacketVersions() {
+ return packetVersions;
+ }
+
+ /**
* Get the date after which this server descriptor is valid.
*
* @return date after which this server descriptor is valid
@@ -354,4 +345,13 @@ public class ServerDescriptor {
return incomingMMTPSection;
}
+ /**
+ * Get the Outgoing/MMTP section.
+ *
+ * @return this server descriptor's Outgoing/MMTP section
+ */
+ public OutgoingMMTPSection getOutgoingMMTPSection() {
+ return outgoingMMTPSection;
+ }
+
}