summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/isode/stroke/parser')
-rw-r--r--src/com/isode/stroke/parser/EnumParser.java37
-rw-r--r--src/com/isode/stroke/parser/StreamFeaturesParser.java9
2 files changed, 46 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/EnumParser.java b/src/com/isode/stroke/parser/EnumParser.java
new file mode 100644
index 0000000..2d35c79
--- /dev/null
+++ b/src/com/isode/stroke/parser/EnumParser.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.parser;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public class EnumParser<T> {
+
+ private Map<String, T> values = new HashMap<String, T>();
+
+ public EnumParser() {
+
+ }
+
+ public EnumParser addValue(T value, String text) {
+ values.put(text, value);
+ return this;
+ }
+
+ public T parse(String value) {
+ if(values.containsKey(value)) {
+ return values.get(value);
+ } else {
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com/isode/stroke/parser/StreamFeaturesParser.java b/src/com/isode/stroke/parser/StreamFeaturesParser.java
index 5c98268..ee4f9dc 100644
--- a/src/com/isode/stroke/parser/StreamFeaturesParser.java
+++ b/src/com/isode/stroke/parser/StreamFeaturesParser.java
@@ -31,6 +31,8 @@ class StreamFeaturesParser extends GenericElementParser<StreamFeatures> {
inMechanisms_ = true;
} else if (element.equals("compression") && ns.equals("http://jabber.org/features/compress")) {
inCompression_ = true;
+ } else if (element.equals("ver") && ns.equals("urn:xmpp:features:rosterver")) {
+ getElementGeneric().setHasRosterVersioning();
}
} else if (currentDepth_ == 2) {
if (inCompression_ && element.equals("method")) {
@@ -39,6 +41,9 @@ class StreamFeaturesParser extends GenericElementParser<StreamFeatures> {
} else if (inMechanisms_ && element.equals("mechanism")) {
inMechanism_ = true;
currentText_ = "";
+ } else if (inMechanisms_ && element.equals("hostname") && ns.equals("urn:xmpp:domain-based-name:1")) {
+ inAuthenticationHostname_ = true;
+ currentText_ = "";
}
}
++currentDepth_;
@@ -57,6 +62,9 @@ class StreamFeaturesParser extends GenericElementParser<StreamFeatures> {
} else if (inMechanism_) {
getElementGeneric().addAuthenticationMechanism(currentText_);
inMechanism_ = false;
+ } else if (inAuthenticationHostname_) {
+ getElementGeneric().setAuthenticationHostname(currentText_);
+ inAuthenticationHostname_ = false;
}
}
}
@@ -71,4 +79,5 @@ class StreamFeaturesParser extends GenericElementParser<StreamFeatures> {
private boolean inMechanism_ = false;
private boolean inCompression_ = false;
private boolean inCompressionMethod_ = false;
+ private boolean inAuthenticationHostname_ = false;
}