1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Implemented xa, chat and dnd presence

This commit is contained in:
James Booth 2012-05-27 23:00:04 +01:00
parent fadf841d1f
commit 2fe5d3e9d1
4 changed files with 77 additions and 3 deletions

View File

@ -46,6 +46,9 @@ static gboolean _cmd_set_beep(const char * const inp);
static gboolean _cmd_set_flash(const char * const inp);
static gboolean _cmd_away(const char * const inp);
static gboolean _cmd_online(const char * const inp);
static gboolean _cmd_dnd(const char * const inp);
static gboolean _cmd_chat(const char * const inp);
static gboolean _cmd_xa(const char * const inp);
static gboolean _cmd_default(const char * const inp);
gboolean process_input(char *inp)
@ -106,6 +109,12 @@ static gboolean _handle_command(const char * const command, const char * const i
result = _cmd_away(inp);
} else if (strcmp(command, "/online") == 0) {
result = _cmd_online(inp);
} else if (strcmp(command, "/dnd") == 0) {
result = _cmd_dnd(inp);
} else if (strcmp(command, "/chat") == 0) {
result = _cmd_chat(inp);
} else if (strcmp(command, "/xa") == 0) {
result = _cmd_xa(inp);
} else {
result = _cmd_default(inp);
}
@ -286,6 +295,51 @@ static gboolean _cmd_online(const char * const inp)
return TRUE;
}
static gboolean _cmd_dnd(const char * const inp)
{
jabber_conn_status_t conn_status = jabber_connection_status();
if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected.");
} else {
jabber_update_presence(PRESENCE_DND);
title_bar_set_status(PRESENCE_DND);
cons_show("Status set to \"dnd\"");
}
return TRUE;
}
static gboolean _cmd_chat(const char * const inp)
{
jabber_conn_status_t conn_status = jabber_connection_status();
if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected.");
} else {
jabber_update_presence(PRESENCE_CHAT);
title_bar_set_status(PRESENCE_CHAT);
cons_show("Status set to \"chat\"");
}
return TRUE;
}
static gboolean _cmd_xa(const char * const inp)
{
jabber_conn_status_t conn_status = jabber_connection_status();
if (conn_status != JABBER_CONNECTED) {
cons_show("You are not currently connected.");
} else {
jabber_update_presence(PRESENCE_XA);
title_bar_set_status(PRESENCE_XA);
cons_show("Status set to \"xa\"");
}
return TRUE;
}
static gboolean _cmd_default(const char * const inp)
{
if (win_in_chat()) {

View File

@ -35,7 +35,10 @@ typedef enum {
typedef enum {
PRESENCE_OFFLINE,
PRESENCE_ONLINE,
PRESENCE_AWAY
PRESENCE_AWAY,
PRESENCE_DND,
PRESENCE_CHAT,
PRESENCE_XA
} jabber_presence_t;
#if !GLIB_CHECK_VERSION(2,28,0)

View File

@ -189,11 +189,22 @@ void jabber_update_presence(jabber_presence_t status)
pres = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(pres, "presence");
if (status == PRESENCE_AWAY) {
if (status != PRESENCE_ONLINE) {
show = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(show, "show");
xmpp_stanza_t *text = xmpp_stanza_new(jabber_conn.ctx);
if (status == PRESENCE_AWAY)
xmpp_stanza_set_text(text, "away");
else if (status == PRESENCE_DND)
xmpp_stanza_set_text(text, "dnd");
else if (status == PRESENCE_CHAT)
xmpp_stanza_set_text(text, "chat");
else if (status == PRESENCE_XA)
xmpp_stanza_set_text(text, "xa");
else
xmpp_stanza_set_text(text, "online");
xmpp_stanza_add_child(show, text);
xmpp_stanza_add_child(pres, show);
xmpp_stanza_release(text);

View File

@ -104,6 +104,12 @@ static void _title_bar_draw_status()
mvwprintw(title_bar, 0, cols - 13, " ...online ");
} else if (current_status == PRESENCE_AWAY) {
mvwprintw(title_bar, 0, cols - 13, " .....away ");
} else if (current_status == PRESENCE_DND) {
mvwprintw(title_bar, 0, cols - 13, " ......dnd ");
} else if (current_status == PRESENCE_CHAT) {
mvwprintw(title_bar, 0, cols - 13, " .....chat ");
} else if (current_status == PRESENCE_XA) {
mvwprintw(title_bar, 0, cols - 13, " .......xa ");
} else {
mvwprintw(title_bar, 0, cols - 13, " ..offline ");
}