PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/QingTingFanBianYi/src/fm/qingting/qtradio/im/message/IMMessage.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 275 lines | 252 code | 19 blank | 4 comment | 66 complexity | 43dcd22e7209760d69e70e89942171a8 MD5 | raw file
  1. package fm.qingting.qtradio.im.message;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import fm.qingting.qtradio.im.info.GroupInfo;
  6. import fm.qingting.qtradio.room.UserInfo;
  7. import java.util.ArrayList;
  8. import java.util.List;
  9. public class IMMessage
  10. {
  11. public int chatType;
  12. public String mFromAvatar = "";
  13. public String mFromGroupId = "";
  14. public String mFromID = "";
  15. public String mFromName = "";
  16. public String mGender = "n";
  17. public String mGroupName = "";
  18. public String mImage;
  19. public int mLike;
  20. public String mMessage = "";
  21. public String mMsgId = "";
  22. public String mToUserId = "";
  23. public long msgSeq = -1L;
  24. public long publish;
  25. public static JSONObject buildBarrage(String paramString1, String paramString2, UserInfo paramUserInfo)
  26. {
  27. if (paramUserInfo == null);
  28. while ((paramString1 == null) && (paramString2 == null))
  29. return null;
  30. paramString2 = new JSONObject();
  31. try
  32. {
  33. paramString2.put("msg", paramString1);
  34. paramString2.put("sendTime", Long.valueOf(System.currentTimeMillis() / 1000L));
  35. return paramString2;
  36. }
  37. catch (Exception paramString1)
  38. {
  39. paramString1.printStackTrace();
  40. }
  41. return null;
  42. }
  43. public static String buildGroupInfo(String paramString1, String paramString2, int paramInt)
  44. {
  45. JSONObject localJSONObject = new JSONObject();
  46. try
  47. {
  48. localJSONObject.put("groupDesc", paramString1);
  49. localJSONObject.put("ownerId", paramString2);
  50. localJSONObject.put("approve", Integer.valueOf(paramInt));
  51. label35: return localJSONObject.toString();
  52. }
  53. catch (Exception paramString1)
  54. {
  55. break label35;
  56. }
  57. }
  58. public static JSONObject buildIMMessage(String paramString, UserInfo paramUserInfo, GroupInfo paramGroupInfo)
  59. {
  60. if ((paramString == null) || (paramUserInfo == null) || (paramString.equalsIgnoreCase("")) || (paramGroupInfo == null))
  61. return null;
  62. paramUserInfo = new JSONObject();
  63. try
  64. {
  65. paramUserInfo.put("msg", paramString);
  66. paramUserInfo.put("sendTime", Long.valueOf(System.currentTimeMillis() / 1000L));
  67. paramUserInfo.put("groupName", paramGroupInfo.groupName);
  68. return paramUserInfo;
  69. }
  70. catch (Exception paramString)
  71. {
  72. paramString.printStackTrace();
  73. }
  74. return null;
  75. }
  76. public static JSONObject buildIMMessage(String paramString, UserInfo paramUserInfo1, UserInfo paramUserInfo2)
  77. {
  78. if ((paramString == null) || (paramUserInfo1 == null) || (paramString.equalsIgnoreCase("")) || (paramUserInfo2 == null))
  79. return null;
  80. paramUserInfo1 = new JSONObject();
  81. try
  82. {
  83. paramUserInfo1.put("msg", paramString);
  84. paramUserInfo1.put("sendTime", Long.valueOf(System.currentTimeMillis() / 1000L));
  85. return paramUserInfo1;
  86. }
  87. catch (Exception paramString)
  88. {
  89. paramString.printStackTrace();
  90. }
  91. return null;
  92. }
  93. public static List<IMMessage> parseData(List<String> paramList)
  94. {
  95. if ((paramList == null) || (paramList.size() == 0))
  96. return null;
  97. ArrayList localArrayList = new ArrayList();
  98. int i = 0;
  99. while (i < paramList.size())
  100. {
  101. IMMessage localIMMessage = new IMMessage();
  102. if (parseData((String)paramList.get(i), localIMMessage))
  103. localArrayList.add(localIMMessage);
  104. i += 1;
  105. }
  106. return localArrayList;
  107. }
  108. public static boolean parseData(JSONObject paramJSONObject, IMMessage paramIMMessage)
  109. {
  110. if ((paramJSONObject == null) || (paramIMMessage == null))
  111. return false;
  112. try
  113. {
  114. String str = paramJSONObject.getString("msg");
  115. long l2 = paramJSONObject.getLongValue("sendTime");
  116. long l1 = l2;
  117. if (l2 == 0L)
  118. l1 = paramJSONObject.getLongValue("publish");
  119. paramIMMessage.mToUserId = paramJSONObject.getString("toUserId");
  120. paramIMMessage.mMessage = str;
  121. paramIMMessage.publish = l1;
  122. return true;
  123. }
  124. catch (Exception paramJSONObject)
  125. {
  126. }
  127. return false;
  128. }
  129. public static boolean parseData(IMMessage paramIMMessage1, IMMessage paramIMMessage2)
  130. {
  131. if ((paramIMMessage1 == null) || (paramIMMessage2 == null))
  132. return false;
  133. return parseData(paramIMMessage1.mMessage, paramIMMessage2);
  134. }
  135. public static boolean parseData(String paramString, IMMessage paramIMMessage)
  136. {
  137. if ((paramString == null) || (paramIMMessage == null))
  138. return false;
  139. while (true)
  140. try
  141. {
  142. JSONObject localJSONObject = (JSONObject)JSON.parse(paramString);
  143. String str1 = localJSONObject.getString("msg");
  144. paramString = localJSONObject.getString("fromUserId");
  145. if (paramString == null)
  146. {
  147. paramString = localJSONObject.getString("userId");
  148. int i = localJSONObject.getIntValue("chatType");
  149. String str2 = localJSONObject.getString("groupId");
  150. long l2 = localJSONObject.getLongValue("sendTime");
  151. long l1 = l2;
  152. if (l2 == 0L)
  153. l1 = localJSONObject.getLongValue("publish");
  154. String str3 = localJSONObject.getString("groupName");
  155. paramIMMessage.mToUserId = localJSONObject.getString("toUserId");
  156. paramIMMessage.mFromAvatar = localJSONObject.getString("fromAvatar");
  157. if (paramIMMessage.mFromAvatar == null)
  158. paramIMMessage.mFromAvatar = localJSONObject.getString("userAvatar");
  159. paramIMMessage.mMessage = str1;
  160. paramIMMessage.mFromID = paramString;
  161. paramIMMessage.chatType = i;
  162. paramIMMessage.mFromGroupId = str2;
  163. paramIMMessage.publish = l1;
  164. paramIMMessage.mGroupName = str3;
  165. return true;
  166. }
  167. }
  168. catch (Exception paramString)
  169. {
  170. return false;
  171. }
  172. }
  173. public static boolean parseEvent(String paramString, IMMessage paramIMMessage)
  174. {
  175. if ((paramString == null) || (paramIMMessage == null))
  176. return false;
  177. try
  178. {
  179. Object localObject = (JSONObject)JSON.parse(paramString);
  180. if (localObject != null)
  181. {
  182. paramString = ((JSONObject)localObject).getString("from");
  183. String str1 = ((JSONObject)localObject).getString("to");
  184. String str2 = ((JSONObject)localObject).getString("event");
  185. paramIMMessage.mFromID = paramString;
  186. paramIMMessage.mFromGroupId = str1;
  187. paramIMMessage.mFromName = ((JSONObject)localObject).getString("fromName");
  188. paramIMMessage.mGender = ((JSONObject)localObject).getString("fromGender");
  189. paramIMMessage.mMsgId = ((JSONObject)localObject).getString("id");
  190. localObject = ((JSONObject)localObject).getJSONArray("body");
  191. if (localObject != null)
  192. {
  193. parseData(((JSONArray)localObject).getJSONObject(0), paramIMMessage);
  194. if (paramIMMessage != null)
  195. if (str2.equalsIgnoreCase("peer"))
  196. {
  197. paramIMMessage.chatType = 0;
  198. paramIMMessage.mFromID = paramString;
  199. paramIMMessage.mToUserId = str1;
  200. }
  201. else if (str2.equalsIgnoreCase("group"))
  202. {
  203. paramIMMessage.chatType = 1;
  204. paramIMMessage.mFromGroupId = str1;
  205. paramIMMessage.mFromID = paramString;
  206. }
  207. }
  208. }
  209. }
  210. catch (Exception paramString)
  211. {
  212. }
  213. return false;
  214. return true;
  215. }
  216. public GroupInfo buildGroupInfo()
  217. {
  218. GroupInfo localGroupInfo = new GroupInfo();
  219. localGroupInfo.groupId = this.mFromGroupId;
  220. localGroupInfo.groupName = this.mGroupName;
  221. return localGroupInfo;
  222. }
  223. public UserInfo buildUserInfo()
  224. {
  225. UserInfo localUserInfo = new UserInfo();
  226. localUserInfo.userKey = this.mFromID;
  227. localUserInfo.snsInfo.sns_name = this.mFromName;
  228. localUserInfo.snsInfo.sns_avatar = this.mFromAvatar;
  229. localUserInfo.snsInfo.sns_gender = this.mGender;
  230. return localUserInfo;
  231. }
  232. public boolean isBarrage()
  233. {
  234. return (this.chatType == 2) || (this.chatType == 3);
  235. }
  236. public boolean isGroupMsg()
  237. {
  238. return this.chatType == 1;
  239. }
  240. public boolean isPGCBarrage()
  241. {
  242. return this.chatType == 3;
  243. }
  244. public boolean isUGCBarrage()
  245. {
  246. return this.chatType == 2;
  247. }
  248. public String toString()
  249. {
  250. return JSON.toJSONString(this);
  251. }
  252. }
  253. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  254. * Qualified Name: fm.qingting.qtradio.im.message.IMMessage
  255. * JD-Core Version: 0.6.2
  256. */