support for set_ttl query

This commit is contained in:
Vysheng 2014-09-11 15:04:04 +04:00
parent 83be082cec
commit 80d35a2d88
3 changed files with 33 additions and 0 deletions

View File

@ -401,6 +401,7 @@ struct command commands[] = {
{"chat_set_photo", {ca_chat, ca_file_name_end}},
{"set_profile_photo", {ca_file_name_end}},
{"accept_secret_chat", {ca_secret_chat, ca_none}},
{"set_ttl", {ca_secret_chat, ca_number, ca_none}},
{"export_card", {ca_none}},
{"import_card", {ca_string, ca_none}},
{"send_contact", {ca_peer, ca_string, ca_string, ca_string}},
@ -1724,6 +1725,18 @@ void interpreter (char *line UU) {
tgl_peer_t *E = tgl_peer_get (id);
assert (E);
tgl_do_accept_encr_chat_request (&E->encr_chat, 0, 0);
} else if (IS_WORD ("set_ttl")) {
GET_PEER_ENCR_CHAT;
tgl_peer_t *E = tgl_peer_get (id);
assert (E);
long long num = next_token_int ();
if (num == NOT_FOUND) {
printf ("Bad msg id\n");
RET;
}
if (E->encr_chat.state == sc_ok) {
tgl_do_set_encr_chat_ttl (&E->encr_chat, num, 0, 0);
}
} else if (IS_WORD ("safe_quit")) {
safe_quit = 1;
}

View File

@ -805,6 +805,21 @@ void tgl_do_send_encr_chat_layer (struct tgl_secret_chat *E) {
//print_message (M);
}
void tgl_do_set_encr_chat_ttl (struct tgl_secret_chat *E, int ttl, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra) {
long long t;
tglt_secure_random (&t, 8);
int action[2];
action[0] = CODE_decrypted_message_action_set_message_t_t_l;
action[1] = ttl;
bl_do_send_message_action_encr (t, tgl_state.our_id, tgl_get_peer_type (E->id), tgl_get_peer_id (E->id), time (0), 2, action);
struct tgl_message *M = tgl_message_get (t);
assert (M);
assert (M->action.type == tgl_message_action_set_message_ttl);
tgl_do_send_msg (M, callback, callback_extra);
//print_message (M);
}
/* {{{ Seng msg (plain text) */
static int msg_send_encr_on_answer (struct query *q UU) {
assert (fetch_int () == CODE_messages_sent_encrypted_message);
@ -947,6 +962,10 @@ void tgl_do_send_encr_msg_action (struct tgl_message *M, void (*callback)(void *
out_int (CODE_decrypted_message_action_notify_layer);
out_int (M->action.layer);
break;
case tgl_message_action_set_message_ttl:
out_int (CODE_decrypted_message_action_set_message_t_t_l);
out_int (M->action.ttl);
break;
default:
assert (0);
}

1
tgl.h
View File

@ -284,6 +284,7 @@ void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_ex
void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
void tgl_do_del_contact (tgl_peer_id_t id, void (*callback)(void *callback_extra, int success), void *callback_extra);
void tgl_do_set_encr_chat_ttl (struct tgl_secret_chat *E, int ttl, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra);
void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]);