comparison libpurple/protocols/jabber/buddy.c @ 25189:05693f6885a4

Support old (XEP v1.3) Entity Capabilities alongside the new ones. The ext structures from v1.3 are stored in a ref-counted structure that is shared among all instances of the ClientInfo that share the same 'node' (unique per client). exts are only used for v1.3-entity capabilities clients and are not shared with caps that specify the 'hash' attribute (required in v1.5). The jabber_caps_cbplususerdata is also ref-counted and will never leak, even if some disco#info responses from a client return errors.
author Paul Aurich <paul@darkrain42.org>
date Fri, 19 Dec 2008 04:11:07 +0000
parents 6bdcdb77ce77
children 5ad14a53e266
comparison
equal deleted inserted replaced
25188:d5b1fede10a0 25189:05693f6885a4
179 g_free(cmd->name); 179 g_free(cmd->name);
180 g_free(cmd); 180 g_free(cmd);
181 jbr->commands = g_list_delete_link(jbr->commands, jbr->commands); 181 jbr->commands = g_list_delete_link(jbr->commands, jbr->commands);
182 } 182 }
183 183
184 jabber_caps_client_info_unref(jbr->caps); 184 jabber_caps_client_info_unref(jbr->caps.info);
185 if (jbr->caps.exts) {
186 g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL);
187 g_list_free(jbr->caps.exts);
188 }
185 g_free(jbr->name); 189 g_free(jbr->name);
186 g_free(jbr->status); 190 g_free(jbr->status);
187 g_free(jbr->thread_id); 191 g_free(jbr->thread_id);
188 g_free(jbr->client.name); 192 g_free(jbr->client.name);
189 g_free(jbr->client.version); 193 g_free(jbr->client.version);
2507 2511
2508 gboolean 2512 gboolean
2509 jabber_resource_has_capability(const JabberBuddyResource *jbr, const gchar *cap) 2513 jabber_resource_has_capability(const JabberBuddyResource *jbr, const gchar *cap)
2510 { 2514 {
2511 const GList *node = NULL; 2515 const GList *node = NULL;
2512 2516 const JabberCapsNodeExts *exts;
2513 if (!jbr->caps) { 2517
2518 if (!jbr->caps.info) {
2514 purple_debug_error("jabber", 2519 purple_debug_error("jabber",
2515 "Unable to find caps: nothing known about buddy\n"); 2520 "Unable to find caps: nothing known about buddy\n");
2516 return FALSE; 2521 return FALSE;
2517 } 2522 }
2518 2523
2519 node = g_list_find_custom(jbr->caps->features, cap, (GCompareFunc)strcmp); 2524 node = g_list_find_custom(jbr->caps.info->features, cap, (GCompareFunc)strcmp);
2525 if (!node && jbr->caps.exts && jbr->caps.info->exts) {
2526 const GList *ext;
2527 exts = jbr->caps.info->exts;
2528 /* Walk through all the enabled caps, checking each list for the cap.
2529 * Don't check it twice, though. */
2530 for (ext = jbr->caps.exts; ext && !node; ext = ext->next) {
2531 GList *features = g_hash_table_lookup(exts->exts, ext->data);
2532 if (features)
2533 node = g_list_find_custom(features, cap, (GCompareFunc)strcmp);
2534 }
2535 }
2536
2520 /* TODO: Are these messages actually useful? */ 2537 /* TODO: Are these messages actually useful? */
2521 if (node) 2538 if (node)
2522 purple_debug_info("jabber", "Found cap: %s\n", cap); 2539 purple_debug_info("jabber", "Found cap: %s\n", cap);
2523 else 2540 else
2524 purple_debug_info("jabber", "Cap %s not found\n", cap); 2541 purple_debug_info("jabber", "Cap %s not found\n", cap);