summaryrefslogtreecommitdiff
path: root/src/room-config.c
blob: 199545ad583bca96e45a64693d8e24381bf993df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * room-config.c - Channel.Interface.RoomConfig1 implementation
 * Copyright ©2011 Collabora Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"

#include "room-config.h"
#include "muc-channel.h"

#define DEBUG_FLAG GABBLE_DEBUG_MUC
#include "debug.h"

static void gabble_room_config_update_configuration_async (
    TpBaseRoomConfig *base_config,
    GHashTable *validated_properties,
    GAsyncReadyCallback callback,
    gpointer user_data);

struct _GabbleRoomConfigPrivate {
    gpointer hi_dere;
};

G_DEFINE_TYPE (GabbleRoomConfig, gabble_room_config, TP_TYPE_BASE_ROOM_CONFIG)

static void
gabble_room_config_init (GabbleRoomConfig *self)
{
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GABBLE_TYPE_ROOM_CONFIG,
      GabbleRoomConfigPrivate);
}

static void
gabble_room_config_class_init (GabbleRoomConfigClass *klass)
{
  TpBaseRoomConfigClass *parent_class = TP_BASE_ROOM_CONFIG_CLASS (klass);

  parent_class->update_async = gabble_room_config_update_configuration_async;
  g_type_class_add_private (klass, sizeof (GabbleRoomConfigPrivate));
}

GabbleRoomConfig *
gabble_room_config_new (
    TpBaseChannel *channel)
{
  g_return_val_if_fail (TP_IS_BASE_CHANNEL (channel), NULL);

  return g_object_new (GABBLE_TYPE_ROOM_CONFIG,
      "channel", channel,
      NULL);
}

static void
updated_configuration_cb (
    GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  GabbleMucChannel *channel = GABBLE_MUC_CHANNEL (source);
  GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
  GError *error = NULL;

  if (!gabble_muc_channel_update_configuration_finish (channel, result, &error))
    {
      g_simple_async_result_set_from_error (simple, error);
      g_clear_error (&error);
    }

  g_simple_async_result_complete (simple);
  g_object_unref (simple);
}

static void
gabble_room_config_update_configuration_async (
    TpBaseRoomConfig *base_config,
    GHashTable *validated_properties,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  TpBaseChannel *base_channel = tp_base_room_config_dup_channel (base_config);
  GSimpleAsyncResult *simple = g_simple_async_result_new (
      G_OBJECT (base_config), callback, user_data,
      gabble_room_config_update_configuration_async);

  gabble_muc_channel_update_configuration_async (
      GABBLE_MUC_CHANNEL (base_channel), validated_properties,
      updated_configuration_cb, simple);
  g_object_unref (base_channel);
}