diff options
author | James Booth <boothj5@gmail.com> | 2012-02-17 00:42:41 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-02-17 00:42:41 +0000 |
commit | 03b90cf5abfcd802fd901ba2879388be209d7b5e (patch) | |
tree | ed00ee4b4d32ade068aa7e60ab24b5dc0ea9c115 /profanity.c | |
parent | 3be10300f4710b959ea795143c5d6ad261942b76 (diff) | |
download | profani-tty-03b90cf5abfcd802fd901ba2879388be209d7b5e.tar.gz |
Handles failed logins correctly
Diffstat (limited to 'profanity.c')
-rw-r--r-- | profanity.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/profanity.c b/profanity.c index 6d1ce688..7e0dbe30 100644 --- a/profanity.c +++ b/profanity.c @@ -9,15 +9,19 @@ #include "jabber.h" #include "command.h" -static void _profanity_main(void); +static int _profanity_main(void); static void _profanity_event_loop(int *ch, char *cmd, int *size); static void _process_special_keys(int *ch); -void profanity_start(void) +int profanity_start(void) { + int exit_status = QUIT; int cmd_result = AWAIT_COMMAND; char cmd[50]; + title_bar_disconnected(); + gui_refresh(); + while (cmd_result == AWAIT_COMMAND) { title_bar_refresh(); status_bar_refresh(); @@ -26,11 +30,13 @@ void profanity_start(void) } if (cmd_result == START_MAIN) { - _profanity_main(); + exit_status = _profanity_main(); } + + return exit_status; } -static void _profanity_main(void) +static int _profanity_main(void) { int cmd_result = TRUE; @@ -40,14 +46,22 @@ static void _profanity_main(void) char cmd[100]; int size = 0; - while(ch != '\n') + while(ch != '\n') { _profanity_event_loop(&ch, cmd, &size); + int conn_status = jabber_connection_status(); + if (conn_status == DISCONNECTED) { + inp_block(); + return LOGIN_FAIL; + } + } + cmd[size++] = '\0'; cmd_result = handle_command(cmd); } jabber_disconnect(); + return QUIT; } static void _profanity_event_loop(int *ch, char *cmd, int *size) |