libebook-test-utils.la \
$(NULL)
-DEPRECATED_TESTS = \
- test-changes \
- test-ebook \
- test-ebook-async \
- test-nonexistent-id \
- test-search \
- test-self \
- test-stress-bookviews \
- test-bulk-methods
-
### EBookClient Tests ###
# Should be kept ordered approximately from least to most difficult/complex
test-ebook-remove-contacts \
test-ebook-get-book-view
-# test-ebook-stress-factory--serial \
-# test-ebook-stress-factory--fifo \
-# test-ebook-stress-factory--single-book
-
noinst_PROGRAMS = \
$(TESTS) \
- $(DEPRECATED_TESTS) \
$(NULL)
EXTRA_DIST = \
$(srcdir)/data/vcards/simple-2.vcf \
$(NULL)
-test_bulk_methods_LDADD=$(TEST_LIBS)
-test_bulk_methods_CPPFLAGS=$(TEST_CPPFLAGS)
-test_search_LDADD=$(TEST_LIBS)
-test_search_CPPFLAGS=$(TEST_CPPFLAGS)
-test_ebook_LDADD=$(TEST_LIBS)
-test_ebook_CPPFLAGS=$(TEST_CPPFLAGS)
-test_ebook_async_LDADD=$(TEST_LIBS)
-test_ebook_async_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_commit_contact_LDADD=$(TEST_LIBS)
test_ebook_commit_contact_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_get_book_view_LDADD=$(TEST_LIBS)
test_ebook_remove_contact_by_id_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_remove_contacts_LDADD=$(TEST_LIBS)
test_ebook_remove_contacts_CPPFLAGS=$(TEST_CPPFLAGS)
-#test_ebook_stress_factory__fifo_LDADD=$(TEST_LIBS)
-test_ebook_stress_factory__fifo_CPPFLAGS=$(TEST_CPPFLAGS)
-#test_ebook_stress_factory__serial_LDADD=$(TEST_LIBS)
-test_ebook_stress_factory__serial_CPPFLAGS=$(TEST_CPPFLAGS)
-#test_ebook_stress_factory__single_book_LDADD=$(TEST_LIBS)
-test_ebook_stress_factory__single_book_CPPFLAGS=$(TEST_CPPFLAGS)
-test_changes_LDADD=$(TEST_LIBS)
-test_changes_CPPFLAGS=$(TEST_CPPFLAGS)
-test_nonexistent_id_LDADD=$(TEST_LIBS)
-test_nonexistent_id_CPPFLAGS=$(TEST_CPPFLAGS)
-test_self_LDADD=$(TEST_LIBS)
-test_self_CPPFLAGS=$(TEST_CPPFLAGS)
-test_stress_bookviews_LDADD=$(TEST_LIBS)
-test_stress_bookviews_CPPFLAGS=$(TEST_CPPFLAGS)
-include $(top_srcdir)/git.mk
}
}
-typedef struct {
- GMainLoop *loop;
- const gchar *uid;
- ESourceRegistry *registry;
- ESource *scratch;
- ESource *source;
- EBook *book;
-} CreateBookData;
-
-static gboolean
-quit_idle (CreateBookData *data)
-{
- g_main_loop_quit (data->loop);
- return FALSE;
-}
-
-static gboolean
-create_book_idle (CreateBookData *data)
-{
- GError *error = NULL;
-
- data->source = e_source_registry_ref_source (data->registry, data->uid);
- if (!data->source)
- g_error ("Unable to fetch newly created source uid '%s' from the registry", data->uid);
-
- data->book = e_book_new (data->source, &error);
- if (!data->book)
- g_error ("Unable to create the book: %s", error->message);
-
- g_idle_add ((GSourceFunc) quit_idle, data);
-
- return FALSE;
-}
-
-static gboolean
-register_source_idle (CreateBookData *data)
-{
- GError *error = NULL;
- ESourceBackend *backend;
-
- data->registry = e_source_registry_new_sync (NULL, &error);
- if (!data->registry)
- g_error ("Unable to create the registry: %s", error->message);
-
- data->scratch = e_source_new_with_uid (data->uid, NULL, &error);
- if (!data->scratch)
- g_error ("Failed to create source with uid '%s': %s", data->uid, error->message);
-
- backend = e_source_get_extension (data->scratch, E_SOURCE_EXTENSION_ADDRESS_BOOK);
- e_source_backend_set_backend_name (backend, "local");
-
- if (!e_source_registry_commit_source_sync (data->registry, data->scratch, NULL, &error))
- g_error ("Unable to add new source to the registry for uid %s: %s", data->uid, error->message);
-
- /* XXX e_source_registry_commit_source_sync isnt really sync... or else
- * we could call e_source_registry_ref_source() immediately
- */
- g_timeout_add (20, (GSourceFunc) create_book_idle, data);
-
- return FALSE;
-}
-
-static EBook *
-ebook_test_utils_book_with_uid (const gchar *uid)
-{
- CreateBookData data = { 0, };
-
- data.uid = uid;
-
- data.loop = g_main_loop_new (NULL, FALSE);
- g_idle_add ((GSourceFunc) register_source_idle, &data);
- g_main_loop_run (data.loop);
- g_main_loop_unref (data.loop);
-
- g_object_unref (data.scratch);
- g_object_unref (data.source);
- g_object_unref (data.registry);
-
- return data.book;
-}
-
-EBook *
-ebook_test_utils_book_new_temp (gchar **uri)
-{
- EBook *book;
- gchar *uid;
- guint64 real_time = g_get_real_time ();
-
- uid = g_strdup_printf ("test-book-%" G_GINT64_FORMAT, real_time);
- book = ebook_test_utils_book_with_uid (uid);
-
- if (uri)
- *uri = g_strdup (uid);
-
- g_free (uid);
-
- return book;
-}
-
-void
-ebook_test_utils_book_open (EBook *book,
- gboolean only_if_exists)
-{
- GError *error = NULL;
-
- if (!e_book_open (book, only_if_exists, &error)) {
- ESource *source;
- const gchar *name;
-
- source = e_book_get_source (book);
- name = e_source_get_display_name (source);
-
- g_warning (
- "failed to open addressbook: `%s': %s", name,
- error->message);
- exit (1);
- }
-}
-
void
ebook_test_utils_book_get_book_view (EBook *book,
EBookQuery *query,
ebook_test_utils_contacts_are_equal_shallow (EContact *a,
EContact *b);
-EBook *
-ebook_test_utils_book_new_from_uri (const gchar *uri);
-
-EBook *
-ebook_test_utils_book_new_temp (gchar **uri);
-
const gchar *
ebook_test_utils_book_add_contact (EBook *book,
EContact *contact);
gpointer user_data);
void
-ebook_test_utils_book_open (EBook *book,
- gboolean only_if_exists);
-
-void
ebook_test_utils_book_get_book_view (EBook *book,
EBookQuery *query,
EBookView **view);
+++ /dev/null
-#include <libebook/libebook.h>
-
-#define BATCH_SIZE 50
-
-#if 0 /* ACCOUNT_MGMT */
-static gboolean
-check_string_in_slist (GSList *list,
- const gchar *str)
-{
- const GSList *l;
-
- for (l = list; l != NULL; l = l->next) {
- if (g_strcmp0 ((const gchar *) l->data, str) == 0)
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-test_bulk_add_remove (EBookClient *client,
- const gchar *vcard_str,
- gint batch_size)
-{
- gint i;
- GSList *contacts = NULL;
- GSList *added_uids = NULL;
- GSList *book_uids = NULL;
- EBookQuery *query = NULL;
- gchar *sexp = NULL;
- const GSList *l;
-
- query = e_book_query_any_field_contains ("");
- sexp = e_book_query_to_string (query);
- e_book_query_unref (query);
-
- for (i = 0; i < batch_size; ++i) {
- EContact *contact = e_contact_new_from_vcard (vcard_str);
- contacts = g_slist_append (contacts, contact);
- }
-
- g_print (" * Bulk addition of %d contacts...\n", batch_size);
- /* Bulk addition */
- g_return_val_if_fail (e_book_client_add_contacts_sync (client, contacts, &added_uids, NULL, NULL), FALSE);
- g_return_val_if_fail (added_uids != NULL, FALSE);
- g_return_val_if_fail (added_uids->data != NULL, FALSE);
- g_return_val_if_fail (g_slist_length (added_uids) == batch_size, FALSE);
-
- /* Make sure the uids are in the address book */
- g_return_val_if_fail (e_book_client_get_contacts_uids_sync (client, sexp, &book_uids, NULL, NULL), FALSE);
- for (l = added_uids; l != NULL; l = l->next) {
- g_return_val_if_fail (check_string_in_slist (book_uids, (const gchar *) l->data), FALSE);
- }
- g_slist_free_full (book_uids, g_free);
-
- g_print (" * Bulk removal of %d contacts...\n", batch_size);
- /* Bulk removal */
- g_return_val_if_fail (e_book_client_remove_contacts_sync (client, added_uids, NULL, NULL), FALSE);
-
- /* Make sure the uids are no longer in the address book */
- book_uids = NULL;
- g_return_val_if_fail (e_book_client_get_contacts_uids_sync (client, sexp, &book_uids, NULL, NULL), FALSE);
- for (l = added_uids; l != NULL; l = l->next) {
- g_return_val_if_fail (!check_string_in_slist (book_uids, (const gchar *) l->data), FALSE);
- }
- g_slist_free_full (book_uids, g_free);
-
- g_free (sexp);
- g_slist_free_full (added_uids, g_free);
- g_slist_free_full (contacts, g_object_unref);
- return TRUE;
-}
-
-static gboolean
-test_bulk_modify (EBookClient *client,
- const gchar *vcard_str,
- gint batch_size)
-{
- gint i;
- EContact *contact;
- GSList *contacts = NULL;
- GSList *added_uids = NULL;
- const GSList *l, *ll;
- const gchar *old_first_name = "xyz mix";
- const gchar *new_first_name = "abc mix";
-
- for (i = 0; i < batch_size; ++i) {
- EContact *contact = e_contact_new_from_vcard (vcard_str);
- contacts = g_slist_append (contacts, contact);
- }
-
- g_print (" * Bulk addition of %d contacts...\n", batch_size);
- /* Bulk addition */
- g_return_val_if_fail (e_book_client_add_contacts_sync (client, contacts, &added_uids, NULL, NULL), FALSE);
- g_return_val_if_fail (added_uids != NULL, FALSE);
- g_return_val_if_fail (added_uids->data != NULL, FALSE);
- g_return_val_if_fail (g_slist_length (added_uids) == batch_size, FALSE);
-
- g_print (" * Bulk modification of %d contacts...\n", batch_size);
- ll = added_uids;
- for (l = contacts; l != NULL; l = l->next) {
- const gchar * uid = ll->data;
- contact = E_CONTACT (l->data);
-
- /* Set contact UID */
- e_contact_set (contact, E_CONTACT_UID, uid);
-
- /* Change contact first name */
- e_contact_set (contact, E_CONTACT_GIVEN_NAME, new_first_name);
-
- ll = ll->next;
- }
- g_return_val_if_fail (e_book_client_modify_contacts_sync (client, contacts, NULL, NULL), FALSE);
-
- /* Validate */
- for (ll = added_uids; ll != NULL; ll = ll->next) {
- const gchar *first_name;
- const gchar *uid = ll->data;
- contact = NULL;
-
- g_return_val_if_fail (e_book_client_get_contact_sync (client, uid, &contact, NULL, NULL), FALSE);
-
- /* Check contact first name */
- first_name = e_contact_get_const (contact, E_CONTACT_GIVEN_NAME);
- g_return_val_if_fail (g_strcmp0 (first_name, new_first_name) == 0, FALSE);
-
- g_object_unref (contact);
- }
-
- /* Test failure case */
- g_print (" * Bulk modification of %d contacts (expected failure)...\n", batch_size);
- contact = E_CONTACT (g_slist_nth_data (contacts, g_slist_length (contacts) - 2));
- g_return_val_if_fail (e_book_client_remove_contact_sync (client, contact, NULL, NULL), FALSE);
- for (l = contacts; l != NULL; l = l->next) {
- contact = E_CONTACT (l->data);
- /* Change contact first name */
- e_contact_set (contact, E_CONTACT_GIVEN_NAME, old_first_name);
- }
- g_return_val_if_fail (!e_book_client_modify_contacts_sync (client, contacts, NULL, NULL), FALSE);
-
- /* Remove the UID that no longer exists from the added_uid list */
- added_uids = g_slist_delete_link (added_uids, g_slist_nth (added_uids, g_slist_length (added_uids) - 2));
-
- /* Validate */
- for (ll = added_uids; ll != NULL; ll = ll->next) {
- const gchar *first_name;
- const gchar *uid = ll->data;
- contact = NULL;
-
- g_return_val_if_fail (e_book_client_get_contact_sync (client, uid, &contact, NULL, NULL), FALSE);
-
- /* Check contact first name */
- first_name = e_contact_get_const (contact, E_CONTACT_GIVEN_NAME);
- g_return_val_if_fail (g_strcmp0 (first_name, new_first_name) == 0, FALSE);
-
- g_object_unref (contact);
- }
-
- g_print (" * Bulk removal of %d contacts...\n", batch_size);
-
- /* Bulk removal */
- g_return_val_if_fail (e_book_client_remove_contacts_sync (client, added_uids, NULL, NULL), FALSE);
-
- g_slist_free_full (added_uids, g_free);
- g_slist_free_full (contacts, g_object_unref);
- return TRUE;
-}
-#endif /* ACCOUNT_MGMT */
-
-gint main (gint argc, gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- EBookClient *client = NULL;
- const gchar
- *test_vcard_str =
- "BEGIN:VCARD\r\n"
- "VERSION:3.0\r\n"
- "EMAIL;TYPE=OTHER:zyx@no.where\r\n"
- "FN:zyx mix\r\n"
- "N:zyx;mix;;;\r\n"
- "END:VCARD";
-
- g_type_init ();
-
- /* Create EBook Client */
- client = e_book_client_new_system (NULL);
- g_return_val_if_fail (client != NULL, 1);
-
- /* Open address book */
- g_return_val_if_fail (e_client_open_sync (E_CLIENT (client), FALSE, NULL, NULL), 1);
-
- g_print ("Testing bulk addition then removal...\n");
- g_return_val_if_fail (test_bulk_add_remove (client, test_vcard_str, BATCH_SIZE), 1);
- g_print ("Passed.\n");
-
- g_print ("Testing bulk modification...\n");
- g_return_val_if_fail (test_bulk_modify (client, test_vcard_str, BATCH_SIZE), 1);
- g_print ("Passed.\n");
-
- g_object_unref (client);
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-#include "ebook-test-utils.h"
-
-#define NEW_VCARD "BEGIN:VCARD\n\
-X - EVOLUTION - FILE - AS : Toshok, Chris\n\
-FN : Chris Toshok\n\
-EMAIL; INTERNET : toshok@ximian.com\n\
-ORG : Ximian, Inc.;\n\
-END : VCARD"
-
-gint
-main (gint argc,
- gchar **argv)
-{
- EBook *book;
- EContact *contact;
- GList *changes;
- GError *error = NULL;
- EBookChange *change;
- gchar *uri;
-
- g_type_init ();
-
- book = ebook_test_utils_book_new_temp (&uri);
- ebook_test_utils_book_open (book, FALSE);
-
- /* get an initial change set */
- if (!e_book_get_changes (book, "changeidtest", &changes, &error)) {
- printf ("failed to get changes: %s\n", error->message);
- exit (0);
- }
-
- /* make a change to the book */
- contact = e_contact_new_from_vcard (NEW_VCARD);
- ebook_test_utils_book_add_contact (book, contact);
-
- /* get another change set */
- if (!e_book_get_changes (book, "changeidtest", &changes, &error)) {
- printf ("failed to get second set of changes: %s\n", error->message);
- exit (0);
- }
-
- /* make sure that 1 change has occurred */
- if (g_list_length (changes) != 1) {
- printf ("got back %d changes, was expecting 1\n", g_list_length (changes));
- exit (0);
- }
-
- change = changes->data;
- if (change->change_type != E_BOOK_CHANGE_CARD_ADDED) {
- printf ("was expecting a CARD_ADDED change, but didn't get it.\n");
- exit (0);
- }
-
- printf ("got changed vcard back: %s\n", (gchar *) e_contact_get_const (change->contact, E_CONTACT_UID));
-
- e_book_free_change_list (changes);
-
- g_object_unref (contact);
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-#if 0 /* ACCOUNT_MGMT */
-static GMainLoop *loop;
-
-static void
-print_email (EContact *contact)
-{
- const gchar *file_as = e_contact_get_const (contact, E_CONTACT_FILE_AS);
- const gchar *name_or_org = e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG);
- GList *emails, *e;
-
- printf ("Contact: %s\n", file_as);
- printf ("Name or org: %s\n", name_or_org);
- printf ("Email addresses:\n");
- emails = e_contact_get (contact, E_CONTACT_EMAIL);
- for (e = emails; e; e = e->next) {
- printf ("\t%s\n", (gchar *) e->data);
- }
- g_list_foreach (emails, (GFunc) g_free, NULL);
- g_list_free (emails);
-
- printf ("\n");
-}
-
-static void
-print_all_emails_cb (EBook *book,
- const GError *error,
- GList *contacts,
- gpointer closure)
-{
- GList *c;
-
- if (!error) {
- for (c = contacts; c; c = c->next) {
- EContact *contact = E_CONTACT (c->data);
-
- print_email (contact);
- }
- } else {
- g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
- }
-
- g_main_loop_quit (loop);
-}
-
-static void
-print_all_emails (EBook *book)
-{
- EBookQuery *query;
-
- query = e_book_query_field_exists (E_CONTACT_FULL_NAME);
-
- e_book_get_contacts_async (book, query, print_all_emails_cb, NULL);
-
- e_book_query_unref (query);
-}
-
-static void
-print_email_cb (EBook *book,
- const GError *error,
- EContact *contact,
- gpointer closure)
-{
- if (!error)
- print_email (contact);
- else
- g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
-
- printf ("printing all contacts\n");
- print_all_emails (book);
-}
-
-static void
-print_one_email (EBook *book)
-{
- e_book_get_contact_async (book, "pas-id-0002023", print_email_cb, NULL);
-}
-
-static void
-book_loaded_cb (EBook *book,
- const GError *error,
- gpointer data)
-{
- if (error) {
- g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
- return;
- }
-
- printf ("printing one contact\n");
- print_one_email (book);
-}
-#endif /* ACCOUNT_MGMT */
-
-gint
-main (gint argc,
- gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- EBook *book;
-
- g_type_init ();
- loop = g_main_loop_new (NULL, TRUE);
-
- /*
- ** the actual ebook foo
- */
-
- book = e_book_new_system_addressbook (NULL);
-
- printf ("loading addressbook\n");
- e_book_open_async (book, FALSE, book_loaded_cb, book);
-
- g_main_loop_run (loop);
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-#include "ebook-test-utils.h"
-
-#define NUM_BOOKS 200
-
-gint
-main (gint argc,
- gchar **argv)
-{
- gchar *uri = NULL;
- EBook *books[NUM_BOOKS];
- gint i;
-
- g_type_init ();
-
- /* Create and open many books; then remove each of them */
-
- for (i = 0; i < NUM_BOOKS; i++) {
- books[i] = ebook_test_utils_book_new_temp (&uri);
- ebook_test_utils_book_open (books[i], FALSE);
-
- g_free (uri);
- }
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <libebook/libebook.h>
-
-#include "ebook-test-utils.h"
-
-#define NUM_BOOKS 200
-
-gint
-main (gint argc,
- gchar **argv)
-{
- gchar *uri = NULL;
- gint i;
-
- g_type_init ();
-
- /* Serially create, open, (close), and remove many books */
- for (i = 0; i < NUM_BOOKS; i++) {
- EBook *book;
-
- book = ebook_test_utils_book_new_temp (&uri);
- ebook_test_utils_book_open (book, FALSE);
-
- g_free (uri);
- }
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-#include "ebook-test-utils.h"
-
-#define NUM_OPENS 200
-
-gint
-main (gint argc,
- gchar **argv)
-{
- gchar *uri = NULL;
- EBook *book;
- gint i;
-
- g_type_init ();
-
- book = ebook_test_utils_book_new_temp (&uri);
- g_object_unref (book);
-
- /* open and close the same book repeatedly */
- for (i = 0; i < NUM_OPENS - 1; i++) {
- book = ebook_test_utils_book_new_from_uri (uri);
- ebook_test_utils_book_open (book, FALSE);
- g_object_unref (book);
- }
-
- g_free (uri);
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-#include "ebook-test-utils.h"
-
-#if 0 /* ACCOUNT_MGMT */
-static void
-print_email (EContact *contact)
-{
- const gchar *file_as = e_contact_get_const (contact, E_CONTACT_FILE_AS);
- const gchar *name_or_org = e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG);
- GList *emails, *e;
-
- printf ("Contact: %s\n", file_as);
- printf ("Name or org: %s\n", name_or_org);
- printf ("Email addresses:\n");
- emails = e_contact_get (contact, E_CONTACT_EMAIL);
- for (e = emails; e; e = e->next) {
- printf ("\t%s\n", (gchar *) e->data);
- }
- g_list_foreach (emails, (GFunc) g_free, NULL);
- g_list_free (emails);
-
- printf ("\n");
-}
-
-static void
-print_all_emails (EBook *book)
-{
- EBookQuery *query;
- gboolean status;
- GList *cards, *c;
-
- query = e_book_query_field_exists (E_CONTACT_FULL_NAME);
-
- status = e_book_get_contacts (book, query, &cards, NULL);
-
- e_book_query_unref (query);
-
- if (status == FALSE) {
- printf ("error %d getting card list\n", status);
- exit (0);
- }
-
- for (c = cards; c; c = c->next) {
- EContact *contact = E_CONTACT (c->data);
-
- print_email (contact);
-
- g_object_unref (contact);
- }
- g_list_free (cards);
-}
-
-static void
-print_one_email (EBook *book)
-{
- EContact *contact;
- GError *error = NULL;
-
- if (!e_book_get_contact (book, "pas-id-0002023", &contact, &error)) {
- printf ("error %d getting card: %s\n", error->code, error->message);
- g_clear_error (&error);
- return;
- }
-
- print_email (contact);
-
- g_object_unref (contact);
-}
-#endif /* ACCOUNT_MGMT */
-
-gint
-main (gint argc,
- gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- EBook *book;
-
- g_type_init ();
-
- /*
- ** the actual ebook foo
- */
-
- printf ("loading addressbook\n");
- book = e_book_new_system_addressbook (NULL);
- if (!book) {
- printf ("failed to create local addressbook\n");
- exit (0);
- }
-
- ebook_test_utils_book_open (book, FALSE);
-
- printf ("printing one contact\n");
- print_one_email (book);
-
- printf ("printing all contacts\n");
- print_all_emails (book);
-
- g_object_unref (book);
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}
+++ /dev/null
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-gint
-main (gint argc,
- gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- GError *err = NULL;
- EBook *book = NULL;
-
- printf ("loading addressbook\n");
- book = e_book_new_system_addressbook (NULL);
- if (!book) {
- printf ("failed to create local addressbook\n");
- exit (0);
- }
-
- if (!e_book_open (book, FALSE, NULL)) {
- printf ("failed to open local addressbook\n");
- exit (0);
- }
-
- printf ("removing nonexistant contact\n");
- if (!e_book_remove_contact (book, "kk", &err)) {
- printf ("error %d removing contact: %s\n", err->code, err->message);
- g_clear_error (&err);
- }
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-gint
-main (gint argc,
- gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- EBook *book;
- gboolean status;
- EBookQuery *query;
- GList *c, *contacts;
-
- g_type_init ();
-
- if (argc < 3) {
- printf ("usage: test-search <addressbook uri> <query>\n");
- exit (0);
- }
-
- query = e_book_query_from_string (argv[2]);
- if (!query) {
- printf ("failed to parse query string '%s'\n", argv[2]);
- exit (0);
- }
-
- book = e_book_new_system_addressbook (NULL);
- if (!book) {
- printf ("failed to create ebook\n");
- exit (0);
- }
-
- status = e_book_open (book, TRUE, NULL);
- if (status == FALSE) {
- printf ("failed to open addressbook\n");
- exit (0);
- }
-
- status = e_book_get_contacts (book, query, &contacts, NULL);
- if (status == FALSE) {
- printf ("failed to get contacts\n");
- exit (0);
- }
-
- for (c = contacts; c; c = c->next) {
- EContact *contact = E_CONTACT (c->data);
-
- printf ("%s\n", e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30));
-
- g_object_unref (contact);
- }
-
- g_list_free (contacts);
-
- g_object_unref (book);
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-gint
-main (gint argc,
- gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- EBook *book;
- EContact *contact;
- GError *error = NULL;
- gchar *vcard;
-
- g_type_init ();
-
- printf ("getting the self contact\n");
-
- if (!e_book_get_self (&contact, &book, &error)) {
- printf ("error %d getting self: %s\n", error->code, error->message);
- g_clear_error (&error);
- return -1;
- }
-
- vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
- printf ("self contact = \n%s\n", vcard);
- g_free (vcard);
-
- g_object_unref (contact);
- g_object_unref (book);
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libebook/libebook.h>
-
-#if 0 /* ACCOUNT_MGMT */
-static void
-print_contact (EContact *contact)
-{
- GList *emails, *e;
-
- printf ("Contact: %s\n", (gchar *) e_contact_get_const (contact, E_CONTACT_FILE_AS));
- printf ("UID: %s\n", (gchar *) e_contact_get_const (contact, E_CONTACT_UID));
- printf ("Email addresses:\n");
-
- emails = e_contact_get (contact, E_CONTACT_EMAIL);
- for (e = emails; e; e = e->next) {
- printf ("\t%s\n", (gchar *) e->data);
- }
- g_list_foreach (emails, (GFunc) g_free, NULL);
- g_list_free (emails);
-
- printf ("\n");
-}
-
-static void
-contacts_added (EBookView *book_view,
- const GList *contacts)
-{
- GList *l;
-
- for (l = (GList *) contacts; l; l = l->next) {
- print_contact (l->data);
- }
-}
-
-static void
-contacts_removed (EBookView *book_view,
- const GList *ids)
-{
- GList *l;
-
- for (l = (GList *) ids; l; l = l->next) {
- printf ("Removed contact: %s\n", (gchar *) l->data);
- }
-}
-
-static void
-view_complete (EBookView *book_view,
- EBookViewStatus status,
- const gchar *error_msg)
-{
- printf ("view_complete (status == %d, error_msg == %s%s%s)\n", status, error_msg ? "'" : "", error_msg ? error_msg : "NULL", error_msg ? "'" : "");
-}
-#endif /* ACCOUNT_MGMT */
-
-gint
-main (gint argc,
- gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- EBook *book;
- gboolean status;
- EBookQuery *query;
- EBookView *view = NULL;
- EBookView *new_view;
- gint i;
-
- g_type_init ();
-
- /*
- ** the actual ebook foo
- */
-
- printf ("loading addressbook\n");
- book = e_book_new_system_addressbook (NULL);
- if (!book) {
- printf ("failed to create ebook\n");
- exit (0);
- }
-
- status = e_book_open (book, FALSE, NULL);
- if (status == FALSE) {
- printf ("failed to open local addressbook\n");
- exit (0);
- }
-
- query = e_book_query_any_field_contains ("");
-
- for (i = 0; i < 500; i++) {
- status = e_book_get_book_view (book, query, NULL, -1, &new_view, NULL);
-
- g_signal_connect (new_view, "contacts_added", G_CALLBACK (contacts_added), NULL);
- g_signal_connect (new_view, "contacts_removed", G_CALLBACK (contacts_removed), NULL);
- g_signal_connect (new_view, "view_complete", G_CALLBACK (view_complete), NULL);
-
- e_book_view_start (new_view);
-
- if (view) {
- e_book_view_stop (view);
- g_object_unref (view);
- }
-
- view = new_view;
- }
-
- e_book_view_stop (view);
- g_object_unref (view);
-
- e_book_query_unref (query);
- g_object_unref (book);
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}