diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2011-03-23 11:52:39 +0000 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2011-03-23 11:55:05 +0000 |
commit | d13877d457fca3b01c216f0f59d6bb4188361977 (patch) | |
tree | f3ba07332f5b8c1abb574109bd3295e3ba409783 | |
parent | caab8e2608d30d95404ae2b8140dedffbc74b5db (diff) |
Add a ready property on the client object tree
-rw-r--r-- | telepathy-yell/call-channel.c | 70 | ||||
-rw-r--r-- | telepathy-yell/call-content.c | 59 | ||||
-rw-r--r-- | telepathy-yell/call-stream.c | 16 |
3 files changed, 143 insertions, 2 deletions
diff --git a/telepathy-yell/call-channel.c b/telepathy-yell/call-channel.c index 8e91adf..f0b8cdc 100644 --- a/telepathy-yell/call-channel.c +++ b/telepathy-yell/call-channel.c @@ -82,6 +82,9 @@ struct _TpyCallChannelPrivate GPtrArray *contents; GSimpleAsyncResult *result; + + gboolean properties_retrieved; + gboolean ready; }; enum /* props */ @@ -98,7 +101,8 @@ enum /* props */ PROP_INITIAL_AUDIO_NAME, PROP_INITIAL_VIDEO, PROP_INITIAL_VIDEO_NAME, - PROP_MUTABLE_CONTENTS + PROP_MUTABLE_CONTENTS, + PROP_READY }; enum /* signals */ @@ -113,6 +117,41 @@ enum /* signals */ static guint _signals[LAST_SIGNAL] = { 0, }; static void +maybe_go_to_ready (TpyCallChannel *self) +{ + TpyCallChannelPrivate *priv = self->priv; + guint i; + + if (priv->ready) + return; + + if (!priv->properties_retrieved) + return; + + for (i = 0 ; i < priv->contents->len; i++) + { + TpyCallContent *c = g_ptr_array_index (self->priv->contents, i); + gboolean ready; + + g_object_get (c, "ready", &ready, NULL); + + if (!ready) + return; + } + + priv->ready = TRUE; + g_object_notify (G_OBJECT (self), "ready"); +} + +static void +on_content_ready_cb (TpyCallContent *content, + GParamSpec *spec, + TpyCallChannel *self) +{ + maybe_go_to_ready (self); +} + +static void on_content_added_cb (TpProxy *proxy, const gchar *content_path, gpointer user_data, @@ -137,6 +176,8 @@ on_content_added_cb (TpProxy *proxy, } g_ptr_array_add (self->priv->contents, content); + tp_g_signal_connect_object (content, "notify::ready", + G_CALLBACK (on_content_ready_cb), self, 0); g_signal_emit (self, _signals[CONTENT_ADDED], 0, content); } @@ -278,9 +319,16 @@ on_call_channel_get_all_properties_cb (TpProxy *proxy, } g_ptr_array_add (self->priv->contents, content); + + tp_g_signal_connect_object (content, "notify::ready", + G_CALLBACK (on_content_ready_cb), self, 0); } g_signal_emit (self, _signals[MEMBERS_CHANGED], 0, self->priv->members); + + self->priv->properties_retrieved = TRUE; + + maybe_go_to_ready (self); } static void @@ -334,6 +382,10 @@ tpy_call_channel_get_property (GObject *object, g_value_set_boolean (value, self->priv->initial_video); break; + case PROP_READY: + g_value_set_boolean (value, self->priv->ready); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -522,6 +574,21 @@ tpy_call_channel_class_init (TpyCallChannelClass *klass) PROP_INITIAL_VIDEO, param_spec); /** + * TpyCallChannel:ready: + * + * Whether or call channel got all its async information + * + * Since: + */ + param_spec = g_param_spec_boolean ("ready", "Ready", + "If true the call channel and all its contents have retrieved all" + "all async information from the CM", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (gobject_class, PROP_READY, + param_spec); + + /** * TpyCallChannel::content-added * @self: the #TpyCallChannel * @content: the newly added content @@ -588,6 +655,7 @@ tpy_call_channel_class_init (TpyCallChannelClass *klass) g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, G_TYPE_HASH_TABLE); + } static void diff --git a/telepathy-yell/call-content.c b/telepathy-yell/call-content.c index fe40c30..9027464 100644 --- a/telepathy-yell/call-content.c +++ b/telepathy-yell/call-content.c @@ -40,6 +40,8 @@ struct _TpyCallContentPrivate TpMediaStreamType media_type; TpyCallContentDisposition disposition; GList *streams; + gboolean ready; + gboolean properties_retrieved; GSimpleAsyncResult *result; }; @@ -49,7 +51,8 @@ enum PROP_NAME = 1, PROP_MEDIA_TYPE, PROP_DISPOSITION, - PROP_STREAMS + PROP_STREAMS, + PROP_READY }; enum @@ -86,6 +89,42 @@ on_content_removed_cb (TpProxy *proxy, } static void +maybe_go_to_ready (TpyCallContent *self) +{ + TpyCallContentPrivate *priv = self->priv; + GList *l; + + if (priv->ready) + return; + + if (!priv->properties_retrieved) + return; + + + for (l = priv->streams; l != NULL ; l = g_list_next (l)) + { + TpyCallStream *s = l->data; + gboolean ready; + + g_object_get (s, "ready", &ready, NULL); + + if (!ready) + return; + } + + priv->ready = TRUE; + g_object_notify (G_OBJECT (self), "ready"); +} + +static void +on_stream_ready_cb (TpyCallStream *stream, + GParamSpec *spec, + TpyCallContent *self) +{ + maybe_go_to_ready (self); +} + +static void add_streams (TpyCallContent *self, const GPtrArray *streams) { GPtrArray *object_streams; @@ -113,6 +152,9 @@ add_streams (TpyCallContent *self, const GPtrArray *streams) continue; } + tp_g_signal_connect_object (stream, "notify::ready", + G_CALLBACK (on_stream_ready_cb), self, 0); + self->priv->streams = g_list_prepend (self->priv->streams, stream); g_ptr_array_add (object_streams, stream); } @@ -266,6 +308,9 @@ tpy_call_content_get_property ( case PROP_STREAMS: g_value_set_boxed (value, self->priv->streams); break; + case PROP_READY: + g_value_set_boolean (value, self->priv->ready); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -341,6 +386,15 @@ tpy_call_content_class_init ( g_object_class_install_property (object_class, PROP_STREAMS, param_spec); + param_spec = g_param_spec_boolean ("ready", + "Ready", + "If true the content and all its streams have retrieved all" + "all async information from the CM", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_READY, + param_spec); + /** * TpyCallContent::removed * @self: the #TpyCallContent @@ -442,6 +496,9 @@ on_call_content_get_all_properties_cb (TpProxy *proxy, if (streams != NULL) add_streams (self, streams); + + self->priv->properties_retrieved = TRUE; + maybe_go_to_ready (self); } static void diff --git a/telepathy-yell/call-stream.c b/telepathy-yell/call-stream.c index 3b313e0..9a04581 100644 --- a/telepathy-yell/call-stream.c +++ b/telepathy-yell/call-stream.c @@ -36,6 +36,7 @@ enum PROP_REMOTE_MEMBERS = 1, PROP_LOCAL_SENDING_STATE, PROP_CAN_REQUEST_RECEIVING, + PROP_READY, }; struct _TpyCallStreamPrivate @@ -43,6 +44,7 @@ struct _TpyCallStreamPrivate GHashTable *remote_members; TpySendingState local_sending_state; gboolean can_request_receiving; + gboolean ready; GSimpleAsyncResult *result; }; @@ -74,6 +76,9 @@ on_call_stream_get_all_properties_cb (TpProxy *proxy, if (members != NULL) self->priv->remote_members = g_boxed_copy (TPY_HASH_TYPE_CALL_MEMBER_MAP, members); + + self->priv->ready = TRUE; + g_object_notify (G_OBJECT (self), "ready"); } static void @@ -193,6 +198,9 @@ tpy_call_stream_get_property ( case PROP_CAN_REQUEST_RECEIVING: g_value_set_boolean (value, priv->can_request_receiving); break; + case PROP_READY: + g_value_set_boolean (value, priv->ready); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -257,6 +265,14 @@ tpy_call_stream_class_init (TpyCallStreamClass *bsc_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_CAN_REQUEST_RECEIVING, param_spec); + + param_spec = g_param_spec_boolean ("ready", + "Ready", + "If true the stream has retrieved all async information from the CM", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_READY, + param_spec); } TpySendingState |