PageRenderTime 74ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/QingTingFanBianYi/src/fm/qingting/qtradio/im/IMAgent.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 1960 lines | 1863 code | 93 blank | 4 comment | 596 complexity | 977a5855bd0a71ebcafeb270b882a486 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. package fm.qingting.qtradio.im;
  2. import android.content.Context;
  3. import android.os.Handler;
  4. import android.os.Looper;
  5. import android.os.Message;
  6. import android.text.TextUtils;
  7. import android.widget.Toast;
  8. import com.alibaba.fastjson.JSON;
  9. import com.alibaba.fastjson.JSONArray;
  10. import com.alibaba.fastjson.JSONObject;
  11. import fm.qingting.framework.data.DataManager;
  12. import fm.qingting.framework.data.IResultRecvHandler;
  13. import fm.qingting.framework.data.IResultToken;
  14. import fm.qingting.framework.data.Result;
  15. import fm.qingting.qtradio.controller.ControllerManager;
  16. import fm.qingting.qtradio.data.IMDatabaseDS;
  17. import fm.qingting.qtradio.im.info.GroupInfo;
  18. import fm.qingting.qtradio.im.message.IMMessage;
  19. import fm.qingting.qtradio.log.LogModule;
  20. import fm.qingting.qtradio.logger.QTLogger;
  21. import fm.qingting.qtradio.manager.INETEventListener;
  22. import fm.qingting.qtradio.manager.NetWorkManage;
  23. import fm.qingting.qtradio.model.GlobalCfg;
  24. import fm.qingting.qtradio.model.InfoManager;
  25. import fm.qingting.qtradio.model.RootNode;
  26. import fm.qingting.qtradio.model.RootNode.IInfoUpdateEventListener;
  27. import fm.qingting.qtradio.model.SharedCfg;
  28. import fm.qingting.qtradio.room.SnsInfo;
  29. import fm.qingting.qtradio.room.UserInfo;
  30. import fm.qingting.qtradio.room.WeiboChat;
  31. import fm.qingting.qtradio.social.CloudCenter;
  32. import fm.qingting.qtradio.social.UserProfile;
  33. import fm.qingting.utils.ImageUtil;
  34. import fm.qingting.utils.QTMSGManage;
  35. import fm.qingting.utils.RangeRandom;
  36. import fm.qingting.websocket.WebSocketClient;
  37. import fm.qingting.websocket.WebSocketClient.Listener;
  38. import java.net.URI;
  39. import java.util.ArrayList;
  40. import java.util.Arrays;
  41. import java.util.Collections;
  42. import java.util.HashMap;
  43. import java.util.Iterator;
  44. import java.util.List;
  45. import java.util.Map;
  46. import java.util.Map.Entry;
  47. import java.util.Set;
  48. import org.apache.http.message.BasicNameValuePair;
  49. public class IMAgent
  50. implements IResultRecvHandler, INETEventListener
  51. {
  52. private static long MAX_RecvMsg_INTERVAL = 0L;
  53. private static final String TAG = "IMAgent2";
  54. private static IMAgent instance;
  55. private static long mLastRecvMsgTime = 0L;
  56. private final int CONNECT_CHATROOM_FAILED = 2;
  57. private int CONNECT_INTERVAL = 20;
  58. private int IM_HISTORY_SIZE = 100;
  59. private int MSG_CNT_PER_PAGE = 10;
  60. private int PING_INTERVAL = 300;
  61. private final String PROTOCOL_HEAD = "ws://";
  62. private final int RECV_LIST_MSG = 1;
  63. private final int RECV_SINGLE_MSG = 0;
  64. private long SEND_NOTIFICATION_INTERVAL = 2000L;
  65. private boolean autoGet = false;
  66. private boolean autoJoin = false;
  67. private boolean autoLogin = false;
  68. private Handler connectHandler = new Handler();
  69. private String connectUrl;
  70. private boolean connected = false;
  71. private boolean connecting = false;
  72. private Runnable doConnect = new Runnable()
  73. {
  74. public void run()
  75. {
  76. IMAgent.this.connect();
  77. }
  78. };
  79. private long lastPingTime = 0L;
  80. private boolean loginSuccess = false;
  81. private List<String> lstHasCheckin = new ArrayList();
  82. private int mAddProgramId = 0;
  83. private int mAddTime = 0;
  84. private int mBarraeProgramId = 0;
  85. private Context mContext;
  86. private String mCurrentGroupId;
  87. private List<UserInfo> mCurrentGroupUsers;
  88. private Handler mDispatchHandler = new DispatchHandler(Looper.getMainLooper());
  89. private JSONObject mJsonMsg = new JSONObject();
  90. private String mLastFromId = null;
  91. private String mLastNetType = "";
  92. private List<String> mLstEnableGroups = new ArrayList();
  93. private List<IMMessage> mLstImageBarrage = null;
  94. private IMMessage mLstSendImageBarrage = null;
  95. private List<String> mLstTempWatchGroups = new ArrayList();
  96. private List<IMMessage> mLstTextBarrage = null;
  97. private String mPingMsg = null;
  98. private int mRecvMsgCnt = 0;
  99. private long mRecvMsgTime = 0L;
  100. private int mTotalUnReadMsgCnt = 0;
  101. private WebSocketClient mWebSocket;
  102. private Map<String, UserInfo> mapATUser = new HashMap();
  103. private Map<String, GroupInfo> mapGroupInfo = new HashMap();
  104. private Map<String, List<IMEventListener>> mapIMEventListeners = new HashMap();
  105. private Map<String, List<IMMessage>> mapMessage = new HashMap();
  106. private Map<String, Integer> mapUnReadMsgCnt = new HashMap();
  107. private int maxHistoryRecords = 30;
  108. private int maxOnlineUsers = 1000;
  109. private int recordCnt = 0;
  110. private IMAgent()
  111. {
  112. NetWorkManage.getInstance().addListener(this);
  113. this.mLastNetType = NetWorkManage.getInstance().getNetWorkType();
  114. initUnReadMsg();
  115. }
  116. private void _connect()
  117. {
  118. if ((this.connectUrl == null) || (this.connectUrl.equalsIgnoreCase("")))
  119. getImServer();
  120. do
  121. {
  122. do
  123. {
  124. return;
  125. if (!this.connecting)
  126. break;
  127. }
  128. while (this.mContext == null);
  129. return;
  130. }
  131. while ((this.connected) && (this.mWebSocket != null));
  132. try
  133. {
  134. this.connecting = true;
  135. List localList = Arrays.asList(new BasicNameValuePair[] { new BasicNameValuePair("Cookie", "session=abcd") });
  136. this.mWebSocket = new WebSocketClient(URI.create(this.connectUrl), new WebSocketClient.Listener()
  137. {
  138. public void onConnect()
  139. {
  140. IMAgent.this.handleConnect();
  141. }
  142. public void onDisconnect(int paramAnonymousInt, String paramAnonymousString)
  143. {
  144. IMAgent.this.handleConnectFailure();
  145. }
  146. public void onError(Exception paramAnonymousException)
  147. {
  148. IMAgent.this.handleConnectFailure();
  149. }
  150. public void onMessage(String paramAnonymousString)
  151. {
  152. IMAgent.this.handleMessage(paramAnonymousString);
  153. }
  154. public void onMessage(byte[] paramAnonymousArrayOfByte)
  155. {
  156. }
  157. }
  158. , localList);
  159. this.mWebSocket.connect();
  160. return;
  161. }
  162. catch (Exception localException)
  163. {
  164. }
  165. }
  166. private void addGroupInfo(GroupInfo paramGroupInfo)
  167. {
  168. if ((paramGroupInfo == null) || (paramGroupInfo.groupId == null))
  169. return;
  170. this.mapGroupInfo.put(paramGroupInfo.groupId, paramGroupInfo);
  171. }
  172. private void addMsgToDS(IMMessage paramIMMessage)
  173. {
  174. if (paramIMMessage == null)
  175. return;
  176. String str;
  177. Object localObject;
  178. if (paramIMMessage.isGroupMsg())
  179. {
  180. str = paramIMMessage.mFromGroupId;
  181. localObject = (List)this.mapMessage.get(str);
  182. if (localObject == null)
  183. break label67;
  184. ((List)localObject).add(paramIMMessage);
  185. }
  186. while (true)
  187. {
  188. if (!paramIMMessage.isGroupMsg())
  189. break label98;
  190. IMDatabaseDS.getInstance().appendGroupMessage(paramIMMessage, false);
  191. return;
  192. str = paramIMMessage.mFromID;
  193. break;
  194. label67: localObject = new ArrayList();
  195. ((List)localObject).add(paramIMMessage);
  196. this.mapMessage.put(str, localObject);
  197. }
  198. label98: IMDatabaseDS.getInstance().appendPrivateMessage(paramIMMessage, false);
  199. }
  200. private boolean canHandle(String paramString, int paramInt)
  201. {
  202. if (paramString == null);
  203. do
  204. {
  205. do
  206. {
  207. do
  208. {
  209. return false;
  210. if (paramInt != 0)
  211. break;
  212. }
  213. while (isSelf(paramString));
  214. return true;
  215. }
  216. while (paramInt != 1);
  217. if (hasInTempWatchGroups(paramString) != -1)
  218. return true;
  219. }
  220. while (!IMContacts.getInstance().hasWatchedGroup(paramString));
  221. return true;
  222. }
  223. private void dispatchIMEvent(String paramString, IMMessage paramIMMessage)
  224. {
  225. if (this.mapIMEventListeners.containsKey(paramString))
  226. {
  227. List localList = (List)this.mapIMEventListeners.get(paramString);
  228. int j = localList.size();
  229. int i = 0;
  230. while (i < j)
  231. {
  232. ((IMEventListener)localList.get(i)).onIMEvent(paramString, paramIMMessage);
  233. i += 1;
  234. }
  235. }
  236. }
  237. private void dispatchIMEvent(String paramString, List<IMMessage> paramList)
  238. {
  239. if (this.mapIMEventListeners.containsKey(paramString))
  240. {
  241. List localList = (List)this.mapIMEventListeners.get(paramString);
  242. int j = localList.size();
  243. int i = 0;
  244. while (i < j)
  245. {
  246. ((IMEventListener)localList.get(i)).onIMListMsg(paramString, paramList);
  247. i += 1;
  248. }
  249. }
  250. }
  251. private byte[] getFileByPath(String paramString)
  252. {
  253. if ((paramString == null) || (paramString.equalsIgnoreCase("")))
  254. return null;
  255. try
  256. {
  257. paramString = ImageUtil.getCompressImage(paramString);
  258. return paramString;
  259. }
  260. catch (Exception paramString)
  261. {
  262. paramString.printStackTrace();
  263. }
  264. return null;
  265. }
  266. private void getImServer()
  267. {
  268. UserInfo localUserInfo = InfoManager.getInstance().getUserProfile().getUserInfo();
  269. if ((localUserInfo != null) && (localUserInfo.userKey != null) && (!localUserInfo.userKey.equalsIgnoreCase("")))
  270. {
  271. HashMap localHashMap = new HashMap();
  272. localHashMap.put("from", localUserInfo.userKey);
  273. DataManager.getInstance().getData("GET_IM_SERVER", this, localHashMap);
  274. }
  275. }
  276. public static IMAgent getInstance()
  277. {
  278. if (instance == null)
  279. instance = new IMAgent();
  280. return instance;
  281. }
  282. private IMMessage getLatestGroupMessage(String paramString)
  283. {
  284. if (paramString == null)
  285. return null;
  286. paramString = (List)this.mapMessage.get(paramString);
  287. if (paramString == null)
  288. return null;
  289. if (paramString.size() == 0)
  290. return null;
  291. return (IMMessage)paramString.get(paramString.size() - 1);
  292. }
  293. private IMMessage getLatestUserMessage(String paramString)
  294. {
  295. if (paramString == null)
  296. return null;
  297. paramString = (List)this.mapMessage.get(paramString);
  298. if (paramString == null)
  299. return null;
  300. if (paramString.size() == 0)
  301. return null;
  302. return (IMMessage)paramString.get(paramString.size() - 1);
  303. }
  304. private String getMsgId()
  305. {
  306. Object localObject = InfoManager.getInstance().getUserProfile().getUserInfo();
  307. if (localObject != null)
  308. {
  309. localObject = ((UserInfo)localObject).userKey;
  310. if (localObject != null)
  311. {
  312. long l = System.currentTimeMillis();
  313. return (String)localObject + l;
  314. }
  315. }
  316. return null;
  317. }
  318. private void handleConnectFailure()
  319. {
  320. this.connected = false;
  321. this.connecting = false;
  322. this.loginSuccess = false;
  323. if (this.mWebSocket != null)
  324. this.mWebSocket.disconnect();
  325. if (!InfoManager.getInstance().hasConnectedNetwork())
  326. {
  327. this.mDispatchHandler.sendMessage(this.mDispatchHandler.obtainMessage(2, null));
  328. return;
  329. }
  330. asyncConnect();
  331. }
  332. private void handleMessage(String paramString)
  333. {
  334. if ((paramString == null) || (paramString.equalsIgnoreCase("")));
  335. while (true)
  336. {
  337. return;
  338. try
  339. {
  340. paramString = (JSONObject)JSON.parse(paramString);
  341. String str = paramString.getString("event");
  342. if (str != null)
  343. {
  344. if (str.equalsIgnoreCase("login"))
  345. {
  346. recvLogin();
  347. return;
  348. }
  349. Object localObject;
  350. if (str.equalsIgnoreCase("peer"))
  351. {
  352. if (this.loginSuccess)
  353. {
  354. str = paramString.getString("from");
  355. if (canHandle(str, 0))
  356. {
  357. localObject = new IMMessage();
  358. ((IMMessage)localObject).mFromID = str;
  359. ((IMMessage)localObject).mFromName = paramString.getString("fromName");
  360. ((IMMessage)localObject).mGender = paramString.getString("fromGender");
  361. ((IMMessage)localObject).mMsgId = paramString.getString("id");
  362. recvMsg(0, paramString.getJSONArray("body"), (IMMessage)localObject);
  363. }
  364. }
  365. }
  366. else if ((str.equalsIgnoreCase("group")) && (this.loginSuccess))
  367. {
  368. str = paramString.getString("from");
  369. if (!isSelf(str))
  370. {
  371. localObject = paramString.getString("to");
  372. if (canHandle((String)localObject, 1))
  373. {
  374. IMMessage localIMMessage = new IMMessage();
  375. localIMMessage.mFromID = str;
  376. localIMMessage.mFromGroupId = ((String)localObject);
  377. localIMMessage.mFromName = paramString.getString("fromName");
  378. localIMMessage.mGender = paramString.getString("fromGender");
  379. localIMMessage.mMsgId = paramString.getString("id");
  380. recvMsg(1, paramString.getJSONArray("body"), localIMMessage);
  381. return;
  382. }
  383. }
  384. }
  385. }
  386. }
  387. catch (Exception paramString)
  388. {
  389. }
  390. }
  391. }
  392. private int hasInTempWatchGroups(String paramString)
  393. {
  394. int j;
  395. if (paramString == null)
  396. {
  397. j = -1;
  398. return j;
  399. }
  400. int i = 0;
  401. while (true)
  402. {
  403. if (i >= this.mLstTempWatchGroups.size())
  404. break label52;
  405. j = i;
  406. if (((String)this.mLstTempWatchGroups.get(i)).equalsIgnoreCase(paramString))
  407. break;
  408. i += 1;
  409. }
  410. label52: return -1;
  411. }
  412. private boolean isSelf(String paramString)
  413. {
  414. if (paramString == null);
  415. UserInfo localUserInfo;
  416. do
  417. {
  418. return false;
  419. localUserInfo = InfoManager.getInstance().getUserProfile().getUserInfo();
  420. }
  421. while ((localUserInfo == null) || (localUserInfo.userKey == null) || (!localUserInfo.userKey.equalsIgnoreCase(paramString)));
  422. return true;
  423. }
  424. private boolean isSetBlack(IMMessage paramIMMessage)
  425. {
  426. if (paramIMMessage == null);
  427. do
  428. {
  429. do
  430. {
  431. do
  432. return false;
  433. while (paramIMMessage.isGroupMsg());
  434. if (!IMUtil.isSetBlack(paramIMMessage.mMessage))
  435. break;
  436. }
  437. while (!CloudCenter.getInstance().isLiveRoomAdmin(paramIMMessage.mFromID));
  438. if (InfoManager.getInstance().getUserProfile().getUserInfo() != null)
  439. InfoManager.getInstance().getUserProfile().getUserInfo().setBlocked(true);
  440. return true;
  441. }
  442. while (!ImBlackList.inBlackList(this.mContext, paramIMMessage.mFromID));
  443. return true;
  444. }
  445. private void login()
  446. {
  447. try
  448. {
  449. Object localObject = InfoManager.getInstance().getUserProfile().getUserInfo();
  450. if ((localObject != null) && (this.mWebSocket != null))
  451. {
  452. JSONObject localJSONObject = new JSONObject();
  453. localJSONObject.put("event", "login");
  454. localJSONObject.put("from", ((UserInfo)localObject).userKey);
  455. localObject = localJSONObject.toString();
  456. if (localObject != null)
  457. this.mWebSocket.send((String)localObject);
  458. }
  459. return;
  460. }
  461. catch (Exception localException)
  462. {
  463. localException.printStackTrace();
  464. }
  465. }
  466. private boolean needSendMsgNotification(IMMessage paramIMMessage)
  467. {
  468. if (paramIMMessage == null);
  469. String str;
  470. do
  471. {
  472. do
  473. {
  474. return false;
  475. if (paramIMMessage.isGroupMsg())
  476. return hasEnabledGroup(paramIMMessage.mFromGroupId);
  477. if (!IMUtil.isSetBlack(paramIMMessage.mMessage))
  478. break;
  479. }
  480. while (InfoManager.getInstance().getUserProfile().getUserInfo() == null);
  481. InfoManager.getInstance().getUserProfile().getUserInfo().setBlocked(true);
  482. return false;
  483. str = paramIMMessage.mFromID;
  484. }
  485. while (ControllerManager.getInstance().isActive(paramIMMessage.chatType, str));
  486. return true;
  487. }
  488. private void recvLogin()
  489. {
  490. this.loginSuccess = true;
  491. }
  492. private void recvMsg(int paramInt, JSONArray paramJSONArray, IMMessage paramIMMessage)
  493. {
  494. if ((paramJSONArray != null) && (paramIMMessage != null));
  495. try
  496. {
  497. if (paramJSONArray.size() == 1)
  498. {
  499. IMMessage.parseData(paramJSONArray.getJSONObject(0), paramIMMessage);
  500. paramIMMessage.chatType = paramInt;
  501. if (paramIMMessage != null)
  502. {
  503. if (isSetBlack(paramIMMessage))
  504. return;
  505. if ((paramIMMessage.mFromAvatar == null) || (paramIMMessage.mFromAvatar.equalsIgnoreCase("")))
  506. paramIMMessage.mFromAvatar = getUserAvatar(paramIMMessage.mFromID);
  507. if ((paramIMMessage.mFromGroupId != null) && (!paramIMMessage.mFromGroupId.equalsIgnoreCase("")) && (paramIMMessage.mGroupName == null) && (paramIMMessage.isGroupMsg()))
  508. {
  509. paramJSONArray = getGroupInfo(paramIMMessage.mFromGroupId);
  510. if (paramJSONArray != null)
  511. paramIMMessage.mGroupName = paramJSONArray.groupName;
  512. }
  513. long l = InfoManager.getInstance().getMsgSeq() + 1L;
  514. paramIMMessage.msgSeq = l;
  515. InfoManager.getInstance().setMsgSeq(l);
  516. this.mRecvMsgCnt += 1;
  517. if (!paramIMMessage.isGroupMsg())
  518. {
  519. if (InfoManager.getInstance().getUserProfile() != null)
  520. paramIMMessage.mToUserId = InfoManager.getInstance().getUserProfile().getUserKey();
  521. IMContacts.getInstance().addRecentContacts(paramIMMessage.buildUserInfo());
  522. paramJSONArray = (Integer)this.mapUnReadMsgCnt.get(paramIMMessage.mFromID);
  523. if (paramJSONArray == null)
  524. this.mapUnReadMsgCnt.put(paramIMMessage.mFromID, Integer.valueOf(1));
  525. while (true)
  526. {
  527. this.mTotalUnReadMsgCnt += 1;
  528. addMsgToDS(paramIMMessage);
  529. this.mDispatchHandler.sendMessage(this.mDispatchHandler.obtainMessage(0, paramIMMessage));
  530. if (!needSendMsgNotification(paramIMMessage))
  531. break;
  532. sendNotification(paramIMMessage);
  533. return;
  534. paramInt = paramJSONArray.intValue();
  535. this.mapUnReadMsgCnt.put(paramIMMessage.mFromID, Integer.valueOf(paramInt + 1));
  536. }
  537. }
  538. IMContacts.getInstance().addRecentContacts(paramIMMessage.mFromGroupId);
  539. paramJSONArray = (Integer)this.mapUnReadMsgCnt.get(paramIMMessage.mFromGroupId);
  540. if (paramJSONArray == null)
  541. this.mapUnReadMsgCnt.put(paramIMMessage.mFromGroupId, Integer.valueOf(1));
  542. while (true)
  543. {
  544. this.mTotalUnReadMsgCnt += 1;
  545. break;
  546. paramInt = paramJSONArray.intValue();
  547. this.mapUnReadMsgCnt.put(paramIMMessage.mFromGroupId, Integer.valueOf(paramInt + 1));
  548. }
  549. }
  550. }
  551. return;
  552. }
  553. catch (Exception paramJSONArray)
  554. {
  555. }
  556. }
  557. private void saveEnableGroup()
  558. {
  559. String str = null;
  560. int i = 0;
  561. if (i < this.mLstEnableGroups.size())
  562. {
  563. if (str != null);
  564. for (str = str + "_"; ; str = "")
  565. {
  566. str = str + (String)this.mLstEnableGroups.get(i);
  567. i += 1;
  568. break;
  569. }
  570. }
  571. if (str != null)
  572. GlobalCfg.getInstance(this.mContext).setEnableGroups(str);
  573. }
  574. private void sendNotification(IMMessage paramIMMessage)
  575. {
  576. }
  577. public void addBarrageInfo(int paramInt1, int paramInt2)
  578. {
  579. this.mAddProgramId = paramInt1;
  580. this.mAddTime = paramInt2;
  581. }
  582. public void addBaseUserInfo(String paramString1, String paramString2, String paramString3)
  583. {
  584. if ((paramString1 == null) || (paramString2 == null))
  585. return;
  586. BaseUserInfoPool.putBaseInfo(paramString1, paramString2, paramString3);
  587. }
  588. public void addGroup(String paramString)
  589. {
  590. if (paramString == null)
  591. return;
  592. int i = 0;
  593. while (true)
  594. {
  595. if (i >= this.mLstTempWatchGroups.size())
  596. break label36;
  597. if (hasInTempWatchGroups(paramString) != -1)
  598. break;
  599. i += 1;
  600. }
  601. label36: this.mLstTempWatchGroups.add(paramString);
  602. }
  603. public boolean allowRecvMsg()
  604. {
  605. long l = System.currentTimeMillis();
  606. if ((l - mLastRecvMsgTime) / 1000L > MAX_RecvMsg_INTERVAL)
  607. {
  608. mLastRecvMsgTime = l;
  609. return true;
  610. }
  611. return false;
  612. }
  613. public void asyncConnect()
  614. {
  615. this.connectHandler.removeCallbacks(this.doConnect);
  616. long l = RangeRandom.Random(this.CONNECT_INTERVAL);
  617. this.connectHandler.postDelayed(this.doConnect, l * 1000L);
  618. }
  619. public void clearNotificationMsg()
  620. {
  621. this.mLastFromId = null;
  622. this.mRecvMsgCnt = 0;
  623. this.mRecvMsgTime = 0L;
  624. }
  625. public boolean clearUnreadCnt(String paramString)
  626. {
  627. if (paramString == null)
  628. return false;
  629. if (this.mapUnReadMsgCnt.get(paramString) == null)
  630. return false;
  631. int i = ((Integer)this.mapUnReadMsgCnt.get(paramString)).intValue();
  632. this.mTotalUnReadMsgCnt -= i;
  633. this.mapUnReadMsgCnt.put(paramString, Integer.valueOf(0));
  634. return true;
  635. }
  636. public void connect()
  637. {
  638. getImServer();
  639. }
  640. public void disableGroup(String paramString)
  641. {
  642. int i = 0;
  643. while (true)
  644. {
  645. if (i < this.mLstEnableGroups.size())
  646. {
  647. if (((String)this.mLstEnableGroups.get(i)).equalsIgnoreCase(paramString))
  648. {
  649. this.mLstEnableGroups.remove(i);
  650. saveEnableGroup();
  651. }
  652. }
  653. else
  654. return;
  655. i += 1;
  656. }
  657. }
  658. public void enableGroup(String paramString)
  659. {
  660. if (paramString == null);
  661. while (hasEnableGroups(paramString))
  662. return;
  663. this.mLstEnableGroups.add(paramString);
  664. saveEnableGroup();
  665. }
  666. public String getATTaName(String paramString)
  667. {
  668. if ((paramString != null) && (paramString.startsWith("@")))
  669. {
  670. String str = "";
  671. int i = 0;
  672. while (true)
  673. {
  674. if ((i >= paramString.length()) || (paramString.charAt(i) == ' '))
  675. {
  676. if (str.length() <= 1)
  677. break;
  678. return str;
  679. }
  680. str = str + paramString.charAt(i);
  681. i += 1;
  682. }
  683. }
  684. return null;
  685. }
  686. public int getAddBarrageTime()
  687. {
  688. return this.mAddTime;
  689. }
  690. public String getCheckinText()
  691. {
  692. switch ((int)RangeRandom.Random(5L))
  693. {
  694. default:
  695. case 0:
  696. case 1:
  697. case 2:
  698. do
  699. {
  700. do
  701. {
  702. return "签个到,大家好呀";
  703. str = InfoManager.getInstance().getCurrentCity();
  704. }
  705. while ((str == null) || (str.equalsIgnoreCase("")));
  706. str = "我在" + str;
  707. return str + "签个到,大家好呀";
  708. return "大家好,有人吗?";
  709. str = InfoManager.getInstance().getCurrentCity();
  710. }
  711. while ((str == null) || (str.equalsIgnoreCase("")));
  712. String str = "大家好,有" + str;
  713. return str + "的吗?";
  714. case 3:
  715. return "哈喽,大家好";
  716. case 4:
  717. }
  718. return "各位帅哥美女好";
  719. }
  720. public GroupInfo getGroupInfo(String paramString)
  721. {
  722. if (paramString == null)
  723. return null;
  724. return (GroupInfo)this.mapGroupInfo.get(paramString);
  725. }
  726. public List<UserInfo> getGroupMembers(String paramString)
  727. {
  728. if (TextUtils.equals(paramString, this.mCurrentGroupId))
  729. return this.mCurrentGroupUsers;
  730. return null;
  731. }
  732. public List<IMMessage> getImageBarrage(int paramInt)
  733. {
  734. if (this.mBarraeProgramId == paramInt)
  735. return this.mLstImageBarrage;
  736. return null;
  737. }
  738. public IMMessage getSendImageBarrage()
  739. {
  740. return this.mLstSendImageBarrage;
  741. }
  742. public List<IMMessage> getTxtBarrage(int paramInt)
  743. {
  744. if (this.mBarraeProgramId == paramInt)
  745. return this.mLstTextBarrage;
  746. return null;
  747. }
  748. public int getUnreadCnt()
  749. {
  750. if (this.mTotalUnReadMsgCnt < 0)
  751. return 0;
  752. return this.mTotalUnReadMsgCnt;
  753. }
  754. public int getUnreadCnt(String paramString)
  755. {
  756. if (paramString == null);
  757. while (this.mapUnReadMsgCnt.get(paramString) == null)
  758. return 0;
  759. return ((Integer)this.mapUnReadMsgCnt.get(paramString)).intValue();
  760. }
  761. public String getUserAvatar(String paramString)
  762. {
  763. if ((paramString == null) || (paramString.length() == 0))
  764. return null;
  765. return BaseUserInfoPool.getAvatar(paramString);
  766. }
  767. public UserInfo getUserInfoByName(String paramString)
  768. {
  769. if ((paramString != null) && (!paramString.equalsIgnoreCase("")))
  770. return (UserInfo)this.mapATUser.get(paramString);
  771. return null;
  772. }
  773. public void handleConnect()
  774. {
  775. this.connected = true;
  776. this.connecting = false;
  777. if (!this.loginSuccess)
  778. {
  779. login();
  780. this.autoLogin = false;
  781. }
  782. }
  783. public boolean hasCheckIn(String paramString)
  784. {
  785. if (paramString == null);
  786. while (true)
  787. {
  788. return false;
  789. int i = 0;
  790. while (i < this.lstHasCheckin.size())
  791. {
  792. if (((String)this.lstHasCheckin.get(i)).equalsIgnoreCase(paramString))
  793. return true;
  794. i += 1;
  795. }
  796. }
  797. }
  798. public boolean hasEnableGroups(String paramString)
  799. {
  800. if ((paramString == null) || (this.mLstEnableGroups == null));
  801. while (true)
  802. {
  803. return false;
  804. int i = 0;
  805. while (i < this.mLstEnableGroups.size())
  806. {
  807. if (((String)this.mLstEnableGroups.get(i)).equalsIgnoreCase(paramString))
  808. return true;
  809. i += 1;
  810. }
  811. }
  812. }
  813. public boolean hasEnabledGroup(String paramString)
  814. {
  815. if ((paramString == null) || (this.mLstEnableGroups == null));
  816. while (true)
  817. {
  818. return false;
  819. int i = 0;
  820. while (i < this.mLstEnableGroups.size())
  821. {
  822. if (((String)this.mLstEnableGroups.get(i)).equalsIgnoreCase(paramString))
  823. return true;
  824. i += 1;
  825. }
  826. }
  827. }
  828. public void initEnableGroups()
  829. {
  830. Object localObject = GlobalCfg.getInstance(this.mContext).getEnableGroups();
  831. if (localObject != null)
  832. {
  833. localObject = ((String)localObject).split("_");
  834. if (localObject != null)
  835. break label28;
  836. }
  837. while (true)
  838. {
  839. return;
  840. label28: int i = 0;
  841. while (i < localObject.length)
  842. {
  843. this.mLstEnableGroups.add(localObject[i]);
  844. i += 1;
  845. }
  846. }
  847. }
  848. public void initGroup()
  849. {
  850. List localList = IMContacts.getInstance().getWatchedGroupContacts();
  851. if (localList != null)
  852. {
  853. int i = 0;
  854. while (i < localList.size())
  855. {
  856. this.mapGroupInfo.put(((GroupInfo)localList.get(i)).groupId, localList.get(i));
  857. i += 1;
  858. }
  859. }
  860. }
  861. public void initService(Context paramContext)
  862. {
  863. this.mContext = paramContext;
  864. }
  865. public void initUnReadMsg()
  866. {
  867. Object localObject2 = GlobalCfg.getInstance(this.mContext).getUnReadID();
  868. Object localObject1 = GlobalCfg.getInstance(this.mContext).getUnReadCnt();
  869. if ((localObject2 != null) && (localObject1 != null))
  870. {
  871. localObject2 = ((String)localObject2).split("_");
  872. if (localObject2 != null)
  873. break label43;
  874. }
  875. while (true)
  876. {
  877. return;
  878. label43: localObject1 = ((String)localObject1).split("_");
  879. if ((localObject1 != null) && (localObject1.length == localObject2.length))
  880. {
  881. int i = 0;
  882. while (i < localObject2.length)
  883. {
  884. if ((localObject2[i] != null) && (localObject2[i].length() > 0) && (localObject1[i] != null) && (localObject1[i].length() > 0))
  885. {
  886. int j = Integer.valueOf(localObject1[i]).intValue();
  887. this.mTotalUnReadMsgCnt += j;
  888. this.mapUnReadMsgCnt.put(localObject2[i], Integer.valueOf(j));
  889. }
  890. i += 1;
  891. }
  892. }
  893. }
  894. }
  895. public boolean isCheckin(int paramInt)
  896. {
  897. return paramInt == 1;
  898. }
  899. public void leaveGroup(String paramString)
  900. {
  901. if (paramString == null);
  902. int i;
  903. do
  904. {
  905. return;
  906. i = hasInTempWatchGroups(paramString);
  907. }
  908. while (i == -1);
  909. this.mLstTempWatchGroups.remove(i);
  910. }
  911. public void likeBarrage(IMMessage paramIMMessage)
  912. {
  913. if (!CloudCenter.getInstance().isLogin(false))
  914. Toast.makeText(this.mContext, "登录后才能点赞", 1).show();
  915. while ((paramIMMessage == null) || (paramIMMessage.mMsgId == null))
  916. return;
  917. new HashMap().put("id", paramIMMessage.mMsgId);
  918. DataManager.getInstance().getData("POST_LIKE_BARRAGE", this, null);
  919. }
  920. public void loadBarrage(int paramInt, RootNode.IInfoUpdateEventListener paramIInfoUpdateEventListener)
  921. {
  922. HashMap localHashMap = new HashMap();
  923. localHashMap.put("id", String.valueOf(paramInt));
  924. this.mBarraeProgramId = paramInt;
  925. DataManager.getInstance().getData("GET_PROGRAM_BARRAGE", this, localHashMap);
  926. if (paramIInfoUpdateEventListener != null)
  927. InfoManager.getInstance().root().registerInfoUpdateListener(paramIInfoUpdateEventListener, 8);
  928. }
  929. public void loadGroupInfo(String paramString, RootNode.IInfoUpdateEventListener paramIInfoUpdateEventListener)
  930. {
  931. if ((paramString != null) && (!paramString.equalsIgnoreCase("")))
  932. IMDataLoadWrapper.loadGroupInfo(paramString, this);
  933. if (paramIInfoUpdateEventListener != null)
  934. InfoManager.getInstance().root().registerInfoUpdateListener(paramIInfoUpdateEventListener, 6);
  935. }
  936. public void loadGroupMembers(String paramString, int paramInt1, int paramInt2)
  937. {
  938. this.mCurrentGroupId = paramString;
  939. IMDataLoadWrapper.loadGroupUserList(paramString, paramInt1, paramInt2, this);
  940. }
  941. public void loadLatestGroupMsgFromNet(String paramString1, String paramString2)
  942. {
  943. if ((paramString1 == null) || (paramString2 == null) || (paramString1.equalsIgnoreCase("")) || (paramString2.equalsIgnoreCase("")))
  944. return;
  945. HashMap localHashMap = new HashMap();
  946. localHashMap.put("groupId", paramString1);
  947. localHashMap.put("msgId", paramString2);
  948. DataManager.getInstance().getData("get_im_group_latest_msg", this, localHashMap);
  949. }
  950. public IMMessage loadLatestMsg(String paramString, int paramInt)
  951. {
  952. if (paramString == null)
  953. return null;
  954. List localList = (List)this.mapMessage.get(paramString);
  955. int i;
  956. if (localList == null)
  957. {
  958. if (paramInt == 1)
  959. localList = IMDatabaseDS.getInstance().getGroupConversation(paramString, this.MSG_CNT_PER_PAGE);
  960. while (localList != null)
  961. {
  962. Collections.reverse(localList);
  963. i = 0;
  964. while (true)
  965. if (i < localList.size())
  966. {
  967. if ((((IMMessage)localList.get(i)).mFromAvatar == null) || (((IMMessage)localList.get(i)).mFromAvatar.equalsIgnoreCase("")))
  968. ((IMMessage)localList.get(i)).mFromAvatar = getUserAvatar(((IMMessage)localList.get(i)).mFromID);
  969. i += 1;
  970. continue;
  971. if (paramInt != 0)
  972. break label276;
  973. UserInfo localUserInfo = InfoManager.getInstance().getUserProfile().getUserInfo();
  974. if (localUserInfo == null)
  975. break label276;
  976. localList = IMDatabaseDS.getInstance().getPrivateConversation(localUserInfo.userKey, paramString, this.MSG_CNT_PER_PAGE);
  977. break;
  978. }
  979. this.mapMessage.put(paramString, localList);
  980. }
  981. }
  982. while (true)
  983. {
  984. if (localList != null)
  985. {
  986. i = localList.size();
  987. if (i > 0)
  988. {
  989. if (paramInt == 1)
  990. loadLatestGroupMsgFromNet(((IMMessage)localList.get(i - 1)).mFromGroupId, ((IMMessage)localList.get(i - 1)).mMsgId);
  991. while (true)
  992. {
  993. return (IMMessage)localList.get(i - 1);
  994. if (paramInt != 0);
  995. }
  996. }
  997. }
  998. return null;
  999. label276: break;
  1000. }
  1001. }
  1002. public void loadLatestPeerMsgFromNet()
  1003. {
  1004. UserInfo localUserInfo = InfoManager.getInstance().getUserProfile().getUserInfo();
  1005. if (localUserInfo == null)
  1006. return;
  1007. HashMap localHashMap = new HashMap();
  1008. localHashMap.put("userid", localUserInfo.userKey);
  1009. DataManager.getInstance().getData("get_im_peer_latest_msg", this, localHashMap);
  1010. }
  1011. public List<IMMessage> loadMoreGroupMsgFromDB(String paramString, int paramInt)
  1012. {
  1013. int i = 0;
  1014. if (paramString == null)
  1015. paramString = null;
  1016. do
  1017. {
  1018. return paramString;
  1019. if (InfoManager.getInstance().getUserProfile().getUserInfo() == null)
  1020. return null;
  1021. List localList = (List)this.mapMessage.get(paramString);
  1022. if (localList == null)
  1023. {
  1024. localList = IMDatabaseDS.getInstance().getGroupConversation(paramString, this.MSG_CNT_PER_PAGE);
  1025. if (localList == null)
  1026. break;
  1027. Collections.reverse(localList);
  1028. paramInt = i;
  1029. while (paramInt < localList.size())
  1030. {
  1031. if ((((IMMessage)localList.get(paramInt)).mFromAvatar == null) || (((IMMessage)localList.get(paramInt)).mFromAvatar.equalsIgnoreCase("")))
  1032. ((IMMessage)localList.get(paramInt)).mFromAvatar = getUserAvatar(((IMMessage)localList.get(paramInt)).mFromID);
  1033. paramInt += 1;
  1034. }
  1035. this.mapMessage.put(paramString, localList);
  1036. return localList;
  1037. }
  1038. if (localList.size() <= 0)
  1039. break;
  1040. if (((IMMessage)localList.get(0)).msgSeq == paramInt)
  1041. {
  1042. paramString = IMDatabaseDS.getInstance().getGroupConversationLessThan(paramString, this.MSG_CNT_PER_PAGE, paramInt);
  1043. if ((paramString == null) || (paramString.size() <= 0))
  1044. break;
  1045. Collections.reverse(paramString);
  1046. localList.addAll(0, paramString);
  1047. paramInt = 0;
  1048. while (paramInt < localList.size())
  1049. {
  1050. if ((((IMMessage)localList.get(paramInt)).mFromAvatar == null) || (((IMMessage)localList.get(paramInt)).mFromAvatar.equalsIgnoreCase("")))
  1051. ((IMMessage)localList.get(paramInt)).mFromAvatar = getUserAvatar(((IMMessage)localList.get(paramInt)).mFromID);
  1052. paramInt += 1;
  1053. }
  1054. return paramString;
  1055. }
  1056. paramString = localList;
  1057. }
  1058. while (paramInt == -1);
  1059. return null;
  1060. }
  1061. public List<IMMessage> loadMoreGroupMsgFromNet(String paramString1, String paramString2)
  1062. {
  1063. if (paramString1 == null)
  1064. paramString2 = null;
  1065. List localList;
  1066. do
  1067. {
  1068. return paramString2;
  1069. if (paramString2 != null)
  1070. break label89;
  1071. localList = (List)this.mapMessage.get(paramString1);
  1072. if (localList == null)
  1073. break;
  1074. paramString2 = localList;
  1075. }
  1076. while (localList.size() > 0);
  1077. paramString2 = new HashMap();
  1078. paramString2.put("group", paramString1);
  1079. paramString2.put("fetchsize", String.valueOf(this.IM_HISTORY_SIZE));
  1080. DataManager.getInstance().getData("GET_IM_HISTORY_FROM_SERVER", this, paramString2);
  1081. label89: return null;
  1082. }
  1083. public void loadMoreGroupMsgFromNet(String paramString, int paramInt)
  1084. {
  1085. if (paramString == null)
  1086. return;
  1087. HashMap localHashMap = new HashMap();
  1088. localHashMap.put("group", paramString);
  1089. localHashMap.put("fetchsize", String.valueOf(paramInt));
  1090. DataManager.getInstance().getData("GET_IM_HISTORY_FROM_SERVER", this, localHashMap);
  1091. }
  1092. public List<IMMessage> loadMoreUserMsgFromDB(String paramString, int paramInt)
  1093. {
  1094. int i = 0;
  1095. if (paramString == null)
  1096. paramString = null;
  1097. do
  1098. {
  1099. return paramString;
  1100. UserInfo localUserInfo = InfoManager.getInstance().getUserProfile().getUserInfo();
  1101. if (localUserInfo == null)
  1102. return null;
  1103. List localList = (List)this.mapMessage.get(paramString);
  1104. if (localList == null)
  1105. {
  1106. localList = IMDatabaseDS.getInstance().getPrivateConversation(localUserInfo.userKey, paramString, this.MSG_CNT_PER_PAGE);
  1107. if (localList == null)
  1108. break;
  1109. Collections.reverse(localList);
  1110. paramInt = i;
  1111. while (paramInt < localList.size())
  1112. {
  1113. if ((((IMMessage)localList.get(paramInt)).mFromAvatar == null) || (((IMMessage)localList.get(paramInt)).mFromAvatar.equalsIgnoreCase("")))
  1114. ((IMMessage)localList.get(paramInt)).mFromAvatar = getUserAvatar(((IMMessage)localList.get(paramInt)).mFromID);
  1115. paramInt += 1;
  1116. }
  1117. this.mapMessage.put(paramString, localList);
  1118. return localList;
  1119. }
  1120. if (localList.size() <= 0)
  1121. break;
  1122. if (((IMMessage)localList.get(0)).msgSeq == paramInt)
  1123. {
  1124. paramString = IMDatabaseDS.getInstance().getPrivateConversationLessThan(localUserInfo.userKey, paramString, this.MSG_CNT_PER_PAGE, paramInt);
  1125. if ((paramString == null) || (paramString.size() <= 0))
  1126. break;
  1127. Collections.reverse(paramString);
  1128. localList.addAll(0, paramString);
  1129. paramInt = 0;
  1130. while (paramInt < localList.size())
  1131. {
  1132. if ((((IMMessage)localList.get(paramInt)).mFromAvatar == null) || (((IMMessage)localList.get(paramInt)).mFromAvatar.equalsIgnoreCase("")))
  1133. ((IMMessage)localList.get(paramInt)).mFromAvatar = getUserAvatar(((IMMessage)localList.get(paramInt)).mFromID);
  1134. paramInt += 1;
  1135. }
  1136. return paramString;
  1137. }
  1138. paramString = localList;
  1139. }
  1140. while (paramInt == -1);
  1141. return null;
  1142. }
  1143. public void loadMoreUserMsgFromNet(String paramString)
  1144. {
  1145. if (paramString == null);
  1146. UserInfo localUserInfo;
  1147. do
  1148. {
  1149. return;
  1150. localUserInfo = InfoManager.getInstance().getUserProfile().getUserInfo();
  1151. }
  1152. while (localUserInfo == null);
  1153. HashMap localHashMap = new HashMap();
  1154. localHashMap.put("sender", paramString);
  1155. localHashMap.put("receiver", localUserInfo.userKey);
  1156. DataManager.getInstance().getData("get_im_peer_history_from_server", this, localHashMap);
  1157. }
  1158. public void logout()
  1159. {
  1160. this.connected = false;
  1161. this.connecting = false;
  1162. this.loginSuccess = false;
  1163. if (this.mWebSocket != null)
  1164. this.mWebSocket.disconnect();
  1165. }
  1166. public void onNetChanged(String paramString)
  1167. {
  1168. if (paramString == null);
  1169. do
  1170. {
  1171. return;
  1172. if ((paramString.equalsIgnoreCase("nonet")) || (paramString.equalsIgnoreCase(this.mLastNetType)))
  1173. {
  1174. this.mLastNetType = paramString;
  1175. return;
  1176. }
  1177. this.mLastNetType = paramString;
  1178. }
  1179. while (this.connected);
  1180. _connect();
  1181. }
  1182. public void onRecvResult(Result paramResult, Object paramObject1, IResultToken paramIResultToken, Object paramObject2)
  1183. {
  1184. paramObject1 = paramIResultToken.getType();
  1185. int i;
  1186. if (paramResult.getSuccess())
  1187. {
  1188. if (paramObject1.equalsIgnoreCase("get_group_info"))
  1189. {
  1190. paramResult = (GroupInfo)paramResult.getData();
  1191. if (paramResult != null)
  1192. {
  1193. addGroupInfo(paramResult);
  1194. InfoManager.getInstance().root().setInfoUpdate(6);
  1195. IMContacts.getInstance().updateGroupInfo(paramResult.groupId);
  1196. }
  1197. }
  1198. do
  1199. {
  1200. do
  1201. {
  1202. do
  1203. {
  1204. do
  1205. {
  1206. return;
  1207. if (!paramObject1.equalsIgnoreCase("GET_PROGRAM_BARRAGE"))
  1208. break;
  1209. paramObject1 = (String)((Map)paramObject2).get("id");
  1210. paramResult = (List)paramResult.getData();
  1211. }
  1212. while ((paramResult == null) || (paramObject1 == null) || (Integer.valueOf(paramObject1).intValue() != this.mBarraeProgramId) || (paramResult.size() != 2));
  1213. this.mLstTextBarrage = ((List)paramResult.get(0));
  1214. this.mLstImageBarrage = ((List)paramResult.get(1));
  1215. InfoManager.getInstance().root().setInfoUpdate(8);
  1216. return;
  1217. if (paramObject1.equalsIgnoreCase("POST_PROGRAM_BARRAGE"))
  1218. {
  1219. this.mLstSendImageBarrage = ((IMMessage)paramResult.getData());
  1220. InfoManager.getInstance().root().setInfoUpdate(9);
  1221. Toast.makeText(this.mContext, "发送弹幕成功", 1).show();
  1222. return;
  1223. }
  1224. if (!paramObject1.equalsIgnoreCase("get_group_users"))
  1225. break;
  1226. paramResult = (List)paramResult.getData();
  1227. }
  1228. while (paramResult == null);
  1229. this.mCurrentGroupUsers = paramResult;
  1230. i = 0;
  1231. while (i < paramResult.size())
  1232. {
  1233. paramObject1 = (UserInfo)paramResult.get(i);
  1234. BaseUserInfoPool.putBaseInfo(paramObject1.userKey, paramObject1.snsInfo.sns_avatar, paramObject1.snsInfo.sns_gender);
  1235. i += 1;
  1236. }
  1237. InfoManager.getInstance().root().setInfoUpdate(7);
  1238. return;
  1239. if (!paramObject1.equalsIgnoreCase("GET_IM_SERVER"))
  1240. break;
  1241. paramResult = (String)paramResult.getData();
  1242. }
  1243. while ((paramResult == null) || (paramResult.equalsIgnoreCase("")));
  1244. this.connectUrl = paramResult;
  1245. _connect();
  1246. return;
  1247. if (!paramObject1.equalsIgnoreCase("GET_IM_HISTORY_FROM_SERVER"))
  1248. break;
  1249. paramObject1 = (String)((HashMap)paramObject2).get("group");
  1250. paramResult = (List)paramResult.getData();
  1251. }
  1252. while ((paramObject1 == null) || (paramResult == null) || (paramResult.size() <= 0));
  1253. paramIResultToken = getLatestGroupMessage(paramObject1);
  1254. if (paramIResultToken == null)
  1255. break label1366;
  1256. }
  1257. label1366: for (long l1 = paramIResultToken.publish; ; l1 = 0L)
  1258. {
  1259. boolean bool = IMContacts.getInstance().hasWatchedGroup(paramObject1);
  1260. i = 0;
  1261. long l2;
  1262. while (i < paramResult.size())
  1263. {
  1264. paramIResultToken = (IMMessage)paramResult.get(i);
  1265. if ((paramIResultToken.isGroupMsg()) && (l1 < paramIResultToken.publish))
  1266. {
  1267. if (bool)
  1268. LatestMessages.putMessage(paramIResultToken.mFromGroupId, paramIResultToken);
  1269. l2 = InfoManager.getInstance().getMsgSeq() + 1L;
  1270. paramIResultToken.msgSeq = l2;
  1271. InfoManager.getInstance().setMsgSeq(l2);
  1272. if (paramIResultToken.mGroupName == null)
  1273. {
  1274. paramObject2 = (GroupInfo)this.mapGroupInfo.get(paramIResultToken.mFromGroupId);
  1275. if (paramObject2 != null)
  1276. paramIResultToken.mGroupName = paramObject2.groupName;
  1277. }
  1278. }
  1279. i += 1;
  1280. }
  1281. paramIResultToken = (List)this.mapMessage.get(paramObject1);
  1282. if ((paramIResultToken == null) || (paramIResultToken.size() == 0))
  1283. {
  1284. this.mapMessage.put(paramObject1, paramResult);
  1285. dispatchIMEvent("RECV_LIST_MSG", paramResult);
  1286. }
  1287. while (true)
  1288. {
  1289. IMDatabaseDS.getInstance().appendListGroupMessage(paramResult, false);
  1290. return;
  1291. paramIResultToken.addAll(paramResult);
  1292. dispatchIMEvent("RECV_LIST_MSG", paramResult);
  1293. }
  1294. if (paramObject1.equalsIgnoreCase("get_im_base_user_info"))
  1295. {
  1296. paramObject1 = (String)((HashMap)paramObject2).get("user");
  1297. paramResult = (UserInfo)paramResult.getData();
  1298. if ((paramResult == null) || (paramObject1 == null))
  1299. break;
  1300. BaseUserInfoPool.putBaseInfo(paramObject1, paramResult.snsInfo.sns_avatar, paramResult.snsInfo.sns_gender);
  1301. return;
  1302. }
  1303. int j;
  1304. if (paramObject1.equalsIgnoreCase("get_im_peer_latest_msg"))
  1305. {
  1306. paramObject1 = (String)((HashMap)paramObject2).get("userid");
  1307. paramResult = (List)paramResult.getData();
  1308. if ((paramResult == null) || (paramResult.size() <= 0))
  1309. break;
  1310. i = 0;
  1311. while (i < paramResult.size())
  1312. {
  1313. paramIResultToken = (UnreadMessagesFromNet)paramResult.get(i);
  1314. j = paramIResultToken.getCount();
  1315. paramIResultToken = paramIResultToken.getMessage();
  1316. if ((j > 0) && (paramIResultToken != null))
  1317. {
  1318. paramObject2 = getLatestUserMessage(paramObject1);
  1319. if ((paramObject2 == null) || (paramObject2.publish < paramIResultToken.publish))
  1320. {
  1321. if ((paramIResultToken.mFromAvatar == null) || (paramIResultToken.mFromAvatar.equalsIgnoreCase("")))
  1322. paramIResultToken.mFromAvatar = getUserAvatar(paramIResultToken.mFromID);
  1323. paramIResultToken.mToUserId = paramObject1;
  1324. LatestMessages.putMessage(paramIResultToken.mFromID, paramIResultToken);
  1325. saveUnReadMsg(paramIResultToken.mFromID, j);
  1326. IMContacts.getInstance().addRecentUserContacts(paramIResultToken.mFromID, paramIResultToken.mFromName, paramIResultToken.mFromAvatar);
  1327. loadMoreUserMsgFromNet(paramIResultToken.mFromID);
  1328. }
  1329. }
  1330. i += 1;
  1331. }
  1332. storeUnReadMsgCnt();
  1333. return;
  1334. }
  1335. if (paramObject1.equalsIgnoreCase("get_im_group_latest_msg"))
  1336. {
  1337. paramObject1 = (String)((HashMap)paramObject2).get("groupId");
  1338. paramIResultToken = (UnreadMessagesFromNet)paramResult.getData();
  1339. if (paramIResultToken == null)
  1340. break;
  1341. paramResult = paramIResultToken.getMessage();
  1342. j = paramIResultToken.getCount();
  1343. if ((paramObject1 == null) || (paramResult == null) || (j <= 0))
  1344. break;
  1345. if (paramResult.mGroupName == null)
  1346. {
  1347. paramIResultToken = (GroupInfo)this.mapGroupInfo.get(paramResult.mFromGroupId);
  1348. if (paramIResultToken != null)
  1349. paramResult.mGroupName = paramIResultToken.groupName;
  1350. }
  1351. if ((paramResult.mMessage != null) && (!paramResult.mMessage.equalsIgnoreCase("")));
  1352. for (i = 1; ; i = 0)
  1353. {
  1354. l1 = 0L;
  1355. paramIResultToken = getLatestGroupMessage(paramObject1);
  1356. if (paramIResultToken != null)
  1357. l1 = paramIResultToken.publish;
  1358. if (i != 0)
  1359. LatestMessages.putMessage(paramObject1, paramResult);
  1360. IMContacts.getInstance().addRecentContacts(paramObject1);
  1361. if (l1 >= paramResult.publish)
  1362. break;
  1363. saveUnReadMsg(paramObject1, j);
  1364. storeUnReadMsgCnt();
  1365. loadMoreGroupMsgFromNet(paramObject1, j);
  1366. return;
  1367. }
  1368. }
  1369. if (!paramObject1.equalsIgnoreCase("get_im_peer_history_from_server"))
  1370. break;
  1371. paramObject1 = (String)((HashMap)paramObject2).get("sender");
  1372. paramResult = (List)paramResult.getData();
  1373. if ((paramObject1 == null) || (paramResult == null) || (paramResult.size() <= 0))
  1374. break;
  1375. paramIResultToken = getLatestUserMessage(paramObject1);
  1376. if (paramIResultToken != null);
  1377. for (l1 = paramIResultToken.publish; ; l1 = 0L)
  1378. {
  1379. i = 0;
  1380. while (i < paramResult.size())
  1381. {
  1382. paramIResultToken = (IMMessage)paramResult.get(i);
  1383. if (l1 < paramIResultToken.publish)
  1384. {
  1385. LatestMessages.putMessage(paramIResultToken.mFromID, paramIResultToken);
  1386. if ((paramIResultToken.mFromAvatar == null) || (paramIResultToken.mFromAvatar.equalsIgnoreCase("")))
  1387. paramIResultToken.mFromAvatar = getUserAvatar(paramIResultToken.mFromID);
  1388. l2 = InfoManager.getInstance().getMsgSeq() + 1L;
  1389. paramIResultToken.msgSeq = l2;
  1390. InfoManager.getInstance().setMsgSeq(l2);
  1391. }
  1392. i += 1;
  1393. }
  1394. paramIResultToken = (List)this.mapMessage.get(paramObject1);
  1395. if ((paramIResultToken == null) || (paramIResultToken.size() == 0))
  1396. this.mapMessage.put(paramObject1, paramResult);
  1397. while (true)
  1398. {
  1399. IMDatabaseDS.getInstance().appendListPrivateMessage(paramResult, false);
  1400. return;
  1401. paramIResultToken.addAll(paramResult);
  1402. }
  1403. if (!paramObject1.equalsIgnoreCase("POST_PROGRAM_BARRAGE"))
  1404. break;
  1405. Toast.makeText(this.mContext, "发送弹幕失败", 1).show();
  1406. return;
  1407. }
  1408. }
  1409. }
  1410. public void ping()
  1411. {
  1412. if ((this.mWebSocket != null) && (this.loginSuccess))
  1413. try
  1414. {
  1415. long l = System.currentTimeMillis() / 1000L;
  1416. if (l - this.lastPingTime < this.PING_INTERVAL)
  1417. return;
  1418. this.lastPingTime = l;
  1419. if (this.mPingMsg == null)
  1420. {
  1421. JSONObject localJSONObject = new JSONObject();
  1422. localJSONObject.put("event", "ping");
  1423. localJSONObject.put("from", InfoManager.getInstance().getUserProfile().getUserInfo().userKey);
  1424. this.mPingMsg = localJSONObject.toJSONString();
  1425. }
  1426. if (this.mPingMsg != null)
  1427. {
  1428. this.mWebSocket.send(this.mPingMsg);
  1429. return;
  1430. }
  1431. }
  1432. catch (Exception localException)
  1433. {
  1434. }
  1435. }
  1436. public void registerIMEventListener(IMEventListener paramIMEventListener, String paramString)
  1437. {
  1438. int i;
  1439. if ((paramIMEventListener != null) && (paramString != null))
  1440. {
  1441. if (this.mapIMEventListeners.containsKey(paramString))
  1442. {
  1443. localObject = (List)this.mapIMEventListeners.get(paramString);
  1444. i = 0;
  1445. }
  1446. }
  1447. else
  1448. {
  1449. while (i < ((List)localObject).size())
  1450. {
  1451. if (((List)localObject).get(i) == paramIMEventListener)
  1452. return;
  1453. i += 1;
  1454. }
  1455. ((List)this.mapIMEventListeners.get(paramString)).add(paramIMEventListener);
  1456. return;
  1457. }
  1458. Object localObject = new ArrayList();
  1459. ((List)localObject).add(paramIMEventListener);
  1460. this.mapIMEventListeners.put(paramString, localObject);
  1461. }
  1462. public void saveUnReadMsg(String paramString, int paramInt)
  1463. {
  1464. if (paramString == null)
  1465. return;
  1466. Integer localInteger = (Integer)this.mapUnReadMsgCnt.get(paramString);
  1467. if (localInteger != null);
  1468. for (localInteger = Integer.valueOf(localInteger.intValue() + paramInt); ; localInteger = Integer.valueOf(1))
  1469. {
  1470. this.mTotalUnReadMsgCnt += paramInt;
  1471. this.mapUnReadMsgCnt.put(paramString, localInteger);
  1472. return;
  1473. }
  1474. }
  1475. public boolean sendBarrage(int paramInt1, String paramString1, String paramString2, int paramInt2)
  1476. {
  1477. if ((paramString1 == null) && (paramString2 == null))
  1478. return false;
  1479. if (paramString1 != null);
  1480. try
  1481. {
  1482. if (InfoManager.getInstance().getMaxWordsInLiveRoom() < paramString1.length())
  1483. {
  1484. Toast.makeText(this.mContext, "超出字数范围,字数最长为" + InfoManager.getInstance().getMaxWordsInLiveRoom() + "个", 1).show();
  1485. return false;
  1486. }
  1487. if (SharedCfg.getInstance().hitFilter(paramString1))
  1488. {
  1489. Toast.makeText(this.mContext, "消息中包含敏感词,敬请三思", 1).show();
  1490. return false;
  1491. }
  1492. HashMap localHashMap = new HashMap();
  1493. localHashMap.put("content", paramString1);
  1494. localHashMap.put("timePoint", String.valueOf

Large files files are truncated, but you can click here to view the full file