]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-contact.c
Chat window's tab label changes the font color when got an incoming msg. (Fixes ...
[empathy.git] / libempathy / empathy-contact.c
index 8e07fb9f6f313d44ea895e376ce378905c9a186a..d351aecbc53e9d2b5a619b79a0c06fb6a38592ce 100644 (file)
@@ -39,7 +39,7 @@
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact)
 typedef struct {
   TpContact *tp_contact;
-  McAccount *account;
+  EmpathyAccount *account;
   gchar *id;
   gchar *name;
   EmpathyAvatar *avatar;
@@ -159,7 +159,7 @@ empathy_contact_class_init (EmpathyContactClass *class)
       g_param_spec_object ("account",
         "The account",
         "The account associated with the contact",
-        MC_TYPE_ACCOUNT,
+        EMPATHY_TYPE_ACCOUNT,
         G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (object_class,
@@ -409,12 +409,11 @@ empathy_contact_new (TpContact *tp_contact)
 }
 
 EmpathyContact *
-empathy_contact_new_for_log (McAccount *account,
+empathy_contact_new_for_log (EmpathyAccount *account,
                              const gchar *id,
                              const gchar *name,
                              gboolean is_user)
 {
-  g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
   g_return_val_if_fail (id != NULL, NULL);
 
   return g_object_new (EMPATHY_TYPE_CONTACT,
@@ -554,7 +553,7 @@ empathy_contact_set_avatar (EmpathyContact *contact,
   g_object_notify (G_OBJECT (contact), "avatar");
 }
 
-McAccount *
+EmpathyAccount *
 empathy_contact_get_account (EmpathyContact *contact)
 {
   EmpathyContactPriv *priv;
@@ -830,7 +829,7 @@ static gchar *
 contact_get_avatar_filename (EmpathyContact *contact,
                              const gchar *token)
 {
-  McAccount *account;
+  EmpathyAccount *account;
   gchar *avatar_path;
   gchar *avatar_file;
   gchar *token_escaped;
@@ -847,7 +846,7 @@ contact_get_avatar_filename (EmpathyContact *contact,
   avatar_path = g_build_filename (g_get_user_cache_dir (),
       PACKAGE_NAME,
       "avatars",
-      mc_account_get_unique_name (account),
+      empathy_account_get_unique_name (account),
       contact_escaped,
       NULL);
   g_mkdir_with_parents (avatar_path, 0700);
@@ -1082,3 +1081,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;
+}