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

« back to all changes in this revision

Viewing changes to libempathy/empathy-contact.c

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2011-12-21 15:12:56 UTC
  • mfrom: (1.1.84)
  • Revision ID: package-import@ubuntu.com-20111221151256-9b1pny75wphfmqd6
Tags: 3.3.3-0ubuntu1
* New upstream version
  - Require folks >= 0.6.6 (LP: #907501)
* debian/control
  - bump build depends for folks to >= 0.6.6
* debian/watch
  - use the .xz file

Show diffs side-by-side

added added

removed removed

Lines of Context:
694
694
         !tp_strdiff (tp_proxy_get_object_path (data->account), path);
695
695
}
696
696
 
 
697
static void
 
698
get_contacts_cb (TpConnection *connection,
 
699
    guint n_contacts,
 
700
    TpContact * const *contacts,
 
701
    const gchar * const *requested_ids,
 
702
    GHashTable *failed_id_errors,
 
703
    const GError *error,
 
704
    gpointer user_data,
 
705
    GObject *weak_object)
 
706
{
 
707
  EmpathyContact *self = (EmpathyContact *) weak_object;
 
708
  EmpathyContactPriv *priv = GET_PRIV (self);
 
709
  TpContact *tp_contact;
 
710
 
 
711
  if (n_contacts != 1)
 
712
    return;
 
713
 
 
714
  tp_contact = contacts[0];
 
715
 
 
716
  g_return_if_fail (priv->tp_contact == NULL);
 
717
  priv->tp_contact = g_object_ref (tp_contact);
 
718
  g_object_notify (G_OBJECT (self), "tp-contact");
 
719
 
 
720
  /* Update capabilities now that we have a TpContact */
 
721
  set_capabilities_from_tp_caps (self,
 
722
      tp_contact_get_capabilities (tp_contact));
 
723
}
 
724
 
697
725
EmpathyContact *
698
726
empathy_contact_from_tpl_contact (TpAccount *account,
699
727
    TplEntity *tpl_entity)
724
752
    }
725
753
  else
726
754
    {
 
755
      TpConnection *conn;
 
756
      const gchar *id;
 
757
 
727
758
      is_user = (TPL_ENTITY_SELF == tpl_entity_get_entity_type (tpl_entity));
728
759
 
 
760
      id = tpl_entity_get_identifier (tpl_entity);
 
761
 
729
762
      retval = g_object_new (EMPATHY_TYPE_CONTACT,
730
 
          "id", tpl_entity_get_identifier (tpl_entity),
 
763
          "id", id,
731
764
          "alias", tpl_entity_get_alias (tpl_entity),
732
765
          "account", account,
733
766
          "is-user", is_user,
734
767
          NULL);
 
768
 
 
769
      /* Try to get a TpContact associated to have at least contact
 
770
       * capabilities if possible. This is useful for CM supporting calling
 
771
       * offline contacts for example. */
 
772
      conn = tp_account_get_connection (account);
 
773
      if (conn != NULL)
 
774
        {
 
775
          TpContactFeature features[] = { TP_CONTACT_FEATURE_CAPABILITIES };
 
776
          conn = tp_account_get_connection (account);
 
777
 
 
778
          tp_connection_get_contacts_by_id (conn, 1, &id,
 
779
              G_N_ELEMENTS (features), features, get_contacts_cb,
 
780
              NULL, NULL, G_OBJECT (retval));
 
781
        }
735
782
    }
736
783
 
737
784
  if (!EMP_STR_EMPTY (tpl_entity_get_avatar_token (tpl_entity)))
956
1003
 
957
1004
  if (priv->persona == NULL && priv->tp_contact != NULL)
958
1005
    {
959
 
      /* FIXME: This is disgustingly slow */
960
 
      /* Query for the persona */
961
 
      EmpathyIndividualManager *manager;
962
 
      GList *individuals, *l;
963
 
 
964
 
      manager = empathy_individual_manager_dup_singleton ();
965
 
      individuals = empathy_individual_manager_get_members (manager);
966
 
 
967
 
      for (l = individuals; l != NULL; l = l->next)
 
1006
      TpfPersona *persona;
 
1007
 
 
1008
      persona = tpf_persona_dup_for_contact (priv->tp_contact);
 
1009
      if (persona != NULL)
968
1010
        {
969
 
          FolksIndividual *individual = FOLKS_INDIVIDUAL (l->data);
970
 
          GeeSet *personas;
971
 
          GeeIterator *iter;
972
 
          gboolean persona_found = FALSE;
973
 
 
974
 
          personas = folks_individual_get_personas (individual);
975
 
          iter = gee_iterable_iterator (GEE_ITERABLE (personas));
976
 
          while (!persona_found && gee_iterator_next (iter))
977
 
            {
978
 
              TpfPersona *persona = gee_iterator_get (iter);
979
 
 
980
 
              if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (persona)))
981
 
                {
982
 
                  TpContact *tp_contact = tpf_persona_get_contact (persona);
983
 
 
984
 
                  if (tp_contact == priv->tp_contact)
985
 
                    {
986
 
                      /* Found the right persona */
987
 
                      empathy_contact_set_persona (contact,
988
 
                          (FolksPersona *) persona);
989
 
                      persona_found = TRUE;
990
 
                    }
991
 
                  g_clear_object (&persona);
992
 
                }
993
 
            }
994
 
          g_clear_object (&iter);
 
1011
          empathy_contact_set_persona (contact, (FolksPersona *) persona);
 
1012
          g_object_unref (persona);
995
1013
        }
996
 
 
997
 
      g_list_free (individuals);
998
 
      g_object_unref (manager);
999
1014
    }
1000
1015
 
1001
1016
  return priv->persona;