mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Renamed some propreties on the jabber connection for clarity
This commit is contained in:
parent
b48d0e90c6
commit
b223950255
@ -2193,10 +2193,9 @@ _cmd_set_priority(gchar **args, struct cmd_help_t help)
|
|||||||
int intval;
|
int intval;
|
||||||
|
|
||||||
if (_strtoi(value, &intval, -128, 127) == 0) {
|
if (_strtoi(value, &intval, -128, 127) == 0) {
|
||||||
char *status = jabber_get_status();
|
|
||||||
prefs_set_priority((int)intval);
|
prefs_set_priority((int)intval);
|
||||||
// update presence with new priority
|
// 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);
|
cons_show("Priority set to %d.", intval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,17 +140,17 @@ void jabber_process_events(void);
|
|||||||
const char * jabber_get_jid(void);
|
const char * jabber_get_jid(void);
|
||||||
jabber_conn_status_t jabber_get_connection_status(void);
|
jabber_conn_status_t jabber_get_connection_status(void);
|
||||||
int jabber_get_priority(void);
|
int jabber_get_priority(void);
|
||||||
jabber_presence_t jabber_get_presence(void);
|
jabber_presence_t jabber_get_presence_type(void);
|
||||||
char * jabber_get_status(void);
|
char * jabber_get_presence_message(void);
|
||||||
void jabber_free_resources(void);
|
void jabber_free_resources(void);
|
||||||
void jabber_restart(void);
|
void jabber_restart(void);
|
||||||
void jabber_set_autoping(int seconds);
|
void jabber_set_autoping(int seconds);
|
||||||
xmpp_conn_t *jabber_get_conn(void);
|
xmpp_conn_t *jabber_get_conn(void);
|
||||||
xmpp_ctx_t *jabber_get_ctx(void);
|
xmpp_ctx_t *jabber_get_ctx(void);
|
||||||
int error_handler(xmpp_stanza_t * const stanza);
|
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_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);
|
char* jabber_get_account_name(void);
|
||||||
|
|
||||||
// message functions
|
// message functions
|
||||||
|
@ -41,10 +41,10 @@ static struct _jabber_conn_t {
|
|||||||
xmpp_ctx_t *ctx;
|
xmpp_ctx_t *ctx;
|
||||||
xmpp_conn_t *conn;
|
xmpp_conn_t *conn;
|
||||||
jabber_conn_status_t conn_status;
|
jabber_conn_status_t conn_status;
|
||||||
jabber_presence_t presence;
|
jabber_presence_t presence_type;
|
||||||
char *status;
|
char *presence_message;
|
||||||
int tls_disabled;
|
|
||||||
int priority;
|
int priority;
|
||||||
|
int tls_disabled;
|
||||||
} jabber_conn;
|
} jabber_conn;
|
||||||
|
|
||||||
// for auto reconnect
|
// for auto reconnect
|
||||||
@ -83,8 +83,8 @@ jabber_init(const int disable_tls)
|
|||||||
{
|
{
|
||||||
log_info("Initialising XMPP");
|
log_info("Initialising XMPP");
|
||||||
jabber_conn.conn_status = JABBER_STARTED;
|
jabber_conn.conn_status = JABBER_STARTED;
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
jabber_conn.presence_type = PRESENCE_OFFLINE;
|
||||||
jabber_conn.status = NULL;
|
jabber_conn.presence_message = NULL;
|
||||||
jabber_conn.tls_disabled = disable_tls;
|
jabber_conn.tls_disabled = disable_tls;
|
||||||
presence_init();
|
presence_init();
|
||||||
}
|
}
|
||||||
@ -93,8 +93,8 @@ void
|
|||||||
jabber_restart(void)
|
jabber_restart(void)
|
||||||
{
|
{
|
||||||
jabber_conn.conn_status = JABBER_STARTED;
|
jabber_conn.conn_status = JABBER_STARTED;
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
jabber_conn.presence_type = PRESENCE_OFFLINE;
|
||||||
FREE_SET_NULL(jabber_conn.status);
|
FREE_SET_NULL(jabber_conn.presence_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
jabber_conn_status_t
|
jabber_conn_status_t
|
||||||
@ -220,15 +220,15 @@ jabber_get_priority(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
jabber_presence_t
|
jabber_presence_t
|
||||||
jabber_get_presence(void)
|
jabber_get_presence_type(void)
|
||||||
{
|
{
|
||||||
return jabber_conn.presence;
|
return jabber_conn.presence_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
jabber_get_status(void)
|
jabber_get_presence_message(void)
|
||||||
{
|
{
|
||||||
return jabber_conn.status;
|
return jabber_conn.presence_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -238,17 +238,17 @@ jabber_get_account_name(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
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) {
|
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();
|
iq_roster_request();
|
||||||
jabber_conn.conn_status = JABBER_CONNECTED;
|
jabber_conn.conn_status = JABBER_CONNECTED;
|
||||||
jabber_conn.presence = PRESENCE_ONLINE;
|
jabber_conn.presence_type = PRESENCE_ONLINE;
|
||||||
|
|
||||||
if (prefs_get_reconnect() != 0) {
|
if (prefs_get_reconnect() != 0) {
|
||||||
if (reconnect_timer != NULL) {
|
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
|
// close stream response from server after disconnect is handled too
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
jabber_conn.conn_status = JABBER_DISCONNECTED;
|
||||||
jabber_conn.presence = PRESENCE_OFFLINE;
|
jabber_conn.presence_type = PRESENCE_OFFLINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ presence_leave_chat_room(const char * const room_jid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
presence_update(jabber_presence_t status, const char * const msg,
|
presence_update(jabber_presence_t presence_type, const char * const msg,
|
||||||
int idle)
|
int idle)
|
||||||
{
|
{
|
||||||
xmpp_ctx_t *ctx = jabber_get_ctx();
|
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)
|
if (pri < JABBER_PRIORITY_MIN || pri > JABBER_PRIORITY_MAX)
|
||||||
pri = 0;
|
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);
|
jabber_conn_set_priority(pri);
|
||||||
|
|
||||||
switch(status)
|
switch(presence_type)
|
||||||
{
|
{
|
||||||
case PRESENCE_AWAY:
|
case PRESENCE_AWAY:
|
||||||
show = STANZA_TEXT_AWAY;
|
show = STANZA_TEXT_AWAY;
|
||||||
@ -184,9 +185,10 @@ presence_update(jabber_presence_t status, const char * const msg,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
jabber_conn_set_status(msg);
|
|
||||||
|
|
||||||
xmpp_stanza_t *presence = stanza_create_presence(ctx, show, msg);
|
xmpp_stanza_t *presence = stanza_create_presence(ctx, show, msg);
|
||||||
|
|
||||||
|
// servers must treat no priority as 0
|
||||||
if (pri != 0) {
|
if (pri != 0) {
|
||||||
xmpp_stanza_t *priority, *value;
|
xmpp_stanza_t *priority, *value;
|
||||||
char pri_str[10];
|
char pri_str[10];
|
||||||
|
Loading…
Reference in New Issue
Block a user