Esempio n. 1
0
static void
contact_constructed (GObject *object)
{
  EmpathyContact *contact = (EmpathyContact *) object;
  EmpathyContactPriv *priv = GET_PRIV (contact);
  GHashTable *location;
  TpHandle self_handle;
  TpHandle handle;

  if (priv->tp_contact == NULL)
    return;

  priv->presence = empathy_contact_get_presence (contact);

  location = tp_contact_get_location (priv->tp_contact);
  if (location != NULL)
    empathy_contact_set_location (contact, location);

  set_capabilities_from_tp_caps (contact,
      tp_contact_get_capabilities (priv->tp_contact));

  contact_set_avatar_from_tp_contact (contact);

  /* Set is-user property. Note that it could still be the handle is
   * different from the connection's self handle, in the case the handle
   * comes from a group interface. */
  self_handle = tp_connection_get_self_handle (
      tp_contact_get_connection (priv->tp_contact));
  handle = tp_contact_get_handle (priv->tp_contact);
  empathy_contact_set_is_user (contact, self_handle == handle);

  g_signal_connect (priv->tp_contact, "notify",
    G_CALLBACK (tp_contact_notify_cb), contact);
}
Esempio n. 2
0
static void
tp_contact_notify_cb (TpContact *tp_contact,
                      GParamSpec *param,
                      GObject *contact)
{
  EmpathyContactPriv *priv = GET_PRIV (contact);

  /* Forward property notifications */
  if (!tp_strdiff (param->name, "alias"))
    g_object_notify (contact, "name");
  else if (!tp_strdiff (param->name, "presence-type")) {
    TpConnectionPresenceType presence;

    presence = empathy_contact_get_presence (EMPATHY_CONTACT (contact));
    g_signal_emit (contact, signals[PRESENCE_CHANGED], 0, presence,
      priv->presence);
    priv->presence = presence;
    g_object_notify (contact, "presence");
  }
  else if (!tp_strdiff (param->name, "presence-message"))
    g_object_notify (contact, "presence-message");
  else if (!tp_strdiff (param->name, "identifier"))
    g_object_notify (contact, "id");
  else if (!tp_strdiff (param->name, "handle"))
    g_object_notify (contact, "handle");
  else if (!tp_strdiff (param->name, "location"))
    {
      GHashTable *location;

      location = tp_contact_get_location (tp_contact);
      /* This will start a geoclue search to find the address if needed */
      empathy_contact_set_location (EMPATHY_CONTACT (contact), location);
    }
}
static void
tp_contact_factory_update_location (EmpathyTpContactFactory *tp_factory,
				    guint handle,
				    GHashTable *location)
{
	EmpathyContact *contact;
	GHashTable     *new_location;

	contact = tp_contact_factory_find_by_handle (tp_factory, handle);

	if (contact == NULL)
		return;

	new_location = g_hash_table_new_full (g_str_hash, g_str_equal,
		(GDestroyNotify) g_free, (GDestroyNotify) tp_g_value_slice_free);
	tp_g_hash_table_update (new_location, location, (GBoxedCopyFunc) g_strdup,
		(GBoxedCopyFunc) tp_g_value_slice_dup);
	empathy_contact_set_location (contact, new_location);
	g_hash_table_unref (new_location);

	tp_contact_factory_geocode (contact);
}