1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-11 22:55:58 +01:00

[search] Return and expect the high-level forms API types

This commit is contained in:
Florian Schmaus 2021-05-02 22:02:40 +02:00
parent 6ec654ad1e
commit c9ea1c11b6

View file

@ -24,6 +24,8 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jxmpp.jid.DomainBareJid;
@ -38,7 +40,8 @@ import org.jxmpp.jid.DomainBareJid;
* con.login("john", "doe");
* UserSearchManager search = new UserSearchManager(con, "users.jabber.org");
* Form searchForm = search.getSearchForm();
* Form answerForm = searchForm.createAnswerForm();
* FillableForm answerForm = searchForm.getFillableForm()
* // Fill out the form.
* answerForm.setAnswer("last", "DeMoro");
* ReportedData data = search.getSearchResults(answerForm);
* // Use Returned Data
@ -71,8 +74,9 @@ public class UserSearchManager {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public DataForm getSearchForm(DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return userSearch.getSearchForm(con, searchService);
public Form getSearchForm(DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
DataForm dataForm = userSearch.getSearchForm(con, searchService);
return new Form(dataForm);
}
/**
@ -87,11 +91,12 @@ public class UserSearchManager {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public ReportedData getSearchResults(DataForm searchForm, DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return userSearch.sendSearchForm(con, searchForm, searchService);
public ReportedData getSearchResults(FillableForm searchForm, DomainBareJid searchService)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
DataForm dataForm = searchForm.getDataFormToSubmit();
return userSearch.sendSearchForm(con, dataForm, searchService);
}
/**
* Returns a collection of search services found on the server.
*