diff --git a/source/org/jivesoftware/smackx/ReportedData.java b/source/org/jivesoftware/smackx/ReportedData.java index 6c51bfc93..93e5fd140 100644 --- a/source/org/jivesoftware/smackx/ReportedData.java +++ b/source/org/jivesoftware/smackx/ReportedData.java @@ -230,7 +230,7 @@ public class ReportedData { public Iterator getValues(String variable) { for(Iterator it=getFields();it.hasNext();) { Field field = (Field) it.next(); - if (variable.equals(field.getVariable())) { + if (variable.equalsIgnoreCase(field.getVariable())) { return field.getValues(); } } diff --git a/source/org/jivesoftware/smackx/search/SimpleUserSearch.java b/source/org/jivesoftware/smackx/search/SimpleUserSearch.java index e3497d39a..50e63b29e 100644 --- a/source/org/jivesoftware/smackx/search/SimpleUserSearch.java +++ b/source/org/jivesoftware/smackx/search/SimpleUserSearch.java @@ -28,6 +28,7 @@ import java.util.List; * @author Derek DeMoro */ class SimpleUserSearch extends IQ { + private Form form; private ReportedData data; @@ -55,7 +56,7 @@ class SimpleUserSearch extends IQ { form = Form.getFormFrom(this); } - if(form == null){ + if (form == null) { return ""; } @@ -87,13 +88,14 @@ class SimpleUserSearch extends IQ { List fields = new ArrayList(); while (!done) { - if(parser.getAttributeCount() > 0){ + if (parser.getAttributeCount() > 0) { String jid = parser.getAttributeValue("", "jid"); List valueList = new ArrayList(); valueList.add(jid); ReportedData.Field field = new ReportedData.Field("jid", valueList); fields.add(field); } + int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG && parser.getName().equals("item")) { @@ -112,9 +114,20 @@ class SimpleUserSearch extends IQ { ReportedData.Field field = new ReportedData.Field(name, valueList); fields.add(field); + boolean exists = false; + Iterator cols = data.getColumns(); + while (cols.hasNext()) { + ReportedData.Column column = (ReportedData.Column) cols.next(); + if (column.getVariable().equals(name)) { + exists = true; + } + } + // Column name should be the same - ReportedData.Column column = new ReportedData.Column(name, name, "text-single"); - data.addColumn(column); + if (!exists) { + ReportedData.Column column = new ReportedData.Column(name, name, "text-single"); + data.addColumn(column); + } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals("query")) { diff --git a/source/org/jivesoftware/smackx/search/UserSearch.java b/source/org/jivesoftware/smackx/search/UserSearch.java index 79c453280..662031ac2 100644 --- a/source/org/jivesoftware/smackx/search/UserSearch.java +++ b/source/org/jivesoftware/smackx/search/UserSearch.java @@ -172,7 +172,7 @@ public class UserSearch extends IQ { while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG && parser.getName().equals("instructions")) { - buildDataForm(simpleUserSearch, parser.getText(), parser); + buildDataForm(simpleUserSearch, parser.nextText(), parser); return simpleUserSearch; } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals("item")) { @@ -203,14 +203,15 @@ public class UserSearch extends IQ { private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception { DataForm dataForm = new DataForm(Form.TYPE_FORM); boolean done = false; + dataForm.setTitle("User Search"); + dataForm.addInstruction(instructions); while (!done) { int eventType = parser.next(); - dataForm.setTitle("User Search"); - dataForm.addInstruction(instructions); if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) { String name = parser.getName(); FormField field = new FormField(name); + field.setLabel(name); field.setType(FormField.TYPE_TEXT_SINGLE); dataForm.addField(field); }