summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2011-09-09 12:10:06 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-15 10:58:23 +0100
commitaf091b3540daf716d7cbe080bf903f7c84e3b520 (patch)
treeb9094ccf497982894eb685da9b5b00ddb5b68a22 /src
parentdbd130225b9aa35b1244efc0ce2ed3c1979a59d7 (diff)
MUCManager: simplify foreach_channel
Diffstat (limited to 'src')
-rw-r--r--src/idle-muc-manager.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/idle-muc-manager.c b/src/idle-muc-manager.c
index 6bcc92c..7a02552 100644
--- a/src/idle-muc-manager.c
+++ b/src/idle-muc-manager.c
@@ -572,26 +572,27 @@ static void _muc_manager_add_handlers(IdleMUCManager *manager)
idle_parser_add_handler(priv->conn->parser, IDLE_PARSER_PREFIXCMD_TOPIC, _topic_handler, manager);
}
-struct _ForeachHelperData {
- TpExportableChannelFunc func;
- gpointer user_data;
-};
-
-static void _foreach_helper(gpointer key, gpointer value, gpointer user_data) {
- struct _ForeachHelperData *data = user_data;
- data->func(value, data->user_data);
-}
-
-static void _muc_manager_foreach_channel(TpChannelManager *iface, TpExportableChannelFunc func, gpointer user_data) {
- IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE(iface);
- struct _ForeachHelperData data = {func, user_data};
+static void
+_muc_manager_foreach_channel (
+ TpChannelManager *iface,
+ TpExportableChannelFunc func,
+ gpointer user_data)
+{
+ IdleMUCManagerPrivate *priv = IDLE_MUC_MANAGER_GET_PRIVATE (iface);
- if (!priv->channels) {
- IDLE_DEBUG("Channels hash table missing, ignoring...");
- return;
- }
+ if (priv->channels == NULL)
+ {
+ IDLE_DEBUG ("Channels hash table missing, ignoring...");
+ }
+ else
+ {
+ GHashTableIter iter;
+ gpointer v;
- g_hash_table_foreach(priv->channels, _foreach_helper, &data);
+ g_hash_table_iter_init (&iter, priv->channels);
+ while (g_hash_table_iter_next (&iter, NULL, &v))
+ func (TP_EXPORTABLE_CHANNEL (v), user_data);
+ }
}
static void