diff libpurple/protocols/jabber/buddy.c @ 23445:4ac5db6e39f3

Custom smileys for XMPP according to XEP 0231. Refs #5627. committer: Sadrul Habib Chowdhury <imadil@gmail.com>
author Marcus Lundblad <ml@update.uu.se>
date Sun, 01 Jun 2008 20:55:54 +0000
parents 4f49d4b25e24
children c45d05bd58ed
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Sun Jun 01 18:08:14 2008 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Sun Jun 01 20:55:54 2008 +0000
@@ -2500,5 +2500,38 @@
 			js);
 }
 
+gboolean
+jabber_resource_has_capability(const JabberBuddyResource *jbr, const gchar *cap)
+{
+	const GList *iter = NULL;
 
+	if (!jbr->caps) {
+		purple_debug_error("jabber",
+			"Unable to find caps: nothing known about buddy\n");
+		return FALSE;
+	}
 
+	for (iter = jbr->caps->features ; iter ; iter = g_list_next(iter)) {
+		purple_debug_info("jabber", "Found cap: %s\n", (char *)iter->data);
+		if (strcmp(iter->data, cap) == 0) {
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
+gboolean
+jabber_buddy_has_capability(const JabberBuddy *jb, const gchar *cap)
+{
+	JabberBuddyResource *jbr = jabber_buddy_find_resource((JabberBuddy*)jb, NULL);
+
+	if (!jbr) {
+		purple_debug_error("jabber",
+			"Unable to find caps: buddy might be offline\n");
+		return FALSE;
+	}
+
+	return jabber_resource_has_capability(jbr, cap);
+}
+