~bcurtiswx/ubuntu/precise/empathy/3.4.2.1-0ubuntu1

« back to all changes in this revision

Viewing changes to libempathy/empathy-contact.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2009-11-16 23:40:52 UTC
  • mfrom: (1.1.39 upstream)
  • mto: (6.3.7 experimental)
  • mto: This revision was merged to the branch mainline in revision 80.
  • Revision ID: james.westby@ubuntu.com-20091116234052-7hhwrpeln4mwdyw7
Tags: upstream-2.29.2
ImportĀ upstreamĀ versionĀ 2.29.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#include <glib/gi18n-lib.h>
27
27
 
 
28
#include <telepathy-glib/account-manager.h>
28
29
#include <telepathy-glib/util.h>
29
30
 
30
31
#include "empathy-contact.h"
31
 
#include "empathy-account-manager.h"
32
32
#include "empathy-utils.h"
33
33
#include "empathy-enum-types.h"
34
34
#include "empathy-marshal.h"
39
39
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact)
40
40
typedef struct {
41
41
  TpContact *tp_contact;
42
 
  EmpathyAccount *account;
 
42
  TpAccount *account;
43
43
  gchar *id;
44
44
  gchar *name;
45
45
  EmpathyAvatar *avatar;
159
159
      g_param_spec_object ("account",
160
160
        "The account",
161
161
        "The account associated with the contact",
162
 
        EMPATHY_TYPE_ACCOUNT,
 
162
        TP_TYPE_ACCOUNT,
163
163
        G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
164
164
 
165
165
  g_object_class_install_property (object_class,
409
409
}
410
410
 
411
411
EmpathyContact *
412
 
empathy_contact_new_for_log (EmpathyAccount *account,
 
412
empathy_contact_new_for_log (TpAccount *account,
413
413
                             const gchar *id,
414
414
                             const gchar *name,
415
415
                             gboolean is_user)
416
416
{
417
417
  g_return_val_if_fail (id != NULL, NULL);
 
418
  g_assert (account != NULL);
418
419
 
419
420
  return g_object_new (EMPATHY_TYPE_CONTACT,
420
421
      "account", account,
553
554
  g_object_notify (G_OBJECT (contact), "avatar");
554
555
}
555
556
 
556
 
EmpathyAccount *
 
557
TpAccount *
557
558
empathy_contact_get_account (EmpathyContact *contact)
558
559
{
559
560
  EmpathyContactPriv *priv;
564
565
 
565
566
  if (priv->account == NULL && priv->tp_contact != NULL)
566
567
    {
567
 
      EmpathyAccountManager *manager;
568
568
      TpConnection *connection;
569
569
 
570
570
      /* FIXME: This assume the account manager already exists */
571
 
      manager = empathy_account_manager_dup_singleton ();
572
571
      connection = tp_contact_get_connection (priv->tp_contact);
573
 
      priv->account = empathy_account_manager_get_account_for_connection (
574
 
          manager, connection);
575
 
      g_object_ref (priv->account);
576
 
      g_object_unref (manager);
 
572
      priv->account =
 
573
        g_object_ref (empathy_get_account_for_connection (connection));
577
574
    }
578
575
 
579
576
  return priv->account;
854
851
contact_get_avatar_filename (EmpathyContact *contact,
855
852
                             const gchar *token)
856
853
{
857
 
  EmpathyAccount *account;
 
854
  TpAccount *account;
858
855
  gchar *avatar_path;
859
856
  gchar *avatar_file;
860
857
  gchar *token_escaped;
868
865
  avatar_path = g_build_filename (g_get_user_cache_dir (),
869
866
      "telepathy",
870
867
      "avatars",
871
 
      empathy_account_get_connection_manager (account),
872
 
      empathy_account_get_protocol (account),
 
868
      tp_account_get_connection_manager (account),
 
869
      tp_account_get_protocol (account),
873
870
      NULL);
874
871
  g_mkdir_with_parents (avatar_path, 0700);
875
872
 
947
944
  if (data)
948
945
    {
949
946
      DEBUG ("Avatar loaded from %s", filename);
950
 
      avatar = empathy_avatar_new (data, len, NULL, g_strdup (token), filename);
 
947
      avatar = empathy_avatar_new ((guchar *) data, len, NULL, g_strdup (token),
 
948
          filename);
951
949
      empathy_contact_set_avatar (contact, avatar);
952
950
      empathy_avatar_unref (avatar);
953
951
    }
 
952
  else
 
953
    {
 
954
      g_free (filename);
 
955
    }
954
956
 
955
957
  return data != NULL;
956
958
}
1043
1045
                             const gchar *filename,
1044
1046
                             GError **error)
1045
1047
{
1046
 
  return g_file_set_contents (filename, self->data, self->len, error);
 
1048
  return g_file_set_contents (filename, (const gchar *) self->data, self->len,
 
1049
      error);
1047
1050
}
1048
1051
 
1049
1052
/**