曹妃甸核酸检测平台.apk(点击下载) / BOSHPacketReader.java


package asmack.org.jivesoftware.smack;

import asmack.com.kenai.jbosh.AbstractC0195b;
import asmack.com.kenai.jbosh.BOSHMessageEvent;
import asmack.com.kenai.jbosh.D;
import asmack.com.kenai.jbosh.F;
import asmack.com.kenai.jbosh.y;
import asmack.org.jivesoftware.smack.packet.Packet;
import asmack.org.jivesoftware.smack.sasl.SASLMechanism;
import asmack.org.jivesoftware.smack.util.PacketParserUtils;
import com.umeng.analytics.pro.c;
import java.io.StringReader;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

public class BOSHPacketReader implements y {
    private BOSHConnection connection;

    public BOSHPacketReader(BOSHConnection bOSHConnection) {
        this.connection = bOSHConnection;
    }

    private void parseFeatures(XmlPullParser xmlPullParser) throws Exception {
        boolean z = false;
        while (!z) {
            int next = xmlPullParser.next();
            if (next == 2) {
                if (xmlPullParser.getName().equals("mechanisms")) {
                    this.connection.getSASLAuthentication().setAvailableSASLMethods(PacketParserUtils.parseMechanisms(xmlPullParser));
                } else if (xmlPullParser.getName().equals("bind")) {
                    this.connection.getSASLAuthentication().bindingRequired();
                } else if (xmlPullParser.getName().equals(c.aw)) {
                    this.connection.getSASLAuthentication().sessionsSupported();
                } else if (xmlPullParser.getName().equals("register")) {
                    this.connection.getAccountManager().setSupportsAccountCreation(true);
                }
            } else if (next == 3 && xmlPullParser.getName().equals("features")) {
                z = true;
            }
        }
    }

    @Override // asmack.com.kenai.jbosh.y
    public void responseReceived(BOSHMessageEvent bOSHMessageEvent) {
        int next;
        BOSHConnection bOSHConnection;
        Packet success;
        AbstractC0195b body = bOSHMessageEvent.getBody();
        if (body != null) {
            try {
                if (this.connection.sessionID == null) {
                    this.connection.sessionID = body.a(D.a(BOSHConnection.BOSH_URI, "sid"));
                }
                if (this.connection.authID == null) {
                    this.connection.authID = body.a(D.a(BOSHConnection.BOSH_URI, "authid"));
                }
                XmlPullParser newPullParser = XmlPullParserFactory.newInstance().newPullParser();
                newPullParser.setFeature("http://xmlpull.org/v1/doc/features.html#process-namespaces", true);
                newPullParser.setInput(new StringReader(body.c()));
                newPullParser.getEventType();
                do {
                    next = newPullParser.next();
                    if (next == 2 && !newPullParser.getName().equals("body")) {
                        if (newPullParser.getName().equals("message")) {
                            bOSHConnection = this.connection;
                            success = PacketParserUtils.parseMessage(newPullParser);
                        } else if (newPullParser.getName().equals("iq")) {
                            bOSHConnection = this.connection;
                            success = PacketParserUtils.parseIQ(newPullParser, this.connection);
                        } else if (newPullParser.getName().equals("presence")) {
                            bOSHConnection = this.connection;
                            success = PacketParserUtils.parsePresence(newPullParser);
                        } else if (newPullParser.getName().equals("challenge")) {
                            String nextText = newPullParser.nextText();
                            this.connection.getSASLAuthentication().challengeReceived(nextText);
                            this.connection.processPacket(new SASLMechanism.Challenge(nextText));
                            continue;
                        } else if (newPullParser.getName().equals("success")) {
                            BOSHConnection bOSHConnection2 = this.connection;
                            F.a d2 = F.d();
                            d2.a("xmpp", BOSHConnection.XMPP_BOSH_NS);
                            d2.a(D.a(BOSHConnection.XMPP_BOSH_NS, "restart", "xmpp"), "true");
                            d2.a(D.a(BOSHConnection.BOSH_URI, "to"), this.connection.getServiceName());
                            bOSHConnection2.send(d2.a());
                            this.connection.getSASLAuthentication().authenticated();
                            bOSHConnection = this.connection;
                            success = new SASLMechanism.Success(newPullParser.nextText());
                        } else if (newPullParser.getName().equals("features")) {
                            parseFeatures(newPullParser);
                            continue;
                        } else if (newPullParser.getName().equals("failure")) {
                            if ("urn:ietf:params:xml:ns:xmpp-sasl".equals(newPullParser.getNamespace(null))) {
                                SASLMechanism.Failure parseSASLFailure = PacketParserUtils.parseSASLFailure(newPullParser);
                                this.connection.getSASLAuthentication().authenticationFailed();
                                this.connection.processPacket(parseSASLFailure);
                                continue;
                            } else {
                                continue;
                            }
                        } else if (newPullParser.getName().equals(c.O)) {
                            throw new XMPPException(PacketParserUtils.parseStreamError(newPullParser));
                        }
                        bOSHConnection.processPacket(success);
                        continue;
                    }
                } while (next != 1);
            } catch (Exception e2) {
                if (this.connection.isConnected()) {
                    this.connection.notifyConnectionError(e2);
                }
            }
        }
    }
}