diff options
author | lookshe <github@lookshe.org> | 2016-04-05 23:35:38 +0200 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2016-04-05 23:35:38 +0200 |
commit | 0beb3ca30b31f07e374b870e6a659256f6960170 (patch) | |
tree | 82a389561691afa508433d338e3f87aa6c8a5c7b /src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java | |
parent | 6899b9b01e416da95b9006d9f23bf1e1214f607d (diff) | |
parent | d6a076e11281d4c3fb6b9504fe99d799b04ebbbb (diff) |
Merge branch 'trz/rebase' into trz/rename
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/entities/ServiceDiscoveryResult.java | 32 |
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; |