soc.2008.vv: 8c2c4614: Check remote JID's capabilities for audi...
maiku at soc.pidgin.im
maiku at soc.pidgin.im
Sat May 31 16:25:47 EDT 2008
-----------------------------------------------------------------
Revision: 8c2c4614b3fb8864734e22baba48a3028dacbe35
Ancestor: ff3b6b797ee034e56837d4d4e52600f1285c0ca0
Author: maiku at soc.pidgin.im
Date: 2008-05-31T20:15:34
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/8c2c4614b3fb8864734e22baba48a3028dacbe35
Modified files:
libpurple/protocols/jabber/buddy.c
libpurple/protocols/jabber/buddy.h
libpurple/protocols/jabber/disco.c
libpurple/protocols/jabber/jabber.c
ChangeLog:
Check remote JID's capabilities for audio and video XEP support.
Comments:
Modified patch from Marcus Lundblad (mlundblad).
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/buddy.c 8e94a0b20a3d76b0e62ba906767bd357ab6f66a4
+++ libpurple/protocols/jabber/buddy.c ee00e7be5f7f0198cc5b393c3aac386c8e163b80
@@ -2491,5 +2491,30 @@ void jabber_user_search_begin(PurplePlug
js);
}
+gboolean
+jabber_buddy_has_capability(JabberBuddy *jb, const gchar *cap)
+{
+ JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL);
+ const GList *iter = NULL;
+
+ if (!jbr) {
+ purple_debug_error("jabber",
+ "Unable to find caps: buddy might be offline\n");
+ return FALSE;
+ }
+
+ 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)) {
+ if (strcmp(iter->data, cap) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
============================================================
--- libpurple/protocols/jabber/buddy.h 76c21a001293a2011e6b482cc9b847e941c7fde6
+++ libpurple/protocols/jabber/buddy.h 053bd8a9e997a3f41278f4c4bacf28340bebb34b
@@ -99,6 +99,8 @@ void jabber_buddy_get_info_chat(PurpleCo
void jabber_buddy_get_info_chat(PurpleConnection *gc, int id,
const char *resource);
+gboolean jabber_buddy_has_capability(JabberBuddy *jb, const gchar *cap);
+
GList *jabber_blist_node_menu(PurpleBlistNode *node);
void jabber_set_info(PurpleConnection *gc, const char *info);
============================================================
--- libpurple/protocols/jabber/disco.c ecd502cc546493ca78133dec6984e269c4ef4497
+++ libpurple/protocols/jabber/disco.c cc7536d85ced5961209687186730f9d71abe9e18
@@ -142,6 +142,7 @@ void jabber_disco_info_parse(JabberStrea
SUPPORT_FEATURE(feat->namespace);
}
}
+#ifdef USE_VV
} else if (node && !strcmp(node, CAPS0115_NODE "#voice-v1")) {
SUPPORT_FEATURE("http://www.google.com/session");
SUPPORT_FEATURE("http://www.google.com/transport/p2p");
@@ -150,7 +151,9 @@ void jabber_disco_info_parse(JabberStrea
SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0166.html");
SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0180.html");
SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0167.html");
+ SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0176.html");
SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0177.html");
+#endif
} else {
const char *ext = NULL;
unsigned pos;
============================================================
--- libpurple/protocols/jabber/jabber.c de3dcb7f334740c54c723c5cb03a4edbf2e82eed
+++ libpurple/protocols/jabber/jabber.c 4939e88d407ede4d01d3d11f6a28c9f43ec5690c
@@ -60,6 +60,11 @@
#ifdef USE_VV
#include <gst/farsight/fs-conference-iface.h>
+
+#define XEP_0167_CAP "http://www.xmpp.org/extensions/xep-0167.html"
+#define XEP_0180_CAP "http://www.xmpp.org/extensions/xep-0180.html"
+#define GTALK_CAP "http://www.google.com/session/phone"
+
#endif
#define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5)
@@ -2640,10 +2645,37 @@ gboolean jabber_can_do_media(PurpleConne
gboolean jabber_can_do_media(PurpleConnection *gc, const char *who,
PurpleMediaStreamType type)
{
- if (type == PURPLE_MEDIA_AUDIO)
- return TRUE;
- else
+ JabberStream *js = (JabberStream *) gc->proto_data;
+ JabberBuddy *jb = jabber_buddy_find(js, who, FALSE);
+
+ if (!jb) {
+ purple_debug_error("jabber", "Could not find buddy\n");
return FALSE;
+ }
+#if 0 /* These can be added once we support video */
+ /* XMPP will only support two-way media, AFAIK... */
+ if (type == (PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO)) {
+ purple_debug_info("jabber",
+ "Checking audio/video XEP support for %s\n", who);
+ return (jabber_buddy_has_capability(jb, XEP_0167_CAP) ||
+ jabber_buddy_has_capability(jb, GTALK_CAP)) &&
+ jabber_buddy_has_capability(jb, XEP_0180_CAP);
+ } else
+#endif
+ if (type == (PURPLE_MEDIA_AUDIO)) {
+ purple_debug_info("jabber",
+ "Checking audio XEP support for %s\n", who);
+ return jabber_buddy_has_capability(jb, XEP_0167_CAP) ||
+ jabber_buddy_has_capability(jb, GTALK_CAP);
+ }
+#if 0
+ else if (type == (PURPLE_MEDIA_VIDEO)) {
+ purple_debug_info("jabber",
+ "Checking video XEP support for %s\n", who);
+ return jabber_buddy_has_capability(jb, XEP_0180_CAP);
+ }
+#endif
+ return FALSE;
}
More information about the Commits
mailing list