Commit d3780ebe authored by vysheng's avatar vysheng

Mant fixes. Sometimes work now

parent 8dd17ec6
...@@ -62,7 +62,7 @@ ${EXE}/generate: ${GENERATE_OBJECTS} ${COMMON_OBJECTS} ...@@ -62,7 +62,7 @@ ${EXE}/generate: ${GENERATE_OBJECTS} ${COMMON_OBJECTS}
${AUTO}/scheme.tlo: ${AUTO}/scheme.tl ${EXE}/tlc ${AUTO}/scheme.tlo: ${AUTO}/scheme.tl ${EXE}/tlc
${EXE}/tlc -e $@ ${AUTO}/scheme.tl ${EXE}/tlc -e $@ ${AUTO}/scheme.tl
${AUTO}/scheme.tl: ${srcdir}/scheme.tl ${srcdir}/binlog.tl ${AUTO}/scheme.tl: ${srcdir}/scheme.tl ${srcdir}/binlog.tl ${srcdir}/append.tl
cat $^ > $@ cat $^ > $@
${AUTO}/scheme2.tl: ${AUTO}/scheme.tl ${EXE}/tlc ${AUTO}/scheme2.tl: ${AUTO}/scheme.tl ${EXE}/tlc
......
decryptedMessageMediaVideoL12#4cee6ef3 thumb:bytes thumb_w:int thumb_h:int duration:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaAudioL12#6080758f duration:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
...@@ -159,7 +159,7 @@ int fetch_comb_binlog_set_pts (void *extra) { ...@@ -159,7 +159,7 @@ int fetch_comb_binlog_set_pts (void *extra) {
int fetch_comb_binlog_set_qts (void *extra) { int fetch_comb_binlog_set_qts (void *extra) {
int new_qts = fetch_int (); int new_qts = fetch_int ();
assert (new_qts >= qts); //assert (new_qts >= qts);
qts = new_qts; qts = new_qts;
return 0; return 0;
} }
...@@ -468,8 +468,8 @@ int fetch_comb_binlog_encr_chat_accepted (void *extra) { ...@@ -468,8 +468,8 @@ int fetch_comb_binlog_encr_chat_accepted (void *extra) {
U->nonce = talloc (256); U->nonce = talloc (256);
} }
fetch_ints (U->g_key, 256); fetch_ints (U->g_key, 64);
fetch_ints (U->nonce, 256); fetch_ints (U->nonce, 64);
U->key_fingerprint = fetch_long (); U->key_fingerprint = fetch_long ();
if (U->state == sc_waiting) { if (U->state == sc_waiting) {
...@@ -509,6 +509,7 @@ int fetch_comb_binlog_encr_chat_init (void *extra) { ...@@ -509,6 +509,7 @@ int fetch_comb_binlog_encr_chat_init (void *extra) {
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);
P->encr_chat.g_key = talloc (256);
fetch_ints (P->encr_chat.key, 64); fetch_ints (P->encr_chat.key, 64);
fetch_ints (P->encr_chat.g_key, 64); fetch_ints (P->encr_chat.g_key, 64);
P->flags |= FLAG_CREATED; P->flags |= FLAG_CREATED;
...@@ -810,6 +811,43 @@ int fetch_comb_binlog_send_message_text (void *extra) { ...@@ -810,6 +811,43 @@ int fetch_comb_binlog_send_message_text (void *extra) {
return 0; return 0;
} }
int fetch_comb_binlog_send_message_action_encr (void *extra) {
long long id = fetch_long ();
struct message *M = message_get (id);
if (!M) {
M = talloc0 (sizeof (*M));
M->id = id;
message_insert_tree (M);
messages_allocated ++;
} else {
assert (!(M->flags & FLAG_CREATED));
}
M->flags |= FLAG_CREATED | FLAG_ENCRYPTED;
M->from_id = MK_USER (fetch_int ());
int t = fetch_int ();
M->to_id = set_peer_id (t, fetch_int ());
M->date = fetch_int ();
M->media.type = CODE_decrypted_message_media_empty;
fetch_message_action_encrypted ((void *)user_chat_get (M->to_id), &M->action);
M->unread = 1;
M->out = get_peer_id (M->from_id) == our_id;
M->service = 1;
message_insert (M);
message_insert_unsent (M);
M->flags |= FLAG_PENDING;
#ifdef USE_LUA
lua_new_msg (M);
#endif
return 0;
}
int fetch_comb_binlog_create_message_text_fwd (void *extra) { int fetch_comb_binlog_create_message_text_fwd (void *extra) {
long long id = fetch_int (); long long id = fetch_int ();
...@@ -894,7 +932,7 @@ int fetch_comb_binlog_create_message_media (void *extra) { ...@@ -894,7 +932,7 @@ int fetch_comb_binlog_create_message_media (void *extra) {
} }
int fetch_comb_binlog_create_message_media_encr (void *extra) { int fetch_comb_binlog_create_message_media_encr (void *extra) {
int id = fetch_int (); long long id = fetch_long ();
struct message *M = message_get (id); struct message *M = message_get (id);
if (!M) { if (!M) {
M = talloc0 (sizeof (*M)); M = talloc0 (sizeof (*M));
...@@ -995,7 +1033,7 @@ int fetch_comb_binlog_create_message_service (void *extra) { ...@@ -995,7 +1033,7 @@ int fetch_comb_binlog_create_message_service (void *extra) {
} }
int fetch_comb_binlog_create_message_service_encr (void *extra) { int fetch_comb_binlog_create_message_service_encr (void *extra) {
int id = fetch_int (); long long id = fetch_long ();
struct message *M = message_get (id); struct message *M = message_get (id);
if (!M) { if (!M) {
M = talloc0 (sizeof (*M)); M = talloc0 (sizeof (*M));
...@@ -1008,10 +1046,14 @@ int fetch_comb_binlog_create_message_service_encr (void *extra) { ...@@ -1008,10 +1046,14 @@ int fetch_comb_binlog_create_message_service_encr (void *extra) {
M->flags |= FLAG_CREATED | FLAG_ENCRYPTED; M->flags |= FLAG_CREATED | FLAG_ENCRYPTED;
M->from_id = MK_USER (fetch_int ()); M->from_id = MK_USER (fetch_int ());
int t = fetch_int (); int t = fetch_int ();
assert (t == PEER_ENCR_CHAT);
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 ();
fetch_message_action_encrypted (&M->action); struct secret_chat *E = (void *)user_chat_get (M->to_id);
assert (E);
fetch_message_action_encrypted (0, &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;
M->service = 1; M->service = 1;
...@@ -1187,6 +1229,7 @@ void replay_log_event (void) { ...@@ -1187,6 +1229,7 @@ void replay_log_event (void) {
FETCH_COMBINATOR_FUNCTION (binlog_create_message_text) FETCH_COMBINATOR_FUNCTION (binlog_create_message_text)
FETCH_COMBINATOR_FUNCTION (binlog_send_message_text) FETCH_COMBINATOR_FUNCTION (binlog_send_message_text)
FETCH_COMBINATOR_FUNCTION (binlog_send_message_action_encr)
FETCH_COMBINATOR_FUNCTION (binlog_create_message_text_fwd) FETCH_COMBINATOR_FUNCTION (binlog_create_message_text_fwd)
FETCH_COMBINATOR_FUNCTION (binlog_create_message_media) FETCH_COMBINATOR_FUNCTION (binlog_create_message_media)
FETCH_COMBINATOR_FUNCTION (binlog_create_message_media_encr) FETCH_COMBINATOR_FUNCTION (binlog_create_message_media_encr)
...@@ -1775,6 +1818,18 @@ void bl_do_send_message_text (long long msg_id, int from_id, int to_type, int to ...@@ -1775,6 +1818,18 @@ void bl_do_send_message_text (long long msg_id, int from_id, int to_type, int to
add_log_event (packet_buffer, 4 * (packet_ptr - packet_buffer)); add_log_event (packet_buffer, 4 * (packet_ptr - packet_buffer));
} }
void bl_do_send_message_action_encr (long long msg_id, int from_id, int to_type, int to_id, int date, int l, const int *action) {
clear_packet ();
out_int (CODE_binlog_send_message_action_encr);
out_long (msg_id);
out_int (from_id);
out_int (to_type);
out_int (to_id);
out_int (date);
out_ints (action, l);
add_log_event (packet_buffer, 4 * (packet_ptr - packet_buffer));
}
void bl_do_create_message_text_fwd (int msg_id, int from_id, int to_type, int to_id, int date, int fwd, int fwd_date, int l, const char *s) { void bl_do_create_message_text_fwd (int msg_id, int from_id, int to_type, int to_id, int date, int fwd, int fwd_date, int l, const char *s) {
clear_packet (); clear_packet ();
out_int (CODE_binlog_create_message_text_fwd); out_int (CODE_binlog_create_message_text_fwd);
...@@ -1842,6 +1897,7 @@ void bl_do_create_message_service (int msg_id, int from_id, int to_type, int to_ ...@@ -1842,6 +1897,7 @@ void bl_do_create_message_service (int msg_id, int from_id, int to_type, int to_
out_ints (data, len); out_ints (data, len);
add_log_event (packet_buffer, 4 * (packet_ptr - packet_buffer)); add_log_event (packet_buffer, 4 * (packet_ptr - packet_buffer));
} }
void bl_do_create_message_service_encr (long long msg_id, int from_id, int to_type, int to_id, int date, const int *data, int len) { void bl_do_create_message_service_encr (long long msg_id, int from_id, int to_type, int to_id, int date, const int *data, int len) {
clear_packet (); clear_packet ();
out_int (CODE_binlog_create_message_service_encr); out_int (CODE_binlog_create_message_service_encr);
......
...@@ -81,6 +81,7 @@ void bl_do_create_message_media_fwd (int msg_id, int from_id, int to_type, int t ...@@ -81,6 +81,7 @@ void bl_do_create_message_media_fwd (int msg_id, int from_id, int to_type, int t
void bl_do_create_message_media_encr (long long msg_id, int from_id, int to_type, int to_id, int date, int l, const char *s, const int *data, int len, const int *data2, int len2); void bl_do_create_message_media_encr (long long msg_id, int from_id, int to_type, int to_id, int date, int l, const char *s, const int *data, int len, const int *data2, int len2);
void bl_do_create_message_service_encr (long long msg_id, int from_id, int to_type, int to_id, int date, const int *data, int len); void bl_do_create_message_service_encr (long long msg_id, int from_id, int to_type, int to_id, int date, const int *data, int len);
void bl_do_send_message_text (long long msg_id, int from_id, int to_type, int to_id, int date, int l, const char *s); void bl_do_send_message_text (long long msg_id, int from_id, int to_type, int to_id, int date, int l, const char *s);
void bl_do_send_message_action_encr (long long msg_id, int from_id, int to_type, int to_id, int date, int l, const int *s);
void bl_do_set_unread (struct message *M, int unread); void bl_do_set_unread (struct message *M, int unread);
void bl_do_set_message_sent (struct message *M); void bl_do_set_message_sent (struct message *M);
void bl_do_set_msg_id (struct message *M, int id); void bl_do_set_msg_id (struct message *M, int id);
......
...@@ -52,12 +52,13 @@ binlog.chatDelParticipant id:int version:int user:int = binlog.Update; ...@@ -52,12 +52,13 @@ binlog.chatDelParticipant id:int version:int user:int = binlog.Update;
binlog.createMessageText id:int from_id:int to_type:int to_id:int date:int text:string = binlog.Update; binlog.createMessageText id:int from_id:int to_type:int to_id:int date:int text:string = binlog.Update;
binlog.sendMessageText id:long from_id:int to_type:int to_id:int date:int text:string = binlog.Update; binlog.sendMessageText id:long from_id:int to_type:int to_id:int date:int text:string = binlog.Update;
binlog.sendMessageActionEncr id:long from_id:int to_type:int to_id:int date:int action:DecryptedMessageAction = binlog.Update;
binlog.createMessageTextFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string = binlog.Update; binlog.createMessageTextFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string = binlog.Update;
binlog.createMessageMedia id:int from_id:int to_type:int to_id:int date:int text:string media:MessageMedia = binlog.Update; binlog.createMessageMedia id:int from_id:int to_type:int to_id:int date:int text:string media:MessageMedia = binlog.Update;
binlog.createMessageMediaEncr id:int from_id:int to_type:int to_id:int date:int text:string media:DecryptedMessageMedia file:EncryptedFile = binlog.Update; binlog.createMessageMediaEncr id:long from_id:int to_type:int to_id:int date:int text:string media:DecryptedMessageMedia file:EncryptedFile = binlog.Update;
binlog.createMessageMediaFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string media:MessageMedia = binlog.Update; binlog.createMessageMediaFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string media:MessageMedia = binlog.Update;
binlog.createMessageService id:int from_id:int to_type:int to_id:int date:int action:MessageAction = binlog.Update; binlog.createMessageService id:int from_id:int to_type:int to_id:int date:int action:MessageAction = binlog.Update;
binlog.createMessageServiceEncr id:int from_id:int to_type:int to_id:int date:int action:DecryptedMessageAction = binlog.Update; binlog.createMessageServiceEncr id:long from_id:int to_type:int to_id:int date:int action:DecryptedMessageAction = binlog.Update;
binlog.createMessageServiceFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int action:MessageAction = binlog.Update; binlog.createMessageServiceFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int action:MessageAction = binlog.Update;
binlog.messageSetUnread id:int = binlog.Update; binlog.messageSetUnread id:int = binlog.Update;
binlog.setMessageSent id:long = binlog.Update; binlog.setMessageSent id:long = binlog.Update;
......
...@@ -77,6 +77,20 @@ int is_same_word (const char *s, size_t l, const char *word) { ...@@ -77,6 +77,20 @@ int is_same_word (const char *s, size_t l, const char *word) {
return s && word && strlen (word) == l && !memcmp (s, word, l); return s && word && strlen (word) == l && !memcmp (s, word, l);
} }
char *end_string_token (int *l) {
while (*line_ptr == ' ') { line_ptr ++; }
if (!*line_ptr) {
*l = 0;
return 0;
}
char *s = line_ptr;
while (*line_ptr) { line_ptr ++; }
while (*line_ptr == ' ' || !*line_ptr) { line_ptr --; }
line_ptr ++;
*l = line_ptr - s;
return s;
}
char *next_token (int *l) { char *next_token (int *l) {
while (*line_ptr == ' ') { line_ptr ++; } while (*line_ptr == ' ') { line_ptr ++; }
if (!*line_ptr) { if (!*line_ptr) {
...@@ -683,7 +697,7 @@ void interpreter (char *line UU) { ...@@ -683,7 +697,7 @@ void interpreter (char *line UU) {
} else if (IS_WORD ("send_photo")) { } else if (IS_WORD ("send_photo")) {
GET_PEER; GET_PEER;
int t; int t;
char *s = next_token (&t); char *s = end_string_token (&t);
if (!s) { if (!s) {
printf ("Empty file name\n"); printf ("Empty file name\n");
RET; RET;
...@@ -692,7 +706,7 @@ void interpreter (char *line UU) { ...@@ -692,7 +706,7 @@ void interpreter (char *line UU) {
} else if (IS_WORD("send_video")) { } else if (IS_WORD("send_video")) {
GET_PEER; GET_PEER;
int t; int t;
char *s = next_token (&t); char *s = end_string_token (&t);
if (!s) { if (!s) {
printf ("Empty file name\n"); printf ("Empty file name\n");
RET; RET;
...@@ -969,7 +983,7 @@ void interpreter (char *line UU) { ...@@ -969,7 +983,7 @@ void interpreter (char *line UU) {
} else if (IS_WORD("send_audio")) { } else if (IS_WORD("send_audio")) {
GET_PEER; GET_PEER;
int t; int t;
char *s = next_token (&t); char *s = end_string_token (&t);
if (!s) { if (!s) {
printf ("Empty file name\n"); printf ("Empty file name\n");
RET; RET;
...@@ -978,7 +992,7 @@ void interpreter (char *line UU) { ...@@ -978,7 +992,7 @@ void interpreter (char *line UU) {
} else if (IS_WORD("send_document")) { } else if (IS_WORD("send_document")) {
GET_PEER; GET_PEER;
int t; int t;
char *s = next_token (&t); char *s = end_string_token (&t);
if (!s) { if (!s) {
printf ("Empty file name\n"); printf ("Empty file name\n");
RET; RET;
...@@ -1236,10 +1250,18 @@ void print_media (struct message_media *M) { ...@@ -1236,10 +1250,18 @@ void print_media (struct message_media *M) {
} }
return; return;
case CODE_message_media_video: case CODE_message_media_video:
if (M->video.mime_type) {
printf ("[video: type %s]", M->video.mime_type);
} else {
printf ("[video]"); printf ("[video]");
}
return; return;
case CODE_message_media_audio: case CODE_message_media_audio:
if (M->audio.mime_type) {
printf ("[audio: type %s]", M->audio.mime_type);
} else {
printf ("[audio]"); printf ("[audio]");
}
return; return;
case CODE_message_media_document: case CODE_message_media_document:
if (M->document.mime_type && M->document.caption) { if (M->document.mime_type && M->document.caption) {
...@@ -1252,9 +1274,11 @@ void print_media (struct message_media *M) { ...@@ -1252,9 +1274,11 @@ void print_media (struct message_media *M) {
printf ("[photo]"); printf ("[photo]");
return; return;
case CODE_decrypted_message_media_video: case CODE_decrypted_message_media_video:
case CODE_decrypted_message_media_video_l12:
printf ("[video]"); printf ("[video]");
return; return;
case CODE_decrypted_message_media_audio: case CODE_decrypted_message_media_audio:
case CODE_decrypted_message_media_audio_l12:
printf ("[audio]"); printf ("[audio]");
return; return;
case CODE_decrypted_message_media_document: case CODE_decrypted_message_media_document:
...@@ -1427,6 +1451,21 @@ void print_service_message (struct message *M) { ...@@ -1427,6 +1451,21 @@ void print_service_message (struct message *M) {
case CODE_decrypted_message_action_set_message_t_t_l: case CODE_decrypted_message_action_set_message_t_t_l:
printf (" set ttl to %d seconds. Unsupported yet\n", M->action.ttl); printf (" set ttl to %d seconds. Unsupported yet\n", M->action.ttl);
break; break;
case CODE_decrypted_message_action_read_messages:
printf (" %d messages marked read\n", M->action.read_cnt);
break;
case CODE_decrypted_message_action_delete_messages:
printf (" %d messages deleted\n", M->action.delete_cnt);
break;
case CODE_decrypted_message_action_screenshot_messages:
printf (" %d messages screenshoted\n", M->action.screenshot_cnt);
break;
case CODE_decrypted_message_action_flush_history:
printf (" cleared history\n");
break;
case CODE_decrypted_message_action_notify_layer:
printf (" updated layer to %d\n", M->action.layer);
break;
default: default:
assert (0); assert (0);
} }
......
...@@ -1281,6 +1281,9 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1281,6 +1281,9 @@ void work_update (struct connection *c UU, long long msg_id UU) {
if (E->state == sc_request && !disable_auto_accept) { if (E->state == sc_request && !disable_auto_accept) {
do_accept_encr_chat_request (E); do_accept_encr_chat_request (E);
} }
if (E->state == sc_ok) {
do_send_encr_chat_layer (E);
}
fetch_int (); // date fetch_int (); // date
} }
break; break;
...@@ -1395,6 +1398,22 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1395,6 +1398,22 @@ void work_update (struct connection *c UU, long long msg_id UU) {
} }
} }
break; break;
case CODE_update_user_blocked:
{
int id = fetch_int ();
int blocked = fetch_bool ();
peer_t *P = user_chat_get (MK_USER (id));
if (P && (P->flags & FLAG_CREATED)) {
bl_do_user_set_blocked (&P->user, blocked);
}
}
break;
case CODE_update_notify_settings:
{
assert (skip_type_any (TYPE_TO_PARAM (notify_peer)) >= 0);
assert (skip_type_any (TYPE_TO_PARAM (peer_notify_settings)) >= 0);
}
break;
default: default:
logprintf ("Unknown update type %08x\n", op); logprintf ("Unknown update type %08x\n", op);
; ;
......
...@@ -320,7 +320,7 @@ void out_random (int n) { ...@@ -320,7 +320,7 @@ void out_random (int n) {
int allow_send_linux_version; int allow_send_linux_version;
void do_insert_header (void) { void do_insert_header (void) {
out_int (CODE_invoke_with_layer12); out_int (CODE_invoke_with_layer15);
out_int (CODE_init_connection); out_int (CODE_init_connection);
out_int (TG_APP_ID); out_int (TG_APP_ID);
if (allow_send_linux_version) { if (allow_send_linux_version) {
...@@ -840,6 +840,20 @@ void encr_finish (struct secret_chat *E) { ...@@ -840,6 +840,20 @@ void encr_finish (struct secret_chat *E) {
} }
/* }}} */ /* }}} */
void do_send_encr_chat_layer (struct secret_chat *E) {
long long t;
secure_random (&t, 8);
int action[2];
action[0] = CODE_decrypted_message_action_notify_layer;
action[1] = 15;
bl_do_send_message_action_encr (t, our_id, get_peer_type (E->id), get_peer_id (E->id), time (0), 2, action);
struct message *M = message_get (t);
assert (M);
do_send_msg (M);
print_message (M);
}
/* {{{ Seng msg (plain text) */ /* {{{ Seng msg (plain text) */
int msg_send_encr_on_answer (struct query *q UU) { int msg_send_encr_on_answer (struct query *q UU) {
assert (fetch_int () == CODE_messages_sent_encrypted_message); assert (fetch_int () == CODE_messages_sent_encrypted_message);
...@@ -925,7 +939,41 @@ struct query_methods msg_send_encr_methods = { ...@@ -925,7 +939,41 @@ struct query_methods msg_send_encr_methods = {
int out_message_num; int out_message_num;
int our_id; int our_id;
void do_send_encr_msg_action (struct message *M) {
peer_t *P = user_chat_get (M->to_id);
if (!P || P->encr_chat.state != sc_ok) { return; }
clear_packet ();
out_int (CODE_messages_send_encrypted_service);
out_int (CODE_input_encrypted_chat);
out_int (get_peer_id (M->to_id));
out_long (P->encr_chat.access_hash);
out_long (M->id);
encr_start ();
out_int (CODE_decrypted_message_service);
out_long (M->id);
static int buf[4];
secure_random (buf, 16);
out_cstring ((void *)buf, 16);
switch (M->action.type) {
case CODE_decrypted_message_action_notify_layer:
out_int (M->action.type);
out_int (M->action.layer);
break;
default:
assert (0);
}
encr_finish (&P->encr_chat);
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &msg_send_encr_methods, M);
}
void do_send_encr_msg (struct message *M) { void do_send_encr_msg (struct message *M) {
if (M->service) {
do_send_encr_msg_action (M);
return;
}
peer_t *P = user_chat_get (M->to_id); peer_t *P = user_chat_get (M->to_id);
if (!P || P->encr_chat.state != sc_ok) { return; } if (!P || P->encr_chat.state != sc_ok) { return; }
...@@ -1167,7 +1215,7 @@ int get_dialogs_on_answer (struct query *q UU) { ...@@ -1167,7 +1215,7 @@ int get_dialogs_on_answer (struct query *q UU) {
static peer_id_t plist[100]; static peer_id_t plist[100];
int dl_size = n; int dl_size = n;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
assert (fetch_int () == CODE_dialog); assert (fetch_int () == (int)CODE_dialog);
if (i < 100) { if (i < 100) {
plist[i] = fetch_peer_id (); plist[i] = fetch_peer_id ();
dlist[2 * i + 0] = fetch_int (); dlist[2 * i + 0] = fetch_int ();
...@@ -1177,6 +1225,7 @@ int get_dialogs_on_answer (struct query *q UU) { ...@@ -1177,6 +1225,7 @@ int get_dialogs_on_answer (struct query *q UU) {
fetch_int (); fetch_int ();
fetch_int (); fetch_int ();
} }
assert (skip_type_any (TYPE_TO_PARAM (peer_notify_settings)) >= 0);
} }
assert (fetch_int () == CODE_vector); assert (fetch_int () == CODE_vector);
n = fetch_int (); n = fetch_int ();
...@@ -1419,6 +1468,7 @@ void send_part (struct send_file *f) { ...@@ -1419,6 +1468,7 @@ void send_part (struct send_file *f) {
out_int (100); out_int (100);
out_int (100); out_int (100);
out_int (100); out_int (100);
out_string ("video");
} }
if (f->media_type == CODE_input_media_uploaded_document || f->media_type == CODE_input_media_uploaded_thumb_document) { if (f->media_type == CODE_input_media_uploaded_document || f->media_type == CODE_input_media_uploaded_thumb_document) {
out_string (s + 1); out_string (s + 1);
...@@ -1426,6 +1476,7 @@ void send_part (struct send_file *f) { ...@@ -1426,6 +1476,7 @@ void send_part (struct send_file *f) {
} }
if (f->media_type == CODE_input_media_uploaded_audio) { if (f->media_type == CODE_input_media_uploaded_audio) {
out_int (60); out_int (60);
out_string ("audio");
} }
out_long (-lrand48 () * (1ll << 32) - lrand48 ()); out_long (-lrand48 () * (1ll << 32) - lrand48 ());
...@@ -1468,6 +1519,7 @@ void send_part (struct send_file *f) { ...@@ -1468,6 +1519,7 @@ void send_part (struct send_file *f) {
} }
if (f->media_type == CODE_input_media_uploaded_video) { if (f->media_type == CODE_input_media_uploaded_video) {
out_int (0); out_int (0);
out_string ("video");
} }
if (f->media_type == CODE_input_media_uploaded_document) { if (f->media_type == CODE_input_media_uploaded_document) {
out_string (f->file_name); out_string (f->file_name);
...@@ -1475,6 +1527,7 @@ void send_part (struct send_file *f) { ...@@ -1475,6 +1527,7 @@ void send_part (struct send_file *f) {
} }
if (f->media_type == CODE_input_media_uploaded_audio) { if (f->media_type == CODE_input_media_uploaded_audio) {
out_int (60); out_int (60);
out_string ("audio");
} }
if (f->media_type == CODE_input_media_uploaded_video || f->media_type == CODE_input_media_uploaded_photo) { if (f->media_type == CODE_input_media_uploaded_video || f->media_type == CODE_input_media_uploaded_photo) {
out_int (100); out_int (100);
...@@ -1584,7 +1637,7 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) { ...@@ -1584,7 +1637,7 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
f->key = talloc (32); f->key = talloc (32);
secure_random (f->key, 32); secure_random (f->key, 32);
} }
if (f->media_type == CODE_input_media_uploaded_video && !f->encr) { /*if (f->media_type == CODE_input_media_uploaded_video && !f->encr) {
f->media_type = CODE_input_media_uploaded_thumb_video; f->media_type = CODE_input_media_uploaded_thumb_video;
send_file_thumb (f); send_file_thumb (f);
} else if (f->media_type == CODE_input_media_uploaded_document && !f->encr) { } else if (f->media_type == CODE_input_media_uploaded_document && !f->encr) {
...@@ -1592,7 +1645,8 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) { ...@@ -1592,7 +1645,8 @@ void do_send_photo (int type, peer_id_t to_id, char *file_name) {
send_file_thumb (f); send_file_thumb (f);
} else { } else {
send_part (f); send_part (f);
} }*/
send_part (f);
} }
/* }}} */ /* }}} */
...@@ -2161,6 +2215,12 @@ int add_contact_on_answer (struct query *q UU) { ...@@ -2161,6 +2215,12 @@ int add_contact_on_answer (struct query *q UU) {
} }
assert (fetch_int () == CODE_vector); assert (fetch_int () == CODE_vector);
n = fetch_int (); n = fetch_int ();
for (i = 0; i < n; i++) {
long long id = fetch_long ();
logprintf ("contact #%lld not added. Please retry\n", id);
}
assert (fetch_int () == CODE_vector);
n = fetch_int ();
for (i = 0; i < n ; i++) { for (i = 0; i < n ; i++) {
struct user *U = fetch_alloc_user (); struct user *U = fetch_alloc_user ();
print_start (); print_start ();
......
...@@ -117,6 +117,7 @@ void do_contacts_search (int limit, const char *s); ...@@ -117,6 +117,7 @@ void do_contacts_search (int limit, const char *s);
void do_send_msg (struct message *M); void do_send_msg (struct message *M);
void do_delete_msg (long long id); void do_delete_msg (long long id);
void do_restore_msg (long long id); void do_restore_msg (long long id);
void do_send_encr_chat_layer (struct secret_chat *E);
// For binlog // For binlog
......
scheme12.tl scheme15.tl
\ No newline at end of file \ No newline at end of file
...@@ -557,6 +557,7 @@ void fetch_video (struct video *V) { ...@@ -557,6 +557,7 @@ void fetch_video (struct video *V) {
V->date = fetch_int (); V->date = fetch_int ();
V->caption = fetch_str_dup (); V->caption = fetch_str_dup ();
V->duration = fetch_int (); V->duration = fetch_int ();
V->mime_type = fetch_str_dup ();
V->size = fetch_int (); V->size = fetch_int ();
fetch_photo_size (&V->thumb); fetch_photo_size (&V->thumb);
V->dc_id = fetch_int (); V->dc_id = fetch_int ();
...@@ -573,6 +574,7 @@ void fetch_audio (struct audio *V) { ...@@ -573,6 +574,7 @@ void fetch_audio (struct audio *V) {
V->user_id = fetch_int (); V->user_id = fetch_int ();
V->date = fetch_int (); V->date = fetch_int ();
V->duration = fetch_int (); V->duration = fetch_int ();
V->mime_type = fetch_str_dup ();
V->size = fetch_int (); V->size = fetch_int ();
V->dc_id = fetch_int (); V->dc_id = fetch_int ();
} }
...@@ -770,12 +772,16 @@ void fetch_message_media_encrypted (struct message_media *M) { ...@@ -770,12 +772,16 @@ void fetch_message_media_encrypted (struct message_media *M) {
} }
break; break;
case CODE_decrypted_message_media_video: case CODE_decrypted_message_media_video:
M->type = x; case CODE_decrypted_message_media_video_l12:
M->type = CODE_decrypted_message_media_video;
l = prefetch_strlen (); l = prefetch_strlen ();
fetch_str (l); // thumb fetch_str (l); // thumb
fetch_int (); // thumb_w fetch_int (); // thumb_w
fetch_int (); // thumb_h fetch_int (); // thumb_h
M->encr_video.duration = fetch_int (); M->encr_video.duration = fetch_int ();
if (x == CODE_decrypted_message_media_video) {
M->encr_video.mime_type = fetch_str_dup ();
}
M->encr_video.w = fetch_int (); M->encr_video.w = fetch_int ();
M->encr_video.h = fetch_int (); M->encr_video.h = fetch_int ();
M->encr_video.size = fetch_int (); M->encr_video.size = fetch_int ();
...@@ -799,8 +805,12 @@ void fetch_message_media_encrypted (struct message_media *M) { ...@@ -799,8 +805,12 @@ void fetch_message_media_encrypted (struct message_media *M) {
} }
break; break;
case CODE_decrypted_message_media_audio: case CODE_decrypted_message_media_audio:
M->type = x; case CODE_decrypted_message_media_audio_l12:
M->type = CODE_decrypted_message_media_audio;
M->encr_audio.duration = fetch_int (); M->encr_audio.duration = fetch_int ();
if (x == CODE_decrypted_message_media_audio) {
M->encr_audio.mime_type = fetch_str_dup ();
}
M->encr_audio.size = fetch_int (); M->encr_audio.size = fetch_int ();
l = prefetch_strlen (); l = prefetch_strlen ();
...@@ -881,13 +891,60 @@ void fetch_message_media_encrypted (struct message_media *M) { ...@@ -881,13 +891,60 @@ void fetch_message_media_encrypted (struct message_media *M) {
} }
} }
void fetch_message_action_encrypted (struct message_action *M) { void fetch_message_action_encrypted (struct secret_chat *E, struct message_action *M) {
unsigned x = fetch_int (); unsigned x = fetch_int ();
switch (x) { switch (x) {
case CODE_decrypted_message_action_set_message_t_t_l: case CODE_decrypted_message_action_set_message_t_t_l:
M->type = x; M->type = x;
M->ttl = fetch_int (); M->ttl = fetch_int ();
break; break;
case CODE_decrypted_message_action_read_messages:
M->type = x;
{
assert (fetch_int () == CODE_vector);
int n = fetch_int ();
M->read_cnt = n;
while (n -- > 0) {
long long id = fetch_long ();
struct message *N = message_get (id);
if (N) {
N->unread = 0;
}
}
}
break;
case CODE_decrypted_message_action_delete_messages:
M->type = x;
{
assert (fetch_int () == CODE_vector);
int n = fetch_int ();
M->delete_cnt = n;
while (n -- > 0) {
fetch_long ();
}
}
break;
case CODE_decrypted_message_action_screenshot_messages:
M->type = x;
{
assert (fetch_int () == CODE_vector);
int n = fetch_int ();
M->screenshot_cnt = n;
while (n -- > 0) {
fetch_long ();
}
}
break;
case CODE_decrypted_message_action_notify_layer:
M->type = x;
M->layer = fetch_int ();
//if (M->from_id != our_id) {
// E->layer = M->layer;
//}
break;
case CODE_decrypted_message_action_flush_history:
M->type = x;
break;
default: default:
logprintf ("x = 0x%08x\n", x); logprintf ("x = 0x%08x\n", x);
assert (0); assert (0);
...@@ -1106,6 +1163,10 @@ void fetch_encrypted_message (struct message *M) { ...@@ -1106,6 +1163,10 @@ void fetch_encrypted_message (struct message *M) {
} }
in_ptr = save_in_ptr; in_ptr = save_in_ptr;
in_end = save_in_end; in_end = save_in_end;
} else {
if (P && new) {
assert (0);
}
} }
if (sx == CODE_encrypted_message) { if (sx == CODE_encrypted_message) {
...@@ -1114,14 +1175,11 @@ void fetch_encrypted_message (struct message *M) { ...@@ -1114,14 +1175,11 @@ void fetch_encrypted_message (struct message *M) {
assert (skip_type_any (TYPE_TO_PARAM (encrypted_file)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (encrypted_file)) >= 0);
if (x == CODE_decrypted_message) { if (x == CODE_decrypted_message) {
bl_do_create_message_media_encr (id, P->encr_chat.user_id, PEER_ENCR_CHAT, to_id, date, l, s, start, end - start, start_file, in_ptr - start_file); bl_do_create_message_media_encr (id, P->encr_chat.user_id, PEER_ENCR_CHAT, to_id, date, l, s, start, end - start, start_file, in_ptr - start_file);
} else if (x == CODE_decrypted_message_service) {
bl_do_create_message_service_encr (id, P->encr_chat.user_id, PEER_ENCR_CHAT, to_id, date, start, end - start);
} }
} else { } else {
x = fetch_int (); assert (skip_type_any (TYPE_TO_PARAM (encrypted_file)) >= 0);
if (x == CODE_encrypted_file) {
fetch_skip (7);
} else {
assert (x == CODE_encrypted_file_empty);
}
M->media.type = CODE_message_media_empty; M->media.type = CODE_message_media_empty;
} }
} else { } else {
...@@ -1480,7 +1538,6 @@ struct message *fetch_alloc_encrypted_message (void) { ...@@ -1480,7 +1538,6 @@ struct message *fetch_alloc_encrypted_message (void) {
message_insert_tree (M); message_insert_tree (M);
messages_allocated ++; messages_allocated ++;
assert (message_get (M->id) == M); assert (message_get (M->id) == M);
logprintf ("id = %lld\n", M->id);
} }
fetch_encrypted_message (M); fetch_encrypted_message (M);
return M; return M;
......
...@@ -98,6 +98,7 @@ struct encr_video { ...@@ -98,6 +98,7 @@ struct encr_video {
int w; int w;
int h; int h;
int duration; int duration;
char *mime_type;
}; };
struct encr_audio { struct encr_audio {
...@@ -110,6 +111,7 @@ struct encr_audio { ...@@ -110,6 +111,7 @@ struct encr_audio {
unsigned char *key; unsigned char *key;
unsigned char *iv; unsigned char *iv;
int duration; int duration;
char *mime_type;
}; };
struct encr_document { struct encr_document {
...@@ -203,6 +205,7 @@ struct secret_chat { ...@@ -203,6 +205,7 @@ struct secret_chat {
int admin_id; int admin_id;
int date; int date;
int ttl; int ttl;
int layer;
long long access_hash; long long access_hash;
unsigned char *g_key; unsigned char *g_key;
unsigned char *nonce; unsigned char *nonce;
...@@ -240,6 +243,7 @@ struct video { ...@@ -240,6 +243,7 @@ struct video {
int duration; int duration;
int w; int w;
int h; int h;
char *mime_type;
}; };
struct audio { struct audio {
...@@ -250,6 +254,7 @@ struct audio { ...@@ -250,6 +254,7 @@ struct audio {
int size; int size;
int dc_id; int dc_id;
int duration; int duration;
char *mime_type;
}; };
struct document { struct document {
...@@ -276,6 +281,10 @@ struct message_action { ...@@ -276,6 +281,10 @@ struct message_action {
struct photo photo; struct photo photo;
int user; int user;
int ttl; int ttl;
int layer;
int read_cnt;
int delete_cnt;
int screenshot_cnt;
}; };
}; };
...@@ -344,7 +353,7 @@ struct message *fetch_alloc_encrypted_message (void); ...@@ -344,7 +353,7 @@ struct message *fetch_alloc_encrypted_message (void);
void fetch_encrypted_message_file (struct message_media *M); void fetch_encrypted_message_file (struct message_media *M);
void fetch_skip_encrypted_message_file (void); void fetch_skip_encrypted_message_file (void);
void fetch_encrypted_message_file (struct message_media *M); void fetch_encrypted_message_file (struct message_media *M);
void fetch_message_action_encrypted (struct message_action *M); void fetch_message_action_encrypted (struct secret_chat *E, struct message_action *M);
peer_id_t fetch_peer_id (void); peer_id_t fetch_peer_id (void);
void fetch_message_media (struct message_media *M); void fetch_message_media (struct message_media *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