summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-16 18:30:56 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-16 18:30:56 +0100
commit6ff9e1a08d0a3c24e68cb1b65289eb95e7060359 (patch)
tree4ab553a0fdb6be13ffa2064f0bb4a0e5e7c93dd7 /src
parenta66b3c0c7ded54ca407439871d87b7fbd20535e8 (diff)
room-config: flicker CanUpdateConfiguration but keep MutableProperties stable
I had misunderstood these two properties before, yet again. This is better and easier. I added more tests. Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/idle-muc-channel.c22
-rw-r--r--src/room-config.c32
2 files changed, 34 insertions, 20 deletions
diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c
index 09b487f..1ee5748 100644
--- a/src/idle-muc-channel.c
+++ b/src/idle-muc-channel.c
@@ -243,11 +243,6 @@ idle_muc_channel_constructed (GObject *obj)
priv->room_config =
(TpBaseRoomConfig *) idle_room_config_new ((TpBaseChannel *) self);
-
- tp_base_room_config_set_can_update_configuration (
- priv->room_config, TRUE);
- /* Just to get CanUpdateConfiguration out there. */
- tp_base_room_config_emit_properties_changed (priv->room_config);
}
static void
@@ -572,31 +567,18 @@ static void change_mode_state(IdleMUCChannel *obj, guint add, guint remove) {
}
if (combined & (MODE_FLAG_OPERATOR_PRIVILEGE | MODE_FLAG_HALFOP_PRIVILEGE)) {
- static const TpBaseRoomConfigProperty prop_helper[] = {
- TP_BASE_ROOM_CONFIG_INVITE_ONLY,
- TP_BASE_ROOM_CONFIG_LIMIT,
- TP_BASE_ROOM_CONFIG_MODERATED,
- TP_BASE_ROOM_CONFIG_PASSWORD,
- TP_BASE_ROOM_CONFIG_PASSWORD_PROTECTED,
- TP_BASE_ROOM_CONFIG_PRIVATE,
- TP_NUM_BASE_ROOM_CONFIG_PROPERTIES
- };
if (add & (MODE_FLAG_OPERATOR_PRIVILEGE | MODE_FLAG_HALFOP_PRIVILEGE)) {
group_add |= TP_CHANNEL_GROUP_FLAG_CAN_ADD | TP_CHANNEL_GROUP_FLAG_CAN_REMOVE | TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE;
- for (int i = 0; prop_helper[i] != TP_NUM_BASE_ROOM_CONFIG_PROPERTIES; ++i) {
- tp_base_room_config_set_property_mutable (priv->room_config, prop_helper[i], TRUE);
- }
+ tp_base_room_config_set_can_update_configuration (priv->room_config, TRUE);
if (flags & MODE_FLAG_TOPIC_ONLY_SETTABLE_BY_OPS)
idle_muc_channel_update_can_set_topic (obj, TRUE);
} else if (remove & (MODE_FLAG_OPERATOR_PRIVILEGE | MODE_FLAG_HALFOP_PRIVILEGE)) {
group_remove |= TP_CHANNEL_GROUP_FLAG_CAN_REMOVE | TP_CHANNEL_GROUP_FLAG_MESSAGE_REMOVE;
- for (int i = 0; prop_helper[i] != TP_NUM_BASE_ROOM_CONFIG_PROPERTIES; ++i) {
- tp_base_room_config_set_property_mutable (priv->room_config, prop_helper[i], FALSE);
- }
+ tp_base_room_config_set_can_update_configuration (priv->room_config, FALSE);
if (flags & MODE_FLAG_INVITE_ONLY)
group_remove |= TP_CHANNEL_GROUP_FLAG_CAN_ADD;
diff --git a/src/room-config.c b/src/room-config.c
index 10d994d..27f0c9b 100644
--- a/src/room-config.c
+++ b/src/room-config.c
@@ -61,6 +61,35 @@ idle_room_config_init (IdleRoomConfig *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, IDLE_TYPE_ROOM_CONFIG,
IdleRoomConfigPrivate);
+}
+
+static void
+idle_room_config_constructed (GObject *object)
+{
+ TpBaseRoomConfig *self = TP_BASE_ROOM_CONFIG (object);
+ static const TpBaseRoomConfigProperty prop_helper[] = {
+ TP_BASE_ROOM_CONFIG_INVITE_ONLY,
+ TP_BASE_ROOM_CONFIG_LIMIT,
+ TP_BASE_ROOM_CONFIG_MODERATED,
+ TP_BASE_ROOM_CONFIG_PASSWORD,
+ TP_BASE_ROOM_CONFIG_PASSWORD_PROTECTED,
+ TP_BASE_ROOM_CONFIG_PRIVATE,
+ TP_NUM_BASE_ROOM_CONFIG_PROPERTIES
+ };
+ guint i;
+ void (*chain_up)(GObject *) =
+ G_OBJECT_CLASS (idle_room_config_parent_class)->constructed;
+
+ if (chain_up != NULL)
+ chain_up (object);
+
+ for (i = 0; prop_helper[i] != TP_NUM_BASE_ROOM_CONFIG_PROPERTIES; ++i)
+ {
+ tp_base_room_config_set_property_mutable (self, prop_helper[i], TRUE);
+ }
+
+ /* Just to get the mutable properties out there. */
+ tp_base_room_config_emit_properties_changed (self);
/* Let's reset the password back to the empty string when
* password-protected is set to False. */
@@ -71,8 +100,11 @@ idle_room_config_init (IdleRoomConfig *self)
static void
idle_room_config_class_init (IdleRoomConfigClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
TpBaseRoomConfigClass *parent_class = TP_BASE_ROOM_CONFIG_CLASS (klass);
+ object_class->constructed = idle_room_config_constructed;
+
parent_class->update_async = idle_room_config_update_configuration_async;
g_type_class_add_private (klass, sizeof (IdleRoomConfigPrivate));
}