annotate libpurple/protocols/jabber/pep.c @ 30961:356a8d472395

propagate from branch 'im.pidgin.pidgin' (head 947bfbeaa5e5a82ae69f2f3d36e34af9c15e24df) to branch 'im.pidgin.cpw.malu.xmpp.google_relay' (head fedd5136b6592607c51921ec43a7d6fe5741f5a5)
author Marcus Lundblad <ml@update.uu.se>
date Wed, 01 Sep 2010 18:41:53 +0000
parents 5e7ff3ed7ad0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
1 /*
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
3 *
28398
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 28397
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 28397
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 28397
diff changeset
6 * source distribution.
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
7 *
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
11 * (at your option) any later version.
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
12 *
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
16 * GNU General Public License for more details.
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
17 *
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
28397
8c991e09efcb Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents: 26885
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
21 *
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
22 */
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
23
19697
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17602
diff changeset
24 #include "internal.h"
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17602
diff changeset
25
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
26 #include "pep.h"
17565
2f67cb504a51 Implemented publishing events
Andreas Monitzer <pidgin@monitzer.com>
parents: 17561
diff changeset
27 #include "iq.h"
17566
0370da969e8a Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <pidgin@monitzer.com>
parents: 17565
diff changeset
28 #include <string.h>
25815
5dd25c58b65e Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents: 24499
diff changeset
29 #include "useravatar.h"
17586
beaeb7fb4dbd Removed a stale include
Andreas Monitzer <pidgin@monitzer.com>
parents: 17582
diff changeset
30 #include "usermood.h"
17596
6842cc73b1b7 Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17586
diff changeset
31 #include "usernick.h"
25763
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25575
diff changeset
32 #include "usertune.h"
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
33
17566
0370da969e8a Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <pidgin@monitzer.com>
parents: 17565
diff changeset
34 static GHashTable *pep_handlers = NULL;
0370da969e8a Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <pidgin@monitzer.com>
parents: 17565
diff changeset
35
0370da969e8a Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <pidgin@monitzer.com>
parents: 17565
diff changeset
36 void jabber_pep_init(void) {
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
37 if(!pep_handlers) {
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
38 pep_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
39
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
40 /* register PEP handlers */
25815
5dd25c58b65e Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents: 24499
diff changeset
41 jabber_avatar_init();
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
42 jabber_mood_init();
25763
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25575
diff changeset
43 jabber_tune_init();
17596
6842cc73b1b7 Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17586
diff changeset
44 jabber_nick_init();
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
45 }
17566
0370da969e8a Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <pidgin@monitzer.com>
parents: 17565
diff changeset
46 }
0370da969e8a Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <pidgin@monitzer.com>
parents: 17565
diff changeset
47
25763
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25575
diff changeset
48 void jabber_pep_uninit(void) {
26885
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26873
diff changeset
49 /* any PEP handlers that need to clean things up go here. The standard
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26873
diff changeset
50 * cleanup of removing the handler and feature are handled here and by
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26873
diff changeset
51 * jabber_features_destroy() in jabber.c
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26873
diff changeset
52 */
25763
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25575
diff changeset
53 g_hash_table_destroy(pep_handlers);
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25575
diff changeset
54 pep_handlers = NULL;
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25575
diff changeset
55 }
860ebaf275ae Add more jabber plugin unloading functions to clean up more data structures
Paul Aurich <paul@darkrain42.org>
parents: 25575
diff changeset
56
17575
5fc8a8a25008 Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents: 17573
diff changeset
57 void jabber_pep_init_actions(GList **m) {
5fc8a8a25008 Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents: 17573
diff changeset
58 /* register the PEP-specific actions */
17596
6842cc73b1b7 Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17586
diff changeset
59 jabber_nick_init_action(m);
17575
5fc8a8a25008 Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents: 17573
diff changeset
60 }
5fc8a8a25008 Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents: 17573
diff changeset
61
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 19698
diff changeset
62 void jabber_pep_register_handler(const char *xmlns, JabberPEPHandler handlerfunc) {
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
63 gchar *notifyns = g_strdup_printf("%s+notify", xmlns);
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 19698
diff changeset
64 jabber_add_feature(notifyns, NULL); /* receiving PEPs is always supported */
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
65 g_free(notifyns);
17566
0370da969e8a Implemented adding callbacks for PEP events. Moved the feature list to be application-global instead of per-connection (makes more sense).
Andreas Monitzer <pidgin@monitzer.com>
parents: 17565
diff changeset
66 g_hash_table_replace(pep_handlers, g_strdup(xmlns), handlerfunc);
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
67 }
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
68
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
69 static void
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
70 do_pep_iq_request_item_callback(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
71 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
72 xmlnode *packet, gpointer data)
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
73 {
26873
5872d1bc546f On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <paul@darkrain42.org>
parents: 26817
diff changeset
74 xmlnode *pubsub;
17582
0f0e98978d66 Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17581
diff changeset
75 xmlnode *items = NULL;
17581
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
76 JabberPEPHandler *cb = data;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
77
26873
5872d1bc546f On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <paul@darkrain42.org>
parents: 26817
diff changeset
78 if (type == JABBER_IQ_RESULT) {
5872d1bc546f On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <paul@darkrain42.org>
parents: 26817
diff changeset
79 pubsub = xmlnode_get_child_with_namespace(packet, "pubsub", "http://jabber.org/protocol/pubsub");
5872d1bc546f On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <paul@darkrain42.org>
parents: 26817
diff changeset
80 if(pubsub)
5872d1bc546f On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <paul@darkrain42.org>
parents: 26817
diff changeset
81 items = xmlnode_get_child(pubsub, "items");
5872d1bc546f On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <paul@darkrain42.org>
parents: 26817
diff changeset
82 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
83
17582
0f0e98978d66 Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17581
diff changeset
84 cb(js, from, items);
17581
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
85 }
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
86
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
87 void jabber_pep_request_item(JabberStream *js, const char *to, const char *node, const char *id, JabberPEPHandler cb) {
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
88 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
28917
b0a04b783e5c jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
89 xmlnode *pubsub, *items;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
90
29896
93e8e6331d44 jabber: Allow jabber_pep_request_item() to take NULL for JID; server's routing takes care of the rest
Paul Aurich <paul@darkrain42.org>
parents: 28917
diff changeset
91 if (to)
93e8e6331d44 jabber: Allow jabber_pep_request_item() to take NULL for JID; server's routing takes care of the rest
Paul Aurich <paul@darkrain42.org>
parents: 28917
diff changeset
92 xmlnode_set_attrib(iq->node, "to", to);
93e8e6331d44 jabber: Allow jabber_pep_request_item() to take NULL for JID; server's routing takes care of the rest
Paul Aurich <paul@darkrain42.org>
parents: 28917
diff changeset
93
17581
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
94 pubsub = xmlnode_new_child(iq->node,"pubsub");
29896
93e8e6331d44 jabber: Allow jabber_pep_request_item() to take NULL for JID; server's routing takes care of the rest
Paul Aurich <paul@darkrain42.org>
parents: 28917
diff changeset
95 xmlnode_set_namespace(pubsub, "http://jabber.org/protocol/pubsub");
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
96
17581
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
97 items = xmlnode_new_child(pubsub, "items");
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
98 xmlnode_set_attrib(items,"node",node);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
99
28917
b0a04b783e5c jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
100 if (id) {
b0a04b783e5c jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
101 xmlnode *item = xmlnode_new_child(items, "item");
17581
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
102 xmlnode_set_attrib(item, "id", id);
28917
b0a04b783e5c jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
103 } else
b0a04b783e5c jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
104 /* Most recent item */
b0a04b783e5c jabber: Properly request just the most recent item from a PEP node.
Paul Aurich <paul@darkrain42.org>
parents: 28398
diff changeset
105 xmlnode_set_attrib(items, "max_items", "1");
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
106
17581
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
107 jabber_iq_set_callback(iq,do_pep_iq_request_item_callback,(gpointer)cb);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
108
17581
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
109 jabber_iq_send(iq);
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
110 }
5ab3c6bb95b4 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17580
diff changeset
111
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 19698
diff changeset
112 gboolean jabber_pep_namespace_only_when_pep_enabled_cb(JabberStream *js, const gchar *namespace) {
17580
7754d39d70c5 Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17576
diff changeset
113 return js->pep;
7754d39d70c5 Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17576
diff changeset
114 }
7754d39d70c5 Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17576
diff changeset
115
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
116 void jabber_handle_event(JabberMessage *jm) {
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
117 /* this may be called even when the own server doesn't support pep! */
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
118 JabberPEPHandler *jph;
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
119 GList *itemslist;
26816
c26c6d25142d Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <paul@darkrain42.org>
parents: 26791
diff changeset
120 char *jid;
c26c6d25142d Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <paul@darkrain42.org>
parents: 26791
diff changeset
121
c26c6d25142d Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <paul@darkrain42.org>
parents: 26791
diff changeset
122 if (jm->type != JABBER_MESSAGE_EVENT)
c26c6d25142d Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <paul@darkrain42.org>
parents: 26791
diff changeset
123 return;
c26c6d25142d Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <paul@darkrain42.org>
parents: 26791
diff changeset
124
c26c6d25142d Don't try to process PEP events if it's not <message type='event'/>
Paul Aurich <paul@darkrain42.org>
parents: 26791
diff changeset
125 jid = jabber_get_bare_jid(jm->from);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
126
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
127 for(itemslist = jm->eventitems; itemslist; itemslist = itemslist->next) {
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
128 xmlnode *items = (xmlnode*)itemslist->data;
17573
2f067d8fb19a Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17572
diff changeset
129 const char *nodename = xmlnode_get_attrib(items,"node");
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
130
17573
2f067d8fb19a Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17572
diff changeset
131 if(nodename && (jph = g_hash_table_lookup(pep_handlers, nodename)))
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
132 jph(jm->js, jid, items);
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
133 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24499
diff changeset
134
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
135 /* discard items we don't have a handler for */
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
136 g_free(jid);
17561
a75079eae085 added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
137 }
17565
2f67cb504a51 Implemented publishing events
Andreas Monitzer <pidgin@monitzer.com>
parents: 17561
diff changeset
138
26791
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
139 void jabber_pep_delete_node(JabberStream *js, const gchar *node)
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
140 {
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
141 JabberIq *iq;
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
142 xmlnode *pubsub, *del;
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
143
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
144 g_return_if_fail(node != NULL);
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
145 g_return_if_fail(js->pep);
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
146
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
147 iq = jabber_iq_new(js, JABBER_IQ_SET);
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
148
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
149 pubsub = xmlnode_new_child(iq->node, "pubsub");
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
150 xmlnode_set_namespace(pubsub, "http://jabber.org/protocol/pubsub#owner");
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
151
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
152 del = xmlnode_new_child(pubsub, "delete");
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
153 xmlnode_set_attrib(del, "node", node);
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
154
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
155 jabber_iq_send(iq);
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
156 }
80437c891f92 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents: 26567
diff changeset
157
17565
2f67cb504a51 Implemented publishing events
Andreas Monitzer <pidgin@monitzer.com>
parents: 17561
diff changeset
158 void jabber_pep_publish(JabberStream *js, xmlnode *publish) {
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
159 JabberIq *iq;
19698
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19697
diff changeset
160 xmlnode *pubsub;
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19697
diff changeset
161
17602
9edab4849ba8 Fixed a leak in the PEP code that leaked PEP nodes when the server doesn't support this XEP.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17596
diff changeset
162 if(js->pep != TRUE) {
9edab4849ba8 Fixed a leak in the PEP code that leaked PEP nodes when the server doesn't support this XEP.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17596
diff changeset
163 /* ignore when there's no PEP support on the server */
9edab4849ba8 Fixed a leak in the PEP code that leaked PEP nodes when the server doesn't support this XEP.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17596
diff changeset
164 xmlnode_free(publish);
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
165 return;
17602
9edab4849ba8 Fixed a leak in the PEP code that leaked PEP nodes when the server doesn't support this XEP.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17596
diff changeset
166 }
19698
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19697
diff changeset
167
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
168 iq = jabber_iq_new(js, JABBER_IQ_SET);
19698
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19697
diff changeset
169
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19697
diff changeset
170 pubsub = xmlnode_new("pubsub");
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
171 xmlnode_set_namespace(pubsub, "http://jabber.org/protocol/pubsub");
19698
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19697
diff changeset
172
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
173 xmlnode_insert_child(pubsub, publish);
19698
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19697
diff changeset
174
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
175 xmlnode_insert_child(iq->node, pubsub);
19698
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19697
diff changeset
176
17572
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17568
diff changeset
177 jabber_iq_send(iq);
17565
2f67cb504a51 Implemented publishing events
Andreas Monitzer <pidgin@monitzer.com>
parents: 17561
diff changeset
178 }