Search in sources :

Example 1 with EnablePacket

use of eu.siacs.conversations.xmpp.stanzas.streammgmt.EnablePacket in project Conversations by siacs.

the class XmppConnection method sendPostBindInitialization.

private void sendPostBindInitialization() {
    smVersion = 0;
    if (streamFeatures.hasChild("sm", "urn:xmpp:sm:3")) {
        smVersion = 3;
    } else if (streamFeatures.hasChild("sm", "urn:xmpp:sm:2")) {
        smVersion = 2;
    }
    if (smVersion != 0) {
        synchronized (this.mStanzaQueue) {
            final EnablePacket enable = new EnablePacket(smVersion);
            tagWriter.writeStanzaAsync(enable);
            stanzasSent = 0;
            mStanzaQueue.clear();
        }
    }
    features.carbonsEnabled = false;
    features.blockListRequested = false;
    synchronized (this.disco) {
        this.disco.clear();
    }
    Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": starting service discovery");
    mPendingServiceDiscoveries.set(0);
    if (smVersion == 0 || Patches.DISCO_EXCEPTIONS.contains(account.getJid().getDomain().toEscapedString())) {
        Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": do not wait for service discovery");
        mWaitForDisco.set(false);
    } else {
        mWaitForDisco.set(true);
    }
    lastDiscoStarted = SystemClock.elapsedRealtime();
    mXmppConnectionService.scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
    Element caps = streamFeatures.findChild("c");
    final String hash = caps == null ? null : caps.getAttribute("hash");
    final String ver = caps == null ? null : caps.getAttribute("ver");
    ServiceDiscoveryResult discoveryResult = null;
    if (hash != null && ver != null) {
        discoveryResult = mXmppConnectionService.getCachedServiceDiscoveryResult(new Pair<>(hash, ver));
    }
    final boolean requestDiscoItemsFirst = !account.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY);
    if (requestDiscoItemsFirst) {
        sendServiceDiscoveryItems(account.getDomain());
    }
    if (discoveryResult == null) {
        sendServiceDiscoveryInfo(account.getDomain());
    } else {
        Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": server caps came from cache");
        disco.put(account.getDomain(), discoveryResult);
    }
    discoverMamPreferences();
    sendServiceDiscoveryInfo(account.getJid().asBareJid());
    if (!requestDiscoItemsFirst) {
        sendServiceDiscoveryItems(account.getDomain());
    }
    if (!mWaitForDisco.get()) {
        finalizeBind();
    }
    this.lastSessionStarted = SystemClock.elapsedRealtime();
}
Also used : EnablePacket(eu.siacs.conversations.xmpp.stanzas.streammgmt.EnablePacket) ServiceDiscoveryResult(eu.siacs.conversations.entities.ServiceDiscoveryResult) Element(eu.siacs.conversations.xml.Element) Pair(android.util.Pair)

Aggregations

Pair (android.util.Pair)1 ServiceDiscoveryResult (eu.siacs.conversations.entities.ServiceDiscoveryResult)1 Element (eu.siacs.conversations.xml.Element)1 EnablePacket (eu.siacs.conversations.xmpp.stanzas.streammgmt.EnablePacket)1