[empathy] Expose channel group flags via EmpathyContactList iface



commit 736807e3c658aee559cb3d41413e775023d29c51
Author: Davyd Madeley <davyd madeley id au>
Date:   Fri Apr 24 14:25:27 2009 +0800

    Expose channel group flags via EmpathyContactList iface

 libempathy/empathy-contact-list.c    |   11 +++++++++++
 libempathy/empathy-contact-list.h    |   10 ++++++++++
 libempathy/empathy-tp-contact-list.c |   25 +++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c
index 1fe894e..d9493af 100644
--- a/libempathy/empathy-contact-list.c
+++ b/libempathy/empathy-contact-list.c
@@ -229,3 +229,14 @@ empathy_contact_list_remove_group (EmpathyContactList *list,
 	}
 }
 
+EmpathyContactListFlags
+empathy_contact_list_get_flags (EmpathyContactList *list)
+{
+	g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), 0);
+
+	if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_flags) {
+		return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_flags (list);
+	} else {
+		return 0;
+	}
+}
diff --git a/libempathy/empathy-contact-list.h b/libempathy/empathy-contact-list.h
index 5eabf32..0296b64 100644
--- a/libempathy/empathy-contact-list.h
+++ b/libempathy/empathy-contact-list.h
@@ -34,6 +34,11 @@ G_BEGIN_DECLS
 #define EMPATHY_IS_CONTACT_LIST(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONTACT_LIST))
 #define EMPATHY_CONTACT_LIST_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), EMPATHY_TYPE_CONTACT_LIST, EmpathyContactListIface))
 
+typedef enum {
+	EMPATHY_CONTACT_LIST_CAN_ADD		= 1 << 0,
+	EMPATHY_CONTACT_LIST_CAN_REMOVE		= 1 << 1,
+} EmpathyContactListFlags;
+
 typedef struct _EmpathyContactListIface EmpathyContactListIface;
 
 struct _EmpathyContactListIface {
@@ -64,6 +69,8 @@ struct _EmpathyContactListIface {
 					       const gchar	  *group);
 	EmpathyContactMonitor *
 			 (*get_monitor)       (EmpathyContactList *list);
+	EmpathyContactListFlags
+			 (*get_flags)         (EmpathyContactList *list);
 };
 
 GType    empathy_contact_list_get_type          (void) G_GNUC_CONST;
@@ -92,6 +99,9 @@ void	 empathy_contact_list_remove_group	(EmpathyContactList *list,
 EmpathyContactMonitor *
          empathy_contact_list_get_monitor       (EmpathyContactList *list);
 
+EmpathyContactListFlags
+         empathy_contact_list_get_flags		(EmpathyContactList *list);
+
 G_END_DECLS
 
 #endif /* __EMPATHY_CONTACT_LIST_H__ */
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index cdb0431..4ae5c88 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -1074,6 +1074,30 @@ tp_contact_list_remove_group (EmpathyContactList *list,
 	g_array_free (handles, TRUE);
 }
 
+static EmpathyContactListFlags
+tp_contact_list_get_flags (EmpathyContactList *list)
+{
+	EmpathyTpContactListPriv *priv;
+	EmpathyContactListFlags flags = 0;
+	TpChannelGroupFlags group_flags;
+
+	g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), FALSE);
+
+	priv = GET_PRIV (list);
+
+	group_flags = tp_channel_group_get_flags (priv->subscribe);
+
+	if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) {
+		flags |= EMPATHY_CONTACT_LIST_CAN_ADD;
+	}
+
+	if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_REMOVE) {
+		flags |= EMPATHY_CONTACT_LIST_CAN_REMOVE;
+	}
+
+	return flags;
+}
+
 static void
 tp_contact_list_iface_init (EmpathyContactListIface *iface)
 {
@@ -1087,6 +1111,7 @@ tp_contact_list_iface_init (EmpathyContactListIface *iface)
 	iface->remove_from_group = tp_contact_list_remove_from_group;
 	iface->rename_group      = tp_contact_list_rename_group;
 	iface->remove_group	 = tp_contact_list_remove_group;
+	iface->get_flags	 = tp_contact_list_get_flags;
 }
 
 gboolean



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