diff --git a/binlog.c b/binlog.c index 214c284..e49e655 100644 --- a/binlog.c +++ b/binlog.c @@ -273,7 +273,7 @@ void replay_log_event (struct telegram *instance) { } else { assert (!(_U->flags & FLAG_CREATED)); } - struct user *U = (void *)_U; + struct tgl_user *U = (void *)_U; U->flags |= FLAG_CREATED; if (get_peer_id (id) == instance->our_id) { U->flags |= FLAG_USER_SELF; @@ -1114,7 +1114,7 @@ void bl_do_new_user (struct binlog *bl, struct mtproto_connection *self, int id, add_log_event (bl, self, self->packet_buffer, 4 * (self->packet_ptr - self->packet_buffer)); } -void bl_do_user_delete (struct binlog *bl, struct mtproto_connection *self, struct user *U) { +void bl_do_user_delete (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U) { if (U->flags & FLAG_DELETED) { return; } int *ev = alloc_log_event (bl, 8); ev[0] = CODE_binlog_user_delete; @@ -1122,7 +1122,7 @@ void bl_do_user_delete (struct binlog *bl, struct mtproto_connection *self, stru add_log_event (bl, self, ev, 8); } -void bl_do_set_user_profile_photo (struct binlog *bl, struct mtproto_connection *self, struct user *U, +void bl_do_set_user_profile_photo (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, long long photo_id, struct file_location *big, struct file_location *small) { if (photo_id == U->photo_id) { return; } if (!photo_id) { @@ -1169,7 +1169,7 @@ void bl_do_set_user_profile_photo (struct binlog *bl, struct mtproto_connection } } -void bl_do_set_user_name (struct binlog *bl, struct mtproto_connection *self, struct user *U, const char *f, +void bl_do_set_user_name (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, const char *f, int fl, const char *l, int ll) { if ((U->first_name && (int)strlen (U->first_name) == fl && !strncmp (U->first_name, f, fl)) && (U->last_name && (int)strlen (U->last_name) == ll && !strncmp (U->last_name, l, ll))) { @@ -1183,7 +1183,7 @@ void bl_do_set_user_name (struct binlog *bl, struct mtproto_connection *self, st add_log_event (bl, self, self->packet_buffer, 4 * (self->packet_ptr - self->packet_buffer)); } -void bl_do_set_user_access_token (struct binlog *bl, struct mtproto_connection *self, struct user *U, long long access_token) { +void bl_do_set_user_access_token (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, long long access_token) { if (U->access_hash == access_token) { return; } int *ev = alloc_log_event (bl, 16); ev[0] = CODE_binlog_set_user_access_token; @@ -1192,7 +1192,7 @@ void bl_do_set_user_access_token (struct binlog *bl, struct mtproto_connection * add_log_event (bl, self, ev, 16); } -void bl_do_set_user_phone (struct binlog *bl, struct mtproto_connection *self, struct user *U, +void bl_do_set_user_phone (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, const char *p, int pl) { if (U->phone && (int)strlen (U->phone) == pl && !strncmp (U->phone, p, pl)) { return; @@ -1204,7 +1204,7 @@ const char *p, int pl) { add_log_event (bl, self, self->packet_buffer, 4 * (self->packet_ptr - self->packet_buffer)); } -void bl_do_set_user_friend (struct binlog *bl, struct mtproto_connection *self, struct user *U, int friend) { +void bl_do_set_user_friend (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, int friend) { if (friend == ((U->flags & FLAG_USER_CONTACT) != 0)) { return ; } int *ev = alloc_log_event (bl, 12); ev[0] = CODE_binlog_set_user_friend; @@ -1242,7 +1242,7 @@ void bl_do_set_working_dc (struct binlog *bl, struct mtproto_connection *self, i add_log_event (bl, self, ev, 8); } -void bl_do_set_user_full_photo (struct binlog *bl, struct mtproto_connection *self, struct user *U, const int *start, int len) { +void bl_do_set_user_full_photo (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, const int *start, int len) { if (U->photo.id == *(long long *)(start + 1)) { return; } int *ev = alloc_log_event (bl, len + 8); ev[0] = CODE_binlog_user_full_photo; @@ -1251,7 +1251,7 @@ void bl_do_set_user_full_photo (struct binlog *bl, struct mtproto_connection *se add_log_event (bl, self, ev, len + 8); } -void bl_do_set_user_blocked (struct binlog *bl, struct mtproto_connection *self, struct user *U, int blocked) { +void bl_do_set_user_blocked (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, int blocked) { if (U->blocked == blocked) { return; } int *ev = alloc_log_event (bl, 12); ev[0] = CODE_binlog_user_blocked; @@ -1260,7 +1260,7 @@ void bl_do_set_user_blocked (struct binlog *bl, struct mtproto_connection *self, add_log_event (bl, self, ev, 12); } -void bl_do_set_user_real_name (struct binlog *bl, struct mtproto_connection *self, struct user *U, const char *f, int fl, const char *l, int ll) { +void bl_do_set_user_real_name (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, const char *f, int fl, const char *l, int ll) { if ((U->real_first_name && (int)strlen (U->real_first_name) == fl && !strncmp (U->real_first_name, f, fl)) && (U->real_last_name && (int)strlen (U->real_last_name) == ll && !strncmp (U->real_last_name, l, ll))) { return; diff --git a/binlog.h b/binlog.h index 1f6b1ed..ac4b7b1 100644 --- a/binlog.h +++ b/binlog.h @@ -93,15 +93,15 @@ void bl_do_dc_option (struct binlog *bl, struct mtproto_connection *self, int id void bl_do_set_our_id (struct binlog *bl, struct mtproto_connection *self, int id); void bl_do_new_user (struct binlog *bl, struct mtproto_connection *self, int id, const char *f, int fl, const char *l, int ll, long long access_token, const char *p, int pl, int contact); -void bl_do_user_delete (struct binlog *bl, struct mtproto_connection *self, struct user *U); -void bl_do_set_user_profile_photo (struct binlog *bl, struct mtproto_connection *self, struct user *U, long long photo_id, struct file_location *big, struct file_location *small); -void bl_do_set_user_name (struct binlog *bl, struct mtproto_connection *self, struct user *U, const char *f, int fl, const char *l, int ll); -void bl_do_set_user_access_token (struct binlog *bl, struct mtproto_connection *self, struct user *U, long long access_token); -void bl_do_set_user_phone (struct binlog *bl, struct mtproto_connection *self, struct user *U, const char *p, int pl); -void bl_do_set_user_friend (struct binlog *bl, struct mtproto_connection *self, struct user *U, int friend); -void bl_do_set_user_full_photo (struct binlog *bl, struct mtproto_connection *self, struct user *U, const int *start, int len); -void bl_do_set_user_blocked (struct binlog *bl, struct mtproto_connection *self, struct user *U, int blocked); -void bl_do_set_user_real_name (struct binlog *bl, struct mtproto_connection *self, struct user *U, const char *f, int fl, const char *l, int ll); +void bl_do_user_delete (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U); +void bl_do_set_user_profile_photo (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, long long photo_id, struct file_location *big, struct file_location *small); +void bl_do_set_user_name (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, const char *f, int fl, const char *l, int ll); +void bl_do_set_user_access_token (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, long long access_token); +void bl_do_set_user_phone (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, const char *p, int pl); +void bl_do_set_user_friend (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, int friend); +void bl_do_set_user_full_photo (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, const int *start, int len); +void bl_do_set_user_blocked (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, int blocked); +void bl_do_set_user_real_name (struct binlog *bl, struct mtproto_connection *self, struct tgl_user *U, const char *f, int fl, const char *l, int ll); void bl_do_encr_chat_delete (struct binlog *bl, struct mtproto_connection *self, struct secret_chat *U); void bl_do_encr_chat_requested (struct binlog *bl, struct mtproto_connection *self, struct secret_chat *U, long long access_hash, int date, int admin_id, int user_id, unsigned char g_key[], unsigned char nonce[]); diff --git a/mtproto-client.c b/mtproto-client.c index 4dd20f5..30c6a11 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -806,7 +806,7 @@ void work_update_binlog (struct mtproto_connection *self) { peer_id_t user_id = MK_USER (fetch_int (self)); peer_t *UC = user_chat_get (bl, user_id); if (UC) { - struct user *U = &UC->user; + struct tgl_user *U = &UC->user; if (U->first_name) { tfree_str (U->first_name); } if (U->last_name) { tfree_str (U->last_name); } if (U->print_name) { @@ -829,7 +829,7 @@ void work_update_binlog (struct mtproto_connection *self) { peer_t *UC = user_chat_get (bl, user_id); fetch_date (self); if (UC) { - struct user *U = &UC->user; + struct tgl_user *U = &UC->user; unsigned y = fetch_int (self); if (y == CODE_user_profile_photo_empty) { diff --git a/queries.c b/queries.c index 3d83789..63a57fe 100644 --- a/queries.c +++ b/queries.c @@ -835,7 +835,7 @@ int msg_send_on_answer (struct query *q UU) { if (b == CODE_contacts_foreign_link_requested) { fetch_bool (mtp); } - struct user *U = fetch_alloc_user (mtp); + struct tgl_user *U = fetch_alloc_user (mtp); U->flags &= ~(FLAG_USER_IN_CONTACT | FLAG_USER_OUT_CONTACT); if (a == CODE_contacts_my_link_contact) { @@ -1760,7 +1760,7 @@ void do_get_chat_info (struct telegram *instance, peer_id_t id) { /* {{{ User info */ -void print_user_info (struct user *U) { +void print_user_info (struct tgl_user *U) { // TODO: use peer peer_t *C UU = (void *)U; @@ -1790,7 +1790,7 @@ int user_info_on_answer (struct query *q UU) { struct mtproto_connection *mtp = query_get_mtproto(q); struct show_info_extra *extra = q->extra; - struct user *U = fetch_alloc_user_full (mtp); + struct tgl_user *U = fetch_alloc_user_full (mtp); event_user_info_received_handler (mtp->instance, U, extra->show_info); tfree (extra, sizeof(struct show_info_extra)); //print_user_info (U); @@ -2233,7 +2233,7 @@ int add_contact_on_answer (struct query *q UU) { assert (fetch_int (mtp) == CODE_vector); n = fetch_int (mtp); for (i = 0; i < n ; i++) { - struct user *U = fetch_alloc_user (mtp); + struct tgl_user *U = fetch_alloc_user (mtp); //print_start (); //push_color (COLOR_YELLOW); debug ("User #%d: ", get_peer_id (U->id)); @@ -2337,7 +2337,7 @@ int contacts_search_on_answer (struct query *q UU) { //print_start (); //push_color (COLOR_YELLOW); for (i = 0; i < n; i++) { - struct user *U = fetch_alloc_user (mtp); + struct tgl_user *U = fetch_alloc_user (mtp); debug ("User "); //push_color (COLOR_RED); debug ("%s %s", U->first_name, U->last_name); diff --git a/structures.c b/structures.c index d7feadb..ed30181 100644 --- a/structures.c +++ b/structures.c @@ -164,7 +164,7 @@ char *create_print_name (struct binlog *bl, peer_id_t id, const char *a1, const * */ -long long fetch_user_photo (struct mtproto_connection *mtp, struct user *U) { +long long fetch_user_photo (struct mtproto_connection *mtp, struct tgl_user *U) { unsigned x = fetch_int (mtp); code_assert (x == CODE_user_profile_photo || x == CODE_user_profile_photo_old || x == CODE_user_profile_photo_empty); if (x == CODE_user_profile_photo_empty) { @@ -199,7 +199,7 @@ int user_get_alias(peer_t *user, char *buffer, int maxlen) } } -int fetch_user (struct mtproto_connection *mtp, struct user *U) { +int fetch_user (struct mtproto_connection *mtp, struct tgl_user *U) { struct telegram *instance = mtp->instance; unsigned x = fetch_int (mtp); @@ -408,7 +408,7 @@ void fetch_encrypted_chat (struct mtproto_connection *mtp, struct secret_chat *U } void fetch_notify_settings (struct mtproto_connection *mtp); -void fetch_user_full (struct mtproto_connection *mtp, struct user *U) { +void fetch_user_full (struct mtproto_connection *mtp, struct tgl_user *U) { assert (fetch_int (mtp) == CODE_user_full); fetch_alloc_user (mtp); unsigned x; @@ -1522,7 +1522,7 @@ static int id_cmp (struct message *M1, struct message *M2) { else { return 0; } } -struct user *fetch_alloc_user (struct mtproto_connection *mtp) { +struct tgl_user *fetch_alloc_user (struct mtproto_connection *mtp) { struct binlog *bl = mtp->instance->bl; debug("fetch_alloc_user()\n"); @@ -1587,7 +1587,7 @@ void insert_chat (struct binlog *bl, peer_t *P) { bl->Peers[bl->peer_num ++] = P; } -struct user *fetch_alloc_user_full (struct mtproto_connection *mtp) { +struct tgl_user *fetch_alloc_user_full (struct mtproto_connection *mtp) { struct binlog *bl = mtp->bl; int data[3]; prefetch_data (mtp, data, 12); @@ -1607,7 +1607,7 @@ struct user *fetch_alloc_user_full (struct mtproto_connection *mtp) { } } -void free_user (struct user *U) { +void free_user (struct tgl_user *U) { if (U->first_name) { tfree_str (U->first_name); } if (U->last_name) { tfree_str (U->last_name); } if (U->print_name) { tfree_str (U->print_name); } diff --git a/structures.h b/structures.h index 00bef50..cc4ce08 100644 --- a/structures.h +++ b/structures.h @@ -142,7 +142,7 @@ struct user_status { int when; }; -struct user { +struct tgl_user { peer_id_t id; int flags; struct message *last; @@ -229,7 +229,7 @@ typedef union peer { struct file_location photo_small; struct photo photo; }; - struct user user; + struct tgl_user user; struct chat chat; struct secret_chat encr_chat; } peer_t; @@ -337,9 +337,9 @@ struct message { int fetch_file_location (struct mtproto_connection *mtp, struct file_location *loc); int fetch_user_status (struct mtproto_connection *mtp, struct user_status *S); -int fetch_user (struct mtproto_connection *mtp, struct user *U); -struct user *fetch_alloc_user (struct mtproto_connection *mtp); -struct user *fetch_alloc_user_full (struct mtproto_connection *mtp); +int fetch_user (struct mtproto_connection *mtp, struct tgl_user *U); +struct tgl_user *fetch_alloc_user (struct mtproto_connection *mtp); +struct tgl_user *fetch_alloc_user_full (struct mtproto_connection *mtp); struct chat *fetch_alloc_chat (struct mtproto_connection *mtp); struct chat *fetch_alloc_chat_full (struct mtproto_connection *mtp); struct secret_chat *fetch_alloc_encrypted_chat (struct mtproto_connection *mtp); @@ -358,7 +358,7 @@ void fetch_message_media_encrypted (struct mtproto_connection *mtp, struct messa void fetch_message_action (struct mtproto_connection *mtp, struct message_action *M); void message_insert_tree (struct message *M); -void free_user (struct user *U); +void free_user (struct tgl_user *U); void free_chat (struct chat *U); char *create_print_name (struct binlog *bl, peer_id_t id, const char *a1, const char *a2, const char *a3, const char *a4); diff --git a/telegram.h b/telegram.h index 736f11e..9e14021 100644 --- a/telegram.h +++ b/telegram.h @@ -251,7 +251,7 @@ struct telegram { long long cur_downloading_bytes; long long cur_downloaded_bytes; int our_id; - struct user User; + struct tgl_user User; BN_CTX *ctx; int encr_root; unsigned char *encr_prime;