Commiting UserSearch

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2855 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro 2005-09-20 21:02:30 +00:00 committed by derek
parent c9342aa169
commit a5991bfa94
4 changed files with 24 additions and 8 deletions

View File

@ -46,7 +46,7 @@ import java.util.*;
*
* @author Matt Tucker
*/
class Cache implements Map {
public class Cache implements Map {
/**
* The map the keys and values are stored in.

View File

@ -83,6 +83,7 @@ class SimpleUserSearch extends IQ {
protected void parseItems(XmlPullParser parser) throws Exception {
ReportedData data = new ReportedData();
data.addColumn(new ReportedData.Column("JID", "jid", "text-single"));
boolean done = false;

View File

@ -211,7 +211,21 @@ public class UserSearch extends IQ {
if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
String name = parser.getName();
FormField field = new FormField(name);
field.setLabel(name);
// Handle hard coded values.
if(name.equals("first")){
field.setLabel("First Name");
}
else if(name.equals("last")){
field.setLabel("Last Name");
}
else if(name.equals("email")){
field.setLabel("Email Address");
}
else if(name.equals("nick")){
field.setLabel("Nickname");
}
field.setType(FormField.TYPE_TEXT_SINGLE);
dataForm.addField(field);
}

View File

@ -44,28 +44,26 @@ import java.util.List;
public class UserSearchManager {
private XMPPConnection con;
private String searchService;
private UserSearch userSearch;
/**
* Creates a new UserSearchManager.
*
* @param con the XMPPConnection to use.
* @param searchService the name of the search service. (ex. search.jivesoftware.com)
*/
public UserSearchManager(XMPPConnection con, String searchService) {
public UserSearchManager(XMPPConnection con) {
this.con = con;
this.searchService = searchService;
userSearch = new UserSearch();
}
/**
* Returns the form to fill out to perform a search.
*
* @param searchService the search service to query.
* @return the form to fill out to perform a search.
* @throws XMPPException thrown if a server error has occurred.
*/
public Form getSearchForm() throws XMPPException {
public Form getSearchForm(String searchService) throws XMPPException {
return userSearch.getSearchForm(con, searchService);
}
@ -74,13 +72,15 @@ public class UserSearchManager {
* in the form of <code>ReportedData</code>
*
* @param searchForm the <code>Form</code> to submit for searching.
* @param searchService the name of the search service to use.
* @return the ReportedData returned by the server.
* @throws XMPPException thrown if a server error has occurred.
*/
public ReportedData getSearchResults(Form searchForm) throws XMPPException {
public ReportedData getSearchResults(Form searchForm, String searchService) throws XMPPException {
return userSearch.sendSearchForm(con, searchForm, searchService);
}
/**
* Returns a collection of search services found on the server.
*
@ -100,4 +100,5 @@ public class UserSearchManager {
}
return searchServices;
}
}