diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java b/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java index 42f2d8409..c4fc30abc 100644 --- a/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java +++ b/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java @@ -17,6 +17,7 @@ import org.json.JSONObject; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.forms.Data; +import eu.siacs.conversations.xmpp.forms.Field; import eu.siacs.conversations.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; |