Search in sources :

Example 76 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method pushMamPreferences.

public void pushMamPreferences(Account account, Element prefs) {
    IqPacket set = new IqPacket(IqPacket.TYPE.SET);
    set.addChild(prefs);
    sendIqPacket(account, set, null);
}
Also used : IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 77 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class XmppConnection method sendPing.

public void sendPing() {
    if (!r()) {
        final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
        iq.setFrom(account.getJid());
        iq.addChild("ping", "urn:xmpp:ping");
        this.sendIqPacket(iq, null);
    }
    this.lastPingSent = SystemClock.elapsedRealtime();
}
Also used : IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 78 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class XmppConnection method sendServiceDiscoveryItems.

private void sendServiceDiscoveryItems(final Jid server) {
    mPendingServiceDiscoveries.incrementAndGet();
    final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
    iq.setTo(server.toDomainJid());
    iq.query("http://jabber.org/protocol/disco#items");
    this.sendIqPacket(iq, new OnIqPacketReceived() {

        @Override
        public void onIqPacketReceived(final Account account, final IqPacket packet) {
            if (packet.getType() == IqPacket.TYPE.RESULT) {
                HashSet<Jid> items = new HashSet<Jid>();
                final List<Element> elements = packet.query().getChildren();
                for (final Element element : elements) {
                    if (element.getName().equals("item")) {
                        final Jid jid = element.getAttributeAsJid("jid");
                        if (jid != null && !jid.equals(account.getServer())) {
                            items.add(jid);
                        }
                    }
                }
                for (Jid jid : items) {
                    sendServiceDiscoveryInfo(jid);
                }
            } else {
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco items of " + server);
            }
            if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
                if (mPendingServiceDiscoveries.decrementAndGet() == 0 && mWaitForDisco.compareAndSet(true, false)) {
                    finalizeBind();
                }
            }
        }
    });
}
Also used : Account(de.pixart.messenger.entities.Account) Jid(de.pixart.messenger.xmpp.jid.Jid) Element(de.pixart.messenger.xml.Element) List(java.util.List) ArrayList(java.util.ArrayList) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket) HashSet(java.util.HashSet)

Example 79 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class XmppConnection method sendStartSession.

private void sendStartSession() {
    Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": sending legacy session to outdated server");
    final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET);
    startSession.addChild("session", "urn:ietf:params:xml:ns:xmpp-session");
    this.sendUnmodifiedIqPacket(startSession, (account, packet) -> {
        if (packet.getType() == IqPacket.TYPE.RESULT) {
            sendPostBindInitialization();
        } else if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
            throw new StateChangingError(Account.State.SESSION_FAILURE);
        }
    }, true);
}
Also used : IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 80 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class XmppConnection method sendEnableCarbons.

private void sendEnableCarbons() {
    final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
    iq.addChild("enable", "urn:xmpp:carbons:2");
    this.sendIqPacket(iq, new OnIqPacketReceived() {

        @Override
        public void onIqPacketReceived(final Account account, final IqPacket packet) {
            if (!packet.hasChild("error")) {
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": successfully enabled carbons");
                features.carbonsEnabled = true;
            } else {
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": error enableing carbons " + packet.toString());
            }
        }
    });
}
Also used : Account(de.pixart.messenger.entities.Account) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Aggregations

IqPacket (de.pixart.messenger.xmpp.stanzas.IqPacket)81 Element (de.pixart.messenger.xml.Element)48 Account (de.pixart.messenger.entities.Account)39 OnIqPacketReceived (de.pixart.messenger.xmpp.OnIqPacketReceived)31 Jid (de.pixart.messenger.xmpp.jid.Jid)15 ArrayList (java.util.ArrayList)7 Data (de.pixart.messenger.xmpp.forms.Data)6 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)6 PreKeyBundle (org.whispersystems.libsignal.state.PreKeyBundle)5 JinglePacket (de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket)4 IOException (java.io.IOException)4 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)4 Bundle (android.os.Bundle)3 Pair (android.util.Pair)3 Contact (de.pixart.messenger.entities.Contact)3 Conversation (de.pixart.messenger.entities.Conversation)3 FileNotFoundException (java.io.FileNotFoundException)3 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 List (java.util.List)3