From 4afeb994e1fb9bdef315d0eaa24c3821536e30c1 Mon Sep 17 00:00:00 2001 From: Davyd Madeley Date: Fri, 24 Apr 2009 15:16:46 +0800 Subject: call GetAliasFlags() to determine if an alias can be set on a ContactList Pending FIXMEs: - need to lookup RequestableChannelClasses to see if Groups can be requested on this connection - need to work out the best way to pass ContactListFlags to empathy_contact_menu_new() --- libempathy/empathy-contact-list.h | 2 ++ libempathy/empathy-tp-contact-list.c | 37 +++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'libempathy') diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h index 0296b6486..28238e44a 100644 --- a/libempathy/empathy-contact-list.h +++ b/libempathy/empathy-contact-list.h @@ -37,6 +37,8 @@ G_BEGIN_DECLS typedef enum { EMPATHY_CONTACT_LIST_CAN_ADD = 1 << 0, EMPATHY_CONTACT_LIST_CAN_REMOVE = 1 << 1, + EMPATHY_CONTACT_LIST_CAN_ALIAS = 1 << 2, + EMPATHY_CONTACT_LIST_CAN_GROUP = 1 << 3, } EmpathyContactListFlags; typedef struct _EmpathyContactListIface EmpathyContactListIface; diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index 514f7a6b5..e81528c80 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -50,6 +50,8 @@ typedef struct { GHashTable *pendings; /* handle -> EmpathyContact */ GHashTable *groups; /* group name -> TpChannel */ GHashTable *add_to_group; /* group name -> GArray of handles */ + + EmpathyContactListFlags flags; } EmpathyTpContactListPriv; typedef enum { @@ -508,6 +510,25 @@ tp_contact_list_publish_request_channel_cb (TpConnection *connection, list); } +static void +tp_contact_list_get_alias_flags_cb (TpConnection *connection, + guint flags, + const GError *error, + gpointer user_data, + GObject *list) +{ + EmpathyTpContactListPriv *priv = GET_PRIV (list); + + if (error) { + DEBUG ("Error: %s", error->message); + return; + } + + if (flags & TP_CONNECTION_ALIAS_FLAG_USER_SET) { + priv->flags |= EMPATHY_CONTACT_LIST_CAN_ALIAS; + } +} + static void tp_contact_list_publish_request_handle_cb (TpConnection *connection, const GArray *handles, @@ -722,6 +743,19 @@ tp_contact_list_constructed (GObject *list) priv->factory = empathy_tp_contact_factory_dup_singleton (priv->connection); + /* call GetAliasFlags() */ + if (tp_proxy_has_interface_by_id (priv->connection, + TP_IFACE_QUARK_CONNECTION_INTERFACE_ALIASING)) { + tp_cli_connection_interface_aliasing_call_get_alias_flags ( + priv->connection, + -1, + tp_contact_list_get_alias_flags_cb, + NULL, NULL, + G_OBJECT (list)); + } + + /* FIXME: lookup RequestableChannelClasses */ + names[0] = "publish"; tp_cli_connection_call_request_handles (priv->connection, -1, @@ -1078,12 +1112,13 @@ static EmpathyContactListFlags tp_contact_list_get_flags (EmpathyContactList *list) { EmpathyTpContactListPriv *priv; - EmpathyContactListFlags flags = 0; + EmpathyContactListFlags flags; TpChannelGroupFlags group_flags; g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), FALSE); priv = GET_PRIV (list); + flags = priv->flags; group_flags = tp_channel_group_get_flags (priv->subscribe); -- cgit v1.2.3