include form fields into caps hash calculation
This commit is contained in:
parent
8d98c52803
commit
867d0ef191
|
@ -17,6 +17,7 @@ import org.json.JSONObject;
|
||||||
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.forms.Data;
|
import eu.siacs.conversations.xmpp.forms.Data;
|
||||||
|
import eu.siacs.conversations.xmpp.forms.Field;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
import eu.siacs.conversations.xmpp.stanzas.IqPacket;
|
||||||
|
|
||||||
public class ServiceDiscoveryResult {
|
public class ServiceDiscoveryResult {
|
||||||
|
@ -220,7 +221,21 @@ public class ServiceDiscoveryResult {
|
||||||
|
|
||||||
for(Data form : forms) {
|
for(Data form : forms) {
|
||||||
s.append(form.getFormType() + "<");
|
s.append(form.getFormType() + "<");
|
||||||
//TODO append fields and values
|
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;
|
MessageDigest md;
|
||||||
|
|
|
@ -9,6 +9,8 @@ import eu.siacs.conversations.xml.Element;
|
||||||
|
|
||||||
public class Data extends Element {
|
public class Data extends Element {
|
||||||
|
|
||||||
|
private static final String FORM_TYPE = "FORM_TYPE";
|
||||||
|
|
||||||
public Data() {
|
public Data() {
|
||||||
super("x");
|
super("x");
|
||||||
this.setAttribute("xmlns","jabber:x:data");
|
this.setAttribute("xmlns","jabber:x:data");
|
||||||
|
@ -17,7 +19,8 @@ public class Data extends Element {
|
||||||
public List<Field> getFields() {
|
public List<Field> getFields() {
|
||||||
ArrayList<Field> fields = new ArrayList<Field>();
|
ArrayList<Field> fields = new ArrayList<Field>();
|
||||||
for(Element child : getChildren()) {
|
for(Element child : getChildren()) {
|
||||||
if (child.getName().equals("field")) {
|
if (child.getName().equals("field")
|
||||||
|
&& !FORM_TYPE.equals(child.getAttribute("var"))) {
|
||||||
fields.add(Field.parse(child));
|
fields.add(Field.parse(child));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +29,8 @@ public class Data extends Element {
|
||||||
|
|
||||||
public Field getFieldByName(String needle) {
|
public Field getFieldByName(String needle) {
|
||||||
for(Element child : getChildren()) {
|
for(Element child : getChildren()) {
|
||||||
if (child.getName().equals("field") && needle.equals(child.getAttribute("var"))) {
|
if (child.getName().equals("field")
|
||||||
|
&& needle.equals(child.getAttribute("var"))) {
|
||||||
return Field.parse(child);
|
return Field.parse(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,11 +80,11 @@ public class Data extends Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFormType(String formType) {
|
public void setFormType(String formType) {
|
||||||
this.put("FORM_TYPE", formType);
|
this.put(FORM_TYPE, formType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFormType() {
|
public String getFormType() {
|
||||||
String type = getValue("FORM_TYPE");
|
String type = getValue(FORM_TYPE);
|
||||||
return type == null ? "" : type;
|
return type == null ? "" : type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue