From 57cff060a37cea2e6b8aafaae336175723278c9b Mon Sep 17 00:00:00 2001 From: Vysheng Date: Mon, 3 Feb 2014 19:50:57 +0400 Subject: [PATCH] Added -W key to wait dialog list before processing input --- loop.c | 12 +++++++++++- main.c | 6 +++++- queries.c | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/loop.c b/loop.c index d82d1bc..5dcc97a 100644 --- a/loop.c +++ b/loop.c @@ -326,6 +326,7 @@ extern int peer_num; extern int encr_root; extern unsigned char *encr_prime; extern int encr_param_version; +extern int dialog_list_got; void read_secret_chat_file (void) { if (binlog_enabled) { return; } @@ -443,11 +444,16 @@ int mcs (void) { extern int difference_got; int dgot (void) { - return !difference_got; + return difference_got; +} +int dlgot (void) { + return dialog_list_got; } int readline_active; int new_dc_num; +int wait_dialog_list; + int loop (void) { on_start (); if (binlog_enabled) { @@ -598,6 +604,10 @@ int loop (void) { do_get_dialog_list (); + if (wait_dialog_list) { + dialog_list_got = 0; + net_loop (0, dlgot); + } return main_loop (); } diff --git a/main.c b/main.c index 562e351..91ddc3b 100644 --- a/main.c +++ b/main.c @@ -358,12 +358,13 @@ FILE *log_net_f; int register_mode; int disable_auto_accept; +int wait_dialog_list; char *lua_file; void args_parse (int argc, char **argv) { int opt = 0; - while ((opt = getopt (argc, argv, "u:hk:vn:Nc:p:l:RfBL:Es:")) != -1) { + while ((opt = getopt (argc, argv, "u:hk:vn:Nc:p:l:RfBL:Es:wW")) != -1) { switch (opt) { case 'u': set_default_username (optarg); @@ -413,6 +414,9 @@ void args_parse (int argc, char **argv) { case 's': lua_file = tstrdup (optarg); break; + case 'W': + wait_dialog_list = 1; + break; case 'h': default: usage (); diff --git a/queries.c b/queries.c index e830d34..35a36f4 100644 --- a/queries.c +++ b/queries.c @@ -1087,6 +1087,7 @@ void do_get_history (peer_id_t id, int limit) { /* }}} */ /* {{{ Get dialogs */ +int dialog_list_got; int get_dialogs_on_answer (struct query *q UU) { unsigned x = fetch_int (); assert (x == CODE_messages_dialogs || x == CODE_messages_dialogs_slice); @@ -1147,6 +1148,8 @@ int get_dialogs_on_answer (struct query *q UU) { } pop_color (); print_end (); + + dialog_list_got = 1; return 0; }