diff options
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-tp-chat.c | 73 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.h | 11 |
2 files changed, 61 insertions, 23 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 09077538a..83faaff39 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -58,13 +58,6 @@ typedef struct { gboolean ready; } EmpathyTpChatPriv; -typedef struct { - gchar *name; - guint id; - TpPropertyFlags flags; - GValue *value; -} TpChatProperty; - static void tp_chat_iface_init (EmpathyContactListIface *iface); enum { @@ -493,10 +486,10 @@ tp_chat_property_flags_changed_cb (TpProxy *proxy, } for (i = 0; i < properties->len; i++) { - GValueArray *prop_struct; - TpChatProperty *property; - guint id; - guint flags; + GValueArray *prop_struct; + EmpathyTpChatProperty *property; + guint id; + guint flags; prop_struct = g_ptr_array_index (properties, i); id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0)); @@ -531,10 +524,10 @@ tp_chat_properties_changed_cb (TpProxy *proxy, } for (i = 0; i < properties->len; i++) { - GValueArray *prop_struct; - TpChatProperty *property; - guint id; - GValue *src_value; + GValueArray *prop_struct; + EmpathyTpChatProperty *property; + guint id; + GValue *src_value; prop_struct = g_ptr_array_index (properties, i); id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0)); @@ -597,11 +590,11 @@ tp_chat_list_properties_cb (TpProxy *proxy, ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), properties->len); priv->properties = g_ptr_array_sized_new (properties->len); for (i = 0; i < properties->len; i++) { - GValueArray *prop_struct; - TpChatProperty *property; + GValueArray *prop_struct; + EmpathyTpChatProperty *property; prop_struct = g_ptr_array_index (properties, i); - property = g_slice_new0 (TpChatProperty); + property = g_slice_new0 (EmpathyTpChatProperty); 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)); @@ -628,9 +621,13 @@ empathy_tp_chat_set_property (EmpathyTpChat *chat, const gchar *name, const GValue *value) { - EmpathyTpChatPriv *priv = GET_PRIV (chat); - TpChatProperty *property; - guint i; + EmpathyTpChatPriv *priv = GET_PRIV (chat); + EmpathyTpChatProperty *property; + guint i; + + if (!priv->had_properties_list) { + return; + } for (i = 0; i < priv->properties->len; i++) { property = g_ptr_array_index (priv->properties, i); @@ -672,6 +669,36 @@ empathy_tp_chat_set_property (EmpathyTpChat *chat, } } +EmpathyTpChatProperty * +empathy_tp_chat_get_property (EmpathyTpChat *chat, + const gchar *name) +{ + EmpathyTpChatPriv *priv = GET_PRIV (chat); + EmpathyTpChatProperty *property; + guint i; + + if (!priv->had_properties_list) { + return NULL; + } + + for (i = 0; i < priv->properties->len; i++) { + property = g_ptr_array_index (priv->properties, i); + if (!tp_strdiff (property->name, name)) { + return property; + } + } + + return NULL; +} + +GPtrArray * +empathy_tp_chat_get_properties (EmpathyTpChat *chat) +{ + EmpathyTpChatPriv *priv = GET_PRIV (chat); + + return priv->properties; +} + static void tp_chat_dispose (GObject *object) { @@ -727,14 +754,14 @@ tp_chat_finalize (GObject *object) if (priv->properties) { for (i = 0; i < priv->properties->len; i++) { - TpChatProperty *property; + EmpathyTpChatProperty *property; property = g_ptr_array_index (priv->properties, i); g_free (property->name); if (property->value) { tp_g_value_slice_free (property->value); } - g_slice_free (TpChatProperty, property); + g_slice_free (EmpathyTpChatProperty, property); } g_ptr_array_free (priv->properties, TRUE); } diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h index f7d2b58a1..f07f0648f 100644 --- a/libempathy/empathy-tp-chat.h +++ b/libempathy/empathy-tp-chat.h @@ -52,6 +52,13 @@ struct _EmpathyTpChatClass { GObjectClass parent_class; }; +typedef struct { + gchar *name; + guint id; + TpPropertyFlags flags; + GValue *value; +} EmpathyTpChatProperty; + GType empathy_tp_chat_get_type (void) G_GNUC_CONST; EmpathyTpChat *empathy_tp_chat_new (TpChannel *channel); void empathy_tp_chat_close (EmpathyTpChat *chat); @@ -67,6 +74,10 @@ void empathy_tp_chat_set_state (EmpathyTpChat *chat, void empathy_tp_chat_set_property (EmpathyTpChat *chat, const gchar *name, const GValue *value); +EmpathyTpChatProperty * + empathy_tp_chat_get_property (EmpathyTpChat *chat, + const gchar *name); +GPtrArray * empathy_tp_chat_get_properties (EmpathyTpChat *chat); /* Returns a read-only list of pending messages (should be a copy maybe ?) */ const GList * empathy_tp_chat_get_pending_messages (EmpathyTpChat *chat); |