From a5991bfa942a45b06f1d5719db458d47f60bfb98 Mon Sep 17 00:00:00 2001 From: Derek DeMoro Date: Tue, 20 Sep 2005 21:02:30 +0000 Subject: [PATCH] Commiting UserSearch git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2855 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/util/Cache.java | 2 +- .../smackx/search/SimpleUserSearch.java | 1 + .../jivesoftware/smackx/search/UserSearch.java | 16 +++++++++++++++- .../smackx/search/UserSearchManager.java | 13 +++++++------ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/source/org/jivesoftware/smack/util/Cache.java b/source/org/jivesoftware/smack/util/Cache.java index ec282c054..009e23b8a 100644 --- a/source/org/jivesoftware/smack/util/Cache.java +++ b/source/org/jivesoftware/smack/util/Cache.java @@ -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. diff --git a/source/org/jivesoftware/smackx/search/SimpleUserSearch.java b/source/org/jivesoftware/smackx/search/SimpleUserSearch.java index 50e63b29e..9566a66dd 100644 --- a/source/org/jivesoftware/smackx/search/SimpleUserSearch.java +++ b/source/org/jivesoftware/smackx/search/SimpleUserSearch.java @@ -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; diff --git a/source/org/jivesoftware/smackx/search/UserSearch.java b/source/org/jivesoftware/smackx/search/UserSearch.java index 662031ac2..993ac59e1 100644 --- a/source/org/jivesoftware/smackx/search/UserSearch.java +++ b/source/org/jivesoftware/smackx/search/UserSearch.java @@ -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); } diff --git a/source/org/jivesoftware/smackx/search/UserSearchManager.java b/source/org/jivesoftware/smackx/search/UserSearchManager.java index f33567983..50c8ff67d 100644 --- a/source/org/jivesoftware/smackx/search/UserSearchManager.java +++ b/source/org/jivesoftware/smackx/search/UserSearchManager.java @@ -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 ReportedData * * @param searchForm the Form 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; } + }