annotate libpurple/protocols/jabber/caps.c @ 26743:de9816c970fe

Use purple_strequal and g_str_equal
author Paul Aurich <paul@darkrain42.org>
date Sat, 18 Apr 2009 18:17:16 +0000
parents 061df5754d20
children b1f8cebaab17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17609
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 *
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
4 * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com>
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
5 *
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
6 * 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
7 * 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
8 * 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
9 * (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
10 *
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 * 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
12 * 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
13 * 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
14 * 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
15 *
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 * 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
17 * along with this program; if not, write to the Free Software
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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 *
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
20 */
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
19697
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17629
diff changeset
22 #include "internal.h"
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17629
diff changeset
23
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
24 #include "debug.h"
17609
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
25 #include "caps.h"
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
26 #include "cipher.h"
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
27 #include "iq.h"
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
28 #include "presence.h"
17609
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
29 #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
30
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 #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
32
25758
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: 25757
diff changeset
33 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: 25757
diff changeset
34 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: 25757
diff changeset
35 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: 25757
diff changeset
36 } JabberDataFormField;
17609
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
37
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
38 typedef struct _JabberCapsKey {
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 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
40 char *ver;
25758
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: 25757
diff changeset
41 char *hash;
17609
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
42 } JabberCapsKey;
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
25762
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
44 static GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsClientInfo */
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
45 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: 25783
diff changeset
46 static guint save_timer = 0;
17609
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
47
25758
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: 25757
diff changeset
48 /**
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: 25757
diff changeset
49 * Processes a query-node and returns a JabberCapsClientInfo object with all relevant info.
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: 25757
diff changeset
50 *
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: 25757
diff changeset
51 * @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: 25757
diff changeset
52 * @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: 25757
diff changeset
53 */
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: 25757
diff changeset
54 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: 25757
diff changeset
55
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
56 /* Free a GList of allocated char* */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
57 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
58 free_string_glist(GList *list)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
59 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
60 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: 25783
diff changeset
61 g_list_free(list);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
62 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
63
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
64 static JabberCapsNodeExts*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
65 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: 25783
diff changeset
66 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
67 g_return_val_if_fail(exts != NULL, NULL);
17609
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
68
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
69 ++exts->ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
70 return exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
71 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
72
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
73 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
74 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: 25783
diff changeset
75 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
76 if (exts == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
77 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
78
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
79 g_return_if_fail(exts->ref != 0);
17609
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
80
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
81 if (--exts->ref != 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
82 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
83
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
84 g_hash_table_destroy(exts->exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
85 g_free(exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
86 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
87
25783
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
88 static guint jabber_caps_hash(gconstpointer data) {
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
89 const JabberCapsKey *key = data;
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
90 guint nodehash = g_str_hash(key->node);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
91 guint verhash = g_str_hash(key->ver);
26743
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26570
diff changeset
92 /*
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26570
diff changeset
93 * '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: 26570
diff changeset
94 * 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: 26570
diff changeset
95 * a Deku Shrub...
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26570
diff changeset
96 */
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
97 guint hashhash = (key->hash ? g_str_hash(key->hash) : 0);
25585
45816181b7de * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25584
diff changeset
98 return nodehash ^ verhash ^ hashhash;
17609
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
99 }
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
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
101 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) {
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
102 const JabberCapsKey *name1 = v1;
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
103 const JabberCapsKey *name2 = v2;
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
26743
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26570
diff changeset
105 return g_str_equal(name1->node, name2->node) &&
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26570
diff changeset
106 g_str_equal(name1->ver, name2->ver) &&
de9816c970fe Use purple_strequal and g_str_equal
Paul Aurich <paul@darkrain42.org>
parents: 26570
diff changeset
107 purple_strequal(name1->hash, name2->hash);
17609
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
108 }
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
109
25783
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
110 void jabber_caps_destroy_key(gpointer data) {
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
111 JabberCapsKey *key = data;
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
112 g_free(key->node);
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
113 g_free(key->ver);
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
114 g_free(key->hash);
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
115 g_free(key);
17609
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 }
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
117
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
118 static void
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
119 jabber_caps_client_info_destroy(JabberCapsClientInfo *info)
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
120 {
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
121 if (info == NULL)
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
122 return;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
123
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
124 while(info->identities) {
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
125 JabberIdentity *id = info->identities->data;
17609
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
126 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
127 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
128 g_free(id->name);
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
129 g_free(id->lang);
17609
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
130 g_free(id);
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
131 info->identities = g_list_delete_link(info->identities, info->identities);
17609
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
132 }
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
133
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
134 free_string_glist(info->features);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
135 free_string_glist(info->forms);
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
136
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
137 jabber_caps_node_exts_unref(info->exts);
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
138
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
139 g_free(info);
17609
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
140 }
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
141
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
142 /* 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: 25783
diff changeset
143 * keep it around. */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
144 static JabberCapsNodeExts*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
145 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: 25783
diff changeset
146 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
147 JabberCapsNodeExts *exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
148 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: 25783
diff changeset
149 exts = g_new0(JabberCapsNodeExts, 1);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
150 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: 25783
diff changeset
151 (GDestroyNotify)free_string_glist);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
152 g_hash_table_insert(nodetable, g_strdup(node), jabber_caps_node_exts_ref(exts));
17609
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
153 }
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
154
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
155 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: 25783
diff changeset
156 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
157
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
158 static void
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
159 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: 25784
diff changeset
160 {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
161 const char *identifier = key;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
162 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: 25784
diff changeset
163 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: 25784
diff changeset
164
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
165 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: 25784
diff changeset
166 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: 25784
diff changeset
167
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
168 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: 25784
diff changeset
169 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: 25784
diff changeset
170 xmlnode_set_attrib(feature, "var", (const gchar *)node->data);
17609
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
171 }
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
172 }
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
173
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
174 static void jabber_caps_store_client(gpointer key, gpointer value, gpointer user_data) {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
175 JabberCapsKey *clientinfo = key;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
176 JabberCapsClientInfo *props = value;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
177 xmlnode *root = user_data;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
178 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: 25784
diff changeset
179 GList *iter;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
180
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
181 xmlnode_set_attrib(client, "node", clientinfo->node);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
182 xmlnode_set_attrib(client, "ver", clientinfo->ver);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
183 if (clientinfo->hash)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
184 xmlnode_set_attrib(client, "hash", clientinfo->hash);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
185 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: 25784
diff changeset
186 JabberIdentity *id = iter->data;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
187 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: 25784
diff changeset
188 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: 25784
diff changeset
189 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: 25784
diff changeset
190 if (id->name)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
191 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: 25784
diff changeset
192 if (id->lang)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
193 xmlnode_set_attrib(identity, "lang", id->lang);
17609
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
194 }
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
195
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
196 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: 25784
diff changeset
197 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: 25784
diff changeset
198 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: 25784
diff changeset
199 xmlnode_set_attrib(feature, "var", feat);
17609
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
200 }
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
201
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
202 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: 25784
diff changeset
203 /* FIXME: See #7814 */
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
204 xmlnode *xdata = iter->data;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
205 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: 25784
diff changeset
206 }
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
207
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
208 /* 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: 25784
diff changeset
209 if (props->exts)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
210 g_hash_table_foreach(props->exts->exts, (GHFunc)exts_to_xmlnode, client);
17609
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
211 }
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
212
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
213 static gboolean
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
214 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: 25784
diff changeset
215 {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
216 char *str;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
217 int length = 0;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
218 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: 25784
diff changeset
219 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: 25784
diff changeset
220 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: 25784
diff changeset
221 xmlnode_free(root);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
222 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: 25784
diff changeset
223 g_free(str);
17609
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
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
225 save_timer = 0;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
226 return FALSE;
17609
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
227 }
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
228
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
229 static void
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
230 schedule_caps_save(void)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
231 {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
232 if (save_timer == 0)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
233 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: 25784
diff changeset
234 }
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
235
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
236 static void
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
237 jabber_caps_load(void)
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
238 {
17609
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 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
240 xmlnode *client;
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
241
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
242 if(!capsdata)
17609
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
243 return;
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
244
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
245 if (strcmp(capsdata->name, "capabilities") != 0) {
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
246 xmlnode_free(capsdata);
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
247 return;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
248 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
249
17609
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
250 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
251 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
252 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
253 if(!strcmp(client->name, "client")) {
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 JabberCapsKey *key = g_new0(JabberCapsKey, 1);
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
255 JabberCapsClientInfo *value = g_new0(JabberCapsClientInfo, 1);
17609
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
256 xmlnode *child;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
257 JabberCapsNodeExts *exts = NULL;
17609
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
258 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
259 key->ver = g_strdup(xmlnode_get_attrib(client,"ver"));
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
260 key->hash = g_strdup(xmlnode_get_attrib(client,"hash"));
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
261
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
262 /* v1.3 capabilities */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
263 if (key->hash == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
264 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: 25783
diff changeset
265
17609
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 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
267 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
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 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
270 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
271 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
272 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
273 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
274 } 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
275 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
276 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
277 const char *name = xmlnode_get_attrib(child, "name");
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
278 const char *lang = xmlnode_get_attrib(child, "lang");
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
279 JabberIdentity *id;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
280
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
281 if (!category || !type)
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
282 continue;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
283
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
284 id = g_new0(JabberIdentity, 1);
17609
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
285 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
286 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
287 id->name = g_strdup(name);
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
288 id->lang = g_strdup(lang);
17609
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
289
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
290 value->identities = g_list_append(value->identities,id);
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
291 } else if(!strcmp(child->name,"x")) {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
292 /* FIXME: See #7814 -- this will cause problems if anyone
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
293 * 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: 25783
diff changeset
294 * 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: 25783
diff changeset
295 * xmlnode_from_str, not the output version... */
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
296 value->forms = g_list_append(value->forms, xmlnode_copy(child));
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
297 } 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: 25783
diff changeset
298 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: 25783
diff changeset
299 } else if (!strcmp(child->name, "ext")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
300 /* TODO: Do we care about reading in the identities listed here? */
17609
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
301 const char *identifier = xmlnode_get_attrib(child, "identifier");
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
302 xmlnode *node;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
303 GList *features = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
304
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
305 if (!identifier)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
306 continue;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
307
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
308 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: 25783
diff changeset
309 if (node->type != XMLNODE_TYPE_TAG)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
310 continue;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
311 if (!strcmp(node->name, "feature")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
312 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: 25783
diff changeset
313 if (!var)
17609
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
314 continue;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
315 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: 25783
diff changeset
316 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
317 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
318
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
319 if (features) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
320 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: 25783
diff changeset
321 features);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
322 } else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
323 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: 25783
diff changeset
324 identifier);
17609
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 }
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
326 }
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
327
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
328 value->exts = exts;
17609
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
329 g_hash_table_replace(capstable, key, value);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
330
17609
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 }
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
332 }
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
333 xmlnode_free(capsdata);
17609
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
334 }
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
335
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
336 void jabber_caps_init(void)
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
337 {
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
338 nodetable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)jabber_caps_node_exts_unref);
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
339 capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, jabber_caps_destroy_key, (GDestroyNotify)jabber_caps_client_info_destroy);
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
340 jabber_caps_load();
17609
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
341 }
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
342
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
343 void jabber_caps_uninit(void)
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
344 {
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
345 if (save_timer != 0) {
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
346 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: 25784
diff changeset
347 save_timer = 0;
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
348 do_jabber_caps_store(NULL);
17609
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 }
25785
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
350 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: 25784
diff changeset
351 g_hash_table_destroy(nodetable);
3bec4f4db198 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <paul@darkrain42.org>
parents: 25784
diff changeset
352 capstable = NULL;
17609
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
353 }
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
354
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
355 typedef struct _jabber_caps_cbplususerdata {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
356 guint ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
357
17609
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
358 jabber_caps_get_info_cb cb;
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
359 gpointer cb_data;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23765
diff changeset
360
17609
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
361 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
362 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
363 char *ver;
25580
4c97156431b4 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25579
diff changeset
364 char *hash;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
365
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
366 JabberCapsClientInfo *info;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
367
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
368 GList *exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
369 guint extOutstanding;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
370 JabberCapsNodeExts *node_exts;
17609
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
371 } 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
372
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
373 static jabber_caps_cbplususerdata*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
374 cbplususerdata_ref(jabber_caps_cbplususerdata *data)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
375 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
376 g_return_val_if_fail(data != NULL, NULL);
19724
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: 19721
diff changeset
377
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
378 ++data->ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
379 return data;
17609
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 }
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
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
382 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
383 cbplususerdata_unref(jabber_caps_cbplususerdata *data)
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
384 {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
385 if (data == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
386 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
387
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
388 g_return_if_fail(data->ref != 0);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
389
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
390 if (--data->ref > 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
391 return;
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
392
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
393 g_free(data->who);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
394 g_free(data->node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
395 g_free(data->ver);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
396 g_free(data->hash);
17609
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
397
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
398 /* If we have info here, it's already in the capstable, so don't free it */
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
399 if (data->exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
400 free_string_glist(data->exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
401 if (data->node_exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
402 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: 25783
diff changeset
403 g_free(data);
17609
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
404 }
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
405
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
406 static void
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
407 jabber_caps_get_info_complete(jabber_caps_cbplususerdata *userdata)
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
408 {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
409 userdata->cb(userdata->info, userdata->exts, userdata->cb_data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
410 userdata->info = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
411 userdata->exts = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
412
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
413 if (userdata->ref != 1)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
414 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: 25783
diff changeset
415 userdata->ref);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
416 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
417
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
418 static void
26570
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
419 jabber_caps_client_iqcb(JabberStream *js, const char *from, JabberIqType type,
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
420 const char *id, xmlnode *packet, gpointer data)
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
421 {
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
422 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
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
423 "http://jabber.org/protocol/disco#info");
17609
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
424 jabber_caps_cbplususerdata *userdata = data;
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
425 JabberCapsClientInfo *info = NULL, *value;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
426 JabberCapsKey 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
427
26570
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
428 if (!query || type == JABBER_IQ_ERROR) {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
429 /* 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: 25783
diff changeset
430 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: 25783
diff changeset
431 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
432 return;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
433 }
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
434
25753
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25752
diff changeset
435 /* check hash */
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25752
diff changeset
436 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
437
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
438 /* 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: 25783
diff changeset
439 if (userdata->hash) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
440 gchar *hash = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
441 if (!strcmp(userdata->hash, "sha-1")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
442 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: 25783
diff changeset
443 } else if (!strcmp(userdata->hash, "md5")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
444 hash = jabber_caps_calculate_hash(info, "md5");
17609
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
445 }
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
446
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
447 if (!hash || strcmp(hash, userdata->ver)) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
448 purple_debug_warning("jabber", "Could not validate caps info from %s\n",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
449 xmlnode_get_attrib(packet, "from"));
19724
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: 19721
diff changeset
450
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
451 userdata->cb(NULL, NULL, userdata->cb_data);
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
452 jabber_caps_client_info_destroy(info);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
453 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
454 g_free(hash);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
455 return;
23765
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
456 }
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
457
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
458 g_free(hash);
25753
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25752
diff changeset
459 }
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
460
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
461 if (!userdata->hash && userdata->node_exts) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
462 /* 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: 25783
diff changeset
463 * ours (along with our ref) */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
464 info->exts = userdata->node_exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
465 userdata->node_exts = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
466 }
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
467
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
468 key.node = userdata->node;
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
469 key.ver = userdata->ver;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
470 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
471
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
472 /* 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: 25765
diff changeset
473 * a new one if we need to */
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
474 if ((value = g_hash_table_lookup(capstable, &key))) {
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
475 jabber_caps_client_info_destroy(info);
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
476 info = value;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
477 } else {
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
478 JabberCapsKey *n_key = g_new(JabberCapsKey, 1);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
479 n_key->node = userdata->node;
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
480 n_key->ver = userdata->ver;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
481 n_key->hash = userdata->hash;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
482 userdata->node = userdata->ver = userdata->hash = NULL;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
483
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
484 /* The capstable gets a reference */
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
485 g_hash_table_insert(capstable, n_key, info);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
486 schedule_caps_save();
25753
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25752
diff changeset
487 }
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
488
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
489 userdata->info = info;
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
490
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
491 if (userdata->extOutstanding == 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
492 jabber_caps_get_info_complete(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
493
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
494 cbplususerdata_unref(userdata);
17609
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
495 }
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
496
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
497 typedef struct {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
498 const char *name;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
499 jabber_caps_cbplususerdata *data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
500 } ext_iq_data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
501
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
502 static void
26570
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
503 jabber_caps_ext_iqcb(JabberStream *js, const char *from, JabberIqType type,
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
504 const char *id, xmlnode *packet, gpointer data)
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
505 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
506 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
507 "http://jabber.org/protocol/disco#info");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
508 xmlnode *child;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
509 ext_iq_data *userdata = data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
510 GList *features = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
511 JabberCapsNodeExts *node_exts;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
512
26570
061df5754d20 Fix up the propagate
Paul Aurich <paul@darkrain42.org>
parents: 26569
diff changeset
513 if (!query || type == JABBER_IQ_ERROR) {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
514 cbplususerdata_unref(userdata->data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
515 g_free(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
516 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
517 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
518
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
519 /* 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: 25783
diff changeset
520 * 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: 25783
diff changeset
521 * 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: 25783
diff changeset
522 */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
523 --userdata->data->extOutstanding;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
524
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
525 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: 25783
diff changeset
526 child = xmlnode_get_next_twin(child)) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
527 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: 25783
diff changeset
528 if (var)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
529 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: 25783
diff changeset
530 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
531
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
532 node_exts = (userdata->data->info ? userdata->data->info->exts :
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
533 userdata->data->node_exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
534 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: 25783
diff changeset
535 schedule_caps_save();
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
536
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
537 /* Are we done? */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
538 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: 25783
diff changeset
539 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: 25783
diff changeset
540
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
541 cbplususerdata_unref(userdata->data);
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
542 g_free(userdata);
17609
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
543 }
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
544
25746
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
545 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
546 const char *ver, const char *hash, const char *ext,
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
547 jabber_caps_get_info_cb cb, gpointer user_data)
25746
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
548 {
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
549 JabberCapsClientInfo *info;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
550 JabberCapsKey key;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
551 jabber_caps_cbplususerdata *userdata;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
552
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
553 if (ext && *ext && hash)
26539
20743d9bd62d Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <paul@darkrain42.org>
parents: 26528
diff changeset
554 purple_debug_info("jabber", "Ignoring exts in new-style caps from %s\n",
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
555 who);
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
556
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
557 /* 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: 25781
diff changeset
558 key.node = (char *)node;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
559 key.ver = (char *)ver;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
560 key.hash = (char *)hash;
19697
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17629
diff changeset
561
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
562 info = g_hash_table_lookup(capstable, &key);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
563 if (info && hash) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
564 /* v1.5 - We already have all the information we care about */
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
565 cb(info, NULL, user_data);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
566 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
567 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
568
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
569 userdata = g_new0(jabber_caps_cbplususerdata, 1);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
570 /* This ref is given to fetching the basic node#ver info if we need it
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
571 * or unrefed at the bottom of this function */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
572 cbplususerdata_ref(userdata);
17609
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
573 userdata->cb = cb;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
574 userdata->cb_data = user_data;
17609
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
575 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
576 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
577 userdata->ver = g_strdup(ver);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
578 userdata->hash = g_strdup(hash);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
579
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
580 if (info) {
25786
5ad14a53e266 Partial disapproval of b8fdbd255c614e7305f835b843a3414675a86a19
Paul Aurich <paul@darkrain42.org>
parents: 25785
diff changeset
581 userdata->info = info;
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
582 } else {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
583 /* 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: 25783
diff changeset
584 * to fetch it. */
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
585 JabberIq *iq;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
586 xmlnode *query;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
587 char *nodever;
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
588
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
589 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
590 "http://jabber.org/protocol/disco#info");
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
591 query = xmlnode_get_child_with_namespace(iq->node, "query",
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
592 "http://jabber.org/protocol/disco#info");
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
593 nodever = g_strdup_printf("%s#%s", node, ver);
17609
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 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
595 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
596 xmlnode_set_attrib(iq->node, "to", who);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
597
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
598 jabber_iq_set_callback(iq, jabber_caps_client_iqcb, userdata);
17609
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
599 jabber_iq_send(iq);
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
600 }
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
601
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
602 /* Are there any exts that we don't recognize? */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
603 if (ext && *ext && !hash) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
604 JabberCapsNodeExts *node_exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
605 gchar **splat = g_strsplit(ext, " ", 0);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
606 int i;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
607
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
608 if (info) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
609 if (info->exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
610 node_exts = info->exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
611 else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
612 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: 25783
diff changeset
613 } else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
614 /* 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: 25783
diff changeset
615 node_exts = userdata->node_exts = jabber_caps_find_exts_by_node(node);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
616
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
617 for (i = 0; splat[i]; ++i) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
618 userdata->exts = g_list_prepend(userdata->exts, splat[i]);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
619 /* Look it up if we don't already know what it means */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
620 if (!g_hash_table_lookup(node_exts->exts, splat[i])) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
621 JabberIq *iq;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
622 xmlnode *query;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
623 char *nodeext;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
624 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: 25783
diff changeset
625
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
626 cbdata->name = splat[i];
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
627 cbdata->data = cbplususerdata_ref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
628
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
629 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
630 "http://jabber.org/protocol/disco#info");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
631 query = xmlnode_get_child_with_namespace(iq->node, "query",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
632 "http://jabber.org/protocol/disco#info");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
633 nodeext = g_strdup_printf("%s#%s", node, splat[i]);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
634 xmlnode_set_attrib(query, "node", nodeext);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
635 g_free(nodeext);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
636 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: 25783
diff changeset
637
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
638 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: 25783
diff changeset
639 jabber_iq_send(iq);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
640
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
641 ++userdata->extOutstanding;
17609
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
642 }
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
643 splat[i] = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
644 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
645 /* 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: 25783
diff changeset
646 * g_strfreev. */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
647 g_free(splat);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
648 }
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
649
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
650 if (userdata->info && userdata->extOutstanding == 0) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
651 jabber_caps_get_info_complete(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
652 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
653 }
17609
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
654 }
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
655
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
656 static gint
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
657 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: 25780
diff changeset
658 {
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
659 const JabberIdentity *ac;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
660 const JabberIdentity *bc;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
661 gint cat_cmp;
25577
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
662 gint typ_cmp;
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
663
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
664 ac = a;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
665 bc = b;
19724
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: 19721
diff changeset
666
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
667 if ((cat_cmp = strcmp(ac->category, bc->category)) == 0) {
25577
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
668 if ((typ_cmp = strcmp(ac->type, bc->type)) == 0) {
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
669 if (!ac->lang && !bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
670 return 0;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
671 } 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: 25750
diff changeset
672 return 1;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
673 } 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: 25750
diff changeset
674 return -1;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
675 } else {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
676 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: 25750
diff changeset
677 }
25577
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
678 } else {
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
679 return typ_cmp;
17609
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
680 }
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
681 } else {
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
682 return cat_cmp;
17609
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
683 }
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
684 }
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
685
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
686 static gchar *jabber_caps_get_formtype(const xmlnode *x) {
25579
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: 25578
diff changeset
687 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: 25578
diff changeset
688 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: 25578
diff changeset
689 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: 25578
diff changeset
690 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: 25578
diff changeset
691 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: 25578
diff changeset
692 }
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: 25578
diff changeset
693
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
694 static gint
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
695 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: 25780
diff changeset
696 {
25588
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25586
diff changeset
697 const xmlnode *aformtypefield = a;
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25586
diff changeset
698 const xmlnode *bformtypefield = b;
25578
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
699 char *aformtype;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
700 char *bformtype;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
701 int result;
25579
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: 25578
diff changeset
702
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: 25578
diff changeset
703 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: 25578
diff changeset
704 bformtype = jabber_caps_get_formtype(bformtypefield);
25578
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
705
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
706 result = strcmp(aformtype, bformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
707 g_free(aformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
708 g_free(bformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
709 return result;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
710 }
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
711
25758
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: 25757
diff changeset
712 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: 25757
diff changeset
713 {
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
714 xmlnode *child;
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
715 JabberCapsClientInfo *info;
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
716
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
717 if (!query || strcmp(query->xmlns, "http://jabber.org/protocol/disco#info"))
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
718 return 0;
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
719
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
720 info = g_new0(JabberCapsClientInfo, 1);
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
721
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
722 for(child = query->child; child; child = child->next) {
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
723 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: 25575
diff changeset
724 /* parse identity */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
725 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: 25575
diff changeset
726 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: 25575
diff changeset
727 const char *name = xmlnode_get_attrib(child, "name");
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
728 const char *lang = xmlnode_get_attrib(child, "lang");
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
729 JabberIdentity *id;
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
730
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
731 if (!category || !type)
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
732 continue;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
733
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
734 id = g_new0(JabberIdentity, 1);
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
735 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: 25575
diff changeset
736 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: 25575
diff changeset
737 id->name = g_strdup(name);
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
738 id->lang = g_strdup(lang);
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
739
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
740 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: 25575
diff changeset
741 } 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: 25575
diff changeset
742 /* parse feature */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
743 const char *var = xmlnode_get_attrib(child, "var");
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
744 if (var)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
745 info->features = g_list_prepend(info->features, g_strdup(var));
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
746 } else if (!strcmp(child->name, "x")) {
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
747 if (child->xmlns && !strcmp(child->xmlns, "jabber:x:data")) {
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
748 /* x-data form */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
749 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: 25575
diff changeset
750 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: 25575
diff changeset
751 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
752 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
753 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
754 return info;
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
755 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
756
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
757 static gint jabber_caps_xdata_field_compare(gconstpointer a, gconstpointer b)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
758 {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
759 const JabberDataFormField *ac = a;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
760 const JabberDataFormField *bc = b;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
761
25579
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: 25578
diff changeset
762 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: 25578
diff changeset
763 }
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: 25578
diff changeset
764
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
765 static GList* jabber_caps_xdata_get_fields(const xmlnode *x)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
766 {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
767 GList *fields = NULL;
25579
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: 25578
diff changeset
768 xmlnode *field;
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
769
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
770 if (!x)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
771 return NULL;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
772
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
773 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: 25755
diff changeset
774 xmlnode *value;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
775 JabberDataFormField *xdatafield = g_new0(JabberDataFormField, 1);
25579
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: 25578
diff changeset
776 xdatafield->var = g_strdup(xmlnode_get_attrib(field, "var"));
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
777
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
778 for (value = xmlnode_get_child(field, "value"); value; value = xmlnode_get_next_twin(value)) {
25579
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: 25578
diff changeset
779 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: 25578
diff changeset
780 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: 25578
diff changeset
781 }
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
782
25748
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25746
diff changeset
783 xdatafield->values = g_list_sort(xdatafield->values, (GCompareFunc)strcmp);
25579
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: 25578
diff changeset
784 fields = g_list_append(fields, xdatafield);
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
785 }
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
786
25579
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: 25578
diff changeset
787 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: 25578
diff changeset
788 return fields;
17609
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
789 }
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
790
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
791 static GString*
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
792 jabber_caps_verification_append(GString *verification, const gchar *string)
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
793 {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
794 verification = g_string_append(verification, string);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
795 return g_string_append_c(verification, '<');
25579
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: 25578
diff changeset
796 }
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: 25578
diff changeset
797
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
798 gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash)
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
799 {
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
800 GList *node;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
801 GString *verification;
25579
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: 25578
diff changeset
802 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: 25578
diff changeset
803 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: 25578
diff changeset
804 gsize checksum_size = 20;
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
805 gboolean success;
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
806
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
807 if (!info || !(context = purple_cipher_context_new_by_name(hash, NULL)))
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
808 return NULL;
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
809
25578
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
810 /* sort identities, features and x-data forms */
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
811 info->identities = g_list_sort(info->identities, jabber_identity_compare);
25748
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25746
diff changeset
812 info->features = g_list_sort(info->features, (GCompareFunc)strcmp);
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
813 info->forms = g_list_sort(info->forms, jabber_xdata_compare);
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
814
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
815 verification = g_string_new("");
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
816
25579
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: 25578
diff changeset
817 /* concat identities to the verification string */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
818 for (node = info->identities; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
819 JabberIdentity *id = (JabberIdentity*)node->data;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
820
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
821 g_string_append_printf(verification, "%s/%s/%s/%s<", id->category,
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
822 id->type, id->lang ? id->lang : "", id->name);
25579
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: 25578
diff changeset
823 }
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
824
25579
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: 25578
diff changeset
825 /* concat features to the verification string */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
826 for (node = info->features; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
827 verification = jabber_caps_verification_append(verification, node->data);
25579
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: 25578
diff changeset
828 }
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
829
25579
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: 25578
diff changeset
830 /* concat x-data forms to the verification string */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
831 for(node = info->forms; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
832 xmlnode *data = (xmlnode *)node->data;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
833 gchar *formtype = jabber_caps_get_formtype(data);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
834 GList *fields = jabber_caps_xdata_get_fields(data);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
835
25579
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: 25578
diff changeset
836 /* 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: 25578
diff changeset
837 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: 25578
diff changeset
838 g_free(formtype);
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
839
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
840 while (fields) {
25579
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: 25578
diff changeset
841 GList *value;
25580
4c97156431b4 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25579
diff changeset
842 JabberDataFormField *field = (JabberDataFormField*)fields->data;
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
843
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
844 if (strcmp(field->var, "FORM_TYPE")) {
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
845 /* Append the "var" attribute */
25579
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: 25578
diff changeset
846 verification = jabber_caps_verification_append(verification, field->var);
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
847 /* Append <value/> elements' cdata */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
848 for(value = field->values; value; value = value->next) {
25579
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: 25578
diff changeset
849 verification = jabber_caps_verification_append(verification, value->data);
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
850 g_free(value->data);
25579
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: 25578
diff changeset
851 }
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: 25578
diff changeset
852 }
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
853
25579
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: 25578
diff changeset
854 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: 25578
diff changeset
855 g_list_free(field->values);
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
856
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
857 fields = g_list_delete_link(fields, fields);
25579
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: 25578
diff changeset
858 }
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: 25578
diff changeset
859 }
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
860
25582
fd19927e2b64 * support for calculating both hashes, sha-1 and md5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25580
diff changeset
861 /* generate hash */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
862 purple_cipher_context_append(context, (guchar*)verification->str, verification->len);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
863
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
864 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: 25780
diff changeset
865 checksum, &checksum_size);
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
866
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
867 g_string_free(verification, TRUE);
25579
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: 25578
diff changeset
868 purple_cipher_context_destroy(context);
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
869
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
870 return (success ? purple_base64_encode(checksum, checksum_size) : NULL);
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
871 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
872
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
873 void jabber_caps_calculate_own_hash(JabberStream *js) {
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
874 JabberCapsClientInfo info;
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
875 GList *iter = 0;
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
876 GList *features = 0;
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
877
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
878 if (!jabber_identities && !jabber_features) {
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
879 /* This really shouldn't ever happen */
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
880 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: 25758
diff changeset
881 g_free(js->caps_hash);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
882 js->caps_hash = NULL;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
883 return;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
884 }
25588
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25586
diff changeset
885
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
886 /* build the currently-supported list of features */
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
887 if (jabber_features) {
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
888 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: 25583
diff changeset
889 JabberFeature *feat = iter->data;
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
890 if(!feat->is_enabled || feat->is_enabled(js, feat->namespace)) {
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
891 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: 25583
diff changeset
892 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
893 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
894 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
895
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
896 info.features = features;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
897 info.identities = jabber_identities;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
898 info.forms = NULL;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
899
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
900 g_free(js->caps_hash);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
901 js->caps_hash = jabber_caps_calculate_hash(&info, "sha1");
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
902 g_list_free(features);
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
903 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
904
25742
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
905 const gchar* jabber_caps_get_own_hash(JabberStream *js)
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
906 {
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
907 if (!js->caps_hash)
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
908 jabber_caps_calculate_own_hash(js);
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
909
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
910 return js->caps_hash;
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
911 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
912
25743
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
913 void jabber_caps_broadcast_change()
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
914 {
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
915 GList *node, *accounts = purple_accounts_get_all_active();
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
916
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
917 for (node = accounts; node; node = node->next) {
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
918 PurpleAccount *account = node->data;
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
919 const char *prpl_id = purple_account_get_protocol_id(account);
25744
6adbaf3d25e3 Fix a null dereference on non-connected accounts
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
920 if (!strcmp("prpl-jabber", prpl_id) && purple_account_is_connected(account)) {
25743
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
921 PurpleConnection *gc = purple_account_get_connection(account);
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
922 jabber_presence_send(gc->proto_data, TRUE);
25590
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25589
diff changeset
923 }
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25589
diff changeset
924 }
25743
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
925
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
926 g_list_free(accounts);
25590
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25589
diff changeset
927 }
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25589
diff changeset
928