diff options
-rw-r--r-- | src/mcd-dispatch-operation-priv.h | 2 | ||||
-rw-r--r-- | src/mcd-dispatch-operation.c | 14 | ||||
-rw-r--r-- | src/mcd-dispatcher.c | 10 | ||||
-rw-r--r-- | src/plugin-dispatch-operation.c | 22 |
4 files changed, 27 insertions, 21 deletions
diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h index 933c12a4..23ddb5d3 100644 --- a/src/mcd-dispatch-operation-priv.h +++ b/src/mcd-dispatch-operation-priv.h @@ -75,7 +75,7 @@ G_GNUC_INTERNAL McdDispatchOperation *_mcd_dispatch_operation_new ( G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_has_channel ( McdDispatchOperation *self, McdChannel *channel); -G_GNUC_INTERNAL const GList *_mcd_dispatch_operation_peek_channels ( +G_GNUC_INTERNAL McdChannel *_mcd_dispatch_operation_peek_channel ( McdDispatchOperation *self); G_GNUC_INTERNAL GList *_mcd_dispatch_operation_dup_channels ( McdDispatchOperation *self); diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c index 17272276..dda2aa9c 100644 --- a/src/mcd-dispatch-operation.c +++ b/src/mcd-dispatch-operation.c @@ -1149,7 +1149,7 @@ mcd_dispatch_operation_channel_aborted_cb (McdChannel *channel, _mcd_dispatch_operation_lose_channel (self, channel); - if (_mcd_dispatch_operation_peek_channels (self) == NULL) + if (self->priv->channels == NULL) { DEBUG ("Nothing left in this context"); } @@ -1884,11 +1884,17 @@ _mcd_dispatch_operation_has_channel (McdDispatchOperation *self, return (g_list_find (self->priv->channels, channel) != NULL); } -const GList * -_mcd_dispatch_operation_peek_channels (McdDispatchOperation *self) +McdChannel * +_mcd_dispatch_operation_peek_channel (McdDispatchOperation *self) { g_return_val_if_fail (MCD_IS_DISPATCH_OPERATION (self), NULL); - return self->priv->channels; + g_return_val_if_fail (self->priv->channels == NULL || + self->priv->channels->next == NULL, NULL); + + if (self->priv->channels == NULL) + return NULL; + + return self->priv->channels->data; } GList * diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c index 6fff70de..07d6f9af 100644 --- a/src/mcd-dispatcher.c +++ b/src/mcd-dispatcher.c @@ -314,7 +314,7 @@ _mcd_dispatcher_enter_state_machine (McdDispatcher *dispatcher, list = g_list_delete_link (list, list); } } - else if (_mcd_dispatch_operation_peek_channels (operation) == NULL) + else if (_mcd_dispatch_operation_peek_channel (operation) == NULL) { DEBUG ("No channels left"); } @@ -625,11 +625,11 @@ mcd_dispatcher_client_needs_recovery_cb (McdClientProxy *client, if (_mcd_dispatch_operation_has_invoked_observers (op)) { - for (channels = _mcd_dispatch_operation_peek_channels (op); - channels != NULL; - channels = channels->next) + McdChannel *mcd_channel = + _mcd_dispatch_operation_peek_channel (op); + + if (mcd_channel != NULL) { - McdChannel *mcd_channel = channels->data; GHashTable *properties = _mcd_channel_get_immutable_properties (mcd_channel); diff --git a/src/plugin-dispatch-operation.c b/src/plugin-dispatch-operation.c index 934e6dde..0281dbfc 100644 --- a/src/plugin-dispatch-operation.c +++ b/src/plugin-dispatch-operation.c @@ -178,9 +178,11 @@ plugin_do_get_n_channels (McpDispatchOperation *obj) McdPluginDispatchOperation *self = MCD_PLUGIN_DISPATCH_OPERATION (obj); g_return_val_if_fail (self != NULL, 0); - /* FIXME: O(n) */ - return g_list_length ((GList *) _mcd_dispatch_operation_peek_channels ( - self->real_cdo)); + + if (_mcd_dispatch_operation_peek_channel (self->real_cdo) != NULL) + return 1; + + return 0; } static const gchar * @@ -191,11 +193,10 @@ plugin_do_get_nth_channel_path (McpDispatchOperation *obj, McdChannel *channel; g_return_val_if_fail (self != NULL, NULL); - /* FIXME: O(n) */ - channel = g_list_nth_data ((GList *) _mcd_dispatch_operation_peek_channels ( - self->real_cdo), n); - if (channel == NULL) + channel = _mcd_dispatch_operation_peek_channel (self->real_cdo); + + if (channel == NULL || n != 0) return NULL; return mcd_channel_get_object_path (channel); @@ -210,11 +211,10 @@ plugin_do_ref_nth_channel_properties (McpDispatchOperation *obj, GHashTable *ret; g_return_val_if_fail (self != NULL, NULL); - /* FIXME: O(n) */ - channel = g_list_nth_data ((GList *) _mcd_dispatch_operation_peek_channels ( - self->real_cdo), n); - if (channel == NULL) + channel = _mcd_dispatch_operation_peek_channel (self->real_cdo); + + if (channel == NULL || n != 0) return NULL; ret = _mcd_channel_get_immutable_properties (channel); |