Mercurial > pidgin
annotate libpurple/protocols/jabber/pep.c @ 26709:80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Instead of publishing our avatar to both PEP nodes, publish only to the new
and delete anything at the old. We still support receiving both/either.
Backward compatibility is achieved through vcard-temp:x:update.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 27 Apr 2009 05:49:32 +0000 |
parents | 242a8c97270b |
children | c26c6d25142d |
rev | line source |
---|---|
17834
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 * |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
4 * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com> |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
5 * |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
6 * 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
|
7 * 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
|
8 * 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
|
9 * (at your option) any later version. |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
10 * |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
11 * 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
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
15 * |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
16 * 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
|
17 * along with this program; if not, write to the Free Software |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
19 * |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
20 */ |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
21 |
19698
d32ed28cf645
Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17875
diff
changeset
|
22 #include "internal.h" |
d32ed28cf645
Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17875
diff
changeset
|
23 |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
24 #include "pep.h" |
17838
2f67cb504a51
Implemented publishing events
Andreas Monitzer <pidgin@monitzer.com>
parents:
17834
diff
changeset
|
25 #include "iq.h" |
17839
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:
17838
diff
changeset
|
26 #include <string.h> |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
24554
diff
changeset
|
27 #include "useravatar.h" |
17859
beaeb7fb4dbd
Removed a stale include
Andreas Monitzer <pidgin@monitzer.com>
parents:
17855
diff
changeset
|
28 #include "usermood.h" |
17869
6842cc73b1b7
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17859
diff
changeset
|
29 #include "usernick.h" |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
30 |
17839
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:
17838
diff
changeset
|
31 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:
17838
diff
changeset
|
32 |
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:
17838
diff
changeset
|
33 void jabber_pep_init(void) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
34 if(!pep_handlers) { |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
35 pep_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
36 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
37 /* register PEP handlers */ |
25351
5dd25c58b65e
Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <paul@darkrain42.org>
parents:
24554
diff
changeset
|
38 jabber_avatar_init(); |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
39 jabber_mood_init(); |
17869
6842cc73b1b7
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17859
diff
changeset
|
40 jabber_nick_init(); |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
41 } |
17839
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:
17838
diff
changeset
|
42 } |
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:
17838
diff
changeset
|
43 |
17848
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
44 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:
17846
diff
changeset
|
45 /* register the PEP-specific actions */ |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
46 jabber_mood_init_action(m); |
17869
6842cc73b1b7
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17859
diff
changeset
|
47 jabber_nick_init_action(m); |
17848
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
48 } |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
49 |
17839
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:
17838
diff
changeset
|
50 void jabber_pep_register_handler(const char *shortname, const char *xmlns, JabberPEPHandler handlerfunc) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
51 gchar *notifyns = g_strdup_printf("%s+notify", xmlns); |
17849
e49b259fc7dd
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17848
diff
changeset
|
52 jabber_add_feature(shortname, notifyns, NULL); /* receiving PEPs is always supported */ |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
53 g_free(notifyns); |
17839
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:
17838
diff
changeset
|
54 g_hash_table_replace(pep_handlers, g_strdup(xmlns), handlerfunc); |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
55 } |
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
56 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
57 static void |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
58 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:
25952
diff
changeset
|
59 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:
25952
diff
changeset
|
60 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:
25952
diff
changeset
|
61 { |
24554
4caae7801f4d
Fix the namespace URL we look for on PEP reply stanzas to match the URL we
Paul Aurich <paul@darkrain42.org>
parents:
19699
diff
changeset
|
62 xmlnode *pubsub = xmlnode_get_child_with_namespace(packet,"pubsub","http://jabber.org/protocol/pubsub"); |
17855
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:
17854
diff
changeset
|
63 xmlnode *items = NULL; |
17854
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:
17853
diff
changeset
|
64 JabberPEPHandler *cb = data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
65 |
17855
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:
17854
diff
changeset
|
66 if(pubsub) |
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:
17854
diff
changeset
|
67 items = xmlnode_get_child(pubsub, "items"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
68 |
17855
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:
17854
diff
changeset
|
69 cb(js, from, items); |
17854
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:
17853
diff
changeset
|
70 } |
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:
17853
diff
changeset
|
71 |
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:
17853
diff
changeset
|
72 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:
17853
diff
changeset
|
73 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET); |
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:
17853
diff
changeset
|
74 xmlnode *pubsub, *items, *item; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
75 |
17854
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:
17853
diff
changeset
|
76 xmlnode_set_attrib(iq->node,"to",to); |
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:
17853
diff
changeset
|
77 pubsub = xmlnode_new_child(iq->node,"pubsub"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
78 |
17854
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:
17853
diff
changeset
|
79 xmlnode_set_namespace(pubsub,"http://jabber.org/protocol/pubsub"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
80 |
17854
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:
17853
diff
changeset
|
81 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:
17853
diff
changeset
|
82 xmlnode_set_attrib(items,"node",node); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
83 |
17854
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:
17853
diff
changeset
|
84 item = xmlnode_new_child(items, "item"); |
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:
17853
diff
changeset
|
85 if(id) |
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:
17853
diff
changeset
|
86 xmlnode_set_attrib(item, "id", id); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
87 |
17854
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:
17853
diff
changeset
|
88 jabber_iq_set_callback(iq,do_pep_iq_request_item_callback,(gpointer)cb); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
89 |
17854
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:
17853
diff
changeset
|
90 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:
17853
diff
changeset
|
91 } |
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:
17853
diff
changeset
|
92 |
17853
7754d39d70c5
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
93 gboolean jabber_pep_namespace_only_when_pep_enabled_cb(JabberStream *js, const gchar *shortname, const gchar *namespace) { |
7754d39d70c5
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
94 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:
17849
diff
changeset
|
95 } |
7754d39d70c5
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
96 |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
97 void jabber_handle_event(JabberMessage *jm) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
98 /* 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:
17841
diff
changeset
|
99 JabberPEPHandler *jph; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
100 GList *itemslist; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
101 char *jid = jabber_get_bare_jid(jm->from); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
102 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
103 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:
17841
diff
changeset
|
104 xmlnode *items = (xmlnode*)itemslist->data; |
17846
2f067d8fb19a
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17845
diff
changeset
|
105 const char *nodename = xmlnode_get_attrib(items,"node"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
106 |
17846
2f067d8fb19a
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17845
diff
changeset
|
107 if(nodename && (jph = g_hash_table_lookup(pep_handlers, nodename))) |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
108 jph(jm->js, jid, items); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
109 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24554
diff
changeset
|
110 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
111 /* 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:
17841
diff
changeset
|
112 g_free(jid); |
17834
a75079eae085
added preliminary frame for pep-support
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
113 } |
17838
2f67cb504a51
Implemented publishing events
Andreas Monitzer <pidgin@monitzer.com>
parents:
17834
diff
changeset
|
114 |
26709
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
115 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:
26485
diff
changeset
|
116 { |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
117 JabberIq *iq; |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
118 xmlnode *pubsub, *del; |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
119 |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
120 g_return_if_fail(node != NULL); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
121 g_return_if_fail(js->pep); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
122 |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
123 iq = jabber_iq_new(js, JABBER_IQ_SET); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
124 |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
125 pubsub = xmlnode_new_child(iq->node, "pubsub"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
126 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:
26485
diff
changeset
|
127 |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
128 del = xmlnode_new_child(pubsub, "delete"); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
129 xmlnode_set_attrib(del, "node", node); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
130 |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
131 jabber_iq_send(iq); |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
132 } |
80437c891f92
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <paul@darkrain42.org>
parents:
26485
diff
changeset
|
133 |
17838
2f67cb504a51
Implemented publishing events
Andreas Monitzer <pidgin@monitzer.com>
parents:
17834
diff
changeset
|
134 void jabber_pep_publish(JabberStream *js, xmlnode *publish) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
135 JabberIq *iq; |
19699
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
136 xmlnode *pubsub; |
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
137 |
17875
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:
17869
diff
changeset
|
138 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:
17869
diff
changeset
|
139 /* 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:
17869
diff
changeset
|
140 xmlnode_free(publish); |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
141 return; |
17875
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:
17869
diff
changeset
|
142 } |
19699
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
143 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
144 iq = jabber_iq_new(js, JABBER_IQ_SET); |
19699
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
145 |
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
146 pubsub = xmlnode_new("pubsub"); |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
147 xmlnode_set_namespace(pubsub, "http://jabber.org/protocol/pubsub"); |
19699
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
148 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
149 xmlnode_insert_child(pubsub, publish); |
19699
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
150 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
151 xmlnode_insert_child(iq->node, pubsub); |
19699
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
152 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17841
diff
changeset
|
153 jabber_iq_send(iq); |
17838
2f67cb504a51
Implemented publishing events
Andreas Monitzer <pidgin@monitzer.com>
parents:
17834
diff
changeset
|
154 } |