pidgin: d5451d4c: Support pushed notifications about XEP-0...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Tue May 26 23:25:44 EDT 2009
-----------------------------------------------------------------
Revision: d5451d4ca60f9201d94adc9dc0cea60cd2f68eba
Ancestor: 1ecd9e6b8e4cd9ddac69d4c40d68d82020932626
Author: darkrain42 at pidgin.im
Date: 2009-05-26T23:44:55
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d5451d4ca60f9201d94adc9dc0cea60cd2f68eba
Modified files:
libpurple/protocols/jabber/iq.c
libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/jabber.h
ChangeLog:
Support pushed notifications about XEP-0191 Blocks/Unblocks. Closes #8045.
Recompiling jabberd2 from scratch magically made the pushes work, so I was
able to test this and it works, except for causing a crash in jabberd2 that
Mark already fixed. :)
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/iq.c 7fcf359237e0f43a8c783ebe2811e8961c942320
+++ libpurple/protocols/jabber/iq.c c390da42a3529b5e0264108b3e808979ea547fd2
@@ -495,6 +495,8 @@ void jabber_iq_init(void)
jabber_iq_register_handler("session", "http://www.google.com/session",
jabber_google_session_parse);
#endif
+ jabber_iq_register_handler("block", "urn:xmpp:blocking", jabber_blocklist_parse_push);
+ jabber_iq_register_handler("unblock", "urn:xmpp:blocking", jabber_blocklist_parse_push);
jabber_iq_register_handler("time", "urn:xmpp:time", jabber_iq_time_parse);
}
============================================================
--- libpurple/protocols/jabber/jabber.c 1b13af6b0272ad467c72843a54a7e53066a144e6
+++ libpurple/protocols/jabber/jabber.c f33da2858aaff88e489b1e54acab5508176e77f5
@@ -1652,6 +1652,59 @@ void jabber_idle_set(PurpleConnection *g
jabber_presence_send(js, FALSE);
}
+void jabber_blocklist_parse_push(JabberStream *js, const char *from,
+ JabberIqType type, const char *id,
+ xmlnode *child)
+{
+ JabberIq *result;
+ xmlnode *item;
+ PurpleAccount *account;
+ gboolean is_block;
+
+ if (!jabber_is_own_account(js, from)) {
+ xmlnode *error, *x;
+ result = jabber_iq_new(js, JABBER_IQ_ERROR);
+ xmlnode_set_attrib(result->node, "id", id);
+ xmlnode_set_attrib(result->node, "to", from);
+
+ error = xmlnode_new_child(result->node, "error");
+ xmlnode_set_attrib(error, "type", "cancel");
+ x = xmlnode_new_child(error, "not-allowed");
+ xmlnode_set_namespace(x, "urn:ietf:params:xml:ns:xmpp-stanzas");
+
+ jabber_iq_send(result);
+ return;
+ }
+
+ account = purple_connection_get_account(js->gc);
+ is_block = g_str_equal(child->name, "block");
+
+ item = xmlnode_get_child(child, "item");
+ if (!is_block && item == NULL) {
+ /* Unblock everyone */
+ purple_debug_info("jabber", "Received unblock push. Unblocking everyone.\n");
+
+ while (account->deny != NULL) {
+ purple_privacy_deny_remove(account, account->deny->data, TRUE);
+ }
+ } else {
+ for ( ; item; item = xmlnode_get_next_twin(item)) {
+ const char *jid = xmlnode_get_attrib(item, "jid");
+ if (jid == NULL || *jid == '\0')
+ continue;
+
+ if (is_block)
+ purple_privacy_deny_add(account, jid, TRUE);
+ else
+ purple_privacy_deny_remove(account, jid, TRUE);
+ }
+ }
+
+ result = jabber_iq_new(js, JABBER_IQ_RESULT);
+ xmlnode_set_attrib(result->node, "id", id);
+ jabber_iq_send(result);
+}
+
static void jabber_blocklist_parse(JabberStream *js, const char *from,
JabberIqType type, const char *id,
xmlnode *packet, gpointer data)
@@ -1666,6 +1719,14 @@ static void jabber_blocklist_parse(Jabbe
if (blocklist == NULL)
return;
+ /* This is the only privacy method supported by XEP-0191 */
+ if (account->perm_deny != PUPRLE_PRIVACY_DENY_USERS)
+ account->perm_deny = PURPLE_PRIVACY_DENY_USERS;
+
+ /*
+ * FIXME: We should probably completely override the local list with
+ * the contents of the server list instead of merging them.
+ */
item = xmlnode_get_child(blocklist, "item");
while (item != NULL) {
const char *jid = xmlnode_get_attrib(item, "jid");
============================================================
--- libpurple/protocols/jabber/jabber.h e95d747b7183a6cc90b36ba767016ee42484b7ec
+++ libpurple/protocols/jabber/jabber.h bbe0a9889aa19b62ade36273dd189dac47bd0c31
@@ -347,6 +347,9 @@ void jabber_idle_set(PurpleConnection *g
void jabber_login(PurpleAccount *account);
void jabber_close(PurpleConnection *gc);
void jabber_idle_set(PurpleConnection *gc, int idle);
+void jabber_blocklist_parse_push(JabberStream *js, const char *from,
+ JabberIqType type, const char *id,
+ xmlnode *child);
void jabber_request_block_list(JabberStream *js);
void jabber_add_deny(PurpleConnection *gc, const char *who);
void jabber_rem_deny(PurpleConnection *gc, const char *who);
More information about the Commits
mailing list