[telepathy-gabble/master] Don't try to remove contents in GTalk calls
Will Thompson
will.thompson at collabora.co.uk
Mon Jun 22 11:21:00 PDT 2009
---
src/jingle-session.c | 6 +++++
src/jingle-session.h | 2 +
src/media-channel.c | 57 ++++++++++++++++++++++++++++++++++++++-----------
3 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/src/jingle-session.c b/src/jingle-session.c
index aaafa80..ce6b3d8 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -2235,6 +2235,12 @@ gabble_jingle_session_get_remote_ringing (GabbleJingleSession *sess)
return sess->priv->remote_ringing;
}
+gboolean
+gabble_jingle_session_can_modify_contents (GabbleJingleSession *sess)
+{
+ return !JINGLE_IS_GOOGLE_DIALECT (sess->priv->dialect);
+}
+
/* Only to be used for the test suite */
void
gabble_set_jingle_session_timeout (guint ms)
diff --git a/src/jingle-session.h b/src/jingle-session.h
index be5c0ce..ed9bd0d 100644
--- a/src/jingle-session.h
+++ b/src/jingle-session.h
@@ -109,6 +109,8 @@ const gchar *gabble_jingle_session_get_peer_resource (
GabbleJingleSession *sess);
const gchar *gabble_jingle_session_get_sid (GabbleJingleSession *sess);
+gboolean gabble_jingle_session_can_modify_contents (GabbleJingleSession *sess);
+
typedef void (*JingleReplyHandler) (GObject *, gboolean success,
LmMessage *reply);
void gabble_jingle_session_send (GabbleJingleSession *sess,
diff --git a/src/media-channel.c b/src/media-channel.c
index 7a687e6..44ebbe8 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -1158,6 +1158,14 @@ gabble_media_channel_remove_streams (TpSvcChannelTypeStreamedMedia *iface,
priv = obj->priv;
+ if (!gabble_jingle_session_can_modify_contents (priv->session))
+ {
+ GError e = { TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+ "Streams can't be removed from Google Talk calls" };
+ dbus_g_method_return_error (context, &e);
+ return;
+ }
+
stream_objs = g_ptr_array_sized_new (streams->len);
/* check that all stream ids are valid and at the same time build an array
@@ -1270,16 +1278,26 @@ gabble_media_channel_request_stream_direction (TpSvcChannelTypeStreamedMedia *if
if (stream_direction == TP_MEDIA_STREAM_DIRECTION_NONE)
{
- GabbleJingleMediaRtp *c;
+ if (gabble_jingle_session_can_modify_contents (priv->session))
+ {
+ GabbleJingleMediaRtp *c;
- DEBUG ("request for NONE direction; removing stream");
+ DEBUG ("request for NONE direction; removing stream");
- c = gabble_media_stream_get_content (stream);
- gabble_jingle_session_remove_content (priv->session,
- (GabbleJingleContent *) c);
+ c = gabble_media_stream_get_content (stream);
+ gabble_jingle_session_remove_content (priv->session,
+ (GabbleJingleContent *) c);
- tp_svc_channel_type_streamed_media_return_from_request_stream_direction (
- context);
+ tp_svc_channel_type_streamed_media_return_from_request_stream_direction (
+ context);
+ }
+ else
+ {
+ GError e = { TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+ "Stream direction can't be set to None in Google Talk calls" };
+ DEBUG ("%s", e.message);
+ dbus_g_method_return_error (context, &e);
+ }
return;
}
@@ -2418,12 +2436,25 @@ stream_error_cb (GabbleMediaStream *stream,
tp_svc_channel_type_streamed_media_emit_stream_error (chan, id, errno,
message);
- /* remove stream from session (removal will be signalled
- * so we can dispose of the stream)
- */
- c = gabble_media_stream_get_content (stream);
- gabble_jingle_session_remove_content (priv->session,
- (GabbleJingleContent *) c);
+ if (gabble_jingle_session_can_modify_contents (priv->session))
+ {
+ /* remove stream from session (removal will be signalled
+ * so we can dispose of the stream)
+ */
+ c = gabble_media_stream_get_content (stream);
+ gabble_jingle_session_remove_content (priv->session,
+ (GabbleJingleContent *) c);
+ }
+ else
+ {
+ /* We can't remove the content; let's terminate the call. (The
+ * alternative is to carry on the call with only audio/video, which will
+ * look or sound bad to the Google Talk-using peer.)
+ */
+ DEBUG ("Terminating call in response to stream error");
+ gabble_jingle_session_terminate (priv->session,
+ TP_CHANNEL_GROUP_CHANGE_REASON_ERROR, NULL);
+ }
}
static void
--
1.5.6.5
More information about the telepathy-commits
mailing list