diff options
author | James Booth <boothj5@gmail.com> | 2013-01-31 21:51:35 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-01-31 21:51:35 +0000 |
commit | b2239502557462f4e1744cb3151b6eb2d185ff86 (patch) | |
tree | 69e5ef753995461bfc6b15c80311c1d17833c0ba | |
parent | b48d0e90c6d4610d42690dce76f08b75dba03c7a (diff) | |
download | profani-tty-b2239502557462f4e1744cb3151b6eb2d185ff86.tar.gz |
Renamed some propreties on the jabber connection for clarity
-rw-r--r-- | src/command.c | 3 | ||||
-rw-r--r-- | src/xmpp.h | 8 | ||||
-rw-r--r-- | src/xmpp_conn.c | 36 | ||||
-rw-r--r-- | src/xmpp_presence.c | 10 |
4 files changed, 29 insertions, 28 deletions
diff --git a/src/command.c b/src/command.c index 8addccec..c717a3f2 100644 --- a/src/command.c +++ b/src/command.c @@ -2193,10 +2193,9 @@ _cmd_set_priority(gchar **args, struct cmd_help_t help) int intval; if (_strtoi(value, &intval, -128, 127) == 0) { - char *status = jabber_get_status(); prefs_set_priority((int)intval); // update presence with new priority - presence_update(jabber_get_presence(), status, 0); + presence_update(jabber_get_presence_type(), jabber_get_presence_message(), 0); cons_show("Priority set to %d.", intval); } diff --git a/src/xmpp.h b/src/xmpp.h index bc44ecbf..97d1da45 100644 --- a/src/xmpp.h +++ b/src/xmpp.h @@ -140,17 +140,17 @@ void jabber_process_events(void); const char * jabber_get_jid(void); jabber_conn_status_t jabber_get_connection_status(void); int jabber_get_priority(void); -jabber_presence_t jabber_get_presence(void); -char * jabber_get_status(void); +jabber_presence_t jabber_get_presence_type(void); +char * jabber_get_presence_message(void); void jabber_free_resources(void); void jabber_restart(void); void jabber_set_autoping(int seconds); xmpp_conn_t *jabber_get_conn(void); xmpp_ctx_t *jabber_get_ctx(void); int error_handler(xmpp_stanza_t * const stanza); -void jabber_conn_set_presence(jabber_presence_t presence); +void jabber_conn_set_presence_type(jabber_presence_t presence_type); void jabber_conn_set_priority(int priority); -void jabber_conn_set_status(const char * const message); +void jabber_conn_set_presence_message(const char * const message); char* jabber_get_account_name(void); // message functions diff --git a/src/xmpp_conn.c b/src/xmpp_conn.c index 6b05b48d..5aac8760 100644 --- a/src/xmpp_conn.c +++ b/src/xmpp_conn.c @@ -41,10 +41,10 @@ static struct _jabber_conn_t { xmpp_ctx_t *ctx; xmpp_conn_t *conn; jabber_conn_status_t conn_status; - jabber_presence_t presence; - char *status; - int tls_disabled; + jabber_presence_t presence_type; + char *presence_message; int priority; + int tls_disabled; } jabber_conn; // for auto reconnect @@ -83,8 +83,8 @@ jabber_init(const int disable_tls) { log_info("Initialising XMPP"); jabber_conn.conn_status = JABBER_STARTED; - jabber_conn.presence = PRESENCE_OFFLINE; - jabber_conn.status = NULL; + jabber_conn.presence_type = PRESENCE_OFFLINE; + jabber_conn.presence_message = NULL; jabber_conn.tls_disabled = disable_tls; presence_init(); } @@ -93,8 +93,8 @@ void jabber_restart(void) { jabber_conn.conn_status = JABBER_STARTED; - jabber_conn.presence = PRESENCE_OFFLINE; - FREE_SET_NULL(jabber_conn.status); + jabber_conn.presence_type = PRESENCE_OFFLINE; + FREE_SET_NULL(jabber_conn.presence_message); } jabber_conn_status_t @@ -220,15 +220,15 @@ jabber_get_priority(void) } jabber_presence_t -jabber_get_presence(void) +jabber_get_presence_type(void) { - return jabber_conn.presence; + return jabber_conn.presence_type; } char * -jabber_get_status(void) +jabber_get_presence_message(void) { - return jabber_conn.status; + return jabber_conn.presence_message; } char * @@ -238,17 +238,17 @@ jabber_get_account_name(void) } void -jabber_conn_set_presence(jabber_presence_t presence) +jabber_conn_set_presence_type(jabber_presence_t presence_type) { - jabber_conn.presence = presence; + jabber_conn.presence_type = presence_type; } void -jabber_conn_set_status(const char * const message) +jabber_conn_set_presence_message(const char * const message) { - FREE_SET_NULL(jabber_conn.status); + FREE_SET_NULL(jabber_conn.presence_message); if (message != NULL) { - jabber_conn.status = strdup(message); + jabber_conn.presence_message = strdup(message); } } @@ -412,7 +412,7 @@ _connection_handler(xmpp_conn_t * const conn, iq_roster_request(); jabber_conn.conn_status = JABBER_CONNECTED; - jabber_conn.presence = PRESENCE_ONLINE; + jabber_conn.presence_type = PRESENCE_ONLINE; if (prefs_get_reconnect() != 0) { if (reconnect_timer != NULL) { @@ -449,7 +449,7 @@ _connection_handler(xmpp_conn_t * const conn, // close stream response from server after disconnect is handled too jabber_conn.conn_status = JABBER_DISCONNECTED; - jabber_conn.presence = PRESENCE_OFFLINE; + jabber_conn.presence_type = PRESENCE_OFFLINE; } } diff --git a/src/xmpp_presence.c b/src/xmpp_presence.c index 125e1400..190484ac 100644 --- a/src/xmpp_presence.c +++ b/src/xmpp_presence.c @@ -141,7 +141,7 @@ presence_leave_chat_room(const char * const room_jid) } void -presence_update(jabber_presence_t status, const char * const msg, +presence_update(jabber_presence_t presence_type, const char * const msg, int idle) { xmpp_ctx_t *ctx = jabber_get_ctx(); @@ -157,10 +157,11 @@ presence_update(jabber_presence_t status, const char * const msg, if (pri < JABBER_PRIORITY_MIN || pri > JABBER_PRIORITY_MAX) pri = 0; - jabber_conn_set_presence(status); + jabber_conn_set_presence_type(presence_type); + jabber_conn_set_presence_message(msg); jabber_conn_set_priority(pri); - switch(status) + switch(presence_type) { case PRESENCE_AWAY: show = STANZA_TEXT_AWAY; @@ -184,9 +185,10 @@ presence_update(jabber_presence_t status, const char * const msg, break; } - jabber_conn_set_status(msg); xmpp_stanza_t *presence = stanza_create_presence(ctx, show, msg); + + // servers must treat no priority as 0 if (pri != 0) { xmpp_stanza_t *priority, *value; char pri_str[10]; |