/** * e_contact_locate_match_full: * @registry: an #ESourceRegistry * @book: The book to look in. If this is NULL, use the default * addressbook. * @contact: The contact to compare to. * @avoid: A list of contacts to not match. These will not show up in the search. * @cb: The function to call. * @closure: The closure to add to the call. * * Look for the best match and return it using the EABContactMatchQueryCallback. **/ void eab_contact_locate_match_full (ESourceRegistry *registry, EBookClient *book_client, EContact *contact, GList *avoid, EABContactMatchQueryCallback cb, gpointer closure) { MatchSearchInfo *info; ESource *source; g_return_if_fail (E_IS_SOURCE_REGISTRY (registry)); g_return_if_fail (E_IS_CONTACT (contact)); g_return_if_fail (cb != NULL); info = g_new0 (MatchSearchInfo, 1); info->contact = g_object_ref (contact); info->cb = cb; info->closure = closure; info->avoid = g_list_copy (avoid); g_list_foreach (info->avoid, (GFunc) g_object_ref, NULL); if (book_client) { use_common_book_client (g_object_ref (book_client), info); return; } source = e_source_registry_ref_default_address_book (registry); e_book_client_connect (source, 30, NULL, book_client_connect_cb, info); g_object_unref (source); }
static void csv_import (EImport *ei, EImportTarget *target, EImportImporter *im) { CSVImporter *gci; ESource *source; gchar *filename; FILE *file; gint errn; EImportTargetURI *s = (EImportTargetURI *) target; GError *error = NULL; filename = g_filename_from_uri (s->uri_src, NULL, &error); if (filename == NULL) { e_import_complete (ei, target, error); g_clear_error (&error); return; } file = g_fopen (filename, "r"); errn = errno; g_free (filename); if (file == NULL) { error = g_error_new_literal (G_IO_ERROR, g_io_error_from_errno (errn), _("Can’t open .csv file")); e_import_complete (ei, target, error); g_clear_error (&error); return; } gci = g_malloc0 (sizeof (*gci)); g_datalist_set_data (&target->data, "csv-data", gci); gci->import = g_object_ref (ei); gci->target = target; gci->file = file; gci->fields_map = NULL; gci->count = 0; fseek (file, 0, SEEK_END); gci->size = ftell (file); fseek (file, 0, SEEK_SET); source = g_datalist_get_data (&target->data, "csv-source"); e_book_client_connect (source, 30, NULL, book_client_connect_cb, gci); }
static void csv_import (EImport *ei, EImportTarget *target, EImportImporter *im) { CSVImporter *gci; ESource *source; gchar *filename; FILE *file; EImportTargetURI *s = (EImportTargetURI *) target; filename = g_filename_from_uri (s->uri_src, NULL, NULL); if (filename == NULL) { g_message (G_STRLOC ": Couldn't get filename from URI '%s'", s->uri_src); return; } file = g_fopen (filename, "r"); g_free (filename); if (file == NULL) { g_message ("Can't open .csv file"); e_import_complete (ei, target); return; } gci = g_malloc0 (sizeof (*gci)); g_datalist_set_data (&target->data, "csv-data", gci); gci->import = g_object_ref (ei); gci->target = target; gci->file = file; gci->fields_map = NULL; gci->count = 0; fseek (file, 0, SEEK_END); gci->size = ftell (file); fseek (file, 0, SEEK_SET); source = g_datalist_get_data (&target->data, "csv-source"); e_book_client_connect (source, 30, NULL, book_client_connect_cb, gci); }
static void ldif_import (EImport *ei, EImportTarget *target, EImportImporter *im) { LDIFImporter *gci; ESource *source; FILE *file = NULL; EImportTargetURI *s = (EImportTargetURI *) target; gchar *filename; filename = g_filename_from_uri (s->uri_src, NULL, NULL); if (filename != NULL) { file = g_fopen (filename, "r"); g_free (filename); } if (file == NULL) { g_message (G_STRLOC ":Can't open .ldif file"); e_import_complete (ei, target); return; } gci = g_malloc0 (sizeof (*gci)); g_datalist_set_data (&target->data, "ldif-data", gci); gci->import = g_object_ref (ei); gci->target = target; gci->file = file; fseek (file, 0, SEEK_END); gci->size = ftell (file); fseek (file, 0, SEEK_SET); gci->dn_contact_hash = g_hash_table_new_full ( g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) NULL); source = g_datalist_get_data (&target->data, "ldif-source"); e_book_client_connect (source, NULL, book_client_connect_cb, gci); }