mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Handling logins and outputting to console
This commit is contained in:
parent
b79e61fd80
commit
66ae3d2bf8
@ -28,9 +28,6 @@ int handle_start_command(char *cmd)
|
|||||||
status_bar_refresh();
|
status_bar_refresh();
|
||||||
char passwd[20];
|
char passwd[20];
|
||||||
inp_get_password(passwd);
|
inp_get_password(passwd);
|
||||||
|
|
||||||
status_bar_print_message(user);
|
|
||||||
status_bar_refresh();
|
|
||||||
jabber_connect(user, passwd);
|
jabber_connect(user, passwd);
|
||||||
result = START_MAIN;
|
result = START_MAIN;
|
||||||
} else {
|
} else {
|
||||||
|
17
jabber.c
17
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)
|
void jabber_connect(char *user, char *passwd)
|
||||||
{
|
{
|
||||||
xmpp_initialize();
|
xmpp_initialize();
|
||||||
|
|
||||||
_log = xmpp_get_file_logger();
|
_log = xmpp_get_file_logger();
|
||||||
_ctx = xmpp_ctx_new(NULL, _log);
|
_ctx = xmpp_ctx_new(NULL, _log);
|
||||||
_conn = xmpp_conn_new(_ctx);
|
_conn = xmpp_conn_new(_ctx);
|
||||||
|
|
||||||
xmpp_conn_set_jid(_conn, user);
|
xmpp_conn_set_jid(_conn, user);
|
||||||
xmpp_conn_set_pass(_conn, passwd);
|
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)
|
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;
|
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
|
||||||
|
|
||||||
if (status == XMPP_CONN_CONNECT) {
|
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;
|
xmpp_stanza_t* pres;
|
||||||
log_msg(CONN, "connected");
|
|
||||||
xmpp_handler_add(conn, _jabber_message_handler, NULL, "message", NULL, ctx);
|
xmpp_handler_add(conn, _jabber_message_handler, NULL, "message", NULL, ctx);
|
||||||
xmpp_id_handler_add(conn, _roster_handler, "roster", 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);
|
xmpp_stanza_release(pres);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
cons_show("Login failed.");
|
||||||
log_msg(CONN, "disconnected");
|
log_msg(CONN, "disconnected");
|
||||||
xmpp_stop(ctx);
|
xmpp_stop(ctx);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ void status_bar_get_password(void)
|
|||||||
mvwprintw(status_bar, 0, 9, "Enter password:");
|
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);
|
mvwprintw(status_bar, 0, 9, msg);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ void cons_show(char *cmd);
|
|||||||
void status_bar_refresh(void);
|
void status_bar_refresh(void);
|
||||||
void status_bar_clear(void);
|
void status_bar_clear(void);
|
||||||
void status_bar_get_password(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_inactive(int win);
|
||||||
void status_bar_active(int win);
|
void status_bar_active(int win);
|
||||||
void status_bar_update_time(void);
|
void status_bar_update_time(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user