[Telepathy-commits] [telepathy-glib/master] ExampleCallableMediaStream: set initial direction at construct time

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Mar 24 13:34:12 PDT 2009


This avoids the emission of a spurious direction change signal.
---
 examples/cm/callable/media-channel.c |   16 +---------------
 examples/cm/callable/media-stream.c  |   33 +++++++++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/examples/cm/callable/media-channel.c b/examples/cm/callable/media-channel.c
index c3372d4..aaacada 100644
--- a/examples/cm/callable/media-channel.c
+++ b/examples/cm/callable/media-channel.c
@@ -1036,6 +1036,7 @@ example_callable_media_channel_add_stream (ExampleCallableMediaChannel *self,
       "id", id,
       "handle", self->priv->handle,
       "type", media_type,
+      "locally-requested", locally_requested,
       NULL);
 
   g_hash_table_insert (self->priv->streams, GUINT_TO_POINTER (id), stream);
@@ -1071,21 +1072,6 @@ example_callable_media_channel_add_stream (ExampleCallableMediaChannel *self,
   g_signal_connect (stream, "direction-changed",
       G_CALLBACK (stream_direction_changed_cb), self);
 
-  if (locally_requested)
-    {
-      /* the local user wants this stream to be bidirectional (which
-       * requires remote acknowledgement */
-      example_callable_media_stream_change_direction (stream,
-          TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL, NULL);
-    }
-  else
-    {
-      /* the remote user wants this stream to be bidirectional (which
-       * requires local acknowledgement) */
-      example_callable_media_stream_receive_direction_request (stream,
-          TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL);
-    }
-
   if (self->priv->progress == PROGRESS_ACTIVE)
     {
       example_callable_media_stream_connect (stream);
diff --git a/examples/cm/callable/media-stream.c b/examples/cm/callable/media-stream.c
index 2b59d4b..1177064 100644
--- a/examples/cm/callable/media-stream.c
+++ b/examples/cm/callable/media-stream.c
@@ -45,6 +45,7 @@ enum
   PROP_DIRECTION,
   PROP_STREAM_INFO,
   PROP_SIMULATION_DELAY,
+  PROP_LOCALLY_REQUESTED,
   N_PROPS
 };
 
@@ -74,6 +75,7 @@ struct _ExampleCallableMediaStreamPrivate
 
   guint connected_event_id;
 
+  gboolean locally_requested;
   gboolean removed;
 };
 
@@ -84,10 +86,10 @@ example_callable_media_stream_init (ExampleCallableMediaStream *self)
       EXAMPLE_TYPE_CALLABLE_MEDIA_STREAM,
       ExampleCallableMediaStreamPrivate);
 
-  /* FIXME: no particular "implicit" direction is currently mandated by
-   * telepathy-spec */
+  /* start off directionless */
   self->priv->direction = TP_MEDIA_STREAM_DIRECTION_NONE;
   self->priv->pending_send = 0;
+  self->priv->state = TP_MEDIA_STREAM_STATE_DISCONNECTED;
 }
 
 static void
@@ -188,6 +190,10 @@ get_property (GObject *object,
       g_value_set_uint (value, self->priv->simulation_delay);
       break;
 
+    case PROP_LOCALLY_REQUESTED:
+      g_value_set_boolean (value, self->priv->locally_requested);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -225,6 +231,22 @@ set_property (GObject *object,
       self->priv->simulation_delay = g_value_get_uint (value);
       break;
 
+    case PROP_LOCALLY_REQUESTED:
+      self->priv->locally_requested = g_value_get_boolean (value);
+
+      if (self->priv->locally_requested)
+        {
+          example_callable_media_stream_change_direction (self,
+              TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL, NULL);
+        }
+      else
+        {
+          example_callable_media_stream_receive_direction_request (self,
+              TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL);
+        }
+
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -339,6 +361,13 @@ example_callable_media_stream_class_init (ExampleCallableMediaStreamClass *klass
   g_object_class_install_property (object_class, PROP_SIMULATION_DELAY,
       param_spec);
 
+  param_spec = g_param_spec_boolean ("locally-requested", "Locally requested?",
+      "True if this channel was requested by the local user",
+      FALSE,
+      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_LOCALLY_REQUESTED,
+      param_spec);
+
   signals[SIGNAL_REMOVED] = g_signal_new ("removed",
       G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
       g_cclosure_marshal_VOID__VOID,
-- 
1.5.6.5




More information about the telepathy-commits mailing list