aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorDavyd Madeley <davyd@madeley.id.au>2009-07-14 18:47:47 +0800
committerDavyd Madeley <davyd@madeley.id.au>2009-07-15 18:12:16 +0800
commitce74b001af76af82c3bc448784ce7826b99d378f (patch)
tree96217803c58fd27e1e1be1c27d34d23312818ecd /libempathy-gtk
parent81f7d9001ac4da0f72b81d1c3d4861a011e62a1d (diff)
downloadgsoc2013-empathy-ce74b001af76af82c3bc448784ce7826b99d378f.tar
gsoc2013-empathy-ce74b001af76af82c3bc448784ce7826b99d378f.tar.gz
gsoc2013-empathy-ce74b001af76af82c3bc448784ce7826b99d378f.tar.bz2
gsoc2013-empathy-ce74b001af76af82c3bc448784ce7826b99d378f.tar.lz
gsoc2013-empathy-ce74b001af76af82c3bc448784ce7826b99d378f.tar.xz
gsoc2013-empathy-ce74b001af76af82c3bc448784ce7826b99d378f.tar.zst
gsoc2013-empathy-ce74b001af76af82c3bc448784ce7826b99d378f.zip
Check CAN_ADD before returning an Add Contact... menu item
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-contact-menu.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index 3c4eb0bbf..b4d694b6a 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -146,12 +146,27 @@ empathy_contact_add_menu_item_new (EmpathyContact *contact)
GtkWidget *item;
GtkWidget *image;
EmpathyContactManager *manager;
+ TpConnection *connection;
GList *l, *members;
gboolean found = FALSE;
+ EmpathyContactListFlags flags;
g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ if (!empathy_contact_manager_initialized ()) {
+ return NULL;
+ }
+
manager = empathy_contact_manager_dup_singleton ();
+ connection = empathy_contact_get_connection (contact);
+
+ flags = empathy_contact_manager_get_flags_for_connection (manager,
+ connection);
+
+ if (!(flags & EMPATHY_CONTACT_LIST_CAN_ADD)) {
+ return NULL;
+ }
+
members = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (manager));
for (l = members; l; l = l->next) {
if (!found && empathy_contact_equal (l->data, contact)) {
@@ -163,6 +178,7 @@ empathy_contact_add_menu_item_new (EmpathyContact *contact)
g_object_unref (l->data);
}
g_list_free (members);
+ g_object_unref (manager);
if (found) {
return NULL;