mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 22:12:05 +01:00
RC Release of JEP 55
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2844 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
64ac585dec
commit
c9342aa169
3 changed files with 22 additions and 8 deletions
|
@ -230,7 +230,7 @@ public class ReportedData {
|
||||||
public Iterator getValues(String variable) {
|
public Iterator getValues(String variable) {
|
||||||
for(Iterator it=getFields();it.hasNext();) {
|
for(Iterator it=getFields();it.hasNext();) {
|
||||||
Field field = (Field) it.next();
|
Field field = (Field) it.next();
|
||||||
if (variable.equals(field.getVariable())) {
|
if (variable.equalsIgnoreCase(field.getVariable())) {
|
||||||
return field.getValues();
|
return field.getValues();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.List;
|
||||||
* @author Derek DeMoro
|
* @author Derek DeMoro
|
||||||
*/
|
*/
|
||||||
class SimpleUserSearch extends IQ {
|
class SimpleUserSearch extends IQ {
|
||||||
|
|
||||||
private Form form;
|
private Form form;
|
||||||
private ReportedData data;
|
private ReportedData data;
|
||||||
|
|
||||||
|
@ -94,6 +95,7 @@ class SimpleUserSearch extends IQ {
|
||||||
ReportedData.Field field = new ReportedData.Field("jid", valueList);
|
ReportedData.Field field = new ReportedData.Field("jid", valueList);
|
||||||
fields.add(field);
|
fields.add(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
int eventType = parser.next();
|
int eventType = parser.next();
|
||||||
|
|
||||||
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("item")) {
|
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("item")) {
|
||||||
|
@ -112,10 +114,21 @@ class SimpleUserSearch extends IQ {
|
||||||
ReportedData.Field field = new ReportedData.Field(name, valueList);
|
ReportedData.Field field = new ReportedData.Field(name, valueList);
|
||||||
fields.add(field);
|
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
|
// Column name should be the same
|
||||||
|
if (!exists) {
|
||||||
ReportedData.Column column = new ReportedData.Column(name, name, "text-single");
|
ReportedData.Column column = new ReportedData.Column(name, name, "text-single");
|
||||||
data.addColumn(column);
|
data.addColumn(column);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (eventType == XmlPullParser.END_TAG) {
|
else if (eventType == XmlPullParser.END_TAG) {
|
||||||
if (parser.getName().equals("query")) {
|
if (parser.getName().equals("query")) {
|
||||||
done = true;
|
done = true;
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class UserSearch extends IQ {
|
||||||
while (!done) {
|
while (!done) {
|
||||||
int eventType = parser.next();
|
int eventType = parser.next();
|
||||||
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("instructions")) {
|
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("instructions")) {
|
||||||
buildDataForm(simpleUserSearch, parser.getText(), parser);
|
buildDataForm(simpleUserSearch, parser.nextText(), parser);
|
||||||
return simpleUserSearch;
|
return simpleUserSearch;
|
||||||
}
|
}
|
||||||
else if (eventType == XmlPullParser.START_TAG && parser.getName().equals("item")) {
|
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 {
|
private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception {
|
||||||
DataForm dataForm = new DataForm(Form.TYPE_FORM);
|
DataForm dataForm = new DataForm(Form.TYPE_FORM);
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
dataForm.setTitle("User Search");
|
||||||
|
dataForm.addInstruction(instructions);
|
||||||
while (!done) {
|
while (!done) {
|
||||||
int eventType = parser.next();
|
int eventType = parser.next();
|
||||||
|
|
||||||
dataForm.setTitle("User Search");
|
|
||||||
dataForm.addInstruction(instructions);
|
|
||||||
if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
|
if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
FormField field = new FormField(name);
|
FormField field = new FormField(name);
|
||||||
|
field.setLabel(name);
|
||||||
field.setType(FormField.TYPE_TEXT_SINGLE);
|
field.setType(FormField.TYPE_TEXT_SINGLE);
|
||||||
dataForm.addField(field);
|
dataForm.addField(field);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue