diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-01-10 00:15:31 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-01-10 00:15:31 +0800 |
commit | c870b1b51063dff7e5218d8bd6bdc565cb69b577 (patch) | |
tree | 4cb2431426467c02ae36c1c38cc3a4da90a1f5f6 /libempathy/empathy-chatroom.c | |
parent | eba71b838f543c7dd9390e74911526cf3d48fa26 (diff) | |
download | gsoc2013-empathy-c870b1b51063dff7e5218d8bd6bdc565cb69b577.tar gsoc2013-empathy-c870b1b51063dff7e5218d8bd6bdc565cb69b577.tar.gz gsoc2013-empathy-c870b1b51063dff7e5218d8bd6bdc565cb69b577.tar.bz2 gsoc2013-empathy-c870b1b51063dff7e5218d8bd6bdc565cb69b577.tar.lz gsoc2013-empathy-c870b1b51063dff7e5218d8bd6bdc565cb69b577.tar.xz gsoc2013-empathy-c870b1b51063dff7e5218d8bd6bdc565cb69b577.tar.zst gsoc2013-empathy-c870b1b51063dff7e5218d8bd6bdc565cb69b577.zip |
Let a chatroom keep a reference to a its TpChat if applicable
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
svn path=/trunk/; revision=2189
Diffstat (limited to 'libempathy/empathy-chatroom.c')
-rw-r--r-- | libempathy/empathy-chatroom.c | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/libempathy/empathy-chatroom.c b/libempathy/empathy-chatroom.c index 0920c8a14..16707bd15 100644 --- a/libempathy/empathy-chatroom.c +++ b/libempathy/empathy-chatroom.c @@ -35,7 +35,8 @@ typedef struct { gchar *room; gchar *name; gboolean auto_connect; - gboolean favorite; + gboolean favorite; + EmpathyTpChat *tp_chat; } EmpathyChatroomPriv; @@ -55,7 +56,8 @@ enum { PROP_ROOM, PROP_NAME, PROP_AUTO_CONNECT, - PROP_FAVORITE, + PROP_FAVORITE, + PROP_TP_CHAT, }; G_DEFINE_TYPE (EmpathyChatroom, empathy_chatroom, G_TYPE_OBJECT); @@ -113,6 +115,14 @@ empathy_chatroom_class_init (EmpathyChatroomClass *klass) G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (object_class, + PROP_TP_CHAT, + g_param_spec_object ("tp-chat", + "Chatroom channel wrapper", + "The wrapper for the chatroom channel if there is one", + EMPATHY_TYPE_TP_CHAT, + G_PARAM_READWRITE)); + g_type_class_add_private (object_class, sizeof (EmpathyChatroomPriv)); } @@ -132,6 +142,9 @@ chatroom_finalize (GObject *object) priv = GET_PRIV (object); + if (priv->tp_chat != NULL) + g_object_unref (priv->tp_chat); + g_object_unref (priv->account); g_free (priv->room); g_free (priv->name); @@ -165,6 +178,9 @@ chatroom_get_property (GObject *object, case PROP_FAVORITE: g_value_set_boolean (value, priv->favorite); break; + case PROP_TP_CHAT: + g_value_set_object (value, priv->tp_chat); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -206,6 +222,22 @@ chatroom_set_property (GObject *object, FALSE); } break; + case PROP_TP_CHAT: { + GObject *chat = g_value_dup_object (value); + + if (chat == (GObject *) priv->tp_chat) + break; + + g_assert (chat == NULL || priv->tp_chat == NULL); + + if (priv->tp_chat != NULL) { + g_object_unref (priv->tp_chat); + priv->tp_chat = NULL; + } else { + priv->tp_chat = EMPATHY_TP_CHAT (chat); + } + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -389,3 +421,14 @@ empathy_chatroom_equal (gconstpointer v1, return empathy_account_equal (account_a, account_b) && !tp_strdiff (room_a, room_b); } + +EmpathyTpChat * +empathy_chatroom_get_tp_chat (EmpathyChatroom *chatroom) { + EmpathyChatroomPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), NULL); + + priv = GET_PRIV (chatroom); + + return priv->tp_chat; +} |