[empathy] call GetAliasFlags() to determine if an alias can be set on a ContactList



commit 4afeb994e1fb9bdef315d0eaa24c3821536e30c1
Author: Davyd Madeley <davyd madeley id au>
Date:   Fri Apr 24 15:16:46 2009 +0800

    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-gtk/empathy-contact-list-view.c |    1 +
 libempathy/empathy-contact-list.h          |    2 +
 libempathy/empathy-tp-contact-list.c       |   37 +++++++++++++++++++++++++++-
 3 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index fc096b2..d187b0d 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -1508,6 +1508,7 @@ empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view)
 	}
 	flags = empathy_contact_list_view_get_flags (view);
 
+	/* FIXME: how to get the contact list flags in empathy_contact_menu_new() */
 	menu = empathy_contact_menu_new (contact, priv->contact_features);
 
 	/* Remove contact */
diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h
index 0296b64..28238e4 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 514f7a6..e81528c 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 {
@@ -509,6 +511,25 @@ tp_contact_list_publish_request_channel_cb (TpConnection *connection,
 }
 
 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,
 					   const GError *error,
@@ -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);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]