1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added _cmd_away

Not yet sending message to server
This commit is contained in:
James Booth 2012-05-27 19:53:16 +01:00
parent 11ce116a85
commit f5eab87588
3 changed files with 24 additions and 0 deletions

View File

@ -44,6 +44,7 @@ static gboolean _cmd_msg(const char * const inp);
static gboolean _cmd_close(const char * const inp); static gboolean _cmd_close(const char * const inp);
static gboolean _cmd_set_beep(const char * const inp); static gboolean _cmd_set_beep(const char * const inp);
static gboolean _cmd_set_flash(const char * const inp); static gboolean _cmd_set_flash(const char * const inp);
static gboolean _cmd_away(const char * const inp);
static gboolean _cmd_default(const char * const inp); static gboolean _cmd_default(const char * const inp);
gboolean process_input(char *inp) gboolean process_input(char *inp)
@ -100,6 +101,8 @@ static gboolean _handle_command(const char * const command, const char * const i
result = _cmd_set_beep(inp); result = _cmd_set_beep(inp);
} else if (strcmp(command, "/flash") == 0) { } else if (strcmp(command, "/flash") == 0) {
result = _cmd_set_flash(inp); result = _cmd_set_flash(inp);
} else if (strcmp(command, "/away") == 0) {
result = _cmd_away(inp);
} else { } else {
result = _cmd_default(inp); result = _cmd_default(inp);
} }
@ -250,6 +253,20 @@ static gboolean _cmd_set_flash(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_away(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_AWAY);
cons_show("Status set to \"away\"");
}
return TRUE;
}
static gboolean _cmd_default(const char * const inp) static gboolean _cmd_default(const char * const inp)
{ {
if (win_in_chat()) { if (win_in_chat()) {

View File

@ -179,6 +179,11 @@ void jabber_roster_request(void)
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
void jabber_update_presence(jabber_presence_t status)
{
jabber_conn.presence = status;
}
static int _jabber_message_handler(xmpp_conn_t * const conn, static int _jabber_message_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata) xmpp_stanza_t * const stanza, void * const userdata)
{ {

View File

@ -38,6 +38,7 @@ typedef enum {
void jabber_init(const int disable_tls); void jabber_init(const int disable_tls);
jabber_conn_status_t jabber_connection_status(void); jabber_conn_status_t jabber_connection_status(void);
jabber_presence_t jabber_presence_status(void);
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);
@ -45,5 +46,6 @@ void jabber_roster_request(void);
void jabber_process_events(void); void jabber_process_events(void);
void jabber_send(const char * const msg, const char * const recipient); void jabber_send(const char * const msg, const char * const recipient);
const char * jabber_get_jid(void); const char * jabber_get_jid(void);
void jabber_update_presence(jabber_presence_t status);
#endif #endif