diff options
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/roster.c | 13 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 23 | ||||
-rw-r--r-- | src/xmpp/stanza.h | 2 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 1 |
4 files changed, 39 insertions, 0 deletions
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index c2aa245a..18000cd4 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -145,6 +145,16 @@ roster_add_new(const char * const barejid, const char * const name) xmpp_stanza_release(iq); } +void +roster_remove(const char * const barejid) +{ + xmpp_conn_t * const conn = connection_get_conn(); + xmpp_ctx_t * const ctx = connection_get_ctx(); + xmpp_stanza_t *iq = stanza_create_roster_remove_set(ctx, barejid); + xmpp_send(conn, iq); + xmpp_stanza_release(iq); +} + gboolean roster_add(const char * const barejid, const char * const name, GSList *groups, const char * const subscription, gboolean pending_out) @@ -366,6 +376,9 @@ _roster_handle_push(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, // remove from roster if (g_strcmp0(sub, "remove") == 0) { // remove barejid and name + if (name == NULL) { + name = barejid; + } autocomplete_remove(barejid_ac, barejid); autocomplete_remove(name_ac, name); g_hash_table_remove(name_to_barejid, name); diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 78d85c18..59a89671 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -90,6 +90,29 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient, } xmpp_stanza_t * +stanza_create_roster_remove_set(xmpp_ctx_t *ctx, const char * const barejid) +{ + xmpp_stanza_t *iq = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(iq, STANZA_NAME_IQ); + xmpp_stanza_set_type(iq, STANZA_TYPE_SET); + + xmpp_stanza_t *query = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(query, STANZA_NAME_QUERY); + xmpp_stanza_set_ns(query, XMPP_NS_ROSTER); + + xmpp_stanza_t *item = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(item, STANZA_NAME_ITEM); + xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, barejid); + xmpp_stanza_set_attribute(item, STANZA_ATTR_SUBSCRIPTION, "remove"); + + xmpp_stanza_add_child(query, item); + xmpp_stanza_add_child(iq, query); + + return iq; + +} + +xmpp_stanza_t * stanza_create_roster_set(xmpp_ctx_t *ctx, const char * const jid, const char * const handle, GSList *groups) { diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 169497bc..b35486e8 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -180,5 +180,7 @@ char * stanza_get_show(xmpp_stanza_t *stanza, char *def); xmpp_stanza_t * stanza_create_roster_set(xmpp_ctx_t *ctx, const char * const jid, const char * const handle, GSList *groups); +xmpp_stanza_t * stanza_create_roster_remove_set(xmpp_ctx_t *ctx, + const char * const barejid); #endif diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 6ca1444d..5469519b 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -144,5 +144,6 @@ gboolean roster_add(const char * const barejid, const char * const name, void roster_change_name(const char * const barejid, const char * const new_name); char * roster_barejid_from_name(const char * const name); void roster_add_new(const char * const barejid, const char * const name); +void roster_remove(const char * const barejid); #endif |