diff --git a/command.c b/command.c index 117240f4..b3ce1e93 100644 --- a/command.c +++ b/command.c @@ -28,9 +28,6 @@ int handle_start_command(char *cmd) status_bar_refresh(); char passwd[20]; inp_get_password(passwd); - - status_bar_print_message(user); - status_bar_refresh(); jabber_connect(user, passwd); result = START_MAIN; } else { diff --git a/jabber.c b/jabber.c index 5e365783..dde27d3c 100644 --- a/jabber.c +++ b/jabber.c @@ -42,14 +42,20 @@ static int _roster_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanz void jabber_connect(char *user, char *passwd) { xmpp_initialize(); + _log = xmpp_get_file_logger(); _ctx = xmpp_ctx_new(NULL, _log); _conn = xmpp_conn_new(_ctx); xmpp_conn_set_jid(_conn, user); xmpp_conn_set_pass(_conn, passwd); - xmpp_connect_client(_conn, NULL, 0, _jabber_conn_handler, _ctx); + int connect_status = xmpp_connect_client(_conn, NULL, 0, _jabber_conn_handler, _ctx); + + if (connect_status == -1) + cons_show("XMPP connection failure"); + else + cons_show("Connecting..."); } void jabber_disconnect(void) @@ -129,8 +135,14 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn, xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata; if (status == XMPP_CONN_CONNECT) { + char line[100]; + sprintf(line, "%s logged in successfully.", xmpp_conn_get_jid(conn)); + + cons_show(line); + status_bar_print_message(xmpp_conn_get_jid(conn)); + status_bar_refresh(); + xmpp_stanza_t* pres; - log_msg(CONN, "connected"); xmpp_handler_add(conn, _jabber_message_handler, NULL, "message", NULL, ctx); xmpp_id_handler_add(conn, _roster_handler, "roster", ctx); @@ -140,6 +152,7 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn, xmpp_stanza_release(pres); } else { + cons_show("Login failed."); log_msg(CONN, "disconnected"); xmpp_stop(ctx); } diff --git a/status_bar.c b/status_bar.c index b9ef76a3..7189cc9e 100644 --- a/status_bar.c +++ b/status_bar.c @@ -55,7 +55,7 @@ void status_bar_get_password(void) mvwprintw(status_bar, 0, 9, "Enter password:"); } -void status_bar_print_message(char *msg) +void status_bar_print_message(const char *msg) { mvwprintw(status_bar, 0, 9, msg); } diff --git a/windows.h b/windows.h index 1bbab6ca..ac1ba8e8 100644 --- a/windows.h +++ b/windows.h @@ -40,7 +40,7 @@ void cons_show(char *cmd); void status_bar_refresh(void); void status_bar_clear(void); void status_bar_get_password(void); -void status_bar_print_message(char *msg); +void status_bar_print_message(const char *msg); void status_bar_inactive(int win); void status_bar_active(int win); void status_bar_update_time(void);