diff options
author | Travis Reitter <treitter@gmail.com> | 2010-06-22 23:43:18 +0800 |
---|---|---|
committer | Travis Reitter <treitter@gmail.com> | 2010-07-21 07:12:35 +0800 |
commit | ae79986102a22b65a3f9f4eb2328971272eec204 (patch) | |
tree | 7a119f5fb1b9546b7f7e6ac21798893581feaf68 /libempathy | |
parent | 315a71325f98d86722d7c313d726828f767cef82 (diff) | |
download | gsoc2013-empathy-ae79986102a22b65a3f9f4eb2328971272eec204.tar gsoc2013-empathy-ae79986102a22b65a3f9f4eb2328971272eec204.tar.gz gsoc2013-empathy-ae79986102a22b65a3f9f4eb2328971272eec204.tar.bz2 gsoc2013-empathy-ae79986102a22b65a3f9f4eb2328971272eec204.tar.lz gsoc2013-empathy-ae79986102a22b65a3f9f4eb2328971272eec204.tar.xz gsoc2013-empathy-ae79986102a22b65a3f9f4eb2328971272eec204.tar.zst gsoc2013-empathy-ae79986102a22b65a3f9f4eb2328971272eec204.zip |
Support contact adding
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-individual-manager.c | 50 | ||||
-rw-r--r-- | libempathy/empathy-individual-manager.h | 4 |
2 files changed, 54 insertions, 0 deletions
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c index 95955d642..fe8ccadf9 100644 --- a/libempathy/empathy-individual-manager.c +++ b/libempathy/empathy-individual-manager.c @@ -260,6 +260,56 @@ empathy_individual_manager_lookup_member (EmpathyIndividualManager *self, return NULL; } +static void +aggregator_add_persona_from_details_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + EmpathyIndividualManager *self = EMPATHY_INDIVIDUAL_MANAGER (user_data); + EmpathyIndividualManagerPriv *priv = GET_PRIV (self); + FolksPersona *persona; + GError *error = NULL; + + persona = folks_individual_aggregator_add_persona_from_details_finish ( + priv->aggregator, result, &error); + if (error != NULL) + { + g_warning ("failed to add individual from contact: %s", error->message); + g_clear_error (&error); + } +} + +void +empathy_individual_manager_add_from_contact (EmpathyIndividualManager *self, + EmpathyContact *contact) +{ + EmpathyIndividualManagerPriv *priv; + GHashTable* details; + TpAccount *account; + const gchar *store_id; + + g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self)); + g_return_if_fail (EMPATHY_IS_CONTACT (contact)); + + priv = GET_PRIV (self); + + DEBUG (G_STRLOC ": adding individual from contact %s (%s)", + empathy_contact_get_id (contact), empathy_contact_get_name (contact)); + + account = empathy_contact_get_account (contact); + store_id = tp_proxy_get_object_path (TP_PROXY (account)); + + details = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (details, "contact", + (gchar*) empathy_contact_get_id (contact)); + + folks_individual_aggregator_add_persona_from_details ( + priv->aggregator, NULL, "telepathy", store_id, details, + aggregator_add_persona_from_details_cb, self); + + g_hash_table_destroy (details); +} + void empathy_individual_manager_remove (EmpathyIndividualManager *self, FolksIndividual *individual, diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h index 030ea815f..2fab1ffb0 100644 --- a/libempathy/empathy-individual-manager.h +++ b/libempathy/empathy-individual-manager.h @@ -71,6 +71,10 @@ FolksIndividual *empathy_individual_manager_lookup_member ( EmpathyIndividualManager *manager, const gchar *id); +void empathy_individual_manager_add_from_contact ( + EmpathyIndividualManager *manager, + EmpathyContact *contact); + void empathy_individual_manager_remove (EmpathyIndividualManager *manager, FolksIndividual *individual, const gchar *message); |