changeset 23870:aaf11cffe2b2

Prevent multiple voice and video sessions within the same conversation. Properly update the menu when starting or stopping a media session.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Thu, 14 Aug 2008 23:14:56 +0000
parents 551a462b346a
children b5ba1ab6ebdc
files libpurple/protocols/jabber/jingle.c pidgin/gtkconv.c
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jingle.c	Sat Aug 09 03:51:42 2008 +0000
+++ b/libpurple/protocols/jabber/jingle.c	Thu Aug 14 23:14:56 2008 +0000
@@ -1414,6 +1414,13 @@
 			purple_debug_error("jingle", "Jingle session with "
 					"id={%s} already exists\n", sid);
 			/* send iq error */
+		} else if ((session = jabber_jingle_session_find_by_jid(js,
+				xmlnode_get_attrib(packet, "from")))) {
+			purple_debug_fatal("jingle", "Jingle session with "
+					"jid={%s} already exists\n",
+					xmlnode_get_attrib(packet, "from"));
+			/* send jingle redirect packet */
+			return;
 		} else {
 			session = jabber_jingle_session_create_by_id(js, sid);
 			jabber_jingle_session_handle_session_initiate(session, jingle);
--- a/pidgin/gtkconv.c	Sat Aug 09 03:51:42 2008 +0000
+++ b/pidgin/gtkconv.c	Thu Aug 14 23:14:56 2008 +0000
@@ -6381,7 +6381,8 @@
 		/* check if account support voice calls, and if the current buddy
 			supports it */
 		if (account != NULL && purple_conversation_get_type(conv)
-					== PURPLE_CONV_TYPE_IM) {
+					== PURPLE_CONV_TYPE_IM
+					&& gtkconv->gtkmedia == NULL) {
 			gboolean audio = purple_prpl_can_do_media(account,
 					purple_conversation_get_name(conv),
 					PURPLE_MEDIA_AUDIO);
@@ -7732,6 +7733,13 @@
 }
 
 static void
+pidgin_conv_gtkmedia_destroyed(GtkWidget *widget, PidginConversation *gtkconv)
+{
+	gtk_widget_destroyed(widget, &(gtkconv->gtkmedia));
+	gray_stuff_out(gtkconv);
+}
+
+static void
 pidgin_conv_new_media_cb(PurpleMediaManager *manager, PurpleMedia *media, gpointer nul)
 {
 	GtkWidget *gtkmedia;
@@ -7751,10 +7759,13 @@
 	g_signal_connect(G_OBJECT(gtkmedia), "message", G_CALLBACK(pidgin_gtkmedia_message_cb), conv);
 
 	gtkconv->gtkmedia = gtkmedia;
-	g_signal_connect(G_OBJECT(gtkmedia), "destroy", G_CALLBACK(gtk_widget_destroyed), &(gtkconv->gtkmedia));
+	g_signal_connect(G_OBJECT(gtkmedia), "destroy", G_CALLBACK(
+			pidgin_conv_gtkmedia_destroyed), gtkconv);
 
 	gtk_paned_pack2(GTK_PANED(gtkconv->middle_hpaned),
 			pidgin_media_get_display_widget(gtkmedia), FALSE, TRUE);
+
+	gray_stuff_out(gtkconv);
 }
 
 #endif