aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-06-09 03:22:39 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-06-09 03:22:39 +0800
commitdb7cecd7653d88081ea9c89ac7e68b0816961189 (patch)
treebfa907fe6da0e13001c0ec3c8617506e3e5d7e92 /libempathy
parentd8b89b20f13552d3bd1c658f3396714e24744ff6 (diff)
downloadgsoc2013-empathy-db7cecd7653d88081ea9c89ac7e68b0816961189.tar
gsoc2013-empathy-db7cecd7653d88081ea9c89ac7e68b0816961189.tar.gz
gsoc2013-empathy-db7cecd7653d88081ea9c89ac7e68b0816961189.tar.bz2
gsoc2013-empathy-db7cecd7653d88081ea9c89ac7e68b0816961189.tar.lz
gsoc2013-empathy-db7cecd7653d88081ea9c89ac7e68b0816961189.tar.xz
gsoc2013-empathy-db7cecd7653d88081ea9c89ac7e68b0816961189.tar.zst
gsoc2013-empathy-db7cecd7653d88081ea9c89ac7e68b0816961189.zip
Do not save when closing the dialog. Update information in real-time and
2007-06-08 Xavier Claessens <xclaesse@gmail.com> * libempathy-gtk/empathy-contact-dialogs.c: * libempathy-gtk/empathy-contact-widget.c: * libempathy-gtk/empathy-contact-widget.h: Do not save when closing the dialog. Update information in real-time and just provides a "Close" button. That's more GNOME spirite. * libempathy/empathy-tp-contact-list.c: * libempathy/gossip-contact.h: * libempathy/gossip-contact.c: New methods: gossip_contact_add/remove_group(). This fixes leaks when a contact is added/removed from a group. svn path=/trunk/; revision=132
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-tp-contact-list.c45
-rw-r--r--libempathy/gossip-contact.c39
-rw-r--r--libempathy/gossip-contact.h4
3 files changed, 51 insertions, 37 deletions
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index 3be79533a..97948a4f2 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -1470,24 +1470,12 @@ tp_contact_list_group_members_added_cb (GossipTelepathyGroup *group,
for (l = added_list; l; l = l->next) {
GossipContact *contact;
- GList *contact_groups;
contact = GOSSIP_CONTACT (l->data);
- contact_groups = gossip_contact_get_groups (contact);
-
- /* FIXME: this leaks */
- if (!g_list_find_custom (contact_groups,
- group_name,
- (GCompareFunc) strcmp)) {
- gossip_debug (DEBUG_DOMAIN, "Contact %s added to group '%s'",
- gossip_contact_get_name (contact),
- group_name);
- contact_groups = g_list_append (contact_groups,
- g_strdup (group_name));
- tp_contact_list_block_contact (list, contact);
- gossip_contact_set_groups (contact, contact_groups);
- tp_contact_list_unblock_contact (list, contact);
- }
+
+ tp_contact_list_block_contact (list, contact);
+ gossip_contact_add_group (contact, group_name);
+ tp_contact_list_unblock_contact (list, contact);
g_object_unref (contact);
}
@@ -1514,29 +1502,12 @@ tp_contact_list_group_members_removed_cb (GossipTelepathyGroup *group,
for (l = removed_list; l; l = l->next) {
GossipContact *contact;
- GList *contact_groups;
- GList *to_remove;
- /* FIXME: Does it leak ? */
- contact = GOSSIP_CONTACT (l->data);
- contact_groups = gossip_contact_get_groups (contact);
- contact_groups = g_list_copy (contact_groups);
-
- to_remove = g_list_find_custom (contact_groups,
- group_name,
- (GCompareFunc) strcmp);
- if (to_remove) {
- gossip_debug (DEBUG_DOMAIN, "Contact %d removed from group '%s'",
- gossip_contact_get_handle (contact),
- group_name);
- contact_groups = g_list_remove_link (contact_groups,
- to_remove);
- tp_contact_list_block_contact (list, contact);
- gossip_contact_set_groups (contact, contact_groups);
- tp_contact_list_unblock_contact (list, contact);
- }
+ contact = l->data;
- g_list_free (contact_groups);
+ tp_contact_list_block_contact (list, contact);
+ gossip_contact_remove_group (contact, group_name);
+ tp_contact_list_unblock_contact (list, contact);
g_object_unref (contact);
}
diff --git a/libempathy/gossip-contact.c b/libempathy/gossip-contact.c
index 267d86646..86b6ee6e0 100644
--- a/libempathy/gossip-contact.c
+++ b/libempathy/gossip-contact.c
@@ -592,6 +592,8 @@ gossip_contact_set_handle (GossipContact *contact,
{
GossipContactPriv *priv;
+ g_return_if_fail (GOSSIP_IS_CONTACT (contact));
+
priv = GET_PRIV (contact);
priv->handle = handle;
@@ -599,6 +601,43 @@ gossip_contact_set_handle (GossipContact *contact,
g_object_notify (G_OBJECT (contact), "handle");
}
+void
+gossip_contact_add_group (GossipContact *contact,
+ const gchar *group)
+{
+ GossipContactPriv *priv;
+
+ g_return_if_fail (GOSSIP_IS_CONTACT (contact));
+ g_return_if_fail (group != NULL);
+
+ priv = GET_PRIV (contact);
+
+ if (!g_list_find_custom (priv->groups, group, (GCompareFunc) strcmp)) {
+ priv->groups = g_list_prepend (priv->groups, g_strdup (group));
+ g_object_notify (G_OBJECT (contact), "groups");
+ }
+}
+
+void
+gossip_contact_remove_group (GossipContact *contact,
+ const gchar *group)
+{
+ GossipContactPriv *priv;
+ GList *l;
+
+ g_return_if_fail (GOSSIP_IS_CONTACT (contact));
+ g_return_if_fail (group != NULL);
+
+ priv = GET_PRIV (contact);
+
+ l = g_list_find_custom (priv->groups, group, (GCompareFunc) strcmp);
+ if (l) {
+ g_free (l->data);
+ priv->groups = g_list_delete_link (priv->groups, l);
+ g_object_notify (G_OBJECT (contact), "groups");
+ }
+}
+
gboolean
gossip_contact_is_online (GossipContact *contact)
{
diff --git a/libempathy/gossip-contact.h b/libempathy/gossip-contact.h
index 3dc9bc76d..23da37538 100644
--- a/libempathy/gossip-contact.h
+++ b/libempathy/gossip-contact.h
@@ -85,6 +85,10 @@ void gossip_contact_set_subscription (GossipContact
GossipSubscription subscription);
void gossip_contact_set_handle (GossipContact *contact,
guint handle);
+void gossip_contact_add_group (GossipContact *contact,
+ const gchar *group);
+void gossip_contact_remove_group (GossipContact *contact,
+ const gchar *group);
gboolean gossip_contact_is_online (GossipContact *contact);
gboolean gossip_contact_is_in_group (GossipContact *contact,
const gchar *group);