summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Barnett <jbarnett@stanfordalumni.org>2012-05-15 13:21:44 -0700
committerJoe Barnett <jbarnett@stanfordalumni.org>2012-05-15 13:21:44 -0700
commit191f78215111311fbb4b46a8e683b4889de3a49b (patch)
tree25ace9004032d5e1fce24c9349b544abd1d7495a
parent23daca1cc03cda47e7125e238ef77ca1fa0c6384 (diff)
notify channel manager when channel closes
-rw-r--r--src/kindling-roomlist-channel.c8
-rw-r--r--src/kindling-roomlist-manager.c14
2 files changed, 18 insertions, 4 deletions
diff --git a/src/kindling-roomlist-channel.c b/src/kindling-roomlist-channel.c
index 9e94cdf..3c7d0e0 100644
--- a/src/kindling-roomlist-channel.c
+++ b/src/kindling-roomlist-channel.c
@@ -53,7 +53,6 @@ kindling_roomlist_channel_constructed (GObject *obj) {
g_printf("roomlist constructed\n");
GObjectClass *parent_class = kindling_roomlist_channel_parent_class;
KindlingRoomlistChannel *self = KINDLING_ROOMLIST_CHANNEL(obj);
- TpBaseChannel *base_chan = (TpBaseChannel *)self;
if (parent_class->constructed != NULL) {
parent_class->constructed(obj);
}
@@ -71,6 +70,12 @@ kindling_roomlist_channel_finalize (GObject *object)
/* TODO: Add deinitalization code here */
g_printf("roomlist finalize\n");
+ KindlingRoomlistChannelPrivate *priv = KINDLING_ROOMLIST_CHANNEL_GET_PRIVATE(object);
+ while (priv->rooms->len > 0) {
+ g_boxed_free(TP_STRUCT_TYPE_ROOM_INFO, g_ptr_array_index(priv->rooms, 0));
+ g_ptr_array_remove_index_fast (priv->rooms, 0);
+ }
+ g_ptr_array_free(priv->rooms, TRUE);
G_OBJECT_CLASS (kindling_roomlist_channel_parent_class)->finalize (object);
}
static const gchar *kindling_roomlist_channel_interfaces[] = {
@@ -88,7 +93,6 @@ kindling_roomlist_channel_class_init (KindlingRoomlistChannelClass *klass)
g_printf("roomlist class init\n");
GObjectClass* object_class = G_OBJECT_CLASS (klass);
TpBaseChannelClass* parent_class = TP_BASE_CHANNEL_CLASS (klass);
- GParamSpec *param_spec;
g_type_class_add_private (klass, sizeof(KindlingRoomlistChannelPrivate));
object_class->finalize = kindling_roomlist_channel_finalize;
diff --git a/src/kindling-roomlist-manager.c b/src/kindling-roomlist-manager.c
index 3a205b8..0cbf491 100644
--- a/src/kindling-roomlist-manager.c
+++ b/src/kindling-roomlist-manager.c
@@ -147,6 +147,15 @@ static void kindling_roomlist_manager_type_foreach_channel_class (GType type,
g_hash_table_unref (table);
}
+static void roomlist_channel_closed_cb (KindlingRoomlistChannel *channel, gpointer user_data) {
+ KindlingRoomlistManager *self = KINDLING_ROOMLIST_MANAGER(user_data);
+ KindlingRoomlistManagerPrivate *priv = KINDLING_ROOMLIST_MANAGER_GET_PRIVATE(self);
+ tp_channel_manager_emit_channel_closed_for_object (self, TP_EXPORTABLE_CHANNEL(channel));
+ if (priv->channels != NULL) {
+ g_ptr_array_remove (priv->channels, channel);
+ g_object_unref (channel);
+ }
+}
static gboolean kindling_roomlist_manager_get_channel(TpChannelManager *manager,
gpointer request_token,
@@ -159,18 +168,19 @@ static gboolean kindling_roomlist_manager_get_channel(TpChannelManager *manager,
TP_IFACE_CHANNEL_TYPE_ROOM_LIST)) {
return FALSE;
}
- if (priv->channels->len > 0) {
+ if (priv->channels->len > 0 && !require_new) {
tp_channel_manager_emit_request_already_satisfied (manager, request_token, TP_EXPORTABLE_CHANNEL(g_ptr_array_index (priv->channels,0)));
return TRUE;
}
channel = g_object_new(KINDLING_TYPE_ROOMLIST_CHANNEL, "connection", priv->conn);
+ g_signal_connect (channel, "closed", (GCallback) roomlist_channel_closed_cb, manager);
g_ptr_array_add(priv->channels, channel);
GSList *request_tokens = g_slist_prepend (NULL, request_token);
tp_channel_manager_emit_new_channel (manager,
TP_EXPORTABLE_CHANNEL(channel),
request_tokens);
g_slist_free (request_tokens);
- return FALSE;
+ return TRUE;
}
static gboolean kindling_roomlist_manager_ensure_channel(TpChannelManager *manager,