tests: Silence compiler warnings.
[platform/upstream/evolution-data-server.git] / tests / libebook / test-stress-bookviews.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 #include <stdlib.h>
4 #include <libebook/libebook.h>
5
6 #if 0  /* ACCOUNT_MGMT */
7 static void
8 print_contact (EContact *contact)
9 {
10         GList *emails, *e;
11
12         printf ("Contact: %s\n", (gchar *) e_contact_get_const (contact, E_CONTACT_FILE_AS));
13         printf ("UID: %s\n", (gchar *) e_contact_get_const (contact, E_CONTACT_UID));
14         printf ("Email addresses:\n");
15
16         emails = e_contact_get (contact, E_CONTACT_EMAIL);
17         for (e = emails; e; e = e->next) {
18                 printf ("\t%s\n",  (gchar *) e->data);
19         }
20         g_list_foreach (emails, (GFunc) g_free, NULL);
21         g_list_free (emails);
22
23         printf ("\n");
24 }
25
26 static void
27 contacts_added (EBookView *book_view,
28                 const GList *contacts)
29 {
30   GList *l;
31
32   for (l = (GList *) contacts; l; l = l->next) {
33     print_contact (l->data);
34   }
35 }
36
37 static void
38 contacts_removed (EBookView *book_view,
39                   const GList *ids)
40 {
41   GList *l;
42
43   for (l = (GList *) ids; l; l = l->next) {
44     printf ("Removed contact: %s\n", (gchar *) l->data);
45   }
46 }
47
48 static void
49 view_complete (EBookView *book_view,
50                EBookViewStatus status,
51                const gchar *error_msg)
52 {
53   printf ("view_complete (status == %d, error_msg == %s%s%s)\n", status, error_msg ? "'" : "", error_msg ? error_msg : "NULL", error_msg ? "'" : "");
54 }
55 #endif /* ACCOUNT_MGMT */
56
57 gint
58 main (gint argc,
59       gchar **argv)
60 {
61 #if 0  /* ACCOUNT_MGMT */
62         EBook *book;
63         gboolean status;
64         EBookQuery *query;
65         EBookView *view = NULL;
66         EBookView *new_view;
67         gint i;
68
69         g_type_init ();
70
71         /*
72         ** the actual ebook foo
73         */
74
75         printf ("loading addressbook\n");
76         book = e_book_new_system_addressbook (NULL);
77         if (!book) {
78                 printf ("failed to create ebook\n");
79                 exit (0);
80         }
81
82         status = e_book_open (book, FALSE, NULL);
83         if (status == FALSE) {
84                 printf ("failed to open local addressbook\n");
85                 exit (0);
86         }
87
88         query = e_book_query_any_field_contains ("");
89
90         for (i = 0; i < 500; i++) {
91                 status = e_book_get_book_view (book, query, NULL, -1, &new_view, NULL);
92
93                 g_signal_connect (new_view, "contacts_added", G_CALLBACK (contacts_added), NULL);
94                 g_signal_connect (new_view, "contacts_removed", G_CALLBACK (contacts_removed), NULL);
95                 g_signal_connect (new_view, "view_complete", G_CALLBACK (view_complete), NULL);
96
97                 e_book_view_start (new_view);
98
99                 if (view) {
100                         e_book_view_stop (view);
101                         g_object_unref (view);
102                 }
103
104                 view = new_view;
105         }
106
107         e_book_view_stop (view);
108         g_object_unref (view);
109
110         e_book_query_unref (query);
111         g_object_unref (book);
112 #endif /* ACCOUNT_MGMT */
113
114         return 0;
115 }