1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

Added notification on leave

This commit is contained in:
James Booth 2012-02-27 23:33:29 +00:00
parent 02ba1dafb6
commit ecf5640f46
2 changed files with 37 additions and 40 deletions

View File

@ -302,34 +302,25 @@ static int _jabber_presence_handler(xmpp_conn_t * const conn,
char *short_from = strtok(from, "@"); char *short_from = strtok(from, "@");
char *type = xmpp_stanza_get_attribute(stanza, "type"); char *type = xmpp_stanza_get_attribute(stanza, "type");
char *show_str, *status_str;
xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show");
if (show != NULL)
show_str = xmpp_stanza_get_text(show);
else
show_str = NULL;
xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status");
if (status != NULL)
status_str = xmpp_stanza_get_text(status);
else
status_str = NULL;
if (type == NULL) { // online if (type == NULL) { // online
xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show");
if (show != NULL) {
char *show_str = xmpp_stanza_get_text(show);
xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status");
if (status != NULL) {
char *status_str = xmpp_stanza_get_text(status);
if (show_str != NULL)
cons_show_contact_online(short_from, show_str, status_str); cons_show_contact_online(short_from, show_str, status_str);
}
}
} else { // offline } else { // offline
xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show");
if (show != NULL) {
char *show_str = xmpp_stanza_get_text(show);
xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status");
if (status != NULL) {
char *status_str = xmpp_stanza_get_text(status);
if (show_str != NULL)
cons_show_contact_offline(short_from, show_str, status_str); cons_show_contact_offline(short_from, show_str, status_str);
} }
}
}
return 1; return 1;
} }

View File

@ -128,9 +128,7 @@ void win_show_outgoing_msg(char *from, char *to, char *message)
void cons_help(void) void cons_help(void)
{ {
_win_show_time(0); _win_show_time(0);
wattron(_wins[0].win, A_BOLD);
wprintw(_wins[0].win, "Help:\n"); wprintw(_wins[0].win, "Help:\n");
wattroff(_wins[0].win, A_BOLD);
cons_show(" Commands:"); cons_show(" Commands:");
cons_show(" /help : This help."); cons_show(" /help : This help.");
@ -148,20 +146,18 @@ void cons_good_show(char *msg)
{ {
_win_show_time(0); _win_show_time(0);
wattron(_wins[0].win, A_BOLD); wattron(_wins[0].win, A_BOLD);
wattron(_wins[0].win, COLOR_PAIR(2));
wprintw(_wins[0].win, "%s\n", msg); wprintw(_wins[0].win, "%s\n", msg);
wattroff(_wins[0].win, A_BOLD); wattroff(_wins[0].win, A_BOLD);
wattroff(_wins[0].win, COLOR_PAIR(2));
} }
void cons_bad_show(char *msg) void cons_bad_show(char *msg)
{ {
_win_show_time(0); _win_show_time(0);
wattron(_wins[0].win, A_BOLD);
wattron(_wins[0].win, COLOR_PAIR(6)); wattron(_wins[0].win, COLOR_PAIR(6));
wattron(_wins[0].win, A_BOLD);
wprintw(_wins[0].win, "%s\n", msg); wprintw(_wins[0].win, "%s\n", msg);
wattroff(_wins[0].win, A_BOLD);
wattroff(_wins[0].win, COLOR_PAIR(6)); wattroff(_wins[0].win, COLOR_PAIR(6));
wattroff(_wins[0].win, A_BOLD);
} }
void cons_show(char *msg) void cons_show(char *msg)
@ -208,26 +204,36 @@ void cons_show_contact_online(char *from, char *show, char *status)
{ {
_win_show_time(0); _win_show_time(0);
wattron(_wins[0].win, COLOR_PAIR(2)); wattron(_wins[0].win, COLOR_PAIR(2));
wattron(_wins[0].win, A_BOLD);
wprintw(_wins[0].win, "++ %s", from);
if (show != NULL)
wprintw(_wins[0].win, " is %s", show);
if (status != NULL) if (status != NULL)
wprintw(_wins[0].win, "+ %s is %s, \"%s\"\n", from, show, status); wprintw(_wins[0].win, ", \"%s\"", status);
else
wprintw(_wins[0].win, "+ %s is %s\n", from, show); wprintw(_wins[0].win, "\n");
wattroff(_wins[0].win, COLOR_PAIR(2)); wattroff(_wins[0].win, COLOR_PAIR(2));
wattroff(_wins[0].win, A_BOLD);
} }
void cons_show_contact_offline(char *from, char *show, char *status) void cons_show_contact_offline(char *from, char *show, char *status)
{ {
_win_show_time(0); _win_show_time(0);
wattron(_wins[0].win, COLOR_PAIR(7)); wattron(_wins[0].win, COLOR_PAIR(5));
wprintw(_wins[0].win, "-- %s", from);
if (show != NULL)
wprintw(_wins[0].win, " is %s", show);
if (status != NULL) if (status != NULL)
wprintw(_wins[0].win, "- %s is %s, \"%s\"\n", from, show, status); wprintw(_wins[0].win, ", \"%s\"", status);
else
wprintw(_wins[0].win, "- %s is %s\n", from, show);
wattroff(_wins[0].win, COLOR_PAIR(7)); wprintw(_wins[0].win, "\n");
wattroff(_wins[0].win, COLOR_PAIR(5));
} }
void win_handle_switch(int *ch) void win_handle_switch(int *ch)