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:
parent
02ba1dafb6
commit
ecf5640f46
39
jabber.c
39
jabber.c
@ -302,33 +302,24 @@ static int _jabber_presence_handler(xmpp_conn_t * const conn,
|
||||
char *short_from = strtok(from, "@");
|
||||
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
|
||||
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
|
||||
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;
|
||||
|
38
windows.c
38
windows.c
@ -128,9 +128,7 @@ void win_show_outgoing_msg(char *from, char *to, char *message)
|
||||
void cons_help(void)
|
||||
{
|
||||
_win_show_time(0);
|
||||
wattron(_wins[0].win, A_BOLD);
|
||||
wprintw(_wins[0].win, "Help:\n");
|
||||
wattroff(_wins[0].win, A_BOLD);
|
||||
|
||||
cons_show(" Commands:");
|
||||
cons_show(" /help : This help.");
|
||||
@ -148,20 +146,18 @@ void cons_good_show(char *msg)
|
||||
{
|
||||
_win_show_time(0);
|
||||
wattron(_wins[0].win, A_BOLD);
|
||||
wattron(_wins[0].win, COLOR_PAIR(2));
|
||||
wprintw(_wins[0].win, "%s\n", msg);
|
||||
wattroff(_wins[0].win, A_BOLD);
|
||||
wattroff(_wins[0].win, COLOR_PAIR(2));
|
||||
}
|
||||
|
||||
void cons_bad_show(char *msg)
|
||||
{
|
||||
_win_show_time(0);
|
||||
wattron(_wins[0].win, A_BOLD);
|
||||
wattron(_wins[0].win, COLOR_PAIR(6));
|
||||
wattron(_wins[0].win, A_BOLD);
|
||||
wprintw(_wins[0].win, "%s\n", msg);
|
||||
wattroff(_wins[0].win, A_BOLD);
|
||||
wattroff(_wins[0].win, COLOR_PAIR(6));
|
||||
wattroff(_wins[0].win, A_BOLD);
|
||||
}
|
||||
|
||||
void cons_show(char *msg)
|
||||
@ -208,26 +204,36 @@ void cons_show_contact_online(char *from, char *show, char *status)
|
||||
{
|
||||
_win_show_time(0);
|
||||
wattron(_wins[0].win, COLOR_PAIR(2));
|
||||
wattron(_wins[0].win, A_BOLD);
|
||||
|
||||
wprintw(_wins[0].win, "++ %s", from);
|
||||
|
||||
if (status != NULL)
|
||||
wprintw(_wins[0].win, "+ %s is %s, \"%s\"\n", from, show, status);
|
||||
else
|
||||
wprintw(_wins[0].win, "+ %s is %s\n", from, show);
|
||||
if (show != NULL)
|
||||
wprintw(_wins[0].win, " is %s", show);
|
||||
if (status != NULL)
|
||||
wprintw(_wins[0].win, ", \"%s\"", status);
|
||||
|
||||
wprintw(_wins[0].win, "\n");
|
||||
|
||||
wattroff(_wins[0].win, COLOR_PAIR(2));
|
||||
wattroff(_wins[0].win, A_BOLD);
|
||||
}
|
||||
|
||||
void cons_show_contact_offline(char *from, char *show, char *status)
|
||||
{
|
||||
_win_show_time(0);
|
||||
wattron(_wins[0].win, COLOR_PAIR(7));
|
||||
wattron(_wins[0].win, COLOR_PAIR(5));
|
||||
|
||||
if (status != NULL)
|
||||
wprintw(_wins[0].win, "- %s is %s, \"%s\"\n", from, show, status);
|
||||
else
|
||||
wprintw(_wins[0].win, "- %s is %s\n", from, show);
|
||||
wprintw(_wins[0].win, "-- %s", from);
|
||||
|
||||
if (show != NULL)
|
||||
wprintw(_wins[0].win, " is %s", show);
|
||||
if (status != NULL)
|
||||
wprintw(_wins[0].win, ", \"%s\"", status);
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user