annotate libpurple/protocols/jabber/caps.c @ 25784:05693f6885a4

Support old (XEP v1.3) Entity Capabilities alongside the new ones. The ext structures from v1.3 are stored in a ref-counted structure that is shared among all instances of the ClientInfo that share the same 'node' (unique per client). exts are only used for v1.3-entity capabilities clients and are not shared with caps that specify the 'hash' attribute (required in v1.5). The jabber_caps_cbplususerdata is also ref-counted and will never leak, even if some disco#info responses from a client return errors.
author Paul Aurich <paul@darkrain42.org>
date Fri, 19 Dec 2008 04:11:07 +0000
parents d5b1fede10a0
children 3bec4f4db198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
1 /*
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
3 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
4 * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com>
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
5 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
9 * (at your option) any later version.
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
10 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
14 * GNU General Public License for more details.
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
15 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
19 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
20 */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
21
19697
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17629
diff changeset
22 #include "internal.h"
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17629
diff changeset
23
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
24 #include "debug.h"
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
25 #include "caps.h"
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
26 #include "cipher.h"
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
27 #include "iq.h"
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
28 #include "presence.h"
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
29 #include "util.h"
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
30
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
31 #define JABBER_CAPS_FILENAME "xmpp-caps.xml"
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
32
25758
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
33 typedef struct _JabberDataFormField {
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
34 gchar *var;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
35 GList *values;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
36 } JabberDataFormField;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
37
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
38 typedef struct _JabberCapsKey {
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
39 char *node;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
40 char *ver;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
41 char *hash;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
42 } JabberCapsKey;
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
43
25762
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
44 static GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsClientInfo */
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
45 static GHashTable *nodetable = NULL; /* char *node -> JabberCapsNodeExts */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
46 static guint save_timer = 0;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
47
25758
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
48 /**
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
49 * Processes a query-node and returns a JabberCapsClientInfo object with all relevant info.
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
50 *
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
51 * @param query A query object.
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
52 * @return A JabberCapsClientInfo object.
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
53 */
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
54 static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query);
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
55
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
56 #if 0
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
57 typedef struct _JabberCapsValue {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
58 GList *identities; /* JabberCapsIdentity */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
59 GList *features; /* char * */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
60 GHashTable *ext; /* char * -> JabberCapsValueExt */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
61 } JabberCapsValue;
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
62 #endif
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
63
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
64 /* Free a GList of allocated char* */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
65 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
66 free_string_glist(GList *list)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
67 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
68 g_list_foreach(list, (GFunc)g_free, NULL);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
69 g_list_free(list);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
70 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
71
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
72 static JabberCapsNodeExts*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
73 jabber_caps_node_exts_ref(JabberCapsNodeExts *exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
74 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
75 g_return_val_if_fail(exts != NULL, NULL);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
76
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
77 ++exts->ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
78 return exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
79 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
80
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
81 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
82 jabber_caps_node_exts_unref(JabberCapsNodeExts *exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
83 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
84 if (exts == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
85 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
86
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
87 g_return_if_fail(exts->ref != 0);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
88
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
89 if (--exts->ref != 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
90 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
91
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
92 g_hash_table_destroy(exts->exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
93 g_free(exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
94 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
95
25783
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
96 static guint jabber_caps_hash(gconstpointer data) {
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
97 const JabberCapsKey *key = data;
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
98 guint nodehash = g_str_hash(key->node);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
99 guint verhash = g_str_hash(key->ver);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
100 /* 'hash' was optional in XEP-0115 v1.4 and I think g_str_hash crashes on
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
101 * NULL >:O. Okay, maybe I've played too much Zelda, but that looks like
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
102 * a Deku Shrub... */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
103 guint hashhash = (key->hash ? g_str_hash(key->hash) : 0);
25585
45816181b7de * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25584
diff changeset
104 return nodehash ^ verhash ^ hashhash;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
105 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
106
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
107 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
108 const JabberCapsKey *name1 = v1;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
109 const JabberCapsKey *name2 = v2;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
110 /* Again, hash might be NULL and I *know* strcmp will crash on NULL. */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
111 gboolean hasheq = ((!name1->hash && !name2->hash) ||
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
112 (name1->hash && name2->hash && !strcmp(name1->hash, name2->hash)));
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
113
25748
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25746
diff changeset
114 return strcmp(name1->node, name2->node) == 0 &&
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25746
diff changeset
115 strcmp(name1->ver, name2->ver) == 0 &&
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
116 hasheq;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
117 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
118
25783
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
119 void jabber_caps_destroy_key(gpointer data) {
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
120 JabberCapsKey *key = data;
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
121 g_free(key->node);
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
122 g_free(key->ver);
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
123 g_free(key->hash);
d5b1fede10a0 Rename a few variables
Paul Aurich <paul@darkrain42.org>
parents: 25782
diff changeset
124 g_free(key);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
125 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
126
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
127 JabberCapsClientInfo *
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
128 jabber_caps_client_info_ref(JabberCapsClientInfo *info)
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
129 {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
130 g_return_val_if_fail(info != NULL, NULL);
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
131 ++info->ref;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
132 return info;
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
133 }
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
134
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
135 void
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
136 jabber_caps_client_info_unref(JabberCapsClientInfo *info)
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
137 {
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
138 if (info == NULL)
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
139 return;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
140
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
141 g_return_if_fail(info->ref != 0);
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
142
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
143 if (--info->ref != 0)
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
144 return;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
145
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
146 while(info->identities) {
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
147 JabberIdentity *id = info->identities->data;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
148 g_free(id->category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
149 g_free(id->type);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
150 g_free(id->name);
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
151 g_free(id->lang);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
152 g_free(id);
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
153 info->identities = g_list_delete_link(info->identities, info->identities);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
154 }
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
155
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
156 free_string_glist(info->features);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
157 free_string_glist(info->forms);
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
158
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
159 jabber_caps_node_exts_unref(info->exts);
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
160
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
161 #if 0
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
162 g_hash_table_destroy(valuestruct->ext);
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
163 #endif
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
164
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
165 g_free(info);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
166 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
167
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
168 /* NOTE: Takes a reference to the exts, unref it if you don't really want to
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
169 * keep it around. */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
170 static JabberCapsNodeExts*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
171 jabber_caps_find_exts_by_node(const char *node)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
172 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
173 JabberCapsNodeExts *exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
174 if (NULL == (exts = g_hash_table_lookup(nodetable, node))) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
175 exts = g_new0(JabberCapsNodeExts, 1);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
176 exts->exts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
177 (GDestroyNotify)free_string_glist);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
178 g_hash_table_insert(nodetable, g_strdup(node), jabber_caps_node_exts_ref(exts));
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
179 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
180
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
181 return jabber_caps_node_exts_ref(exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
182 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
183
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
184 #if 0
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
185 static void jabber_caps_ext_destroy_value(gpointer value) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
186 JabberCapsValueExt *valuestruct = value;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
187 while(valuestruct->identities) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
188 JabberCapsIdentity *id = valuestruct->identities->data;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
189 g_free(id->category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
190 g_free(id->type);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
191 g_free(id->name);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
192 g_free(id);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
193
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
194 valuestruct->identities = g_list_delete_link(valuestruct->identities,valuestruct->identities);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
195 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
196 while(valuestruct->features) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
197 g_free(valuestruct->features->data);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
198 valuestruct->features = g_list_delete_link(valuestruct->features,valuestruct->features);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
199 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
200 g_free(valuestruct);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
201 }
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
202 #endif
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
203
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
204 static void jabber_caps_load(void);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
205 static gboolean do_jabber_caps_store(gpointer data);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
206
25762
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
207 void jabber_caps_init(void)
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
208 {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
209 nodetable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)jabber_caps_node_exts_unref);
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
210 capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, jabber_caps_destroy_key, (GDestroyNotify)jabber_caps_client_info_unref);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
211 jabber_caps_load();
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
212 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
213
25762
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
214 void jabber_caps_uninit(void)
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
215 {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
216 if (save_timer != 0) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
217 purple_timeout_remove(save_timer);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
218 save_timer = 0;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
219 do_jabber_caps_store(NULL);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
220 }
25762
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
221 g_hash_table_destroy(capstable);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
222 g_hash_table_destroy(nodetable);
25762
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
223 capstable = NULL;
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
224 }
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25761
diff changeset
225
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
226 static void jabber_caps_load(void) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
227 xmlnode *capsdata = purple_util_read_xml_from_file(JABBER_CAPS_FILENAME, "XMPP capabilities cache");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
228 xmlnode *client;
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
229
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
230 if(!capsdata)
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
231 return;
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
232
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
233 if (strcmp(capsdata->name, "capabilities") != 0) {
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
234 xmlnode_free(capsdata);
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
235 return;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
236 }
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
237
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
238 for(client = capsdata->child; client; client = client->next) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
239 if(client->type != XMLNODE_TYPE_TAG)
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
240 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
241 if(!strcmp(client->name, "client")) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
242 JabberCapsKey *key = g_new0(JabberCapsKey, 1);
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
243 JabberCapsClientInfo *value = g_new0(JabberCapsClientInfo, 1);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
244 xmlnode *child;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
245 JabberCapsNodeExts *exts = NULL;
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
246 jabber_caps_client_info_ref(value);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
247 key->node = g_strdup(xmlnode_get_attrib(client,"node"));
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
248 key->ver = g_strdup(xmlnode_get_attrib(client,"ver"));
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
249 key->hash = g_strdup(xmlnode_get_attrib(client,"hash"));
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
250
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
251 /* v1.3 capabilities */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
252 if (key->hash == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
253 exts = jabber_caps_find_exts_by_node(key->node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
254
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
255 for(child = client->child; child; child = child->next) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
256 if(child->type != XMLNODE_TYPE_TAG)
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
257 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
258 if(!strcmp(child->name,"feature")) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
259 const char *var = xmlnode_get_attrib(child, "var");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
260 if(!var)
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
261 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
262 value->features = g_list_append(value->features,g_strdup(var));
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
263 } else if(!strcmp(child->name,"identity")) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
264 const char *category = xmlnode_get_attrib(child, "category");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
265 const char *type = xmlnode_get_attrib(child, "type");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
266 const char *name = xmlnode_get_attrib(child, "name");
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
267 const char *lang = xmlnode_get_attrib(child, "lang");
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
268 JabberIdentity *id;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
269
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
270 if (!category || !type)
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
271 continue;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
272
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
273 id = g_new0(JabberIdentity, 1);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
274 id->category = g_strdup(category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
275 id->type = g_strdup(type);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
276 id->name = g_strdup(name);
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
277 id->lang = g_strdup(lang);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
278
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
279 value->identities = g_list_append(value->identities,id);
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
280 } else if(!strcmp(child->name,"x")) {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
281 /* FIXME: See #7814 -- this will cause problems if anyone
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
282 * ever actually specifies forms. In fact, for this to
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
283 * work properly, that bug needs to be fixed in
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
284 * xmlnode_from_str, not the output version... */
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
285 value->forms = g_list_append(value->forms, xmlnode_copy(child));
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
286 } else if (!strcmp(child->name, "ext") && key->hash != NULL) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
287 purple_debug_warning("jabber", "Ignoring exts when reading new-style caps\n");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
288 } else if (!strcmp(child->name, "ext")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
289 /* TODO: Do we care about reading in the identities listed here? */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
290 const char *identifier = xmlnode_get_attrib(child, "identifier");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
291 xmlnode *node;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
292 GList *features = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
293
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
294 if (!identifier)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
295 continue;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
296
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
297 for (node = child->child; node; node = node->next) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
298 if (node->type != XMLNODE_TYPE_TAG)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
299 continue;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
300 if (!strcmp(node->name, "feature")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
301 const char *var = xmlnode_get_attrib(node, "var");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
302 if (!var)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
303 continue;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
304 features = g_list_prepend(features, g_strdup(var));
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
305 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
306 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
307
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
308 if (features) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
309 g_hash_table_insert(exts->exts, g_strdup(identifier),
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
310 features);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
311 } else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
312 purple_debug_warning("jabber", "Caps ext %s had no features.\n",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
313 identifier);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
314 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
315 }
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
316
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
317 value->exts = exts;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
318 g_hash_table_replace(capstable, key, value);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
319
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
320 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
321 }
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
322 xmlnode_free(capsdata);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
323 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
324
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
325 #if 0
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
326 static void jabber_caps_store_ext(gpointer key, gpointer value, gpointer user_data) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
327 const char *extname = key;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
328 JabberCapsValueExt *props = value;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
329 xmlnode *root = user_data;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
330 xmlnode *ext = xmlnode_new_child(root,"ext");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
331 GList *iter;
19726
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19721
diff changeset
332
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
333 xmlnode_set_attrib(ext,"identifier",extname);
19726
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19721
diff changeset
334
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
335 for(iter = props->identities; iter; iter = g_list_next(iter)) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
336 JabberCapsIdentity *id = iter->data;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
337 xmlnode *identity = xmlnode_new_child(ext, "identity");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
338 xmlnode_set_attrib(identity, "category", id->category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
339 xmlnode_set_attrib(identity, "type", id->type);
19726
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19721
diff changeset
340 if (id->name)
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19721
diff changeset
341 xmlnode_set_attrib(identity, "name", id->name);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
342 }
19726
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19721
diff changeset
343
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
344 for(iter = props->features; iter; iter = g_list_next(iter)) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
345 const char *feat = iter->data;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
346 xmlnode *feature = xmlnode_new_child(ext, "feature");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
347 xmlnode_set_attrib(feature, "var", feat);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
348 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
349 }
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
350 #endif
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
351
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
352 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
353 exts_to_xmlnode(gconstpointer key, gconstpointer value, gpointer user_data)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
354 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
355 const char *identifier = key;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
356 const GList *features = value, *node;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
357 xmlnode *client = user_data, *ext, *feature;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
358
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
359 ext = xmlnode_new_child(client, "ext");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
360 xmlnode_set_attrib(ext, "identifier", identifier);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
361
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
362 for (node = features; node; node = node->next) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
363 feature = xmlnode_new_child(ext, "feature");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
364 xmlnode_set_attrib(feature, "var", (const gchar *)node->data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
365 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
366 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
367
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
368 static void jabber_caps_store_client(gpointer key, gpointer value, gpointer user_data) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
369 JabberCapsKey *clientinfo = key;
25757
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25756
diff changeset
370 JabberCapsClientInfo *props = value;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
371 xmlnode *root = user_data;
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25592
diff changeset
372 xmlnode *client = xmlnode_new_child(root, "client");
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
373 GList *iter;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
374
25593
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25592
diff changeset
375 xmlnode_set_attrib(client, "node", clientinfo->node);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25592
diff changeset
376 xmlnode_set_attrib(client, "ver", clientinfo->ver);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
377 if (clientinfo->hash)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
378 xmlnode_set_attrib(client, "hash", clientinfo->hash);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
379 for(iter = props->identities; iter; iter = g_list_next(iter)) {
25750
30a686c079d5 Remove JabberCapsIdentity and just use JabberIdentity everywhere
Paul Aurich <paul@darkrain42.org>
parents: 25749
diff changeset
380 JabberIdentity *id = iter->data;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
381 xmlnode *identity = xmlnode_new_child(client, "identity");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
382 xmlnode_set_attrib(identity, "category", id->category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
383 xmlnode_set_attrib(identity, "type", id->type);
21325
d7a43e142c6e An identity does not always have a name; for example, Google Talk web folks can have type 'web', category 'client', no name.
Evan Schoenberg <evan.s@dreskin.net>
parents: 19728
diff changeset
384 if (id->name)
d7a43e142c6e An identity does not always have a name; for example, Google Talk web folks can have type 'web', category 'client', no name.
Evan Schoenberg <evan.s@dreskin.net>
parents: 19728
diff changeset
385 xmlnode_set_attrib(identity, "name", id->name);
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
386 if (id->lang)
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
387 xmlnode_set_attrib(identity, "lang", id->lang);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
388 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
389
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
390 for(iter = props->features; iter; iter = g_list_next(iter)) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
391 const char *feat = iter->data;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
392 xmlnode *feature = xmlnode_new_child(client, "feature");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
393 xmlnode_set_attrib(feature, "var", feat);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
394 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
395
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
396 for(iter = props->forms; iter; iter = g_list_next(iter)) {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
397 /* FIXME: See #7814 */
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
398 xmlnode *xdata = iter->data;
25591
324cd6544a7b * fixing memory related bug; forgotton to duplicate some data which otherwise may be deleted by other parts of the program
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25590
diff changeset
399 xmlnode_insert_child(client, xmlnode_copy(xdata));
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
400 }
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
401
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
402 /* TODO: Ideally, only save this once-per-node... */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
403 if (props->exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
404 g_hash_table_foreach(props->exts->exts, (GHFunc)exts_to_xmlnode, client);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
405 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
406
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
407 static gboolean
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
408 do_jabber_caps_store(gpointer data)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
409 {
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
410 char *str;
25589
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25588
diff changeset
411 int length = 0;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
412 xmlnode *root = xmlnode_new("capabilities");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
413 g_hash_table_foreach(capstable, jabber_caps_store_client, root);
25589
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25588
diff changeset
414 str = xmlnode_to_formatted_str(root, &length);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
415 xmlnode_free(root);
25589
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25588
diff changeset
416 purple_util_write_data_to_file(JABBER_CAPS_FILENAME, str, length);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
417 g_free(str);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
418
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
419 save_timer = 0;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
420 return FALSE;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
421 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
422
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
423 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
424 schedule_caps_save(void)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
425 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
426 if (save_timer == 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
427 save_timer = purple_timeout_add_seconds(5, do_jabber_caps_store, NULL);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
428 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
429
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
430 #if 0
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
431 /* this function assumes that all information is available locally */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
432 static JabberCapsClientInfo *jabber_caps_collect_info(const char *node, const char *ver, GList *ext) {
21688
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
433 JabberCapsClientInfo *result;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
434 JabberCapsKey *key = g_new0(JabberCapsKey, 1);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
435 JabberCapsValue *caps;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
436 GList *iter;
21688
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
437
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
438 key->node = (char *)node;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
439 key->ver = (char *)ver;
21688
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
440
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
441 caps = g_hash_table_lookup(capstable,key);
21688
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
442
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
443 g_free(key);
21688
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
444
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
445 if (caps == NULL)
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
446 return NULL;
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
447
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
448 result = g_new0(JabberCapsClientInfo, 1);
6f4ffdc65230 Fix a crash when an error occurs discovering a the capabilities of a client. Fixes #4081.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21595
diff changeset
449
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
450 /* join all information */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
451 for(iter = caps->identities; iter; iter = g_list_next(iter)) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
452 JabberCapsIdentity *id = iter->data;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
453 JabberCapsIdentity *newid = g_new0(JabberCapsIdentity, 1);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
454 newid->category = g_strdup(id->category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
455 newid->type = g_strdup(id->type);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
456 newid->name = g_strdup(id->name);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
457
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
458 result->identities = g_list_append(result->identities,newid);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
459 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
460 for(iter = caps->features; iter; iter = g_list_next(iter)) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
461 const char *feat = iter->data;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
462 char *newfeat = g_strdup(feat);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
463
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
464 result->features = g_list_append(result->features,newfeat);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
465 }
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
466 #if 0
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
467 for(iter = ext; iter; iter = g_list_next(iter)) {
17613
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17609
diff changeset
468 const char *extname = iter->data;
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17609
diff changeset
469 JabberCapsValueExt *extinfo = g_hash_table_lookup(caps->ext,extname);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
470
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
471 if(extinfo) {
17613
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17609
diff changeset
472 GList *iter2;
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17609
diff changeset
473 for(iter2 = extinfo->identities; iter2; iter2 = g_list_next(iter2)) {
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17609
diff changeset
474 JabberCapsIdentity *id = iter2->data;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
475 JabberCapsIdentity *newid = g_new0(JabberCapsIdentity, 1);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
476 newid->category = g_strdup(id->category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
477 newid->type = g_strdup(id->type);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
478 newid->name = g_strdup(id->name);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
479
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
480 result->identities = g_list_append(result->identities,newid);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
481 }
17613
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17609
diff changeset
482 for(iter2 = extinfo->features; iter2; iter2 = g_list_next(iter2)) {
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17609
diff changeset
483 const char *feat = iter2->data;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
484 char *newfeat = g_strdup(feat);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
485
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
486 result->features = g_list_append(result->features,newfeat);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
487 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
488 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
489 }
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
490 #endif
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
491 return result;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
492 }
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
493 #endif
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
494
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
495 typedef struct _jabber_caps_cbplususerdata {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
496 guint ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
497
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
498 jabber_caps_get_info_cb cb;
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
499 gpointer cb_data;
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
500
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
501 char *who;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
502 char *node;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
503 char *ver;
25580
4c97156431b4 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25579
diff changeset
504 char *hash;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
505
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
506 JabberCapsClientInfo *info;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
507
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
508 GList *exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
509 guint extOutstanding;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
510 JabberCapsNodeExts *node_exts;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
511 } jabber_caps_cbplususerdata;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
512
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
513 static jabber_caps_cbplususerdata*
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
514 cbplususerdata_ref(jabber_caps_cbplususerdata *data)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
515 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
516 g_return_val_if_fail(data != NULL, NULL);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
517
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
518 ++data->ref;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
519 return data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
520 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
521
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
522 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
523 cbplususerdata_unref(jabber_caps_cbplususerdata *data)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
524 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
525 if (data == NULL)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
526 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
527
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
528 g_return_if_fail(data->ref != 0);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
529
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
530 if (--data->ref > 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
531 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
532
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
533 g_free(data->who);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
534 g_free(data->node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
535 g_free(data->ver);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
536 g_free(data->hash);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
537
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
538 if (data->info)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
539 jabber_caps_client_info_unref(data->info);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
540 if (data->exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
541 free_string_glist(data->exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
542 if (data->node_exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
543 jabber_caps_node_exts_unref(data->node_exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
544 g_free(data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
545 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
546
25746
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
547 #if 0
19724
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
548 typedef struct jabber_ext_userdata {
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
549 jabber_caps_cbplususerdata *userdata;
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
550 char *node;
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
551 } jabber_ext_userdata;
25746
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
552 #endif
19724
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
553
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
554 #if 0
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
555 static void jabber_caps_get_info_check_completion(jabber_caps_cbplususerdata *userdata) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
556 if(userdata->extOutstanding == 0) {
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
557 userdata->cb(jabber_caps_collect_info(userdata->node, userdata->ver, userdata->ext), userdata->cb_data);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
558 g_free(userdata->who);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
559 g_free(userdata->node);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
560 g_free(userdata->ver);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
561 while(userdata->ext) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
562 g_free(userdata->ext->data);
17629
ce04ca030a1b Fixed some memory leaks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17613
diff changeset
563 userdata->ext = g_list_delete_link(userdata->ext,userdata->ext);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
564 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
565 g_free(userdata);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
566 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
567 }
25583
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25582
diff changeset
568 #endif
25588
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25586
diff changeset
569 #if 0
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
570 static void jabber_caps_ext_iqcb(JabberStream *js, xmlnode *packet, gpointer data) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
571 /* collect data and fetch all exts */
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
572 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#info");
19724
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
573 jabber_ext_userdata *extuserdata = data;
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
574 jabber_caps_cbplususerdata *userdata = extuserdata->userdata;
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
575 const char *node = extuserdata->node;
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
576
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
577 --userdata->extOutstanding;
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
578
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
579 /* TODO: Better error handling */
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
580 printf("\n\tjabber_caps_ext_iqcb for %s", xmlnode_get_attrib(packet, "from"));
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
581 if(node && query) {
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
582 const char *key;
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
583 JabberCapsValue *client;
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
584 xmlnode *child;
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
585 JabberCapsValueExt *value = g_new0(JabberCapsValueExt, 1);
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
586 JabberCapsKey *clientkey = g_new0(JabberCapsKey, 1);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
587
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
588 clientkey->node = userdata->node;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
589 clientkey->ver = userdata->ver;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
590
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
591 client = g_hash_table_lookup(capstable, clientkey);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
592
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
593 g_free(clientkey);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
594
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
595 /* split node by #, key either points to \0 or the correct ext afterwards */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
596 for(key = node; key[0] != '\0'; ++key) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
597 if(key[0] == '#') {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
598 ++key;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
599 break;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
600 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
601 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
602
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
603 for(child = query->child; child; child = child->next) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
604 if(child->type != XMLNODE_TYPE_TAG)
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
605 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
606 if(!strcmp(child->name,"feature")) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
607 const char *var = xmlnode_get_attrib(child, "var");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
608 if(!var)
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
609 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
610 value->features = g_list_append(value->features,g_strdup(var));
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
611 } else if(!strcmp(child->name,"identity")) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
612 const char *category = xmlnode_get_attrib(child, "category");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
613 const char *type = xmlnode_get_attrib(child, "type");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
614 const char *name = xmlnode_get_attrib(child, "name");
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
615
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
616 JabberCapsIdentity *id = g_new0(JabberCapsIdentity, 1);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
617 id->category = g_strdup(category);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
618 id->type = g_strdup(type);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
619 id->name = g_strdup(name);
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
620
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
621 value->identities = g_list_append(value->identities,id);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
622 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
623 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
624 jabber_caps_store();
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
625 }
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
626
19724
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
627 g_free(extuserdata->node);
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
628 g_free(extuserdata);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
629 jabber_caps_get_info_check_completion(userdata);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
630 }
25588
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25586
diff changeset
631 #endif
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
632
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
633 static void
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
634 jabber_caps_get_info_complete(jabber_caps_cbplususerdata *userdata)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
635 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
636 userdata->cb(userdata->info, userdata->exts, userdata->cb_data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
637 userdata->info = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
638 userdata->exts = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
639
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
640 if (userdata->ref != 1)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
641 purple_debug_warning("jabber", "Lost a reference to caps cbdata: %d\n",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
642 userdata->ref);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
643 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
644
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
645 static void
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
646 jabber_caps_client_iqcb(JabberStream *js, xmlnode *packet, gpointer data)
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
647 {
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
648 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
649 "http://jabber.org/protocol/disco#info");
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
650 jabber_caps_cbplususerdata *userdata = data;
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
651 JabberCapsClientInfo *info = NULL, *value;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
652 const char *type = xmlnode_get_attrib(packet, "type");
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
653 JabberCapsKey key;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
654
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
655 if (!query || !strcmp(type, "error")) {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
656 /* Any outstanding exts will be dealt with via ref-counting */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
657 userdata->cb(NULL, NULL, userdata->cb_data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
658 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
659 return;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
660 }
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
661
25753
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25752
diff changeset
662 /* check hash */
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25752
diff changeset
663 info = jabber_caps_parse_client_info(query);
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
664
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
665 /* Only validate if these are v1.5 capabilities */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
666 if (userdata->hash) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
667 gchar *hash = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
668 if (!strcmp(userdata->hash, "sha-1")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
669 hash = jabber_caps_calculate_hash(info, "sha1");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
670 } else if (!strcmp(userdata->hash, "md5")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
671 hash = jabber_caps_calculate_hash(info, "md5");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
672 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
673
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
674 if (!hash || strcmp(hash, userdata->ver)) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
675 purple_debug_warning("jabber", "Could not validate caps info from %s\n",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
676 xmlnode_get_attrib(packet, "from"));
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
677
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
678 userdata->cb(NULL, NULL, userdata->cb_data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
679 jabber_caps_client_info_unref(info);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
680 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
681 g_free(hash);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
682 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
683 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
684
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
685 g_free(hash);
25753
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25752
diff changeset
686 }
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
687
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
688 if (!userdata->hash && userdata->node_exts) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
689 /* If the ClientInfo doesn't have information about the exts, give them
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
690 * ours (along with our ref) */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
691 info->exts = userdata->node_exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
692 userdata->node_exts = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
693 }
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
694
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
695 userdata->info = info;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
696
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
697 key.node = userdata->node;
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
698 key.ver = userdata->ver;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
699 key.hash = userdata->hash;
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
700
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
701 /* Use the copy of this data already in the table if it exists or insert
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
702 * a new one if we need to */
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
703 if ((value = g_hash_table_lookup(capstable, &key))) {
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
704 jabber_caps_client_info_unref(info);
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
705 jabber_caps_client_info_ref(value);
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
706 info = value;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
707 } else {
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
708 JabberCapsKey *n_key = g_new(JabberCapsKey, 1);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
709 n_key->node = userdata->node;
25780
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25765
diff changeset
710 n_key->ver = userdata->ver;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
711 n_key->hash = userdata->hash;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
712 userdata->node = userdata->ver = userdata->hash = NULL;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
713
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
714 /* The capstable gets a reference */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
715 g_hash_table_insert(capstable, n_key, jabber_caps_client_info_ref(info));
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
716 schedule_caps_save();
25753
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25752
diff changeset
717 }
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
718
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
719 if (userdata->extOutstanding == 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
720 jabber_caps_get_info_complete(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
721
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
722 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
723 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
724
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
725 typedef struct {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
726 const char *name;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
727 jabber_caps_cbplususerdata *data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
728 } ext_iq_data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
729
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
730 static void
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
731 jabber_caps_ext_iqcb(JabberStream *js, xmlnode *packet, gpointer data)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
732 {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
733 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
734 "http://jabber.org/protocol/disco#info");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
735 xmlnode *child;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
736 ext_iq_data *userdata = data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
737 const char *type = xmlnode_get_attrib(packet, "type");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
738 GList *features = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
739 JabberCapsNodeExts *node_exts;
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
740
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
741 if (!query || !strcmp(type, "error")) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
742 cbplususerdata_unref(userdata->data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
743 g_free(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
744 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
745 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
746
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
747 /* So, we decrement this after checking for an error, which means that
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
748 * if there *is* an error, we'll never call the callback passed to
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
749 * jabber_caps_get_info. We will still free all of our data, though.
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
750 */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
751 --userdata->data->extOutstanding;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
752
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
753 for (child = xmlnode_get_child(query, "feature"); child;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
754 child = xmlnode_get_next_twin(child)) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
755 const char *var = xmlnode_get_attrib(child, "var");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
756 if (var)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
757 features = g_list_prepend(features, g_strdup(var));
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
758 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
759
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
760 node_exts = (userdata->data->info ? userdata->data->info->exts :
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
761 userdata->data->node_exts);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
762 g_hash_table_insert(node_exts->exts, g_strdup(userdata->name), features);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
763 schedule_caps_save();
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
764
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
765 /* Are we done? */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
766 if (userdata->data->info && userdata->data->extOutstanding == 0)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
767 jabber_caps_get_info_complete(userdata->data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
768
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
769 cbplususerdata_unref(userdata->data);
25754
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25753
diff changeset
770 g_free(userdata);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
771 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
772
25746
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
773 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
774 const char *ver, const char *hash, const char *ext,
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
775 jabber_caps_get_info_cb cb, gpointer user_data)
25746
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
776 {
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
777 JabberCapsClientInfo *info;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
778 JabberCapsKey key;
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
779 jabber_caps_cbplususerdata *userdata;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
780
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
781 if (ext && *ext && hash)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
782 purple_debug_warning("jabber", "Ignoring exts in new-style caps from %s\n",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
783 who);
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
784
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
785 /* Using this in a read-only fashion, so the cast is OK */
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
786 key.node = (char *)node;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
787 key.ver = (char *)ver;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
788 key.hash = (char *)hash;
19697
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17629
diff changeset
789
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
790 info = g_hash_table_lookup(capstable, &key);
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
791 if (info && hash) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
792 /* v1.5 - We already have all the information we care about */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
793 cb(jabber_caps_client_info_ref(info), NULL, user_data);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
794 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
795 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
796
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
797 userdata = g_new0(jabber_caps_cbplususerdata, 1);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
798 /* This ref is given to fetching the basic node#ver info if we need it
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
799 * or unrefed at the bottom of this function */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
800 cbplususerdata_ref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
801 userdata->cb = cb;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
802 userdata->cb_data = user_data;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
803 userdata->who = g_strdup(who);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
804 userdata->node = g_strdup(node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
805 userdata->ver = g_strdup(ver);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
806 userdata->hash = g_strdup(hash);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
807
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
808 if (info) {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
809 userdata->info = jabber_caps_client_info_ref(info);
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
810 } else {
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
811 /* If we don't have the basic information about the client, we need
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
812 * to fetch it. */
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
813 JabberIq *iq;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
814 xmlnode *query;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
815 char *nodever;
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
816
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
817 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
818 "http://jabber.org/protocol/disco#info");
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
819 query = xmlnode_get_child_with_namespace(iq->node, "query",
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
820 "http://jabber.org/protocol/disco#info");
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
821 nodever = g_strdup_printf("%s#%s", node, ver);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
822 xmlnode_set_attrib(query, "node", nodever);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
823 g_free(nodever);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
824 xmlnode_set_attrib(iq->node, "to", who);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
825
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
826 jabber_iq_set_callback(iq, jabber_caps_client_iqcb, userdata);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
827 jabber_iq_send(iq);
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
828 }
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
829
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
830 /* Are there any exts that we don't recognize? */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
831 if (ext && *ext && !hash) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
832 JabberCapsNodeExts *node_exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
833 gchar **splat = g_strsplit(ext, " ", 0);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
834 int i;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
835
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
836 if (info) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
837 if (info->exts)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
838 node_exts = info->exts;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
839 else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
840 node_exts = info->exts = jabber_caps_find_exts_by_node(node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
841 } else
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
842 /* We'll put it in later once we have the client info */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
843 node_exts = userdata->node_exts = jabber_caps_find_exts_by_node(node);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
844
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
845 for (i = 0; splat[i]; ++i) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
846 userdata->exts = g_list_prepend(userdata->exts, splat[i]);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
847 /* Look it up if we don't already know what it means */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
848 if (!g_hash_table_lookup(node_exts->exts, splat[i])) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
849 JabberIq *iq;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
850 xmlnode *query;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
851 char *nodeext;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
852 ext_iq_data *cbdata = g_new(ext_iq_data, 1);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
853
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
854 cbdata->name = splat[i];
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
855 cbdata->data = cbplususerdata_ref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
856
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
857 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
858 "http://jabber.org/protocol/disco#info");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
859 query = xmlnode_get_child_with_namespace(iq->node, "query",
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
860 "http://jabber.org/protocol/disco#info");
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
861 nodeext = g_strdup_printf("%s#%s", node, splat[i]);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
862 xmlnode_set_attrib(query, "node", nodeext);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
863 g_free(nodeext);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
864 xmlnode_set_attrib(iq->node, "to", who);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
865
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
866 jabber_iq_set_callback(iq, jabber_caps_ext_iqcb, cbdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
867 jabber_iq_send(iq);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
868
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
869 ++userdata->extOutstanding;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
870 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
871 splat[i] = NULL;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
872 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
873 /* All the strings are now part of the GList, so don't need
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
874 * g_strfreev. */
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
875 g_free(splat);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
876 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
877
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
878 if (userdata->info && userdata->extOutstanding == 0) {
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
879 jabber_caps_get_info_complete(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
880 cbplususerdata_unref(userdata);
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
881 }
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
882
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
883 return;
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
884
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
885 #if 0
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
886 /* The above check was originally simply "if (!info)", so this was executed
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
887 * on info being non-null */
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
888 } else {
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
889 GList *iter;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
890 /* fetch unknown exts only */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
891 for(iter = userdata->ext; iter; iter = g_list_next(iter)) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
892 JabberCapsValueExt *extvalue = g_hash_table_lookup(client->ext, (const char*)iter->data);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
893 JabberIq *iq;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
894 xmlnode *query;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
895 char *nodever;
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
896 jabber_ext_userdata *ext_data;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
897
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
898 if(extvalue) {
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
899 /* we already have this ext, don't bother with it */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
900 --userdata->extOutstanding;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
901 continue;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
902 }
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
903
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
904 ext_data = g_new0(jabber_ext_userdata, 1);
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
905
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
906 iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#info");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
907 query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#info");
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
908 nodever = g_strdup_printf("%s#%s", node, (const char*)iter->data);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
909 xmlnode_set_attrib(query, "node", nodever);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
910 xmlnode_set_attrib(iq->node, "to", who);
19728
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19727
diff changeset
911
19724
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
912 ext_data->node = nodever;
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
913 ext_data->userdata = userdata;
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
914
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19721
diff changeset
915 jabber_iq_set_callback(iq, jabber_caps_ext_iqcb, ext_data);
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
916 jabber_iq_send(iq);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
917 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
918 /* maybe we have all data available anyways? This is the ideal case where no network traffic is necessary */
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
919 jabber_caps_get_info_check_completion(userdata);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
920 }
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
921 #endif
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
922 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
923
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
924 static gint
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
925 jabber_identity_compare(gconstpointer a, gconstpointer b)
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
926 {
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
927 const JabberIdentity *ac;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
928 const JabberIdentity *bc;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
929 gint cat_cmp;
25577
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
930 gint typ_cmp;
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
931
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
932 ac = a;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
933 bc = b;
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
934
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
935 if ((cat_cmp = strcmp(ac->category, bc->category)) == 0) {
25577
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
936 if ((typ_cmp = strcmp(ac->type, bc->type)) == 0) {
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
937 if (!ac->lang && !bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
938 return 0;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
939 } else if (ac->lang && !bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
940 return 1;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
941 } else if (!ac->lang && bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
942 return -1;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
943 } else {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
944 return strcmp(ac->lang, bc->lang);
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
945 }
25577
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
946 } else {
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
947 return typ_cmp;
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25576
diff changeset
948 }
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
949 } else {
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
950 return cat_cmp;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
951 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
952 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
953
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
954 #if 0
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
955 static gint jabber_caps_jabber_feature_compare(gconstpointer a, gconstpointer b) {
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
956 const JabberFeature *ac;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
957 const JabberFeature *bc;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
958
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
959 ac = a;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
960 bc = b;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
961
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
962 return strcmp(ac->namespace, bc->namespace);
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
963 }
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
964 #endif
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
965
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
966 static gchar *jabber_caps_get_formtype(const xmlnode *x) {
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
967 xmlnode *formtypefield;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
968 formtypefield = xmlnode_get_child(x, "field");
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
969 while (formtypefield && strcmp(xmlnode_get_attrib(formtypefield, "var"), "FORM_TYPE")) formtypefield = xmlnode_get_next_twin(formtypefield);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
970 formtypefield = xmlnode_get_child(formtypefield, "value");
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
971 return xmlnode_get_data(formtypefield);;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
972 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
973
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
974 static gint
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
975 jabber_xdata_compare(gconstpointer a, gconstpointer b)
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
976 {
25588
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25586
diff changeset
977 const xmlnode *aformtypefield = a;
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25586
diff changeset
978 const xmlnode *bformtypefield = b;
25578
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
979 char *aformtype;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
980 char *bformtype;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
981 int result;
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
982
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
983 aformtype = jabber_caps_get_formtype(aformtypefield);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
984 bformtype = jabber_caps_get_formtype(bformtypefield);
25578
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
985
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
986 result = strcmp(aformtype, bformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
987 g_free(aformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
988 g_free(bformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
989 return result;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
990 }
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
991
25758
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
992 static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query)
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25757
diff changeset
993 {
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
994 xmlnode *child;
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
995 JabberCapsClientInfo *info;
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
996
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
997 if (!query || strcmp(query->xmlns, "http://jabber.org/protocol/disco#info"))
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
998 return 0;
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
999
25741
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25740
diff changeset
1000 info = g_new0(JabberCapsClientInfo, 1);
25782
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
1001 jabber_caps_client_info_ref(info);
6bdcdb77ce77 Reference-count JabberCapsClientInfo and fix bug.
Paul Aurich <paul@darkrain42.org>
parents: 25781
diff changeset
1002
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1003 for(child = query->child; child; child = child->next) {
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1004 if (!strcmp(child->name,"identity")) {
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1005 /* parse identity */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1006 const char *category = xmlnode_get_attrib(child, "category");
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1007 const char *type = xmlnode_get_attrib(child, "type");
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1008 const char *name = xmlnode_get_attrib(child, "name");
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
1009 const char *lang = xmlnode_get_attrib(child, "lang");
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
1010 JabberIdentity *id;
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
1011
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
1012 if (!category || !type)
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
1013 continue;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
1014
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
1015 id = g_new0(JabberIdentity, 1);
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1016 id->category = g_strdup(category);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1017 id->type = g_strdup(type);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1018 id->name = g_strdup(name);
25751
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
1019 id->lang = g_strdup(lang);
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25750
diff changeset
1020
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1021 info->identities = g_list_append(info->identities, id);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1022 } else if (!strcmp(child->name, "feature")) {
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1023 /* parse feature */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1024 const char *var = xmlnode_get_attrib(child, "var");
25784
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
1025 if (var)
05693f6885a4 Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <paul@darkrain42.org>
parents: 25783
diff changeset
1026 info->features = g_list_prepend(info->features, g_strdup(var));
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1027 } else if (!strcmp(child->name, "x")) {
25752
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25751
diff changeset
1028 if (child->xmlns && !strcmp(child->xmlns, "jabber:x:data")) {
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1029 /* x-data form */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1030 xmlnode *dataform = xmlnode_copy(child);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1031 info->forms = g_list_append(info->forms, dataform);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1032 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1033 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1034 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1035 return info;
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1036 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1037
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1038 static gint jabber_caps_xdata_field_compare(gconstpointer a, gconstpointer b)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1039 {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1040 const JabberDataFormField *ac = a;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1041 const JabberDataFormField *bc = b;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1042
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1043 return strcmp(ac->var, bc->var);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1044 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1045
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1046 static GList* jabber_caps_xdata_get_fields(const xmlnode *x)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1047 {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1048 GList *fields = NULL;
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1049 xmlnode *field;
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1050
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1051 if (!x)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1052 return NULL;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1053
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1054 for (field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1055 xmlnode *value;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1056 JabberDataFormField *xdatafield = g_new0(JabberDataFormField, 1);
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1057 xdatafield->var = g_strdup(xmlnode_get_attrib(field, "var"));
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1058
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1059 for (value = xmlnode_get_child(field, "value"); value; value = xmlnode_get_next_twin(value)) {
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1060 gchar *val = xmlnode_get_data(value);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1061 xdatafield->values = g_list_append(xdatafield->values, val);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1062 }
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1063
25748
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25746
diff changeset
1064 xdatafield->values = g_list_sort(xdatafield->values, (GCompareFunc)strcmp);
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1065 fields = g_list_append(fields, xdatafield);
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1066 }
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1067
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1068 fields = g_list_sort(fields, jabber_caps_xdata_field_compare);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1069 return fields;
17609
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
1070 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
1071
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1072 static GString*
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1073 jabber_caps_verification_append(GString *verification, const gchar *string)
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1074 {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1075 verification = g_string_append(verification, string);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1076 return g_string_append_c(verification, '<');
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1077 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1078
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1079 gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash)
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1080 {
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1081 GList *node;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1082 GString *verification;
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1083 PurpleCipherContext *context;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1084 guint8 checksum[20];
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1085 gsize checksum_size = 20;
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
1086 gboolean success;
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1087
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1088 if (!info || !(context = purple_cipher_context_new_by_name(hash, NULL)))
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1089 return NULL;
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1090
25578
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25577
diff changeset
1091 /* sort identities, features and x-data forms */
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
1092 info->identities = g_list_sort(info->identities, jabber_identity_compare);
25748
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25746
diff changeset
1093 info->features = g_list_sort(info->features, (GCompareFunc)strcmp);
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
1094 info->forms = g_list_sort(info->forms, jabber_xdata_compare);
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1095
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1096 verification = g_string_new("");
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1097
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1098 /* concat identities to the verification string */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1099 for (node = info->identities; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1100 JabberIdentity *id = (JabberIdentity*)node->data;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1101
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1102 g_string_append_printf(verification, "%s/%s/%s/%s<", id->category,
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1103 id->type, id->lang ? id->lang : "", id->name);
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1104 }
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1105
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1106 /* concat features to the verification string */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1107 for (node = info->features; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1108 verification = jabber_caps_verification_append(verification, node->data);
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1109 }
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1110
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1111 /* concat x-data forms to the verification string */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1112 for(node = info->forms; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1113 xmlnode *data = (xmlnode *)node->data;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1114 gchar *formtype = jabber_caps_get_formtype(data);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1115 GList *fields = jabber_caps_xdata_get_fields(data);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1116
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1117 /* append FORM_TYPE's field value to the verification string */
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1118 verification = jabber_caps_verification_append(verification, formtype);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1119 g_free(formtype);
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1120
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1121 while (fields) {
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1122 GList *value;
25580
4c97156431b4 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25579
diff changeset
1123 JabberDataFormField *field = (JabberDataFormField*)fields->data;
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1124
25756
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25755
diff changeset
1125 if (strcmp(field->var, "FORM_TYPE")) {
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1126 /* Append the "var" attribute */
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1127 verification = jabber_caps_verification_append(verification, field->var);
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
1128 /* Append <value/> elements' cdata */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1129 for(value = field->values; value; value = value->next) {
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1130 verification = jabber_caps_verification_append(verification, value->data);
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1131 g_free(value->data);
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1132 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1133 }
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1134
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1135 g_free(field->var);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1136 g_list_free(field->values);
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1137
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1138 fields = g_list_delete_link(fields, fields);
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1139 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1140 }
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1141
25582
fd19927e2b64 * support for calculating both hashes, sha-1 and md5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25580
diff changeset
1142 /* generate hash */
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1143 purple_cipher_context_append(context, (guchar*)verification->str, verification->len);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1144
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
1145 success = purple_cipher_context_digest(context, verification->len,
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
1146 checksum, &checksum_size);
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1147
25755
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25754
diff changeset
1148 g_string_free(verification, TRUE);
25579
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25578
diff changeset
1149 purple_cipher_context_destroy(context);
25749
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25748
diff changeset
1150
25781
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25780
diff changeset
1151 return (success ? purple_base64_encode(checksum, checksum_size) : NULL);
25576
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1152 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25575
diff changeset
1153
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1154 void jabber_caps_calculate_own_hash(JabberStream *js) {
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1155 JabberCapsClientInfo info;
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1156 GList *iter = 0;
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1157 GList *features = 0;
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
1158
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1159 if (!jabber_identities && !jabber_features) {
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1160 /* This really shouldn't ever happen */
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1161 purple_debug_warning("jabber", "No features or identities, cannot calculate own caps hash.\n");
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1162 g_free(js->caps_hash);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1163 js->caps_hash = NULL;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1164 return;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1165 }
25588
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25586
diff changeset
1166
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1167 /* build the currently-supported list of features */
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1168 if (jabber_features) {
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1169 for (iter = jabber_features; iter; iter = iter->next) {
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1170 JabberFeature *feat = iter->data;
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1171 if(!feat->is_enabled || feat->is_enabled(js, feat->namespace)) {
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1172 features = g_list_append(features, feat->namespace);
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1173 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1174 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1175 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1176
25760
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1177 info.features = features;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1178 info.identities = jabber_identities;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1179 info.forms = NULL;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1180
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1181 g_free(js->caps_hash);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25758
diff changeset
1182 js->caps_hash = jabber_caps_calculate_hash(&info, "sha1");
25584
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25583
diff changeset
1183 g_list_free(features);
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
1184 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
1185
25742
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
1186 const gchar* jabber_caps_get_own_hash(JabberStream *js)
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
1187 {
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
1188 if (!js->caps_hash)
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
1189 jabber_caps_calculate_own_hash(js);
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
1190
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25741
diff changeset
1191 return js->caps_hash;
25575
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
1192 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
1193
25743
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1194 void jabber_caps_broadcast_change()
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1195 {
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1196 GList *node, *accounts = purple_accounts_get_all_active();
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1197
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1198 for (node = accounts; node; node = node->next) {
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1199 PurpleAccount *account = node->data;
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1200 const char *prpl_id = purple_account_get_protocol_id(account);
25744
6adbaf3d25e3 Fix a null dereference on non-connected accounts
Paul Aurich <paul@darkrain42.org>
parents: 25743
diff changeset
1201 if (!strcmp("prpl-jabber", prpl_id) && purple_account_is_connected(account)) {
25743
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1202 PurpleConnection *gc = purple_account_get_connection(account);
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1203 jabber_presence_send(gc->proto_data, TRUE);
25590
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25589
diff changeset
1204 }
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25589
diff changeset
1205 }
25743
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1206
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25742
diff changeset
1207 g_list_free(accounts);
25590
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25589
diff changeset
1208 }
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25589
diff changeset
1209