aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorPatryk Zawadzki <patrys@pld-linux.org>2009-06-16 21:37:08 +0800
committerPatryk Zawadzki <patrys@pld-linux.org>2009-06-16 21:37:08 +0800
commit40d33622db46952e016cc8e540403cccb7ba6103 (patch)
treef26977dd5915f8df13e60faa61b943890bb6575f /libempathy
parentcea163a21118f4f06aa6c37fa4463f9666a63019 (diff)
downloadgsoc2013-empathy-40d33622db46952e016cc8e540403cccb7ba6103.tar
gsoc2013-empathy-40d33622db46952e016cc8e540403cccb7ba6103.tar.gz
gsoc2013-empathy-40d33622db46952e016cc8e540403cccb7ba6103.tar.bz2
gsoc2013-empathy-40d33622db46952e016cc8e540403cccb7ba6103.tar.lz
gsoc2013-empathy-40d33622db46952e016cc8e540403cccb7ba6103.tar.xz
gsoc2013-empathy-40d33622db46952e016cc8e540403cccb7ba6103.tar.zst
gsoc2013-empathy-40d33622db46952e016cc8e540403cccb7ba6103.zip
Introduce empathy_contact_equal, adapt themes
Fixed adium and boxes theme engines to check if contacts refer to the same id instead of comparing pointers. This fixes bug #585885.
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-contact.c37
-rw-r--r--libempathy/empathy-contact.h4
2 files changed, 40 insertions, 1 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 8e07fb9f6..bad6ef470 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -1082,3 +1082,40 @@ empathy_contact_set_location (EmpathyContact *contact,
priv->location = g_hash_table_ref (location);
g_object_notify (G_OBJECT (contact), "location");
}
+
+/**
+ * empathy_contact_equal:
+ * @contact1: an #EmpathyContact
+ * @contact2: an #EmpathyContact
+ *
+ * Returns FALSE if one of the contacts is NULL but the other is not.
+ * Otherwise returns TRUE if both pointer are equal or if they bith
+ * refer to the same id.
+ * It's only necessary to call this function if your contact objects
+ * come from logs where contacts are created dynamically and comparing
+ * pointers is not enough.
+ */
+gboolean
+empathy_contact_equal (gconstpointer contact1,
+ gconstpointer contact2)
+{
+ EmpathyContact *c1;
+ EmpathyContact *c2;
+ const gchar *id1;
+ const gchar *id2;
+
+ if ((contact1 == NULL) != (contact2 == NULL)) {
+ return FALSE;
+ }
+ if (contact1 == contact2) {
+ return TRUE;
+ }
+ c1 = EMPATHY_CONTACT (contact1);
+ c2 = EMPATHY_CONTACT (contact2);
+ id1 = empathy_contact_get_id (c1);
+ id2 = empathy_contact_get_id (c2);
+ if (!tp_strdiff (id1, id2)) {
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index f4418768e..f88831342 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -125,7 +125,9 @@ gboolean empathy_avatar_save_to_file (EmpathyAvatar *avatar,
GHashTable * empathy_contact_get_location (EmpathyContact *contact);
void empathy_contact_set_location (EmpathyContact *contact,
- GHashTable *location);
+ GHashTable *location);
+gboolean empathy_contact_equal (gconstpointer contact1,
+ gconstpointer contact2);
G_END_DECLS