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


package com.xbcx.im;

import android.content.BroadcastReceiver;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.text.TextUtils;
import android.util.SparseArray;
import asmack.org.jivesoftware.smack.Chat;
import asmack.org.jivesoftware.smack.PacketCollector;
import asmack.org.jivesoftware.smack.Roster;
import asmack.org.jivesoftware.smack.RosterEntry;
import asmack.org.jivesoftware.smack.SmackConfiguration;
import asmack.org.jivesoftware.smack.XMPPException;
import asmack.org.jivesoftware.smack.filter.PacketIDFilter;
import asmack.org.jivesoftware.smack.packet.IQ;
import asmack.org.jivesoftware.smack.packet.Message;
import asmack.org.jivesoftware.smack.packet.MessageEvent;
import asmack.org.jivesoftware.smack.packet.Presence;
import asmack.org.jivesoftware.smack.packet.Privacy;
import asmack.org.jivesoftware.smack.packet.RosterPacket;
import asmack.org.jivesoftware.smack.util.PacketParserUtils;
import asmack.org.jivesoftware.smack.util.StringUtils;
import asmack.org.jivesoftware.smackx.GroupChatInvitation;
import asmack.org.jivesoftware.smackx.muc.Occupant;
import asmack.org.jivesoftware.smackx.packet.MUCUser;
import asmack.org.jivesoftware.smackx.packet.Nick;
import asmack.org.jivesoftware.smackx.packet.VCard;
import c.s.e.d;
import com.health.im.b;
import com.igexin.sdk.PushConsts;
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
import com.xbcx.core.C0526d;
import com.xbcx.core.PicUrlObject;
import com.xbcx.core.XApplication;
import com.xbcx.core.q;
import com.xbcx.im.a.c;
import com.xbcx.im.ui.C0584i;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import org.xmlpull.v1.XmlPullParser;

public class XIMSystem extends IMSystem implements q.a {
    protected C0526d mEventManager = C0526d.c();
    protected boolean mIsRegister;
    private boolean mLastMobileConnected;
    private boolean mLastWifiConnected;
    protected SparseArray<q.b> mMapCodeToRunners = new SparseArray<>();
    protected Map<String, String> mMapForbiddenJoinUserId = new ConcurrentHashMap();
    protected Map<String, String> mMapForbiddenSendUserId = new ConcurrentHashMap();
    private BroadcastReceiver mNetReceiver = new K(this);

    /* access modifiers changed from: private */
    public class A extends u {
        private A() {
            super();
        }

        /* synthetic */ A(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            String str = (String) oVar.a(0);
            IMGroup iMGroup = XIMSystem.this.mMapIdToGroup.get(str);
            String name = iMGroup == null ? "" : iMGroup.getName();
            XIMSystem xIMSystem = XIMSystem.this;
            xIMSystem.mRoster.quitGroupChat(xIMSystem.addSuffixGroupChatJid(str), BaseImageDownloader.DEFAULT_HTTP_READ_TIMEOUT);
            try {
                N onCreateXMessage = XIMSystem.this.onCreateXMessage(N.buildMessageId(), 10);
                onCreateXMessage.setContent(XIMSystem.this.getString(d.e(XIMSystem.this.mContext, "group_prompt_quited_group"), new Object[]{XIMSystem.this.getString(d.e(XIMSystem.this.mContext, "you"))}));
                onCreateXMessage.setFromType(2);
                onCreateXMessage.setGroupId(str);
                onCreateXMessage.setGroupName(name);
                onCreateXMessage.setSendTime(System.currentTimeMillis());
                XIMSystem.this.onReceiveMessage(onCreateXMessage);
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class B extends u {
        private B() {
            super();
        }

        /* synthetic */ B(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            N n = (N) oVar.a(0);
            try {
                (n.getFromType() == 2 ? XIMSystem.this : XIMSystem.this).doSend(n);
                return true;
            } finally {
                n.setSended();
                n.updateDB();
            }
        }
    }

    /* access modifiers changed from: private */
    public class C extends u {
        private C() {
            super();
        }

        /* synthetic */ C(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            I i = (I) oVar.a(0);
            G g2 = new G();
            g2.setType(IQ.Type.SET);
            g2.b("auth");
            g2.a(i.a());
            g2.setPrivacyList("default", new ArrayList());
            PacketCollector createPacketCollector = XIMSystem.this.mConnection.createPacketCollector(new PacketIDFilter(g2.getPacketID()));
            managePacketCollector(createPacketCollector);
            XIMSystem.this.mConnection.sendPacket(g2);
            XIMSystem.this.checkResultIQ((Privacy) createPacketCollector.nextResult((long) SmackConfiguration.getPacketReplyTimeout()));
            XIMSystem.this.mVerifyType = i.a();
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class D implements q.b {
        private D() {
        }

        /* synthetic */ D(XIMSystem xIMSystem, K k) {
            this();
        }

        @Override // com.xbcx.core.q.b
        public void onEventRun(com.xbcx.core.o oVar) throws Exception {
            C0544i iVar = (C0544i) oVar.a(0);
            XIMSystem xIMSystem = XIMSystem.this;
            iVar.f15661b = xIMSystem.mIsConnecting;
            iVar.f15660a = xIMSystem.mIsConnectionAvailable;
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: com.xbcx.im.XIMSystem$a  reason: case insensitive filesystem */
    public class C0532a extends u {
        private C0532a() {
            super();
        }

        /* synthetic */ C0532a(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            RosterPacket rosterPacket = new RosterPacket();
            rosterPacket.setType(IQ.Type.SET);
            rosterPacket.setFrom(XIMSystem.this.mConnection.getUser());
            rosterPacket.addRosterItem(new RosterPacket.Item(XIMSystem.this.addSuffixUserJid((String) oVar.a(0)), (String) oVar.a(1)));
            PacketCollector createPacketCollector = XIMSystem.this.mConnection.createPacketCollector(new PacketIDFilter(rosterPacket.getPacketID()));
            managePacketCollector(createPacketCollector);
            XIMSystem.this.mConnection.sendPacket(rosterPacket);
            XIMSystem.this.checkResultIQ((IQ) createPacketCollector.nextResult((long) SmackConfiguration.getPacketReplyTimeout()));
            return true;
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: com.xbcx.im.XIMSystem$b  reason: case insensitive filesystem */
    public class C0533b extends u {
        private C0533b() {
            super();
        }

        /* synthetic */ C0533b(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            String str = (String) oVar.a(0);
            if (TextUtils.isEmpty(str)) {
                return false;
            }
            Chat orCreateChat = XIMSystem.this.getOrCreateChat(str, 1);
            Message message = new Message();
            MessageEvent messageEvent = new MessageEvent();
            messageEvent.mAttris.addAttribute("kind", "addfriendconfirm");
            message.addExtension(messageEvent);
            message.attributes.addAttribute(Nick.ELEMENT_NAME, XIMSystem.this.getLoginNick());
            orCreateChat.sendMessage(message);
            return true;
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: com.xbcx.im.XIMSystem$c  reason: case insensitive filesystem */
    public class C0534c extends u {
        private C0534c() {
            super();
        }

        /* synthetic */ C0534c(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            Chat orCreateChat = XIMSystem.this.getOrCreateChat((String) oVar.a(0), 1);
            Message message = new Message();
            MessageEvent messageEvent = new MessageEvent();
            messageEvent.mAttris.addAttribute("kind", "addfriendask");
            messageEvent.setContent((String) oVar.a(1));
            message.addExtension(messageEvent);
            message.attributes.addAttribute(Nick.ELEMENT_NAME, XIMSystem.this.getLoginNick());
            orCreateChat.sendMessage(message);
            return true;
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: com.xbcx.im.XIMSystem$d  reason: case insensitive filesystem */
    public class C0535d extends u {
        private C0535d() {
            super();
        }

        /* synthetic */ C0535d(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            Collection<String> collection = (Collection) oVar.a(1);
            XIMSystem xIMSystem = XIMSystem.this;
            RosterEntry entry = xIMSystem.mRoster.getEntry(xIMSystem.addSuffixGroupChatJid((String) oVar.a(0)));
            if (entry == null || !entry.isGroupChat()) {
                return false;
            }
            ArrayList arrayList = new ArrayList();
            for (String str : collection) {
                arrayList.add(XIMSystem.this.addSuffixUserJid(str));
            }
            entry.addChilds(arrayList, BaseImageDownloader.DEFAULT_HTTP_READ_TIMEOUT);
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class e extends u {
        private e() {
            super();
        }

        /* synthetic */ e(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            ArrayList arrayList = new ArrayList();
            arrayList.add((String) oVar.a(0));
            XIMSystem.this.doAddBlackList(arrayList);
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class f extends u {
        private f() {
            super();
        }

        /* synthetic */ f(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            String str = (String) oVar.a(1);
            XIMSystem xIMSystem = XIMSystem.this;
            RosterEntry entry = xIMSystem.mRoster.getEntry(xIMSystem.addSuffixGroupChatJid((String) oVar.a(0)));
            if (entry == null || !entry.isGroupChat()) {
                return false;
            }
            entry.changeGroupName(str, BaseImageDownloader.DEFAULT_HTTP_READ_TIMEOUT);
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class g extends u {
        private g() {
            super();
        }

        /* synthetic */ g(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            return XIMSystem.this.isFriend((String) oVar.a(0));
        }
    }

    /* access modifiers changed from: private */
    public class h extends u {
        private h() {
            super();
        }

        /* synthetic */ h(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            return XIMSystem.this.isInBlackList((String) oVar.a(0));
        }
    }

    /* access modifiers changed from: private */
    public class i extends u {
        private i() {
            super();
        }

        /* synthetic */ i(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean canExecute() {
            return true;
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            return XIMSystem.this.isJoinedMultiUserChat();
        }
    }

    /* access modifiers changed from: private */
    public class j extends u {
        private j() {
            super();
        }

        /* synthetic */ j(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            String str = (String) oVar.a(0);
            ArrayList arrayList = new ArrayList();
            for (String str2 : (Collection) oVar.a(1)) {
                arrayList.add(XIMSystem.this.addSuffixUserJid(str2));
            }
            oVar.a(StringUtils.parseName(XIMSystem.this.mRoster.createGroupChat(str, arrayList, BaseImageDownloader.DEFAULT_HTTP_READ_TIMEOUT)));
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class k extends u {
        private k() {
            super();
        }

        /* synthetic */ k(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            XIMSystem xIMSystem = XIMSystem.this;
            Roster roster = xIMSystem.mRoster;
            roster.removeEntry(roster.getEntry(xIMSystem.addSuffixUserJid((String) oVar.a(0))));
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class l extends u {
        private l() {
            super();
        }

        /* synthetic */ l(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            Collection<String> collection = (Collection) oVar.a(1);
            XIMSystem xIMSystem = XIMSystem.this;
            RosterEntry entry = xIMSystem.mRoster.getEntry(xIMSystem.addSuffixGroupChatJid((String) oVar.a(0)));
            if (entry == null || !entry.isGroupChat()) {
                return false;
            }
            ArrayList arrayList = new ArrayList();
            for (String str : collection) {
                arrayList.add(XIMSystem.this.addSuffixUserJid(str));
            }
            entry.deleteChilds(arrayList, BaseImageDownloader.DEFAULT_HTTP_READ_TIMEOUT);
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class m extends u {
        private m() {
            super();
        }

        /* synthetic */ m(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            String str = (String) oVar.a(0);
            IMGroup iMGroup = XIMSystem.this.mMapIdToGroup.get(str);
            String name = iMGroup == null ? "" : iMGroup.getName();
            XIMSystem xIMSystem = XIMSystem.this;
            xIMSystem.mRoster.deleteGroupChat(xIMSystem.addSuffixGroupChatJid(str), BaseImageDownloader.DEFAULT_HTTP_READ_TIMEOUT);
            try {
                N onCreateXMessage = XIMSystem.this.onCreateXMessage(N.buildMessageId(), 10);
                onCreateXMessage.setContent(XIMSystem.this.getString(d.e(XIMSystem.this.mContext, "group_prompt_removed_group"), new Object[]{XIMSystem.this.getString(d.e(XIMSystem.this.mContext, "you"))}));
                onCreateXMessage.setFromType(2);
                onCreateXMessage.setGroupId(str);
                onCreateXMessage.setGroupName(name);
                onCreateXMessage.setSendTime(System.currentTimeMillis());
                XIMSystem.this.onReceiveMessage(onCreateXMessage);
            } catch (Exception e2) {
                e2.printStackTrace();
            }
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class n extends u {
        private n() {
            super();
        }

        /* synthetic */ n(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            ArrayList arrayList = new ArrayList();
            arrayList.add((String) oVar.a(0));
            XIMSystem.this.doDeleteBlackList(arrayList);
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class o extends u {
        private o() {
            super();
        }

        /* synthetic */ o(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            oVar.a(Collections.unmodifiableCollection(XIMSystem.this.mMapIdToContact.values()));
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class p extends u {
        private p() {
            super();
        }

        /* synthetic */ p(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            oVar.a(Collections.unmodifiableCollection(XIMSystem.this.mMapIdToGroup.values()));
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class q extends u {
        private q() {
            super();
        }

        /* synthetic */ q(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean canExecute() {
            return true;
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            oVar.a(XIMSystem.this.mMapIdToGroup.get((String) oVar.a(0)));
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class r extends u {
        private r() {
            super();
        }

        /* synthetic */ r(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean canExecute() {
            return true;
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            A a2 = XIMSystem.this.mMultiUserChat.get();
            IMChatRoom a3 = a2 == null ? null : a2.a();
            if (a3 == null) {
                a3 = XIMSystem.this.mAtomicDisconnectRoom.get();
            }
            oVar.a(a3);
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class s extends u {
        private s() {
            super();
        }

        /* synthetic */ s(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            oVar.a(Collections.unmodifiableCollection(XIMSystem.this.mMapIdBlackList.keySet()));
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class t extends u {
        private t() {
            super();
        }

        /* synthetic */ t(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean canExecute() {
            return true;
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            oVar.a(I.a(XIMSystem.this.mVerifyType));
            return true;
        }
    }

    /* access modifiers changed from: protected */
    public abstract class u implements q.b {
        private List<PacketCollector> mListPacketCollector;

        protected u() {
        }

        /* access modifiers changed from: protected */
        public boolean canExecute() {
            return XIMSystem.this.mIsConnectionAvailable;
        }

        /* access modifiers changed from: protected */
        public void execute(com.xbcx.core.o oVar) throws Exception {
            try {
                Logger logger = XApplication.getLogger();
                logger.info(getClass().getName() + " execute");
                oVar.a(onExecute(oVar));
                List<PacketCollector> list = this.mListPacketCollector;
                if (list != null) {
                    for (PacketCollector packetCollector : list) {
                        packetCollector.cancel();
                    }
                }
                Logger logger2 = XApplication.getLogger();
                logger2.info(getClass().getName() + " execute:" + oVar.d());
            } catch (XMPPException e2) {
                if ("No response from the server.".equals(e2.getMessage())) {
                    onTimeout();
                }
                throw e2;
            } catch (Throwable th) {
                List<PacketCollector> list2 = this.mListPacketCollector;
                if (list2 != null) {
                    for (PacketCollector packetCollector2 : list2) {
                        packetCollector2.cancel();
                    }
                }
                Logger logger3 = XApplication.getLogger();
                logger3.info(getClass().getName() + " execute:" + oVar.d());
                throw th;
            }
        }

        /* access modifiers changed from: protected */
        public void managePacketCollector(PacketCollector packetCollector) {
            if (this.mListPacketCollector == null) {
                this.mListPacketCollector = new ArrayList();
            }
            this.mListPacketCollector.add(packetCollector);
        }

        @Override // com.xbcx.core.q.b
        public void onEventRun(com.xbcx.core.o oVar) throws Exception {
            if (canExecute()) {
                execute(oVar);
            }
        }

        /* access modifiers changed from: protected */
        public abstract boolean onExecute(com.xbcx.core.o oVar) throws Exception;

        /* access modifiers changed from: protected */
        public void onTimeout() {
            XIMSystem xIMSystem = XIMSystem.this;
            if (xIMSystem.mIsConnectionAvailable) {
                xIMSystem.mConnection.disconnect();
            }
        }
    }

    /* access modifiers changed from: protected */
    public class v extends u {
        protected v() {
            super();
        }

        @Override // com.xbcx.core.q.b, com.xbcx.im.XIMSystem.u
        public void onEventRun(com.xbcx.core.o oVar) throws Exception {
            try {
                super.onEventRun(oVar);
            } finally {
                XIMSystem.this.handleJoinRoomFinished(oVar.d());
            }
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            boolean z;
            IMChatRoom iMChatRoom = (IMChatRoom) oVar.a(0);
            Boolean bool = (Boolean) oVar.a(1);
            AtomicBoolean atomicBoolean = (AtomicBoolean) oVar.a(2);
            boolean booleanValue = bool == null ? false : bool.booleanValue();
            if (!(atomicBoolean == null ? false : atomicBoolean.get())) {
                if (booleanValue) {
                    XIMSystem.this.mAtomicDisconnectRoom.set(null);
                    XIMSystem.this.doJoinRandom(iMChatRoom);
                } else {
                    if (XIMSystem.this.mAtomicDisconnectRoom.get() != null) {
                        if (XIMSystem.this.mAtomicDisconnectRoom.get().getId().equals(iMChatRoom.getId())) {
                            z = true;
                            oVar.a(Boolean.valueOf(z));
                            XIMSystem.this.doJoin(iMChatRoom);
                        } else {
                            XIMSystem.this.mAtomicDisconnectRoom.set(null);
                        }
                    }
                    z = false;
                    oVar.a(Boolean.valueOf(z));
                    XIMSystem.this.doJoin(iMChatRoom);
                }
            }
            if (atomicBoolean == null || !atomicBoolean.get()) {
                return true;
            }
            XIMSystem.this.doLeave();
            return false;
        }
    }

    /* access modifiers changed from: private */
    public class w extends u {
        private w() {
            super();
        }

        /* synthetic */ w(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            M m = new M(this, (String) oVar.a(0));
            m.setType(IQ.Type.SET);
            m.setFrom(XIMSystem.this.mConnection.getUser());
            PacketCollector createPacketCollector = XIMSystem.this.mConnection.createPacketCollector(new PacketIDFilter(m.getPacketID()));
            managePacketCollector(createPacketCollector);
            XIMSystem.this.mConnection.sendPacket(m);
            IQ iq = (IQ) createPacketCollector.nextResult((long) SmackConfiguration.getPacketReplyTimeout());
            XIMSystem.this.checkResultIQ(iq);
            if (!iq.getType().equals(IQ.Type.RESULT)) {
                return false;
            }
            XIMSystem.this.mRoster.reload();
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class x extends u {
        private x() {
            super();
        }

        /* synthetic */ x(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean canExecute() {
            return true;
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            XIMSystem.this.doLeave();
            XIMSystem.this.mAtomicDisconnectRoom.set(null);
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class y extends u {
        private y() {
            super();
        }

        /* synthetic */ y(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            String str = (String) oVar.a(0);
            VCard vCard = new VCard();
            XIMSystem xIMSystem = XIMSystem.this;
            vCard.load(xIMSystem.mConnection, xIMSystem.addSuffixUserJid(str));
            PicUrlObject picUrlObject = new PicUrlObject(str);
            picUrlObject.setName(vCard.getNickName());
            picUrlObject.setPicUrl(vCard.getField("DESC"));
            oVar.a(picUrlObject);
            return true;
        }
    }

    /* access modifiers changed from: private */
    public class z extends u {
        private z() {
            super();
        }

        /* synthetic */ z(XIMSystem xIMSystem, K k) {
            this();
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean canExecute() {
            return true;
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public boolean onExecute(com.xbcx.core.o oVar) throws Exception {
            XIMSystem.this.mEventManager.c(com.xbcx.core.p.IM_LoginStart, new Object[0]);
            XIMSystem xIMSystem = XIMSystem.this;
            xIMSystem.doLogin(xIMSystem.mIsRegister);
            return true;
        }

        /* access modifiers changed from: protected */
        @Override // com.xbcx.im.XIMSystem.u
        public void onTimeout() {
        }
    }

    @Override // com.xbcx.im.IMSystem, asmack.org.jivesoftware.smackx.muc.UserStatusListener
    public void banned(String str, String str2) {
        super.banned(str, str2);
        this.mEventManager.c(com.xbcx.core.p.IM_OutCast, getUser(), str2);
    }

    /* access modifiers changed from: protected */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x00ac  */
    public N createServerMessage(XmlPullParser xmlPullParser, String str, String str2, int i2) throws Exception {
        String removeSuffix;
        xmlPullParser.setInput(new StringReader(str));
        int eventType = xmlPullParser.getEventType();
        while (eventType != 1) {
            if (eventType != 0 && eventType == 2 && "message".equals(xmlPullParser.getName())) {
                Message message = (Message) PacketParserUtils.parseMessage(xmlPullParser);
                if (message.getType().equals(Message.Type.error)) {
                    break;
                }
                Message.Body messageBody = message.getMessageBody(null);
                if (messageBody != null) {
                    Chat orCreateChat = getOrCreateChat(str2, i2);
                    N onCreateServerMessage = onCreateServerMessage(onCreateReceiveXMessageId(message), parseMessageType(messageBody));
                    if (orCreateChat.getParticipant().contains(IMSystem.GROUP_FLAG)) {
                        onCreateServerMessage.setFromType(2);
                    } else if (orCreateChat.getParticipant().contains(IMSystem.NOTICE_FLAG)) {
                        onCreateServerMessage.setFromType(5);
                    } else {
                        removeSuffix = removeSuffix(orCreateChat.getParticipant());
                        onCreateServerMessage.setFromType(1);
                        onCreateServerMessage.setUserId(removeSuffix);
                        onCreateServerMessage.setUserName(message.attributes.getAttributeValue(Nick.ELEMENT_NAME));
                        onSetMessageCommonValue(onCreateServerMessage, message);
                        if (isLocalId(removeSuffix(message.getFrom()))) {
                            onCreateServerMessage.setFromSelf(true);
                            onCreateServerMessage.setUploadSuccess(true);
                        }
                        return onCreateServerMessage;
                    }
                    onCreateServerMessage.setGroupId(removeSuffix(orCreateChat.getParticipant()));
                    removeSuffix = removeSuffix(message.getFrom());
                    onCreateServerMessage.setUserId(removeSuffix);
                    onCreateServerMessage.setUserName(message.attributes.getAttributeValue(Nick.ELEMENT_NAME));
                    onSetMessageCommonValue(onCreateServerMessage, message);
                    if (isLocalId(removeSuffix(message.getFrom()))) {
                    }
                    return onCreateServerMessage;
                }
            }
            eventType = xmlPullParser.next();
        }
        return null;
    }

    /* access modifiers changed from: protected */
    public List<IMRoomMember> doGetRoomMember() {
        A a2 = this.mMultiUserChat.get();
        ArrayList arrayList = new ArrayList();
        if (a2 != null) {
            Iterator<String> occupants = a2.getOccupants();
            while (occupants.hasNext()) {
                Occupant occupant = a2.getOccupant(occupants.next());
                arrayList.add(new IMRoomMember(removeSuffix(occupant.getJid()), occupant.getNick(), E.a(occupant.getRole()).toString()));
            }
        }
        return arrayList;
    }

    @Override // com.xbcx.core.q.a
    public void eventRunEnd(com.xbcx.core.o oVar) {
        int i2;
        int a2 = oVar.a();
        if (a2 == com.xbcx.core.p.IM_Login) {
            handleLoginFinished(oVar.d());
            return;
        }
        if (a2 == com.xbcx.core.p.AppBackground) {
            i2 = 60000;
        } else if (a2 == com.xbcx.core.p.AppForceground) {
            i2 = 1000;
        } else if (a2 == com.xbcx.core.p.IM_NotifyReceiveRoomMessage) {
            synchronized (this.mNeedDelayReceiveRoomMessage) {
                this.mNeedDelayReceiveRoomMessage.notify();
            }
            return;
        } else {
            return;
        }
        this.mReConnectIntervalMillis = i2;
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public List<String> getAllRoomIdInDb(String str) {
        return (List) this.mEventManager.c(com.xbcx.core.p.DB_ReadMessageTableNames, str).b(0);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public String getAvatarUrl() {
        return "";
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public String getLoginNick() {
        String s2 = b.s();
        return com.yht.util.y.a(s2) ? H.getInstance().getCacheName(getUser()) : s2;
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public long getRoomLastMessageSendTime(String str) {
        c cVar = new c();
        cVar.f15574a = str;
        cVar.f15575b = new String[]{"sendtime"};
        this.mEventManager.c(com.xbcx.core.p.DB_ReadLastMessage, cVar);
        return cVar.a("sendtime", 0);
    }

    /* access modifiers changed from: protected */
    public void managerRegisterRunner(int i2, q.b bVar) {
        this.mEventManager.a(i2, bVar);
        this.mMapCodeToRunners.put(i2, bVar);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onBlackListChanged() {
        super.onBlackListChanged();
        this.mEventManager.c(com.xbcx.core.p.IM_PrivacyListChanged, Collections.unmodifiableCollection(this.mMapIdBlackList.keySet()));
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onConflict() {
        this.mEventManager.c(com.xbcx.core.p.IM_Conflict, new Object[0]);
        super.onConflict();
    }

    @Override // com.xbcx.im.IMSystem
    public void onCreate() {
        super.onCreate();
        this.mEventManager.a(com.xbcx.core.p.IM_Login, (q.a) this, false);
        this.mEventManager.a(com.xbcx.core.p.AppBackground, (q.a) this, false);
        this.mEventManager.a(com.xbcx.core.p.AppForceground, (q.a) this, false);
        this.mEventManager.a(com.xbcx.core.p.IM_NotifyReceiveRoomMessage, (q.a) this, false);
        managerRegisterRunner(com.xbcx.core.p.IM_Login, new z(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_StatusQuery, new D(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_SendMessage, new B(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_JoinChatRoom, new v());
        managerRegisterRunner(com.xbcx.core.p.IM_LeaveChatRoom, new x(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_CheckIsJoinedRoom, new i(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_GetJoinedChatRoom, new r(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_LoadVCard, new y(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_GetFriendList, new o(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_CheckIsFriend, new g(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_AddFriendApply, new C0532a(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_AddFriendVerify, new C0534c(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_AddFriendConfirm, new C0533b(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_DeleteFriend, new k(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_GetGroupChatList, new p(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_GetGroup, new q(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_CreateGroupChat, new j(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_DeleteGroupChat, new m(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_QuitGroupChat, new A(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_AddGroupChatMember, new C0535d(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_ChangeGroupChatName, new f(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_DeleteGroupChatMember, new l(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_GetVerifyType, new t(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_SetVerifyType, new C(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_GetPrivacyList, new s(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_AddBlackList, new e(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_DeleteBlackList, new n(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_CheckInBlackList, new h(this, null));
        managerRegisterRunner(com.xbcx.core.p.IM_JoinGroup, new w(this, null));
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
        NetworkInfo networkInfo = connectivityManager.getNetworkInfo(1);
        if (networkInfo != null) {
            this.mLastWifiConnected = networkInfo.isConnected();
        }
        NetworkInfo networkInfo2 = connectivityManager.getNetworkInfo(0);
        if (networkInfo2 != null) {
            this.mLastMobileConnected = networkInfo2.isConnected();
        }
        registerReceiver(this.mNetReceiver, new IntentFilter(PushConsts.ACTION_BROADCAST_NETWORK_CHANGE));
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public IMContact onCreateContactByRosterEntry(RosterEntry rosterEntry) {
        return new IMContact(removeSuffix(rosterEntry.getUser()), rosterEntry.getName());
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public IMRoomMember onCreateRoomMember(Presence presence) {
        MUCUser.Item item = ((MUCUser) presence.getExtension(GroupChatInvitation.ELEMENT_NAME, "http://jabber.org/protocol/muc#user")).getItem();
        return new IMRoomMember(removeSuffix(item.getJid()), StringUtils.parseResource(presence.getFrom()), E.a(item.getRole()).toString());
    }

    /* access modifiers changed from: protected */
    public N onCreateServerMessage(String str, int i2) {
        return new F(str, i2);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public N onCreateXMessage(String str, int i2) {
        return C0584i.j.createXMessage(str, i2);
    }

    @Override // com.xbcx.im.IMSystem
    public void onDestroy() {
        super.onDestroy();
        int size = this.mMapCodeToRunners.size();
        for (int i2 = 0; i2 < size; i2++) {
            int keyAt = this.mMapCodeToRunners.keyAt(i2);
            this.mEventManager.b(keyAt, this.mMapCodeToRunners.get(keyAt));
        }
        unregisterReceiver(this.mNetReceiver);
        this.mEventManager.a(com.xbcx.core.p.IM_Login, this);
        this.mEventManager.a(com.xbcx.core.p.AppBackground, this);
        this.mEventManager.a(com.xbcx.core.p.AppForceground, this);
        this.mEventManager.a(com.xbcx.core.p.IM_NotifyReceiveRoomMessage, this);
    }

    /* access modifiers changed from: protected */
    public void onForbiddenSendListChanged() {
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onFriendListChanged() {
        super.onFriendListChanged();
        Collections.sort(new LinkedList(this.mMapIdToContact.values()), new L(this));
        this.mEventManager.c(com.xbcx.core.p.IM_FriendListChanged, Collections.unmodifiableCollection(this.mMapIdToContact.values()));
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onGroupChatListChanged() {
        super.onGroupChatListChanged();
        this.mEventManager.c(com.xbcx.core.p.IM_GroupChatListChanged, Collections.unmodifiableCollection(this.mMapIdToGroup.values()));
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onHandleConnectionClosedOnError() {
        super.onHandleConnectionClosedOnError();
        this.mEventManager.b(com.xbcx.core.p.IM_ConnectionInterrupt, 0);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onLoginFailure() {
        super.onLoginFailure();
        this.mEventManager.c(com.xbcx.core.p.IM_LoginFailure, new Object[0]);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onLoginOut() {
        super.onLoginOut();
        this.mEventManager.c(com.xbcx.core.p.IM_LoginOuted, new Object[0]);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onLoginPwdError() {
        super.onLoginPwdError();
        this.mEventManager.c(com.xbcx.core.p.IM_LoginPwdError, new Object[0]);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onProcessRoomPresence(Presence presence) {
        super.onProcessRoomPresence(presence);
        if (presence.getType() == Presence.Type.available) {
            MUCUser.Item item = ((MUCUser) presence.getExtension(GroupChatInvitation.ELEMENT_NAME, "http://jabber.org/protocol/muc#user")).getItem();
            String removeSuffix = removeSuffix(item.getJid());
            if (E.f15550c.a().equals(item.getRole())) {
                if (!this.mMapForbiddenSendUserId.containsKey(removeSuffix)) {
                    this.mMapForbiddenSendUserId.put(removeSuffix, removeSuffix);
                } else {
                    return;
                }
            } else if (this.mMapForbiddenSendUserId.containsKey(removeSuffix)) {
                this.mMapForbiddenSendUserId.remove(removeSuffix);
            } else {
                return;
            }
            onForbiddenSendListChanged();
        }
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onReceiveMessage(N n2) {
        super.onReceiveMessage(n2);
        if (((Boolean) this.mEventManager.c(com.xbcx.core.p.DB_SaveMessage, n2).b(0)).booleanValue()) {
            com.yht.util.s.c("onReceiveMessage is already save message");
            return;
        }
        com.yht.util.r.a(new c.s.b.e(n2));
        this.mEventManager.c(com.xbcx.core.p.IM_ReceiveMessage, n2);
        this.mEventManager.c(com.xbcx.core.p.HandleRecentChat, n2);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void onRoomMemberChanged() {
        super.onRoomMemberChanged();
        this.mMultiUserChat.get();
    }

    @Override // asmack.org.jivesoftware.smack.RosterListener, com.xbcx.im.IMSystem
    public void presenceChanged(Presence presence) {
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void requestJoinRoom(IMChatRoom iMChatRoom) {
        if (this.mIsConnectionAvailable) {
            this.mEventManager.b(com.xbcx.core.p.IM_JoinChatRoom, iMChatRoom);
        }
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void requestLogin() {
        this.mEventManager.b(com.xbcx.core.p.IM_Login, new Object[0]);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void requestReconnect() {
        int i2 = 1;
        this.mReConnectCount++;
        if (this.mReConnectCount >= 8) {
            this.mReConnectCount = 8;
        }
        try {
            i2 = new Random().nextInt((int) Math.pow(2.0d, (double) this.mReConnectCount));
        } catch (Exception unused) {
        }
        this.mEventManager.a(com.xbcx.core.p.IM_Login, (long) (i2 * 1000), new Object[0]);
    }

    /* access modifiers changed from: protected */
    @Override // com.xbcx.im.IMSystem
    public void syncVCard(String str) {
        if (com.yht.util.y.a(str)) {
            com.yht.util.s.c("syncVcard failed, from id is null");
            return;
        }
        C0526d.c().b(com.xbcx.core.p.IM_LoadVCard, str);
    }
}