diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-08-15 17:07:46 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-08-16 12:07:41 +0100 |
commit | 930e744331bb058d009f150b54a791a52dd1f7d2 (patch) | |
tree | 2ff20ea8dbbfe83102d5dc72d9c634df47aa510e /src/connection-contact-info.c | |
parent | 4c46b78a768409dc56561d1556ff9cab13a2b572 (diff) | |
download | telepathy-salut-930e744331bb058d009f150b54a791a52dd1f7d2.tar.gz |
ContactInfo: implement GetContactInfo
Diffstat (limited to 'src/connection-contact-info.c')
-rw-r--r-- | src/connection-contact-info.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/connection-contact-info.c b/src/connection-contact-info.c index 3bb4f056..837aa5bd 100644 --- a/src/connection-contact-info.c +++ b/src/connection-contact-info.c @@ -242,6 +242,54 @@ salut_conn_contact_info_changed ( } static void +salut_conn_contact_info_get_contact_info ( + TpSvcConnectionInterfaceContactInfo *iface, + const GArray *contacts, + DBusGMethodInvocation *context) +{ + SalutConnection *self = SALUT_CONNECTION (iface); + TpBaseConnection *base = (TpBaseConnection *) self; + TpHandleRepoIface *contacts_repo = + tp_base_connection_get_handles (base, TP_HANDLE_TYPE_CONTACT); + SalutContactManager *contact_manager; + guint i; + GHashTable *ret; + GError *error = NULL; + + TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (TP_BASE_CONNECTION (iface), + context); + + if (!tp_handles_are_valid (contacts_repo, contacts, FALSE, &error)) + { + dbus_g_method_return_error (context, error); + g_error_free (error); + return; + } + + g_object_get (self, "contact-manager", &contact_manager, NULL); + ret = dbus_g_type_specialized_construct (TP_HASH_TYPE_CONTACT_INFO_MAP); + + for (i = 0; i < contacts->len; i++) + { + TpHandle handle = g_array_index (contacts, TpHandle, i); + SalutContact *contact = salut_contact_manager_get_contact ( + contact_manager, handle); + + if (contact != NULL) + { + g_hash_table_insert (ret, GUINT_TO_POINTER (handle), + build_contact_info_for_contact (contact)); + g_object_unref (contact); + } + } + + tp_svc_connection_interface_contact_info_return_from_get_contact_info ( + context, ret); + g_boxed_free (TP_HASH_TYPE_CONTACT_INFO_MAP, ret); + g_object_unref (contact_manager); +} + +static void salut_conn_contact_info_refresh_contact_info ( TpSvcConnectionInterfaceContactInfo *iface, const GArray *contacts, @@ -260,6 +308,7 @@ salut_conn_contact_info_iface_init ( #define IMPLEMENT(x) tp_svc_connection_interface_contact_info_implement_##x \ (klass, salut_conn_contact_info_##x) + IMPLEMENT (get_contact_info); IMPLEMENT (refresh_contact_info); #undef IMPLEMENT } |