Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lowering xmpp presence priority on away. #38

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion protocols/jabber/presence.c
Expand Up @@ -180,6 +180,22 @@ xt_status jabber_pkt_presence(struct xt_node *node, gpointer data)
return XT_HANDLED;
}

static char *choose_priority(struct im_connection *ic)
{
struct jabber_data *jd = ic->proto_data;
char *prio = set_getstr(&ic->acc->set, "priority");

if (jd->away_state->code != NULL) {
int new_prio = (atoi(prio) - 5);
if (new_prio < 0) {
new_prio = 0;
}
return g_strdup_printf("%d", new_prio);
}

return g_strdup(prio);
}

/* Whenever presence information is updated, call this function to inform the
server. */
int presence_send_update(struct im_connection *ic)
Expand All @@ -188,9 +204,10 @@ int presence_send_update(struct im_connection *ic)
struct xt_node *node, *cap;
GSList *l;
int st;
char *prio = choose_priority(ic);

node = jabber_make_packet("presence", NULL, NULL, NULL);
xt_add_child(node, xt_new_node("priority", set_getstr(&ic->acc->set, "priority"), NULL));
xt_add_child(node, xt_new_node("priority", prio, NULL));
if (jd->away_state) {
xt_add_child(node, xt_new_node("show", jd->away_state->code, NULL));
}
Expand Down Expand Up @@ -221,6 +238,7 @@ int presence_send_update(struct im_connection *ic)
}

xt_free_node(node);
g_free(prio);
return st;
}

Expand Down