static gboolean mail_account_in_recipients (ESourceRegistry *registry, ESource *source, GHashTable *recipients) { ESourceExtension *extension; const gchar *extension_name; const gchar *uid; gboolean match = FALSE; gchar *address; /* Disregard disabled mail accounts. */ if (!e_source_registry_check_enabled (registry, source)) return FALSE; extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT; extension = e_source_get_extension (source, extension_name); uid = e_source_mail_account_get_identity_uid ( E_SOURCE_MAIL_ACCOUNT (extension)); if (uid == NULL) return FALSE; source = e_source_registry_ref_source (registry, uid); if (source == NULL) return FALSE; extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY; if (!e_source_has_extension (source, extension_name)) { g_object_unref (source); return FALSE; } extension = e_source_get_extension (source, extension_name); address = e_source_mail_identity_dup_address ( E_SOURCE_MAIL_IDENTITY (extension)); g_object_unref (source); if (address != NULL) { match = g_hash_table_contains (recipients, address); g_free (address); } return match; }
static void yahoo_backend_config_calendar_child (ECollectionBackend *backend, ESource *source) { EYahooBackend *yahoo_backend; ESource *collection_source; ESource *mail_identity_source; ESourceExtension *extension; ESourceCollection *collection_extension; const gchar *extension_name; const gchar *identity; gchar *display_name = NULL; /* FIXME As a future enhancement, we should query Yahoo! * for a list of user calendars and add them to the * collection with matching display names and colors. */ yahoo_backend = E_YAHOO_BACKEND (backend); collection_source = e_backend_get_source (E_BACKEND (backend)); collection_extension = e_source_get_extension ( collection_source, E_SOURCE_EXTENSION_COLLECTION); identity = e_source_collection_get_identity (collection_extension); /* XXX Assume the calendar's display name can be derived from * the user's mail identity. As mentioned above, we should * really just query Yahoo! for a list of user calendars. */ mail_identity_source = g_weak_ref_get (&yahoo_backend->mail_identity_source); if (mail_identity_source != NULL) { extension = e_source_get_extension ( mail_identity_source, E_SOURCE_EXTENSION_MAIL_IDENTITY); display_name = e_source_mail_identity_dup_name ( E_SOURCE_MAIL_IDENTITY (extension)); if (display_name != NULL) g_strdelimit (display_name, " ", '_'); g_object_unref (mail_identity_source); } extension_name = E_SOURCE_EXTENSION_AUTHENTICATION; extension = e_source_get_extension (source, extension_name); e_source_authentication_set_host ( E_SOURCE_AUTHENTICATION (extension), YAHOO_CALENDAR_HOST); e_binding_bind_property ( collection_extension, "identity", extension, "user", G_BINDING_SYNC_CREATE); extension_name = E_SOURCE_EXTENSION_SECURITY; extension = e_source_get_extension (source, extension_name); e_source_security_set_secure ( E_SOURCE_SECURITY (extension), TRUE); extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND; extension = e_source_get_extension (source, extension_name); e_source_webdav_set_display_name ( E_SOURCE_WEBDAV (extension), display_name); if (identity != NULL && display_name != NULL) { gchar *resource_path; resource_path = g_strdup_printf ( YAHOO_CALENDAR_CALDAV_PATH, identity, display_name); e_source_webdav_set_resource_path ( E_SOURCE_WEBDAV (extension), resource_path); g_free (resource_path); } g_free (display_name); }