libpurple/protocols/jabber/caps.c

Sat, 04 Apr 2009 03:15:59 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Sat, 04 Apr 2009 03:15:59 +0000
branch
cpw.darkrain42.xmpp.bosh
changeset 26658
bde1aa281432
parent 26482
72d16a73cf12
parent 26072
e8fce2b2b9fe
child 26668
ef06285f3b64
permissions
-rw-r--r--

propagate from branch 'im.pidgin.pidgin' (head fe7003f2f5aaf8a4e745df26f3fe846210fc22a9)
to branch 'im.pidgin.cpw.darkrain42.xmpp.bosh' (head 86c828b108a688e4bf7852ad7b0a7bec76463665)

17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
1 /*
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
3 *
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
4 * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com>
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
5 *
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
9 * (at your option) any later version.
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
10 *
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
14 * GNU General Public License for more details.
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
15 *
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
19 *
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
20 */
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
21
19898
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 17836
diff changeset
22 #include "internal.h"
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 17836
diff changeset
23
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
24 #include "debug.h"
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
25 #include "caps.h"
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
26 #include "cipher.h"
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
27 #include "iq.h"
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
28 #include "presence.h"
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
29 #include "util.h"
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
30
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
31 #define JABBER_CAPS_FILENAME "xmpp-caps.xml"
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
32
24732
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
33 typedef struct _JabberDataFormField {
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
34 gchar *var;
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
35 GList *values;
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
36 } JabberDataFormField;
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
37
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
38 typedef struct _JabberCapsKey {
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
39 char *node;
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
40 char *ver;
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
41 char *hash;
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
42 } JabberCapsKey;
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
43
24736
42ffd8ecdb6e Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
44 static GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsClientInfo */
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
45 static GHashTable *nodetable = NULL; /* char *node -> JabberCapsNodeExts */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
46 static guint save_timer = 0;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
47
24732
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
48 /**
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
49 * Processes a query-node and returns a JabberCapsClientInfo object with all relevant info.
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
50 *
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
51 * @param query A query object.
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
52 * @return A JabberCapsClientInfo object.
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
53 */
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
54 static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query);
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
55
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
56 /* Free a GList of allocated char* */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
57 static void
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
58 free_string_glist(GList *list)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
59 {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
60 g_list_foreach(list, (GFunc)g_free, NULL);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
61 g_list_free(list);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
62 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
63
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
64 static JabberCapsNodeExts*
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
65 jabber_caps_node_exts_ref(JabberCapsNodeExts *exts)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
66 {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
67 g_return_val_if_fail(exts != NULL, NULL);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
68
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
69 ++exts->ref;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
70 return exts;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
71 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
72
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
73 static void
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
74 jabber_caps_node_exts_unref(JabberCapsNodeExts *exts)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
75 {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
76 if (exts == NULL)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
77 return;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
78
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
79 g_return_if_fail(exts->ref != 0);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
80
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
81 if (--exts->ref != 0)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
82 return;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
83
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
84 g_hash_table_destroy(exts->exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
85 g_free(exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
86 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
87
24879
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
88 static guint jabber_caps_hash(gconstpointer data) {
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
89 const JabberCapsKey *key = data;
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
90 guint nodehash = g_str_hash(key->node);
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
91 guint verhash = g_str_hash(key->ver);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
92 /* 'hash' was optional in XEP-0115 v1.4 and I think g_str_hash crashes on
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
93 * NULL >:O. Okay, maybe I've played too much Zelda, but that looks like
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
94 * a Deku Shrub... */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
95 guint hashhash = (key->hash ? g_str_hash(key->hash) : 0);
23596
164fbee281c1 * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23595
diff changeset
96 return nodehash ^ verhash ^ hashhash;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
97 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
98
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
99 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
100 const JabberCapsKey *name1 = v1;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
101 const JabberCapsKey *name2 = v2;
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
102 /* Again, hash might be NULL and I *know* strcmp will crash on NULL. */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
103 gboolean hasheq = ((!name1->hash && !name2->hash) ||
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
104 (name1->hash && name2->hash && !strcmp(name1->hash, name2->hash)));
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
105
24722
4896d0884130 Use strcmp instead of a wrapper
Paul Aurich <darkrain42@pidgin.im>
parents: 24720
diff changeset
106 return strcmp(name1->node, name2->node) == 0 &&
4896d0884130 Use strcmp instead of a wrapper
Paul Aurich <darkrain42@pidgin.im>
parents: 24720
diff changeset
107 strcmp(name1->ver, name2->ver) == 0 &&
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
108 hasheq;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
109 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
110
24879
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
111 void jabber_caps_destroy_key(gpointer data) {
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
112 JabberCapsKey *key = data;
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
113 g_free(key->node);
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
114 g_free(key->ver);
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
115 g_free(key->hash);
823943d2f2b9 Rename a few variables
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
116 g_free(key);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
117 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
118
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
119 static void
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
120 jabber_caps_client_info_destroy(JabberCapsClientInfo *info)
24878
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
121 {
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
122 if (info == NULL)
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
123 return;
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
124
24731
c0a5e4f2bed5 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <darkrain42@pidgin.im>
parents: 24730
diff changeset
125 while(info->identities) {
c0a5e4f2bed5 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <darkrain42@pidgin.im>
parents: 24730
diff changeset
126 JabberIdentity *id = info->identities->data;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
127 g_free(id->category);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
128 g_free(id->type);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
129 g_free(id->name);
24725
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
130 g_free(id->lang);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
131 g_free(id);
24731
c0a5e4f2bed5 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <darkrain42@pidgin.im>
parents: 24730
diff changeset
132 info->identities = g_list_delete_link(info->identities, info->identities);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
133 }
24731
c0a5e4f2bed5 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <darkrain42@pidgin.im>
parents: 24730
diff changeset
134
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
135 free_string_glist(info->features);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
136 free_string_glist(info->forms);
23594
f80bec337aa7 * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23593
diff changeset
137
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
138 jabber_caps_node_exts_unref(info->exts);
24731
c0a5e4f2bed5 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <darkrain42@pidgin.im>
parents: 24730
diff changeset
139
c0a5e4f2bed5 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <darkrain42@pidgin.im>
parents: 24730
diff changeset
140 g_free(info);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
141 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
142
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
143 /* NOTE: Takes a reference to the exts, unref it if you don't really want to
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
144 * keep it around. */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
145 static JabberCapsNodeExts*
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
146 jabber_caps_find_exts_by_node(const char *node)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
147 {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
148 JabberCapsNodeExts *exts;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
149 if (NULL == (exts = g_hash_table_lookup(nodetable, node))) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
150 exts = g_new0(JabberCapsNodeExts, 1);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
151 exts->exts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
152 (GDestroyNotify)free_string_glist);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
153 g_hash_table_insert(nodetable, g_strdup(node), jabber_caps_node_exts_ref(exts));
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
154 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
155
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
156 return jabber_caps_node_exts_ref(exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
157 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
158
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
159 static void
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
160 exts_to_xmlnode(gconstpointer key, gconstpointer value, gpointer user_data)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
161 {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
162 const char *identifier = key;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
163 const GList *features = value, *node;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
164 xmlnode *client = user_data, *ext, *feature;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
165
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
166 ext = xmlnode_new_child(client, "ext");
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
167 xmlnode_set_attrib(ext, "identifier", identifier);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
168
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
169 for (node = features; node; node = node->next) {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
170 feature = xmlnode_new_child(ext, "feature");
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
171 xmlnode_set_attrib(feature, "var", (const gchar *)node->data);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
172 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
173 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
174
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
175 static void jabber_caps_store_client(gpointer key, gpointer value, gpointer user_data) {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
176 JabberCapsKey *clientinfo = key;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
177 JabberCapsClientInfo *props = value;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
178 xmlnode *root = user_data;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
179 xmlnode *client = xmlnode_new_child(root, "client");
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
180 GList *iter;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
181
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
182 xmlnode_set_attrib(client, "node", clientinfo->node);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
183 xmlnode_set_attrib(client, "ver", clientinfo->ver);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
184 if (clientinfo->hash)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
185 xmlnode_set_attrib(client, "hash", clientinfo->hash);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
186 for(iter = props->identities; iter; iter = g_list_next(iter)) {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
187 JabberIdentity *id = iter->data;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
188 xmlnode *identity = xmlnode_new_child(client, "identity");
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
189 xmlnode_set_attrib(identity, "category", id->category);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
190 xmlnode_set_attrib(identity, "type", id->type);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
191 if (id->name)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
192 xmlnode_set_attrib(identity, "name", id->name);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
193 if (id->lang)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
194 xmlnode_set_attrib(identity, "lang", id->lang);
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
195 }
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
196
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
197 for(iter = props->features; iter; iter = g_list_next(iter)) {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
198 const char *feat = iter->data;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
199 xmlnode *feature = xmlnode_new_child(client, "feature");
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
200 xmlnode_set_attrib(feature, "var", feat);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
201 }
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
202
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
203 for(iter = props->forms; iter; iter = g_list_next(iter)) {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
204 /* FIXME: See #7814 */
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
205 xmlnode *xdata = iter->data;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
206 xmlnode_insert_child(client, xmlnode_copy(xdata));
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
207 }
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
208
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
209 /* TODO: Ideally, only save this once-per-node... */
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
210 if (props->exts)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
211 g_hash_table_foreach(props->exts->exts, (GHFunc)exts_to_xmlnode, client);
24736
42ffd8ecdb6e Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
212 }
42ffd8ecdb6e Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <darkrain42@pidgin.im>
parents: 24735
diff changeset
213
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
214 static gboolean
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
215 do_jabber_caps_store(gpointer data)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
216 {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
217 char *str;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
218 int length = 0;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
219 xmlnode *root = xmlnode_new("capabilities");
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
220 g_hash_table_foreach(capstable, jabber_caps_store_client, root);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
221 str = xmlnode_to_formatted_str(root, &length);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
222 xmlnode_free(root);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
223 purple_util_write_data_to_file(JABBER_CAPS_FILENAME, str, length);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
224 g_free(str);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
225
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
226 save_timer = 0;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
227 return FALSE;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
228 }
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
229
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
230 static void
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
231 schedule_caps_save(void)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
232 {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
233 if (save_timer == 0)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
234 save_timer = purple_timeout_add_seconds(5, do_jabber_caps_store, NULL);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
235 }
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
236
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
237 static void
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
238 jabber_caps_load(void)
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
239 {
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
240 xmlnode *capsdata = purple_util_read_xml_from_file(JABBER_CAPS_FILENAME, "XMPP capabilities cache");
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
241 xmlnode *client;
19930
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
242
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
243 if(!capsdata)
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
244 return;
19930
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
245
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
246 if (strcmp(capsdata->name, "capabilities") != 0) {
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
247 xmlnode_free(capsdata);
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
248 return;
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
249 }
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
250
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
251 for(client = capsdata->child; client; client = client->next) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
252 if(client->type != XMLNODE_TYPE_TAG)
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
253 continue;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
254 if(!strcmp(client->name, "client")) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
255 JabberCapsKey *key = g_new0(JabberCapsKey, 1);
24731
c0a5e4f2bed5 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <darkrain42@pidgin.im>
parents: 24730
diff changeset
256 JabberCapsClientInfo *value = g_new0(JabberCapsClientInfo, 1);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
257 xmlnode *child;
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
258 JabberCapsNodeExts *exts = NULL;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
259 key->node = g_strdup(xmlnode_get_attrib(client,"node"));
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
260 key->ver = g_strdup(xmlnode_get_attrib(client,"ver"));
23594
f80bec337aa7 * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23593
diff changeset
261 key->hash = g_strdup(xmlnode_get_attrib(client,"hash"));
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
262
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
263 /* v1.3 capabilities */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
264 if (key->hash == NULL)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
265 exts = jabber_caps_find_exts_by_node(key->node);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
266
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
267 for(child = client->child; child; child = child->next) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
268 if(child->type != XMLNODE_TYPE_TAG)
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
269 continue;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
270 if(!strcmp(child->name,"feature")) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
271 const char *var = xmlnode_get_attrib(child, "var");
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
272 if(!var)
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
273 continue;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
274 value->features = g_list_append(value->features,g_strdup(var));
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
275 } else if(!strcmp(child->name,"identity")) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
276 const char *category = xmlnode_get_attrib(child, "category");
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
277 const char *type = xmlnode_get_attrib(child, "type");
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
278 const char *name = xmlnode_get_attrib(child, "name");
24725
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
279 const char *lang = xmlnode_get_attrib(child, "lang");
24726
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
280 JabberIdentity *id;
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
281
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
282 if (!category || !type)
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
283 continue;
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
284
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
285 id = g_new0(JabberIdentity, 1);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
286 id->category = g_strdup(category);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
287 id->type = g_strdup(type);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
288 id->name = g_strdup(name);
24725
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
289 id->lang = g_strdup(lang);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
290
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
291 value->identities = g_list_append(value->identities,id);
23594
f80bec337aa7 * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23593
diff changeset
292 } else if(!strcmp(child->name,"x")) {
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
293 /* FIXME: See #7814 -- this will cause problems if anyone
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
294 * ever actually specifies forms. In fact, for this to
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
295 * work properly, that bug needs to be fixed in
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
296 * xmlnode_from_str, not the output version... */
23594
f80bec337aa7 * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23593
diff changeset
297 value->forms = g_list_append(value->forms, xmlnode_copy(child));
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
298 } else if (!strcmp(child->name, "ext") && key->hash != NULL) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
299 purple_debug_warning("jabber", "Ignoring exts when reading new-style caps\n");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
300 } else if (!strcmp(child->name, "ext")) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
301 /* TODO: Do we care about reading in the identities listed here? */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
302 const char *identifier = xmlnode_get_attrib(child, "identifier");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
303 xmlnode *node;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
304 GList *features = NULL;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
305
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
306 if (!identifier)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
307 continue;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
308
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
309 for (node = child->child; node; node = node->next) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
310 if (node->type != XMLNODE_TYPE_TAG)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
311 continue;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
312 if (!strcmp(node->name, "feature")) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
313 const char *var = xmlnode_get_attrib(node, "var");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
314 if (!var)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
315 continue;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
316 features = g_list_prepend(features, g_strdup(var));
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
317 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
318 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
319
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
320 if (features) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
321 g_hash_table_insert(exts->exts, g_strdup(identifier),
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
322 features);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
323 } else
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
324 purple_debug_warning("jabber", "Caps ext %s had no features.\n",
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
325 identifier);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
326 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
327 }
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
328
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
329 value->exts = exts;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
330 g_hash_table_replace(capstable, key, value);
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
331
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
332 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
333 }
19930
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
334 xmlnode_free(capsdata);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
335 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
336
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
337 void jabber_caps_init(void)
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
338 {
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
339 nodetable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)jabber_caps_node_exts_unref);
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
340 capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, jabber_caps_destroy_key, (GDestroyNotify)jabber_caps_client_info_destroy);
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
341 jabber_caps_load();
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
342 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
343
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
344 void jabber_caps_uninit(void)
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
345 {
24881
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
346 if (save_timer != 0) {
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
347 purple_timeout_remove(save_timer);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
348 save_timer = 0;
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
349 do_jabber_caps_store(NULL);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
350 }
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
351 g_hash_table_destroy(capstable);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
352 g_hash_table_destroy(nodetable);
7a3aa84f6e57 Remove the old if 0'd out caps code and reorder some functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 24880
diff changeset
353 capstable = NULL;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
354 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
355
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
356 typedef struct _jabber_caps_cbplususerdata {
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
357 guint ref;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
358
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
359 jabber_caps_get_info_cb cb;
24876
5861f7210c6c Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <darkrain42@pidgin.im>
parents: 24742
diff changeset
360 gpointer cb_data;
5861f7210c6c Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <darkrain42@pidgin.im>
parents: 24742
diff changeset
361
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
362 char *who;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
363 char *node;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
364 char *ver;
23591
ba1e3ed78d40 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23590
diff changeset
365 char *hash;
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
366
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
367 JabberCapsClientInfo *info;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
368
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
369 GList *exts;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
370 guint extOutstanding;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
371 JabberCapsNodeExts *node_exts;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
372 } jabber_caps_cbplususerdata;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
373
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
374 static jabber_caps_cbplususerdata*
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
375 cbplususerdata_ref(jabber_caps_cbplususerdata *data)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
376 {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
377 g_return_val_if_fail(data != NULL, NULL);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
378
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
379 ++data->ref;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
380 return data;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
381 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
382
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
383 static void
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
384 cbplususerdata_unref(jabber_caps_cbplususerdata *data)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
385 {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
386 if (data == NULL)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
387 return;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
388
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
389 g_return_if_fail(data->ref != 0);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
390
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
391 if (--data->ref > 0)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
392 return;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
393
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
394 g_free(data->who);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
395 g_free(data->node);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
396 g_free(data->ver);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
397 g_free(data->hash);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
398
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
399 /* If we have info here, it's already in the capstable, so don't free it */
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
400 if (data->exts)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
401 free_string_glist(data->exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
402 if (data->node_exts)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
403 jabber_caps_node_exts_unref(data->node_exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
404 g_free(data);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
405 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
406
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
407 static void
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
408 jabber_caps_get_info_complete(jabber_caps_cbplususerdata *userdata)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
409 {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
410 userdata->cb(userdata->info, userdata->exts, userdata->cb_data);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
411 userdata->info = NULL;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
412 userdata->exts = NULL;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
413
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
414 if (userdata->ref != 1)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
415 purple_debug_warning("jabber", "Lost a reference to caps cbdata: %d\n",
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
416 userdata->ref);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
417 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
418
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
419 static void
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
420 jabber_caps_client_iqcb(JabberStream *js, xmlnode *packet, gpointer data)
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
421 {
21680
1b52846a0d97 Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <datallah@pidgin.im>
parents: 21491
diff changeset
422 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
1b52846a0d97 Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <datallah@pidgin.im>
parents: 21491
diff changeset
423 "http://jabber.org/protocol/disco#info");
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
424 jabber_caps_cbplususerdata *userdata = data;
24876
5861f7210c6c Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <darkrain42@pidgin.im>
parents: 24742
diff changeset
425 JabberCapsClientInfo *info = NULL, *value;
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
426 const char *type = xmlnode_get_attrib(packet, "type");
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
427 JabberCapsKey key;
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
428
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
429 if (!query || !strcmp(type, "error")) {
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
430 /* Any outstanding exts will be dealt with via ref-counting */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
431 userdata->cb(NULL, NULL, userdata->cb_data);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
432 cbplususerdata_unref(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
433 return;
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
434 }
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
435
24727
77092d0aaaf0 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <darkrain42@pidgin.im>
parents: 24726
diff changeset
436 /* check hash */
77092d0aaaf0 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <darkrain42@pidgin.im>
parents: 24726
diff changeset
437 info = jabber_caps_parse_client_info(query);
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
438
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
439 /* Only validate if these are v1.5 capabilities */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
440 if (userdata->hash) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
441 gchar *hash = NULL;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
442 if (!strcmp(userdata->hash, "sha-1")) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
443 hash = jabber_caps_calculate_hash(info, "sha1");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
444 } else if (!strcmp(userdata->hash, "md5")) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
445 hash = jabber_caps_calculate_hash(info, "md5");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
446 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
447
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
448 if (!hash || strcmp(hash, userdata->ver)) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
449 purple_debug_warning("jabber", "Could not validate caps info from %s\n",
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
450 xmlnode_get_attrib(packet, "from"));
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
451
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
452 userdata->cb(NULL, NULL, userdata->cb_data);
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
453 jabber_caps_client_info_destroy(info);
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
454 cbplususerdata_unref(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
455 g_free(hash);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
456 return;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
457 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
458
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
459 g_free(hash);
24727
77092d0aaaf0 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <darkrain42@pidgin.im>
parents: 24726
diff changeset
460 }
21680
1b52846a0d97 Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <datallah@pidgin.im>
parents: 21491
diff changeset
461
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
462 if (!userdata->hash && userdata->node_exts) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
463 /* If the ClientInfo doesn't have information about the exts, give them
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
464 * ours (along with our ref) */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
465 info->exts = userdata->node_exts;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
466 userdata->node_exts = NULL;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
467 }
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
468
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
469 key.node = userdata->node;
24876
5861f7210c6c Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <darkrain42@pidgin.im>
parents: 24742
diff changeset
470 key.ver = userdata->ver;
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
471 key.hash = userdata->hash;
21680
1b52846a0d97 Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <datallah@pidgin.im>
parents: 21491
diff changeset
472
24876
5861f7210c6c Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <darkrain42@pidgin.im>
parents: 24742
diff changeset
473 /* Use the copy of this data already in the table if it exists or insert
5861f7210c6c Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <darkrain42@pidgin.im>
parents: 24742
diff changeset
474 * a new one if we need to */
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
475 if ((value = g_hash_table_lookup(capstable, &key))) {
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
476 jabber_caps_client_info_destroy(info);
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
477 info = value;
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
478 } else {
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
479 JabberCapsKey *n_key = g_new(JabberCapsKey, 1);
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
480 n_key->node = userdata->node;
24876
5861f7210c6c Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <darkrain42@pidgin.im>
parents: 24742
diff changeset
481 n_key->ver = userdata->ver;
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
482 n_key->hash = userdata->hash;
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
483 userdata->node = userdata->ver = userdata->hash = NULL;
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
484
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
485 /* The capstable gets a reference */
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
486 g_hash_table_insert(capstable, n_key, info);
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
487 schedule_caps_save();
24727
77092d0aaaf0 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <darkrain42@pidgin.im>
parents: 24726
diff changeset
488 }
21680
1b52846a0d97 Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <datallah@pidgin.im>
parents: 21491
diff changeset
489
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
490 userdata->info = info;
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
491
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
492 if (userdata->extOutstanding == 0)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
493 jabber_caps_get_info_complete(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
494
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
495 cbplususerdata_unref(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
496 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
497
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
498 typedef struct {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
499 const char *name;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
500 jabber_caps_cbplususerdata *data;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
501 } ext_iq_data;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
502
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
503 static void
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
504 jabber_caps_ext_iqcb(JabberStream *js, xmlnode *packet, gpointer data)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
505 {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
506 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
507 "http://jabber.org/protocol/disco#info");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
508 xmlnode *child;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
509 ext_iq_data *userdata = data;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
510 const char *type = xmlnode_get_attrib(packet, "type");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
511 GList *features = NULL;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
512 JabberCapsNodeExts *node_exts;
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
513
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
514 if (!query || !strcmp(type, "error")) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
515 cbplususerdata_unref(userdata->data);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
516 g_free(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
517 return;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
518 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
519
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
520 /* So, we decrement this after checking for an error, which means that
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
521 * if there *is* an error, we'll never call the callback passed to
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
522 * jabber_caps_get_info. We will still free all of our data, though.
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
523 */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
524 --userdata->data->extOutstanding;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
525
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
526 for (child = xmlnode_get_child(query, "feature"); child;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
527 child = xmlnode_get_next_twin(child)) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
528 const char *var = xmlnode_get_attrib(child, "var");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
529 if (var)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
530 features = g_list_prepend(features, g_strdup(var));
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
531 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
532
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
533 node_exts = (userdata->data->info ? userdata->data->info->exts :
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
534 userdata->data->node_exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
535 g_hash_table_insert(node_exts->exts, g_strdup(userdata->name), features);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
536 schedule_caps_save();
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
537
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
538 /* Are we done? */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
539 if (userdata->data->info && userdata->data->extOutstanding == 0)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
540 jabber_caps_get_info_complete(userdata->data);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
541
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
542 cbplususerdata_unref(userdata->data);
24728
4447de55fdf6 Clean up jabber_caps_client_iqcb
Paul Aurich <darkrain42@pidgin.im>
parents: 24727
diff changeset
543 g_free(userdata);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
544 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
545
24720
93ae4b5531c0 Clean up a few things
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
546 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
547 const char *ver, const char *hash, const char *ext,
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
548 jabber_caps_get_info_cb cb, gpointer user_data)
24720
93ae4b5531c0 Clean up a few things
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
549 {
24878
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
550 JabberCapsClientInfo *info;
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
551 JabberCapsKey key;
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
552 jabber_caps_cbplususerdata *userdata;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
553
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
554 if (ext && *ext && hash)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
555 purple_debug_warning("jabber", "Ignoring exts in new-style caps from %s\n",
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
556 who);
24878
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
557
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
558 /* Using this in a read-only fashion, so the cast is OK */
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
559 key.node = (char *)node;
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
560 key.ver = (char *)ver;
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
561 key.hash = (char *)hash;
19898
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 17836
diff changeset
562
24878
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
563 info = g_hash_table_lookup(capstable, &key);
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
564 if (info && hash) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
565 /* v1.5 - We already have all the information we care about */
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
566 cb(info, NULL, user_data);
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
567 return;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
568 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
569
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
570 userdata = g_new0(jabber_caps_cbplususerdata, 1);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
571 /* This ref is given to fetching the basic node#ver info if we need it
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
572 * or unrefed at the bottom of this function */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
573 cbplususerdata_ref(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
574 userdata->cb = cb;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
575 userdata->cb_data = user_data;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
576 userdata->who = g_strdup(who);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
577 userdata->node = g_strdup(node);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
578 userdata->ver = g_strdup(ver);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
579 userdata->hash = g_strdup(hash);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
580
24878
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
581 if (info) {
24882
7e842d8123e8 Partial disapproval of 19969457944c4807924bcde3090063b23d35ba17
Paul Aurich <darkrain42@pidgin.im>
parents: 24881
diff changeset
582 userdata->info = info;
24878
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
583 } else {
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
584 /* If we don't have the basic information about the client, we need
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
585 * to fetch it. */
24878
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
586 JabberIq *iq;
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
587 xmlnode *query;
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
588 char *nodever;
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
589
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
590 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
591 "http://jabber.org/protocol/disco#info");
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
592 query = xmlnode_get_child_with_namespace(iq->node, "query",
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
593 "http://jabber.org/protocol/disco#info");
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
594 nodever = g_strdup_printf("%s#%s", node, ver);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
595 xmlnode_set_attrib(query, "node", nodever);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
596 g_free(nodever);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
597 xmlnode_set_attrib(iq->node, "to", who);
19930
95cb4da7241e Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <datallah@pidgin.im>
parents: 19929
diff changeset
598
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
599 jabber_iq_set_callback(iq, jabber_caps_client_iqcb, userdata);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
600 jabber_iq_send(iq);
23595
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
601 }
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
602
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
603 /* Are there any exts that we don't recognize? */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
604 if (ext && *ext && !hash) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
605 JabberCapsNodeExts *node_exts;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
606 gchar **splat = g_strsplit(ext, " ", 0);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
607 int i;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
608
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
609 if (info) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
610 if (info->exts)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
611 node_exts = info->exts;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
612 else
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
613 node_exts = info->exts = jabber_caps_find_exts_by_node(node);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
614 } else
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
615 /* We'll put it in later once we have the client info */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
616 node_exts = userdata->node_exts = jabber_caps_find_exts_by_node(node);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
617
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
618 for (i = 0; splat[i]; ++i) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
619 userdata->exts = g_list_prepend(userdata->exts, splat[i]);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
620 /* Look it up if we don't already know what it means */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
621 if (!g_hash_table_lookup(node_exts->exts, splat[i])) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
622 JabberIq *iq;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
623 xmlnode *query;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
624 char *nodeext;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
625 ext_iq_data *cbdata = g_new(ext_iq_data, 1);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
626
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
627 cbdata->name = splat[i];
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
628 cbdata->data = cbplususerdata_ref(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
629
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
630 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
631 "http://jabber.org/protocol/disco#info");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
632 query = xmlnode_get_child_with_namespace(iq->node, "query",
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
633 "http://jabber.org/protocol/disco#info");
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
634 nodeext = g_strdup_printf("%s#%s", node, splat[i]);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
635 xmlnode_set_attrib(query, "node", nodeext);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
636 g_free(nodeext);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
637 xmlnode_set_attrib(iq->node, "to", who);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
638
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
639 jabber_iq_set_callback(iq, jabber_caps_ext_iqcb, cbdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
640 jabber_iq_send(iq);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
641
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
642 ++userdata->extOutstanding;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
643 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
644 splat[i] = NULL;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
645 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
646 /* All the strings are now part of the GList, so don't need
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
647 * g_strfreev. */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
648 g_free(splat);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
649 }
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
650
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
651 if (userdata->info && userdata->extOutstanding == 0) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
652 jabber_caps_get_info_complete(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
653 cbplususerdata_unref(userdata);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
654 }
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
655 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
656
24877
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
657 static gint
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
658 jabber_identity_compare(gconstpointer a, gconstpointer b)
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
659 {
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
660 const JabberIdentity *ac;
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
661 const JabberIdentity *bc;
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
662 gint cat_cmp;
23588
9b2741bcecf2 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23587
diff changeset
663 gint typ_cmp;
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
664
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
665 ac = a;
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
666 bc = b;
24725
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
667
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
668 if ((cat_cmp = strcmp(ac->category, bc->category)) == 0) {
23588
9b2741bcecf2 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23587
diff changeset
669 if ((typ_cmp = strcmp(ac->type, bc->type)) == 0) {
24725
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
670 if (!ac->lang && !bc->lang) {
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
671 return 0;
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
672 } else if (ac->lang && !bc->lang) {
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
673 return 1;
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
674 } else if (!ac->lang && bc->lang) {
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
675 return -1;
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
676 } else {
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
677 return strcmp(ac->lang, bc->lang);
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
678 }
23588
9b2741bcecf2 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23587
diff changeset
679 } else {
9b2741bcecf2 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23587
diff changeset
680 return typ_cmp;
9b2741bcecf2 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23587
diff changeset
681 }
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
682 } else {
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
683 return cat_cmp;
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
684 }
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
685 }
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
686
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
687 static gchar *jabber_caps_get_formtype(const xmlnode *x) {
23590
2ccc80ff0134 * 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: 23589
diff changeset
688 xmlnode *formtypefield;
2ccc80ff0134 * 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: 23589
diff changeset
689 formtypefield = xmlnode_get_child(x, "field");
2ccc80ff0134 * 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: 23589
diff changeset
690 while (formtypefield && strcmp(xmlnode_get_attrib(formtypefield, "var"), "FORM_TYPE")) formtypefield = xmlnode_get_next_twin(formtypefield);
2ccc80ff0134 * 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: 23589
diff changeset
691 formtypefield = xmlnode_get_child(formtypefield, "value");
2ccc80ff0134 * 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: 23589
diff changeset
692 return xmlnode_get_data(formtypefield);;
2ccc80ff0134 * 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: 23589
diff changeset
693 }
2ccc80ff0134 * 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: 23589
diff changeset
694
24877
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
695 static gint
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
696 jabber_xdata_compare(gconstpointer a, gconstpointer b)
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
697 {
23599
ac402ffdcbec * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23597
diff changeset
698 const xmlnode *aformtypefield = a;
ac402ffdcbec * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23597
diff changeset
699 const xmlnode *bformtypefield = b;
23589
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
700 char *aformtype;
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
701 char *bformtype;
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
702 int result;
23590
2ccc80ff0134 * 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: 23589
diff changeset
703
2ccc80ff0134 * 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: 23589
diff changeset
704 aformtype = jabber_caps_get_formtype(aformtypefield);
2ccc80ff0134 * 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: 23589
diff changeset
705 bformtype = jabber_caps_get_formtype(bformtypefield);
23589
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
706
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
707 result = strcmp(aformtype, bformtype);
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
708 g_free(aformtype);
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
709 g_free(bformtype);
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
710 return result;
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
711 }
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
712
24732
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
713 static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query)
7d4f758b7b0a 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 <darkrain42@pidgin.im>
parents: 24731
diff changeset
714 {
23587
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
715 xmlnode *child;
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
716 JabberCapsClientInfo *info;
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
717
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
718 if (!query || strcmp(query->xmlns, "http://jabber.org/protocol/disco#info"))
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
719 return 0;
23587
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
720
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 24714
diff changeset
721 info = g_new0(JabberCapsClientInfo, 1);
24878
19969457944c Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <darkrain42@pidgin.im>
parents: 24877
diff changeset
722
23587
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
723 for(child = query->child; child; child = child->next) {
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
724 if (!strcmp(child->name,"identity")) {
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
725 /* parse identity */
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
726 const char *category = xmlnode_get_attrib(child, "category");
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
727 const char *type = xmlnode_get_attrib(child, "type");
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
728 const char *name = xmlnode_get_attrib(child, "name");
24725
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
729 const char *lang = xmlnode_get_attrib(child, "lang");
24726
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
730 JabberIdentity *id;
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
731
24726
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
732 if (!category || !type)
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
733 continue;
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
734
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
735 id = g_new0(JabberIdentity, 1);
23587
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
736 id->category = g_strdup(category);
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
737 id->type = g_strdup(type);
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
738 id->name = g_strdup(name);
24725
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
739 id->lang = g_strdup(lang);
c72ba845a930 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 24724
diff changeset
740
23587
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
741 info->identities = g_list_append(info->identities, id);
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
742 } else if (!strcmp(child->name, "feature")) {
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
743 /* parse feature */
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
744 const char *var = xmlnode_get_attrib(child, "var");
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
745 if (var)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24879
diff changeset
746 info->features = g_list_prepend(info->features, g_strdup(var));
23587
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
747 } else if (!strcmp(child->name, "x")) {
24726
6d087b9604e5 Error checking and use g_list_foreach
Paul Aurich <darkrain42@pidgin.im>
parents: 24725
diff changeset
748 if (child->xmlns && !strcmp(child->xmlns, "jabber:x:data")) {
23587
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
749 /* x-data form */
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
750 xmlnode *dataform = xmlnode_copy(child);
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
751 info->forms = g_list_append(info->forms, dataform);
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
752 }
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
753 }
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
754 }
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
755 return info;
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
756 }
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
757
24730
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
758 static gint jabber_caps_xdata_field_compare(gconstpointer a, gconstpointer b)
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
759 {
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
760 const JabberDataFormField *ac = a;
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
761 const JabberDataFormField *bc = b;
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
762
23590
2ccc80ff0134 * 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: 23589
diff changeset
763 return strcmp(ac->var, bc->var);
2ccc80ff0134 * 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: 23589
diff changeset
764 }
2ccc80ff0134 * 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: 23589
diff changeset
765
24730
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
766 static GList* jabber_caps_xdata_get_fields(const xmlnode *x)
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
767 {
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
768 GList *fields = NULL;
23590
2ccc80ff0134 * 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: 23589
diff changeset
769 xmlnode *field;
24730
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
770
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
771 if (!x)
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
772 return NULL;
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
773
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
774 for (field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) {
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
775 xmlnode *value;
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
776 JabberDataFormField *xdatafield = g_new0(JabberDataFormField, 1);
23590
2ccc80ff0134 * 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: 23589
diff changeset
777 xdatafield->var = g_strdup(xmlnode_get_attrib(field, "var"));
24730
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
778
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
779 for (value = xmlnode_get_child(field, "value"); value; value = xmlnode_get_next_twin(value)) {
23590
2ccc80ff0134 * 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: 23589
diff changeset
780 gchar *val = xmlnode_get_data(value);
2ccc80ff0134 * 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: 23589
diff changeset
781 xdatafield->values = g_list_append(xdatafield->values, val);
2ccc80ff0134 * 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: 23589
diff changeset
782 }
24730
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
783
24722
4896d0884130 Use strcmp instead of a wrapper
Paul Aurich <darkrain42@pidgin.im>
parents: 24720
diff changeset
784 xdatafield->values = g_list_sort(xdatafield->values, (GCompareFunc)strcmp);
23590
2ccc80ff0134 * 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: 23589
diff changeset
785 fields = g_list_append(fields, xdatafield);
24730
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
786 }
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
787
23590
2ccc80ff0134 * 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: 23589
diff changeset
788 fields = g_list_sort(fields, jabber_caps_xdata_field_compare);
2ccc80ff0134 * 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: 23589
diff changeset
789 return fields;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
790 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
791
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
792 static GString*
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
793 jabber_caps_verification_append(GString *verification, const gchar *string)
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
794 {
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
795 verification = g_string_append(verification, string);
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
796 return g_string_append_c(verification, '<');
23590
2ccc80ff0134 * 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: 23589
diff changeset
797 }
2ccc80ff0134 * 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: 23589
diff changeset
798
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
799 gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash)
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
800 {
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
801 GList *node;
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
802 GString *verification;
23590
2ccc80ff0134 * 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: 23589
diff changeset
803 PurpleCipherContext *context;
2ccc80ff0134 * 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: 23589
diff changeset
804 guint8 checksum[20];
2ccc80ff0134 * 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: 23589
diff changeset
805 gsize checksum_size = 20;
24877
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
806 gboolean success;
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
807
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
808 if (!info || !(context = purple_cipher_context_new_by_name(hash, NULL)))
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
809 return NULL;
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
810
23589
91775cc26843 * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23588
diff changeset
811 /* sort identities, features and x-data forms */
24877
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
812 info->identities = g_list_sort(info->identities, jabber_identity_compare);
24722
4896d0884130 Use strcmp instead of a wrapper
Paul Aurich <darkrain42@pidgin.im>
parents: 24720
diff changeset
813 info->features = g_list_sort(info->features, (GCompareFunc)strcmp);
24877
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
814 info->forms = g_list_sort(info->forms, jabber_xdata_compare);
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
815
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
816 verification = g_string_new("");
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
817
23590
2ccc80ff0134 * 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: 23589
diff changeset
818 /* concat identities to the verification string */
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
819 for (node = info->identities; node; node = node->next) {
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
820 JabberIdentity *id = (JabberIdentity*)node->data;
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
821
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
822 g_string_append_printf(verification, "%s/%s/%s/%s<", id->category,
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
823 id->type, id->lang ? id->lang : "", id->name);
23590
2ccc80ff0134 * 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: 23589
diff changeset
824 }
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
825
23590
2ccc80ff0134 * 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: 23589
diff changeset
826 /* concat features to the verification string */
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
827 for (node = info->features; node; node = node->next) {
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
828 verification = jabber_caps_verification_append(verification, node->data);
23590
2ccc80ff0134 * 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: 23589
diff changeset
829 }
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
830
23590
2ccc80ff0134 * 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: 23589
diff changeset
831 /* concat x-data forms to the verification string */
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
832 for(node = info->forms; node; node = node->next) {
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
833 xmlnode *data = (xmlnode *)node->data;
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
834 gchar *formtype = jabber_caps_get_formtype(data);
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
835 GList *fields = jabber_caps_xdata_get_fields(data);
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
836
23590
2ccc80ff0134 * 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: 23589
diff changeset
837 /* append FORM_TYPE's field value to the verification string */
2ccc80ff0134 * 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: 23589
diff changeset
838 verification = jabber_caps_verification_append(verification, formtype);
2ccc80ff0134 * 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: 23589
diff changeset
839 g_free(formtype);
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
840
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
841 while (fields) {
23590
2ccc80ff0134 * 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: 23589
diff changeset
842 GList *value;
23591
ba1e3ed78d40 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23590
diff changeset
843 JabberDataFormField *field = (JabberDataFormField*)fields->data;
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
844
24730
3037dfb744ef Whitespace and formatting changes
Paul Aurich <darkrain42@pidgin.im>
parents: 24729
diff changeset
845 if (strcmp(field->var, "FORM_TYPE")) {
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
846 /* Append the "var" attribute */
23590
2ccc80ff0134 * 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: 23589
diff changeset
847 verification = jabber_caps_verification_append(verification, field->var);
24877
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
848 /* Append <value/> elements' cdata */
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
849 for(value = field->values; value; value = value->next) {
23590
2ccc80ff0134 * 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: 23589
diff changeset
850 verification = jabber_caps_verification_append(verification, value->data);
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
851 g_free(value->data);
23590
2ccc80ff0134 * 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: 23589
diff changeset
852 }
2ccc80ff0134 * 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: 23589
diff changeset
853 }
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
854
23590
2ccc80ff0134 * 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: 23589
diff changeset
855 g_free(field->var);
2ccc80ff0134 * 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: 23589
diff changeset
856 g_list_free(field->values);
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
857
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
858 fields = g_list_delete_link(fields, fields);
23590
2ccc80ff0134 * 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: 23589
diff changeset
859 }
2ccc80ff0134 * 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: 23589
diff changeset
860 }
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
861
23593
149bce500f4e * support for calculating both hashes, sha-1 and md5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23591
diff changeset
862 /* generate hash */
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
863 purple_cipher_context_append(context, (guchar*)verification->str, verification->len);
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
864
24877
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
865 success = purple_cipher_context_digest(context, verification->len,
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
866 checksum, &checksum_size);
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
867
24729
7ceae14935f8 Rework jabber_caps_calculate_hash
Paul Aurich <darkrain42@pidgin.im>
parents: 24728
diff changeset
868 g_string_free(verification, TRUE);
23590
2ccc80ff0134 * 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: 23589
diff changeset
869 purple_cipher_context_destroy(context);
24723
e3ec27a26ea6 Whitespace, formatting, and // -> /* */
Paul Aurich <darkrain42@pidgin.im>
parents: 24722
diff changeset
870
24877
ee51a3be800d Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <darkrain42@pidgin.im>
parents: 24876
diff changeset
871 return (success ? purple_base64_encode(checksum, checksum_size) : NULL);
23587
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
872 }
1691c5361029 * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23586
diff changeset
873
23595
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
874 void jabber_caps_calculate_own_hash(JabberStream *js) {
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
875 JabberCapsClientInfo info;
23595
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
876 GList *iter = 0;
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
877 GList *features = 0;
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
878
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
879 if (!jabber_identities && !jabber_features) {
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
880 /* This really shouldn't ever happen */
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
881 purple_debug_warning("jabber", "No features or identities, cannot calculate own caps hash.\n");
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
882 g_free(js->caps_hash);
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
883 js->caps_hash = NULL;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
884 return;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
885 }
23599
ac402ffdcbec * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23597
diff changeset
886
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
887 /* build the currently-supported list of features */
23595
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
888 if (jabber_features) {
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
889 for (iter = jabber_features; iter; iter = iter->next) {
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
890 JabberFeature *feat = iter->data;
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
891 if(!feat->is_enabled || feat->is_enabled(js, feat->namespace)) {
23595
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
892 features = g_list_append(features, feat->namespace);
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
893 }
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
894 }
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
895 }
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
896
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
897 info.features = features;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
898 info.identities = jabber_identities;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
899 info.forms = NULL;
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
900
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
901 g_free(js->caps_hash);
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
902 js->caps_hash = jabber_caps_calculate_hash(&info, "sha1");
23595
728a8a576f11 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23594
diff changeset
903 g_list_free(features);
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
904 }
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
905
24716
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
906 const gchar* jabber_caps_get_own_hash(JabberStream *js)
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
907 {
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
908 if (!js->caps_hash)
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
909 jabber_caps_calculate_own_hash(js);
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
910
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
911 return js->caps_hash;
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
912 }
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21720
diff changeset
913
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
914 void jabber_caps_broadcast_change()
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
915 {
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
916 GList *node, *accounts = purple_accounts_get_all_active();
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
917
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
918 for (node = accounts; node; node = node->next) {
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
919 PurpleAccount *account = node->data;
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
920 const char *prpl_id = purple_account_get_protocol_id(account);
24718
8507ef880d6d Fix a null dereference on non-connected accounts
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
921 if (!strcmp("prpl-jabber", prpl_id) && purple_account_is_connected(account)) {
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
922 PurpleConnection *gc = purple_account_get_connection(account);
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
923 jabber_presence_send(gc->proto_data, TRUE);
23601
f7e44345f4b9 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23600
diff changeset
924 }
f7e44345f4b9 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23600
diff changeset
925 }
24717
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
926
13c7497f44f8 Clean up jabber_presence_send
Paul Aurich <darkrain42@pidgin.im>
parents: 24716
diff changeset
927 g_list_free(accounts);
23601
f7e44345f4b9 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23600
diff changeset
928 }
f7e44345f4b9 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 23600
diff changeset
929

mercurial