diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-08-08 05:38:28 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-08-08 05:38:28 +0800 |
commit | 4de1f796a496703b01bcc0a8245030e4fbc378b8 (patch) | |
tree | 9817b8c5b886275946ae6aba5fc3b4f643ec82b4 /calendar/cal-client/client-test.c | |
parent | 3d4dc806bfa5832e7d91218b50512e672e377791 (diff) | |
download | gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.gz gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.bz2 gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.lz gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.xz gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.zst gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.zip |
Big sync. Disable calendar compilation for a few hours - Federico
2000-08-07 Federico Mena Quintero <federico@helixcode.com>
* cal-util/cal-component.c (cal_component_get_as_string): Doh,
libical owns the string's memory, so do not free it.
* cal-client/client-test.c (create_client): Connect to the destroy
signal of the client here.
* cal-client/test.ics: New test file, modified from Eric Busboom's
test file from RFC 2445.
2000-08-05 Federico Mena Quintero <federico@helixcode.com>
* cal-client/client-test.c (dump_component): This was gone for
some reason.
(main): Load a new test file.
2000-08-04 Federico Mena Quintero <federico@helixcode.com>
* cal-util/cal-component.c (cal_component_commit_sequence): New
function to commit changes to the SEQUENCE property.
(cal_component_get_as_string): Ensure that the sequence has been
committed.
* cal-client/cal-client.c (cal_client_get_object): Use
CalComponent instead of the old iCalObject.
(cal_client_update_object): Use iCalObject. Commit the SEQUENCE
property before stringifying the object and piping it over to the
Wombat.
svn path=/trunk/; revision=4585
Diffstat (limited to 'calendar/cal-client/client-test.c')
-rw-r--r-- | calendar/cal-client/client-test.c | 118 |
1 files changed, 75 insertions, 43 deletions
diff --git a/calendar/cal-client/client-test.c b/calendar/cal-client/client-test.c index f8741f4539..7f79b58266 100644 --- a/calendar/cal-client/client-test.c +++ b/calendar/cal-client/client-test.c @@ -1,8 +1,29 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* Evolution calendar client - test program + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: Federico Mena-Quintero <federico@helixcode.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + #include <config.h> #include <bonobo.h> #include <gnome.h> #include <cal-client/cal-client.h> + static CalClient *client1; static CalClient *client2; @@ -21,6 +42,26 @@ cl_printf (CalClient *client, const char *format, ...) va_end (args); } +/* Dumps some interesting data from a component */ +static void +dump_component (CalComponent *comp) +{ + const char *uid; + CalComponentText summary; + + cal_component_get_uid (comp, &uid); + + printf ("UID %s\n", uid); + + cal_component_get_summary (comp, &summary); + if (summary.value) + printf ("\tSummary: `%s', altrep `%s'\n", + summary.value, + summary.altrep ? summary.altrep : "NONE"); + else + printf ("\tNo summary\n"); +} + /* Lists the UIDs of objects in a calendar, called as an idle handler */ static gboolean list_uids (gpointer data) @@ -49,22 +90,20 @@ list_uids (gpointer data) for (l = uids; l; l = l->next) { char *uid; - iCalObject *ico; + CalComponent *comp; CalClientGetStatus status; uid = l->data; - status = cal_client_get_object (client, uid, &ico); + status = cal_client_get_object (client, uid, &comp); if (status == CAL_CLIENT_GET_SUCCESS) { printf ("------------------------------\n"); - dump_icalobject (ico); + dump_component (comp); printf ("------------------------------\n"); + gtk_object_unref (GTK_OBJECT (comp)); } else { printf ("FAILED: %d\n", status); } - - // cal_client_update_object (client, uid, calobj); - // g_free (calobj); } } @@ -98,32 +137,50 @@ obj_updated (CalClient *client, const char *uid, gpointer data) cl_printf (client, "Object updated: %s\n", uid); } +/* Callback used when a client is destroyed */ +static void +client_destroy_cb (GtkObject *object, gpointer data) +{ + if (CAL_CLIENT (object) == client1) + client1 = NULL; + else if (CAL_CLIENT (object) == client2) + client2 = NULL; + else + g_assert_not_reached (); + + if (!client1 && !client2) + gtk_main_quit (); +} + /* Creates a calendar client and tries to load the specified URI into it */ -static CalClient * -create_client (const char *uri, gboolean load) +static void +create_client (CalClient **client, const char *uri, gboolean load) { - CalClient *client; gboolean result; - client = cal_client_new (); - if (!client) { + *client = cal_client_new (); + if (!*client) { g_message ("create_client(): could not create the client"); exit (1); } - gtk_signal_connect (GTK_OBJECT (client), "cal_loaded", + gtk_signal_connect (GTK_OBJECT (*client), "destroy", + client_destroy_cb, + NULL); + + gtk_signal_connect (GTK_OBJECT (*client), "cal_loaded", GTK_SIGNAL_FUNC (cal_loaded), NULL); - gtk_signal_connect (GTK_OBJECT (client), "obj_updated", + gtk_signal_connect (GTK_OBJECT (*client), "obj_updated", GTK_SIGNAL_FUNC (obj_updated), NULL); printf ("Calendar loading `%s'...\n", uri); if (load) - result = cal_client_load_calendar (client, uri); + result = cal_client_load_calendar (*client, uri); else - result = cal_client_create_calendar (client, uri); + result = cal_client_create_calendar (*client, uri); if (!result) { g_message ("create_client(): failure when issuing calendar %s request `%s'", @@ -131,23 +188,6 @@ create_client (const char *uri, gboolean load) uri); exit (1); } - - return client; -} - -/* Callback used when a client is destroyed */ -static void -client_destroy_cb (GtkObject *object, gpointer data) -{ - if (CAL_CLIENT (object) == client1) - client1 = NULL; - else if (CAL_CLIENT (object) == client2) - client2 = NULL; - else - g_assert_not_reached (); - - if (!client1 && !client2) - gtk_main_quit (); } #ifdef USING_OAF @@ -195,17 +235,9 @@ main (int argc, char **argv) exit (1); } - client1 = create_client ("/cvs/evolution/calendar/gui/test2.vcf", TRUE); - gtk_signal_connect (GTK_OBJECT (client1), "destroy", - client_destroy_cb, - NULL); - - client2 = create_client ("/cvs/evolution/calendar/gui/test2.vcf", FALSE); - gtk_signal_connect (GTK_OBJECT (client2), "destroy", - client_destroy_cb, - NULL); + create_client (&client1, "/cvs/evolution/calendar/cal-client/test.ics", TRUE); + create_client (&client2, "/cvs/evolution/calendar/cal-client/test.ics", FALSE); bonobo_main (); - return 0; } |