]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-contact.c
add myself to AUTHORS
[empathy.git] / libempathy / empathy-contact.c
index bad6ef470accf2c280492309e52686392224b20a..a440ef23b17b44ef2700e33e66d914148368107e 100644 (file)
 
 #include <glib/gi18n-lib.h>
 
+#include <telepathy-glib/account-manager.h>
 #include <telepathy-glib/util.h>
 
 #include "empathy-contact.h"
-#include "empathy-account-manager.h"
 #include "empathy-utils.h"
 #include "empathy-enum-types.h"
 #include "empathy-marshal.h"
@@ -39,7 +39,7 @@
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact)
 typedef struct {
   TpContact *tp_contact;
-  McAccount *account;
+  TpAccount *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,
+        TP_TYPE_ACCOUNT,
         G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (object_class,
@@ -409,13 +409,13 @@ empathy_contact_new (TpContact *tp_contact)
 }
 
 EmpathyContact *
-empathy_contact_new_for_log (McAccount *account,
+empathy_contact_new_for_log (TpAccount *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);
+  g_assert (account != NULL);
 
   return g_object_new (EMPATHY_TYPE_CONTACT,
       "account", account,
@@ -554,7 +554,7 @@ empathy_contact_set_avatar (EmpathyContact *contact,
   g_object_notify (G_OBJECT (contact), "avatar");
 }
 
-McAccount *
+TpAccount *
 empathy_contact_get_account (EmpathyContact *contact)
 {
   EmpathyContactPriv *priv;
@@ -565,15 +565,12 @@ empathy_contact_get_account (EmpathyContact *contact)
 
   if (priv->account == NULL && priv->tp_contact != NULL)
     {
-      EmpathyAccountManager *manager;
       TpConnection *connection;
 
       /* FIXME: This assume the account manager already exists */
-      manager = empathy_account_manager_dup_singleton ();
       connection = tp_contact_get_connection (priv->tp_contact);
-      priv->account = empathy_account_manager_get_account (manager, connection);
-      g_object_ref (priv->account);
-      g_object_unref (manager);
+      priv->account =
+        g_object_ref (empathy_get_account_for_connection (connection));
     }
 
   return priv->account;
@@ -802,6 +799,30 @@ empathy_contact_can_voip (EmpathyContact *contact)
       EMPATHY_CAPABILITIES_VIDEO);
 }
 
+gboolean
+empathy_contact_can_voip_audio (EmpathyContact *contact)
+{
+  EmpathyContactPriv *priv;
+
+  g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+
+  priv = GET_PRIV (contact);
+
+  return priv->capabilities & EMPATHY_CAPABILITIES_AUDIO;
+}
+
+gboolean
+empathy_contact_can_voip_video (EmpathyContact *contact)
+{
+  EmpathyContactPriv *priv;
+
+  g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+
+  priv = GET_PRIV (contact);
+
+  return priv->capabilities & EMPATHY_CAPABILITIES_VIDEO;
+}
+
 gboolean
 empathy_contact_can_send_files (EmpathyContact *contact)
 {
@@ -830,31 +851,27 @@ static gchar *
 contact_get_avatar_filename (EmpathyContact *contact,
                              const gchar *token)
 {
-  McAccount *account;
+  TpAccount *account;
   gchar *avatar_path;
   gchar *avatar_file;
   gchar *token_escaped;
-  gchar *contact_escaped;
 
   if (EMP_STR_EMPTY (empathy_contact_get_id (contact)))
     return NULL;
 
-  contact_escaped = tp_escape_as_identifier (empathy_contact_get_id (contact));
   token_escaped = tp_escape_as_identifier (token);
   account = empathy_contact_get_account (contact);
 
-  /* FIXME: Do not use the account, but proto/cm instead */
   avatar_path = g_build_filename (g_get_user_cache_dir (),
-      PACKAGE_NAME,
+      "telepathy",
       "avatars",
-      mc_account_get_unique_name (account),
-      contact_escaped,
+      tp_account_get_connection_manager (account),
+      tp_account_get_protocol (account),
       NULL);
   g_mkdir_with_parents (avatar_path, 0700);
 
   avatar_file = g_build_filename (avatar_path, token_escaped, NULL);
 
-  g_free (contact_escaped);
   g_free (token_escaped);
   g_free (avatar_path);
 
@@ -927,10 +944,15 @@ empathy_contact_load_avatar_cache (EmpathyContact *contact,
   if (data)
     {
       DEBUG ("Avatar loaded from %s", filename);
-      avatar = empathy_avatar_new (data, len, NULL, g_strdup (token), filename);
+      avatar = empathy_avatar_new ((guchar *) data, len, NULL, g_strdup (token),
+          filename);
       empathy_contact_set_avatar (contact, avatar);
       empathy_avatar_unref (avatar);
     }
+  else
+    {
+      g_free (filename);
+    }
 
   return data != NULL;
 }
@@ -1023,7 +1045,8 @@ empathy_avatar_save_to_file (EmpathyAvatar *self,
                              const gchar *filename,
                              GError **error)
 {
-  return g_file_set_contents (filename, self->data, self->len, error);
+  return g_file_set_contents (filename, (const gchar *) self->data, self->len,
+      error);
 }
 
 /**