diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2012-05-16 17:08:20 +0100 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2012-05-16 17:08:20 +0100 |
commit | eb9aa795c7f4047f93f785889955cbf40408c448 (patch) | |
tree | 8bc4cf1a45edcaffe2813e87e8326638334bf709 | |
parent | 0ca501e59fcff2279a927535708bf2143169d7fe (diff) |
muc-channel: turn DO_QUICK_BOOLEAN from a macro into a function
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | src/idle-muc-channel.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c index 5d90df5..5b9a486 100644 --- a/src/idle-muc-channel.c +++ b/src/idle-muc-channel.c @@ -1545,6 +1545,35 @@ subject_iface_init ( #undef IMPLEMENT } +static void +do_quick_boolean (IdleMUCChannel *self, + GHashTable *properties, + TpBaseRoomConfigProperty prop_id, + const gchar *gobject_property_name, + const gchar irc_mode) +{ + IdleMUCChannelPrivate *priv = self->priv; + + if (g_hash_table_lookup (properties, GUINT_TO_POINTER (prop_id)) != NULL) + { + gboolean new_value = tp_asv_get_boolean (properties, + GUINT_TO_POINTER (prop_id), NULL); + gboolean current_value; + + g_object_get (priv->room_config, + gobject_property_name, ¤t_value, + NULL); + + if (current_value != new_value) + { + gchar *cmd = g_strdup_printf ("MODE %s %c%c", + priv->channel_name, new_value ? '+' : '-', irc_mode); + send_command (self, cmd); + g_free (cmd); + } + } +} + void idle_muc_channel_update_configuration_async ( IdleMUCChannel *self, @@ -1558,29 +1587,12 @@ idle_muc_channel_update_configuration_async ( const gchar *password; /* do the quick ones */ - -#define DO_QUICK_BOOLEAN(prop, name, irc_mode) \ - if (g_hash_table_lookup (validated_properties, GUINT_TO_POINTER (prop)) != NULL) \ - { \ - gboolean value = tp_asv_get_boolean (validated_properties, \ - GUINT_TO_POINTER (prop), NULL); \ - gboolean current; \ - g_object_get (priv->room_config, \ - name, ¤t, \ - NULL); \ - if (current != value) \ - { \ - gchar *cmd = g_strdup_printf ("MODE %s %s%s", priv->channel_name, \ - value ? "+" : "-", irc_mode); \ - send_command (self, cmd); \ - g_free (cmd); \ - } \ - } - - DO_QUICK_BOOLEAN (TP_BASE_ROOM_CONFIG_INVITE_ONLY, "invite-only", "i"); - DO_QUICK_BOOLEAN (TP_BASE_ROOM_CONFIG_MODERATED, "moderated", "m"); - DO_QUICK_BOOLEAN (TP_BASE_ROOM_CONFIG_PRIVATE, "private", "s"); -#undef DO_QUICK_BOOLEAN + do_quick_boolean (self, validated_properties, + TP_BASE_ROOM_CONFIG_INVITE_ONLY, "invite-only", 'i'); + do_quick_boolean (self, validated_properties, + TP_BASE_ROOM_CONFIG_MODERATED, "moderated", 'm'); + do_quick_boolean (self, validated_properties, + TP_BASE_ROOM_CONFIG_PRIVATE, "private", 's'); /* now the rest */ |