From 2961f108ec156d0dfc6c071b8cafbe955d41241b Mon Sep 17 00:00:00 2001 From: Vysheng Date: Fri, 25 Oct 2013 02:32:13 +0400 Subject: [PATCH] Ask dialog list at start. Try resend query on timeout --- loop.c | 2 ++ queries.c | 13 ++++++++++++- queries.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/loop.c b/loop.c index 5bde497..1f3fd0c 100644 --- a/loop.c +++ b/loop.c @@ -254,6 +254,8 @@ int loop (void) { rl_attempted_completion_function = (CPPFunction *) complete_text; rl_completion_entry_function = complete_none; + do_get_dialog_list (); + return main_loop (); } diff --git a/queries.c b/queries.c index 25154af..eb0ab28 100644 --- a/queries.c +++ b/queries.c @@ -61,7 +61,16 @@ int alarm_query (struct query *q) { } tree_delete_query (queries_tree, q); q->ev.timeout = get_double_time () + QUERY_TIMEOUT; - //insert_event_timer (&q->ev); + insert_event_timer (&q->ev); + + clear_packet (); + out_int (CODE_msg_container); + out_long (q->msg_id); + out_int (q->seq_no); + out_int (4 * q->data_len); + out_ints (q->data, q->data_len); + + encrypt_send_message (q->session->c, packet_buffer, packet_ptr - packet_buffer, 0); return 0; } @@ -80,6 +89,8 @@ struct query *send_query (struct dc *DC, int ints, void *data, struct query_meth q->data = malloc (4 * ints); memcpy (q->data, data, 4 * ints); q->msg_id = encrypt_send_message (DC->sessions[0]->c, data, ints, 1); + q->session = DC->sessions[0]; + q->seq_no = DC->sessions[0]->seq_no - 1; if (verbosity) { logprintf ( "Msg_id is %lld %p\n", q->msg_id, q); } diff --git a/queries.h b/queries.h index 7a9ef52..dc245c9 100644 --- a/queries.h +++ b/queries.h @@ -39,10 +39,12 @@ struct query { long long msg_id; int data_len; int flags; + int seq_no; void *data; struct query_methods *methods; struct event_timer ev; struct dc *DC; + struct session *session; void *extra; };