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 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(); }
private void TL_updateNewMessage(TL.Object update) { cb.onMessage(update.getObject("message"), Dialog.MSG_INCOMING | Dialog.MSG_HISTORY); setUpdate(-1, update.getInt("pts"), -1); }