]> git.0d.be Git - empathy.git/commitdiff
Introduce empathy_contact_equal, adapt themes
authorPatryk Zawadzki <patrys@pld-linux.org>
Tue, 16 Jun 2009 13:37:08 +0000 (15:37 +0200)
committerPatryk Zawadzki <patrys@pld-linux.org>
Tue, 16 Jun 2009 13:37:08 +0000 (15:37 +0200)
Fixed adium and boxes theme engines to check if contacts refer to
the same id instead of comparing pointers. This fixes bug #585885.

libempathy-gtk/empathy-theme-adium.c
libempathy-gtk/empathy-theme-boxes.c
libempathy/empathy-contact.c
libempathy/empathy-contact.h

index 82384acd1760aed85921a88558febffac2f51489..321d1998cf7285ff57aa6492e7c804719396002c 100644 (file)
@@ -500,7 +500,8 @@ theme_adium_append_message (EmpathyChatView *view,
        }
 
        /* Get the right html/func to add the message */
-       if (priv->last_contact == sender) {
+       func = "appendMessage";
+       if (empathy_contact_equal (priv->last_contact, sender)) {
                func = "appendNextMessage";
                if (empathy_contact_is_user (sender)) {
                        html = priv->out_nextcontent_html;
@@ -512,7 +513,6 @@ theme_adium_append_message (EmpathyChatView *view,
                }
        }
        if (!html) {
-               func = "appendMessage";
                if (empathy_contact_is_user (sender)) {
                        html = priv->out_content_html;
                        len = priv->out_content_len;
index 19913295697d95a12938e36ea045f281bead338d..64d95d4f2db1ec17a3b05bd8d006d336cc3fd850 100644 (file)
@@ -210,7 +210,7 @@ theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme,
        /* Only insert a header if the previously inserted block is not the same
         * as this one.
         */
-       if (last_contact == contact) {
+       if (empathy_contact_equal (last_contact, contact)) {
                return;
        }
 
index 8e07fb9f6f313d44ea895e376ce378905c9a186a..bad6ef470accf2c280492309e52686392224b20a 100644 (file)
@@ -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;
+}
index f4418768e8aad4a80f8e06e6d691841dccbc1261..f88831342ca1fa4daf84e93ec72034a40fd6a7c5 100644 (file)
@@ -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