Exemplo n.º 1
0
FolksIndividual *
empathy_create_individual_from_tp_contact (TpContact *contact)
{
  GeeSet *personas;
  TpfPersona *persona;
  FolksIndividual *individual;

  persona = tpf_persona_dup_for_contact (contact);
  if (persona == NULL)
    {
      DEBUG ("Failed to get a persona for %s",
          tp_contact_get_identifier (contact));
      return NULL;
    }

  personas = GEE_SET (
      gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref,
      g_direct_hash, g_direct_equal));

  gee_collection_add (GEE_COLLECTION (personas), persona);

  individual = folks_individual_new (personas);

  g_clear_object (&persona);
  g_clear_object (&personas);

  return individual;
}
Exemplo n.º 2
0
static FolksIndividual *
create_individual_from_persona (FolksPersona *persona)
{
  GeeSet *personas;
  FolksIndividual *individual;

  personas = GEE_SET (
      gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref,
      NULL, NULL, NULL, NULL, NULL, NULL));

  gee_collection_add (GEE_COLLECTION (personas), persona);

  individual = folks_individual_new (personas);

  g_clear_object (&personas);

  return individual;
}
Exemplo n.º 3
0
static void
link_individual (EmpathyIndividualLinker *self,
    FolksIndividual *individual)
{
  EmpathyIndividualLinkerPriv *priv = GET_PRIV (self);
  GeeSet *old_personas, *new_personas;
  GeeHashSet *final_personas;
  gboolean personas_changed;

  /* Add the individual to the link */
  g_hash_table_insert (priv->changed_individuals, individual,
      GUINT_TO_POINTER (TRUE));

  /* Add personas which are in @individual to priv->new_individual, adding them
   * to the set of personas. */
  old_personas = folks_individual_get_personas (individual);
  new_personas = folks_individual_get_personas (priv->new_individual);
  final_personas = gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref,
      g_object_unref, g_direct_hash, g_direct_equal);
  gee_collection_add_all (GEE_COLLECTION (final_personas),
      GEE_COLLECTION (old_personas));
  personas_changed = gee_collection_add_all (GEE_COLLECTION (final_personas),
      GEE_COLLECTION (new_personas));

  /* avoid updating all values in the Individual if the set of personas doesn't
   * actually change */
  if (personas_changed)
    {
      folks_individual_set_personas (priv->new_individual,
          GEE_SET (final_personas));
    }

  g_clear_object (&final_personas);

  /* Update the toggle renderers, so that if this Individual is listed in
   * another group in the EmpathyIndividualView, the toggle button for that
   * group is updated. */
  update_toggle_renderers (self);

  g_object_notify (G_OBJECT (self), "has-changed");
}
Exemplo n.º 4
0
static void
unlink_individual (EmpathyIndividualLinker *self,
    FolksIndividual *individual)
{
  EmpathyIndividualLinkerPriv *priv = GET_PRIV (self);
  GeeSet *removed_personas, *old_personas;
  GeeHashSet *final_personas;
  gboolean personas_changed;

  /* Remove the individual from the link */
  g_hash_table_remove (priv->changed_individuals, individual);

  /* Remove personas which are in @individual from priv->new_individual. */
  old_personas = folks_individual_get_personas (priv->new_individual);
  removed_personas = folks_individual_get_personas (individual);

  final_personas = gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref,
      g_object_unref, g_direct_hash, g_direct_equal);
  gee_collection_add_all (GEE_COLLECTION (final_personas),
      GEE_COLLECTION (old_personas));
  personas_changed = gee_collection_remove_all (GEE_COLLECTION (final_personas),
      GEE_COLLECTION (removed_personas));

  if (personas_changed)
    {
      folks_individual_set_personas (priv->new_individual,
          GEE_SET (final_personas));
    }

  g_clear_object (&final_personas);

  /* Update the toggle renderers, so that if this Individual is listed in
   * another group in the EmpathyIndividualView, the toggle button for that
   * group is updated. */
  update_toggle_renderers (self);

  g_object_notify (G_OBJECT (self), "has-changed");
}