Fetch jabber:iq:gateway prompt

This commit is contained in:
Stephen Paul Weber 2022-03-07 10:10:55 -05:00
parent 04748f92f9
commit d29b33863b
No known key found for this signature in database
GPG key ID: D11C2911CE519CDE
2 changed files with 25 additions and 0 deletions

View file

@ -145,6 +145,7 @@ import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.OnBindListener;
import eu.siacs.conversations.xmpp.OnContactStatusChanged;
import eu.siacs.conversations.xmpp.OnGatewayPromptResult;
import eu.siacs.conversations.xmpp.OnIqPacketReceived;
import eu.siacs.conversations.xmpp.OnKeyStatusUpdated;
import eu.siacs.conversations.xmpp.OnMessageAcknowledged;
@ -4655,6 +4656,23 @@ public class XmppConnectionService extends Service {
}
}
public void fetchGatewayPrompt(Account account, final Jid jid, final OnGatewayPromptResult callback) {
IqPacket request = new IqPacket(IqPacket.TYPE.GET);
request.setTo(jid);
request.query("jabber:iq:gateway");
sendIqPacket(account, request, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
callback.onGatewayPromptResult(packet.query().findChildContent("prompt"), null);
} else {
Element error = packet.findChild("error");
callback.onGatewayPromptResult(null, error == null ? null : error.findChildContent("text"));
}
}
});
}
public void fetchCaps(Account account, final Jid jid, final Presence presence) {
final Pair<String, String> key = new Pair<>(presence.getHash(), presence.getVer());
final ServiceDiscoveryResult disco = getCachedServiceDiscoveryResult(key);

View file

@ -0,0 +1,7 @@
package eu.siacs.conversations.xmpp;
public interface OnGatewayPromptResult {
// if prompt is null, there was an error
// errorText may or may not be set
public void onGatewayPromptResult(String prompt, String errorText);
}