mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 02:46:21 +00:00
Moved login attempt handler code to profanity module
This commit is contained in:
24
src/jabber.c
24
src/jabber.c
@@ -348,16 +348,7 @@ _jabber_conn_handler(xmpp_conn_t * const conn,
|
|||||||
|
|
||||||
if (status == XMPP_CONN_CONNECT) {
|
if (status == XMPP_CONN_CONNECT) {
|
||||||
const char *jid = xmpp_conn_get_jid(conn);
|
const char *jid = xmpp_conn_get_jid(conn);
|
||||||
const char *msg = " logged in successfully.";
|
prof_handle_login_success(jid);
|
||||||
char line[strlen(jid) + 1 + strlen(msg) + 1];
|
|
||||||
sprintf(line, "%s %s", jid, msg);
|
|
||||||
title_bar_set_status(PRESENCE_ONLINE);
|
|
||||||
|
|
||||||
cons_show(line);
|
|
||||||
log_info(line);
|
|
||||||
win_page_off();
|
|
||||||
status_bar_print_message(jid);
|
|
||||||
status_bar_refresh();
|
|
||||||
|
|
||||||
xmpp_stanza_t* pres;
|
xmpp_stanza_t* pres;
|
||||||
xmpp_handler_add(conn, _jabber_message_handler, NULL, "message", NULL, ctx);
|
xmpp_handler_add(conn, _jabber_message_handler, NULL, "message", NULL, ctx);
|
||||||
@@ -370,8 +361,6 @@ _jabber_conn_handler(xmpp_conn_t * const conn,
|
|||||||
xmpp_send(conn, pres);
|
xmpp_send(conn, pres);
|
||||||
xmpp_stanza_release(pres);
|
xmpp_stanza_release(pres);
|
||||||
|
|
||||||
prefs_add_login(jid);
|
|
||||||
|
|
||||||
jabber_conn.conn_status = JABBER_CONNECTED;
|
jabber_conn.conn_status = JABBER_CONNECTED;
|
||||||
jabber_conn.presence = PRESENCE_ONLINE;
|
jabber_conn.presence = PRESENCE_ONLINE;
|
||||||
} else {
|
} else {
|
||||||
@@ -390,21 +379,14 @@ _jabber_conn_handler(xmpp_conn_t * const conn,
|
|||||||
|
|
||||||
// lost connection for unkown reason
|
// lost connection for unkown reason
|
||||||
} else if (jabber_conn.conn_status == JABBER_CONNECTED) {
|
} else if (jabber_conn.conn_status == JABBER_CONNECTED) {
|
||||||
cons_bad_show("Lost connection.");
|
prof_handle_lost_connection();
|
||||||
log_info("Lost connection");
|
|
||||||
win_disconnected();
|
|
||||||
win_page_off();
|
|
||||||
log_info("disconnected");
|
|
||||||
xmpp_stop(ctx);
|
xmpp_stop(ctx);
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
jabber_conn.presence = PRESENCE_OFFLINE;
|
||||||
|
|
||||||
// login attempt failed
|
// login attempt failed
|
||||||
} else {
|
} else {
|
||||||
cons_bad_show("Login failed.");
|
prof_handle_failed_login();
|
||||||
log_info("Login failed");
|
|
||||||
win_page_off();
|
|
||||||
log_info("disconnected");
|
|
||||||
xmpp_stop(ctx);
|
xmpp_stop(ctx);
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
jabber_conn.presence = PRESENCE_OFFLINE;
|
||||||
|
|||||||
@@ -193,6 +193,40 @@ prof_handle_incoming_message(char *from, char *message)
|
|||||||
win_page_off();
|
win_page_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prof_handle_login_success(const char *jid)
|
||||||
|
{
|
||||||
|
const char *msg = " logged in successfully.";
|
||||||
|
char line[strlen(jid) + 1 + strlen(msg) + 1];
|
||||||
|
sprintf(line, "%s %s", jid, msg);
|
||||||
|
title_bar_set_status(PRESENCE_ONLINE);
|
||||||
|
cons_show(line);
|
||||||
|
log_info(line);
|
||||||
|
win_page_off();
|
||||||
|
status_bar_print_message(jid);
|
||||||
|
status_bar_refresh();
|
||||||
|
prefs_add_login(jid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prof_handle_lost_connection(void)
|
||||||
|
{
|
||||||
|
cons_bad_show("Lost connection.");
|
||||||
|
log_info("Lost connection");
|
||||||
|
win_disconnected();
|
||||||
|
win_page_off();
|
||||||
|
log_info("disconnected");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prof_handle_failed_login(void)
|
||||||
|
{
|
||||||
|
cons_bad_show("Login failed.");
|
||||||
|
log_info("Login failed");
|
||||||
|
win_page_off();
|
||||||
|
log_info("disconnected");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_create_config_directory()
|
_create_config_directory()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
void profanity_init(const int disable_tls, char *log_level);
|
void profanity_init(const int disable_tls, char *log_level);
|
||||||
void profanity_run(void);
|
void profanity_run(void);
|
||||||
|
void prof_handle_login_success(const char *jid);
|
||||||
|
void prof_handle_lost_connection(void);
|
||||||
|
void prof_handle_failed_login(void);
|
||||||
void prof_handle_typing(char *from);
|
void prof_handle_typing(char *from);
|
||||||
void prof_handle_incoming_message(char *from, char *message);
|
void prof_handle_incoming_message(char *from, char *message);
|
||||||
void profanity_shutdown_init(void);
|
void profanity_shutdown_init(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user