private void update(TL.Object someUser) { if (someUser.id == 0x771095da) { // userFull object = someUser; blocked = object.getBool("blocked"); } else object.set("user", someUser); TL.Object user = object.getObject("user"); id = user.getInt("id"); if (!user.name.equals("userEmpty")) { first_name = user.getString("first_name"); last_name = user.getString("last_name"); if (!user.name.equals("userDeleted")) { setPhoto(user.getObject("photo")); setStatus(user.getObject("status")); if (user.name.equals("userSelf")) User.self = this; else access_hash = user.getLong("access_hash"); if (!user.name.equals("userForeign")) { if (user.name.equals("userContact")) contact = true; phone = user.getString("phone"); } } } }
private void TL_messages_StatedMessage(TL.Object obj) { setUpdate(-1, obj.getInt("pts"), obj.getInt("seq")); User.addUsers(obj.getVector("users")); TL.Object message = obj.getObject("message"); Dialog d = Dialog.getDialog(message.getInt("from_id"), message.getObject("to_id"), true); Dialog.newMessage(message, Dialog.MSG_INCOMING); }
private void TL_auth_Authorization(TL.Object obj) { // int expires = obj.getInt("expires"); bind = true; dcState.set("bind", bind); cb.onAuth(obj.getObject("user")); cb.onBind(); }
private void TL_Updates(TL.Object obj) { if (obj.name.equals("updatesTooLong")) api_updates_getDifference(); boolean chat = obj.name.equals("updateShortChatMessage"); if (obj.name.equals("updateShortMessage") || chat) { cb.onMessage( Dialog.Message.newObject( obj.getInt("id"), obj.getInt("from_id"), chat ? obj.getInt("chat_id") : -1, obj.getInt("from_id"), obj.getInt("date"), obj.getString("message"), null), Dialog.MSG_INCOMING | Dialog.MSG_HISTORY); setUpdate(obj.getInt("date"), obj.getInt("pts"), obj.getInt("seq")); } if (obj.name.equals("updateShort")) { onUpdate(obj.getObject("update"), null, null); setUpdate(obj.getInt("date"), -1, -1); } if (obj.name.equals("updatesCombined") || obj.name.equals("updates")) { TL.Vector updates = obj.getVector("updates"); for (int i = 0; i < updates.count; i++) onUpdate(updates.getObject(i), obj.getVector("users"), obj.getVector("chats")); setUpdate(obj.getInt("date"), -1, obj.getInt("seq")); } }
public TL.Object getPhotoLocation() { if (photo == null || photo.name.equals("userProfilePhotoEmpty")) return null; try { return photo.getObject("photo_small"); } catch (Exception e) { return null; } }
private void TL_RpcResult(TL.Object obj) { req_msg_id = obj.getLong("req_msg_id"); TL.Object result = obj.getObject("result"); Message msg = TLMessage.get(req_msg_id); if (msg != null && msg.result != null) msg.result.onResultRPC( result, msg.param, result.name != null && result.name.equals("rpc_error")); process(result); TLMessage.delete(req_msg_id); }
private void TL_messages_StatedMessages(TL.Object obj) { setUpdate(-1, obj.getInt("pts"), obj.getInt("seq")); User.addUsers(obj.getVector("users")); TL.Vector messages = obj.getVector("messages"); for (int i = 0; i < messages.count; i++) { TL.Object message = messages.getObject(i); Dialog d = Dialog.getDialog(message.getInt("from_id"), message.getObject("to_id"), true); Dialog.newMessage(message, Dialog.MSG_INCOMING); } }
private void TL_MessageContainer(TL.Object obj) { TL.Vector v = (TL.Vector) obj; int count = v.count; Common.logDebug("msg_count: " + count); for (int i = 0; i < v.count; i++) { TL.Object message = v.getObject(i); ack_message(message.getInt("seqno"), message.getLong("msg_id")); process(message.getObject("body")); } }
public void setPhoto(TL.Object userPhoto) { boolean update = photo == null || !Arrays.equals(photo.serialize(), userPhoto.serialize()); if (update) try { photo = userPhoto; object.getObject("user").set("photo", photo); Main.main.updateUser(this); } catch (Exception e) { e.printStackTrace(); } }
public void setStatus(TL.Object userStatus) { boolean update = this.status == null || !Arrays.equals(status.serialize(), userStatus.serialize()); if (update) try { status = userStatus; online = status.id == 0xedb93949; object.getObject("user").set("status", status); Main.main.updateUser(this); } catch (Exception e) { e.printStackTrace(); } }
private void TL_updates_Difference(TL.Object obj) { if (obj.name.equals("updates.differenceEmpty")) setUpdate(obj.getInt("date"), -1, obj.getInt("seq")); if (obj.name.equals("updates.difference") || obj.name.equals("updates.differenceSlice")) { TL.Vector other_updates = obj.getVector("other_updates"); for (int i = 0; i < other_updates.count; i++) onUpdate(other_updates.getObject(i), obj.getVector("users"), obj.getVector("chats")); TL.Vector new_messages = obj.getVector("new_messages"); for (int i = 0; i < new_messages.count; i++) Dialog.newMessage(new_messages.getObject(i), Dialog.MSG_HISTORY); // if (new_messages.count > 0) // Dialog.vibrate(); if (obj.name.equals("updates.differenceSlice")) { TL_updates_State(obj.getObject("intermediate_state")); this.api_updates_getDifference(); } else TL_updates_State(obj.getObject("state")); } }
public void TL_messages_Dialogs(TL.Object obj) { User.addUsers(obj.getVector("users")); Chat.addChats(obj.getVector("chats")); // dialogs TL.Vector dialogs = obj.getVector("dialogs"); for (int i = 0; i < dialogs.count; i++) { TL.Object dobj = dialogs.getObject(i); Dialog d = Dialog.getDialog(-1, dobj.getObject("peer"), true); d.updating = true; } // messages TL.Vector messages = obj.getVector("messages"); for (int i = 0; i < messages.count; i++) cb.onMessage(messages.getObject(i), Dialog.MSG_HISTORY); for (int i = 0; i < dialogs.count; i++) { TL.Object dobj = dialogs.getObject(i); Dialog d = Dialog.getDialog(-1, dobj.getObject("peer"), true); if (dobj.getInt("top_message") == -7) // config_dialogs magic d.noHistory = true; d.unread_count = dobj.getInt("unread_count"); d.updating = false; Main.main.updateDialog(d); } Common.logError("dialogs: " + Dialog.dialogs.size()); // slice if (obj.name.equals("messages.dialogsSlice") && dialogs.count > 0) { int limit = obj.getInt("count") - Dialog.dialogs.size(); if (limit > 0) api_messages_getDialogs(Dialog.dialogs.size(), 0, limit); } if (Main.main != null) Main.main.resetDialogs(); }
public static User addUser(TL.Object user) { if (user == null) return null; int id = user.name.equals("userFull") ? user.getObject("user").getInt("id") : user.getInt("id"); User old = users.get(id); if (old != null) { old.update(user); getFullInfo(); return old; } else { User u = new User(user); users.put(id, u); getFullInfo(); return u; } }
public CharSequence getTitleColored() { String title = getTitle(); if (object != null) { TL.Object u = object.getObject("user"); if (u != null) { String color = "010101"; // userContact switch (u.id) { case 0x22e8ceb0: // userRequest case 0x5214c89d: // userForeign color = "006fc8"; break; case 0xb29ad7cc: // userDeleted color = "666666"; break; } return Html.fromHtml("<font color=\"#" + color + "\">" + title + "</font>"); } } return title; }
private void TL_updateUserPhoto(TL.Object update) { User user = User.getUser(update.getInt("user_id")); if (user != null) user.setPhoto(update.getObject("photo")); }
private void TL_updateUserStatus(TL.Object update) { User user = User.getUser(update.getInt("user_id")); if (user != null) user.setStatus(update.getObject("status")); }
private void TL_updateChatParticipants(TL.Object update) { TL.Object p = update.getObject("participants"); Chat chat = Chat.getChat(p.getInt("chat_id")); if (chat != null) chat.setParticipants(p); }
private void TL_updateNewMessage(TL.Object update) { cb.onMessage(update.getObject("message"), Dialog.MSG_INCOMING | Dialog.MSG_HISTORY); setUpdate(-1, update.getInt("pts"), -1); }
private void TL_messages_ChatFull(TL.Object obj) { User.addUsers(obj.getVector("users")); TL.Object full_chat = obj.getObject("full_chat"); Chat chat = Chat.getChat(full_chat.getInt("id")); if (chat != null) chat.update(full_chat); }