]> git.0d.be Git - empathy.git/commitdiff
Expose channel group flags via EmpathyContactList iface
authorDavyd Madeley <davyd@madeley.id.au>
Fri, 24 Apr 2009 06:25:27 +0000 (14:25 +0800)
committerDavyd Madeley <davyd@madeley.id.au>
Wed, 15 Jul 2009 10:12:15 +0000 (11:12 +0100)
libempathy/empathy-contact-list.c
libempathy/empathy-contact-list.h
libempathy/empathy-tp-contact-list.c

index 1fe894e99619bf21689489b4f05f62c3903f1688..d9493af1e8091307d7bf05fc4ef96ee06872f15a 100644 (file)
@@ -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;
+       }
+}
index 5eabf32c3c588f0001fc506cc431ced89c43b3b2..0296b648647fae60904106559cc391dcd33e3aae 100644 (file)
@@ -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))
 
 #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 {
 typedef struct _EmpathyContactListIface EmpathyContactListIface;
 
 struct _EmpathyContactListIface {
@@ -64,6 +69,8 @@ struct _EmpathyContactListIface {
                                               const gchar        *group);
        EmpathyContactMonitor *
                         (*get_monitor)       (EmpathyContactList *list);
                                               const gchar        *group);
        EmpathyContactMonitor *
                         (*get_monitor)       (EmpathyContactList *list);
+       EmpathyContactListFlags
+                        (*get_flags)         (EmpathyContactList *list);
 };
 
 GType    empathy_contact_list_get_type          (void) G_GNUC_CONST;
 };
 
 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);
 
 EmpathyContactMonitor *
          empathy_contact_list_get_monitor       (EmpathyContactList *list);
 
+EmpathyContactListFlags
+         empathy_contact_list_get_flags                (EmpathyContactList *list);
+
 G_END_DECLS
 
 #endif /* __EMPATHY_CONTACT_LIST_H__ */
 G_END_DECLS
 
 #endif /* __EMPATHY_CONTACT_LIST_H__ */
index cdb0431c4f05acf4f72a81b0b20810addd80a64e..4ae5c88c92dc039b32b95f63c996d19b7c6b0c4d 100644 (file)
@@ -1074,6 +1074,30 @@ tp_contact_list_remove_group (EmpathyContactList *list,
        g_array_free (handles, TRUE);
 }
 
        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)
 {
 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->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
 }
 
 gboolean