annotate libpurple/protocols/jabber/caps.c @ 25783:d5b1fede10a0

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