~singpolyma/cheogram-android

d29b33863b3dbe7a02bb885351a0a550634446ec — Stephen Paul Weber 2 years ago 04748f9
Fetch jabber:iq:gateway prompt
M src/main/java/eu/siacs/conversations/services/XmppConnectionService.java => src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +18 -0
@@ 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);

A src/main/java/eu/siacs/conversations/xmpp/OnGatewayPromptResult.java => src/main/java/eu/siacs/conversations/xmpp/OnGatewayPromptResult.java +7 -0
@@ 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);
}