1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +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.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; 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.jivesoftware.smackx.xdata.packet.DataForm;
import org.jxmpp.jid.DomainBareJid; import org.jxmpp.jid.DomainBareJid;
@ -38,7 +40,8 @@ import org.jxmpp.jid.DomainBareJid;
* con.login("john", "doe"); * con.login("john", "doe");
* UserSearchManager search = new UserSearchManager(con, "users.jabber.org"); * UserSearchManager search = new UserSearchManager(con, "users.jabber.org");
* Form searchForm = search.getSearchForm(); * Form searchForm = search.getSearchForm();
* Form answerForm = searchForm.createAnswerForm(); * FillableForm answerForm = searchForm.getFillableForm()
* // Fill out the form.
* answerForm.setAnswer("last", "DeMoro"); * answerForm.setAnswer("last", "DeMoro");
* ReportedData data = search.getSearchResults(answerForm); * ReportedData data = search.getSearchResults(answerForm);
* // Use Returned Data * // Use Returned Data
@ -71,8 +74,9 @@ public class UserSearchManager {
* @throws NotConnectedException if the XMPP connection is not connected. * @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public DataForm getSearchForm(DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { public Form getSearchForm(DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return userSearch.getSearchForm(con, searchService); 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 NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted. * @throws InterruptedException if the calling thread was interrupted.
*/ */
public ReportedData getSearchResults(DataForm searchForm, DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { public ReportedData getSearchResults(FillableForm searchForm, DomainBareJid searchService)
return userSearch.sendSearchForm(con, searchForm, 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. * Returns a collection of search services found on the server.
* *