annotate libpurple/protocols/jabber/caps.c @ 29458:a538cb73f897

propagate from branch 'im.pidgin.pidgin' (head b0098e2250f135d121960d8152e144e7e344125e) to branch 'im.pidgin.cpw.rekkanoryo.icqxstatus' (head dcd3ab65d5cfcd79b00a7b95ab5fe788da64c112)
author Marcus Lundblad <ml@update.uu.se>
date Sun, 07 Feb 2010 19:31:56 +0000
parents 9ae3e70a327b
children 12ba4c648872
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
1 /*
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
3 *
28048
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 28047
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: 28047
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: 28047
diff changeset
6 * source distribution.
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
7 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
11 * (at your option) any later version.
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
12 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
16 * GNU General Public License for more details.
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
17 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
28047
8c991e09efcb Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents: 28037
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
21 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
22 */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
23
19698
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17902
diff changeset
24 #include "internal.h"
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17902
diff changeset
25
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
26 #include "debug.h"
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
27 #include "caps.h"
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
28 #include "cipher.h"
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
29 #include "iq.h"
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
30 #include "presence.h"
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
31 #include "util.h"
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
32
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
33 #define JABBER_CAPS_FILENAME "xmpp-caps.xml"
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
34
25162
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
35 typedef struct _JabberDataFormField {
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
36 gchar *var;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
37 GList *values;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
38 } JabberDataFormField;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
39
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
40 static GHashTable *capstable = NULL; /* JabberCapsTuple -> JabberCapsClientInfo */
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
41 static GHashTable *nodetable = NULL; /* char *node -> JabberCapsNodeExts */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
42 static guint save_timer = 0;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
43
25162
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
44 /**
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
45 * Processes a query-node and returns a JabberCapsClientInfo object with all relevant info.
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
46 *
25162
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
47 * @param query A query object.
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
48 * @return A JabberCapsClientInfo object.
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
49 */
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
50 static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query);
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
51
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
52 /* Free a GList of allocated char* */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
53 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
54 free_string_glist(GList *list)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
55 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
56 g_list_foreach(list, (GFunc)g_free, NULL);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
57 g_list_free(list);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
58 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
59
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
60 static JabberCapsNodeExts*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
61 jabber_caps_node_exts_ref(JabberCapsNodeExts *exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
62 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
63 g_return_val_if_fail(exts != NULL, NULL);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
64
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
65 ++exts->ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
66 return exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
67 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
68
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
69 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
70 jabber_caps_node_exts_unref(JabberCapsNodeExts *exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
71 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
72 if (exts == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
73 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
74
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
75 g_return_if_fail(exts->ref != 0);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
76
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
77 if (--exts->ref != 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
78 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
79
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
80 g_hash_table_destroy(exts->exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
81 g_free(exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
82 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23703
diff changeset
83
25188
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25187
diff changeset
84 static guint jabber_caps_hash(gconstpointer data) {
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
85 const JabberCapsTuple *key = data;
25188
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25187
diff changeset
86 guint nodehash = g_str_hash(key->node);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
87 guint verhash = g_str_hash(key->ver);
26661
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26488
diff changeset
88 /*
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26488
diff changeset
89 * 'hash' was optional in XEP-0115 v1.4 and g_str_hash crashes on NULL >:O.
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26488
diff changeset
90 * Okay, maybe I've played too much Zelda, but that looks like
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26488
diff changeset
91 * a Deku Shrub...
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26488
diff changeset
92 */
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
93 guint hashhash = (key->hash ? g_str_hash(key->hash) : 0);
25027
45816181b7de * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25026
diff changeset
94 return nodehash ^ verhash ^ hashhash;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
95 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
96
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
97 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) {
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
98 const JabberCapsTuple *name1 = v1;
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
99 const JabberCapsTuple *name2 = v2;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
100
26661
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26488
diff changeset
101 return g_str_equal(name1->node, name2->node) &&
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26488
diff changeset
102 g_str_equal(name1->ver, name2->ver) &&
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26488
diff changeset
103 purple_strequal(name1->hash, name2->hash);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
104 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
105
25191
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
106 static void
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
107 jabber_caps_client_info_destroy(JabberCapsClientInfo *info)
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
108 {
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
109 if (info == NULL)
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
110 return;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
111
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
112 while(info->identities) {
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
113 JabberIdentity *id = info->identities->data;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
114 g_free(id->category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
115 g_free(id->type);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
116 g_free(id->name);
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
117 g_free(id->lang);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
118 g_free(id);
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
119 info->identities = g_list_delete_link(info->identities, info->identities);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
120 }
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
121
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
122 free_string_glist(info->features);
26816
bcc577785c2b Free the forms properly; they're xmlnodes, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 26803
diff changeset
123
bcc577785c2b Free the forms properly; they're xmlnodes, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 26803
diff changeset
124 while (info->forms) {
bcc577785c2b Free the forms properly; they're xmlnodes, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 26803
diff changeset
125 xmlnode_free(info->forms->data);
bcc577785c2b Free the forms properly; they're xmlnodes, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 26803
diff changeset
126 info->forms = g_list_delete_link(info->forms, info->forms);
bcc577785c2b Free the forms properly; they're xmlnodes, not strings.
Paul Aurich <paul@darkrain42.org>
parents: 26803
diff changeset
127 }
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
128
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
129 jabber_caps_node_exts_unref(info->exts);
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
130
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
131 g_free((char *)info->tuple.node);
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
132 g_free((char *)info->tuple.ver);
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
133 g_free((char *)info->tuple.hash);
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
134
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
135 g_free(info);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
136 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
137
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
138 /* NOTE: Takes a reference to the exts, unref it if you don't really want to
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
139 * keep it around. */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
140 static JabberCapsNodeExts*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
141 jabber_caps_find_exts_by_node(const char *node)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
142 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
143 JabberCapsNodeExts *exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
144 if (NULL == (exts = g_hash_table_lookup(nodetable, node))) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
145 exts = g_new0(JabberCapsNodeExts, 1);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
146 exts->exts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
147 (GDestroyNotify)free_string_glist);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
148 g_hash_table_insert(nodetable, g_strdup(node), jabber_caps_node_exts_ref(exts));
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
149 }
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
150
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
151 return jabber_caps_node_exts_ref(exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
152 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
153
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
154 static void
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
155 exts_to_xmlnode(gconstpointer key, gconstpointer value, gpointer user_data)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
156 {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
157 const char *identifier = key;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
158 const GList *features = value, *node;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
159 xmlnode *client = user_data, *ext, *feature;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
160
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
161 ext = xmlnode_new_child(client, "ext");
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
162 xmlnode_set_attrib(ext, "identifier", identifier);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
163
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
164 for (node = features; node; node = node->next) {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
165 feature = xmlnode_new_child(ext, "feature");
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
166 xmlnode_set_attrib(feature, "var", (const gchar *)node->data);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
167 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
168 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
169
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
170 static void jabber_caps_store_client(gpointer key, gpointer value, gpointer user_data) {
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
171 const JabberCapsTuple *tuple = key;
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
172 const JabberCapsClientInfo *props = value;
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
173 xmlnode *root = user_data;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
174 xmlnode *client = xmlnode_new_child(root, "client");
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
175 GList *iter;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23703
diff changeset
176
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
177 xmlnode_set_attrib(client, "node", tuple->node);
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
178 xmlnode_set_attrib(client, "ver", tuple->ver);
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
179 if (tuple->hash)
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
180 xmlnode_set_attrib(client, "hash", tuple->hash);
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
181 for(iter = props->identities; iter; iter = g_list_next(iter)) {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
182 JabberIdentity *id = iter->data;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
183 xmlnode *identity = xmlnode_new_child(client, "identity");
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
184 xmlnode_set_attrib(identity, "category", id->category);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
185 xmlnode_set_attrib(identity, "type", id->type);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
186 if (id->name)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
187 xmlnode_set_attrib(identity, "name", id->name);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
188 if (id->lang)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
189 xmlnode_set_attrib(identity, "lang", id->lang);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
190 }
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
191
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
192 for(iter = props->features; iter; iter = g_list_next(iter)) {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
193 const char *feat = iter->data;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
194 xmlnode *feature = xmlnode_new_child(client, "feature");
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
195 xmlnode_set_attrib(feature, "var", feat);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
196 }
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
197
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
198 for(iter = props->forms; iter; iter = g_list_next(iter)) {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
199 /* FIXME: See #7814 */
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
200 xmlnode *xdata = iter->data;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
201 xmlnode_insert_child(client, xmlnode_copy(xdata));
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
202 }
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
203
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
204 /* TODO: Ideally, only save this once-per-node... */
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
205 if (props->exts)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
206 g_hash_table_foreach(props->exts->exts, (GHFunc)exts_to_xmlnode, client);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
207 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
208
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
209 static gboolean
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
210 do_jabber_caps_store(gpointer data)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
211 {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
212 char *str;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
213 int length = 0;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
214 xmlnode *root = xmlnode_new("capabilities");
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
215 g_hash_table_foreach(capstable, jabber_caps_store_client, root);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
216 str = xmlnode_to_formatted_str(root, &length);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
217 xmlnode_free(root);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
218 purple_util_write_data_to_file(JABBER_CAPS_FILENAME, str, length);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
219 g_free(str);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
220
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
221 save_timer = 0;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
222 return FALSE;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
223 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
224
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
225 static void
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
226 schedule_caps_save(void)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
227 {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
228 if (save_timer == 0)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
229 save_timer = purple_timeout_add_seconds(5, do_jabber_caps_store, NULL);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
230 }
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
231
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
232 static void
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
233 jabber_caps_load(void)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
234 {
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
235 xmlnode *capsdata = purple_util_read_xml_from_file(JABBER_CAPS_FILENAME, "XMPP capabilities cache");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
236 xmlnode *client;
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
237
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
238 if(!capsdata)
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
239 return;
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
240
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
241 if (strcmp(capsdata->name, "capabilities") != 0) {
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
242 xmlnode_free(capsdata);
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
243 return;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
244 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23703
diff changeset
245
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
246 for(client = capsdata->child; client; client = client->next) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
247 if(client->type != XMLNODE_TYPE_TAG)
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
248 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
249 if(!strcmp(client->name, "client")) {
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
250 JabberCapsClientInfo *value = g_new0(JabberCapsClientInfo, 1);
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
251 JabberCapsTuple *key = (JabberCapsTuple*)&value->tuple;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
252 xmlnode *child;
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
253 JabberCapsNodeExts *exts = NULL;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
254 key->node = g_strdup(xmlnode_get_attrib(client,"node"));
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
255 key->ver = g_strdup(xmlnode_get_attrib(client,"ver"));
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
256 key->hash = g_strdup(xmlnode_get_attrib(client,"hash"));
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
257
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
258 /* v1.3 capabilities */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
259 if (key->hash == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
260 exts = jabber_caps_find_exts_by_node(key->node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
261
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
262 for(child = client->child; child; child = child->next) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
263 if(child->type != XMLNODE_TYPE_TAG)
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
264 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
265 if(!strcmp(child->name,"feature")) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
266 const char *var = xmlnode_get_attrib(child, "var");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
267 if(!var)
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
268 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
269 value->features = g_list_append(value->features,g_strdup(var));
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
270 } else if(!strcmp(child->name,"identity")) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
271 const char *category = xmlnode_get_attrib(child, "category");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
272 const char *type = xmlnode_get_attrib(child, "type");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
273 const char *name = xmlnode_get_attrib(child, "name");
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
274 const char *lang = xmlnode_get_attrib(child, "lang");
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
275 JabberIdentity *id;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23703
diff changeset
276
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
277 if (!category || !type)
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
278 continue;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
279
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
280 id = g_new0(JabberIdentity, 1);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
281 id->category = g_strdup(category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
282 id->type = g_strdup(type);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
283 id->name = g_strdup(name);
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
284 id->lang = g_strdup(lang);
26771
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
285
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
286 value->identities = g_list_append(value->identities,id);
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
287 } else if(!strcmp(child->name,"x")) {
26771
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
288 /* TODO: See #7814 -- this might cause problems if anyone
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
289 * ever actually specifies forms. In fact, for this to
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
290 * work properly, that bug needs to be fixed in
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
291 * xmlnode_from_str, not the output version... */
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
292 value->forms = g_list_append(value->forms, xmlnode_copy(child));
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
293 } else if (!strcmp(child->name, "ext") && key->hash != NULL) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
294 purple_debug_warning("jabber", "Ignoring exts when reading new-style caps\n");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
295 } else if (!strcmp(child->name, "ext")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
296 /* TODO: Do we care about reading in the identities listed here? */
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
297 const char *identifier = xmlnode_get_attrib(child, "identifier");
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
298 xmlnode *node;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
299 GList *features = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
300
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
301 if (!identifier)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
302 continue;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23703
diff changeset
303
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
304 for (node = child->child; node; node = node->next) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
305 if (node->type != XMLNODE_TYPE_TAG)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
306 continue;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
307 if (!strcmp(node->name, "feature")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
308 const char *var = xmlnode_get_attrib(node, "var");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
309 if (!var)
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
310 continue;
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
311 features = g_list_prepend(features, g_strdup(var));
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
312 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
313 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23703
diff changeset
314
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
315 if (features) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
316 g_hash_table_insert(exts->exts, g_strdup(identifier),
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
317 features);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
318 } else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
319 purple_debug_warning("jabber", "Caps ext %s had no features.\n",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
320 identifier);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
321 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
322 }
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
323
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
324 value->exts = exts;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
325 g_hash_table_replace(capstable, key, value);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
326
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
327 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
328 }
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
329 xmlnode_free(capsdata);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
330 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
331
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
332 void jabber_caps_init(void)
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
333 {
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
334 nodetable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)jabber_caps_node_exts_unref);
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
335 capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, NULL, (GDestroyNotify)jabber_caps_client_info_destroy);
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
336 jabber_caps_load();
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
337 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
338
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
339 void jabber_caps_uninit(void)
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
340 {
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
341 if (save_timer != 0) {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
342 purple_timeout_remove(save_timer);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
343 save_timer = 0;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
344 do_jabber_caps_store(NULL);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
345 }
25190
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
346 g_hash_table_destroy(capstable);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25189
diff changeset
347 g_hash_table_destroy(nodetable);
26803
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26790
diff changeset
348 capstable = nodetable = NULL;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
349 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
350
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
351 gboolean jabber_caps_exts_known(const JabberCapsClientInfo *info,
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
352 char **exts)
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
353 {
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
354 int i;
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
355 g_return_val_if_fail(info != NULL, FALSE);
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
356
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
357 if (!exts)
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
358 return TRUE;
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
359
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
360 for (i = 0; exts[i]; ++i) {
26848
7d924c723d7e I forgot to finish this comment before coming back from dinner and committing.
Paul Aurich <paul@darkrain42.org>
parents: 26846
diff changeset
361 /* Hack since we advertise the ext along with v1.5 caps but don't
7d924c723d7e I forgot to finish this comment before coming back from dinner and committing.
Paul Aurich <paul@darkrain42.org>
parents: 26846
diff changeset
362 * store any exts */
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
363 if (g_str_equal(exts[i], "voice-v1") && !info->exts)
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
364 continue;
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
365 if (!info->exts ||
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
366 !g_hash_table_lookup(info->exts->exts, exts[i]))
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
367 return FALSE;
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
368 }
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
369
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
370 return TRUE;
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
371 }
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
372
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
373 typedef struct _jabber_caps_cbplususerdata {
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
374 guint ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
375
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
376 jabber_caps_get_info_cb cb;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
377 gpointer cb_data;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23703
diff changeset
378
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
379 char *who;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
380 char *node;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
381 char *ver;
25022
4c97156431b4 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25021
diff changeset
382 char *hash;
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
383
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
384 JabberCapsClientInfo *info;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
385
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
386 GList *exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
387 guint extOutstanding;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
388 JabberCapsNodeExts *node_exts;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
389 } jabber_caps_cbplususerdata;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
390
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
391 static jabber_caps_cbplususerdata*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
392 cbplususerdata_ref(jabber_caps_cbplususerdata *data)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
393 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
394 g_return_val_if_fail(data != NULL, NULL);
19725
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
395
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
396 ++data->ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
397 return data;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
398 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
399
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
400 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
401 cbplususerdata_unref(jabber_caps_cbplususerdata *data)
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
402 {
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
403 if (data == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
404 return;
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
405
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
406 g_return_if_fail(data->ref != 0);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
407
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
408 if (--data->ref > 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
409 return;
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
410
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
411 g_free(data->who);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
412 g_free(data->node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
413 g_free(data->ver);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
414 g_free(data->hash);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
415
25191
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
416 /* If we have info here, it's already in the capstable, so don't free it */
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
417 if (data->exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
418 free_string_glist(data->exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
419 if (data->node_exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
420 jabber_caps_node_exts_unref(data->node_exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
421 g_free(data);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
422 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
423
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
424 static void
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
425 jabber_caps_get_info_complete(jabber_caps_cbplususerdata *userdata)
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
426 {
26768
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
427 if (userdata->cb) {
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
428 userdata->cb(userdata->info, userdata->exts, userdata->cb_data);
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
429 userdata->info = NULL;
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
430 userdata->exts = NULL;
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
431 }
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
432
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
433 if (userdata->ref != 1)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
434 purple_debug_warning("jabber", "Lost a reference to caps cbdata: %d\n",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
435 userdata->ref);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
436 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
437
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
438 static void
26488
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
439 jabber_caps_client_iqcb(JabberStream *js, const char *from, JabberIqType type,
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
440 const char *id, xmlnode *packet, gpointer data)
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
441 {
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
442 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28439
diff changeset
443 NS_DISCO_INFO);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
444 jabber_caps_cbplususerdata *userdata = data;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
445 JabberCapsClientInfo *info = NULL, *value;
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
446 JabberCapsTuple key;
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
447
26488
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
448 if (!query || type == JABBER_IQ_ERROR) {
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
449 /* Any outstanding exts will be dealt with via ref-counting */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
450 userdata->cb(NULL, NULL, userdata->cb_data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
451 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
452 return;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
453 }
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
454
25157
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
455 /* check hash */
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
456 info = jabber_caps_parse_client_info(query);
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
457
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
458 /* Only validate if these are v1.5 capabilities */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
459 if (userdata->hash) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
460 gchar *hash = NULL;
27915
a40e0b43f57f This is annoying, but am I actually missing anything?
Paul Aurich <paul@darkrain42.org>
parents: 27150
diff changeset
461 /*
a40e0b43f57f This is annoying, but am I actually missing anything?
Paul Aurich <paul@darkrain42.org>
parents: 27150
diff changeset
462 * TODO: If you add *any* hash here, make sure the checksum buffer
a40e0b43f57f This is annoying, but am I actually missing anything?
Paul Aurich <paul@darkrain42.org>
parents: 27150
diff changeset
463 * size in jabber_caps_calculate_hash is large enough. The cipher API
a40e0b43f57f This is annoying, but am I actually missing anything?
Paul Aurich <paul@darkrain42.org>
parents: 27150
diff changeset
464 * doesn't seem to offer a "Get the hash size" function(?).
a40e0b43f57f This is annoying, but am I actually missing anything?
Paul Aurich <paul@darkrain42.org>
parents: 27150
diff changeset
465 */
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
466 if (!strcmp(userdata->hash, "sha-1")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
467 hash = jabber_caps_calculate_hash(info, "sha1");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
468 } else if (!strcmp(userdata->hash, "md5")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
469 hash = jabber_caps_calculate_hash(info, "md5");
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
470 }
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
471
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
472 if (!hash || strcmp(hash, userdata->ver)) {
28037
d905474475dc jabber: Print out the expected/generated caps hashes.
Paul Aurich <paul@darkrain42.org>
parents: 27915
diff changeset
473 purple_debug_warning("jabber", "Could not validate caps info from "
d905474475dc jabber: Print out the expected/generated caps hashes.
Paul Aurich <paul@darkrain42.org>
parents: 27915
diff changeset
474 "%s. Expected %s, got %s\n",
d905474475dc jabber: Print out the expected/generated caps hashes.
Paul Aurich <paul@darkrain42.org>
parents: 27915
diff changeset
475 xmlnode_get_attrib(packet, "from"),
d905474475dc jabber: Print out the expected/generated caps hashes.
Paul Aurich <paul@darkrain42.org>
parents: 27915
diff changeset
476 userdata->ver, hash ? hash : "(null)");
19725
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
477
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
478 userdata->cb(NULL, NULL, userdata->cb_data);
25191
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
479 jabber_caps_client_info_destroy(info);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
480 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
481 g_free(hash);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
482 return;
23703
d79c30d1582a Don't look up caps exts when the initial caps discovery wasn't successful.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21688
diff changeset
483 }
d79c30d1582a Don't look up caps exts when the initial caps discovery wasn't successful.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21688
diff changeset
484
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
485 g_free(hash);
25157
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
486 }
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
487
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
488 if (!userdata->hash && userdata->node_exts) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
489 /* If the ClientInfo doesn't have information about the exts, give them
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
490 * ours (along with our ref) */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
491 info->exts = userdata->node_exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
492 userdata->node_exts = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
493 }
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
494
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
495 key.node = userdata->node;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
496 key.ver = userdata->ver;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
497 key.hash = userdata->hash;
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
498
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
499 /* Use the copy of this data already in the table if it exists or insert
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
500 * a new one if we need to */
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
501 if ((value = g_hash_table_lookup(capstable, &key))) {
25191
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
502 jabber_caps_client_info_destroy(info);
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
503 info = value;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
504 } else {
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
505 JabberCapsTuple *n_key = (JabberCapsTuple *)&info->tuple;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
506 n_key->node = userdata->node;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
507 n_key->ver = userdata->ver;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
508 n_key->hash = userdata->hash;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
509 userdata->node = userdata->ver = userdata->hash = NULL;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
510
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
511 /* The capstable gets a reference */
25191
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
512 g_hash_table_insert(capstable, n_key, info);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
513 schedule_caps_save();
25157
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
514 }
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
515
25191
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
516 userdata->info = info;
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
517
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
518 if (userdata->extOutstanding == 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
519 jabber_caps_get_info_complete(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
520
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
521 cbplususerdata_unref(userdata);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
522 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
523
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
524 typedef struct {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
525 const char *name;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
526 jabber_caps_cbplususerdata *data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
527 } ext_iq_data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
528
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
529 static void
26488
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
530 jabber_caps_ext_iqcb(JabberStream *js, const char *from, JabberIqType type,
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
531 const char *id, xmlnode *packet, gpointer data)
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
532 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
533 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28439
diff changeset
534 NS_DISCO_INFO);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
535 xmlnode *child;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
536 ext_iq_data *userdata = data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
537 GList *features = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
538 JabberCapsNodeExts *node_exts;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
539
26488
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
540 if (!query || type == JABBER_IQ_ERROR) {
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
541 cbplususerdata_unref(userdata->data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
542 g_free(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
543 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
544 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
545
27149
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
546 node_exts = (userdata->data->info ? userdata->data->info->exts :
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
547 userdata->data->node_exts);
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
548
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
549 /* TODO: I don't see how this can actually happen, but it crashed khc. */
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
550 if (!node_exts) {
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
551 purple_debug_error("jabber", "Couldn't find JabberCapsNodeExts. If you "
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
552 "see this, please tell darkrain42 and save your debug log.\n"
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
553 "JabberCapsClientInfo = %p\n", userdata->data->info);
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
554
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
555
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
556 /* Try once more to find the exts and then fail */
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
557 node_exts = jabber_caps_find_exts_by_node(userdata->data->node);
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
558 if (node_exts) {
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
559 purple_debug_info("jabber", "Found the exts on the second try.\n");
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
560 if (userdata->data->info)
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
561 userdata->data->info->exts = node_exts;
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
562 else
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
563 userdata->data->node_exts = node_exts;
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
564 } else {
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
565 cbplususerdata_unref(userdata->data);
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
566 g_free(userdata);
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
567 g_return_if_reached();
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
568 }
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
569 }
e3907cfaeb02 Don't crash when the seemingly impossible occurs.
Paul Aurich <paul@darkrain42.org>
parents: 27148
diff changeset
570
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
571 /* So, we decrement this after checking for an error, which means that
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
572 * if there *is* an error, we'll never call the callback passed to
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
573 * jabber_caps_get_info. We will still free all of our data, though.
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
574 */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
575 --userdata->data->extOutstanding;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
576
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
577 for (child = xmlnode_get_child(query, "feature"); child;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
578 child = xmlnode_get_next_twin(child)) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
579 const char *var = xmlnode_get_attrib(child, "var");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
580 if (var)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
581 features = g_list_prepend(features, g_strdup(var));
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
582 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
583
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
584 g_hash_table_insert(node_exts->exts, g_strdup(userdata->name), features);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
585 schedule_caps_save();
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
586
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
587 /* Are we done? */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
588 if (userdata->data->info && userdata->data->extOutstanding == 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
589 jabber_caps_get_info_complete(userdata->data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
590
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
591 cbplususerdata_unref(userdata->data);
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
592 g_free(userdata);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
593 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
594
25150
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
595 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
596 const char *ver, const char *hash, char **exts,
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
597 jabber_caps_get_info_cb cb, gpointer user_data)
25150
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
598 {
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
599 JabberCapsClientInfo *info;
26845
70fdb6fc8aee Make the JabberCapsTuple (nee Key) available to the rest of the prpl
Paul Aurich <paul@darkrain42.org>
parents: 26816
diff changeset
600 JabberCapsTuple key;
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
601 jabber_caps_cbplususerdata *userdata;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
602
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
603 if (exts && hash) {
28149
cb8937a8a17f jabber: Reduce severity of "Ignoring exts..." message.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
604 purple_debug_misc("jabber", "Ignoring exts in new-style caps from %s\n",
cb8937a8a17f jabber: Reduce severity of "Ignoring exts..." message.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
605 who);
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
606 g_strfreev(exts);
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
607 exts = NULL;
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
608 }
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
609
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
610 /* Using this in a read-only fashion, so the cast is OK */
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
611 key.node = (char *)node;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
612 key.ver = (char *)ver;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
613 key.hash = (char *)hash;
19698
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17902
diff changeset
614
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
615 info = g_hash_table_lookup(capstable, &key);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
616 if (info && hash) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
617 /* v1.5 - We already have all the information we care about */
26768
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
618 if (cb)
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
619 cb(info, NULL, user_data);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
620 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
621 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
622
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
623 userdata = g_new0(jabber_caps_cbplususerdata, 1);
27148
0405276c6698 Fix a lost reference when we only fetch an unknown ext.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
624 /* We start out with 0 references. Every query takes one */
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
625 userdata->cb = cb;
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
626 userdata->cb_data = user_data;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
627 userdata->who = g_strdup(who);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
628 userdata->node = g_strdup(node);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
629 userdata->ver = g_strdup(ver);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
630 userdata->hash = g_strdup(hash);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
631
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
632 if (info) {
25191
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25190
diff changeset
633 userdata->info = info;
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
634 } else {
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
635 /* If we don't have the basic information about the client, we need
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
636 * to fetch it. */
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
637 JabberIq *iq;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
638 xmlnode *query;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
639 char *nodever;
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
640
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28439
diff changeset
641 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO);
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
642 query = xmlnode_get_child_with_namespace(iq->node, "query",
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28439
diff changeset
643 NS_DISCO_INFO);
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
644 nodever = g_strdup_printf("%s#%s", node, ver);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
645 xmlnode_set_attrib(query, "node", nodever);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
646 g_free(nodever);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
647 xmlnode_set_attrib(iq->node, "to", who);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
648
27148
0405276c6698 Fix a lost reference when we only fetch an unknown ext.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
649 cbplususerdata_ref(userdata);
0405276c6698 Fix a lost reference when we only fetch an unknown ext.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
650
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
651 jabber_iq_set_callback(iq, jabber_caps_client_iqcb, userdata);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
652 jabber_iq_send(iq);
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
653 }
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
654
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
655 /* Are there any exts that we don't recognize? */
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
656 if (exts) {
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
657 JabberCapsNodeExts *node_exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
658 int i;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
659
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
660 if (info) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
661 if (info->exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
662 node_exts = info->exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
663 else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
664 node_exts = info->exts = jabber_caps_find_exts_by_node(node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
665 } else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
666 /* We'll put it in later once we have the client info */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
667 node_exts = userdata->node_exts = jabber_caps_find_exts_by_node(node);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
668
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
669 for (i = 0; exts[i]; ++i) {
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
670 userdata->exts = g_list_prepend(userdata->exts, exts[i]);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
671 /* Look it up if we don't already know what it means */
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
672 if (!g_hash_table_lookup(node_exts->exts, exts[i])) {
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
673 JabberIq *iq;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
674 xmlnode *query;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
675 char *nodeext;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
676 ext_iq_data *cbdata = g_new(ext_iq_data, 1);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
677
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
678 cbdata->name = exts[i];
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
679 cbdata->data = cbplususerdata_ref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
680
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28439
diff changeset
681 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
682 query = xmlnode_get_child_with_namespace(iq->node, "query",
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28439
diff changeset
683 NS_DISCO_INFO);
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
684 nodeext = g_strdup_printf("%s#%s", node, exts[i]);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
685 xmlnode_set_attrib(query, "node", nodeext);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
686 g_free(nodeext);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
687 xmlnode_set_attrib(iq->node, "to", who);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
688
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
689 jabber_iq_set_callback(iq, jabber_caps_ext_iqcb, cbdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
690 jabber_iq_send(iq);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
691
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
692 ++userdata->extOutstanding;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
693 }
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
694 exts[i] = NULL;
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
695 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
696 /* All the strings are now part of the GList, so don't need
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
697 * g_strfreev. */
26846
d0a049ede31e Only call jabber_caps_get_info if we don't have all the information we want.
Paul Aurich <paul@darkrain42.org>
parents: 26845
diff changeset
698 g_free(exts);
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
699 }
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
700
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
701 if (userdata->info && userdata->extOutstanding == 0) {
27150
3b2a2469ffbf This works better.
Paul Aurich <paul@darkrain42.org>
parents: 27149
diff changeset
702 /* Start with 1 ref so the below functions are happy */
3b2a2469ffbf This works better.
Paul Aurich <paul@darkrain42.org>
parents: 27149
diff changeset
703 userdata->ref = 1;
3b2a2469ffbf This works better.
Paul Aurich <paul@darkrain42.org>
parents: 27149
diff changeset
704
27148
0405276c6698 Fix a lost reference when we only fetch an unknown ext.
Paul Aurich <paul@darkrain42.org>
parents: 26932
diff changeset
705 /* We have everything we need right now */
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
706 jabber_caps_get_info_complete(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
707 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
708 }
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
709 }
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
710
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
711 static gint
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
712 jabber_identity_compare(gconstpointer a, gconstpointer b)
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
713 {
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
714 const JabberIdentity *ac;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
715 const JabberIdentity *bc;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
716 gint cat_cmp;
25019
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
717 gint typ_cmp;
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
718
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
719 ac = a;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
720 bc = b;
19725
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
721
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
722 if ((cat_cmp = strcmp(ac->category, bc->category)) == 0) {
25019
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
723 if ((typ_cmp = strcmp(ac->type, bc->type)) == 0) {
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
724 if (!ac->lang && !bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
725 return 0;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
726 } else if (ac->lang && !bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
727 return 1;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
728 } else if (!ac->lang && bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
729 return -1;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
730 } else {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
731 return strcmp(ac->lang, bc->lang);
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
732 }
25019
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
733 } else {
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
734 return typ_cmp;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
735 }
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
736 } else {
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
737 return cat_cmp;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
738 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
739 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
740
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
741 static gchar *jabber_caps_get_formtype(const xmlnode *x) {
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
742 xmlnode *formtypefield;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
743 formtypefield = xmlnode_get_child(x, "field");
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
744 while (formtypefield && strcmp(xmlnode_get_attrib(formtypefield, "var"), "FORM_TYPE")) formtypefield = xmlnode_get_next_twin(formtypefield);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
745 formtypefield = xmlnode_get_child(formtypefield, "value");
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
746 return xmlnode_get_data(formtypefield);;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
747 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
748
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
749 static gint
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
750 jabber_xdata_compare(gconstpointer a, gconstpointer b)
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
751 {
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
752 const xmlnode *aformtypefield = a;
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
753 const xmlnode *bformtypefield = b;
25020
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
754 char *aformtype;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
755 char *bformtype;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
756 int result;
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
757
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
758 aformtype = jabber_caps_get_formtype(aformtypefield);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
759 bformtype = jabber_caps_get_formtype(bformtypefield);
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
760
25020
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
761 result = strcmp(aformtype, bformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
762 g_free(aformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
763 g_free(bformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
764 return result;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
765 }
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
766
25162
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
767 static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query)
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
768 {
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
769 xmlnode *child;
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
770 JabberCapsClientInfo *info;
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
771
28650
9ae3e70a327b jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents: 28439
diff changeset
772 if (!query || strcmp(query->xmlns, NS_DISCO_INFO))
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
773 return 0;
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
774
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
775 info = g_new0(JabberCapsClientInfo, 1);
25187
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25186
diff changeset
776
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
777 for(child = query->child; child; child = child->next) {
26749
b1f8cebaab17 Skip iterating non-node children; thanks to Marcus for crashing me.
Paul Aurich <paul@darkrain42.org>
parents: 26661
diff changeset
778 if (child->type != XMLNODE_TYPE_TAG)
b1f8cebaab17 Skip iterating non-node children; thanks to Marcus for crashing me.
Paul Aurich <paul@darkrain42.org>
parents: 26661
diff changeset
779 continue;
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
780 if (!strcmp(child->name,"identity")) {
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
781 /* parse identity */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
782 const char *category = xmlnode_get_attrib(child, "category");
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
783 const char *type = xmlnode_get_attrib(child, "type");
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
784 const char *name = xmlnode_get_attrib(child, "name");
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
785 const char *lang = xmlnode_get_attrib(child, "lang");
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
786 JabberIdentity *id;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
787
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
788 if (!category || !type)
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
789 continue;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
790
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
791 id = g_new0(JabberIdentity, 1);
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
792 id->category = g_strdup(category);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
793 id->type = g_strdup(type);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
794 id->name = g_strdup(name);
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
795 id->lang = g_strdup(lang);
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
796
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
797 info->identities = g_list_append(info->identities, id);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
798 } else if (!strcmp(child->name, "feature")) {
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
799 /* parse feature */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
800 const char *var = xmlnode_get_attrib(child, "var");
25189
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
801 if (var)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25188
diff changeset
802 info->features = g_list_prepend(info->features, g_strdup(var));
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
803 } else if (!strcmp(child->name, "x")) {
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
804 if (child->xmlns && !strcmp(child->xmlns, "jabber:x:data")) {
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
805 /* x-data form */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
806 xmlnode *dataform = xmlnode_copy(child);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
807 info->forms = g_list_append(info->forms, dataform);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
808 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
809 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
810 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
811 return info;
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
812 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
813
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
814 static gint jabber_caps_xdata_field_compare(gconstpointer a, gconstpointer b)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
815 {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
816 const JabberDataFormField *ac = a;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
817 const JabberDataFormField *bc = b;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
818
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
819 return strcmp(ac->var, bc->var);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
820 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
821
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
822 static GList* jabber_caps_xdata_get_fields(const xmlnode *x)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
823 {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
824 GList *fields = NULL;
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
825 xmlnode *field;
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
826
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
827 if (!x)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
828 return NULL;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
829
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
830 for (field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
831 xmlnode *value;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
832 JabberDataFormField *xdatafield = g_new0(JabberDataFormField, 1);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
833 xdatafield->var = g_strdup(xmlnode_get_attrib(field, "var"));
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
834
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
835 for (value = xmlnode_get_child(field, "value"); value; value = xmlnode_get_next_twin(value)) {
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
836 gchar *val = xmlnode_get_data(value);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
837 xdatafield->values = g_list_append(xdatafield->values, val);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
838 }
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
839
25152
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25150
diff changeset
840 xdatafield->values = g_list_sort(xdatafield->values, (GCompareFunc)strcmp);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
841 fields = g_list_append(fields, xdatafield);
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
842 }
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
843
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
844 fields = g_list_sort(fields, jabber_caps_xdata_field_compare);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
845 return fields;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
846 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
847
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
848 static GString*
26771
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
849 jabber_caps_verification_append(GString *verification, const gchar *str)
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
850 {
26772
ab31daf1c1ee Sadrul pointed me at g_markup_escape_text, thanks!
Paul Aurich <paul@darkrain42.org>
parents: 26771
diff changeset
851 char *tmp = g_markup_escape_text(str, -1);
26771
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
852 verification = g_string_append(verification, tmp);
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
853 g_free(tmp);
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
854 return g_string_append_c(verification, '<');
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
855 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
856
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
857 gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash)
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
858 {
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
859 GList *node;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
860 GString *verification;
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
861 PurpleCipherContext *context;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
862 guint8 checksum[20];
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
863 gsize checksum_size = 20;
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
864 gboolean success;
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
865
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
866 if (!info || !(context = purple_cipher_context_new_by_name(hash, NULL)))
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
867 return NULL;
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
868
25020
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
869 /* sort identities, features and x-data forms */
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
870 info->identities = g_list_sort(info->identities, jabber_identity_compare);
25152
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25150
diff changeset
871 info->features = g_list_sort(info->features, (GCompareFunc)strcmp);
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
872 info->forms = g_list_sort(info->forms, jabber_xdata_compare);
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
873
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
874 verification = g_string_new("");
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
875
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
876 /* concat identities to the verification string */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
877 for (node = info->identities; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
878 JabberIdentity *id = (JabberIdentity*)node->data;
26772
ab31daf1c1ee Sadrul pointed me at g_markup_escape_text, thanks!
Paul Aurich <paul@darkrain42.org>
parents: 26771
diff changeset
879 char *category = g_markup_escape_text(id->category, -1);
ab31daf1c1ee Sadrul pointed me at g_markup_escape_text, thanks!
Paul Aurich <paul@darkrain42.org>
parents: 26771
diff changeset
880 char *type = g_markup_escape_text(id->type, -1);
26790
6a177edc401e Avoid a g_markup_escape_text assertion failure
Paul Aurich <paul@darkrain42.org>
parents: 26772
diff changeset
881 char *lang = NULL;
6a177edc401e Avoid a g_markup_escape_text assertion failure
Paul Aurich <paul@darkrain42.org>
parents: 26772
diff changeset
882 char *name = NULL;
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
883
26790
6a177edc401e Avoid a g_markup_escape_text assertion failure
Paul Aurich <paul@darkrain42.org>
parents: 26772
diff changeset
884 if (id->lang)
6a177edc401e Avoid a g_markup_escape_text assertion failure
Paul Aurich <paul@darkrain42.org>
parents: 26772
diff changeset
885 lang = g_markup_escape_text(id->lang, -1);
6a177edc401e Avoid a g_markup_escape_text assertion failure
Paul Aurich <paul@darkrain42.org>
parents: 26772
diff changeset
886 if (id->name)
6a177edc401e Avoid a g_markup_escape_text assertion failure
Paul Aurich <paul@darkrain42.org>
parents: 26772
diff changeset
887 name = g_markup_escape_text(id->name, -1);
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
888
26771
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
889 g_string_append_printf(verification, "%s/%s/%s/%s<", category,
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
890 type, lang ? lang : "", name ? name : "");
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
891
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
892 g_free(category);
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
893 g_free(type);
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
894 g_free(lang);
e72df47d41fe Escape all the values when appending them to the Entity Caps verification str.
Paul Aurich <paul@darkrain42.org>
parents: 26768
diff changeset
895 g_free(name);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
896 }
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
897
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
898 /* concat features to the verification string */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
899 for (node = info->features; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
900 verification = jabber_caps_verification_append(verification, node->data);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
901 }
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
902
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
903 /* concat x-data forms to the verification string */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
904 for(node = info->forms; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
905 xmlnode *data = (xmlnode *)node->data;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
906 gchar *formtype = jabber_caps_get_formtype(data);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
907 GList *fields = jabber_caps_xdata_get_fields(data);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
908
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
909 /* append FORM_TYPE's field value to the verification string */
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
910 verification = jabber_caps_verification_append(verification, formtype);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
911 g_free(formtype);
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
912
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
913 while (fields) {
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
914 GList *value;
26932
a8537bbcfb79 Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents: 26848
diff changeset
915 JabberDataFormField *field = (JabberDataFormField*)fields->data;
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
916
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
917 if (strcmp(field->var, "FORM_TYPE")) {
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
918 /* Append the "var" attribute */
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
919 verification = jabber_caps_verification_append(verification, field->var);
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
920 /* Append <value/> elements' cdata */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
921 for(value = field->values; value; value = value->next) {
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
922 verification = jabber_caps_verification_append(verification, value->data);
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
923 g_free(value->data);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
924 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
925 }
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
926
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
927 g_free(field->var);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
928 g_list_free(field->values);
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
929
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
930 fields = g_list_delete_link(fields, fields);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
931 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
932 }
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
933
25024
fd19927e2b64 * support for calculating both hashes, sha-1 and md5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25022
diff changeset
934 /* generate hash */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
935 purple_cipher_context_append(context, (guchar*)verification->str, verification->len);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
936
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
937 success = purple_cipher_context_digest(context, verification->len,
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
938 checksum, &checksum_size);
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
939
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
940 g_string_free(verification, TRUE);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
941 purple_cipher_context_destroy(context);
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
942
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
943 return (success ? purple_base64_encode(checksum, checksum_size) : NULL);
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
944 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
945
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
946 void jabber_caps_calculate_own_hash(JabberStream *js) {
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
947 JabberCapsClientInfo info;
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
948 GList *iter = 0;
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
949 GList *features = 0;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
950
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
951 if (!jabber_identities && !jabber_features) {
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
952 /* This really shouldn't ever happen */
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
953 purple_debug_warning("jabber", "No features or identities, cannot calculate own caps hash.\n");
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
954 g_free(js->caps_hash);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
955 js->caps_hash = NULL;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
956 return;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
957 }
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
958
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
959 /* build the currently-supported list of features */
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
960 if (jabber_features) {
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
961 for (iter = jabber_features; iter; iter = iter->next) {
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
962 JabberFeature *feat = iter->data;
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
963 if(!feat->is_enabled || feat->is_enabled(js, feat->namespace)) {
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
964 features = g_list_append(features, feat->namespace);
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
965 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
966 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
967 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
968
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
969 info.features = features;
26768
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
970 info.identities = g_list_copy(jabber_identities);
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
971 info.forms = NULL;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
972
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
973 g_free(js->caps_hash);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
974 js->caps_hash = jabber_caps_calculate_hash(&info, "sha1");
26768
966d2f2f86c8 Don't crash when the caps cb is NULL and don't corrupt jabber_identities
Paul Aurich <paul@darkrain42.org>
parents: 26749
diff changeset
975 g_list_free(info.identities);
28439
edf17df87055 jabber: Plug another leak.
Paul Aurich <paul@darkrain42.org>
parents: 28149
diff changeset
976 g_list_free(info.features);
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
977 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
978
25146
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
979 const gchar* jabber_caps_get_own_hash(JabberStream *js)
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
980 {
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
981 if (!js->caps_hash)
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
982 jabber_caps_calculate_own_hash(js);
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
983
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
984 return js->caps_hash;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
985 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
986
25147
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
987 void jabber_caps_broadcast_change()
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
988 {
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
989 GList *node, *accounts = purple_accounts_get_all_active();
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
990
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
991 for (node = accounts; node; node = node->next) {
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
992 PurpleAccount *account = node->data;
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
993 const char *prpl_id = purple_account_get_protocol_id(account);
25148
6adbaf3d25e3 Fix a null dereference on non-connected accounts
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
994 if (!strcmp("prpl-jabber", prpl_id) && purple_account_is_connected(account)) {
25147
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
995 PurpleConnection *gc = purple_account_get_connection(account);
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
996 jabber_presence_send(gc->proto_data, TRUE);
25032
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
997 }
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
998 }
25147
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
999
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
1000 g_list_free(accounts);
25032
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
1001 }
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
1002