思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c

以下内容为反编译后的 AbstractXMPPConnection.java 源代码,内容仅作参考


package org.jivesoftware.smack;

import com.taobao.weex.el.parse.Operators;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.lang.Thread;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackFuture;
import org.jivesoftware.smack.StanzaCollector;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.compress.packet.Compress;
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
import org.jivesoftware.smack.debugger.SmackDebugger;
import org.jivesoftware.smack.debugger.SmackDebuggerFactory;
import org.jivesoftware.smack.filter.IQReplyFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.StanzaIdFilter;
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
import org.jivesoftware.smack.packet.Bind;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Mechanisms;
import org.jivesoftware.smack.packet.Nonza;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Session;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StartTls;
import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.sasl.core.SASLAnonymous;
import org.jivesoftware.smack.util.Async;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.dns.DNSResolver;
import org.jivesoftware.smack.util.dns.HostAddress;
import org.xmlpull.v1.XmlPullParser;
public abstract class AbstractXMPPConnection implements XMPPConnection {
    public static final boolean $assertionsDisabled = false;
    public static final AsyncButOrdered<AbstractXMPPConnection> ASYNC_BUT_ORDERED;
    public static final ExecutorService CACHED_EXECUTOR_SERVICE;
    public static final ScheduledExecutorService SCHEDULED_EXECUTOR_SERVICE;
    public long authenticatedConnectionInitiallyEstablishedTimestamp;
    public XMPPInputOutputStream compressionHandler;
    public final ConnectionConfiguration config;
    public int currentAsyncRunnables;
    public final SmackDebugger debugger;
    public int deferredAsyncRunnablesCount;
    public int deferredAsyncRunnablesCountPrevious;
    public String host;
    public List<HostAddress> hostAddresses;
    public long lastStanzaReceived;
    public int port;
    public Reader reader;
    public final SASLAuthentication saslAuthentication;
    public String streamId;
    public String usedPassword;
    public hx3 usedResource;
    public String usedUsername;
    public uw3 user;
    public Writer writer;
    public qw3 xmppServiceDomain;
    public static final Logger LOGGER = Logger.getLogger(AbstractXMPPConnection.class.getName());
    public static final AtomicInteger connectionCounter = new AtomicInteger(0);
    public final Set<ConnectionListener> connectionListeners = new CopyOnWriteArraySet();
    public final Collection<StanzaCollector> collectors = new ConcurrentLinkedQueue();
    public final Map<StanzaListener, ListenerWrapper> syncRecvListeners = new LinkedHashMap();
    public final Map<StanzaListener, ListenerWrapper> asyncRecvListeners = new LinkedHashMap();
    public final Map<StanzaListener, ListenerWrapper> sendListeners = new HashMap();
    public final Map<StanzaListener, InterceptorWrapper> interceptors = new HashMap();
    public final Lock connectionLock = new ReentrantLock();
    public final Map<String, ExtensionElement> streamFeatures = new HashMap();
    public boolean connected = false;
    public long replyTimeout = SmackConfiguration.getDefaultReplyTimeout();
    public final SynchronizationPoint<SmackException> tlsHandled = new SynchronizationPoint<>(this, "establishing TLS");
    public final SynchronizationPoint<SmackException> lastFeaturesReceived = new SynchronizationPoint<>(this, "last stream features received from server");
    public final SynchronizationPoint<XMPPException> saslFeatureReceived = new SynchronizationPoint<>(this, "SASL mechanisms stream feature from server");
    public final int connectionCounterValue = connectionCounter.getAndIncrement();
    public XMPPConnection.FromMode fromMode = XMPPConnection.FromMode.OMITTED;
    public ParsingExceptionCallback parsingExceptionCallback = SmackConfiguration.getDefaultParsingExceptionCallback();
    public final Executor limitedExcutor = new Executor() {
        @Override
        public void execute(Runnable runnable) {
            AbstractXMPPConnection.this.asyncGoLimited(runnable);
        }
    };
    public boolean authenticated = false;
    public boolean wasAuthenticated = false;
    public final Map<String, IQRequestHandler> setIqRequestHandler = new HashMap();
    public final Map<String, IQRequestHandler> getIqRequestHandler = new HashMap();
    public SmackConfiguration.UnknownIqRequestReplyMode unknownIqRequestReplyMode = SmackConfiguration.getUnknownIqRequestReplyMode();
    public final Queue<Runnable> deferredAsyncRunnables = new LinkedList();
    public int maxAsyncRunnables = SmackConfiguration.getDefaultConcurrencyLevelLimit();

    public static class AnonymousClass15 {
        public static final int[] $SwitchMap$org$jivesoftware$smack$SmackConfiguration$UnknownIqRequestReplyMode;
        public static final int[] $SwitchMap$org$jivesoftware$smack$XMPPConnection$FromMode;
        public static final int[] $SwitchMap$org$jivesoftware$smack$iqrequest$IQRequestHandler$Mode = new int[IQRequestHandler.Mode.values().length];
        public static final int[] $SwitchMap$org$jivesoftware$smack$packet$IQ$Type;

        static {
            try {
                $SwitchMap$org$jivesoftware$smack$iqrequest$IQRequestHandler$Mode[IQRequestHandler.Mode.sync.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$iqrequest$IQRequestHandler$Mode[IQRequestHandler.Mode.async.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            $SwitchMap$org$jivesoftware$smack$SmackConfiguration$UnknownIqRequestReplyMode = new int[SmackConfiguration.UnknownIqRequestReplyMode.values().length];
            try {
                $SwitchMap$org$jivesoftware$smack$SmackConfiguration$UnknownIqRequestReplyMode[SmackConfiguration.UnknownIqRequestReplyMode.doNotReply.ordinal()] = 1;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$SmackConfiguration$UnknownIqRequestReplyMode[SmackConfiguration.UnknownIqRequestReplyMode.replyFeatureNotImplemented.ordinal()] = 2;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$SmackConfiguration$UnknownIqRequestReplyMode[SmackConfiguration.UnknownIqRequestReplyMode.replyServiceUnavailable.ordinal()] = 3;
            } catch (NoSuchFieldError unused5) {
            }
            $SwitchMap$org$jivesoftware$smack$packet$IQ$Type = new int[IQ.Type.values().length];
            try {
                $SwitchMap$org$jivesoftware$smack$packet$IQ$Type[IQ.Type.set.ordinal()] = 1;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$packet$IQ$Type[IQ.Type.get.ordinal()] = 2;
            } catch (NoSuchFieldError unused7) {
            }
            $SwitchMap$org$jivesoftware$smack$XMPPConnection$FromMode = new int[XMPPConnection.FromMode.values().length];
            try {
                $SwitchMap$org$jivesoftware$smack$XMPPConnection$FromMode[XMPPConnection.FromMode.OMITTED.ordinal()] = 1;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$XMPPConnection$FromMode[XMPPConnection.FromMode.USER.ordinal()] = 2;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$XMPPConnection$FromMode[XMPPConnection.FromMode.UNCHANGED.ordinal()] = 3;
            } catch (NoSuchFieldError unused10) {
            }
        }
    }

    public static class InterceptorWrapper {
        public final StanzaFilter packetFilter;
        public final StanzaListener packetInterceptor;

        public InterceptorWrapper(StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
            this.packetInterceptor = stanzaListener;
            this.packetFilter = stanzaFilter;
        }

        public boolean filterMatches(Stanza stanza) {
            StanzaFilter stanzaFilter = this.packetFilter;
            return stanzaFilter == null || stanzaFilter.accept(stanza);
        }

        public StanzaListener getInterceptor() {
            return this.packetInterceptor;
        }
    }

    public static class ListenerWrapper {
        public final StanzaFilter packetFilter;
        public final StanzaListener packetListener;

        public ListenerWrapper(StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
            this.packetListener = stanzaListener;
            this.packetFilter = stanzaFilter;
        }

        public boolean filterMatches(Stanza stanza) {
            StanzaFilter stanzaFilter = this.packetFilter;
            return stanzaFilter == null || stanzaFilter.accept(stanza);
        }

        public StanzaListener getListener() {
            return this.packetListener;
        }
    }

    static {
        SmackConfiguration.getVersion();
        SCHEDULED_EXECUTOR_SERVICE = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
            @Override
            public Thread newThread(Runnable runnable) {
                Thread thread = new Thread(runnable);
                thread.setName("Smack Scheduled Executor Service");
                thread.setDaemon(true);
                return thread;
            }
        });
        CACHED_EXECUTOR_SERVICE = Executors.newCachedThreadPool(new ThreadFactory() {
            @Override
            public Thread newThread(Runnable runnable) {
                Thread thread = new Thread(runnable);
                thread.setName("Smack Cached Executor");
                thread.setDaemon(true);
                thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
                    @Override
                    public void uncaughtException(Thread thread2, Throwable th) {
                        Logger logger = AbstractXMPPConnection.LOGGER;
                        Level level = Level.WARNING;
                        logger.log(level, thread2 + " encountered uncaught exception", th);
                    }
                });
                return thread;
            }
        });
        ASYNC_BUT_ORDERED = new AsyncButOrdered<>();
    }

    public AbstractXMPPConnection(ConnectionConfiguration connectionConfiguration) {
        this.saslAuthentication = new SASLAuthentication(this, connectionConfiguration);
        this.config = connectionConfiguration;
        SmackDebuggerFactory debuggerFactory = connectionConfiguration.getDebuggerFactory();
        if (debuggerFactory != null) {
            this.debugger = debuggerFactory.create(this);
        } else {
            this.debugger = null;
        }
        for (ConnectionCreationListener connectionCreationListener : XMPPConnectionRegistry.getConnectionCreationListeners()) {
            connectionCreationListener.connectionCreated(this);
        }
    }

    public static int access$210(AbstractXMPPConnection abstractXMPPConnection) {
        int i = abstractXMPPConnection.currentAsyncRunnables;
        abstractXMPPConnection.currentAsyncRunnables = i - 1;
        return i;
    }

    public static int access$310(AbstractXMPPConnection abstractXMPPConnection) {
        int i = abstractXMPPConnection.deferredAsyncRunnablesCount;
        abstractXMPPConnection.deferredAsyncRunnablesCount = i - 1;
        return i;
    }

    public static void asyncGo(Runnable runnable) {
        CACHED_EXECUTOR_SERVICE.execute(runnable);
    }

    private void firePacketInterceptors(Stanza stanza) {
        LinkedList<StanzaListener> linkedList = new LinkedList();
        synchronized (this.interceptors) {
            for (InterceptorWrapper interceptorWrapper : this.interceptors.values()) {
                if (interceptorWrapper.filterMatches(stanza)) {
                    linkedList.add(interceptorWrapper.getInterceptor());
                }
            }
        }
        for (StanzaListener stanzaListener : linkedList) {
            try {
                stanzaListener.processStanza(stanza);
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, "Packet interceptor threw exception", (Throwable) e);
            }
        }
    }

    public static ScheduledFuture<?> schedule(Runnable runnable, long j, TimeUnit timeUnit) {
        return SCHEDULED_EXECUTOR_SERVICE.schedule(runnable, j, timeUnit);
    }

    @Override
    public void addAsyncStanzaListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
        if (stanzaListener != null) {
            ListenerWrapper listenerWrapper = new ListenerWrapper(stanzaListener, stanzaFilter);
            synchronized (this.asyncRecvListeners) {
                this.asyncRecvListeners.put(stanzaListener, listenerWrapper);
            }
            return;
        }
        throw new NullPointerException("Packet listener is null.");
    }

    @Override
    public void addConnectionListener(ConnectionListener connectionListener) {
        if (connectionListener == null) {
            return;
        }
        this.connectionListeners.add(connectionListener);
    }

    @Override
    public void addOneTimeSyncCallback(final StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
        final StanzaListener stanzaListener2 = new StanzaListener() {
            @Override
            public void processStanza(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException {
                try {
                    stanzaListener.processStanza(stanza);
                } finally {
                    AbstractXMPPConnection.this.removeSyncStanzaListener(this);
                }
            }
        };
        addSyncStanzaListener(stanzaListener2, stanzaFilter);
        schedule(new Runnable() {
            @Override
            public void run() {
                AbstractXMPPConnection.this.removeSyncStanzaListener(stanzaListener2);
            }
        }, getReplyTimeout(), TimeUnit.MILLISECONDS);
    }

    @Override
    @Deprecated
    public void addPacketInterceptor(StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
        addStanzaInterceptor(stanzaListener, stanzaFilter);
    }

    @Override
    @Deprecated
    public void addPacketSendingListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
        addStanzaSendingListener(stanzaListener, stanzaFilter);
    }

    @Override
    public void addStanzaInterceptor(StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
        if (stanzaListener != null) {
            InterceptorWrapper interceptorWrapper = new InterceptorWrapper(stanzaListener, stanzaFilter);
            synchronized (this.interceptors) {
                this.interceptors.put(stanzaListener, interceptorWrapper);
            }
            return;
        }
        throw new NullPointerException("Packet interceptor is null.");
    }

    @Override
    public void addStanzaSendingListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
        if (stanzaListener != null) {
            ListenerWrapper listenerWrapper = new ListenerWrapper(stanzaListener, stanzaFilter);
            synchronized (this.sendListeners) {
                this.sendListeners.put(stanzaListener, listenerWrapper);
            }
            return;
        }
        throw new NullPointerException("Packet listener is null.");
    }

    public void addStreamFeature(ExtensionElement extensionElement) {
        this.streamFeatures.put(qx3.b(extensionElement.getElementName(), extensionElement.getNamespace()), extensionElement);
    }

    @Override
    public void addSyncStanzaListener(StanzaListener stanzaListener, StanzaFilter stanzaFilter) {
        if (stanzaListener != null) {
            ListenerWrapper listenerWrapper = new ListenerWrapper(stanzaListener, stanzaFilter);
            synchronized (this.syncRecvListeners) {
                this.syncRecvListeners.put(stanzaListener, listenerWrapper);
            }
            return;
        }
        throw new NullPointerException("Packet listener is null.");
    }

    public void afterFeaturesReceived() throws SmackException.SecurityRequiredException, SmackException.NotConnectedException, InterruptedException {
    }

    public void afterSuccessfulLogin(boolean z) throws SmackException.NotConnectedException, InterruptedException {
        if (!z) {
            this.authenticatedConnectionInitiallyEstablishedTimestamp = System.currentTimeMillis();
        }
        this.authenticated = true;
        SmackDebugger smackDebugger = this.debugger;
        if (smackDebugger != null) {
            smackDebugger.userHasLogged(this.user);
        }
        callConnectionAuthenticatedListener(z);
        if (!this.config.isSendPresence() || z) {
            return;
        }
        sendStanza(new Presence(Presence.Type.available));
    }

    public void asyncGoLimited(final Runnable runnable) {
        Runnable runnable2 = new Runnable() {
            @Override
            public void run() {
                runnable.run();
                synchronized (AbstractXMPPConnection.this.deferredAsyncRunnables) {
                    Runnable runnable3 = (Runnable) AbstractXMPPConnection.this.deferredAsyncRunnables.poll();
                    if (runnable3 == null) {
                        AbstractXMPPConnection.access$210(AbstractXMPPConnection.this);
                    } else {
                        AbstractXMPPConnection.access$310(AbstractXMPPConnection.this);
                        AbstractXMPPConnection.asyncGo(runnable3);
                    }
                }
            }
        };
        synchronized (this.deferredAsyncRunnables) {
            if (this.currentAsyncRunnables < this.maxAsyncRunnables) {
                this.currentAsyncRunnables++;
                asyncGo(runnable2);
            } else {
                this.deferredAsyncRunnablesCount++;
                this.deferredAsyncRunnables.add(runnable2);
            }
            int i = this.deferredAsyncRunnablesCount;
            if (i >= 100 && this.deferredAsyncRunnablesCountPrevious < 100) {
                LOGGER.log(Level.WARNING, "High watermark of 100 simultaneous executing runnables reached");
            } else if (i >= 20 && this.deferredAsyncRunnablesCountPrevious < 20) {
                LOGGER.log(Level.INFO, "20 simultaneous executing runnables reached");
            }
            this.deferredAsyncRunnablesCountPrevious = i;
        }
    }

    public void bindResourceAndEstablishSession(hx3 hx3Var) throws XMPPException.XMPPErrorException, SmackException, InterruptedException {
        LOGGER.finer("Waiting for last features to be received before continuing with resource binding");
        this.lastFeaturesReceived.checkIfSuccessOrWaitOrThrow();
        if (hasFeature(Bind.ELEMENT, Bind.NAMESPACE)) {
            Bind newSet = Bind.newSet(hx3Var);
            this.user = ((Bind) createStanzaCollectorAndSend(new StanzaIdFilter(newSet), newSet).nextResultOrThrow()).getJid();
            this.xmppServiceDomain = this.user.g0();
            Session.Feature feature = (Session.Feature) getFeature("session", Session.NAMESPACE);
            if (feature == null || feature.isOptional()) {
                return;
            }
            Session session = new Session();
            createStanzaCollectorAndSend(new StanzaIdFilter(session), session).nextResultOrThrow();
            return;
        }
        throw new SmackException.ResourceBindingNotOfferedException();
    }

    public void callConnectionAuthenticatedListener(boolean z) {
        for (ConnectionListener connectionListener : this.connectionListeners) {
            try {
                connectionListener.authenticated(this, z);
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, "Exception in authenticated listener", (Throwable) e);
            }
        }
    }

    public void callConnectionClosedListener() {
        for (ConnectionListener connectionListener : this.connectionListeners) {
            try {
                connectionListener.connectionClosed();
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, "Error in listener while closing connection", (Throwable) e);
            }
        }
    }

    public void callConnectionClosedOnErrorListener(Exception exc) {
        boolean z;
        if ((exc instanceof XMPPException.StreamErrorException) && ((XMPPException.StreamErrorException) exc).getStreamError().getCondition() == StreamError.Condition.not_authorized && this.wasAuthenticated) {
            z = false;
            LOGGER.log(Level.FINE, "Connection closed with not-authorized stream error after it was already authenticated. The account was likely deleted/unregistered on the server");
        } else {
            z = true;
        }
        if (z) {
            Logger logger = LOGGER;
            Level level = Level.WARNING;
            logger.log(level, "Connection " + this + " closed with error", (Throwable) exc);
        }
        for (ConnectionListener connectionListener : this.connectionListeners) {
            try {
                connectionListener.connectionClosedOnError(exc);
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, "Error in listener while closing connection", (Throwable) e);
            }
        }
    }

    public void callConnectionConnectedListener() {
        for (ConnectionListener connectionListener : this.connectionListeners) {
            connectionListener.connected(this);
        }
    }

    public synchronized AbstractXMPPConnection connect() throws SmackException, IOException, XMPPException, InterruptedException {
        throwAlreadyConnectedExceptionIfAppropriate();
        initState();
        this.saslAuthentication.init();
        this.streamId = null;
        try {
            connectInternal();
            if (!isSecureConnection() && getConfiguration().getSecurityMode() == ConnectionConfiguration.SecurityMode.required) {
                throw new SmackException.SecurityRequiredByClientException();
            }
            this.connected = true;
            callConnectionConnectedListener();
        } catch (IOException | InterruptedException | SmackException | XMPPException e) {
            instantShutdown();
            throw e;
        }
        return this;
    }

    public abstract void connectInternal() throws SmackException, IOException, XMPPException, InterruptedException;

    @Override
    public StanzaCollector createStanzaCollector(StanzaFilter stanzaFilter) {
        return createStanzaCollector(StanzaCollector.newConfiguration().setStanzaFilter(stanzaFilter));
    }

    @Override
    public StanzaCollector createStanzaCollectorAndSend(IQ iq) throws SmackException.NotConnectedException, InterruptedException {
        return createStanzaCollectorAndSend(new IQReplyFilter(iq, this), iq);
    }

    public void disconnect() {
        try {
            disconnect(isAuthenticated() ? new Presence(Presence.Type.unavailable) : null);
        } catch (SmackException.NotConnectedException e) {
            LOGGER.log(Level.FINEST, "Connection is already disconnected", (Throwable) e);
        }
    }

    public void firePacketSendingListeners(final Stanza stanza) {
        SmackDebugger smackDebugger = this.debugger;
        if (smackDebugger != null) {
            smackDebugger.onOutgoingStreamElement(stanza);
        }
        final LinkedList linkedList = new LinkedList();
        synchronized (this.sendListeners) {
            for (ListenerWrapper listenerWrapper : this.sendListeners.values()) {
                if (listenerWrapper.filterMatches(stanza)) {
                    linkedList.add(listenerWrapper.getListener());
                }
            }
        }
        if (linkedList.isEmpty()) {
            return;
        }
        asyncGo(new Runnable() {
            @Override
            public void run() {
                for (StanzaListener stanzaListener : linkedList) {
                    try {
                        stanzaListener.processStanza(stanza);
                    } catch (Exception e) {
                        AbstractXMPPConnection.LOGGER.log(Level.WARNING, "Sending listener threw exception", (Throwable) e);
                    }
                }
            }
        });
    }

    public final long getAuthenticatedConnectionInitiallyEstablishedTimestamp() {
        return this.authenticatedConnectionInitiallyEstablishedTimestamp;
    }

    public ConnectionConfiguration getConfiguration() {
        return this.config;
    }

    @Override
    public int getConnectionCounter() {
        return this.connectionCounterValue;
    }

    public Lock getConnectionLock() {
        return this.connectionLock;
    }

    @Override
    public <F extends ExtensionElement> F getFeature(String str, String str2) {
        return (F) this.streamFeatures.get(qx3.b(str, str2));
    }

    @Override
    public XMPPConnection.FromMode getFromMode() {
        return this.fromMode;
    }

    @Override
    public String getHost() {
        return this.host;
    }

    @Override
    public long getLastStanzaReceived() {
        return this.lastStanzaReceived;
    }

    public ParsingExceptionCallback getParsingExceptionCallback() {
        return this.parsingExceptionCallback;
    }

    @Override
    public int getPort() {
        return this.port;
    }

    @Override
    public long getReplyTimeout() {
        return this.replyTimeout;
    }

    public SASLAuthentication getSASLAuthentication() {
        return this.saslAuthentication;
    }

    @Override
    public String getStreamId() {
        if (isConnected()) {
            return this.streamId;
        }
        return null;
    }

    public final String getUsedSaslMechansism() {
        return this.saslAuthentication.getNameOfLastUsedSaslMechansism();
    }

    @Override
    public final uw3 getUser() {
        return this.user;
    }

    @Override
    public qw3 getXMPPServiceDomain() {
        qw3 qw3Var = this.xmppServiceDomain;
        return qw3Var != null ? qw3Var : this.config.getXMPPServiceDomain();
    }

    @Override
    public boolean hasFeature(String str, String str2) {
        return getFeature(str, str2) != null;
    }

    public void initDebugger() {
        Reader reader = this.reader;
        if (reader != null && this.writer != null) {
            SmackDebugger smackDebugger = this.debugger;
            if (smackDebugger != null) {
                this.reader = smackDebugger.newConnectionReader(reader);
                this.writer = this.debugger.newConnectionWriter(this.writer);
                return;
            }
            return;
        }
        throw new NullPointerException("Reader or writer isn't initialized.");
    }

    public void initState() {
        this.saslFeatureReceived.init();
        this.lastFeaturesReceived.init();
        this.tlsHandled.init();
    }

    public abstract void instantShutdown();

    public void invokeStanzaCollectorsAndNotifyRecvListeners(final Stanza stanza) {
        final IQRequestHandler iQRequestHandler;
        StanzaError.Condition condition;
        if (stanza instanceof IQ) {
            final IQ iq = (IQ) stanza;
            if (iq.isRequestIQ()) {
                String b = qx3.b(iq.getChildElementName(), iq.getChildElementNamespace());
                int i = AnonymousClass15.$SwitchMap$org$jivesoftware$smack$packet$IQ$Type[iq.getType().ordinal()];
                if (i == 1) {
                    synchronized (this.setIqRequestHandler) {
                        iQRequestHandler = this.setIqRequestHandler.get(b);
                    }
                } else if (i == 2) {
                    synchronized (this.getIqRequestHandler) {
                        iQRequestHandler = this.getIqRequestHandler.get(b);
                    }
                } else {
                    throw new IllegalStateException("Should only encounter IQ type 'get' or 'set'");
                }
                if (iQRequestHandler == null) {
                    int i2 = AnonymousClass15.$SwitchMap$org$jivesoftware$smack$SmackConfiguration$UnknownIqRequestReplyMode[this.unknownIqRequestReplyMode.ordinal()];
                    if (i2 != 1) {
                        if (i2 == 2) {
                            condition = StanzaError.Condition.feature_not_implemented;
                        } else if (i2 == 3) {
                            condition = StanzaError.Condition.service_unavailable;
                        } else {
                            throw new AssertionError();
                        }
                        try {
                            sendStanza(IQ.createErrorResponse(iq, StanzaError.getBuilder(condition)));
                            return;
                        } catch (InterruptedException | SmackException.NotConnectedException e) {
                            LOGGER.log(Level.WARNING, "Exception while sending error IQ to unkown IQ request", e);
                            return;
                        }
                    }
                    return;
                }
                Executor executor = null;
                int i3 = AnonymousClass15.$SwitchMap$org$jivesoftware$smack$iqrequest$IQRequestHandler$Mode[iQRequestHandler.getMode().ordinal()];
                if (i3 == 1) {
                    executor = ASYNC_BUT_ORDERED.asExecutorFor(this);
                } else if (i3 == 2) {
                    executor = this.limitedExcutor;
                }
                executor.execute(new Runnable() {
                    public static final boolean $assertionsDisabled = false;

                    @Override
                    public void run() {
                        IQ handleIQRequest = iQRequestHandler.handleIQRequest(iq);
                        if (handleIQRequest == null) {
                            return;
                        }
                        handleIQRequest.setTo(iq.getFrom());
                        handleIQRequest.setStanzaId(iq.getStanzaId());
                        try {
                            AbstractXMPPConnection.this.sendStanza(handleIQRequest);
                        } catch (InterruptedException | SmackException.NotConnectedException e2) {
                            AbstractXMPPConnection.LOGGER.log(Level.WARNING, "Exception while sending response to IQ request", e2);
                        }
                    }
                });
                return;
            }
        }
        final LinkedList<StanzaListener> linkedList = new LinkedList();
        synchronized (this.asyncRecvListeners) {
            for (ListenerWrapper listenerWrapper : this.asyncRecvListeners.values()) {
                if (listenerWrapper.filterMatches(stanza)) {
                    linkedList.add(listenerWrapper.getListener());
                }
            }
        }
        for (final StanzaListener stanzaListener : linkedList) {
            asyncGoLimited(new Runnable() {
                @Override
                public void run() {
                    try {
                        stanzaListener.processStanza(stanza);
                    } catch (Exception e2) {
                        AbstractXMPPConnection.LOGGER.log(Level.SEVERE, "Exception in async packet listener", (Throwable) e2);
                    }
                }
            });
        }
        for (StanzaCollector stanzaCollector : this.collectors) {
            stanzaCollector.processStanza(stanza);
        }
        linkedList.clear();
        synchronized (this.syncRecvListeners) {
            for (ListenerWrapper listenerWrapper2 : this.syncRecvListeners.values()) {
                if (listenerWrapper2.filterMatches(stanza)) {
                    linkedList.add(listenerWrapper2.getListener());
                }
            }
        }
        ASYNC_BUT_ORDERED.performAsyncButOrdered(this, new Runnable() {
            @Override
            public void run() {
                for (StanzaListener stanzaListener2 : linkedList) {
                    try {
                        stanzaListener2.processStanza(stanza);
                    } catch (SmackException.NotConnectedException e2) {
                        AbstractXMPPConnection.LOGGER.log(Level.WARNING, "Got not connected exception, aborting", (Throwable) e2);
                        return;
                    } catch (Exception e3) {
                        AbstractXMPPConnection.LOGGER.log(Level.SEVERE, "Exception in packet listener", (Throwable) e3);
                    }
                }
            }
        });
    }

    @Override
    public final boolean isAnonymous() {
        return isAuthenticated() && SASLAnonymous.NAME.equals(getUsedSaslMechansism());
    }

    @Override
    public final boolean isAuthenticated() {
        return this.authenticated;
    }

    @Override
    public final boolean isConnected() {
        return this.connected;
    }

    @Override
    public abstract boolean isSecureConnection();

    @Override
    public abstract boolean isUsingCompression();

    public synchronized void login() throws XMPPException, SmackException, IOException, InterruptedException {
        login(this.usedUsername != null ? this.usedUsername : this.config.getUsername(), this.usedPassword != null ? this.usedPassword : this.config.getPassword(), this.usedResource != null ? this.usedResource : this.config.getResource());
    }

    public abstract void loginInternal(String str, String str2, hx3 hx3Var) throws XMPPException, SmackException, IOException, InterruptedException;

    public void parseAndProcessStanza(XmlPullParser xmlPullParser) throws Exception {
        Stanza stanza;
        ParserUtils.assertAtStartTag(xmlPullParser);
        int depth = xmlPullParser.getDepth();
        try {
            stanza = PacketParserUtils.parseStanza(xmlPullParser);
        } catch (Exception e) {
            UnparseableStanza unparseableStanza = new UnparseableStanza(PacketParserUtils.parseContentDepth(xmlPullParser, depth), e);
            ParsingExceptionCallback parsingExceptionCallback = getParsingExceptionCallback();
            if (parsingExceptionCallback != null) {
                parsingExceptionCallback.handleUnparsableStanza(unparseableStanza);
            }
            stanza = null;
        }
        ParserUtils.assertAtEndTag(xmlPullParser);
        if (stanza != null) {
            processStanza(stanza);
        }
    }

    public final void parseFeatures(XmlPullParser xmlPullParser) throws Exception {
        char c;
        this.streamFeatures.clear();
        int depth = xmlPullParser.getDepth();
        while (true) {
            int next = xmlPullParser.next();
            if (next == 2 && xmlPullParser.getDepth() == depth + 1) {
                ExtensionElement extensionElement = null;
                String name = xmlPullParser.getName();
                String namespace = xmlPullParser.getNamespace();
                switch (name.hashCode()) {
                    case -676919238:
                        if (name.equals(Mechanisms.ELEMENT)) {
                            c = 1;
                            break;
                        }
                        c = 65535;
                        break;
                    case 3023933:
                        if (name.equals(Bind.ELEMENT)) {
                            c = 2;
                            break;
                        }
                        c = 65535;
                        break;
                    case 1316817241:
                        if (name.equals(StartTls.ELEMENT)) {
                            c = 0;
                            break;
                        }
                        c = 65535;
                        break;
                    case 1431984486:
                        if (name.equals(Compress.Feature.ELEMENT)) {
                            c = 4;
                            break;
                        }
                        c = 65535;
                        break;
                    case 1984987798:
                        if (name.equals("session")) {
                            c = 3;
                            break;
                        }
                        c = 65535;
                        break;
                    default:
                        c = 65535;
                        break;
                }
                if (c == 0) {
                    extensionElement = PacketParserUtils.parseStartTlsFeature(xmlPullParser);
                } else if (c == 1) {
                    extensionElement = new Mechanisms(PacketParserUtils.parseMechanisms(xmlPullParser));
                } else if (c == 2) {
                    extensionElement = Bind.Feature.INSTANCE;
                } else if (c == 3) {
                    extensionElement = PacketParserUtils.parseSessionFeature(xmlPullParser);
                } else if (c != 4) {
                    ExtensionElementProvider<ExtensionElement> streamFeatureProvider = ProviderManager.getStreamFeatureProvider(name, namespace);
                    if (streamFeatureProvider != null) {
                        extensionElement = (ExtensionElement) streamFeatureProvider.parse(xmlPullParser);
                    }
                } else {
                    extensionElement = PacketParserUtils.parseCompressionFeature(xmlPullParser);
                }
                if (extensionElement != null) {
                    addStreamFeature(extensionElement);
                }
            } else if (next == 3 && xmlPullParser.getDepth() == depth) {
                if (hasFeature(Mechanisms.ELEMENT, "urn:ietf:params:xml:ns:xmpp-sasl") && (!hasFeature(StartTls.ELEMENT, StartTls.NAMESPACE) || this.config.getSecurityMode() == ConnectionConfiguration.SecurityMode.disabled)) {
                    this.tlsHandled.reportSuccess();
                    this.saslFeatureReceived.reportSuccess();
                }
                if (hasFeature(Bind.ELEMENT, Bind.NAMESPACE) && (!hasFeature(Compress.Feature.ELEMENT, "http://jabber.org/protocol/compress") || !this.config.isCompressionEnabled())) {
                    this.lastFeaturesReceived.reportSuccess();
                }
                afterFeaturesReceived();
                return;
            }
        }
    }

    public List<HostAddress> populateHostAddresses() {
        LinkedList linkedList = new LinkedList();
        ConnectionConfiguration connectionConfiguration = this.config;
        if (connectionConfiguration.hostAddress != null) {
            this.hostAddresses = new ArrayList(1);
            ConnectionConfiguration connectionConfiguration2 = this.config;
            this.hostAddresses.add(new HostAddress(connectionConfiguration2.port, connectionConfiguration2.hostAddress));
        } else if (connectionConfiguration.host != null) {
            this.hostAddresses = new ArrayList(1);
            DNSResolver dNSResolver = DNSUtil.getDNSResolver();
            ConnectionConfiguration connectionConfiguration3 = this.config;
            HostAddress lookupHostAddress = dNSResolver.lookupHostAddress(connectionConfiguration3.host, connectionConfiguration3.port, linkedList, connectionConfiguration3.getDnssecMode());
            if (lookupHostAddress != null) {
                this.hostAddresses.add(lookupHostAddress);
            }
        } else {
            this.hostAddresses = DNSUtil.resolveXMPPServiceDomain(ez3.b(connectionConfiguration.getXMPPServiceDomain()), linkedList, this.config.getDnssecMode());
        }
        return linkedList;
    }

    public void processStanza(Stanza stanza) throws InterruptedException {
        SmackDebugger smackDebugger = this.debugger;
        if (smackDebugger != null) {
            smackDebugger.onIncomingStreamElement(stanza);
        }
        this.lastStanzaReceived = System.currentTimeMillis();
        invokeStanzaCollectorsAndNotifyRecvListeners(stanza);
    }

    @Override
    public IQRequestHandler registerIQRequestHandler(IQRequestHandler iQRequestHandler) {
        IQRequestHandler put;
        IQRequestHandler put2;
        String b = qx3.b(iQRequestHandler.getElement(), iQRequestHandler.getNamespace());
        int i = AnonymousClass15.$SwitchMap$org$jivesoftware$smack$packet$IQ$Type[iQRequestHandler.getType().ordinal()];
        if (i == 1) {
            synchronized (this.setIqRequestHandler) {
                put = this.setIqRequestHandler.put(b, iQRequestHandler);
            }
            return put;
        } else if (i == 2) {
            synchronized (this.getIqRequestHandler) {
                put2 = this.getIqRequestHandler.put(b, iQRequestHandler);
            }
            return put2;
        } else {
            throw new IllegalArgumentException("Only IQ type of 'get' and 'set' allowed");
        }
    }

    @Override
    public boolean removeAsyncStanzaListener(StanzaListener stanzaListener) {
        boolean z;
        synchronized (this.asyncRecvListeners) {
            z = this.asyncRecvListeners.remove(stanzaListener) != null;
        }
        return z;
    }

    @Override
    public void removeConnectionListener(ConnectionListener connectionListener) {
        this.connectionListeners.remove(connectionListener);
    }

    @Override
    @Deprecated
    public void removePacketInterceptor(StanzaListener stanzaListener) {
        removeStanzaInterceptor(stanzaListener);
    }

    @Override
    @Deprecated
    public void removePacketSendingListener(StanzaListener stanzaListener) {
        removeStanzaSendingListener(stanzaListener);
    }

    @Override
    public void removeStanzaCollector(StanzaCollector stanzaCollector) {
        this.collectors.remove(stanzaCollector);
    }

    @Override
    public void removeStanzaInterceptor(StanzaListener stanzaListener) {
        synchronized (this.interceptors) {
            this.interceptors.remove(stanzaListener);
        }
    }

    @Override
    public void removeStanzaSendingListener(StanzaListener stanzaListener) {
        synchronized (this.sendListeners) {
            this.sendListeners.remove(stanzaListener);
        }
    }

    @Override
    public boolean removeSyncStanzaListener(StanzaListener stanzaListener) {
        boolean z;
        synchronized (this.syncRecvListeners) {
            z = this.syncRecvListeners.remove(stanzaListener) != null;
        }
        return z;
    }

    @Override
    public <S extends Stanza> SmackFuture<S, Exception> sendAsync(S s, StanzaFilter stanzaFilter) {
        return sendAsync(s, stanzaFilter, getReplyTimeout());
    }

    @Override
    public <I extends IQ> I sendIqRequestAndWaitForResponse(IQ iq) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
        return (I) createStanzaCollectorAndSend(iq).nextResultOrThrow();
    }

    @Override
    public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ iq) {
        return sendIqRequestAsync(iq, getReplyTimeout());
    }

    @Override
    public void sendIqWithResponseCallback(IQ iq, StanzaListener stanzaListener) throws SmackException.NotConnectedException, InterruptedException {
        sendIqWithResponseCallback(iq, stanzaListener, null);
    }

    @Override
    public abstract void sendNonza(Nonza nonza) throws SmackException.NotConnectedException, InterruptedException;

    @Override
    public void sendStanza(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException {
        Objects.requireNonNull(stanza, "Stanza must not be null");
        throwNotConnectedExceptionIfAppropriate();
        int i = AnonymousClass15.$SwitchMap$org$jivesoftware$smack$XMPPConnection$FromMode[this.fromMode.ordinal()];
        if (i == 1) {
            stanza.setFrom((xw3) null);
        } else if (i == 2) {
            stanza.setFrom(getUser());
        }
        firePacketInterceptors(stanza);
        sendStanzaInternal(stanza);
    }

    public abstract void sendStanzaInternal(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException;

    @Override
    public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter stanzaFilter, StanzaListener stanzaListener) throws SmackException.NotConnectedException, InterruptedException {
        sendStanzaWithResponseCallback(stanza, stanzaFilter, stanzaListener, null);
    }

    @Override
    public void setFromMode(XMPPConnection.FromMode fromMode) {
        this.fromMode = fromMode;
    }

    public void setMaxAsyncOperations(int i) {
        if (i >= 1) {
            synchronized (this.deferredAsyncRunnables) {
                this.maxAsyncRunnables = i;
            }
            return;
        }
        throw new IllegalArgumentException("Max async operations must be greater than 0");
    }

    public void setParsingExceptionCallback(ParsingExceptionCallback parsingExceptionCallback) {
        this.parsingExceptionCallback = parsingExceptionCallback;
    }

    @Override
    public void setReplyTimeout(long j) {
        this.replyTimeout = j;
    }

    public void setUnknownIqRequestReplyMode(SmackConfiguration.UnknownIqRequestReplyMode unknownIqRequestReplyMode) {
        this.unknownIqRequestReplyMode = (SmackConfiguration.UnknownIqRequestReplyMode) Objects.requireNonNull(unknownIqRequestReplyMode, "Mode must not be null");
    }

    public void setWasAuthenticated() {
        if (this.wasAuthenticated) {
            return;
        }
        this.wasAuthenticated = this.authenticated;
    }

    public abstract void shutdown();

    public void throwAlreadyConnectedExceptionIfAppropriate() throws SmackException.AlreadyConnectedException {
        if (isConnected()) {
            throw new SmackException.AlreadyConnectedException();
        }
    }

    public void throwAlreadyLoggedInExceptionIfAppropriate() throws SmackException.AlreadyLoggedInException {
        if (isAuthenticated()) {
            throw new SmackException.AlreadyLoggedInException();
        }
    }

    public void throwNotConnectedExceptionIfAppropriate() throws SmackException.NotConnectedException {
        throwNotConnectedExceptionIfAppropriate(null);
    }

    public final String toString() {
        uw3 user = getUser();
        String obj = user == null ? "not-authenticated" : user.toString();
        return getClass().getSimpleName() + Operators.ARRAY_START + obj + "] (" + getConnectionCounter() + Operators.BRACKET_END;
    }

    @Override
    public final IQRequestHandler unregisterIQRequestHandler(IQRequestHandler iQRequestHandler) {
        return unregisterIQRequestHandler(iQRequestHandler.getElement(), iQRequestHandler.getNamespace(), iQRequestHandler.getType());
    }

    @Override
    public <S extends Stanza> SmackFuture<S, Exception> sendAsync(S s, final StanzaFilter stanzaFilter, long j) {
        Objects.requireNonNull(s, "stanza must not be null");
        Objects.requireNonNull(stanzaFilter, "replyFilter must not be null");
        final SmackFuture.InternalSmackFuture internalSmackFuture = new SmackFuture.InternalSmackFuture();
        final StanzaListener stanzaListener = new StanzaListener() {
            @Override
            public void processStanza(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException {
                if (AbstractXMPPConnection.this.removeAsyncStanzaListener(this)) {
                    try {
                        XMPPException.XMPPErrorException.ifHasErrorThenThrow(stanza);
                        internalSmackFuture.setResult(stanza);
                    } catch (XMPPException.XMPPErrorException e) {
                        internalSmackFuture.setException(e);
                    }
                }
            }
        };
        schedule(new Runnable() {
            @Override
            public void run() {
                SmackException newWith;
                if (AbstractXMPPConnection.this.removeAsyncStanzaListener(stanzaListener)) {
                    if (!AbstractXMPPConnection.this.isConnected()) {
                        newWith = new SmackException.NotConnectedException(AbstractXMPPConnection.this, stanzaFilter);
                    } else {
                        newWith = SmackException.NoResponseException.newWith(AbstractXMPPConnection.this, stanzaFilter);
                    }
                    internalSmackFuture.setException(newWith);
                }
            }
        }, j, TimeUnit.MILLISECONDS);
        addAsyncStanzaListener(stanzaListener, stanzaFilter);
        try {
            sendStanza(s);
        } catch (InterruptedException | SmackException.NotConnectedException e) {
            internalSmackFuture.setException(e);
        }
        return internalSmackFuture;
    }

    @Override
    public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ iq, long j) {
        return sendAsync(iq, new IQReplyFilter(iq, this), j);
    }

    @Override
    public void sendIqWithResponseCallback(IQ iq, StanzaListener stanzaListener, ExceptionCallback exceptionCallback) throws SmackException.NotConnectedException, InterruptedException {
        sendIqWithResponseCallback(iq, stanzaListener, exceptionCallback, getReplyTimeout());
    }

    @Override
    public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter stanzaFilter, StanzaListener stanzaListener, ExceptionCallback exceptionCallback) throws SmackException.NotConnectedException, InterruptedException {
        sendStanzaWithResponseCallback(stanza, stanzaFilter, stanzaListener, exceptionCallback, getReplyTimeout());
    }

    public void throwNotConnectedExceptionIfAppropriate(String str) throws SmackException.NotConnectedException {
        if (!isConnected()) {
            throw new SmackException.NotConnectedException(str);
        }
    }

    @Override
    public StanzaCollector createStanzaCollector(StanzaCollector.Configuration configuration) {
        StanzaCollector stanzaCollector = new StanzaCollector(this, configuration);
        this.collectors.add(stanzaCollector);
        return stanzaCollector;
    }

    @Override
    public StanzaCollector createStanzaCollectorAndSend(StanzaFilter stanzaFilter, Stanza stanza) throws SmackException.NotConnectedException, InterruptedException {
        StanzaCollector createStanzaCollector = createStanzaCollector(StanzaCollector.newConfiguration().setStanzaFilter(stanzaFilter).setRequest(stanza));
        try {
            sendStanza(stanza);
            return createStanzaCollector;
        } catch (InterruptedException | RuntimeException | SmackException.NotConnectedException e) {
            createStanzaCollector.cancel();
            throw e;
        }
    }

    @Override
    public void sendIqWithResponseCallback(IQ iq, StanzaListener stanzaListener, ExceptionCallback exceptionCallback, long j) throws SmackException.NotConnectedException, InterruptedException {
        sendStanzaWithResponseCallback(iq, new IQReplyFilter(iq, this), stanzaListener, exceptionCallback, j);
    }

    @Override
    public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter stanzaFilter, final StanzaListener stanzaListener, final ExceptionCallback exceptionCallback, long j) throws SmackException.NotConnectedException, InterruptedException {
        Objects.requireNonNull(stanza, "stanza must not be null");
        Objects.requireNonNull(stanzaFilter, "replyFilter must not be null");
        Objects.requireNonNull(stanzaListener, "callback must not be null");
        final StanzaListener stanzaListener2 = new StanzaListener() {
            @Override
            public void processStanza(Stanza stanza2) throws SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException {
                if (AbstractXMPPConnection.this.removeAsyncStanzaListener(this)) {
                    try {
                        XMPPException.XMPPErrorException.ifHasErrorThenThrow(stanza2);
                        stanzaListener.processStanza(stanza2);
                    } catch (XMPPException.XMPPErrorException e) {
                        ExceptionCallback exceptionCallback2 = exceptionCallback;
                        if (exceptionCallback2 != null) {
                            exceptionCallback2.processException(e);
                        }
                    }
                }
            }
        };
        schedule(new Runnable() {
            @Override
            public void run() {
                final Exception newWith;
                if (!AbstractXMPPConnection.this.removeAsyncStanzaListener(stanzaListener2) || exceptionCallback == null) {
                    return;
                }
                if (!AbstractXMPPConnection.this.isConnected()) {
                    newWith = new SmackException.NotConnectedException(AbstractXMPPConnection.this, stanzaFilter);
                } else {
                    newWith = SmackException.NoResponseException.newWith(AbstractXMPPConnection.this, stanzaFilter);
                }
                Async.go(new Runnable() {
                    @Override
                    public void run() {
                        exceptionCallback.processException(newWith);
                    }
                });
            }
        }, j, TimeUnit.MILLISECONDS);
        addAsyncStanzaListener(stanzaListener2, stanzaFilter);
        sendStanza(stanza);
    }

    @Override
    public IQRequestHandler unregisterIQRequestHandler(String str, String str2, IQ.Type type) {
        IQRequestHandler remove;
        IQRequestHandler remove2;
        String b = qx3.b(str, str2);
        int i = AnonymousClass15.$SwitchMap$org$jivesoftware$smack$packet$IQ$Type[type.ordinal()];
        if (i == 1) {
            synchronized (this.setIqRequestHandler) {
                remove = this.setIqRequestHandler.remove(b);
            }
            return remove;
        } else if (i == 2) {
            synchronized (this.getIqRequestHandler) {
                remove2 = this.getIqRequestHandler.remove(b);
            }
            return remove2;
        } else {
            throw new IllegalArgumentException("Only IQ type of 'get' and 'set' allowed");
        }
    }

    public synchronized void disconnect(Presence presence) throws SmackException.NotConnectedException {
        if (presence != null) {
            try {
                sendStanza(presence);
            } catch (InterruptedException e) {
                LOGGER.log(Level.FINE, "Was interrupted while sending unavailable presence. Continuing to disconnect the connection", (Throwable) e);
            }
        }
        shutdown();
        callConnectionClosedListener();
    }

    public synchronized void login(CharSequence charSequence, String str) throws XMPPException, SmackException, IOException, InterruptedException {
        login(charSequence, str, this.config.getResource());
    }

    public synchronized void login(CharSequence charSequence, String str, hx3 hx3Var) throws XMPPException, SmackException, IOException, InterruptedException {
        if (!this.config.allowNullOrEmptyUsername) {
            StringUtils.requireNotNullOrEmpty(charSequence, "Username must not be null or empty");
        }
        throwNotConnectedExceptionIfAppropriate("Did you call connect() before login()?");
        throwAlreadyLoggedInExceptionIfAppropriate();
        this.usedUsername = charSequence != null ? charSequence.toString() : null;
        this.usedPassword = str;
        this.usedResource = hx3Var;
        loginInternal(this.usedUsername, this.usedPassword, this.usedResource);
    }
}