Commit 9959c058 authored by Vysheng's avatar Vysheng

renamed user_chat_get to peer_get

parent d3780ebe
...@@ -180,7 +180,7 @@ int fetch_comb_binlog_set_seq (void *extra) { ...@@ -180,7 +180,7 @@ int fetch_comb_binlog_set_seq (void *extra) {
int fetch_comb_binlog_user_add (void *extra) { int fetch_comb_binlog_user_add (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *_U = user_chat_get (id); peer_t *_U = peer_get (id);
if (!_U) { if (!_U) {
_U = talloc0 (sizeof (*_U)); _U = talloc0 (sizeof (*_U));
_U->id = id; _U->id = id;
...@@ -213,7 +213,7 @@ int fetch_comb_binlog_user_add (void *extra) { ...@@ -213,7 +213,7 @@ int fetch_comb_binlog_user_add (void *extra) {
int fetch_comb_binlog_user_delete (void *extra) { int fetch_comb_binlog_user_delete (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
U->flags |= FLAG_DELETED; U->flags |= FLAG_DELETED;
...@@ -225,7 +225,7 @@ int fetch_comb_binlog_user_delete (void *extra) { ...@@ -225,7 +225,7 @@ int fetch_comb_binlog_user_delete (void *extra) {
int fetch_comb_binlog_user_set_access_hash (void *extra) { int fetch_comb_binlog_user_set_access_hash (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
U->user.access_hash = fetch_long (); U->user.access_hash = fetch_long ();
...@@ -237,7 +237,7 @@ int fetch_comb_binlog_user_set_access_hash (void *extra) { ...@@ -237,7 +237,7 @@ int fetch_comb_binlog_user_set_access_hash (void *extra) {
int fetch_comb_binlog_user_set_phone (void *extra) { int fetch_comb_binlog_user_set_phone (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
if (U->user.phone) { if (U->user.phone) {
tfree_str (U->user.phone); tfree_str (U->user.phone);
...@@ -252,7 +252,7 @@ int fetch_comb_binlog_user_set_phone (void *extra) { ...@@ -252,7 +252,7 @@ int fetch_comb_binlog_user_set_phone (void *extra) {
int fetch_comb_binlog_user_set_friend (void *extra) { int fetch_comb_binlog_user_set_friend (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
if (U->user.phone) { if (U->user.phone) {
tfree_str (U->user.phone); tfree_str (U->user.phone);
...@@ -269,7 +269,7 @@ int fetch_comb_binlog_user_set_friend (void *extra) { ...@@ -269,7 +269,7 @@ int fetch_comb_binlog_user_set_friend (void *extra) {
int fetch_comb_binlog_user_set_full_photo (void *extra) { int fetch_comb_binlog_user_set_full_photo (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
if (U->flags & FLAG_HAS_PHOTO) { if (U->flags & FLAG_HAS_PHOTO) {
free_photo (&U->user.photo); free_photo (&U->user.photo);
...@@ -284,7 +284,7 @@ int fetch_comb_binlog_user_set_full_photo (void *extra) { ...@@ -284,7 +284,7 @@ int fetch_comb_binlog_user_set_full_photo (void *extra) {
int fetch_comb_binlog_user_set_blocked (void *extra) { int fetch_comb_binlog_user_set_blocked (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
U->user.blocked = fetch_int (); U->user.blocked = fetch_int ();
...@@ -297,7 +297,7 @@ int fetch_comb_binlog_user_set_blocked (void *extra) { ...@@ -297,7 +297,7 @@ int fetch_comb_binlog_user_set_blocked (void *extra) {
int fetch_comb_binlog_user_set_real_name (void *extra) { int fetch_comb_binlog_user_set_real_name (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
if (U->user.real_first_name) { tfree_str (U->user.real_first_name); } if (U->user.real_first_name) { tfree_str (U->user.real_first_name); }
...@@ -313,7 +313,7 @@ int fetch_comb_binlog_user_set_real_name (void *extra) { ...@@ -313,7 +313,7 @@ int fetch_comb_binlog_user_set_real_name (void *extra) {
int fetch_comb_binlog_user_set_name (void *extra) { int fetch_comb_binlog_user_set_name (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
if (U->user.first_name) { tfree_str (U->user.first_name); } if (U->user.first_name) { tfree_str (U->user.first_name); }
...@@ -335,7 +335,7 @@ int fetch_comb_binlog_user_set_name (void *extra) { ...@@ -335,7 +335,7 @@ int fetch_comb_binlog_user_set_name (void *extra) {
int fetch_comb_binlog_user_set_photo (void *extra) { int fetch_comb_binlog_user_set_photo (void *extra) {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
...@@ -359,7 +359,7 @@ int fetch_comb_binlog_user_set_photo (void *extra) { ...@@ -359,7 +359,7 @@ int fetch_comb_binlog_user_set_photo (void *extra) {
int fetch_comb_binlog_encr_chat_delete (void *extra) { int fetch_comb_binlog_encr_chat_delete (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *_U = user_chat_get (id); peer_t *_U = peer_get (id);
assert (_U); assert (_U);
struct secret_chat *U = &_U->encr_chat; struct secret_chat *U = &_U->encr_chat;
memset (U->key, 0, sizeof (U->key)); memset (U->key, 0, sizeof (U->key));
...@@ -382,7 +382,7 @@ int fetch_comb_binlog_encr_chat_delete (void *extra) { ...@@ -382,7 +382,7 @@ int fetch_comb_binlog_encr_chat_delete (void *extra) {
int fetch_comb_binlog_encr_chat_requested (void *extra) { int fetch_comb_binlog_encr_chat_requested (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *_U = user_chat_get (id); peer_t *_U = peer_get (id);
if (!_U) { if (!_U) {
_U = talloc0 (sizeof (*_U)); _U = talloc0 (sizeof (*_U));
_U->id = id; _U->id = id;
...@@ -396,7 +396,7 @@ int fetch_comb_binlog_encr_chat_requested (void *extra) { ...@@ -396,7 +396,7 @@ int fetch_comb_binlog_encr_chat_requested (void *extra) {
U->admin_id = fetch_int (); U->admin_id = fetch_int ();
U->user_id = fetch_int (); U->user_id = fetch_int ();
peer_t *Us = user_chat_get (MK_USER (U->user_id)); peer_t *Us = peer_get (MK_USER (U->user_id));
assert (!U->print_name); assert (!U->print_name);
if (Us) { if (Us) {
U->print_name = create_print_name (id, "!", Us->user.first_name, Us->user.last_name, 0); U->print_name = create_print_name (id, "!", Us->user.first_name, Us->user.last_name, 0);
...@@ -422,7 +422,7 @@ int fetch_comb_binlog_encr_chat_requested (void *extra) { ...@@ -422,7 +422,7 @@ int fetch_comb_binlog_encr_chat_requested (void *extra) {
int fetch_comb_binlog_encr_chat_set_access_hash (void *extra) { int fetch_comb_binlog_encr_chat_set_access_hash (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
U->encr_chat.access_hash = fetch_long (); U->encr_chat.access_hash = fetch_long ();
...@@ -434,7 +434,7 @@ int fetch_comb_binlog_encr_chat_set_access_hash (void *extra) { ...@@ -434,7 +434,7 @@ int fetch_comb_binlog_encr_chat_set_access_hash (void *extra) {
int fetch_comb_binlog_encr_chat_set_date (void *extra) { int fetch_comb_binlog_encr_chat_set_date (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
U->encr_chat.date = fetch_int (); U->encr_chat.date = fetch_int ();
...@@ -446,7 +446,7 @@ int fetch_comb_binlog_encr_chat_set_date (void *extra) { ...@@ -446,7 +446,7 @@ int fetch_comb_binlog_encr_chat_set_date (void *extra) {
int fetch_comb_binlog_encr_chat_set_state (void *extra) { int fetch_comb_binlog_encr_chat_set_state (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
assert (U); assert (U);
U->encr_chat.state = fetch_int (); U->encr_chat.state = fetch_int ();
...@@ -458,7 +458,7 @@ int fetch_comb_binlog_encr_chat_set_state (void *extra) { ...@@ -458,7 +458,7 @@ int fetch_comb_binlog_encr_chat_set_state (void *extra) {
int fetch_comb_binlog_encr_chat_accepted (void *extra) { int fetch_comb_binlog_encr_chat_accepted (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *_U = user_chat_get (id); peer_t *_U = peer_get (id);
assert (_U); assert (_U);
struct secret_chat *U = &_U->encr_chat; struct secret_chat *U = &_U->encr_chat;
if (!U->g_key) { if (!U->g_key) {
...@@ -485,7 +485,7 @@ int fetch_comb_binlog_encr_chat_accepted (void *extra) { ...@@ -485,7 +485,7 @@ int fetch_comb_binlog_encr_chat_accepted (void *extra) {
int fetch_comb_binlog_encr_chat_set_key (void *extra) { int fetch_comb_binlog_encr_chat_set_key (void *extra) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *_U = user_chat_get (id); peer_t *_U = peer_get (id);
assert (_U); assert (_U);
struct secret_chat *U = &_U->encr_chat; struct secret_chat *U = &_U->encr_chat;
fetch_ints (U->key, 64); fetch_ints (U->key, 64);
...@@ -500,11 +500,11 @@ int fetch_comb_binlog_encr_chat_set_key (void *extra) { ...@@ -500,11 +500,11 @@ int fetch_comb_binlog_encr_chat_set_key (void *extra) {
int fetch_comb_binlog_encr_chat_init (void *extra) { int fetch_comb_binlog_encr_chat_init (void *extra) {
peer_t *P = talloc0 (sizeof (*P)); peer_t *P = talloc0 (sizeof (*P));
P->id = MK_ENCR_CHAT (fetch_int ()); P->id = MK_ENCR_CHAT (fetch_int ());
assert (!user_chat_get (P->id)); assert (!peer_get (P->id));
P->encr_chat.user_id = fetch_int (); P->encr_chat.user_id = fetch_int ();
P->encr_chat.admin_id = our_id; P->encr_chat.admin_id = our_id;
insert_encrypted_chat (P); insert_encrypted_chat (P);
peer_t *Us = user_chat_get (MK_USER (P->encr_chat.user_id)); peer_t *Us = peer_get (MK_USER (P->encr_chat.user_id));
assert (Us); assert (Us);
P->print_name = create_print_name (P->id, "!", Us->user.first_name, Us->user.last_name, 0); P->print_name = create_print_name (P->id, "!", Us->user.first_name, Us->user.last_name, 0);
peer_insert_name (P); peer_insert_name (P);
...@@ -522,7 +522,7 @@ int fetch_comb_binlog_encr_chat_init (void *extra) { ...@@ -522,7 +522,7 @@ int fetch_comb_binlog_encr_chat_init (void *extra) {
int fetch_comb_binlog_chat_create (void *extra) { int fetch_comb_binlog_chat_create (void *extra) {
peer_id_t id = MK_CHAT (fetch_int ()); peer_id_t id = MK_CHAT (fetch_int ());
peer_t *_C = user_chat_get (id); peer_t *_C = peer_get (id);
if (!_C) { if (!_C) {
_C = talloc0 (sizeof (*_C)); _C = talloc0 (sizeof (*_C));
_C->id = id; _C->id = id;
...@@ -550,7 +550,7 @@ int fetch_comb_binlog_chat_create (void *extra) { ...@@ -550,7 +550,7 @@ int fetch_comb_binlog_chat_create (void *extra) {
} }
int fetch_comb_binlog_chat_change_flags (void *extra) { int fetch_comb_binlog_chat_change_flags (void *extra) {
peer_t *C = user_chat_get (MK_CHAT (fetch_int ())); peer_t *C = peer_get (MK_CHAT (fetch_int ()));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
C->chat.flags |= fetch_int (); C->chat.flags |= fetch_int ();
C->chat.flags &= ~fetch_int (); C->chat.flags &= ~fetch_int ();
...@@ -562,7 +562,7 @@ int fetch_comb_binlog_chat_change_flags (void *extra) { ...@@ -562,7 +562,7 @@ int fetch_comb_binlog_chat_change_flags (void *extra) {
} }
int fetch_comb_binlog_chat_set_title (void *extra) { int fetch_comb_binlog_chat_set_title (void *extra) {
peer_t *C = user_chat_get (MK_CHAT (fetch_int ())); peer_t *C = peer_get (MK_CHAT (fetch_int ()));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
if (C->chat.title) { tfree_str (C->chat.title); } if (C->chat.title) { tfree_str (C->chat.title); }
...@@ -581,7 +581,7 @@ int fetch_comb_binlog_chat_set_title (void *extra) { ...@@ -581,7 +581,7 @@ int fetch_comb_binlog_chat_set_title (void *extra) {
} }
int fetch_comb_binlog_chat_set_photo (void *extra) { int fetch_comb_binlog_chat_set_photo (void *extra) {
peer_t *C = user_chat_get (MK_CHAT (fetch_int ())); peer_t *C = peer_get (MK_CHAT (fetch_int ()));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
fetch_data (&C->photo_big, sizeof (struct file_location)); fetch_data (&C->photo_big, sizeof (struct file_location));
fetch_data (&C->photo_small, sizeof (struct file_location)); fetch_data (&C->photo_small, sizeof (struct file_location));
...@@ -593,7 +593,7 @@ int fetch_comb_binlog_chat_set_photo (void *extra) { ...@@ -593,7 +593,7 @@ int fetch_comb_binlog_chat_set_photo (void *extra) {
} }
int fetch_comb_binlog_chat_set_date (void *extra) { int fetch_comb_binlog_chat_set_date (void *extra) {
peer_t *C = user_chat_get (MK_CHAT (fetch_int ())); peer_t *C = peer_get (MK_CHAT (fetch_int ()));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
C->chat.date = fetch_int (); C->chat.date = fetch_int ();
...@@ -604,7 +604,7 @@ int fetch_comb_binlog_chat_set_date (void *extra) { ...@@ -604,7 +604,7 @@ int fetch_comb_binlog_chat_set_date (void *extra) {
} }
int fetch_comb_binlog_chat_set_version (void *extra) { int fetch_comb_binlog_chat_set_version (void *extra) {
peer_t *C = user_chat_get (MK_CHAT (fetch_int ())); peer_t *C = peer_get (MK_CHAT (fetch_int ()));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
C->chat.version = fetch_int (); C->chat.version = fetch_int ();
C->chat.users_num = fetch_int (); C->chat.users_num = fetch_int ();
...@@ -616,7 +616,7 @@ int fetch_comb_binlog_chat_set_version (void *extra) { ...@@ -616,7 +616,7 @@ int fetch_comb_binlog_chat_set_version (void *extra) {
} }
int fetch_comb_binlog_chat_set_admin (void *extra) { int fetch_comb_binlog_chat_set_admin (void *extra) {
peer_t *C = user_chat_get (MK_CHAT (fetch_int ())); peer_t *C = peer_get (MK_CHAT (fetch_int ()));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
C->chat.admin_id = fetch_int (); C->chat.admin_id = fetch_int ();
...@@ -627,7 +627,7 @@ int fetch_comb_binlog_chat_set_admin (void *extra) { ...@@ -627,7 +627,7 @@ int fetch_comb_binlog_chat_set_admin (void *extra) {
} }
int fetch_comb_binlog_chat_set_participants (void *extra) { int fetch_comb_binlog_chat_set_participants (void *extra) {
peer_t *C = user_chat_get (MK_CHAT (fetch_int ())); peer_t *C = peer_get (MK_CHAT (fetch_int ()));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
C->chat.user_list_version = fetch_int (); C->chat.user_list_version = fetch_int ();
if (C->chat.user_list) { tfree (C->chat.user_list, 12 * C->chat.user_list_size); } if (C->chat.user_list) { tfree (C->chat.user_list, 12 * C->chat.user_list_size); }
...@@ -642,7 +642,7 @@ int fetch_comb_binlog_chat_set_participants (void *extra) { ...@@ -642,7 +642,7 @@ int fetch_comb_binlog_chat_set_participants (void *extra) {
} }
int fetch_comb_binlog_chat_set_full_photo (void *extra) { int fetch_comb_binlog_chat_set_full_photo (void *extra) {
peer_t *C = user_chat_get (MK_CHAT (fetch_int ())); peer_t *C = peer_get (MK_CHAT (fetch_int ()));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
assert (C && (C->flags & FLAG_CREATED)); assert (C && (C->flags & FLAG_CREATED));
...@@ -659,7 +659,7 @@ int fetch_comb_binlog_chat_set_full_photo (void *extra) { ...@@ -659,7 +659,7 @@ int fetch_comb_binlog_chat_set_full_photo (void *extra) {
int fetch_comb_binlog_chat_add_participant (void *extra) { int fetch_comb_binlog_chat_add_participant (void *extra) {
peer_id_t id = MK_CHAT (fetch_int ()); peer_id_t id = MK_CHAT (fetch_int ());
peer_t *_C = user_chat_get (id); peer_t *_C = peer_get (id);
assert (_C && (_C->flags & FLAG_CREATED)); assert (_C && (_C->flags & FLAG_CREATED));
struct chat *C = &_C->chat; struct chat *C = &_C->chat;
...@@ -689,7 +689,7 @@ int fetch_comb_binlog_chat_add_participant (void *extra) { ...@@ -689,7 +689,7 @@ int fetch_comb_binlog_chat_add_participant (void *extra) {
int fetch_comb_binlog_chat_del_participant (void *extra) { int fetch_comb_binlog_chat_del_participant (void *extra) {
peer_id_t id = MK_CHAT (fetch_int ()); peer_id_t id = MK_CHAT (fetch_int ());
peer_t *_C = user_chat_get (id); peer_t *_C = peer_get (id);
assert (_C && (_C->flags & FLAG_CREATED)); assert (_C && (_C->flags & FLAG_CREATED));
struct chat *C = &_C->chat; struct chat *C = &_C->chat;
...@@ -832,7 +832,7 @@ int fetch_comb_binlog_send_message_action_encr (void *extra) { ...@@ -832,7 +832,7 @@ int fetch_comb_binlog_send_message_action_encr (void *extra) {
M->date = fetch_int (); M->date = fetch_int ();
M->media.type = CODE_decrypted_message_media_empty; M->media.type = CODE_decrypted_message_media_empty;
fetch_message_action_encrypted ((void *)user_chat_get (M->to_id), &M->action); fetch_message_action_encrypted ((void *)peer_get (M->to_id), &M->action);
M->unread = 1; M->unread = 1;
M->out = get_peer_id (M->from_id) == our_id; M->out = get_peer_id (M->from_id) == our_id;
...@@ -1050,7 +1050,7 @@ int fetch_comb_binlog_create_message_service_encr (void *extra) { ...@@ -1050,7 +1050,7 @@ int fetch_comb_binlog_create_message_service_encr (void *extra) {
M->to_id = set_peer_id (t, fetch_int ()); M->to_id = set_peer_id (t, fetch_int ());
M->date = fetch_int (); M->date = fetch_int ();
struct secret_chat *E = (void *)user_chat_get (M->to_id); struct secret_chat *E = (void *)peer_get (M->to_id);
assert (E); assert (E);
fetch_message_action_encrypted (0, &M->action); fetch_message_action_encrypted (0, &M->action);
......
...@@ -230,7 +230,7 @@ char *get_default_prompt (void) { ...@@ -230,7 +230,7 @@ char *get_default_prompt (void) {
static char buf[1000]; static char buf[1000];
int l = 0; int l = 0;
if (in_chat_mode) { if (in_chat_mode) {
peer_t *U = user_chat_get (chat_mode_id); peer_t *U = peer_get (chat_mode_id);
assert (U && U->print_name); assert (U && U->print_name);
l += tsnprintf (buf + l, 999 - l, COLOR_RED "%.*s " COLOR_NORMAL, 100, U->print_name); l += tsnprintf (buf + l, 999 - l, COLOR_RED "%.*s " COLOR_NORMAL, 100, U->print_name);
} }
...@@ -856,7 +856,7 @@ void interpreter (char *line UU) { ...@@ -856,7 +856,7 @@ void interpreter (char *line UU) {
do_add_contact (phone, phone_len, first_name, first_name_len, last_name, last_name_len, 0); do_add_contact (phone, phone_len, first_name, first_name_len, last_name, last_name_len, 0);
} else if (IS_WORD ("rename_contact")) { } else if (IS_WORD ("rename_contact")) {
GET_PEER_USER; GET_PEER_USER;
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
if (!U) { if (!U) {
printf ("No such user\n"); printf ("No such user\n");
RET; RET;
...@@ -1407,13 +1407,13 @@ void print_service_message (struct message *M) { ...@@ -1407,13 +1407,13 @@ void print_service_message (struct message *M) {
pop_color (); pop_color ();
printf (" "); printf (" ");
if (get_peer_type (M->to_id) == PEER_CHAT) { if (get_peer_type (M->to_id) == PEER_CHAT) {
print_chat_name (M->to_id, user_chat_get (M->to_id)); print_chat_name (M->to_id, peer_get (M->to_id));
} else { } else {
assert (get_peer_type (M->to_id) == PEER_ENCR_CHAT); assert (get_peer_type (M->to_id) == PEER_ENCR_CHAT);
print_encr_chat_name (M->to_id, user_chat_get (M->to_id)); print_encr_chat_name (M->to_id, peer_get (M->to_id));
} }
printf (" "); printf (" ");
print_user_name (M->from_id, user_chat_get (M->from_id)); print_user_name (M->from_id, peer_get (M->from_id));
switch (M->action.type) { switch (M->action.type) {
case CODE_message_action_empty: case CODE_message_action_empty:
...@@ -1440,12 +1440,12 @@ void print_service_message (struct message *M) { ...@@ -1440,12 +1440,12 @@ void print_service_message (struct message *M) {
break; break;
case CODE_message_action_chat_add_user: case CODE_message_action_chat_add_user:
printf (" added user "); printf (" added user ");
print_user_name (set_peer_id (PEER_USER, M->action.user), user_chat_get (set_peer_id (PEER_USER, M->action.user))); print_user_name (set_peer_id (PEER_USER, M->action.user), peer_get (set_peer_id (PEER_USER, M->action.user)));
printf ("\n"); printf ("\n");
break; break;
case CODE_message_action_chat_delete_user: case CODE_message_action_chat_delete_user:
printf (" deleted user "); printf (" deleted user ");
print_user_name (set_peer_id (PEER_USER, M->action.user), user_chat_get (set_peer_id (PEER_USER, M->action.user))); print_user_name (set_peer_id (PEER_USER, M->action.user), peer_get (set_peer_id (PEER_USER, M->action.user)));
printf ("\n"); printf ("\n");
break; break;
case CODE_decrypted_message_action_set_message_t_t_l: case CODE_decrypted_message_action_set_message_t_t_l:
...@@ -1504,7 +1504,7 @@ void print_message (struct message *M) { ...@@ -1504,7 +1504,7 @@ void print_message (struct message *M) {
print_date (M->date); print_date (M->date);
pop_color (); pop_color ();
printf (" "); printf (" ");
print_user_name (M->to_id, user_chat_get (M->to_id)); print_user_name (M->to_id, peer_get (M->to_id));
push_color (COLOR_GREEN); push_color (COLOR_GREEN);
if (M->unread) { if (M->unread) {
printf (" <<< "); printf (" <<< ");
...@@ -1519,7 +1519,7 @@ void print_message (struct message *M) { ...@@ -1519,7 +1519,7 @@ void print_message (struct message *M) {
print_date (M->date); print_date (M->date);
pop_color (); pop_color ();
printf (" "); printf (" ");
print_user_name (M->from_id, user_chat_get (M->from_id)); print_user_name (M->from_id, peer_get (M->from_id));
push_color (COLOR_BLUE); push_color (COLOR_BLUE);
if (M->unread) { if (M->unread) {
printf (" >>> "); printf (" >>> ");
...@@ -1531,7 +1531,7 @@ void print_message (struct message *M) { ...@@ -1531,7 +1531,7 @@ void print_message (struct message *M) {
} }
} }
} else if (get_peer_type (M->to_id) == PEER_ENCR_CHAT) { } else if (get_peer_type (M->to_id) == PEER_ENCR_CHAT) {
peer_t *P = user_chat_get (M->to_id); peer_t *P = peer_get (M->to_id);
assert (P); assert (P);
if (M->out) { if (M->out) {
push_color (COLOR_GREEN); push_color (COLOR_GREEN);
...@@ -1575,9 +1575,9 @@ void print_message (struct message *M) { ...@@ -1575,9 +1575,9 @@ void print_message (struct message *M) {
print_date (M->date); print_date (M->date);
pop_color (); pop_color ();
printf (" "); printf (" ");
print_chat_name (M->to_id, user_chat_get (M->to_id)); print_chat_name (M->to_id, peer_get (M->to_id));
printf (" "); printf (" ");
print_user_name (M->from_id, user_chat_get (M->from_id)); print_user_name (M->from_id, peer_get (M->from_id));
if ((get_peer_type (M->from_id) == PEER_USER) && (get_peer_id (M->from_id) == our_id)) { if ((get_peer_type (M->from_id) == PEER_USER) && (get_peer_id (M->from_id) == our_id)) {
push_color (COLOR_GREEN); push_color (COLOR_GREEN);
} else { } else {
...@@ -1591,7 +1591,7 @@ void print_message (struct message *M) { ...@@ -1591,7 +1591,7 @@ void print_message (struct message *M) {
} }
if (get_peer_type (M->fwd_from_id) == PEER_USER) { if (get_peer_type (M->fwd_from_id) == PEER_USER) {
printf ("[fwd from "); printf ("[fwd from ");
print_user_name (M->fwd_from_id, user_chat_get (M->fwd_from_id)); print_user_name (M->fwd_from_id, peer_get (M->fwd_from_id));
printf ("] "); printf ("] ");
} }
if (M->message && strlen (M->message)) { if (M->message && strlen (M->message)) {
......
...@@ -82,7 +82,7 @@ void push_chat (peer_t *P) { ...@@ -82,7 +82,7 @@ void push_chat (peer_t *P) {
void push_encr_chat (peer_t *P) { void push_encr_chat (peer_t *P) {
my_lua_checkstack (luaState, 4); my_lua_checkstack (luaState, 4);
lua_pushstring (luaState, "user"); lua_pushstring (luaState, "user");
push_peer (MK_USER (P->encr_chat.user_id), user_chat_get (MK_USER (P->encr_chat.user_id))); push_peer (MK_USER (P->encr_chat.user_id), peer_get (MK_USER (P->encr_chat.user_id)));
lua_settable (luaState, -3); lua_settable (luaState, -3);
} }
...@@ -188,18 +188,18 @@ void push_message (struct message *M) { ...@@ -188,18 +188,18 @@ void push_message (struct message *M) {
if (get_peer_type (M->fwd_from_id)) { if (get_peer_type (M->fwd_from_id)) {
lua_pushstring (luaState, "fwd_from"); lua_pushstring (luaState, "fwd_from");
push_peer (M->fwd_from_id, user_chat_get (M->fwd_from_id)); push_peer (M->fwd_from_id, peer_get (M->fwd_from_id));
lua_settable (luaState, -3); // fwd_from lua_settable (luaState, -3); // fwd_from
lua_add_num_field ("fwd_date", M->fwd_date); lua_add_num_field ("fwd_date", M->fwd_date);
} }
lua_pushstring (luaState, "from"); lua_pushstring (luaState, "from");
push_peer (M->from_id, user_chat_get (M->from_id)); push_peer (M->from_id, peer_get (M->from_id));
lua_settable (luaState, -3); lua_settable (luaState, -3);
lua_pushstring (luaState, "to"); lua_pushstring (luaState, "to");
push_peer (M->to_id, user_chat_get (M->to_id)); push_peer (M->to_id, peer_get (M->to_id));
lua_settable (luaState, -3); lua_settable (luaState, -3);
lua_pushstring (luaState, "out"); lua_pushstring (luaState, "out");
......
...@@ -846,7 +846,7 @@ void work_update_binlog (void) { ...@@ -846,7 +846,7 @@ void work_update_binlog (void) {
case CODE_update_user_name: case CODE_update_user_name:
{ {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
peer_t *UC = user_chat_get (user_id); peer_t *UC = peer_get (user_id);
if (UC) { if (UC) {
struct user *U = &UC->user; struct user *U = &UC->user;
if (U->first_name) { tfree_str (U->first_name); } if (U->first_name) { tfree_str (U->first_name); }
...@@ -868,7 +868,7 @@ void work_update_binlog (void) { ...@@ -868,7 +868,7 @@ void work_update_binlog (void) {
case CODE_update_user_photo: case CODE_update_user_photo:
{ {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
peer_t *UC = user_chat_get (user_id); peer_t *UC = peer_get (user_id);
fetch_date (); fetch_date ();
if (UC) { if (UC) {
struct user *U = &UC->user; struct user *U = &UC->user;
...@@ -952,7 +952,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -952,7 +952,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case CODE_update_user_typing: case CODE_update_user_typing:
{ {
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
if (log_level >= 2) { if (log_level >= 2) {
print_start (); print_start ();
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
...@@ -969,8 +969,8 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -969,8 +969,8 @@ void work_update (struct connection *c UU, long long msg_id UU) {
{ {
peer_id_t chat_id = MK_CHAT (fetch_int ()); peer_id_t chat_id = MK_CHAT (fetch_int ());
peer_id_t id = MK_USER (fetch_int ()); peer_id_t id = MK_USER (fetch_int ());
peer_t *C = user_chat_get (chat_id); peer_t *C = peer_get (chat_id);
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
if (log_level >= 2) { if (log_level >= 2) {
print_start (); print_start ();
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
...@@ -988,7 +988,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -988,7 +988,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case CODE_update_user_status: case CODE_update_user_status:
{ {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (user_id); peer_t *U = peer_get (user_id);
if (U) { if (U) {
fetch_user_status (&U->user.status); fetch_user_status (&U->user.status);
if (log_level >= 3) { if (log_level >= 3) {
...@@ -1011,7 +1011,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1011,7 +1011,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case CODE_update_user_name: case CODE_update_user_name:
{ {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
peer_t *UC = user_chat_get (user_id); peer_t *UC = peer_get (user_id);
if (UC && (UC->flags & FLAG_CREATED)) { if (UC && (UC->flags & FLAG_CREATED)) {
int l1 = prefetch_strlen (); int l1 = prefetch_strlen ();
char *f = fetch_str (l1); char *f = fetch_str (l1);
...@@ -1038,7 +1038,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1038,7 +1038,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case CODE_update_user_photo: case CODE_update_user_photo:
{ {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
peer_t *UC = user_chat_get (user_id); peer_t *UC = peer_get (user_id);
fetch_date (); fetch_date ();
if (UC && (UC->flags & FLAG_CREATED)) { if (UC && (UC->flags & FLAG_CREATED)) {
struct user *U = &UC->user; struct user *U = &UC->user;
...@@ -1116,7 +1116,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1116,7 +1116,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
assert (x == CODE_chat_participants || x == CODE_chat_participants_forbidden); assert (x == CODE_chat_participants || x == CODE_chat_participants_forbidden);
peer_id_t chat_id = MK_CHAT (fetch_int ()); peer_id_t chat_id = MK_CHAT (fetch_int ());
int n = 0; int n = 0;
peer_t *C = user_chat_get (chat_id); peer_t *C = peer_get (chat_id);
if (C && (C->flags & FLAG_CREATED)) { if (C && (C->flags & FLAG_CREATED)) {
if (x == CODE_chat_participants) { if (x == CODE_chat_participants) {
bl_do_chat_set_admin (&C->chat, fetch_int ()); bl_do_chat_set_admin (&C->chat, fetch_int ());
...@@ -1159,7 +1159,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1159,7 +1159,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case CODE_update_contact_registered: case CODE_update_contact_registered:
{ {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (user_id); peer_t *U = peer_get (user_id);
fetch_int (); // date fetch_int (); // date
print_start (); print_start ();
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
...@@ -1174,7 +1174,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1174,7 +1174,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case CODE_update_contact_link: case CODE_update_contact_link:
{ {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (user_id); peer_t *U = peer_get (user_id);
print_start (); print_start ();
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
print_date (time (0)); print_date (time (0));
...@@ -1198,7 +1198,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1198,7 +1198,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case CODE_update_activation: case CODE_update_activation:
{ {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
peer_t *U = user_chat_get (user_id); peer_t *U = peer_get (user_id);
print_start (); print_start ();
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
print_date (time (0)); print_date (time (0));
...@@ -1290,14 +1290,14 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1290,14 +1290,14 @@ void work_update (struct connection *c UU, long long msg_id UU) {
case CODE_update_encrypted_chat_typing: case CODE_update_encrypted_chat_typing:
{ {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); peer_id_t id = MK_ENCR_CHAT (fetch_int ());
peer_t *P = user_chat_get (id); peer_t *P = peer_get (id);
print_start (); print_start ();
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
print_date (time (0)); print_date (time (0));
if (P) { if (P) {
printf (" User "); printf (" User ");
peer_id_t user_id = MK_USER (P->encr_chat.user_id); peer_id_t user_id = MK_USER (P->encr_chat.user_id);
print_user_name (user_id, user_chat_get (user_id)); print_user_name (user_id, peer_get (user_id));
printf (" typing in secret chat "); printf (" typing in secret chat ");
print_encr_chat_name (id, P); print_encr_chat_name (id, P);
printf ("\n"); printf ("\n");
...@@ -1313,7 +1313,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1313,7 +1313,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
peer_id_t id = MK_ENCR_CHAT (fetch_int ()); // chat_id peer_id_t id = MK_ENCR_CHAT (fetch_int ()); // chat_id
fetch_int (); // max_date fetch_int (); // max_date
fetch_int (); // date fetch_int (); // date
peer_t *P = user_chat_get (id); peer_t *P = peer_get (id);
int x = -1; int x = -1;
if (P && P->last) { if (P && P->last) {
x = 0; x = 0;
...@@ -1331,7 +1331,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1331,7 +1331,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
print_date (time (0)); print_date (time (0));
printf (" Encrypted chat "); printf (" Encrypted chat ");
print_encr_chat_name_full (id, user_chat_get (id)); print_encr_chat_name_full (id, peer_get (id));
printf (": %d messages marked read \n", x); printf (": %d messages marked read \n", x);
pop_color (); pop_color ();
print_end (); print_end ();
...@@ -1345,7 +1345,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1345,7 +1345,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
peer_id_t inviter_id = MK_USER (fetch_int ()); peer_id_t inviter_id = MK_USER (fetch_int ());
int version = fetch_int (); int version = fetch_int ();
peer_t *C = user_chat_get (chat_id); peer_t *C = peer_get (chat_id);
if (C && (C->flags & FLAG_CREATED)) { if (C && (C->flags & FLAG_CREATED)) {
bl_do_chat_add_user (&C->chat, version, get_peer_id (user_id), get_peer_id (inviter_id), time (0)); bl_do_chat_add_user (&C->chat, version, get_peer_id (user_id), get_peer_id (inviter_id), time (0));
} }
...@@ -1354,11 +1354,11 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1354,11 +1354,11 @@ void work_update (struct connection *c UU, long long msg_id UU) {
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
print_date (time (0)); print_date (time (0));
printf (" Chat "); printf (" Chat ");
print_chat_name (chat_id, user_chat_get (chat_id)); print_chat_name (chat_id, peer_get (chat_id));
printf (": user "); printf (": user ");
print_user_name (user_id, user_chat_get (user_id)); print_user_name (user_id, peer_get (user_id));
printf (" added by user "); printf (" added by user ");
print_user_name (inviter_id, user_chat_get (inviter_id)); print_user_name (inviter_id, peer_get (inviter_id));
printf ("\n"); printf ("\n");
pop_color (); pop_color ();
print_end (); print_end ();
...@@ -1370,7 +1370,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1370,7 +1370,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
peer_id_t user_id = MK_USER (fetch_int ()); peer_id_t user_id = MK_USER (fetch_int ());
int version = fetch_int (); int version = fetch_int ();
peer_t *C = user_chat_get (chat_id); peer_t *C = peer_get (chat_id);
if (C && (C->flags & FLAG_CREATED)) { if (C && (C->flags & FLAG_CREATED)) {
bl_do_chat_del_user (&C->chat, version, get_peer_id (user_id)); bl_do_chat_del_user (&C->chat, version, get_peer_id (user_id));
} }
...@@ -1379,9 +1379,9 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1379,9 +1379,9 @@ void work_update (struct connection *c UU, long long msg_id UU) {
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
print_date (time (0)); print_date (time (0));
printf (" Chat "); printf (" Chat ");
print_chat_name (chat_id, user_chat_get (chat_id)); print_chat_name (chat_id, peer_get (chat_id));
printf (": user "); printf (": user ");
print_user_name (user_id, user_chat_get (user_id)); print_user_name (user_id, peer_get (user_id));
printf (" deleted\n"); printf (" deleted\n");
pop_color (); pop_color ();
print_end (); print_end ();
...@@ -1402,7 +1402,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1402,7 +1402,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
{ {
int id = fetch_int (); int id = fetch_int ();
int blocked = fetch_bool (); int blocked = fetch_bool ();
peer_t *P = user_chat_get (MK_USER (id)); peer_t *P = peer_get (MK_USER (id));
if (P && (P->flags & FLAG_CREATED)) { if (P && (P->flags & FLAG_CREATED)) {
bl_do_user_set_blocked (&P->user, blocked); bl_do_user_set_blocked (&P->user, blocked);
} }
......
...@@ -940,7 +940,7 @@ int out_message_num; ...@@ -940,7 +940,7 @@ int out_message_num;
int our_id; int our_id;
void do_send_encr_msg_action (struct message *M) { void do_send_encr_msg_action (struct message *M) {
peer_t *P = user_chat_get (M->to_id); peer_t *P = peer_get (M->to_id);
if (!P || P->encr_chat.state != sc_ok) { return; } if (!P || P->encr_chat.state != sc_ok) { return; }
clear_packet (); clear_packet ();
...@@ -974,7 +974,7 @@ void do_send_encr_msg (struct message *M) { ...@@ -974,7 +974,7 @@ void do_send_encr_msg (struct message *M) {
do_send_encr_msg_action (M); do_send_encr_msg_action (M);
return; return;
} }
peer_t *P = user_chat_get (M->to_id); peer_t *P = peer_get (M->to_id);
if (!P || P->encr_chat.state != sc_ok) { return; } if (!P || P->encr_chat.state != sc_ok) { return; }
clear_packet (); clear_packet ();
...@@ -1011,7 +1011,7 @@ void do_send_msg (struct message *M) { ...@@ -1011,7 +1011,7 @@ void do_send_msg (struct message *M) {
void do_send_message (peer_id_t id, const char *msg, int len) { void do_send_message (peer_id_t id, const char *msg, int len) {
if (get_peer_type (id) == PEER_ENCR_CHAT) { if (get_peer_type (id) == PEER_ENCR_CHAT) {
peer_t *P = user_chat_get (id); peer_t *P = peer_get (id);
if (!P) { if (!P) {
logprintf ("Can not send to unknown encrypted chat\n"); logprintf ("Can not send to unknown encrypted chat\n");
return; return;
...@@ -1100,7 +1100,7 @@ void do_messages_mark_read_encr (peer_id_t id, long long access_hash, int last_t ...@@ -1100,7 +1100,7 @@ void do_messages_mark_read_encr (peer_id_t id, long long access_hash, int last_t
} }
void do_mark_read (peer_id_t id) { void do_mark_read (peer_id_t id) {
peer_t *P = user_chat_get (id); peer_t *P = peer_get (id);
if (!P) { if (!P) {
rprintf ("Unknown peer\n"); rprintf ("Unknown peer\n");
return; return;
...@@ -1169,7 +1169,7 @@ struct query_methods get_history_methods = { ...@@ -1169,7 +1169,7 @@ struct query_methods get_history_methods = {
}; };
void do_get_local_history (peer_id_t id, int limit) { void do_get_local_history (peer_id_t id, int limit) {
peer_t *P = user_chat_get (id); peer_t *P = peer_get (id);
if (!P || !P->last) { return; } if (!P || !P->last) { return; }
struct message *M = P->last; struct message *M = P->last;
int count = 1; int count = 1;
...@@ -1248,13 +1248,13 @@ int get_dialogs_on_answer (struct query *q UU) { ...@@ -1248,13 +1248,13 @@ int get_dialogs_on_answer (struct query *q UU) {
peer_t *UC; peer_t *UC;
switch (get_peer_type (plist[i])) { switch (get_peer_type (plist[i])) {
case PEER_USER: case PEER_USER:
UC = user_chat_get (plist[i]); UC = peer_get (plist[i]);
printf ("User "); printf ("User ");
print_user_name (plist[i], UC); print_user_name (plist[i], UC);
printf (": %d unread\n", dlist[2 * i + 1]); printf (": %d unread\n", dlist[2 * i + 1]);
break; break;
case PEER_CHAT: case PEER_CHAT:
UC = user_chat_get (plist[i]); UC = peer_get (plist[i]);
printf ("Chat "); printf ("Chat ");
print_chat_name (plist[i], UC); print_chat_name (plist[i], UC);
printf (": %d unread\n", dlist[2 * i + 1]); printf (": %d unread\n", dlist[2 * i + 1]);
...@@ -1312,7 +1312,7 @@ void out_peer_id (peer_id_t id) { ...@@ -1312,7 +1312,7 @@ void out_peer_id (peer_id_t id) {
out_int (get_peer_id (id)); out_int (get_peer_id (id));
break; break;
case PEER_USER: case PEER_USER:
U = user_chat_get (id); U = peer_get (id);
if (U && U->user.access_hash) { if (U && U->user.access_hash) {
out_int (CODE_input_peer_foreign); out_int (CODE_input_peer_foreign);
out_int (get_peer_id (id)); out_int (get_peer_id (id));
...@@ -1487,7 +1487,7 @@ void send_part (struct send_file *f) { ...@@ -1487,7 +1487,7 @@ void send_part (struct send_file *f) {
out_int (CODE_messages_send_encrypted_file); out_int (CODE_messages_send_encrypted_file);
out_int (CODE_input_encrypted_chat); out_int (CODE_input_encrypted_chat);
out_int (get_peer_id (f->to_id)); out_int (get_peer_id (f->to_id));
peer_t *P = user_chat_get (f->to_id); peer_t *P = peer_get (f->to_id);
assert (P); assert (P);
out_long (P->encr_chat.access_hash); out_long (P->encr_chat.access_hash);
long long r = -lrand48 () * (1ll << 32) - lrand48 (); long long r = -lrand48 () * (1ll << 32) - lrand48 ();
...@@ -1737,9 +1737,9 @@ void print_chat_info (struct chat *C) { ...@@ -1737,9 +1737,9 @@ void print_chat_info (struct chat *C) {
int i; int i;
for (i = 0; i < C->user_list_size; i++) { for (i = 0; i < C->user_list_size; i++) {
printf ("\t\t"); printf ("\t\t");
print_user_name (MK_USER (C->user_list[i].user_id), user_chat_get (MK_USER (C->user_list[i].user_id))); print_user_name (MK_USER (C->user_list[i].user_id), peer_get (MK_USER (C->user_list[i].user_id)));
printf (" invited by "); printf (" invited by ");
print_user_name (MK_USER (C->user_list[i].inviter_id), user_chat_get (MK_USER (C->user_list[i].inviter_id))); print_user_name (MK_USER (C->user_list[i].inviter_id), peer_get (MK_USER (C->user_list[i].inviter_id)));
printf (" at "); printf (" at ");
print_date_full (C->user_list[i].date); print_date_full (C->user_list[i].date);
if (C->user_list[i].user_id == C->admin_id) { if (C->user_list[i].user_id == C->admin_id) {
...@@ -1764,7 +1764,7 @@ struct query_methods chat_info_methods = { ...@@ -1764,7 +1764,7 @@ struct query_methods chat_info_methods = {
void do_get_chat_info (peer_id_t id) { void do_get_chat_info (peer_id_t id) {
if (offline_mode) { if (offline_mode) {
peer_t *C = user_chat_get (id); peer_t *C = peer_get (id);
if (!C) { if (!C) {
rprintf ("No such chat\n"); rprintf ("No such chat\n");
} else { } else {
...@@ -1815,7 +1815,7 @@ struct query_methods user_info_methods = { ...@@ -1815,7 +1815,7 @@ struct query_methods user_info_methods = {
void do_get_user_info (peer_id_t id) { void do_get_user_info (peer_id_t id) {
if (offline_mode) { if (offline_mode) {
peer_t *C = user_chat_get (id); peer_t *C = peer_get (id);
if (!C) { if (!C) {
rprintf ("No such user\n"); rprintf ("No such user\n");
} else { } else {
...@@ -1826,7 +1826,7 @@ void do_get_user_info (peer_id_t id) { ...@@ -1826,7 +1826,7 @@ void do_get_user_info (peer_id_t id) {
clear_packet (); clear_packet ();
out_int (CODE_users_get_full_user); out_int (CODE_users_get_full_user);
assert (get_peer_type (id) == PEER_USER); assert (get_peer_type (id) == PEER_USER);
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
if (U && U->user.access_hash) { if (U && U->user.access_hash) {
out_int (CODE_input_user_foreign); out_int (CODE_input_user_foreign);
out_int (get_peer_id (id)); out_int (get_peer_id (id));
...@@ -2557,18 +2557,18 @@ void do_send_create_encr_chat (void *x, unsigned char *random) { ...@@ -2557,18 +2557,18 @@ void do_send_create_encr_chat (void *x, unsigned char *random) {
BN_bn2bin (r, (void *)g_a); BN_bn2bin (r, (void *)g_a);
int t = lrand48 (); int t = lrand48 ();
while (user_chat_get (MK_ENCR_CHAT (t))) { while (peer_get (MK_ENCR_CHAT (t))) {
t = lrand48 (); t = lrand48 ();
} }
bl_do_encr_chat_init (t, user_id, (void *)random, (void *)g_a); bl_do_encr_chat_init (t, user_id, (void *)random, (void *)g_a);
peer_t *_E = user_chat_get (MK_ENCR_CHAT (t)); peer_t *_E = peer_get (MK_ENCR_CHAT (t));
assert (_E); assert (_E);
struct secret_chat *E = &_E->encr_chat; struct secret_chat *E = &_E->encr_chat;
clear_packet (); clear_packet ();
out_int (CODE_messages_request_encryption); out_int (CODE_messages_request_encryption);
peer_t *U = user_chat_get (MK_USER (E->user_id)); peer_t *U = peer_get (MK_USER (E->user_id));
assert (U); assert (U);
if (U && U->user.access_hash) { if (U && U->user.access_hash) {
out_int (CODE_input_user_foreign); out_int (CODE_input_user_foreign);
...@@ -2768,7 +2768,7 @@ char *colors[4] = {COLOR_GREY, COLOR_CYAN, COLOR_BLUE, COLOR_GREEN}; ...@@ -2768,7 +2768,7 @@ char *colors[4] = {COLOR_GREY, COLOR_CYAN, COLOR_BLUE, COLOR_GREEN};
void do_visualize_key (peer_id_t id) { void do_visualize_key (peer_id_t id) {
assert (get_peer_type (id) == PEER_ENCR_CHAT); assert (get_peer_type (id) == PEER_ENCR_CHAT);
peer_t *P = user_chat_get (id); peer_t *P = peer_get (id);
assert (P); assert (P);
if (P->encr_chat.state != sc_ok) { if (P->encr_chat.state != sc_ok) {
rprintf ("Chat is not initialized yet\n"); rprintf ("Chat is not initialized yet\n");
...@@ -2851,7 +2851,7 @@ void do_add_user_to_chat (peer_id_t chat_id, peer_id_t id, int limit) { ...@@ -2851,7 +2851,7 @@ void do_add_user_to_chat (peer_id_t chat_id, peer_id_t id, int limit) {
out_int (get_peer_id (chat_id)); out_int (get_peer_id (chat_id));
assert (get_peer_type (id) == PEER_USER); assert (get_peer_type (id) == PEER_USER);
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
if (U && U->user.access_hash) { if (U && U->user.access_hash) {
out_int (CODE_input_user_foreign); out_int (CODE_input_user_foreign);
out_int (get_peer_id (id)); out_int (get_peer_id (id));
...@@ -2870,7 +2870,7 @@ void do_del_user_from_chat (peer_id_t chat_id, peer_id_t id) { ...@@ -2870,7 +2870,7 @@ void do_del_user_from_chat (peer_id_t chat_id, peer_id_t id) {
out_int (get_peer_id (chat_id)); out_int (get_peer_id (chat_id));
assert (get_peer_type (id) == PEER_USER); assert (get_peer_type (id) == PEER_USER);
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
if (U && U->user.access_hash) { if (U && U->user.access_hash) {
out_int (CODE_input_user_foreign); out_int (CODE_input_user_foreign);
out_int (get_peer_id (id)); out_int (get_peer_id (id));
...@@ -2888,7 +2888,7 @@ char *create_print_name (peer_id_t id, const char *a1, const char *a2, const cha ...@@ -2888,7 +2888,7 @@ char *create_print_name (peer_id_t id, const char *a1, const char *a2, const cha
void do_create_secret_chat (peer_id_t id) { void do_create_secret_chat (peer_id_t id) {
assert (get_peer_type (id) == PEER_USER); assert (get_peer_type (id) == PEER_USER);
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
if (!U) { if (!U) {
rprintf ("Can not create chat with unknown user\n"); rprintf ("Can not create chat with unknown user\n");
return; return;
...@@ -2906,7 +2906,7 @@ struct query_methods create_group_chat_methods = { ...@@ -2906,7 +2906,7 @@ struct query_methods create_group_chat_methods = {
void do_create_group_chat (peer_id_t id, char *chat_topic) { void do_create_group_chat (peer_id_t id, char *chat_topic) {
assert (get_peer_type (id) == PEER_USER); assert (get_peer_type (id) == PEER_USER);
peer_t *U = user_chat_get (id); peer_t *U = peer_get (id);
if (!U) { if (!U) {
rprintf ("Can not create chat with unknown user\n"); rprintf ("Can not create chat with unknown user\n");
return; return;
......
...@@ -1108,7 +1108,7 @@ void fetch_encrypted_message (struct message *M) { ...@@ -1108,7 +1108,7 @@ void fetch_encrypted_message (struct message *M) {
peer_id_t chat = MK_ENCR_CHAT (to_id); peer_id_t chat = MK_ENCR_CHAT (to_id);
int date = fetch_int (); int date = fetch_int ();
peer_t *P = user_chat_get (chat); peer_t *P = peer_get (chat);
if (!P) { if (!P) {
logprintf ("Encrypted message to unknown chat. Dropping\n"); logprintf ("Encrypted message to unknown chat. Dropping\n");
M->flags |= FLAG_MESSAGE_EMPTY; M->flags |= FLAG_MESSAGE_EMPTY;
...@@ -1218,7 +1218,7 @@ static int id_cmp (struct message *M1, struct message *M2) { ...@@ -1218,7 +1218,7 @@ static int id_cmp (struct message *M1, struct message *M2) {
struct user *fetch_alloc_user (void) { struct user *fetch_alloc_user (void) {
int data[2]; int data[2];
prefetch_data (data, 8); prefetch_data (data, 8);
peer_t *U = user_chat_get (MK_USER (data[1])); peer_t *U = peer_get (MK_USER (data[1]));
if (!U) { if (!U) {
users_allocated ++; users_allocated ++;
U = talloc0 (sizeof (*U)); U = talloc0 (sizeof (*U));
...@@ -1234,7 +1234,7 @@ struct user *fetch_alloc_user (void) { ...@@ -1234,7 +1234,7 @@ struct user *fetch_alloc_user (void) {
struct secret_chat *fetch_alloc_encrypted_chat (void) { struct secret_chat *fetch_alloc_encrypted_chat (void) {
int data[2]; int data[2];
prefetch_data (data, 8); prefetch_data (data, 8);
peer_t *U = user_chat_get (MK_ENCR_CHAT (data[1])); peer_t *U = peer_get (MK_ENCR_CHAT (data[1]));
if (!U) { if (!U) {
U = talloc0 (sizeof (*U)); U = talloc0 (sizeof (*U));
U->id = MK_ENCR_CHAT (data[1]); U->id = MK_ENCR_CHAT (data[1]);
...@@ -1271,7 +1271,7 @@ void insert_chat (peer_t *P) { ...@@ -1271,7 +1271,7 @@ void insert_chat (peer_t *P) {
struct user *fetch_alloc_user_full (void) { struct user *fetch_alloc_user_full (void) {
int data[3]; int data[3];
prefetch_data (data, 12); prefetch_data (data, 12);
peer_t *U = user_chat_get (MK_USER (data[2])); peer_t *U = peer_get (MK_USER (data[2]));
if (U) { if (U) {
fetch_user_full (&U->user); fetch_user_full (&U->user);
return &U->user; return &U->user;
...@@ -1419,7 +1419,7 @@ void message_add_peer (struct message *M) { ...@@ -1419,7 +1419,7 @@ void message_add_peer (struct message *M) {
} else { } else {
id = M->to_id; id = M->to_id;
} }
peer_t *P = user_chat_get (id); peer_t *P = peer_get (id);
if (!P) { if (!P) {
P = talloc0 (sizeof (*P)); P = talloc0 (sizeof (*P));
P->id = id; P->id = id;
...@@ -1477,7 +1477,7 @@ void message_del_peer (struct message *M) { ...@@ -1477,7 +1477,7 @@ void message_del_peer (struct message *M) {
} else { } else {
id = M->to_id; id = M->to_id;
} }
peer_t *P = user_chat_get (id); peer_t *P = peer_get (id);
if (M->prev) { if (M->prev) {
M->prev->next = M->next; M->prev->next = M->next;
} }
...@@ -1576,7 +1576,7 @@ struct message *fetch_alloc_message_short_chat (void) { ...@@ -1576,7 +1576,7 @@ struct message *fetch_alloc_message_short_chat (void) {
struct chat *fetch_alloc_chat (void) { struct chat *fetch_alloc_chat (void) {
int data[2]; int data[2];
prefetch_data (data, 8); prefetch_data (data, 8);
peer_t *U = user_chat_get (MK_CHAT (data[1])); peer_t *U = peer_get (MK_CHAT (data[1]));
if (!U) { if (!U) {
chats_allocated ++; chats_allocated ++;
U = talloc0 (sizeof (*U)); U = talloc0 (sizeof (*U));
...@@ -1592,7 +1592,7 @@ struct chat *fetch_alloc_chat (void) { ...@@ -1592,7 +1592,7 @@ struct chat *fetch_alloc_chat (void) {
struct chat *fetch_alloc_chat_full (void) { struct chat *fetch_alloc_chat_full (void) {
int data[3]; int data[3];
prefetch_data (data, 12); prefetch_data (data, 12);
peer_t *U = user_chat_get (MK_CHAT (data[2])); peer_t *U = peer_get (MK_CHAT (data[2]));
if (U) { if (U) {
fetch_chat_full (&U->chat); fetch_chat_full (&U->chat);
return &U->chat; return &U->chat;
...@@ -1628,7 +1628,7 @@ int print_stat (char *s, int len) { ...@@ -1628,7 +1628,7 @@ int print_stat (char *s, int len) {
); );
} }
peer_t *user_chat_get (peer_id_t id) { peer_t *peer_get (peer_id_t id) {
static peer_t U; static peer_t U;
U.id = id; U.id = id;
return tree_lookup_peer (peer_tree, &U); return tree_lookup_peer (peer_tree, &U);
......
...@@ -367,7 +367,7 @@ void free_chat (struct chat *U); ...@@ -367,7 +367,7 @@ void free_chat (struct chat *U);
char *create_print_name (peer_id_t id, const char *a1, const char *a2, const char *a3, const char *a4); char *create_print_name (peer_id_t id, const char *a1, const char *a2, const char *a3, const char *a4);
int print_stat (char *s, int len); int print_stat (char *s, int len);
peer_t *user_chat_get (peer_id_t id); peer_t *peer_get (peer_id_t id);
struct message *message_get (long long id); struct message *message_get (long long id);
void update_message_id (struct message *M, long long id); void update_message_id (struct message *M, long long id);
void message_insert (struct message *M); void message_insert (struct message *M);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment