diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-03-11 20:23:06 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-03-11 20:23:06 +0800 |
commit | a69b6ced4cb82dc5e898e79dfb58f6e67b7beb59 (patch) | |
tree | cf84c6ef5b7997a17f44e681a5338900df18c7bc | |
parent | 862aee8f30817b0f56c59134cef0c7e51d7cc168 (diff) | |
download | gsoc2013-empathy-a69b6ced4cb82dc5e898e79dfb58f6e67b7beb59.tar gsoc2013-empathy-a69b6ced4cb82dc5e898e79dfb58f6e67b7beb59.tar.gz gsoc2013-empathy-a69b6ced4cb82dc5e898e79dfb58f6e67b7beb59.tar.bz2 gsoc2013-empathy-a69b6ced4cb82dc5e898e79dfb58f6e67b7beb59.tar.lz gsoc2013-empathy-a69b6ced4cb82dc5e898e79dfb58f6e67b7beb59.tar.xz gsoc2013-empathy-a69b6ced4cb82dc5e898e79dfb58f6e67b7beb59.tar.zst gsoc2013-empathy-a69b6ced4cb82dc5e898e79dfb58f6e67b7beb59.zip |
Fix usage of property iface and make use of it to get chatroom topic.
svn path=/trunk/; revision=772
-rw-r--r-- | libempathy-gtk/empathy-group-chat.c | 103 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 33 |
2 files changed, 63 insertions, 73 deletions
diff --git a/libempathy-gtk/empathy-group-chat.c b/libempathy-gtk/empathy-group-chat.c index 008dee81b..a775d97d5 100644 --- a/libempathy-gtk/empathy-group-chat.c +++ b/libempathy-gtk/empathy-group-chat.c @@ -102,12 +102,6 @@ static GtkWidget * group_chat_get_widget (EmpathyChat *cha static gboolean group_chat_is_group_chat (EmpathyChat *chat); static void group_chat_set_tp_chat (EmpathyChat *chat, EmpathyTpChat *tp_chat); -static void group_chat_subject_notify_cb (EmpathyTpChat *tp_chat, - GParamSpec *param, - EmpathyGroupChat *chat); -static void group_chat_name_notify_cb (EmpathyTpChat *tp_chat, - GParamSpec *param, - EmpathyGroupChat *chat); static gboolean group_chat_key_press_event (EmpathyChat *chat, GdkEventKey *event); static gint group_chat_contacts_completion_func (const gchar *s1, @@ -486,6 +480,52 @@ group_chat_is_group_chat (EmpathyChat *chat) } static void +group_chat_property_changed_cb (EmpathyTpChat *tp_chat, + gchar *name, + GValue *value, + EmpathyGroupChat *chat) +{ + EmpathyGroupChatPriv *priv; + const gchar *str = NULL; + + priv = GET_PRIV (chat); + + /* FIXME: this is ugly, should use properties on EmpathyChat obj */ + + if (!tp_strdiff (name, "name")) { + str = g_value_get_string (value); + g_free (priv->name); + priv->name = g_strdup (str); + return; + } + + if (tp_strdiff (name, "subject")) { + return; + } + + str = g_value_get_string (value); + if (!tp_strdiff (priv->topic, str)) { + return; + } + + g_free (priv->topic); + priv->topic = g_strdup (str); + gtk_label_set_text (GTK_LABEL (priv->label_topic), priv->topic); + + if (!EMPATHY_CHAT (chat)->block_events) { + gchar *string; + + if (!G_STR_EMPTY (priv->topic)) { + string = g_strdup_printf (_("Topic set to: %s"), priv->topic); + } else { + string = g_strdup (_("No topic defined")); + } + empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, string); + g_free (string); + } +} + +static void group_chat_set_tp_chat (EmpathyChat *chat, EmpathyTpChat *tp_chat) { @@ -546,56 +586,9 @@ group_chat_set_tp_chat (EmpathyChat *chat, g_signal_connect (priv->tp_chat, "members-changed", G_CALLBACK (group_chat_members_changed_cb), chat); - g_signal_connect (priv->tp_chat, "notify::subject", - G_CALLBACK (group_chat_subject_notify_cb), + g_signal_connect (priv->tp_chat, "property-changed", + G_CALLBACK (group_chat_property_changed_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, - EmpathyGroupChat *chat) -{ - EmpathyGroupChatPriv *priv; - gchar *str = NULL; - - priv = GET_PRIV (chat); - - g_object_get (priv->tp_chat, "subject", &str, NULL); - if (!tp_strdiff (priv->topic, str)) { - g_free (str); - return; - } - - g_free (priv->topic); - priv->topic = str; - gtk_label_set_text (GTK_LABEL (priv->label_topic), priv->topic); - - if (!EMPATHY_CHAT (chat)->block_events) { - if (!G_STR_EMPTY (priv->topic)) { - str = g_strdup_printf (_("Topic set to: %s"), priv->topic); - } else { - str = g_strdup (_("No topic defined")); - } - empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, str); - g_free (str); - } -} - -static void -group_chat_name_notify_cb (EmpathyTpChat *tp_chat, - GParamSpec *param, - EmpathyGroupChat *chat) -{ - EmpathyGroupChatPriv *priv; - - priv = GET_PRIV (chat); - - g_free (priv->name); - g_object_get (priv->tp_chat, "name", &priv->name, NULL); } static gboolean diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index a93e2fc2e..1579979f6 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -54,9 +54,10 @@ struct _EmpathyTpChatPriv { }; typedef struct { - gchar *name; - guint id; - GValue *value; + gchar *name; + guint id; + TpPropertyFlags flags; + GValue *value; } TpChatProperty; static void empathy_tp_chat_class_init (EmpathyTpChatClass *klass); @@ -394,10 +395,6 @@ tp_chat_properties_changed_cb (TpProxy *proxy, EmpathyTpChatPriv *priv = GET_PRIV (chat); guint i, j; - if (!priv->had_properties_list || !properties) { - return; - } - for (i = 0; i < properties->len; i++) { GValueArray *prop_struct; TpChatProperty *property; @@ -406,7 +403,7 @@ tp_chat_properties_changed_cb (TpProxy *proxy, prop_struct = g_ptr_array_index (properties, i); id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0)); - src_value = g_value_array_get_nth (prop_struct, 1); + src_value = g_value_get_boxed (g_value_array_get_nth (prop_struct, 1)); for (j = 0; j < priv->properties->len; j++) { property = g_ptr_array_index (priv->properties, j); @@ -416,6 +413,7 @@ tp_chat_properties_changed_cb (TpProxy *proxy, } else { property->value = g_slice_new0 (GValue); } + g_value_init (property->value, G_VALUE_TYPE (src_value)); g_value_copy (src_value, property->value); empathy_debug (DEBUG_DOMAIN, "property %s changed", @@ -441,7 +439,6 @@ tp_chat_get_properties_cb (TpProxy *proxy, return; } - empathy_debug (DEBUG_DOMAIN, "Got value of properties"); tp_chat_properties_changed_cb (proxy, properties, user_data, chat); } @@ -469,19 +466,19 @@ tp_chat_list_properties_cb (TpProxy *proxy, for (i = 0; i < properties->len; i++) { GValueArray *prop_struct; TpChatProperty *property; - guint id; - const gchar *name; prop_struct = g_ptr_array_index (properties, i); - id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0)); - name = g_value_get_string (g_value_array_get_nth (prop_struct, 1)); - - empathy_debug (DEBUG_DOMAIN, "Adding property %s", name); property = g_slice_new0 (TpChatProperty); - property->id = id; - property->name = g_strdup (name); + property->id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0)); + property->name = g_value_dup_string (g_value_array_get_nth (prop_struct, 1)); + property->flags = g_value_get_uint (g_value_array_get_nth (prop_struct, 3)); + + empathy_debug (DEBUG_DOMAIN, "Adding property name=%s id=%d flags=%d", + property->name, property->id, property->flags); g_ptr_array_add (priv->properties, property); - g_array_append_val (ids, id); + if (property->flags & TP_PROPERTY_FLAG_READ) { + g_array_append_val (ids, property->id); + } } tp_cli_properties_interface_call_get_properties (proxy, -1, |