aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--libempathy-gtk/gossip-chat.c18
-rw-r--r--libempathy-gtk/gossip-chat.h13
-rw-r--r--libempathy-gtk/gossip-group-chat.c166
-rw-r--r--libempathy-gtk/gossip-private-chat.c1
-rw-r--r--libempathy/empathy-tp-chat.c340
6 files changed, 449 insertions, 99 deletions
diff --git a/ChangeLog b/ChangeLog
index ff37310d6..b3917e751 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-06-03 Xavier Claessens <xclaesse@gmail.com>
+
+ * libempathy-gtk/gossip-group-chat.c:
+ * libempathy-gtk/gossip-private-chat.c:
+ * libempathy-gtk/gossip-chat.c:
+ * libempathy-gtk/gossip-chat.h:
+ * libempathy/empathy-tp-chat.c: Add all properties described by TP spec
+ for the Text channel on EmpathyTpChat. Make use of "name" and "subject"
+ properties in GossipGroupChat.
+
2007-06-02 Xavier Claessens <xclaesse@gmail.com>
* libempathy/empathy-log-manager.c: Fix crash when there is no log
diff --git a/libempathy-gtk/gossip-chat.c b/libempathy-gtk/gossip-chat.c
index 37da0853c..5492edfbf 100644
--- a/libempathy-gtk/gossip-chat.c
+++ b/libempathy-gtk/gossip-chat.c
@@ -319,7 +319,6 @@ chat_destroy_cb (EmpathyTpChat *tp_chat,
GossipChat *chat)
{
GossipChatPriv *priv;
- GtkWidget *widget;
priv = GET_PRIV (chat);
@@ -327,12 +326,14 @@ chat_destroy_cb (EmpathyTpChat *tp_chat,
g_object_unref (priv->tp_chat);
priv->tp_chat = NULL;
}
+ priv->sensitive = FALSE;
gossip_chat_view_append_event (chat->view, _("Disconnected"));
+ gtk_widget_set_sensitive (chat->input_text_view, FALSE);
- widget = gossip_chat_get_widget (chat);
- gtk_widget_set_sensitive (widget, FALSE);
- priv->sensitive = FALSE;
+ if (GOSSIP_CHAT_GET_CLASS (chat)->set_tp_chat) {
+ GOSSIP_CHAT_GET_CLASS (chat)->set_tp_chat (chat, NULL);
+ }
}
static void
@@ -1284,7 +1285,6 @@ gossip_chat_set_tp_chat (GossipChat *chat,
EmpathyTpChat *tp_chat)
{
GossipChatPriv *priv;
- GtkWidget *widget;
g_return_if_fail (GOSSIP_IS_CHAT (chat));
g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat));
@@ -1327,11 +1327,15 @@ gossip_chat_set_tp_chat (GossipChat *chat,
empathy_tp_chat_request_pending (tp_chat);
if (!priv->sensitive) {
- widget = gossip_chat_get_widget (chat);
- gtk_widget_set_sensitive (widget, TRUE);
+ gtk_widget_set_sensitive (chat->input_text_view, TRUE);
gossip_chat_view_append_event (chat->view, _("Connected"));
priv->sensitive = TRUE;
}
+
+ if (GOSSIP_CHAT_GET_CLASS (chat)->set_tp_chat) {
+ GOSSIP_CHAT_GET_CLASS (chat)->set_tp_chat (chat, tp_chat);
+ }
+
}
const gchar *
diff --git a/libempathy-gtk/gossip-chat.h b/libempathy-gtk/gossip-chat.h
index 5fedfdd01..85bfc66b9 100644
--- a/libempathy-gtk/gossip-chat.h
+++ b/libempathy-gtk/gossip-chat.h
@@ -57,6 +57,7 @@ struct _GossipChat {
/* Protected */
GossipChatView *view;
+ EmpathyTpChat *tp_chat;
GtkWidget *input_text_view;
gboolean is_first_char;
McAccount *account;
@@ -66,11 +67,13 @@ struct _GossipChatClass {
GObjectClass parent;
/* VTable */
- const gchar * (*get_name) (GossipChat *chat);
- gchar * (*get_tooltip) (GossipChat *chat);
- const gchar * (*get_status_icon_name)(GossipChat *chat);
- GtkWidget * (*get_widget) (GossipChat *chat);
- gboolean (*is_group_chat) (GossipChat *chat);
+ const gchar * (*get_name) (GossipChat *chat);
+ gchar * (*get_tooltip) (GossipChat *chat);
+ const gchar * (*get_status_icon_name)(GossipChat *chat);
+ GtkWidget * (*get_widget) (GossipChat *chat);
+ gboolean (*is_group_chat) (GossipChat *chat);
+ void (*set_tp_chat) (GossipChat *chat,
+ EmpathyTpChat *tp_chat);
};
GType gossip_chat_get_type (void);
diff --git a/libempathy-gtk/gossip-group-chat.c b/libempathy-gtk/gossip-group-chat.c
index 8e8aa1967..9f3a0f79f 100644
--- a/libempathy-gtk/gossip-group-chat.c
+++ b/libempathy-gtk/gossip-group-chat.c
@@ -97,6 +97,14 @@ static gchar * group_chat_get_tooltip (GossipChat *cha
static const gchar * group_chat_get_status_icon_name (GossipChat *chat);
static GtkWidget * group_chat_get_widget (GossipChat *chat);
static gboolean group_chat_is_group_chat (GossipChat *chat);
+static void group_chat_set_tp_chat (GossipChat *chat,
+ EmpathyTpChat *tp_chat);
+static void group_chat_subject_notify_cb (EmpathyTpChat *tp_chat,
+ GParamSpec *param,
+ GossipGroupChat *chat);
+static void group_chat_name_notify_cb (EmpathyTpChat *tp_chat,
+ GParamSpec *param,
+ GossipGroupChat *chat);
/*static gboolean group_chat_key_press_event (GtkWidget *widget,
GdkEventKey *event,
GossipGroupChat *chat);*/
@@ -122,6 +130,7 @@ gossip_group_chat_class_init (GossipGroupChatClass *klass)
chat_class->get_status_icon_name = group_chat_get_status_icon_name;
chat_class->get_widget = group_chat_get_widget;
chat_class->is_group_chat = group_chat_is_group_chat;
+ chat_class->set_tp_chat = group_chat_set_tp_chat;
g_type_class_add_private (object_class, sizeof (GossipGroupChatPriv));
}
@@ -180,29 +189,6 @@ gossip_group_chat_new (McAccount *account,
priv->tp_chat = empathy_tp_chatroom_new (account, tp_chan);
gossip_chat_set_tp_chat (GOSSIP_CHAT (chat), EMPATHY_TP_CHAT (priv->tp_chat));
- /* FIXME: Ask the user before accepting */
- empathy_tp_chatroom_accept_invitation (priv->tp_chat);
-
- /* Create contact list */
- priv->store = gossip_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat));
- priv->view = gossip_contact_list_view_new (priv->store);
- gtk_container_add (GTK_CONTAINER (priv->scrolled_window_contacts),
- GTK_WIDGET (priv->view));
- gtk_widget_show (GTK_WIDGET (priv->view));
-
- g_signal_connect (priv->tp_chat, "contact-added",
- G_CALLBACK (group_chat_contact_added_cb),
- chat);
- g_signal_connect (priv->tp_chat, "contact-removed",
- G_CALLBACK (group_chat_contact_removed_cb),
- chat);
-/* g_signal_connect (priv->tp_chat, "chatroom-topic-changed",
- G_CALLBACK (group_chat_topic_changed_cb),
- chat);
- g_signal_connect (priv->tp_chat, "contact-info-changed",
- G_CALLBACK (group_chat_contact_info_changed_cb),
- chat);*/
-
return chat;
}
@@ -395,29 +381,7 @@ group_chat_contact_removed_cb (EmpathyTpChatroom *tp_chat,
gossip_chat_view_append_event (GOSSIP_CHAT (chat)->view, str);
g_free (str);
}
-/*
-static void
-group_chat_topic_changed_cb (EmpathyTpChatroom *tp_chat,
- const gchar *new_topic,
- GossipGroupChat *chat)
-{
- GossipGroupChatPriv *priv;
- gchar *str;
- priv = GET_PRIV (chat);
-
- gossip_debug (DEBUG_DOMAIN, "Topic changed by to:'%s'", new_topic);
-
- g_free (priv->topic);
- priv->topic = g_strdup (new_topic);
-
- gtk_label_set_text (GTK_LABEL (priv->label_topic), new_topic);
-
- str = g_strdup_printf (_("Topic set to: %s"), new_topic);
- gossip_chat_view_append_event (GOSSIP_CHAT (chat)->view, str);
- g_free (str);
-}
-*/
static void
group_chat_topic_entry_activate_cb (GtkWidget *entry,
GtkDialog *dialog)
@@ -460,6 +424,20 @@ group_chat_get_name (GossipChat *chat)
group_chat = GOSSIP_GROUP_CHAT (chat);
priv = GET_PRIV (group_chat);
+ if (!priv->name) {
+ const gchar *id;
+ const gchar *server;
+
+ id = gossip_chat_get_id (chat);
+ server = strstr (id, "@");
+
+ if (server) {
+ priv->name = g_strndup (id, server - id);
+ } else {
+ priv->name = g_strdup (id);
+ }
+ }
+
return priv->name;
}
@@ -514,6 +492,104 @@ group_chat_is_group_chat (GossipChat *chat)
return TRUE;
}
+
+static void
+group_chat_set_tp_chat (GossipChat *chat,
+ EmpathyTpChat *tp_chat)
+{
+ GossipGroupChat *group_chat;
+ GossipGroupChatPriv *priv;
+
+ g_return_if_fail (GOSSIP_IS_GROUP_CHAT (chat));
+
+ group_chat = GOSSIP_GROUP_CHAT (chat);
+ priv = GET_PRIV (group_chat);
+
+ /* Free all resources related to tp_chat */
+ if (priv->tp_chat) {
+ g_object_unref (priv->tp_chat);
+ priv->tp_chat = NULL;
+ }
+ if (priv->view) {
+ gtk_widget_destroy (GTK_WIDGET (priv->view));
+ g_object_unref (priv->store);
+ }
+ g_free (priv->name);
+ g_free (priv->topic);
+ priv->name = NULL;
+ priv->topic = NULL;
+
+ if (!tp_chat) {
+ /* We are no more connected */
+ gtk_widget_set_sensitive (priv->hbox_topic, FALSE);
+ gtk_widget_set_sensitive (priv->scrolled_window_contacts, FALSE);
+ return;
+ }
+
+ /* We are connected */
+ gtk_widget_set_sensitive (priv->hbox_topic, TRUE);
+ gtk_widget_set_sensitive (priv->scrolled_window_contacts, TRUE);
+
+ priv->tp_chat = g_object_ref (tp_chat);
+
+ /* FIXME: Ask the user before accepting */
+ empathy_tp_chatroom_accept_invitation (priv->tp_chat);
+
+ /* Create contact list */
+ priv->store = gossip_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat));
+ priv->view = gossip_contact_list_view_new (priv->store);
+ gtk_container_add (GTK_CONTAINER (priv->scrolled_window_contacts),
+ GTK_WIDGET (priv->view));
+ gtk_widget_show (GTK_WIDGET (priv->view));
+
+ /* Connect signals */
+ g_signal_connect (priv->tp_chat, "contact-added",
+ G_CALLBACK (group_chat_contact_added_cb),
+ chat);
+ g_signal_connect (priv->tp_chat, "contact-removed",
+ G_CALLBACK (group_chat_contact_removed_cb),
+ chat);
+ g_signal_connect (priv->tp_chat, "notify::subject",
+ G_CALLBACK (group_chat_subject_notify_cb),
+ chat);
+ g_signal_connect (priv->tp_chat, "notify::name",
+ G_CALLBACK (group_chat_name_notify_cb),
+ chat);
+}
+
+static void
+group_chat_subject_notify_cb (EmpathyTpChat *tp_chat,
+ GParamSpec *param,
+ GossipGroupChat *chat)
+{
+ GossipGroupChatPriv *priv;
+ gchar *str;
+
+ priv = GET_PRIV (chat);
+
+ g_free (priv->topic);
+
+ g_object_get (priv->tp_chat, "subject", &priv->topic, NULL);
+ gtk_label_set_text (GTK_LABEL (priv->label_topic), priv->topic);
+
+ str = g_strdup_printf (_("Topic set to: %s"), priv->topic);
+ gossip_chat_view_append_event (GOSSIP_CHAT (chat)->view, str);
+ g_free (str);
+}
+
+static void
+group_chat_name_notify_cb (EmpathyTpChat *tp_chat,
+ GParamSpec *param,
+ GossipGroupChat *chat)
+{
+ GossipGroupChatPriv *priv;
+
+ priv = GET_PRIV (chat);
+
+ g_free (priv->name);
+ g_object_get (priv->tp_chat, "name", &priv->name, NULL);
+}
+
#if 0
static gboolean
group_chat_key_press_event (GtkWidget *widget,
diff --git a/libempathy-gtk/gossip-private-chat.c b/libempathy-gtk/gossip-private-chat.c
index f047f12e2..a7ef8fb03 100644
--- a/libempathy-gtk/gossip-private-chat.c
+++ b/libempathy-gtk/gossip-private-chat.c
@@ -92,6 +92,7 @@ gossip_private_chat_class_init (GossipPrivateChatClass *klass)
chat_class->get_tooltip = private_chat_get_tooltip;
chat_class->get_status_icon_name = private_chat_get_status_icon_name;
chat_class->get_widget = private_chat_get_widget;
+ chat_class->set_tp_chat = NULL;
g_type_class_add_private (object_class, sizeof (GossipPrivateChatPriv));
}
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index ed6a49323..d63e82551 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -28,6 +28,7 @@
#include <libtelepathy/tp-chan-iface-chat-state-gen.h>
#include <libtelepathy/tp-conn.h>
#include <libtelepathy/tp-helpers.h>
+#include <libtelepathy/tp-props-iface.h>
#include "empathy-tp-chat.h"
#include "empathy-contact-manager.h"
@@ -50,54 +51,76 @@ struct _EmpathyTpChatPriv {
MissionControl *mc;
TpChan *tp_chan;
+ DBusGProxy *props_iface;
DBusGProxy *text_iface;
DBusGProxy *chat_state_iface;
};
-static void empathy_tp_chat_class_init (EmpathyTpChatClass *klass);
-static void empathy_tp_chat_init (EmpathyTpChat *chat);
-static void tp_chat_finalize (GObject *object);
-static GObject * tp_chat_constructor (GType type,
- guint n_props,
- GObjectConstructParam *props);
-static void tp_chat_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void tp_chat_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-static void tp_chat_destroy_cb (TpChan *text_chan,
- EmpathyTpChat *chat);
-static void tp_chat_closed_cb (TpChan *text_chan,
- EmpathyTpChat *chat);
-static void tp_chat_received_cb (DBusGProxy *text_iface,
- guint message_id,
- guint timestamp,
- guint from_handle,
- guint message_type,
- guint message_flags,
- gchar *message_body,
- EmpathyTpChat *chat);
-static void tp_chat_sent_cb (DBusGProxy *text_iface,
- guint timestamp,
- guint message_type,
- gchar *message_body,
- EmpathyTpChat *chat);
-static void tp_chat_state_changed_cb (DBusGProxy *chat_state_iface,
- guint handle,
- TelepathyChannelChatState state,
- EmpathyTpChat *chat);
-static void tp_chat_emit_message (EmpathyTpChat *chat,
- guint type,
- guint timestamp,
- guint from_handle,
- const gchar *message_body);
+static void empathy_tp_chat_class_init (EmpathyTpChatClass *klass);
+static void empathy_tp_chat_init (EmpathyTpChat *chat);
+static void tp_chat_finalize (GObject *object);
+static GObject * tp_chat_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props);
+static void tp_chat_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void tp_chat_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void tp_chat_destroy_cb (TpChan *text_chan,
+ EmpathyTpChat *chat);
+static void tp_chat_closed_cb (TpChan *text_chan,
+ EmpathyTpChat *chat);
+static void tp_chat_received_cb (DBusGProxy *text_iface,
+ guint message_id,
+ guint timestamp,
+ guint from_handle,
+ guint message_type,
+ guint message_flags,
+ gchar *message_body,
+ EmpathyTpChat *chat);
+static void tp_chat_sent_cb (DBusGProxy *text_iface,
+ guint timestamp,
+ guint message_type,
+ gchar *message_body,
+ EmpathyTpChat *chat);
+static void tp_chat_state_changed_cb (DBusGProxy *chat_state_iface,
+ guint handle,
+ TelepathyChannelChatState state,
+ EmpathyTpChat *chat);
+static void tp_chat_emit_message (EmpathyTpChat *chat,
+ guint type,
+ guint timestamp,
+ guint from_handle,
+ const gchar *message_body);
+static void tp_chat_properties_ready_cb (TpPropsIface *props_iface,
+ EmpathyTpChat *chat);
+static void tp_chat_properties_changed_cb (TpPropsIface *props_iface,
+ guint prop_id,
+ TpPropsChanged flag,
+ EmpathyTpChat *chat);
enum {
PROP_0,
PROP_ACCOUNT,
- PROP_TP_CHAN
+ PROP_TP_CHAN,
+
+ PROP_ANONYMOUS,
+ PROP_INVITE_ONLY,
+ PROP_LIMIT,
+ PROP_LIMITED,
+ PROP_MODERATED,
+ PROP_NAME,
+ PROP_DESCRIPTION,
+ PROP_PASSWORD,
+ PROP_PASSWORD_REQUIRED,
+ PROP_PERSISTENT,
+ PROP_PRIVATE,
+ PROP_SUBJECT,
+ PROP_SUBJECT_CONTACT,
+ PROP_SUBJECT_TIMESTAMP
};
enum {
@@ -121,6 +144,7 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
object_class->get_property = tp_chat_get_property;
object_class->set_property = tp_chat_set_property;
+ /* Construct-only properties */
g_object_class_install_property (object_class,
PROP_ACCOUNT,
g_param_spec_object ("account",
@@ -129,7 +153,6 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
MC_TYPE_ACCOUNT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
-
g_object_class_install_property (object_class,
PROP_TP_CHAN,
g_param_spec_object ("tp-chan",
@@ -139,6 +162,114 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
+ /* Properties of Text Channel */
+ g_object_class_install_property (object_class,
+ PROP_ANONYMOUS,
+ g_param_spec_boolean ("anonymous",
+ "anonymous",
+ "anonymous",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_INVITE_ONLY,
+ g_param_spec_boolean ("invite-only",
+ "invite-only",
+ "invite-only",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LIMIT,
+ g_param_spec_uint ("limit",
+ "limit",
+ "limit",
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LIMITED,
+ g_param_spec_boolean ("limited",
+ "limited",
+ "limited",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_MODERATED,
+ g_param_spec_boolean ("moderated",
+ "moderated",
+ "moderated",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ "name",
+ "name",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_DESCRIPTION,
+ g_param_spec_string ("description",
+ "description",
+ "description",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_PASSWORD,
+ g_param_spec_string ("password",
+ "password",
+ "password",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_PASSWORD_REQUIRED,
+ g_param_spec_boolean ("password-required",
+ "password-required",
+ "password-required",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_PERSISTENT,
+ g_param_spec_boolean ("persistent",
+ "persistent",
+ "persistent",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_PRIVATE,
+ g_param_spec_boolean ("private",
+ "private",
+ "private"
+ "private",
+ FALSE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_SUBJECT,
+ g_param_spec_string ("subject",
+ "subject",
+ "subject",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_SUBJECT_CONTACT,
+ g_param_spec_uint ("subject-contact",
+ "subject-contact",
+ "subject-contact",
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_SUBJECT_TIMESTAMP,
+ g_param_spec_uint ("subject-timestamp",
+ "subject-timestamp",
+ "subject-timestamp",
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ /* Signals */
signals[MESSAGE_RECEIVED] =
g_signal_new ("message-received",
G_TYPE_FROM_CLASS (klass),
@@ -242,6 +373,8 @@ tp_chat_constructor (GType type,
TELEPATHY_CHAN_IFACE_TEXT_QUARK);
priv->chat_state_iface = tp_chan_get_interface (priv->tp_chan,
TELEPATHY_CHAN_IFACE_CHAT_STATE_QUARK);
+ priv->props_iface = tp_chan_get_interface (priv->tp_chan,
+ TELEPATHY_PROPS_IFACE_QUARK);
g_signal_connect (priv->tp_chan, "destroy",
G_CALLBACK (tp_chat_destroy_cb),
@@ -262,6 +395,30 @@ tp_chat_constructor (GType type,
G_CALLBACK (tp_chat_state_changed_cb),
chat, NULL);
}
+ if (priv->props_iface != NULL) {
+ tp_props_iface_set_mapping (TELEPATHY_PROPS_IFACE (priv->props_iface),
+ "anonymous", PROP_ANONYMOUS,
+ "invite-only", PROP_INVITE_ONLY,
+ "limit", PROP_LIMIT,
+ "limited", PROP_LIMITED,
+ "moderated", PROP_MODERATED,
+ "name", PROP_NAME,
+ "description", PROP_DESCRIPTION,
+ "password", PROP_PASSWORD,
+ "password-required", PROP_PASSWORD_REQUIRED,
+ "persistent", PROP_PERSISTENT,
+ "private", PROP_PRIVATE,
+ "subject", PROP_SUBJECT,
+ "subject-contact", PROP_SUBJECT_CONTACT,
+ "subject-timestamp", PROP_SUBJECT_TIMESTAMP,
+ NULL);
+ g_signal_connect (priv->props_iface, "properties-ready",
+ G_CALLBACK (tp_chat_properties_ready_cb),
+ chat);
+ g_signal_connect (priv->props_iface, "properties-changed",
+ G_CALLBACK (tp_chat_properties_changed_cb),
+ chat);
+ }
return chat;
}
@@ -273,8 +430,21 @@ tp_chat_get_property (GObject *object,
GParamSpec *pspec)
{
EmpathyTpChatPriv *priv;
+ EmpathyTpChat *chat;
priv = GET_PRIV (object);
+ chat = EMPATHY_TP_CHAT (object);
+
+ if (param_id >= PROP_ANONYMOUS &&
+ param_id <= PROP_SUBJECT_TIMESTAMP) {
+ if (priv->props_iface) {
+ tp_props_iface_get_value (TELEPATHY_PROPS_IFACE (priv->props_iface),
+ param_id,
+ value);
+ }
+
+ return;
+ }
switch (param_id) {
case PROP_ACCOUNT:
@@ -296,8 +466,21 @@ tp_chat_set_property (GObject *object,
GParamSpec *pspec)
{
EmpathyTpChatPriv *priv;
+ EmpathyTpChat *chat;
priv = GET_PRIV (object);
+ chat = EMPATHY_TP_CHAT (object);
+
+ if (param_id >= PROP_ANONYMOUS &&
+ param_id <= PROP_SUBJECT_TIMESTAMP) {
+ if (priv->props_iface) {
+ tp_props_iface_set_value (TELEPATHY_PROPS_IFACE (priv->props_iface),
+ param_id,
+ value);
+ }
+
+ return;
+ }
switch (param_id) {
case PROP_ACCOUNT:
@@ -507,6 +690,7 @@ tp_chat_destroy_cb (TpChan *text_chan,
priv->tp_chan = NULL;
priv->text_iface = NULL;
priv->chat_state_iface = NULL;
+ priv->props_iface = NULL;
g_signal_emit (chat, signals[DESTROY], 0);
}
@@ -628,3 +812,75 @@ tp_chat_emit_message (EmpathyTpChat *chat,
g_object_unref (sender);
}
+static void
+tp_chat_properties_ready_cb (TpPropsIface *props_iface,
+ EmpathyTpChat *chat)
+{
+ g_object_notify (G_OBJECT (chat), "anonymous");
+ g_object_notify (G_OBJECT (chat), "invite-only");
+ g_object_notify (G_OBJECT (chat), "limit");
+ g_object_notify (G_OBJECT (chat), "limited");
+ g_object_notify (G_OBJECT (chat), "moderated");
+ g_object_notify (G_OBJECT (chat), "name");
+ g_object_notify (G_OBJECT (chat), "description");
+ g_object_notify (G_OBJECT (chat), "password");
+ g_object_notify (G_OBJECT (chat), "password-required");
+ g_object_notify (G_OBJECT (chat), "persistent");
+ g_object_notify (G_OBJECT (chat), "private");
+ g_object_notify (G_OBJECT (chat), "subject");
+ g_object_notify (G_OBJECT (chat), "subject-contact");
+ g_object_notify (G_OBJECT (chat), "subject-timestamp");
+}
+
+static void
+tp_chat_properties_changed_cb (TpPropsIface *props_iface,
+ guint prop_id,
+ TpPropsChanged flag,
+ EmpathyTpChat *chat)
+{
+ switch (prop_id) {
+ case PROP_ANONYMOUS:
+ g_object_notify (G_OBJECT (chat), "anonymous");
+ break;
+ case PROP_INVITE_ONLY:
+ g_object_notify (G_OBJECT (chat), "invite-only");
+ break;
+ case PROP_LIMIT:
+ g_object_notify (G_OBJECT (chat), "limit");
+ break;
+ case PROP_LIMITED:
+ g_object_notify (G_OBJECT (chat), "limited");
+ break;
+ case PROP_MODERATED:
+ g_object_notify (G_OBJECT (chat), "moderated");
+ break;
+ case PROP_NAME:
+ g_object_notify (G_OBJECT (chat), "name");
+ break;
+ case PROP_DESCRIPTION:
+ g_object_notify (G_OBJECT (chat), "description");
+ break;
+ case PROP_PASSWORD:
+ g_object_notify (G_OBJECT (chat), "password");
+ break;
+ case PROP_PASSWORD_REQUIRED:
+ g_object_notify (G_OBJECT (chat), "password-required");
+ break;
+ case PROP_PERSISTENT:
+ g_object_notify (G_OBJECT (chat), "persistent");
+ break;
+ case PROP_PRIVATE:
+ g_object_notify (G_OBJECT (chat), "private");
+ break;
+ case PROP_SUBJECT:
+ g_object_notify (G_OBJECT (chat), "subject");
+ break;
+ case PROP_SUBJECT_CONTACT:
+ g_object_notify (G_OBJECT (chat), "subject-contact");
+ break;
+ case PROP_SUBJECT_TIMESTAMP:
+ g_object_notify (G_OBJECT (chat), "subject-timestamp");
+ break;
+ }
+}
+