aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java b/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java
index cfba7c4f..562d95b7 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java
@@ -17,6 +17,7 @@ import org.json.JSONObject;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.forms.Data;
+import de.thedevstack.conversationsplus.xmpp.forms.Field;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
public class ServiceDiscoveryResult {
@@ -189,6 +190,19 @@ public class ServiceDiscoveryResult {
return false;
}
+ public String getExtendedDiscoInformation(String formType, String name) {
+ for(Data form : this.forms) {
+ if (formType.equals(form.getFormType())) {
+ for(Field field: form.getFields()) {
+ if (name.equals(field.getFieldName())) {
+ return field.getValue();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
protected byte[] mkCapHash() {
StringBuilder s = new StringBuilder();
@@ -219,8 +233,22 @@ public class ServiceDiscoveryResult {
});
for(Data form : forms) {
- s.append(form.getFormType()+"<");
- //TODO append fields and values
+ s.append(form.getFormType() + "<");
+ List<Field> fields = form.getFields();
+ Collections.sort(fields, new Comparator<Field>() {
+ @Override
+ public int compare(Field lhs, Field rhs) {
+ return lhs.getFieldName().compareTo(rhs.getFieldName());
+ }
+ });
+ for(Field field : fields) {
+ s.append(field.getFieldName()+"<");
+ List<String> values = field.getValues();
+ Collections.sort(values);
+ for(String value : values) {
+ s.append(value+"<");
+ }
+ }
}
MessageDigest md;