mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Add and remove from roster on subscription presence
This commit is contained in:
parent
a061b0d452
commit
80c2209bbd
@ -72,6 +72,12 @@ contact_list_add(const char * const jid, const char * const name,
|
|||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
contact_list_remove(const char * const jid)
|
||||||
|
{
|
||||||
|
g_hash_table_remove(contacts, jid);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
contact_list_update_contact(const char * const jid, const char * const presence,
|
contact_list_update_contact(const char * const jid, const char * const presence,
|
||||||
const char * const status)
|
const char * const status)
|
||||||
@ -103,7 +109,9 @@ contact_list_update_subscription(const char * const jid,
|
|||||||
PContact contact = g_hash_table_lookup(contacts, jid);
|
PContact contact = g_hash_table_lookup(contacts, jid);
|
||||||
|
|
||||||
if (contact == NULL) {
|
if (contact == NULL) {
|
||||||
return;
|
contact = p_contact_new(jid, NULL, "offline", NULL, subscription,
|
||||||
|
pending_out);
|
||||||
|
g_hash_table_insert(contacts, strdup(jid), contact);
|
||||||
} else {
|
} else {
|
||||||
p_contact_set_subscription(contact, subscription);
|
p_contact_set_subscription(contact, subscription);
|
||||||
p_contact_set_pending_out(contact, pending_out);
|
p_contact_set_pending_out(contact, pending_out);
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
void contact_list_init(void);
|
void contact_list_init(void);
|
||||||
void contact_list_clear(void);
|
void contact_list_clear(void);
|
||||||
void contact_list_reset_search_attempts(void);
|
void contact_list_reset_search_attempts(void);
|
||||||
|
void contact_list_remove(const char * const jid);
|
||||||
gboolean contact_list_add(const char * const jid, const char * const name,
|
gboolean contact_list_add(const char * const jid, const char * const name,
|
||||||
const char * const presence, const char * const status,
|
const char * const presence, const char * const status,
|
||||||
const char * const subscription, gboolean pending_out);
|
const char * const subscription, gboolean pending_out);
|
||||||
|
@ -793,6 +793,11 @@ _iq_handler(xmpp_conn_t * const conn,
|
|||||||
const char *jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
|
const char *jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
|
||||||
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
||||||
|
|
||||||
|
if (g_strcmp0(sub, "remove") == 0) {
|
||||||
|
contact_list_remove(jid);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean pending_out = FALSE;
|
gboolean pending_out = FALSE;
|
||||||
const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
|
const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
|
||||||
if ((ask != NULL) && (strcmp(ask, "subscribe") == 0)) {
|
if ((ask != NULL) && (strcmp(ask, "subscribe") == 0)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user