changeset 29579:f65689100cfe

Move odd direction changing functionality to the Fs2 media backend.
author maiku@pidgin.im
date Tue, 27 Oct 2009 18:34:46 +0000
parents dfc724880907
children 7e9d8840e97f
files libpurple/media/backend-fs2.c libpurple/media/media.c
diffstat 2 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media/backend-fs2.c	Tue Oct 27 18:15:23 2009 +0000
+++ b/libpurple/media/backend-fs2.c	Tue Oct 27 18:34:46 2009 +0000
@@ -1416,6 +1416,7 @@
 	PurpleMediaBackendFs2 *backend = PURPLE_MEDIA_BACKEND_FS2(self);
 	PurpleMediaBackendFs2Private *priv =
 			PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(backend);
+	PurpleMediaBackendFs2Stream *stream;
 
 	if (priv->conference == NULL && !_init_conference(backend)) {
 		purple_debug_error("backend-fs2",
@@ -1438,8 +1439,19 @@
 		return FALSE;
 	}
 
-	if (_get_stream(backend, sess_id, who) == NULL &&
-			!_create_stream(backend, sess_id, who, type,
+	stream = _get_stream(backend, sess_id, who);
+
+	if (stream != NULL) {
+		FsStreamDirection type_direction =
+				_session_type_to_fs_stream_direction(type);
+
+		if (_session_type_to_fs_stream_direction(
+				stream->session->type) != type_direction) {
+			/* change direction */
+			g_object_set(stream->stream, "direction",
+					type_direction, NULL);
+		}
+	} else if (!_create_stream(backend, sess_id, who, type,
 			initiator, transmitter, num_params, params)) {
 		purple_debug_error("backend-fs2",
 				"Error creating the stream.\n");
--- a/libpurple/media/media.c	Tue Oct 27 18:15:23 2009 +0000
+++ b/libpurple/media/media.c	Tue Oct 27 18:34:46 2009 +0000
@@ -1230,9 +1230,7 @@
 	participant = purple_media_backend_fs2_get_participant(
 			PURPLE_MEDIA_BACKEND_FS2(media->priv->backend), who);
 
-	stream = purple_media_get_stream(media, sess_id, who);
-
-	if (!stream) {
+	if (purple_media_get_stream(media, sess_id, who) == NULL) {
 		FsStream *fsstream = NULL;
 
 		fsstream = purple_media_backend_fs2_get_stream(
@@ -1249,13 +1247,6 @@
 		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
 				0, PURPLE_MEDIA_STATE_NEW,
 				session->id, who);
-	} else {
-		if (purple_media_to_fs_stream_direction(stream->session->type)
-				!= type_direction) {
-			/* change direction */
-			g_object_set(stream->stream, "direction",
-					type_direction, NULL);
-		}
 	}
 
 	return TRUE;