libpurple/protocols/jabber/caps.c

Sat, 22 Nov 2008 18:26:45 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Sat, 22 Nov 2008 18:26:45 +0000
branch
cpw.darkrain42.xmpp.bosh
changeset 24734
780b8ad67c22
parent 24732
7d4f758b7b0a
child 24735
c34e7fb23612
permissions
-rw-r--r--

Sprinkle around more support for xml:lang on JabberIdentities
Change the IPC has_feature function to take a PurpleAccount and look up
the caps via the jbr

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

mercurial