diff libpurple/protocols/jabber/jabber.c @ 23867:4bc74deeb503

propagate from branch 'im.pidgin.pidgin' (head 434563a4b8fadb9593c241db4bb5ffd0bf2c0627) to branch 'im.pidgin.soc.2008.vv' (head 59d05cb38af9346d82ce57477273f7b381054bcc)
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 09 Aug 2008 02:24:38 +0000
parents fa8567fa0ca0 e23b447aa5ca
children 551a462b346a
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Fri Aug 08 23:34:27 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sat Aug 09 02:24:38 2008 +0000
@@ -56,6 +56,16 @@
 #include "xdata.h"
 #include "pep.h"
 #include "adhoccommands.h"
+#include "jingle.h"
+
+#ifdef USE_VV
+#include <gst/farsight/fs-conference-iface.h>
+
+#define XEP_0167_AUDIO_CAP "urn:xmpp:tmp:jingle:apps:rtp#audio"
+#define XEP_0167_VIDEO_CAP "urn:xmpp:tmp:jingle:apps:rtp#video"
+#define GTALK_CAP "http://www.google.com/session/phone"
+
+#endif
 
 #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5)
 
@@ -659,6 +669,10 @@
 	js->keepalive_timeout = -1;
 	js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user ? js->user->domain : NULL);
 
+#ifdef USE_VV
+	js->sessions = NULL;
+#endif
+
 	if(!js->user) {
 		purple_connection_error_reason (gc,
 			PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
@@ -1269,6 +1283,11 @@
 {
 	JabberStream *js = gc->proto_data;
 
+#ifdef USE_VV
+	/* Close all of the open Jingle sessions on this stream */
+	jabber_jingle_session_terminate_sessions(js);
+#endif
+
 	/* Don't perform any actions on the ssl connection
 	 * if we were forcibly disconnected because it will crash
 	 * on some SSL backends.
@@ -1898,6 +1917,9 @@
 	if(!(jid = jabber_id_new(who)))
 		return;
 
+#ifdef USE_VV
+	jabber_jingle_session_terminate_session_media(js, who);
+#endif
 	if((jb = jabber_buddy_find(js, who, TRUE)) &&
 			(jbr = jabber_buddy_find_resource(jb, jid->resource))) {
 		if(jbr->thread_id) {
@@ -2375,6 +2397,55 @@
 	return TRUE;
 }
 
+#ifdef USE_VV
+
+PurpleMedia *
+jabber_initiate_media(PurpleConnection *gc, const char *who, 
+		      PurpleMediaStreamType type)
+{
+	return jabber_jingle_session_initiate_media(gc->proto_data, who, type);
+}
+
+gboolean jabber_can_do_media(PurpleConnection *gc, const char *who, 
+                             PurpleMediaStreamType type)
+{
+	JabberStream *js = (JabberStream *) gc->proto_data;
+	JabberBuddy *jb;
+
+	if (!js) {
+		purple_debug_error("jabber", "jabber_can_do_media: NULL stream\n");
+		return FALSE;
+	}
+
+	jb = jabber_buddy_find(js, who, FALSE);
+
+	if (!jb) {
+		purple_debug_error("jabber", "Could not find buddy\n");
+		return FALSE;
+	}
+	/* 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_AUDIO_CAP) ||
+				jabber_buddy_has_capability(jb, GTALK_CAP)) && 
+				jabber_buddy_has_capability(jb, XEP_0167_VIDEO_CAP);
+	} else 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_AUDIO_CAP) ||
+				jabber_buddy_has_capability(jb, GTALK_CAP);
+	} 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_0167_VIDEO_CAP);
+	}
+
+	return FALSE;
+}
+
+#endif
+
 void jabber_register_commands(void)
 {
 	purple_cmd_register("config", "", PURPLE_CMD_P_PRPL,