telepathy-mission-control: _mcd_dispatch_operation_peek_channel: adapt from old _peek_channels
Simon McVittie
smcv at kemper.freedesktop.org
Tue Jul 31 03:41:20 PDT 2012
Module: telepathy-mission-control
Branch: master
Commit: 4877199bfb9ac256dc50893adc6462c288c1a36a
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=4877199bfb9ac256dc50893adc6462c288c1a36a
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Fri Jul 20 12:04:35 2012 +0100
_mcd_dispatch_operation_peek_channel: adapt from old _peek_channels
Now that the CDO can contain at most one channel, there's no need to
return a list.
https://bugs.freedesktop.org/show_bug.cgi?id=52305
---
src/mcd-dispatch-operation-priv.h | 2 +-
src/mcd-dispatch-operation.c | 14 ++++++++++----
src/mcd-dispatcher.c | 10 +++++-----
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 933c12a..23ddb5d 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 1727227..dda2aa9 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 6fff70d..07d6f9a 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 934e6dd..0281dbf 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);
More information about the telepathy-commits
mailing list