Added -W key to wait dialog list before processing input

This commit is contained in:
Vysheng 2014-02-03 19:50:57 +04:00
parent 051a64fb76
commit 57cff060a3
3 changed files with 19 additions and 2 deletions

12
loop.c
View File

@ -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 ();
}

6
main.c
View File

@ -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 ();

View File

@ -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;
}