Beispiel #1
0
 private void TL_contacts_ImportedContacts(TL.Object obj) {
   User.addUsers(obj.getVector("users"));
   TL.Vector imported = obj.getVector("imported");
   for (int i = 0; i < imported.count; i++) {
     TL.Object c = imported.getObject(i);
     User.getUser(c.getInt("user_id")).client_id = c.getLong("client_id");
   }
   SyncUtils.updateContacts(Main.main);
 }
Beispiel #2
0
 public static void getFullInfo() {
   synchronized (fullInfoQuery) {
     if (fullInfoQuery.size() == 0) return;
     for (int i = 0; i < fullInfoQuery.size(); i++) {
       User user = fullInfoQuery.get(i);
       if (user.id == 0) continue; // inputUserEmpty
       TL.Object inputUser = user.getInputUser();
       Main.mtp.api(null, null, "users.getFullUser", inputUser);
     }
     fullInfoQuery.clear();
   }
 }
Beispiel #3
0
  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);
  }
Beispiel #4
0
  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;
    }
  }
Beispiel #5
0
  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);
    }
  }
Beispiel #6
0
  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();
  }
Beispiel #7
0
 private void TL_User(TL.Object user) {
   User.addUser(user);
 }
Beispiel #8
0
 private void TL_updateUserPhoto(TL.Object update) {
   User user = User.getUser(update.getInt("user_id"));
   if (user != null) user.setPhoto(update.getObject("photo"));
 }
Beispiel #9
0
 private void TL_updateUserStatus(TL.Object update) {
   User user = User.getUser(update.getInt("user_id"));
   if (user != null) user.setStatus(update.getObject("status"));
 }
Beispiel #10
0
 private void userTyping(int chat_id, int user_id) {
   User user = User.getUser(user_id);
   if (user != null) user.setTyping(chat_id, true);
 }
Beispiel #11
0
 public void onUpdate(TL.Object update, TL.Vector users, TL.Vector chats) {
   User.addUsers(users);
   Chat.addChats(chats);
   invoke(update.name, update);
 }
Beispiel #12
0
 private void TL_contacts_Contacts(TL.Object obj) {
   if (obj.name.equals("contacts.contacts")) User.addUsers(obj.getVector("users"));
 }
Beispiel #13
0
 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);
 }
Beispiel #14
0
 private void TL_UserFull(TL.Object userFull) {
   User.addUser(userFull);
 }
Beispiel #15
0
 private void TL_photos_Photo(TL.Object obj) {
   User.addUsers(obj.getVector("users"));
 }
Beispiel #16
0
 public static void addUsers(TL.Vector users) {
   if (users == null) return;
   for (int i = 0; i < users.count; i++) User.addUser(users.getObject(i));
 }