From 62d3c07f343588c488768690412cc5b4ad998ff9 Mon Sep 17 00:00:00 2001 From: Vysheng Date: Mon, 6 Oct 2014 14:06:48 +0400 Subject: [PATCH] Updated layer 17 --- interface.c | 2 +- queries.c | 28 ++++++++++++++++------------ structures.c | 6 +++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/interface.c b/interface.c index 458fe65..9eaa796 100644 --- a/interface.c +++ b/interface.c @@ -2304,7 +2304,7 @@ void print_media (struct in_ev *ev, struct tgl_message_media *M) { } return; case tgl_message_media_geo: - mprintf (ev, "[geo] https://maps.google.com/?q=%.6lf,%.6lf", M->geo.latitude, M->geo.longitude); + mprintf (ev, "[geo] https://maps.google.com/?q=%.6lf,%.6lf", M->geo.longitude, M->geo.latitude); return; case tgl_message_media_contact: mprintf (ev, "[contact] "); diff --git a/queries.c b/queries.c index a72aa46..792c2b2 100644 --- a/queries.c +++ b/queries.c @@ -994,13 +994,13 @@ void tgl_do_send_encr_msg_action (struct tgl_message *M, void (*callback)(void * out_int (CODE_decrypted_message_service_l16); } else { out_int (CODE_decrypted_message_service); + } + out_long (M->id); + out_random (15 + 4 * (lrand48 () % 3)); + if (P->encr_chat.layer >= 17) { out_int (2 * P->encr_chat.in_seq_no + (P->encr_chat.admin_id != tgl_state.our_id)); out_int (2 * P->encr_chat.out_seq_no + (P->encr_chat.admin_id == tgl_state.our_id)); } - out_long (M->id); - static int buf[4]; - tglt_secure_random (buf, 16); - out_cstring ((void *)buf, 16); switch (M->action.type) { case tgl_message_action_notify_layer: @@ -1044,14 +1044,14 @@ void tgl_do_send_encr_msg (struct tgl_message *M, void (*callback)(void *callbac out_int (CODE_decrypted_message_l16); } else { out_int (CODE_decrypted_message); + } + out_long (M->id); + out_random (15 + 4 * (lrand48 () % 3)); + if (P->encr_chat.layer >= 17) { out_int (2 * P->encr_chat.in_seq_no + (P->encr_chat.admin_id != tgl_state.our_id)); out_int (2 * P->encr_chat.out_seq_no + (P->encr_chat.admin_id == tgl_state.our_id)); out_int (0); } - out_long (M->id); - static int buf[4]; - tglt_secure_random (buf, 16); - out_cstring ((void *)buf, 16); out_cstring ((void *)M->message, M->message_len); out_int (CODE_decrypted_message_media_empty); encr_finish (&P->encr_chat); @@ -1789,12 +1789,14 @@ static void send_part (struct send_file *f, void *callback, void *callback_extra out_int (CODE_decrypted_message_l16); } else { out_int (CODE_decrypted_message); + } + out_long (r); + out_random (15 + 4 * (lrand48 () % 3)); + if (P->encr_chat.layer >= 17) { out_int (2 * P->encr_chat.in_seq_no + (P->encr_chat.admin_id != tgl_state.our_id)); out_int (2 * P->encr_chat.out_seq_no + (P->encr_chat.admin_id == tgl_state.our_id) + 2); out_int (0); } - out_long (r); - out_random (15 + 4 * (lrand48 () % 3)); out_string (""); int *save_ptr = packet_ptr; if (f->media_type == CODE_input_media_uploaded_photo) { @@ -2166,12 +2168,14 @@ void tgl_do_send_location(tgl_peer_id_t id, double latitude, double longitude, v out_int (CODE_decrypted_message_l16); } else { out_int (CODE_decrypted_message); + } + out_long (r); + out_random (15 + 4 * (lrand48 () % 3)); + if (P->encr_chat.layer >= 17) { out_int (2 * P->encr_chat.in_seq_no + (P->encr_chat.admin_id != tgl_state.our_id)); out_int (2 * P->encr_chat.out_seq_no + (P->encr_chat.admin_id == tgl_state.our_id) + 2); out_int (0); } - out_long (r); - out_random (15 + 4 * (lrand48 () % 3)); out_string (""); int *save_ptr = packet_ptr; out_int (CODE_decrypted_message_media_geo_point); diff --git a/structures.c b/structures.c index 148ad3e..7c02cb2 100644 --- a/structures.c +++ b/structures.c @@ -1229,6 +1229,9 @@ void tglf_fetch_encrypted_message (struct tgl_message *M) { } assert (x == CODE_decrypted_message || x == CODE_decrypted_message_service || x == CODE_decrypted_message_l16 || x == CODE_decrypted_message_service_l16); //assert (id == fetch_long ()); + fetch_long (); + ll = prefetch_strlen (); + fetch_str (ll); // random_bytes if (x == CODE_decrypted_message || x == CODE_decrypted_message_service) { int out_seq_no = fetch_int (); int in_seq_no = fetch_int (); @@ -1247,9 +1250,6 @@ void tglf_fetch_encrypted_message (struct tgl_message *M) { } else { P->encr_chat.in_seq_no ++; } - fetch_long (); - ll = prefetch_strlen (); - fetch_str (ll); // random_bytes if (x == CODE_decrypted_message || x == CODE_decrypted_message_l16) { l = prefetch_strlen (); s = fetch_str (l);