aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-contact-menu.c14
-rw-r--r--libempathy/empathy-chatroom-manager.c6
-rw-r--r--libempathy/empathy-chatroom.c47
-rw-r--r--libempathy/empathy-chatroom.h6
4 files changed, 60 insertions, 13 deletions
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index 91138e293..e3fb3c9f7 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -301,20 +301,20 @@ room_sub_menu_activate_cb (GtkWidget *item,
{
TpHandle handle;
GArray handles = {(gchar *) &handle, 1};
+ EmpathyTpChat *chat;
TpChannel *channel;
- g_object_get (data->chatroom, "tp-channel", &channel, NULL);
- if (channel == NULL) {
+ chat = empathy_chatroom_get_tp_chat (data->chatroom);
+ if (chat == NULL) {
/* channel was invalidated. Ignoring */
return;
}
/* send invitation */
handle = empathy_contact_get_handle (data->contact);
+ channel = empathy_tp_chat_get_channel (chat);
tp_cli_channel_interface_group_call_add_members (channel, -1, &handles,
_("Inviting to this room"), NULL, NULL, NULL, NULL);
-
- g_object_unref (channel);
}
static GtkWidget *
@@ -362,17 +362,13 @@ empathy_contact_invite_menu_item_new (EmpathyContact *contact)
for (l = rooms; l != NULL; l = g_list_next (l)) {
EmpathyChatroom *chatroom = l->data;
- TpChannel *channel;
- g_object_get (chatroom, "tp-channel", &channel, NULL);
- if (channel != NULL) {
+ if (empathy_chatroom_get_tp_chat (chatroom) != NULL) {
have_rooms = TRUE;
room_item = create_room_sub_menu (contact, chatroom);
gtk_menu_shell_append (submenu_shell, room_item);
gtk_widget_show (room_item);
-
- g_object_unref (channel);
}
}
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
index 0a637a440..fdc6f3c0c 100644
--- a/libempathy/empathy-chatroom-manager.c
+++ b/libempathy/empathy-chatroom-manager.c
@@ -667,6 +667,7 @@ chatroom_manager_chat_destroyed_cb (EmpathyTpChat *chat,
if (chatroom == NULL)
return;
+ g_object_set (chatroom, "tp-chat", NULL, NULL);
g_object_get (chatroom, "favorite", &favorite, NULL);
if (!favorite)
@@ -715,9 +716,14 @@ chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher,
{
chatroom = empathy_chatroom_new_full (account, roomname, roomname,
FALSE);
+ g_object_set (G_OBJECT (chatroom), "tp-chat", chat, NULL);
empathy_chatroom_manager_add (manager, chatroom);
g_object_unref (chatroom);
}
+ else
+ {
+ g_object_set (G_OBJECT (chatroom), "tp-chat", chat, NULL);
+ }
/* A TpChat is always destroyed as it only gets unreffed after the channel
* has been invalidated in the dispatcher.. */
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;
+}
diff --git a/libempathy/empathy-chatroom.h b/libempathy/empathy-chatroom.h
index a4eecc04a..3261c8d25 100644
--- a/libempathy/empathy-chatroom.h
+++ b/libempathy/empathy-chatroom.h
@@ -26,6 +26,8 @@
#include <libmissioncontrol/mc-account.h>
+#include <libempathy/empathy-tp-chat.h>
+
G_BEGIN_DECLS
#define EMPATHY_TYPE_CHATROOM (empathy_chatroom_get_type ())
@@ -69,8 +71,8 @@ void empathy_chatroom_set_auto_connect (EmpathyChatroom *chatroom,
gboolean auto_connect);
gboolean empathy_chatroom_equal (gconstpointer v1,
gconstpointer v2);
+EmpathyTpChat * empathy_chatroom_get_tp_chat (EmpathyChatroom *chatroom);
-
-G_BEGIN_DECLS
+G_END_DECLS
#endif /* __EMPATHY_CHATROOM_H__ */