Adapt libecal to the new ESource API.
[platform/upstream/evolution-data-server.git] / tests / libecal / test-ecal.c
1 /* Evolution calendar client - test program
2  *
3  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 2 of the GNU Lesser General Public
7  * License as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18
19 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif
22
23 #include <stdlib.h>
24 #include <string.h>
25 #include <glib/gi18n.h>
26 #include <libecal/e-cal.h>
27 #include <libecal/e-cal-component.h>
28 #include <libecal/e-cal-time-util.h>
29 #include <libedataserver/e-data-server-util.h>
30 #include <libical/ical.h>
31
32 /* start_testing_scaffold */
33 #define mu_assert(message, test) do { if (!(test)) return message; else { tests_passed++; return NULL;}} while (0)
34 #define mu_run_test(test) do { const gchar *message = test; tests_run++; \
35                                 if (message) { cl_printf (client, "***Error***\n%s\n", message); break;} } while (0)
36
37 static gint tests_run = 0;
38 static gint tests_passed = 0;
39 /* end_testing_scaffold */
40
41 static ECal *client1;
42 static ECal *client2;
43
44 static GMainLoop *loop;
45
46 /* Prints a message with a client identifier */
47 static void
48 cl_printf (ECal *client,
49            const gchar *format,
50            ...)
51 {
52         va_list args;
53
54         if (client != client1)
55                 return;
56
57         va_start (args, format);
58         printf ("Client %s: ", "Test");
59         vprintf (format, args);
60         va_end (args);
61 }
62
63 static void
64 objects_added_cb (GObject *object,
65                   GList *objects,
66                   gpointer data)
67 {
68         GList *l;
69
70         for (l = objects; l; l = l->next)
71                 cl_printf (data, "Object added %s\n", icalcomponent_get_uid (l->data));
72 }
73
74 static void
75 objects_modified_cb (GObject *object,
76                      GList *objects,
77                      gpointer data)
78 {
79         GList *l;
80
81         for (l = objects; l; l = l->next)
82                 cl_printf (data, "Object modified %s\n", icalcomponent_get_uid (l->data));
83 }
84
85 static void
86 objects_removed_cb (GObject *object,
87                     GList *objects,
88                     gpointer data)
89 {
90         GList *l;
91
92         for (l = objects; l; l = l->next)
93                 cl_printf (data, "Object removed %s\n", icalcomponent_get_uid (l->data));
94 }
95
96 static void
97 view_complete_cb (GObject *object,
98                   ECalendarStatus status,
99                   const gchar *error_msg,
100                   gpointer data)
101 {
102         cl_printf (data, "View complete (status:%d, error_msg:%s)\n", status, error_msg ? error_msg : "NULL");
103 }
104
105 static gboolean
106 list_uids (ECal *client)
107 {
108         GList *objects = NULL;
109         GList *l;
110
111         if (!e_cal_get_object_list (client, "(contains? \"any\" \"test\")", &objects, NULL))
112                 return FALSE;
113
114         cl_printf (client, "UIDS: ");
115
116         cl_printf (client, "\nGot %d objects\n", g_list_length (objects));
117         if (!objects)
118                 printf ("none\n");
119         else {
120                 for (l = objects; l; l = l->next) {
121                         const gchar *uid;
122
123                         uid = icalcomponent_get_uid (l->data);
124                         printf ("`%s' ", uid);
125                 }
126
127                 printf ("\n");
128
129                 for (l = objects; l; l = l->next) {
130                         gchar *obj = icalcomponent_as_ical_string_r (l->data);
131                         printf ("------------------------------\n");
132                         printf ("%s", obj);
133                         printf ("------------------------------\n");
134                         free (obj);
135                 }
136         }
137
138         e_cal_free_object_list (objects);
139
140         return FALSE;
141 }
142
143 /* Callback used when a client is destroyed */
144 static void
145 client_destroy_cb (gpointer data,
146                    GObject *object)
147 {
148         if (E_CAL (object) == client1)
149                 client1 = NULL;
150         else if (E_CAL (object) == client2)
151                 client2 = NULL;
152
153         if (!client1 && !client2)
154                 g_main_loop_quit (loop);
155 }
156
157 static const gchar *
158 test_object_creation (ECal *client,
159                       gchar **uid)
160 {
161         ECalComponent *comp, *comp_retrieved;
162         icalcomponent *icalcomp, *icalcomp_retrieved;
163         struct icaltimetype tt;
164         ECalComponentText text;
165         ECalComponentDateTime dt;
166         ECalComponentTransparency transp;
167         gboolean compare;
168         GError *error = NULL;
169
170         comp = e_cal_component_new ();
171         /* set fields */
172         e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
173         text.value = "Creation of new test event";
174         text.altrep = NULL;
175         e_cal_component_set_summary (comp, &text);
176         tt = icaltime_from_string ("20040109T090000Z");
177         dt.value = &tt;
178         dt.tzid ="UTC";
179         e_cal_component_set_dtstart (comp, &dt);
180         tt = icaltime_from_string ("20040109T103000");
181         dt.value = &tt;
182         dt.tzid ="UTC";
183         e_cal_component_set_dtend (comp, &dt);
184         e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_OPAQUE);
185
186         e_cal_component_commit_sequence (comp);
187         icalcomp = e_cal_component_get_icalcomponent (comp);
188         if (!e_cal_create_object (client, icalcomp, uid, &error)) {
189                 cl_printf (client, "Object creation:  %s\n", error->message);
190                 g_free (comp);
191                 g_free (icalcomp);
192                 return "Test Object Creation failed";
193         }
194         e_cal_component_commit_sequence (comp);
195         if (!e_cal_get_object (client, *uid, NULL, &icalcomp_retrieved, &error)) {
196                 cl_printf (client, "Object retrieval:  %s\n", error->message);
197                 g_free (uid);
198                 g_free (comp);
199                 g_free (icalcomp);
200                 return "Test Object Creation failed";
201
202         }
203
204         comp_retrieved = e_cal_component_new ();
205         if (!e_cal_component_set_icalcomponent (comp_retrieved, icalcomp_retrieved)) {
206                 cl_printf (client, "Could not set icalcomponent\n");
207                 g_free (uid);
208                 g_free (comp);
209                 g_free (icalcomp);
210                 g_free (icalcomp_retrieved);
211                 return "Test Object Creation failed";
212
213         }
214         /* Dumping icalcomp into a string is not useful as the retrieved object
215          * has some generated information like timestamps. We compare
216          * member values we set during creation*/
217         compare = e_cal_component_event_dates_match (comp, comp_retrieved);
218
219         if (compare) {
220                 e_cal_component_get_transparency (comp_retrieved, &transp);
221                 compare = (transp == E_CAL_COMPONENT_TRANSP_OPAQUE);
222         }
223
224         g_free (comp_retrieved);
225         g_free (comp);
226         g_free (icalcomp);
227         g_free (icalcomp_retrieved);
228
229         mu_assert ("Test Object creation : Created object does not match retrieved data\n", compare);
230         return NULL;
231 }
232
233 static const gchar *
234 test_object_modification (ECal *client,
235                           gchar *uid)
236 {
237         const gchar *summary = "This summary was modified";
238         icalcomponent *icalcomp, *icalcomp_modified;
239         gboolean compare;
240         GError *error = NULL;
241
242         if (!e_cal_get_object (client, uid, NULL, &icalcomp, &error)) {
243                 cl_printf (client, "Test Modify object : Could not get the object: %s\n", error->message);
244                 g_free (uid);
245                 return error->message;
246         }
247
248         /* Modify one property of the icalcomp and save it.
249          * Now retrieve it and check the field. */
250         icalcomponent_set_summary (icalcomp, summary);
251         if (!e_cal_modify_object  (client, icalcomp, CALOBJ_MOD_THIS, &error)) {
252                 cl_printf (client, "Test Modify object : Could not modify the object: %s\n", error->message);
253                 g_free (uid);
254                 g_free (icalcomp);
255                 return error->message;
256         }
257
258         if (!e_cal_get_object (client, uid, NULL, &icalcomp_modified, &error)) {
259                 cl_printf (client, "Test Modify object : Could not get the modified object: %s\n", error->message);
260                 g_free (uid);
261                 g_free (icalcomp);
262                 return "Test Object Creation failed";
263         }
264
265         compare = !strcmp ( icalcomponent_get_summary (icalcomp_modified), summary);
266
267         g_free (uid);
268         g_free (icalcomp);
269         g_free (icalcomp_modified);
270
271         mu_assert ("Test Modify object : Modification failed\n", compare);
272         return NULL;
273 }
274
275 #if 0
276 static gchar *
277 test_object_removal (ECal *client)
278 {
279
280         gchar *uid;
281         ECalComponent *comp;
282         icalcomponent *icalcomp;
283         gboolean compare = 1;
284         GError *error = NULL;
285
286         comp = e_cal_component_new ();
287         e_cal_component_commit_sequence (comp);
288         icalcomp = e_cal_component_get_icalcomponent (comp);
289         if (!e_cal_create_object (client, icalcomp, &uid, &error)) {
290                 cl_printf (client, "Test object removal - Object creation:  %s\n", error->message);
291                 g_object_unref (comp);
292                 g_object_unref (icalcomp);
293                 return "Test Object Removal failed\n";
294         }
295
296         if (!e_cal_remove_object (client, uid, &error)) {
297                 cl_printf (client, "Test object removal - Could not remove the object\n");
298                 g_free (uid);
299                 g_object_unref (comp);
300                 g_object_unref (icalcomp);
301                 return "Test Object Removal failed\n";
302
303         }
304
305         compare =  e_cal_get_object (client, uid, NULL, &icalcomp, &error);
306
307         g_free (uid);
308         g_object_unref (comp);
309         g_object_unref (icalcomp);
310
311         mu_assert ("Test object removal - Failed\n", compare);
312         return NULL;
313 }
314 #endif
315
316 static const gchar *
317 test_get_alarms_in_range (ECal *client)
318 {
319         GSList *alarms;
320         icaltimezone *utc;
321         time_t start, end;
322         gboolean compare;
323
324         utc = icaltimezone_get_utc_timezone ();
325         start = time_from_isodate ("20040212T000000Z");
326         end = time_add_day_with_zone (start, 2, utc);
327
328         alarms = e_cal_get_alarms_in_range (client, start, end);
329         compare = (g_slist_length (alarms) == 3);
330
331         e_cal_free_alarms (alarms);
332         mu_assert ("Test getting alarms in range\n", compare);
333
334         return NULL;
335 }
336
337 static const gchar *
338 test_cal_loaded (ECal *client)
339 {
340         /* Test one loaded calendar and another that is not loaded. */
341         mu_assert ("Test get_cal_load_state : Failed \n",
342                         (E_CAL_LOAD_LOADED == e_cal_get_load_state (client)) &&
343                         (E_CAL_LOAD_NOT_LOADED == e_cal_get_load_state (NULL)));
344
345         return NULL;
346 }
347
348 static const gchar *
349 test_get_source (ECal *client,
350                  const gchar *expected)
351 {
352         const gchar *uri;
353         gchar *cal_uri;
354         gboolean compare = 0;
355
356         /* FIXME ESources no longer have built-in URIs. */
357         /* uri = e_source_get_uri (source); */
358         uri = "";
359         cal_uri = g_strconcat ("file://", expected, NULL);
360         compare = !strcmp (expected, uri);
361
362         g_free (cal_uri);
363         mu_assert ("Test get_source : Failed\n", compare);
364
365         return NULL;
366 }
367
368 static const gchar *
369 test_query (ECal *client,
370             const gchar *query,
371             gint expected)
372 {
373         /* This uses pre-loaded data. Hence its results are valid only
374          * when called before any write operation is performed.
375          */
376         gint i = 0;
377         GList *objects = NULL;
378
379         if (!e_cal_get_object_list (client, query, &objects, NULL))
380                 return "Could not get the list of objects";
381         i = g_list_length (objects);
382         e_cal_free_object_list (objects);
383
384         mu_assert ("Test get_object_list : Expected number of objects not found", i == expected);
385
386         return NULL;
387 }
388
389 #if 0
390 static gchar *
391 test_e_cal_new (ECal **cal,
392                 const gchar *uri)
393 {
394         GError *error = NULL;
395         gchar *cal_uri, *cal_file;
396         gboolean created = 0;
397
398         cal_uri = g_strconcat ("file://", uri, NULL);
399         *cal = e_cal_new_from_uri (cal_uri, E_CAL_SOURCE_TYPE_EVENT);
400         if (!*cal) {
401                 g_message (G_STRLOC ": could not create the client");
402                 g_free (cal_uri);
403                 return "Test Creation of new calendar : Failed";
404         }
405         g_object_weak_ref (G_OBJECT (*cal), client_destroy_cb, NULL);
406
407         cl_printf (*cal, "Calendar loading `%s'...\n", uri);
408
409         if (!e_cal_open (*cal, FALSE, &error)) {
410                 cl_printf (*cal, "Load/create %s\n", error->message);
411                 g_free (cal_uri);
412                 return "Test creation of new calendar : Failed";
413         }
414
415         cal_file = g_strconcat (uri, "/calendar.ics", NULL);
416
417         created = g_file_test (cal_file, G_FILE_TEST_EXISTS);
418         g_free (cal_uri);
419         g_free (cal_file);
420
421         mu_assert ("Test creation of new calendar : Failed", created);
422
423         return NULL;
424 }
425
426 static gchar *
427 test_e_cal_remove (ECal *ecal,
428                    const gchar *uri)
429 {
430         gchar *cal_uri;
431         GError *error = NULL;
432         gboolean removed = 0;
433
434         cal_uri = g_strconcat (uri, "/calendar.ics", NULL);
435         if (!e_cal_remove (ecal, &error)) {
436                 cl_printf (ecal, "Test Calendar removal : Could not remove the Calendar : %s\n", error->message);
437         }
438
439         removed = !g_file_test (uri, G_FILE_TEST_EXISTS);
440         g_free (cal_uri);
441
442         mu_assert ("Test Remove calendar : Failed ", removed);
443
444         return NULL;
445 }
446 #endif
447
448 static const gchar *
449 test_new_system_calendar (void)
450 {
451 #if 0  /* ACCOUNT_MGMT */
452         const gchar *user_data_dir;
453         gchar *filename;
454         gboolean created;
455
456         e_cal_new_system_calendar ();
457
458         user_data_dir = e_get_user_data_dir ();
459         filename = g_build_filename (
460                 user_data_dir, "calendar", "system", "calendar.ics", NULL);
461         created = g_file_test (filename, G_FILE_TEST_EXISTS);
462         g_free (filename);
463
464         mu_assert ("Test creation of default system calendar : Failed", created);
465 #endif /* ACCOUNT_MGMT */
466
467         return NULL;
468 }
469
470 static const gchar *
471 test_new_system_tasks (void)
472 {
473 #if 0  /* ACCOUNT_MGMT */
474         const gchar *user_data_dir;
475         gchar *filename;
476         gboolean created;
477
478         e_cal_new_system_tasks ();
479
480         user_data_dir = e_get_user_data_dir ();
481         filename = g_build_filename (
482                 user_data_dir, "tasks", "system", "tasks.ics", NULL);
483         created = g_file_test (filename, G_FILE_TEST_EXISTS);
484         g_free (filename);
485
486         mu_assert ("Test creation of default system tasks : Failed", created);
487 #endif /* ACCOUNT_MGMT */
488
489         return NULL;
490 }
491
492 static const gchar *
493 test_new_system_memos (void)
494 {
495 #if 0  /* ACCOUNT_MGMT */
496         const gchar *user_data_dir;
497         gchar *filename;
498         gboolean created;
499
500         e_cal_new_system_memos ();
501
502         user_data_dir = e_get_user_data_dir ();
503         filename = g_build_filename (
504                 user_data_dir, "memos", "system", "journal.ics", NULL);
505         created = g_file_test (filename, G_FILE_TEST_EXISTS);
506         g_free (filename);
507
508         mu_assert ("Test creation of default system memos : Failed", created);
509 #endif /* ACCOUNT_MGMT */
510
511         return NULL;
512 }
513
514 static gchar *
515 test_get_free_busy (ECal *client)
516 {
517         /* TODO uses NULL for users and currently specific to file backend. */
518         GList *l, *freebusy = NULL;
519         GError *error = NULL;
520         icaltimezone *utc;
521         time_t start, end;
522
523         utc = icaltimezone_get_utc_timezone ();
524         start = time_from_isodate ("20040212T000000Z");
525         end = time_add_day_with_zone (start, 2, utc);
526
527         if (!e_cal_get_free_busy (client, NULL, start, end, &freebusy, &error)) {
528                 cl_printf (client, "Test free/busy : Could not retrieve free busy information :  %s\n", error->message);
529                 return error->message;
530         }
531         if (freebusy) {
532                 cl_printf (client, "Printing free busy information\n");
533                 for (l = freebusy; l; l = l->next) {
534                         gchar *comp_string;
535                         ECalComponent *comp = E_CAL_COMPONENT (l->data);
536
537                         comp_string = e_cal_component_get_as_string (comp);
538                         cl_printf (client, "%s\n\n", comp_string);
539                         g_object_unref (comp);
540                         g_free (comp_string);
541                 }
542         }
543         else {
544                 cl_printf (client, "free_busy was returned but NULL");
545         }
546         return NULL;
547 }
548
549 static gchar *
550 test_get_default_object (ECal *client)
551 {
552         icalcomponent *icalcomp;
553         GError *error = NULL;
554         gchar *ical_string;
555         if (e_cal_get_default_object (client, &icalcomp, &error)) {
556                 ical_string = icalcomponent_as_ical_string_r (icalcomp);
557                 cl_printf (client, "Obtained default object: %s\n", ical_string);
558                 g_free (ical_string);
559                 tests_passed++;
560                 return NULL;
561
562         } else
563                 cl_printf (client, "Test Get default object : Could not get the default object: %s\n", error->message);
564         return error->message;
565 }
566
567 /* XXX The string pasted below is *really* ugly. Alternatively, it could be
568  * read from a file at run-time. Not sure if it is an elegant solution when
569  * multiple clients try to load the same file during stress testing.
570  * how can this be done better ?
571  */
572 #define EXPECTED \
573 "BEGIN : VEVENT\
574 UID : 20040213T055519Z - 15802 - 500 - 1 - 3@testcal\
575 DTSTAMP : 20040213T055519Z\
576 DTSTART; TZID=/softwarestudio.org / Olson_20011030_5 / Asia / Calcutta:\
577  20040213T130000\
578 DTEND; TZID=/softwarestudio.org / Olson_20011030_5 / Asia / Calcutta:\
579  20040213T133000\
580 TRANSP : OPAQUE\
581 SEQUENCE : 3\
582 SUMMARY : Test - Travel plans to Kansas\
583 LOCATION : Yellow Brick road\
584 CLASS : PUBLIC\
585 ORGANIZER; CN = dorothy : MAILTO : dorothy@oz\
586 DESCRIPTION: Discuss way to home\
587 ATTENDEE; CUTYPE = INDIVIDUAL; ROLE = REQ - PARTICIPANT; PARTSTAT = ACCEPTED;\
588  RSVP = TRUE; CN = dorothy; LANGUAGE = en : MAILTO : dorothy@oz\
589 ATTENDEE; CUTYPE = INDIVIDUAL; ROLE = REQ - PARTICIPANT; PARTSTAT = NEEDS - ACTION;\
590  RSVP = TRUE; CN = tinman; LANGUAGE = en : MAILTO : tinman@oz\
591 ATTENDEE; CUTYPE = INDIVIDUAL; ROLE = REQ - PARTICIPANT; PARTSTAT = NEEDS - ACTION;\
592  RSVP = TRUE; CN = toto; LANGUAGE = en : MAILTO : toto@oz\
593 ATTENDEE; CUTYPE = INDIVIDUAL; ROLE = OPT - PARTICIPANT; PARTSTAT = NEEDS - ACTION;\
594  RSVP = TRUE; CN = scarecrow; LANGUAGE = en : MAILTO : scarecrow@oz\
595 LAST - MODIFIED : 20040213T055647Z\
596 END : VEVENT"
597
598 static const gchar *
599 test_get_object (ECal *client)
600 {
601         const gchar *uid = "20040213T055519Z-15802-500-1-3@testcal";
602         gchar *actual;
603         icalcomponent *icalcomp;
604         gboolean compare;
605         GError *error = NULL;
606
607         if (!e_cal_get_object (client, uid, NULL, &icalcomp, &error)) {
608                 cl_printf (client, "Test Get object : Could not get the object: %s\n", error->message);
609                 return error->message;
610         }
611
612         actual = icalcomponent_as_ical_string_r (icalcomp);
613         compare = !strcmp (actual, EXPECTED);
614
615         g_free (actual);
616
617         mu_assert ("Test : get_object does not match the expected output", compare);
618         return NULL;
619 }
620
621 static gchar *
622 test_timezones (ECal *client)
623 {
624         icaltimezone *zone;
625         GError *error = NULL;
626         if (!e_cal_get_timezone (client, "UTC", &zone, &error))
627         {
628                 cl_printf (client, "Could not get the timezone\n");
629         }
630
631         printf ("\n\nTime Zones : \n%s *** %s", icaltimezone_get_display_name (zone), icaltimezone_get_tzid (zone));
632         printf ("\n\nTime Zones : \n%s", icaltimezone_get_location (zone));
633
634         return NULL;
635 }
636
637 static const gchar *
638 all_tests (ECal *client,
639            const gchar *uri)
640 {
641         gchar *uid;
642
643         mu_run_test (test_new_system_calendar ());
644         mu_run_test (test_new_system_tasks ());
645         mu_run_test (test_new_system_memos ());
646         mu_run_test (test_get_source (client, uri));
647         mu_run_test (test_cal_loaded (client));
648
649         /* test_query acts on pre-loaded data. Hence it must executed before
650          * any writes are made */
651         mu_run_test (test_query (client, "(contains? \"any\" \"test\")", 2));
652         mu_run_test (test_query (client, "(contains? \"summary\" \"Kansas\")", 1));
653         mu_run_test (test_query (client, "(contains? \"any\" \"gibberish\")", 0));
654
655         mu_run_test (test_get_default_object (client));
656         mu_run_test (test_get_object (client));
657         mu_run_test (test_get_free_busy (client));
658         mu_run_test (test_object_creation (client, &uid));
659         mu_run_test (test_object_modification (client, uid));
660         /* mu_run_test (test_object_removal (client)); */
661         mu_run_test (test_get_alarms_in_range (client));
662
663 #if 0
664         tmp = g_strconcat (uri, "_tmp", NULL);
665         mu_run_test (test_e_cal_new (&ecal, tmp));
666         mu_run_test (test_e_cal_remove (ecal, tmp));
667         g_free (tmp);
668 #endif
669
670         test_timezones (client);
671
672         return NULL;
673 }
674
675 /* Creates a calendar client and tries to load the specified URI into it */
676 static void
677 create_client (ECal **client,
678                const gchar *uri,
679                ECalSourceType type,
680                gboolean only_if_exists)
681 {
682         const gchar *results;
683         ECalView *query;
684         gchar *cal_uri;
685         GError *error = NULL;
686
687         cal_uri = g_strconcat ("file://", uri, NULL);
688         /* FIXME We don't build ECals from URIs anymore. */
689         /* *client = e_cal_new_from_uri (cal_uri, type); */
690         *client = NULL;
691         if (!*client) {
692                 g_message (G_STRLOC ": could not create the client");
693                 exit (1);
694         }
695
696         g_object_weak_ref (G_OBJECT (*client), client_destroy_cb, NULL);
697
698         cl_printf (*client, "Calendar loading `%s'...\n", uri);
699
700         if (!e_cal_open (*client, only_if_exists, &error)) {
701                 cl_printf (*client, "Load/create %s\n", error->message);
702                 exit (1);
703         }
704         g_clear_error (&error);
705
706         if (!e_cal_get_query (*client, "(contains? \"any\" \"Event\")", &query, NULL)) {
707                 cl_printf (*client, G_STRLOC ": Unable to obtain query");
708                 exit (1);
709         }
710
711         g_signal_connect (G_OBJECT (query), "objects_added",
712                           G_CALLBACK (objects_added_cb), client);
713         g_signal_connect (G_OBJECT (query), "objects_modified",
714                           G_CALLBACK (objects_modified_cb), client);
715         g_signal_connect (G_OBJECT (query), "objects_removed",
716                           G_CALLBACK (objects_removed_cb), client);
717         g_signal_connect (G_OBJECT (query), "view_complete",
718                           G_CALLBACK (view_complete_cb), client);
719
720         e_cal_view_start (query);
721
722         results = all_tests (*client, uri);
723         cl_printf (*client, "\n\n\n*************Tests run: %d****************\n\n", tests_run);
724         cl_printf (*client, "*************Tests passed: %d*************\n\n\n", tests_passed);
725         if (results != NULL)
726                 cl_printf (*client, "***Failures********%s\n", results);
727
728         cl_printf (*client, "dump of the test calendar data");
729         list_uids (*client);
730         g_free (cal_uri);
731
732 }
733
734 gint
735 main (gint argc,
736       gchar **argv)
737 {
738         gchar *uri;
739         bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
740         textdomain (GETTEXT_PACKAGE);
741
742         g_type_init ();
743         loop = g_main_loop_new (NULL, TRUE);
744
745         /* arg1- file name; arg2- client suffix */
746         uri = g_strconcat (argv[1], argv[2], NULL);
747         create_client (&client1, uri, E_CAL_SOURCE_TYPE_EVENT, FALSE);
748
749         g_free (uri);
750         g_main_loop_run (loop);
751         return 0;
752 }