Load roster before sending presence

This commit is contained in:
James Booth
2012-10-28 20:52:30 +00:00
parent 4b6002ae63
commit d13794bf60
10 changed files with 144 additions and 139 deletions

View File

@@ -718,8 +718,9 @@ _cmd_sub(const char * const inp, struct cmd_help_t help)
char *user, *lower; char *user, *lower;
user = strndup(inp+5, strlen(inp)-5); user = strndup(inp+5, strlen(inp)-5);
lower = g_utf8_strdown(user, -1); lower = g_utf8_strdown(user, -1);
jabber_subscribe(lower); jabber_subscribe(lower);
cons_show("Sent subscription request to %s.", user);
result = TRUE; result = TRUE;
} }
@@ -824,16 +825,16 @@ _cmd_who(const char * const inp, struct cmd_help_t help)
// get show // get show
strtok(inp_cpy, " "); strtok(inp_cpy, " ");
char *show = strtok(NULL, " "); char *presence = strtok(NULL, " ");
// bad arg // bad arg
if ((show != NULL) if ((presence != NULL)
&& (strcmp(show, "online") != 0) && (strcmp(presence, "online") != 0)
&& (strcmp(show, "offline") != 0) && (strcmp(presence, "offline") != 0)
&& (strcmp(show, "away") != 0) && (strcmp(presence, "away") != 0)
&& (strcmp(show, "chat") != 0) && (strcmp(presence, "chat") != 0)
&& (strcmp(show, "xa") != 0) && (strcmp(presence, "xa") != 0)
&& (strcmp(show, "dnd") != 0)) { && (strcmp(presence, "dnd") != 0)) {
cons_show("Usage: %s", help.usage); cons_show("Usage: %s", help.usage);
// valid arg // valid arg
@@ -841,23 +842,23 @@ _cmd_who(const char * const inp, struct cmd_help_t help)
GSList *list = get_contact_list(); GSList *list = get_contact_list();
// no arg, show all contacts // no arg, show all contacts
if (show == NULL) { if (presence == NULL) {
cons_show("All contacts:"); cons_show("All contacts:");
cons_show_contacts(list); cons_show_contacts(list);
// online, show all status that indicate online // online, show all status that indicate online
} else if (strcmp("online", show) == 0) { } else if (strcmp("online", presence) == 0) {
cons_show("Contacts (%s):", show); cons_show("Contacts (%s):", presence);
GSList *filtered = NULL; GSList *filtered = NULL;
while (list != NULL) { while (list != NULL) {
PContact contact = list->data; PContact contact = list->data;
const char * const contact_show = (p_contact_show(contact)); const char * const contact_presence = (p_contact_presence(contact));
if ((strcmp(contact_show, "online") == 0) if ((strcmp(contact_presence, "online") == 0)
|| (strcmp(contact_show, "away") == 0) || (strcmp(contact_presence, "away") == 0)
|| (strcmp(contact_show, "dnd") == 0) || (strcmp(contact_presence, "dnd") == 0)
|| (strcmp(contact_show, "xa") == 0) || (strcmp(contact_presence, "xa") == 0)
|| (strcmp(contact_show, "chat") == 0)) { || (strcmp(contact_presence, "chat") == 0)) {
filtered = g_slist_append(filtered, contact); filtered = g_slist_append(filtered, contact);
} }
list = g_slist_next(list); list = g_slist_next(list);
@@ -867,12 +868,12 @@ _cmd_who(const char * const inp, struct cmd_help_t help)
// show specific status // show specific status
} else { } else {
cons_show("Contacts (%s):", show); cons_show("Contacts (%s):", presence);
GSList *filtered = NULL; GSList *filtered = NULL;
while (list != NULL) { while (list != NULL) {
PContact contact = list->data; PContact contact = list->data;
if (strcmp(p_contact_show(contact), show) == 0) { if (strcmp(p_contact_presence(contact), presence) == 0) {
filtered = g_slist_append(filtered, contact); filtered = g_slist_append(filtered, contact);
} }
list = g_slist_next(list); list = g_slist_next(list);

View File

@@ -28,22 +28,31 @@
#include "contact.h" #include "contact.h"
struct p_contact_t { struct p_contact_t {
char *jid;
char *name; char *name;
char *show; char *presence;
char *status; char *status;
char *subscription;
}; };
PContact PContact
p_contact_new(const char * const name, const char * const show, p_contact_new(const char * const jid, const char * const name,
const char * const status) const char * const presence, const char * const status,
const char * const subscription)
{ {
PContact contact = malloc(sizeof(struct p_contact_t)); PContact contact = malloc(sizeof(struct p_contact_t));
contact->name = strdup(name); contact->jid = strdup(jid);
if (show == NULL || (strcmp(show, "") == 0)) if (name != NULL) {
contact->show = strdup("online"); contact->name = strdup(name);
} else {
contact->name = NULL;
}
if (presence == NULL || (strcmp(presence, "") == 0))
contact->presence = strdup("online");
else else
contact->show = strdup(show); contact->presence = strdup(presence);
if (status != NULL) if (status != NULL)
contact->status = strdup(status); contact->status = strdup(status);
@@ -57,8 +66,15 @@ PContact
p_contact_copy(PContact contact) p_contact_copy(PContact contact)
{ {
PContact copy = malloc(sizeof(struct p_contact_t)); PContact copy = malloc(sizeof(struct p_contact_t));
copy->name = strdup(contact->name); copy->jid = strdup(contact->jid);
copy->show = strdup(contact->show);
if (contact->name != NULL) {
copy->name = strdup(contact->name);
} else {
copy->name = NULL;
}
copy->presence = strdup(contact->presence);
if (contact->status != NULL) if (contact->status != NULL)
copy->status = strdup(contact->status); copy->status = strdup(contact->status);
@@ -71,12 +87,21 @@ p_contact_copy(PContact contact)
void void
p_contact_free(PContact contact) p_contact_free(PContact contact)
{ {
free(contact->name); if (contact->jid != NULL) {
free(contact->jid);
if (contact->show != NULL) { contact->jid = NULL;
free(contact->show);
contact->show = NULL;
} }
if (contact->name != NULL) {
free(contact->name);
contact->name = NULL;
}
if (contact->presence != NULL) {
free(contact->presence);
contact->presence = NULL;
}
if (contact->status != NULL) { if (contact->status != NULL) {
free(contact->status); free(contact->status);
contact->status = NULL; contact->status = NULL;
@@ -86,6 +111,12 @@ p_contact_free(PContact contact)
contact = NULL; contact = NULL;
} }
const char *
p_contact_jid(const PContact contact)
{
return contact->jid;
}
const char * const char *
p_contact_name(const PContact contact) p_contact_name(const PContact contact)
{ {
@@ -93,9 +124,9 @@ p_contact_name(const PContact contact)
} }
const char * const char *
p_contact_show(const PContact contact) p_contact_presence(const PContact contact)
{ {
return contact->show; return contact->presence;
} }
const char * const char *
@@ -107,9 +138,10 @@ p_contact_status(const PContact contact)
int int
p_contacts_equal_deep(const PContact c1, const PContact c2) p_contacts_equal_deep(const PContact c1, const PContact c2)
{ {
int jid_eq = (g_strcmp0(c1->jid, c2->jid) == 0);
int name_eq = (g_strcmp0(c1->name, c2->name) == 0); int name_eq = (g_strcmp0(c1->name, c2->name) == 0);
int show_eq = (g_strcmp0(c1->show, c2->show) == 0); int presence_eq = (g_strcmp0(c1->presence, c2->presence) == 0);
int status_eq = (g_strcmp0(c1->status, c2->status) == 0); int status_eq = (g_strcmp0(c1->status, c2->status) == 0);
return (name_eq && show_eq && status_eq); return (jid_eq && name_eq && presence_eq && status_eq);
} }

View File

@@ -25,12 +25,14 @@
typedef struct p_contact_t *PContact; typedef struct p_contact_t *PContact;
PContact p_contact_new(const char * const name, const char * const show, PContact p_contact_new(const char * const jid, const char * const name,
const char * const status); const char * const presence, const char * const status,
const char * const subscription);
PContact p_contact_copy(PContact contact); PContact p_contact_copy(PContact contact);
void p_contact_free(PContact contact); void p_contact_free(PContact contact);
const char * p_contact_jid(PContact contact);
const char * p_contact_name(PContact contact); const char * p_contact_name(PContact contact);
const char * p_contact_show(PContact contact); const char * p_contact_presence(PContact contact);
const char * p_contact_status(PContact contact); const char * p_contact_status(PContact contact);
int p_contacts_equal_deep(const PContact c1, const PContact c2); int p_contacts_equal_deep(const PContact c1, const PContact c2);

View File

@@ -30,7 +30,7 @@ static PAutocomplete ac;
void void
contact_list_init(void) contact_list_init(void)
{ {
ac = p_obj_autocomplete_new((PStrFunc)p_contact_name, ac = p_obj_autocomplete_new((PStrFunc)p_contact_jid,
(PCopyFunc)p_contact_copy, (PCopyFunc)p_contact_copy,
(PEqualDeepFunc)p_contacts_equal_deep, (PEqualDeepFunc)p_contacts_equal_deep,
(GDestroyNotify)p_contact_free); (GDestroyNotify)p_contact_free);
@@ -55,10 +55,12 @@ contact_list_remove(const char * const name)
} }
gboolean gboolean
contact_list_add(const char * const name, const char * const show, contact_list_add(const char * const jid, const char * const name,
const char * const status) const char * const presence, const char * const status,
const char * const subscription)
{ {
return p_autocomplete_add(ac, p_contact_new(name, show, status)); return p_autocomplete_add(ac, p_contact_new(jid, name, presence, status,
subscription));
} }
GSList * GSList *

View File

@@ -30,8 +30,9 @@
void contact_list_init(void); void contact_list_init(void);
void contact_list_clear(void); void contact_list_clear(void);
void contact_list_reset_search_attempts(void); void contact_list_reset_search_attempts(void);
gboolean contact_list_add(const char * const name, const char * const show, gboolean contact_list_add(const char * const jid, const char * const name,
const char * const status); const char * const presence, const char * const status,
const char * const subscription);
gboolean contact_list_remove(const char * const name); gboolean contact_list_remove(const char * const name);
GSList * get_contact_list(void); GSList * get_contact_list(void);
char * contact_list_find_contact(char *search_str); char * contact_list_find_contact(char *search_str);

View File

@@ -26,6 +26,7 @@
#include <strophe.h> #include <strophe.h>
#include "common.h" #include "common.h"
#include "contact_list.h"
#include "jabber.h" #include "jabber.h"
#include "log.h" #include "log.h"
#include "preferences.h" #include "preferences.h"
@@ -49,6 +50,8 @@ static void _xmpp_file_logger(void * const userdata,
const char * const msg); const char * const msg);
static xmpp_log_t * _xmpp_get_file_logger(); static xmpp_log_t * _xmpp_get_file_logger();
static void _jabber_roster_request(void);
// XMPP event handlers // XMPP event handlers
static void _connection_handler(xmpp_conn_t * const conn, static void _connection_handler(xmpp_conn_t * const conn,
const xmpp_conn_event_t status, const int error, const xmpp_conn_event_t status, const int error,
@@ -164,26 +167,6 @@ jabber_send(const char * const msg, const char * const recipient)
free(coded_msg3); free(coded_msg3);
} }
void
jabber_roster_request(void)
{
xmpp_stanza_t *iq, *query;
iq = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(iq, "iq");
xmpp_stanza_set_type(iq, "get");
xmpp_stanza_set_id(iq, "roster");
query = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(query, "query");
xmpp_stanza_set_ns(query, XMPP_NS_ROSTER);
xmpp_stanza_add_child(iq, query);
xmpp_stanza_release(query);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
}
void void
jabber_subscribe(const char * const recipient) jabber_subscribe(const char * const recipient)
{ {
@@ -192,7 +175,7 @@ jabber_subscribe(const char * const recipient)
presence = xmpp_stanza_new(jabber_conn.ctx); presence = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(presence, "presence"); xmpp_stanza_set_name(presence, "presence");
xmpp_stanza_set_type(presence, "subscribe"); xmpp_stanza_set_type(presence, "subscribe");
xmpp_stanza_set_attribute(presence, "to", recipient); xmpp_stanza_set_attribute(presence, "to", recipient);
xmpp_send(jabber_conn.conn, presence); xmpp_send(jabber_conn.conn, presence);
xmpp_stanza_release(presence); xmpp_stanza_release(presence);
} }
@@ -266,6 +249,26 @@ jabber_free_resources(void)
xmpp_shutdown(); xmpp_shutdown();
} }
static void
_jabber_roster_request(void)
{
xmpp_stanza_t *iq, *query;
iq = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(iq, "iq");
xmpp_stanza_set_type(iq, "get");
xmpp_stanza_set_id(iq, "roster");
query = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(query, "query");
xmpp_stanza_set_ns(query, XMPP_NS_ROSTER);
xmpp_stanza_add_child(iq, query);
xmpp_stanza_release(query);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
}
static int static int
_message_handler(xmpp_conn_t * const conn, _message_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata) xmpp_stanza_t * const stanza, void * const userdata)
@@ -333,20 +336,14 @@ _connection_handler(xmpp_conn_t * const conn,
const char *jid = xmpp_conn_get_jid(conn); const char *jid = xmpp_conn_get_jid(conn);
prof_handle_login_success(jid); prof_handle_login_success(jid);
xmpp_stanza_t* pres;
xmpp_handler_add(conn, _message_handler, NULL, "message", NULL, ctx); xmpp_handler_add(conn, _message_handler, NULL, "message", NULL, ctx);
xmpp_handler_add(conn, _presence_handler, NULL, "presence", NULL, ctx); xmpp_handler_add(conn, _presence_handler, NULL, "presence", NULL, ctx);
xmpp_id_handler_add(conn, _roster_handler, "roster", ctx); xmpp_id_handler_add(conn, _roster_handler, "roster", ctx);
xmpp_timed_handler_add(conn, _ping_timed_handler, PING_INTERVAL, ctx); xmpp_timed_handler_add(conn, _ping_timed_handler, PING_INTERVAL, ctx);
pres = xmpp_stanza_new(ctx); _jabber_roster_request();
xmpp_stanza_set_name(pres, "presence");
xmpp_send(conn, pres);
xmpp_stanza_release(pres);
jabber_conn.conn_status = JABBER_CONNECTED; jabber_conn.conn_status = JABBER_CONNECTED;
jabber_conn.presence = PRESENCE_ONLINE; jabber_conn.presence = PRESENCE_ONLINE;
jabber_roster_request();
} else { } else {
// received close stream response from server after disconnect // received close stream response from server after disconnect
@@ -375,6 +372,7 @@ static int
_roster_handler(xmpp_conn_t * const conn, _roster_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata) xmpp_stanza_t * const stanza, void * const userdata)
{ {
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
xmpp_stanza_t *query, *item; xmpp_stanza_t *query, *item;
char *type = xmpp_stanza_get_type(stanza); char *type = xmpp_stanza_get_type(stanza);
@@ -382,27 +380,29 @@ _roster_handler(xmpp_conn_t * const conn,
log_error("Roster query failed"); log_error("Roster query failed");
else { else {
query = xmpp_stanza_get_child_by_name(stanza, "query"); query = xmpp_stanza_get_child_by_name(stanza, "query");
GSList *roster = NULL;
item = xmpp_stanza_get_children(query); item = xmpp_stanza_get_children(query);
while (item != NULL) { while (item != NULL) {
const char *name = xmpp_stanza_get_attribute(item, "name");
const char *jid = xmpp_stanza_get_attribute(item, "jid"); const char *jid = xmpp_stanza_get_attribute(item, "jid");
const char *name = xmpp_stanza_get_attribute(item, "name");
const char *sub = xmpp_stanza_get_attribute(item, "subscription");
jabber_roster_entry *entry = malloc(sizeof(jabber_roster_entry)); if (sub != NULL) {
if (strcmp(sub, "none") != 0) {
if (name != NULL) { contact_list_add(jid, name, "offline", NULL, sub);
entry->name = strdup(name);
} else { }
entry->name = NULL;
} }
entry->jid = strdup(jid);
roster = g_slist_append(roster, entry);
item = xmpp_stanza_get_next(item); item = xmpp_stanza_get_next(item);
} }
/*
prof_handle_roster(roster); xmpp_stanza_t* pres;
pres = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(pres, "presence");
xmpp_send(conn, pres);
xmpp_stanza_release(pres);
*/
} }
return 1; return 1;
@@ -449,13 +449,14 @@ _presence_handler(xmpp_conn_t * const conn,
char *type = xmpp_stanza_get_attribute(stanza, "type"); char *type = xmpp_stanza_get_attribute(stanza, "type");
if (type != NULL) { if (type != NULL) {
// allow all subscription requests for now
if (strcmp(type, "subscribe") == 0) { if (strcmp(type, "subscribe") == 0) {
xmpp_stanza_t *presence; xmpp_stanza_t *presence;
presence = xmpp_stanza_new(jabber_conn.ctx); presence = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(presence, "presence"); xmpp_stanza_set_name(presence, "presence");
xmpp_stanza_set_type(presence, "subscribed"); xmpp_stanza_set_type(presence, "subscribed");
xmpp_stanza_set_attribute(presence, "to", short_from); xmpp_stanza_set_attribute(presence, "to", short_from);
xmpp_send(jabber_conn.conn, presence); xmpp_send(jabber_conn.conn, presence);
xmpp_stanza_release(presence); xmpp_stanza_release(presence);
return 1; return 1;

View File

@@ -44,7 +44,6 @@ void jabber_init(const int disable_tls);
jabber_conn_status_t jabber_connect(const char * const user, jabber_conn_status_t jabber_connect(const char * const user,
const char * const passwd); const char * const passwd);
void jabber_disconnect(void); void jabber_disconnect(void);
void jabber_roster_request(void);
void jabber_process_events(void); void jabber_process_events(void);
void jabber_subscribe(const char * const recipient); void jabber_subscribe(const char * const recipient);
void jabber_send(const char * const msg, const char * const recipient); void jabber_send(const char * const msg, const char * const recipient);

View File

@@ -41,7 +41,6 @@
static log_level_t _get_log_level(char *log_level); static log_level_t _get_log_level(char *log_level);
static gboolean _process_input(char *inp); static gboolean _process_input(char *inp);
static void _create_config_directory(); static void _create_config_directory();
static void _free_roster_entry(jabber_roster_entry *entry);
static void _init(const int disable_tls, char *log_level); static void _init(const int disable_tls, char *log_level);
static void _shutdown(void); static void _shutdown(void);
@@ -166,7 +165,7 @@ prof_handle_failed_login(void)
void void
prof_handle_contact_online(char *contact, char *show, char *status) prof_handle_contact_online(char *contact, char *show, char *status)
{ {
gboolean result = contact_list_add(contact, show, status); gboolean result = contact_list_add(contact, NULL, show, status, NULL);
if (result) { if (result) {
win_contact_online(contact, show, status); win_contact_online(contact, show, status);
} }
@@ -176,30 +175,13 @@ prof_handle_contact_online(char *contact, char *show, char *status)
void void
prof_handle_contact_offline(char *contact, char *show, char *status) prof_handle_contact_offline(char *contact, char *show, char *status)
{ {
gboolean result = contact_list_add(contact, "offline", status); gboolean result = contact_list_add(contact, NULL, "offline", status, NULL);
if (result) { if (result) {
win_contact_offline(contact, show, status); win_contact_offline(contact, show, status);
} }
win_page_off(); win_page_off();
} }
void
prof_handle_roster(GSList *roster)
{
while (roster != NULL) {
jabber_roster_entry *entry = roster->data;
// if contact not in contact list add them as offline
if (contact_list_find_contact(entry->jid) == NULL) {
contact_list_add(entry->jid, "offline", NULL);
}
roster = g_slist_next(roster);
}
g_slist_free_full(roster, (GDestroyNotify)_free_roster_entry);
}
static void static void
_create_config_directory(void) _create_config_directory(void)
{ {
@@ -209,16 +191,6 @@ _create_config_directory(void)
g_string_free(dir, TRUE); g_string_free(dir, TRUE);
} }
static void
_free_roster_entry(jabber_roster_entry *entry)
{
if (entry->name != NULL) {
free(entry->name);
entry->name = NULL;
}
free(entry->jid);
}
static log_level_t static log_level_t
_get_log_level(char *log_level) _get_log_level(char *log_level)
{ {

View File

@@ -23,11 +23,6 @@
#ifndef PROFANITY_H #ifndef PROFANITY_H
#define PROFANITY_H #define PROFANITY_H
typedef struct roster_entry_t {
char *name;
char *jid;
} jabber_roster_entry;
void prof_run(const int disable_tls, char *log_level); void prof_run(const int disable_tls, char *log_level);
void prof_handle_login_success(const char *jid); void prof_handle_login_success(const char *jid);

View File

@@ -427,8 +427,8 @@ win_show_outgoing_msg(const char * const from, const char * const to,
} }
if (contact != NULL) { if (contact != NULL) {
if (strcmp(p_contact_show(contact), "offline") == 0) { if (strcmp(p_contact_presence(contact), "offline") == 0) {
const char const *show = p_contact_show(contact); const char const *show = p_contact_presence(contact);
const char const *status = p_contact_status(contact); const char const *status = p_contact_status(contact);
_show_status_string(win, to, show, status, "--", "offline"); _show_status_string(win, to, show, status, "--", "offline");
} }
@@ -703,41 +703,41 @@ cons_show_contacts(GSList *list)
while(curr) { while(curr) {
PContact contact = curr->data; PContact contact = curr->data;
const char *show = p_contact_show(contact); const char *presence = p_contact_presence(contact);
_win_show_time(_cons_win); _win_show_time(_cons_win);
if (strcmp(show, "online") == 0) { if (strcmp(presence, "online") == 0) {
wattron(_cons_win, COLOUR_ONLINE); wattron(_cons_win, COLOUR_ONLINE);
} else if (strcmp(show, "away") == 0) { } else if (strcmp(presence, "away") == 0) {
wattron(_cons_win, COLOUR_AWAY); wattron(_cons_win, COLOUR_AWAY);
} else if (strcmp(show, "chat") == 0) { } else if (strcmp(presence, "chat") == 0) {
wattron(_cons_win, COLOUR_CHAT); wattron(_cons_win, COLOUR_CHAT);
} else if (strcmp(show, "dnd") == 0) { } else if (strcmp(presence, "dnd") == 0) {
wattron(_cons_win, COLOUR_DND); wattron(_cons_win, COLOUR_DND);
} else if (strcmp(show, "xa") == 0) { } else if (strcmp(presence, "xa") == 0) {
wattron(_cons_win, COLOUR_XA); wattron(_cons_win, COLOUR_XA);
} else { } else {
wattron(_cons_win, COLOUR_OFFLINE); wattron(_cons_win, COLOUR_OFFLINE);
} }
wprintw(_cons_win, "%s", p_contact_name(contact)); wprintw(_cons_win, "%s", p_contact_jid(contact));
wprintw(_cons_win, " is %s", show); wprintw(_cons_win, " is %s", presence);
if (p_contact_status(contact)) if (p_contact_status(contact))
wprintw(_cons_win, ", \"%s\"", p_contact_status(contact)); wprintw(_cons_win, ", \"%s\"", p_contact_status(contact));
wprintw(_cons_win, "\n"); wprintw(_cons_win, "\n");
if (strcmp(show, "online") == 0) { if (strcmp(presence, "online") == 0) {
wattroff(_cons_win, COLOUR_ONLINE); wattroff(_cons_win, COLOUR_ONLINE);
} else if (strcmp(show, "away") == 0) { } else if (strcmp(presence, "away") == 0) {
wattroff(_cons_win, COLOUR_AWAY); wattroff(_cons_win, COLOUR_AWAY);
} else if (strcmp(show, "chat") == 0) { } else if (strcmp(presence, "chat") == 0) {
wattroff(_cons_win, COLOUR_CHAT); wattroff(_cons_win, COLOUR_CHAT);
} else if (strcmp(show, "dnd") == 0) { } else if (strcmp(presence, "dnd") == 0) {
wattroff(_cons_win, COLOUR_DND); wattroff(_cons_win, COLOUR_DND);
} else if (strcmp(show, "xa") == 0) { } else if (strcmp(presence, "xa") == 0) {
wattroff(_cons_win, COLOUR_XA); wattroff(_cons_win, COLOUR_XA);
} else { } else {
wattroff(_cons_win, COLOUR_OFFLINE); wattroff(_cons_win, COLOUR_OFFLINE);