annotate libpurple/protocols/jabber/caps.c @ 25186:ef90728dbae8

Rename a few functions and clean up the exit cleanup of a function
author Paul Aurich <paul@darkrain42.org>
date Sun, 14 Dec 2008 21:19:02 +0000
parents 5d2e4a3b0c63
children 6bdcdb77ce77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
1 /*
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
3 *
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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
19698
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17902
diff changeset
22 #include "internal.h"
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17902
diff changeset
23
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
24 #include "debug.h"
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
25 #include "caps.h"
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
26 #include "cipher.h"
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
27 #include "iq.h"
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
28 #include "presence.h"
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
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
25162
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
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: 25161
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: 25161
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: 25161
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: 25161
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: 25161
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: 25161
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: 25161
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: 25161
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: 25161
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: 25161
diff changeset
43
25166
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
44 static GHashTable *capstable = NULL; /* JabberCapsKey -> JabberCapsClientInfo */
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
45
25162
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
46 /**
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
47 * 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: 25161
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: 25161
diff changeset
49 * @param query A query object.
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
50 * @return A JabberCapsClientInfo object.
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
51 */
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
52 static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query);
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
53
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
54 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
55 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
56 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
57 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
58 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
59 } JabberCapsValue;
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
60 #endif
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
61
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
62 static guint jabber_caps_hash(gconstpointer 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
63 const JabberCapsKey *name = 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
64 guint nodehash = g_str_hash(name->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
65 guint verhash = g_str_hash(name->ver);
25027
45816181b7de * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25026
diff changeset
66 guint hashhash = g_str_hash(name->hash);
45816181b7de * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25026
diff changeset
67 return nodehash ^ verhash ^ hashhash;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
68 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
69
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
70 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
71 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
72 const JabberCapsKey *name2 = v2;
25024
fd19927e2b64 * support for calculating both hashes, sha-1 and md5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25022
diff changeset
73
25152
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25150
diff changeset
74 return strcmp(name1->node, name2->node) == 0 &&
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25150
diff changeset
75 strcmp(name1->ver, name2->ver) == 0 &&
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25150
diff changeset
76 strcmp(name1->hash, name2->hash) == 0;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
77 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
78
25027
45816181b7de * fixing a bug in jabber_caps_compare()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25026
diff changeset
79 void jabber_caps_destroy_key(gpointer key) {
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
80 JabberCapsKey *keystruct = 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
81 g_free(keystruct->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
82 g_free(keystruct->ver);
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
83 g_free(keystruct->hash);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
84 g_free(keystruct);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
85 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
86
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
87 static void
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
88 jabber_caps_client_info_destroy(gpointer data) {
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
89 JabberCapsClientInfo *info = data;
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
90 while(info->identities) {
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
91 JabberIdentity *id = info->identities->data;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
92 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
93 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
94 g_free(id->name);
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
95 g_free(id->lang);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
96 g_free(id);
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
97 info->identities = g_list_delete_link(info->identities, info->identities);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
98 }
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
99
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
100 while(info->features) {
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
101 g_free(info->features->data);
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
102 info->features = g_list_delete_link(info->features, info->features);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
103 }
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
104
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
105 while(info->forms) {
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
106 g_free(info->forms->data);
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
107 info->forms = g_list_delete_link(info->forms, info->forms);
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
108 }
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
109
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
110 #if 0
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
111 g_hash_table_destroy(valuestruct->ext);
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
112 #endif
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
113
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
114 g_free(info);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
115 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
116
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
117 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125 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
126
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
127 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
128 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
129 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
130 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
131 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
132 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
133 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
134 }
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
135 #endif
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
136
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
137 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
138
25166
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
139 void jabber_caps_init(void)
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
140 {
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
141 capstable = g_hash_table_new_full(jabber_caps_hash, jabber_caps_compare, jabber_caps_destroy_key, jabber_caps_client_info_destroy);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
142 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
143 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
144
25166
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
145 void jabber_caps_uninit(void)
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
146 {
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
147 g_hash_table_destroy(capstable);
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
148 capstable = NULL;
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
149 }
18fdbe507fdd Make capstable caps.c-only and add a jabber_caps_uninit() function
Paul Aurich <paul@darkrain42.org>
parents: 25165
diff changeset
150
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
151 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
152 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
153 xmlnode *client;
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
154
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
155 if(!capsdata)
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
156 return;
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
157
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
158 if (strcmp(capsdata->name, "capabilities") != 0) {
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
159 xmlnode_free(capsdata);
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
160 return;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
161 }
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
162
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
163 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
164 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
165 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
166 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
167 JabberCapsKey *key = g_new0(JabberCapsKey, 1);
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
168 JabberCapsClientInfo *value = g_new0(JabberCapsClientInfo, 1);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
169 xmlnode *child;
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
170 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
171 key->ver = g_strdup(xmlnode_get_attrib(client,"ver"));
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
172 key->hash = g_strdup(xmlnode_get_attrib(client,"hash"));
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
173 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 } 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
182 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
183 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
184 const char *name = xmlnode_get_attrib(child, "name");
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
185 const char *lang = xmlnode_get_attrib(child, "lang");
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
186 JabberIdentity *id;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
187
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
188 if (!category || !type)
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
189 continue;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
190
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
191 id = g_new0(JabberIdentity, 1);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
192 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
193 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
194 id->name = g_strdup(name);
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
195 id->lang = g_strdup(lang);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
196
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 value->identities = g_list_append(value->identities,id);
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
198 } else if(!strcmp(child->name,"x")) {
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
199 value->forms = g_list_append(value->forms, xmlnode_copy(child));
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
200 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
202 g_hash_table_replace(capstable, key, 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
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 }
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
205 xmlnode_free(capsdata);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
206 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
207
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
208 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
209 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
210 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
211 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
212 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
213 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
214 GList *iter;
19727
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19722
diff changeset
215
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
216 xmlnode_set_attrib(ext,"identifier",extname);
19727
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19722
diff changeset
217
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
218 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
219 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
220 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
221 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
222 xmlnode_set_attrib(identity, "type", id->type);
19727
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19722
diff changeset
223 if (id->name)
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19722
diff changeset
224 xmlnode_set_attrib(identity, "name", id->name);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
225 }
19727
64e0c7fa92c9 Prevent an assertion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19722
diff changeset
226
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
227 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
228 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
229 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
230 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
231 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
232 }
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
233 #endif
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
234
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
235 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
236 JabberCapsKey *clientinfo = key;
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
237 JabberCapsClientInfo *props = value;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
238 xmlnode *root = user_data;
25035
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25034
diff changeset
239 xmlnode *client = xmlnode_new_child(root, "client");
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
240 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
241
25035
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25034
diff changeset
242 xmlnode_set_attrib(client, "node", clientinfo->node);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25034
diff changeset
243 xmlnode_set_attrib(client, "ver", clientinfo->ver);
affaa4c4836e * some code style adjustments in caps.c
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25034
diff changeset
244 xmlnode_set_attrib(client, "hash", clientinfo->hash);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
245 for(iter = props->identities; iter; iter = g_list_next(iter)) {
25154
30a686c079d5 Remove JabberCapsIdentity and just use JabberIdentity everywhere
Paul Aurich <paul@darkrain42.org>
parents: 25153
diff changeset
246 JabberIdentity *id = iter->data;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
247 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
248 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
249 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: 19729
diff changeset
250 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: 19729
diff changeset
251 xmlnode_set_attrib(identity, "name", id->name);
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
252 if (id->lang)
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
253 xmlnode_set_attrib(identity, "lang", id->lang);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
254 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 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
257 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
258 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
259 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
260 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
262 for(iter = props->forms; iter; iter = g_list_next(iter)) {
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
263 xmlnode *xdata = iter->data;
25033
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: 25032
diff changeset
264 xmlnode_insert_child(client, xmlnode_copy(xdata));
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
265 }
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
266 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
267
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
268 static void jabber_caps_store(void) {
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
269 char *str;
25031
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25030
diff changeset
270 int length = 0;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
271 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
272 g_hash_table_foreach(capstable, jabber_caps_store_client, root);
25031
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25030
diff changeset
273 str = xmlnode_to_formatted_str(root, &length);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
274 xmlnode_free(root);
25031
3f719eaa7fd1 * IPC work
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25030
diff changeset
275 purple_util_write_data_to_file(JABBER_CAPS_FILENAME, str, length);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
276 g_free(str);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
277 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
279 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
280 /* 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
281 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
282 JabberCapsClientInfo *result;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
283 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
284 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
285 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
286
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
287 key->node = (char *)node;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
288 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
289
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
290 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
291
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
292 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
293
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
294 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
295 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
296
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
297 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
298
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
299 /* 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
300 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
301 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
302 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
303 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
304 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
305 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
306
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
307 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
308 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
309 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
310 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
311 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
312
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
313 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
314 }
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
315 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
316 for(iter = ext; iter; iter = g_list_next(iter)) {
17886
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17882
diff changeset
317 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: 17882
diff changeset
318 JabberCapsValueExt *extinfo = g_hash_table_lookup(caps->ext,extname);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
319
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 if(extinfo) {
17886
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17882
diff changeset
321 GList *iter2;
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17882
diff changeset
322 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: 17882
diff changeset
323 JabberCapsIdentity *id = iter2->data;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
324 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
325 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
326 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
327 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
328
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 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
330 }
17886
7c79957207c3 Fixed a few bugs in the caps implementation, it should work properly now.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17882
diff changeset
331 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: 17882
diff changeset
332 const char *feat = iter2->data;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
333 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
334
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
335 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
336 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
337 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
338 }
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
339 #endif
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
340 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
341 }
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
342 #endif
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
343
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 typedef struct _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
345 jabber_caps_get_info_cb cb;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
346 gpointer cb_data;
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
347
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
348 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
349 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
350 char *ver;
25022
4c97156431b4 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25021
diff changeset
351 char *hash;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
352 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
353 unsigned extOutstanding;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
354 #endif
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
355 } 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
356
25150
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
357 #if 0
19725
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
358 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: 19722
diff changeset
359 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: 19722
diff changeset
360 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: 19722
diff changeset
361 } jabber_ext_userdata;
25150
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
362 #endif
19725
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
363
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
364 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
365 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
366 if(userdata->extOutstanding == 0) {
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
367 userdata->cb(jabber_caps_collect_info(userdata->node, userdata->ver, userdata->ext), userdata->cb_data);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
368 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
369 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
370 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
371 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
372 g_free(userdata->ext->data);
17902
ce04ca030a1b Fixed some memory leaks.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17886
diff changeset
373 userdata->ext = g_list_delete_link(userdata->ext,userdata->ext);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
374 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
375 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
376 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
377 }
25025
a85f9b85a7fb * changed storage format for cache to mirror all needed features for XEP-0115v1.5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25024
diff changeset
378 #endif
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
379 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
380 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
381 /* 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
382 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#info");
19725
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
383 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: 19722
diff changeset
384 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: 19722
diff changeset
385 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
386
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
387 --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
388
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
389 /* TODO: Better error handling */
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
390 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
391 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
392 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
393 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
394 xmlnode *child;
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
395 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
396 JabberCapsKey *clientkey = g_new0(JabberCapsKey, 1);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
397
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
398 clientkey->node = userdata->node;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
399 clientkey->ver = userdata->ver;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
400
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
401 client = g_hash_table_lookup(capstable, clientkey);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
402
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
403 g_free(clientkey);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
404
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
405 /* 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
406 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
407 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
408 ++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
409 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
410 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
411 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 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
414 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
415 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
416 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
417 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
418 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
419 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
420 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
421 } 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
422 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
423 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
424 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
425
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
426 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
427 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
428 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
429 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
430
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
431 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
432 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
433 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 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
435 }
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
436
19725
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
437 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: 19722
diff changeset
438 g_free(extuserdata);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
439 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
440 }
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
441 #endif
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
442
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
443 static void
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
444 jabber_caps_client_iqcb(JabberStream *js, xmlnode *packet, gpointer data)
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
445 {
21595
5f85d0781bee Fix a discovery related crash. I think this still needs better error handling. Fixes #3995.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21325
diff changeset
446 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
447 "http://jabber.org/protocol/disco#info");
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
448 jabber_caps_cbplususerdata *userdata = data;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
449 JabberCapsClientInfo *info = NULL, *value;
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
450 gchar *hash = NULL;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
451 const char *type = xmlnode_get_attrib(packet, "type");
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
452 JabberCapsKey key;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
453
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
454 if (!query || !strcmp(type, "error")) {
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
455 userdata->cb(NULL, userdata->cb_data);
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
456 goto out;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
457 }
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
458
25157
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
459 /* check hash */
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
460 info = jabber_caps_parse_client_info(query);
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
461
25157
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
462 if (!strcmp(userdata->hash, "sha-1")) {
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
463 hash = jabber_caps_calculate_hash(info, "sha1");
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
464 } else if (!strcmp(userdata->hash, "md5")) {
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
465 hash = jabber_caps_calculate_hash(info, "md5");
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
466 }
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
467
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
468 if (!hash || strcmp(hash, userdata->ver)) {
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
469 purple_debug_warning("jabber", "Could not validate caps info from %s\n",
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
470 xmlnode_get_attrib(packet, "from"));
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
471
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
472 userdata->cb(NULL, userdata->cb_data);
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
473 jabber_caps_client_info_destroy(info);
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
474 goto out;
25157
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
475 }
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
476
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
477 key.node = userdata->node;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
478 key.ver = userdata->ver;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
479 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
480
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
481 /* Use the copy of this data already in the table if it exists or insert
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
482 * a new one if we need to */
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
483 if ((value = g_hash_table_lookup(capstable, &key))) {
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
484 jabber_caps_client_info_destroy(info);
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
485 info = value;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
486 } else {
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
487 JabberCapsKey *n_key = g_new(JabberCapsKey, 1);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
488 n_key->node = userdata->node;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
489 n_key->ver = userdata->ver;
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
490 n_key->hash = userdata->hash;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
491 userdata->node = userdata->ver = userdata->hash = NULL;
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
492
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
493 g_hash_table_insert(capstable, n_key, info);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
494 jabber_caps_store();
25157
b6cfc5cc6799 Whitespace cleanup (no functional changes, just unwrap the huge if block and
Paul Aurich <paul@darkrain42.org>
parents: 25156
diff changeset
495 }
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
496
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
497 userdata->cb(info, userdata->cb_data);
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
498 /* capstable owns info */
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
499
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
500 out:
25158
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
501 g_free(userdata->who);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
502 g_free(userdata->node);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
503 g_free(userdata->ver);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
504 g_free(userdata->hash);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
505 g_free(userdata);
ec0c95ae4a65 Clean up jabber_caps_client_iqcb
Paul Aurich <paul@darkrain42.org>
parents: 25157
diff changeset
506 g_free(hash);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
507 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
508
25150
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
509 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
510 const char *ver, const char *hash, jabber_caps_get_info_cb cb,
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
511 gpointer user_data)
1eeeb33ed021 Clean up a few things
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
512 {
25161
0ccb80ae7262 Rename some structs and the JabberCapsClientInfo destruction function
Paul Aurich <paul@darkrain42.org>
parents: 25160
diff changeset
513 JabberCapsClientInfo *client;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
514 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
515 jabber_caps_cbplususerdata *userdata = g_new0(jabber_caps_cbplususerdata, 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
516 userdata->cb = cb;
25185
5d2e4a3b0c63 Rename user_data to cb_data (there were too many 'userdata'/'user_data's).
Paul Aurich <paul@darkrain42.org>
parents: 25169
diff changeset
517 userdata->cb_data = user_data;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
518 userdata->who = g_strdup(who);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
519 userdata->node = g_strdup(node);
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
520 userdata->ver = g_strdup(ver);
25022
4c97156431b4 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25021
diff changeset
521 userdata->hash = g_strdup(hash);
19698
d32ed28cf645 Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17902
diff changeset
522
25033
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: 25032
diff changeset
523 key->node = g_strdup(node);
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: 25032
diff changeset
524 key->ver = g_strdup(ver);
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: 25032
diff changeset
525 key->hash = g_strdup(hash);
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
526
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
527 client = g_hash_table_lookup(capstable, key);
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
528
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
529 if(!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
530 JabberIq *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
531 xmlnode *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
532 char *nodever = g_strdup_printf("%s#%s", node, 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
533 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
534 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
535 xmlnode_set_attrib(iq->node, "to", who);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
536
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
537 jabber_iq_set_callback(iq,jabber_caps_client_iqcb,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
538 jabber_iq_send(iq);
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
539 }
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
540 #if 0
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
541 } else {
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
542 GList *iter;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
543 /* 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
544 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
545 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
546 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
547 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
548 char *nodever;
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
549 jabber_ext_userdata *ext_data;
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
550
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
551 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
552 /* 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
553 --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
554 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
555 }
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
556
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
557 ext_data = g_new0(jabber_ext_userdata, 1);
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
558
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
559 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
560 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
561 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
562 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
563 xmlnode_set_attrib(iq->node, "to", who);
19729
d397000d32fc Various leakfixes and preventing unnecessary allocations.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19728
diff changeset
564
19725
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
565 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: 19722
diff changeset
566 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: 19722
diff changeset
567
30e4912e4a27 Some clients don't put the node in the 115 disco response, so send the node to the callback
Sean Egan <seanegan@gmail.com>
parents: 19722
diff changeset
568 jabber_iq_set_callback(iq, jabber_caps_ext_iqcb, ext_data);
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
569 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
570 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to 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 /* 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
572 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
573 }
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
574 #endif
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
575 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
576
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
577 static gint
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
578 jabber_identity_compare(gconstpointer a, gconstpointer b)
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
579 {
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
580 const JabberIdentity *ac;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
581 const JabberIdentity *bc;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
582 gint cat_cmp;
25019
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
583 gint typ_cmp;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
584
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
585 ac = a;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
586 bc = b;
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
587
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
588 if ((cat_cmp = strcmp(ac->category, bc->category)) == 0) {
25019
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
589 if ((typ_cmp = strcmp(ac->type, bc->type)) == 0) {
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
590 if (!ac->lang && !bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
591 return 0;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
592 } else if (ac->lang && !bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
593 return 1;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
594 } else if (!ac->lang && bc->lang) {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
595 return -1;
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
596 } else {
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
597 return strcmp(ac->lang, bc->lang);
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
598 }
25019
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
599 } else {
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
600 return typ_cmp;
f6272b156873 * jabber_caps_jabber_identity_compare() compares xml:lang too, now.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25018
diff changeset
601 }
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
602 } else {
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
603 return cat_cmp;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
604 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
605 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
606
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
607 #if 0
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
608 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
609 const JabberFeature *ac;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
610 const JabberFeature *bc;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
611
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
612 ac = a;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
613 bc = b;
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
614
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
615 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
616 }
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
617 #endif
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
618
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
619 static gchar *jabber_caps_get_formtype(const xmlnode *x) {
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
620 xmlnode *formtypefield;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
621 formtypefield = xmlnode_get_child(x, "field");
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
622 while (formtypefield && strcmp(xmlnode_get_attrib(formtypefield, "var"), "FORM_TYPE")) formtypefield = xmlnode_get_next_twin(formtypefield);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
623 formtypefield = xmlnode_get_child(formtypefield, "value");
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
624 return xmlnode_get_data(formtypefield);;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
625 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
626
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
627 static gint
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
628 jabber_xdata_compare(gconstpointer a, gconstpointer b)
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
629 {
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
630 const xmlnode *aformtypefield = a;
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
631 const xmlnode *bformtypefield = b;
25020
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
632 char *aformtype;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
633 char *bformtype;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
634 int result;
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
635
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
636 aformtype = jabber_caps_get_formtype(aformtypefield);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
637 bformtype = jabber_caps_get_formtype(bformtypefield);
25020
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
638
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
639 result = strcmp(aformtype, bformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
640 g_free(aformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
641 g_free(bformtype);
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
642 return result;
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
643 }
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
644
25162
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
645 static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query)
7dcba13d0e28 Move structures and function definitions in to caps.c and stop any other code from killing JabberCapsClientInfo structures (owned by the hash table)
Paul Aurich <paul@darkrain42.org>
parents: 25161
diff changeset
646 {
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
647 xmlnode *child;
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
648 JabberCapsClientInfo *info;
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
649
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
650 if (!query || strcmp(query->xmlns, "http://jabber.org/protocol/disco#info"))
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
651 return 0;
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
652
25145
1225f3dcf5ab Fix compilation errors and many warnings
Paul Aurich <paul@darkrain42.org>
parents: 25144
diff changeset
653 info = g_new0(JabberCapsClientInfo, 1);
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
654
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
655 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: 25017
diff changeset
656 if (!strcmp(child->name,"identity")) {
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
657 /* parse identity */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
658 const char *category = xmlnode_get_attrib(child, "category");
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
659 const char *type = xmlnode_get_attrib(child, "type");
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
660 const char *name = xmlnode_get_attrib(child, "name");
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
661 const char *lang = xmlnode_get_attrib(child, "lang");
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
662 JabberIdentity *id;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
663
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
664 if (!category || !type)
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
665 continue;
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
666
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
667 id = g_new0(JabberIdentity, 1);
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
668 id->category = g_strdup(category);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
669 id->type = g_strdup(type);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
670 id->name = g_strdup(name);
25155
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
671 id->lang = g_strdup(lang);
27a9672371f1 Don't crash if the lang attribute of an identity is NULL
Paul Aurich <paul@darkrain42.org>
parents: 25154
diff changeset
672
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
673 info->identities = g_list_append(info->identities, id);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
674 } else if (!strcmp(child->name, "feature")) {
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
675 /* parse feature */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
676 const char *var = xmlnode_get_attrib(child, "var");
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
677 if(!var)
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
678 continue;
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
679 info->features = g_list_append(info->features, g_strdup(var));
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
680 } else if (!strcmp(child->name, "x")) {
25156
c2438ad6e6c1 Error checking and use g_list_foreach
Paul Aurich <paul@darkrain42.org>
parents: 25155
diff changeset
681 if (child->xmlns && !strcmp(child->xmlns, "jabber:x:data")) {
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
682 /* x-data form */
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
683 xmlnode *dataform = xmlnode_copy(child);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
684 info->forms = g_list_append(info->forms, dataform);
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
685 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
686 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
687 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
688 return info;
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
689 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
690
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
691 static gint jabber_caps_xdata_field_compare(gconstpointer a, gconstpointer b)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
692 {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
693 const JabberDataFormField *ac = a;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
694 const JabberDataFormField *bc = b;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
695
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
696 return strcmp(ac->var, bc->var);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
697 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
698
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
699 static GList* jabber_caps_xdata_get_fields(const xmlnode *x)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
700 {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
701 GList *fields = NULL;
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
702 xmlnode *field;
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
703
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
704 if (!x)
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
705 return NULL;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
706
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
707 for (field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) {
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
708 xmlnode *value;
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
709 JabberDataFormField *xdatafield = g_new0(JabberDataFormField, 1);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
710 xdatafield->var = g_strdup(xmlnode_get_attrib(field, "var"));
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
711
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
712 for (value = xmlnode_get_child(field, "value"); value; value = xmlnode_get_next_twin(value)) {
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
713 gchar *val = xmlnode_get_data(value);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
714 xdatafield->values = g_list_append(xdatafield->values, val);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
715 }
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
716
25152
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25150
diff changeset
717 xdatafield->values = g_list_sort(xdatafield->values, (GCompareFunc)strcmp);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
718 fields = g_list_append(fields, xdatafield);
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
719 }
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
720
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
721 fields = g_list_sort(fields, jabber_caps_xdata_field_compare);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
722 return fields;
17882
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
723 }
f88b3a093cba Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
724
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
725 static GString*
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
726 jabber_caps_verification_append(GString *verification, const gchar *string)
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
727 {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
728 verification = g_string_append(verification, string);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
729 return g_string_append_c(verification, '<');
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
730 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
731
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
732 gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash)
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
733 {
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
734 GList *node;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
735 GString *verification;
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
736 PurpleCipherContext *context;
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
737 guint8 checksum[20];
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
738 gsize checksum_size = 20;
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
739 gboolean success;
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
740
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
741 if (!info || !(context = purple_cipher_context_new_by_name(hash, NULL)))
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
742 return NULL;
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
743
25020
9867a406707e * defined JabberCapsIdentity as struct _JabberIdentity
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25019
diff changeset
744 /* sort identities, features and x-data forms */
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
745 info->identities = g_list_sort(info->identities, jabber_identity_compare);
25152
8789b9202c06 Use strcmp instead of a wrapper
Paul Aurich <paul@darkrain42.org>
parents: 25150
diff changeset
746 info->features = g_list_sort(info->features, (GCompareFunc)strcmp);
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
747 info->forms = g_list_sort(info->forms, jabber_xdata_compare);
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
748
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
749 verification = g_string_new("");
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
750
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
751 /* concat identities to the verification string */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
752 for (node = info->identities; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
753 JabberIdentity *id = (JabberIdentity*)node->data;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
754
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
755 g_string_append_printf(verification, "%s/%s/%s/%s<", id->category,
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
756 id->type, id->lang ? id->lang : "", id->name);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
757 }
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
758
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
759 /* concat features to the verification string */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
760 for (node = info->features; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
761 verification = jabber_caps_verification_append(verification, node->data);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
762 }
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
763
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
764 /* concat x-data forms to the verification string */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
765 for(node = info->forms; node; node = node->next) {
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
766 xmlnode *data = (xmlnode *)node->data;
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
767 gchar *formtype = jabber_caps_get_formtype(data);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
768 GList *fields = jabber_caps_xdata_get_fields(data);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
769
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
770 /* append FORM_TYPE's field value to the verification string */
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
771 verification = jabber_caps_verification_append(verification, formtype);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
772 g_free(formtype);
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
773
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
774 while (fields) {
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
775 GList *value;
25022
4c97156431b4 * pass hash type to the caps handling functions
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25021
diff changeset
776 JabberDataFormField *field = (JabberDataFormField*)fields->data;
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
777
25160
c8b4029d37c5 Whitespace and formatting changes
Paul Aurich <paul@darkrain42.org>
parents: 25159
diff changeset
778 if (strcmp(field->var, "FORM_TYPE")) {
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
779 /* Append the "var" attribute */
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
780 verification = jabber_caps_verification_append(verification, field->var);
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
781 /* Append <value/> elements' cdata */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
782 for(value = field->values; value; value = value->next) {
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
783 verification = jabber_caps_verification_append(verification, value->data);
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
784 g_free(value->data);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
785 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
786 }
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
787
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
788 g_free(field->var);
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
789 g_list_free(field->values);
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
790
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
791 fields = g_list_delete_link(fields, fields);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
792 }
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
793 }
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
794
25024
fd19927e2b64 * support for calculating both hashes, sha-1 and md5
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25022
diff changeset
795 /* generate hash */
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
796 purple_cipher_context_append(context, (guchar*)verification->str, verification->len);
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
797
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
798 success = purple_cipher_context_digest(context, verification->len,
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
799 checksum, &checksum_size);
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
800
25159
7155fa3ec052 Rework jabber_caps_calculate_hash
Paul Aurich <paul@darkrain42.org>
parents: 25158
diff changeset
801 g_string_free(verification, TRUE);
25021
a5e437b7f915 * implemented jabber_caps_calcualte_hash() which calculates the SHA-1 hash for someones disco response according to XEP-0115
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25020
diff changeset
802 purple_cipher_context_destroy(context);
25153
b5dbf1d9930b Whitespace, formatting, and // -> /* */
Paul Aurich <paul@darkrain42.org>
parents: 25152
diff changeset
803
25186
ef90728dbae8 Rename a few functions and clean up the exit cleanup of a function
Paul Aurich <paul@darkrain42.org>
parents: 25185
diff changeset
804 return (success ? purple_base64_encode(checksum, checksum_size) : NULL);
25018
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
805 }
2a6a37c7970b * changed name of jabber_caps_calculate_hash() to jabber_caps_calculate_own_hash()
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25017
diff changeset
806
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
807 void jabber_caps_calculate_own_hash(JabberStream *js) {
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
808 JabberCapsClientInfo info;
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
809 GList *iter = 0;
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
810 GList *features = 0;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
811
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
812 if (!jabber_identities && !jabber_features) {
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
813 /* This really shouldn't ever happen */
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
814 purple_debug_warning("jabber", "No features or identities, cannot calculate own caps hash.\n");
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
815 g_free(js->caps_hash);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
816 js->caps_hash = NULL;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
817 return;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
818 }
25030
61f37abc8a70 * removing several warnings
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25028
diff changeset
819
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
820 /* build the currently-supported list of features */
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
821 if (jabber_features) {
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
822 for (iter = jabber_features; iter; iter = iter->next) {
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
823 JabberFeature *feat = iter->data;
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
824 if(!feat->is_enabled || feat->is_enabled(js, feat->namespace)) {
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
825 features = g_list_append(features, feat->namespace);
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
826 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
827 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
828 }
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
829
25164
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
830 info.features = features;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
831 info.identities = jabber_identities;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
832 info.forms = NULL;
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
833
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
834 g_free(js->caps_hash);
f462fa160f06 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <paul@darkrain42.org>
parents: 25162
diff changeset
835 js->caps_hash = jabber_caps_calculate_hash(&info, "sha1");
25026
e61603ab10c6 * correctly calculating own features and factor in is_enabled() of features
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25025
diff changeset
836 g_list_free(features);
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
837 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
838
25146
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
839 const gchar* jabber_caps_get_own_hash(JabberStream *js)
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
840 {
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
841 if (!js->caps_hash)
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
842 jabber_caps_calculate_own_hash(js);
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
843
4040da08a733 Entity Capabilities must be per-JabberStream
Paul Aurich <paul@darkrain42.org>
parents: 25145
diff changeset
844 return js->caps_hash;
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
845 }
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
846
25147
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
847 void jabber_caps_broadcast_change()
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
848 {
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
849 GList *node, *accounts = purple_accounts_get_all_active();
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
850
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
851 for (node = accounts; node; node = node->next) {
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
852 PurpleAccount *account = node->data;
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
853 const char *prpl_id = purple_account_get_protocol_id(account);
25148
6adbaf3d25e3 Fix a null dereference on non-connected accounts
Paul Aurich <paul@darkrain42.org>
parents: 25147
diff changeset
854 if (!strcmp("prpl-jabber", prpl_id) && purple_account_is_connected(account)) {
25147
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
855 PurpleConnection *gc = purple_account_get_connection(account);
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
856 jabber_presence_send(gc->proto_data, TRUE);
25032
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
857 }
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
858 }
25147
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
859
6d6e10476c52 Clean up jabber_presence_send
Paul Aurich <paul@darkrain42.org>
parents: 25146
diff changeset
860 g_list_free(accounts);
25032
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
861 }
7f6558c7a0a3 * implemented jabber_caps_broadcast_change() and finished jabber_ipc_add_feature() IPC function
Tobias Markmann <tfar@soc.pidgin.im>
parents: 25031
diff changeset
862