From 200606f92810d3de322e5ee96f8326e1a656f8bb Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 7 Nov 2003 05:52:24 +0000 Subject: Various changes to merge in evolution-data-server reliance. svn path=/trunk/; revision=23206 --- calendar/pcs/.cvsignore | 11 - calendar/pcs/Makefile.am | 92 -- calendar/pcs/cal-backend-file-events.c | 145 --- calendar/pcs/cal-backend-file-events.h | 61 - calendar/pcs/cal-backend-file-todos.c | 135 --- calendar/pcs/cal-backend-file-todos.h | 61 - calendar/pcs/cal-backend-file.c | 1988 -------------------------------- calendar/pcs/cal-backend-file.h | 65 -- calendar/pcs/cal-backend-http.c | 621 ---------- calendar/pcs/cal-backend-http.h | 61 - calendar/pcs/cal-backend-object-sexp.c | 1007 ---------------- calendar/pcs/cal-backend-object-sexp.h | 67 -- calendar/pcs/cal-backend-sync.c | 607 ---------- calendar/pcs/cal-backend-sync.h | 143 --- calendar/pcs/cal-backend-util.c | 61 - calendar/pcs/cal-backend-util.h | 42 - calendar/pcs/cal-backend.c | 1199 ------------------- calendar/pcs/cal-backend.h | 178 --- calendar/pcs/cal-common.h | 47 - calendar/pcs/cal-factory.c | 482 -------- calendar/pcs/cal-factory.h | 74 -- calendar/pcs/cal.c | 1244 -------------------- calendar/pcs/cal.h | 111 -- calendar/pcs/query.c | 492 -------- calendar/pcs/query.h | 81 -- 25 files changed, 9075 deletions(-) delete mode 100644 calendar/pcs/.cvsignore delete mode 100644 calendar/pcs/Makefile.am delete mode 100644 calendar/pcs/cal-backend-file-events.c delete mode 100644 calendar/pcs/cal-backend-file-events.h delete mode 100644 calendar/pcs/cal-backend-file-todos.c delete mode 100644 calendar/pcs/cal-backend-file-todos.h delete mode 100644 calendar/pcs/cal-backend-file.c delete mode 100644 calendar/pcs/cal-backend-file.h delete mode 100644 calendar/pcs/cal-backend-http.c delete mode 100644 calendar/pcs/cal-backend-http.h delete mode 100644 calendar/pcs/cal-backend-object-sexp.c delete mode 100644 calendar/pcs/cal-backend-object-sexp.h delete mode 100644 calendar/pcs/cal-backend-sync.c delete mode 100644 calendar/pcs/cal-backend-sync.h delete mode 100644 calendar/pcs/cal-backend-util.c delete mode 100644 calendar/pcs/cal-backend-util.h delete mode 100644 calendar/pcs/cal-backend.c delete mode 100644 calendar/pcs/cal-backend.h delete mode 100644 calendar/pcs/cal-common.h delete mode 100644 calendar/pcs/cal-factory.c delete mode 100644 calendar/pcs/cal-factory.h delete mode 100644 calendar/pcs/cal.c delete mode 100644 calendar/pcs/cal.h delete mode 100644 calendar/pcs/query.c delete mode 100644 calendar/pcs/query.h (limited to 'calendar/pcs') diff --git a/calendar/pcs/.cvsignore b/calendar/pcs/.cvsignore deleted file mode 100644 index ac51a554db..0000000000 --- a/calendar/pcs/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -.pure -*.la -*.lo -evolution-calendar-stubs.c -evolution-calendar-skels.c -evolution-calendar-common.c -evolution-calendar.h diff --git a/calendar/pcs/Makefile.am b/calendar/pcs/Makefile.am deleted file mode 100644 index 0e47694cee..0000000000 --- a/calendar/pcs/Makefile.am +++ /dev/null @@ -1,92 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"wombat-pcs\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_builddir)/calendar \ - -I$(top_srcdir)/libical/src \ - -I$(top_builddir)/libical/src \ - -I$(top_srcdir)/libwombat \ - -I$(top_builddir)/libwombat \ - $(EVOLUTION_CALENDAR_CFLAGS) - -AM_CFLAGS = \ - -DGTK_DISABLE_DEPRECATED=1 \ - -DGDK_DISABLE_DEPRECATED=1 \ - -DG_DISABLE_DEPRECATED=1 \ - -DGNOME_DISABLE_DEPRECATED=1 - -CORBA_GENERATED_H = \ - evolution-calendar.h - -CORBA_GENERATED_C = \ - evolution-calendar-common.c \ - evolution-calendar-skels.c \ - evolution-calendar-stubs.c - -CORBA_GENERATED = $(CORBA_GENERATED_H) $(CORBA_GENERATED_C) - -idls = \ - $(srcdir)/../idl/evolution-calendar.idl - -idl_flags = -I $(srcdir) $(IDL_INCLUDES) - -$(CORBA_GENERATED_H): $(idls) - $(ORBIT_IDL) $(idl_flags) $(srcdir)/../idl/evolution-calendar.idl - -$(CORBA_GENERATED_C): $(CORBA_GENERATED_H) - -pcsincludedir = $(privincludedir)/pcs - -privlib_LTLIBRARIES = libpcs.la -noinst_LTLIBRARIES = libpcsfile.la libpcshttp.la - -pcsinclude_HEADERS = \ - $(CORBA_GENERATED_H) \ - cal.h \ - cal-backend.h \ - cal-backend-sync.h \ - cal-backend-util.h \ - cal-backend-object-sexp.h\ - cal-common.h \ - cal-factory.h \ - query.h - -libpcs_la_SOURCES = \ - $(pcsinclude_HEADERS) \ - $(CORBA_GENERATED_C) \ - cal.c \ - cal-backend.c \ - cal-backend-sync.c \ - cal-backend-util.c \ - cal-backend-object-sexp.c\ - cal-factory.c \ - query.c - -libpcs_la_LIBADD = \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ - $(top_builddir)/e-util/libeutil.la - -libpcsfile_la_SOURCES = \ - cal-backend-file-events.c\ - cal-backend-file-events.h\ - cal-backend-file-todos.c\ - cal-backend-file-todos.h\ - cal-backend-file.c \ - cal-backend-file.h - -libpcsfile_la_LIBADD = \ - libpcs.la - -libpcshttp_la_SOURCES = \ - cal-backend-http.c \ - cal-backend-http.h - -libpcshttp_la_LIBADD = \ - libpcs.la - -BUILT_SOURCES = $(CORBA_GENERATED) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - diff --git a/calendar/pcs/cal-backend-file-events.c b/calendar/pcs/cal-backend-file-events.c deleted file mode 100644 index a7cf56fac6..0000000000 --- a/calendar/pcs/cal-backend-file-events.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 -#include -#include -#include -#include -#include -#include -#include "e-util/e-xml-hash-utils.h" -#include "cal-util/cal-recur.h" -#include "cal-util/cal-util.h" -#include "cal-backend-file-events.h" -#include "cal-backend-util.h" - - - -/* Private part of the CalBackendFileEvents structure */ -struct _CalBackendFileEventsPrivate { -}; - - - -static void cal_backend_file_events_class_init (CalBackendFileEventsClass *class); -static void cal_backend_file_events_init (CalBackendFileEvents *cbfile, CalBackendFileEventsClass *class); -static void cal_backend_file_events_dispose (GObject *object); -static void cal_backend_file_events_finalize (GObject *object); - -static GObjectClass *parent_class; - - - -/** - * cal_backend_file_events_get_type: - * @void: - * - * Registers the #CalBackendFileEvents class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendFileEvents class. - **/ -GType -cal_backend_file_events_get_type (void) -{ - static GType cal_backend_file_events_type = 0; - - if (!cal_backend_file_events_type) { - static GTypeInfo info = { - sizeof (CalBackendFileEventsClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_file_events_class_init, - NULL, NULL, - sizeof (CalBackendFileEvents), - 0, - (GInstanceInitFunc) cal_backend_file_events_init - }; - cal_backend_file_events_type = g_type_register_static (CAL_BACKEND_FILE_TYPE, - "CalBackendFileEvents", &info, 0); - } - - return cal_backend_file_events_type; -} - -/* Class initialization function for the file backend */ -static void -cal_backend_file_events_class_init (CalBackendFileEventsClass *klass) -{ - GObjectClass *object_class; - CalBackendClass *backend_class; - - object_class = G_OBJECT_CLASS (klass); - backend_class = CAL_BACKEND_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = cal_backend_file_events_dispose; - object_class->finalize = cal_backend_file_events_finalize; - -// backend_class->get_uri = cal_backend_file_events_get_uri; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_file_events_init (CalBackendFileEvents *cbfile, CalBackendFileEventsClass *class) -{ - CalBackendFileEventsPrivate *priv; - - priv = g_new0 (CalBackendFileEventsPrivate, 1); - cbfile->priv = priv; - - cal_backend_file_set_file_name (CAL_BACKEND_FILE (cbfile), "calendar.ics"); -} - -/* Dispose handler for the file backend */ -static void -cal_backend_file_events_dispose (GObject *object) -{ - CalBackendFileEvents *cbfile; - CalBackendFileEventsPrivate *priv; - - cbfile = CAL_BACKEND_FILE_EVENTS (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the file backend */ -static void -cal_backend_file_events_finalize (GObject *object) -{ - CalBackendFileEvents *cbfile; - CalBackendFileEventsPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE_EVENTS (object)); - - cbfile = CAL_BACKEND_FILE_EVENTS (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - diff --git a/calendar/pcs/cal-backend-file-events.h b/calendar/pcs/cal-backend-file-events.h deleted file mode 100644 index 3f812b3e09..0000000000 --- a/calendar/pcs/cal-backend-file-events.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_BACKEND_FILE_EVENTS_H -#define CAL_BACKEND_FILE_EVENTS_H - -#include "cal-backend-file.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_FILE_EVENTS_TYPE (cal_backend_file_events_get_type ()) -#define CAL_BACKEND_FILE_EVENTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_FILE_EVENTS_TYPE, \ - CalBackendFileEvents)) -#define CAL_BACKEND_FILE_EVENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_FILE_EVENTS_TYPE, \ - CalBackendFileEventsClass)) -#define IS_CAL_BACKEND_FILE_EVENTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_FILE_EVENTS_TYPE)) -#define IS_CAL_BACKEND_FILE_EVENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_FILE_EVENTS_TYPE)) - -typedef struct _CalBackendFileEvents CalBackendFileEvents; -typedef struct _CalBackendFileEventsClass CalBackendFileEventsClass; - -typedef struct _CalBackendFileEventsPrivate CalBackendFileEventsPrivate; - -struct _CalBackendFileEvents { - CalBackendFile backend; - - /* Private data */ - CalBackendFileEventsPrivate *priv; -}; - -struct _CalBackendFileEventsClass { - CalBackendFileClass parent_class; -}; - -GType cal_backend_file_events_get_type (void); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-file-todos.c b/calendar/pcs/cal-backend-file-todos.c deleted file mode 100644 index 6f56dd1776..0000000000 --- a/calendar/pcs/cal-backend-file-todos.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Evolution calendar - iCalendar file backend for tasks - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 -#include "cal-backend-file-todos.h" - - - -/* Private part of the CalBackendFileTodos structure */ -struct _CalBackendFileTodosPrivate { -}; - - - -static void cal_backend_file_todos_class_init (CalBackendFileTodosClass *class); -static void cal_backend_file_todos_init (CalBackendFileTodos *cbfile, CalBackendFileTodosClass *class); -static void cal_backend_file_todos_dispose (GObject *object); -static void cal_backend_file_todos_finalize (GObject *object); - -static CalBackendFileClass *parent_class; - - - -/** - * cal_backend_file_todos_get_type: - * @void: - * - * Registers the #CalBackendFileTodos class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendFileTodos class. - **/ -GType -cal_backend_file_todos_get_type (void) -{ - static GType cal_backend_file_todos_type = 0; - - if (!cal_backend_file_todos_type) { - static GTypeInfo info = { - sizeof (CalBackendFileTodosClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_file_todos_class_init, - NULL, NULL, - sizeof (CalBackendFileTodos), - 0, - (GInstanceInitFunc) cal_backend_file_todos_init - }; - cal_backend_file_todos_type = g_type_register_static (CAL_BACKEND_FILE_TYPE, - "CalBackendFileTodos", &info, 0); - } - - return cal_backend_file_todos_type; -} - -/* Class initialization function for the file backend */ -static void -cal_backend_file_todos_class_init (CalBackendFileTodosClass *klass) -{ - GObjectClass *object_class; - CalBackendClass *backend_class; - - object_class = G_OBJECT_CLASS (klass); - backend_class = CAL_BACKEND_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = cal_backend_file_todos_dispose; - object_class->finalize = cal_backend_file_todos_finalize; - -// backend_class->get_uri = cal_backend_file_todos_get_uri; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_file_todos_init (CalBackendFileTodos *cbfile, CalBackendFileTodosClass *class) -{ - CalBackendFileTodosPrivate *priv; - - priv = g_new0 (CalBackendFileTodosPrivate, 1); - cbfile->priv = priv; - - cal_backend_file_set_file_name (CAL_BACKEND_FILE (cbfile), "tasks.ics"); -} - -/* Dispose handler for the file backend */ -static void -cal_backend_file_todos_dispose (GObject *object) -{ - CalBackendFileTodos *cbfile; - CalBackendFileTodosPrivate *priv; - - cbfile = CAL_BACKEND_FILE_TODOS (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the file backend */ -static void -cal_backend_file_todos_finalize (GObject *object) -{ - CalBackendFileTodos *cbfile; - CalBackendFileTodosPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE_TODOS (object)); - - cbfile = CAL_BACKEND_FILE_TODOS (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - diff --git a/calendar/pcs/cal-backend-file-todos.h b/calendar/pcs/cal-backend-file-todos.h deleted file mode 100644 index 7f17122673..0000000000 --- a/calendar/pcs/cal-backend-file-todos.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_BACKEND_FILE_TODOS_H -#define CAL_BACKEND_FILE_TODOS_H - -#include "cal-backend-file.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_FILE_TODOS_TYPE (cal_backend_file_todos_get_type ()) -#define CAL_BACKEND_FILE_TODOS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_FILE_TODOS_TYPE, \ - CalBackendFileTodos)) -#define CAL_BACKEND_FILE_TODOS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_FILE_TODOS_TYPE, \ - CalBackendFileTodosClass)) -#define IS_CAL_BACKEND_FILE_TODOS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_FILE_TODOS_TYPE)) -#define IS_CAL_BACKEND_FILE_TODOS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_FILE_TODOS_TYPE)) - -typedef struct _CalBackendFileTodos CalBackendFileTodos; -typedef struct _CalBackendFileTodosClass CalBackendFileTodosClass; - -typedef struct _CalBackendFileTodosPrivate CalBackendFileTodosPrivate; - -struct _CalBackendFileTodos { - CalBackendFile backend; - - /* Private data */ - CalBackendFileTodosPrivate *priv; -}; - -struct _CalBackendFileTodosClass { - CalBackendFileClass parent_class; -}; - -GType cal_backend_file_todos_get_type (void); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c deleted file mode 100644 index a3cd2c360f..0000000000 --- a/calendar/pcs/cal-backend-file.c +++ /dev/null @@ -1,1988 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000-2003 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 -#include -#include -#include -#include -#include -#include -#include "e-util/e-xml-hash-utils.h" -#include "cal-util/cal-recur.h" -#include "cal-util/cal-util.h" -#include "cal-backend-file-events.h" -#include "cal-backend-util.h" -#include "cal-backend-object-sexp.h" - - - -/* Placeholder for each component and its recurrences */ -typedef struct { - CalComponent *full_object; - GHashTable *recurrences; -} CalBackendFileObject; - -/* Private part of the CalBackendFile structure */ -struct _CalBackendFilePrivate { - /* URI where the calendar data is stored */ - char *uri; - - /* Filename in the dir */ - char *file_name; - gboolean read_only; - - /* Toplevel VCALENDAR component */ - icalcomponent *icalcomp; - - /* All the objects in the calendar, hashed by UID. The - * hash key *is* the uid returned by cal_component_get_uid(); it is not - * copied, so don't free it when you remove an object from the hash - * table. Each item in the hash table is a CalBackendFileObject. - */ - GHashTable *comp_uid_hash; - - GList *comp; - - /* Config database handle for free/busy organizer information */ - EConfigListener *config_listener; - - /* The calendar's default timezone, used for resolving DATE and - floating DATE-TIME values. */ - icaltimezone *default_zone; - - /* The list of live queries */ - GList *queries; -}; - - - -static void cal_backend_file_dispose (GObject *object); -static void cal_backend_file_finalize (GObject *object); - -static CalBackendSyncClass *parent_class; - - - -/* g_hash_table_foreach() callback to destroy recurrences in the hash table */ -static void -free_recurrence (gpointer key, gpointer value, gpointer data) -{ - char *rid = key; - CalComponent *comp = value; - - g_free (rid); - g_object_unref (comp); -} - -/* g_hash_table_foreach() callback to destroy a CalBackendFileObject */ -static void -free_object (gpointer key, gpointer value, gpointer data) -{ - CalBackendFileObject *obj_data = value; - - g_object_unref (obj_data->full_object); - g_hash_table_foreach (obj_data->recurrences, (GHFunc) free_recurrence, NULL); - g_hash_table_destroy (obj_data->recurrences); -} - -/* Saves the calendar data */ -static void -save (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - GnomeVFSURI *uri, *backup_uri; - GnomeVFSHandle *handle = NULL; - GnomeVFSResult result = GNOME_VFS_ERROR_BAD_FILE; - GnomeVFSFileSize out; - gchar *tmp, *backup_uristr; - char *buf; - - priv = cbfile->priv; - g_assert (priv->uri != NULL); - g_assert (priv->icalcomp != NULL); - - uri = gnome_vfs_uri_new (priv->uri); - if (!uri) - goto error_malformed_uri; - - /* save calendar to backup file */ - tmp = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); - if (!tmp) { - gnome_vfs_uri_unref (uri); - goto error_malformed_uri; - } - - backup_uristr = g_strconcat (tmp, "~", NULL); - backup_uri = gnome_vfs_uri_new (backup_uristr); - - g_free (tmp); - g_free (backup_uristr); - - if (!backup_uri) { - gnome_vfs_uri_unref (uri); - goto error_malformed_uri; - } - - result = gnome_vfs_create_uri (&handle, backup_uri, - GNOME_VFS_OPEN_WRITE, - FALSE, 0666); - if (result != GNOME_VFS_OK) { - gnome_vfs_uri_unref (uri); - gnome_vfs_uri_unref (backup_uri); - goto error; - } - - buf = icalcomponent_as_ical_string (priv->icalcomp); - result = gnome_vfs_write (handle, buf, strlen (buf) * sizeof (char), &out); - gnome_vfs_close (handle); - if (result != GNOME_VFS_OK) { - gnome_vfs_uri_unref (uri); - gnome_vfs_uri_unref (backup_uri); - goto error; - } - - /* now copy the temporary file to the real file */ - result = gnome_vfs_move_uri (backup_uri, uri, TRUE); - - gnome_vfs_uri_unref (uri); - gnome_vfs_uri_unref (backup_uri); - if (result != GNOME_VFS_OK) - goto error; - - return; - - error_malformed_uri: - cal_backend_notify_error (CAL_BACKEND (cbfile), - _("Can't save calendar data: Malformed URI.")); - return; - - error: - cal_backend_notify_error (CAL_BACKEND (cbfile), gnome_vfs_result_to_string (result)); - return; -} - -/* Dispose handler for the file backend */ -static void -cal_backend_file_dispose (GObject *object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (object); - priv = cbfile->priv; - - /* Save if necessary */ - - if (priv->comp_uid_hash) { - g_hash_table_foreach (priv->comp_uid_hash, (GHFunc) free_object, NULL); - g_hash_table_destroy (priv->comp_uid_hash); - priv->comp_uid_hash = NULL; - } - - g_list_free (priv->comp); - priv->comp = NULL; - - if (priv->icalcomp) { - icalcomponent_free (priv->icalcomp); - priv->icalcomp = NULL; - } - - if (priv->config_listener) { - g_object_unref (priv->config_listener); - priv->config_listener = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the file backend */ -static void -cal_backend_file_finalize (GObject *object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE (object)); - - cbfile = CAL_BACKEND_FILE (object); - priv = cbfile->priv; - - /* Clean up */ - - if (priv->uri) { - g_free (priv->uri); - priv->uri = NULL; - } - - g_free (priv); - cbfile->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - - -/* Looks up a component by its UID on the backend's component hash table */ -static CalComponent * -lookup_component (CalBackendFile *cbfile, const char *uid) -{ - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - - priv = cbfile->priv; - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - return obj_data ? obj_data->full_object : NULL; -} - - - -/* Calendar backend methods */ - -/* Is_read_only handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_is_read_only (CalBackendSync *backend, Cal *cal, gboolean *read_only) -{ - CalBackendFile *cbfile = (CalBackendFile *) backend; - - *read_only = cbfile->priv->read_only; - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_email_address handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_cal_address (CalBackendSync *backend, Cal *cal, char **address) -{ - /* A file backend has no particular email address associated - * with it (although that would be a useful feature some day). - */ - *address = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_get_ldap_attribute (CalBackendSync *backend, Cal *cal, char **attribute) -{ - *attribute = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_get_alarm_email_address (CalBackendSync *backend, Cal *cal, char **address) -{ - /* A file backend has no particular email address associated - * with it (although that would be a useful feature some day). - */ - *address = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_get_static_capabilities (CalBackendSync *backend, Cal *cal, char **capabilities) -{ - *capabilities = CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS; - - return GNOME_Evolution_Calendar_Success; -} - -/* function to resolve timezones */ -static icaltimezone * -resolve_tzid (const char *tzid, gpointer user_data) -{ - icalcomponent *vcalendar_comp = user_data; - - if (!tzid || !tzid[0]) - return NULL; - else if (!strcmp (tzid, "UTC")) - return icaltimezone_get_utc_timezone (); - - return icalcomponent_get_timezone (vcalendar_comp, tzid); -} - -/* Checks if the specified component has a duplicated UID and if so changes it */ -static void -check_dup_uid (CalBackendFile *cbfile, CalComponent *comp) -{ - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - const char *uid; - char *new_uid; - - priv = cbfile->priv; - - cal_component_get_uid (comp, &uid); - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) - return; /* Everything is fine */ - - g_message ("check_dup_uid(): Got object with duplicated UID `%s', changing it...", uid); - - new_uid = cal_component_gen_uid (); - cal_component_set_uid (comp, new_uid); - g_free (new_uid); - - /* FIXME: I think we need to reset the SEQUENCE property and reset the - * CREATED/DTSTAMP/LAST-MODIFIED. - */ - - save (cbfile); -} - -static const char * -get_rid_string (CalComponent *comp) -{ - CalComponentRange range; - struct icaltimetype tt; - - cal_component_get_recurid (comp, &range); - if (!range.datetime.value) - return "0"; - tt = *range.datetime.value; - cal_component_free_range (&range); - - return icaltime_is_valid_time (tt) && !icaltime_is_null_time (tt) ? - icaltime_as_ical_string (tt) : "0"; -} - -static struct icaltimetype -get_rid_icaltime (CalComponent *comp) -{ - CalComponentRange range; - struct icaltimetype tt; - - cal_component_get_recurid (comp, &range); - if (!range.datetime.value) - return icaltime_null_time (); - tt = *range.datetime.value; - cal_component_free_range (&range); - - return tt; -} - -/* Tries to add an icalcomponent to the file backend. We only store the objects - * of the types we support; all others just remain in the toplevel component so - * that we don't lose them. - */ -static void -add_component (CalBackendFile *cbfile, CalComponent *comp, gboolean add_to_toplevel) -{ - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - const char *uid; - GSList *categories; - - priv = cbfile->priv; - - if (cal_component_is_instance (comp)) { /* FIXME: more checks needed, to detect detached instances */ - const char *rid; - - cal_component_get_uid (comp, &uid); - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) { - g_warning (G_STRLOC ": Got an instance of a non-existing component"); - return; - } - - rid = get_rid_string (comp); - if (g_hash_table_lookup (obj_data->recurrences, rid)) { - g_warning (G_STRLOC ": Tried to adding an already existing recurrence"); - return; - } - - g_hash_table_insert (obj_data->recurrences, g_strdup (rid), comp); - } else { - /* Ensure that the UID is unique; some broken implementations spit - * components with duplicated UIDs. - */ - check_dup_uid (cbfile, comp); - cal_component_get_uid (comp, &uid); - - obj_data = g_new0 (CalBackendFileObject, 1); - obj_data->full_object = comp; - obj_data->recurrences = g_hash_table_new (g_str_hash, g_str_equal); - - g_hash_table_insert (priv->comp_uid_hash, (gpointer) uid, obj_data); - } - - priv->comp = g_list_prepend (priv->comp, comp); - - /* Put the object in the toplevel component if required */ - - if (add_to_toplevel) { - icalcomponent *icalcomp; - - icalcomp = cal_component_get_icalcomponent (comp); - g_assert (icalcomp != NULL); - - icalcomponent_add_component (priv->icalcomp, icalcomp); - } - - /* Update the set of categories */ - cal_component_get_categories_list (comp, &categories); - cal_backend_ref_categories (CAL_BACKEND (cbfile), categories); - cal_component_free_categories_list (categories); -} - -/* g_hash_table_foreach() callback to remove recurrences from the calendar */ -static void -remove_recurrence_cb (gpointer key, gpointer value, gpointer data) -{ - GList *l; - GSList *categories; - icalcomponent *icalcomp; - CalBackendFilePrivate *priv; - CalComponent *comp = value; - CalBackendFile *cbfile = data; - - priv = cbfile->priv; - - /* remove the recurrence from the top-level calendar */ - icalcomp = cal_component_get_icalcomponent (comp); - g_assert (icalcomp != NULL); - - icalcomponent_remove_component (priv->icalcomp, icalcomp); - - /* remove it from our mapping */ - l = g_list_find (priv->comp, comp); - priv->comp = g_list_delete_link (priv->comp, l); - - /* update the set of categories */ - cal_component_get_categories_list (comp, &categories); - cal_backend_unref_categories (CAL_BACKEND (cbfile), categories); - cal_component_free_categories_list (categories); -} - -/* Removes a component from the backend's hash and lists. Does not perform - * notification on the clients. Also removes the component from the toplevel - * icalcomponent. - */ -static void -remove_component (CalBackendFile *cbfile, CalComponent *comp) -{ - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - const char *uid; - GList *l; - GSList *categories; - CalBackendFileObject *obj_data; - - priv = cbfile->priv; - - /* Remove the icalcomp from the toplevel */ - - icalcomp = cal_component_get_icalcomponent (comp); - g_assert (icalcomp != NULL); - - icalcomponent_remove_component (priv->icalcomp, icalcomp); - - /* Remove it from our mapping */ - - cal_component_get_uid (comp, &uid); - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) - return; - - g_hash_table_remove (priv->comp_uid_hash, uid); - - l = g_list_find (priv->comp, comp); - g_assert (l != NULL); - priv->comp = g_list_delete_link (priv->comp, l); - - /* remove the recurrences also */ - g_hash_table_foreach (obj_data->recurrences, (GHFunc) remove_recurrence_cb, cbfile); - - /* Update the set of categories */ - cal_component_get_categories_list (comp, &categories); - cal_backend_unref_categories (CAL_BACKEND (cbfile), categories); - cal_component_free_categories_list (categories); - - free_object ((gpointer) uid, (gpointer) obj_data, NULL); -} - -/* Scans the toplevel VCALENDAR component and stores the objects it finds */ -static void -scan_vcalendar (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - icalcompiter iter; - - priv = cbfile->priv; - g_assert (priv->icalcomp != NULL); - g_assert (priv->comp_uid_hash != NULL); - - for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_ANY_COMPONENT); - icalcompiter_deref (&iter) != NULL; - icalcompiter_next (&iter)) { - icalcomponent *icalcomp; - icalcomponent_kind kind; - CalComponent *comp; - - icalcomp = icalcompiter_deref (&iter); - - kind = icalcomponent_isa (icalcomp); - - if (!(kind == ICAL_VEVENT_COMPONENT - || kind == ICAL_VTODO_COMPONENT - || kind == ICAL_VJOURNAL_COMPONENT)) - continue; - - comp = cal_component_new (); - - if (!cal_component_set_icalcomponent (comp, icalcomp)) - continue; - - add_component (cbfile, comp, FALSE); - } -} - -/* Parses an open iCalendar file and loads it into the backend */ -static CalBackendSyncStatus -open_cal (CalBackendFile *cbfile, const char *uristr) -{ - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - - priv = cbfile->priv; - - icalcomp = cal_util_parse_ics_file (uristr); - if (!icalcomp) - return GNOME_Evolution_Calendar_OtherError; - - /* FIXME: should we try to demangle XROOT components and - * individual components as well? - */ - - if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) { - icalcomponent_free (icalcomp); - - return GNOME_Evolution_Calendar_OtherError; - } - - priv->icalcomp = icalcomp; - - priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); - scan_vcalendar (cbfile); - - priv->uri = g_strdup (uristr); - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -create_cal (CalBackendFile *cbfile, const char *uristr) -{ - CalBackendFilePrivate *priv; - - priv = cbfile->priv; - - /* Create the new calendar information */ - priv->icalcomp = cal_util_new_top_level (); - - /* Create our internal data */ - priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); - - priv->uri = g_strdup (uristr); - - save (cbfile); - - return GNOME_Evolution_Calendar_Success; -} - -static char * -get_uri_string (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - const char *master_uri; - char *full_uri, *str_uri; - GnomeVFSURI *uri; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - master_uri = cal_backend_get_uri (backend); - g_message (G_STRLOC ": Trying to open %s", master_uri); - - /* FIXME Check the error conditions a little more elegantly here */ - if (g_strrstr ("tasks.ics", master_uri) || g_strrstr ("calendar.ics", master_uri)) { - g_warning (G_STRLOC ": Existing file name %s", master_uri); - - return NULL; - } - - full_uri = g_strdup_printf ("%s%s%s", master_uri, G_DIR_SEPARATOR_S, priv->file_name); - uri = gnome_vfs_uri_new (full_uri); - g_free (full_uri); - - if (!uri) - return NULL; - - str_uri = gnome_vfs_uri_to_string (uri, - (GNOME_VFS_URI_HIDE_USER_NAME - | GNOME_VFS_URI_HIDE_PASSWORD - | GNOME_VFS_URI_HIDE_HOST_NAME - | GNOME_VFS_URI_HIDE_HOST_PORT - | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD)); - gnome_vfs_uri_unref (uri); - - if (!str_uri || !strlen (str_uri)) { - g_free (str_uri); - - return NULL; - } - - return str_uri; -} - -/* Open handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_open (CalBackendSync *backend, Cal *cal, gboolean only_if_exists) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - char *str_uri; - CalBackendSyncStatus status; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - /* Claim a succesful open if we are already open */ - if (priv->uri && priv->comp_uid_hash) - return GNOME_Evolution_Calendar_Success; - - str_uri = get_uri_string (CAL_BACKEND (backend)); - if (!str_uri) - return GNOME_Evolution_Calendar_OtherError; - - if (access (str_uri, R_OK) == 0) { - status = open_cal (cbfile, str_uri); - if (access (str_uri, W_OK) != 0) - priv->read_only = TRUE; - } else { - if (only_if_exists) - status = GNOME_Evolution_Calendar_NoSuchCal; - else - status = create_cal (cbfile, str_uri); - } - - g_free (str_uri); - - return status; -} - -static CalBackendSyncStatus -cal_backend_file_remove (CalBackendSync *backend, Cal *cal) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - char *str_uri; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - str_uri = get_uri_string (CAL_BACKEND (backend)); - if (!str_uri) - return GNOME_Evolution_Calendar_OtherError; - - if (access (str_uri, W_OK) != 0) { - g_free (str_uri); - - return GNOME_Evolution_Calendar_PermissionDenied; - } - - /* FIXME Remove backup file and whole directory too? */ - if (unlink (str_uri) != 0) { - g_free (str_uri); - - return GNOME_Evolution_Calendar_OtherError; - } - - g_free (str_uri); - - return GNOME_Evolution_Calendar_Success; -} - -/* is_loaded handler for the file backend */ -static gboolean -cal_backend_file_is_loaded (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - return (priv->icalcomp != NULL); -} - -/* is_remote handler for the file backend */ -static CalMode -cal_backend_file_get_mode (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - return CAL_MODE_LOCAL; -} - -/* Set_mode handler for the file backend */ -static void -cal_backend_file_set_mode (CalBackend *backend, CalMode mode) -{ - cal_backend_notify_mode (backend, - GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED, - GNOME_Evolution_Calendar_MODE_LOCAL); - -} - -static CalBackendSyncStatus -cal_backend_file_get_default_object (CalBackendSync *backend, Cal *cal, char **object) -{ - CalComponent *comp; - - comp = cal_component_new (); - - switch (cal_backend_get_kind (CAL_BACKEND (backend))) { - case ICAL_VEVENT_COMPONENT: - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - break; - case ICAL_VTODO_COMPONENT: - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - break; - case ICAL_VJOURNAL_COMPONENT: - cal_component_set_new_vtype (comp, CAL_COMPONENT_JOURNAL); - break; - default: - g_object_unref (comp); - return GNOME_Evolution_Calendar_ObjectNotFound; - } - - *object = cal_component_get_as_string (comp); - g_object_unref (comp); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_object_component handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_object (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, char **object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - CalComponent *comp = NULL; - gboolean free_comp = FALSE; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_InvalidObject); - g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - g_assert (priv->comp_uid_hash != NULL); - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) - return GNOME_Evolution_Calendar_ObjectNotFound; - - if (rid && *rid) { - comp = g_hash_table_lookup (obj_data->recurrences, rid); - if (!comp) { - icalcomponent *icalcomp; - struct icaltimetype itt; - - itt = icaltime_from_string (rid); - icalcomp = cal_util_construct_instance ( - cal_component_get_icalcomponent (obj_data->full_object), - itt); - if (!icalcomp) - return GNOME_Evolution_Calendar_ObjectNotFound; - - comp = cal_component_new (); - free_comp = TRUE; - cal_component_set_icalcomponent (comp, icalcomp); - } - } else - comp = obj_data->full_object; - - if (!comp) - return GNOME_Evolution_Calendar_ObjectNotFound; - - *object = cal_component_get_as_string (comp); - - if (free_comp) - g_object_unref (comp); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_timezone_object handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_timezone (CalBackendSync *backend, Cal *cal, const char *tzid, char **object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icaltimezone *zone; - icalcomponent *icalcomp; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - if (!strcmp (tzid, "UTC")) { - zone = icaltimezone_get_utc_timezone (); - } else { - zone = icalcomponent_get_timezone (priv->icalcomp, tzid); - if (!zone) { - zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - if (!zone) - return GNOME_Evolution_Calendar_ObjectNotFound; - } - } - - icalcomp = icaltimezone_get_component (zone); - if (!icalcomp) - return GNOME_Evolution_Calendar_InvalidObject; - - *object = g_strdup (icalcomponent_as_ical_string (icalcomp)); - - return GNOME_Evolution_Calendar_Success; -} - -/* Add_timezone handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_add_timezone (CalBackendSync *backend, Cal *cal, const char *tzobj) -{ - icalcomponent *tz_comp; - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = (CalBackendFile *) backend; - - g_return_val_if_fail (IS_CAL_BACKEND_FILE (cbfile), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError); - - priv = cbfile->priv; - - tz_comp = icalparser_parse_string (tzobj); - if (!tz_comp) - return GNOME_Evolution_Calendar_InvalidObject; - - if (icalcomponent_isa (tz_comp) == ICAL_VTIMEZONE_COMPONENT) { - icaltimezone *zone; - - zone = icaltimezone_new (); - icaltimezone_set_component (zone, tz_comp); - if (!icalcomponent_get_timezone (priv->icalcomp, - icaltimezone_get_tzid (zone))) { - icalcomponent_add_component (priv->icalcomp, tz_comp); - save (cbfile); - } - - icaltimezone_free (zone, 1); - } - - return GNOME_Evolution_Calendar_Success; -} - - -static CalBackendSyncStatus -cal_backend_file_set_default_timezone (CalBackendSync *backend, Cal *cal, const char *tzid) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icaltimezone *zone; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - - /* Look up the VTIMEZONE in our icalcomponent. */ - zone = icalcomponent_get_timezone (priv->icalcomp, tzid); - if (!zone) - return GNOME_Evolution_Calendar_ObjectNotFound; - - /* Set the default timezone to it. */ - priv->default_zone = zone; - - return GNOME_Evolution_Calendar_Success; -} - -typedef struct { - GList *obj_list; - gboolean search_needed; - const char *query; - CalBackendObjectSExp *obj_sexp; - CalBackend *backend; - icaltimezone *default_zone; -} MatchObjectData; - -static void -match_recurrence_sexp (gpointer key, gpointer value, gpointer data) -{ - CalComponent *comp = value; - MatchObjectData *match_data = data; - - if ((!match_data->search_needed) || - (cal_backend_object_sexp_match_comp (match_data->obj_sexp, comp, match_data->backend))) { - match_data->obj_list = g_list_append (match_data->obj_list, - cal_component_get_as_string (comp)); - } -} - -static void -match_object_sexp (gpointer key, gpointer value, gpointer data) -{ - CalBackendFileObject *obj_data = value; - MatchObjectData *match_data = data; - - if ((!match_data->search_needed) || - (cal_backend_object_sexp_match_comp (match_data->obj_sexp, obj_data->full_object, match_data->backend))) { - match_data->obj_list = g_list_append (match_data->obj_list, - cal_component_get_as_string (obj_data->full_object)); - - /* match also recurrences */ - g_hash_table_foreach (obj_data->recurrences, - (GHFunc) match_recurrence_sexp, - match_data); - } -} - -/* Get_objects_in_range handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_object_list (CalBackendSync *backend, Cal *cal, const char *sexp, GList **objects) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - MatchObjectData match_data; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_message (G_STRLOC ": Getting object list (%s)", sexp); - - match_data.search_needed = TRUE; - match_data.query = sexp; - match_data.obj_list = NULL; - match_data.backend = CAL_BACKEND (backend); - match_data.default_zone = priv->default_zone; - - if (!strcmp (sexp, "#t")) - match_data.search_needed = FALSE; - - match_data.obj_sexp = cal_backend_object_sexp_new (sexp); - if (!match_data.obj_sexp) - return GNOME_Evolution_Calendar_InvalidQuery; - - g_hash_table_foreach (priv->comp_uid_hash, (GHFunc) match_object_sexp, &match_data); - - *objects = match_data.obj_list; - - return GNOME_Evolution_Calendar_Success; -} - -/* get_query handler for the file backend */ -static void -cal_backend_file_start_query (CalBackend *backend, Query *query) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - MatchObjectData match_data; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_message (G_STRLOC ": Starting query (%s)", query_get_text (query)); - - /* try to match all currently existing objects */ - match_data.search_needed = TRUE; - match_data.query = query_get_text (query); - match_data.obj_list = NULL; - match_data.backend = backend; - match_data.default_zone = priv->default_zone; - - if (!strcmp (match_data.query, "#t")) - match_data.search_needed = FALSE; - - match_data.obj_sexp = query_get_object_sexp (query); - if (!match_data.obj_sexp) { - query_notify_query_done (query, GNOME_Evolution_Calendar_InvalidQuery); - return; - } - - g_hash_table_foreach (priv->comp_uid_hash, (GHFunc) match_object_sexp, &match_data); - - /* notify listeners of all objects */ - if (match_data.obj_list) { - query_notify_objects_added (query, (const GList *) match_data.obj_list); - - /* free memory */ - g_list_foreach (match_data.obj_list, (GFunc) g_free, NULL); - g_list_free (match_data.obj_list); - } - - query_notify_query_done (query, GNOME_Evolution_Calendar_Success); -} - -static gboolean -free_busy_instance (CalComponent *comp, - time_t instance_start, - time_t instance_end, - gpointer data) -{ - icalcomponent *vfb = data; - icalproperty *prop; - icalparameter *param; - struct icalperiodtype ipt; - icaltimezone *utc_zone; - - utc_zone = icaltimezone_get_utc_timezone (); - - ipt.start = icaltime_from_timet_with_zone (instance_start, FALSE, utc_zone); - ipt.end = icaltime_from_timet_with_zone (instance_end, FALSE, utc_zone); - ipt.duration = icaldurationtype_null_duration (); - - /* add busy information to the vfb component */ - prop = icalproperty_new (ICAL_FREEBUSY_PROPERTY); - icalproperty_set_freebusy (prop, ipt); - - param = icalparameter_new_fbtype (ICAL_FBTYPE_BUSY); - icalproperty_add_parameter (prop, param); - - icalcomponent_add_property (vfb, prop); - - return TRUE; -} - -static icalcomponent * -create_user_free_busy (CalBackendFile *cbfile, const char *address, const char *cn, - time_t start, time_t end) -{ - CalBackendFilePrivate *priv; - GList *l; - icalcomponent *vfb; - icaltimezone *utc_zone; - CalBackendObjectSExp *obj_sexp; - char *query; - - priv = cbfile->priv; - - /* create the (unique) VFREEBUSY object that we'll return */ - vfb = icalcomponent_new_vfreebusy (); - if (address != NULL) { - icalproperty *prop; - icalparameter *param; - - prop = icalproperty_new_organizer (address); - if (prop != NULL && cn != NULL) { - param = icalparameter_new_cn (cn); - icalproperty_add_parameter (prop, param); - } - if (prop != NULL) - icalcomponent_add_property (vfb, prop); - } - utc_zone = icaltimezone_get_utc_timezone (); - icalcomponent_set_dtstart (vfb, icaltime_from_timet_with_zone (start, FALSE, utc_zone)); - icalcomponent_set_dtend (vfb, icaltime_from_timet_with_zone (end, FALSE, utc_zone)); - - /* add all objects in the given interval */ - query = g_strdup_printf ("occur-in-time-range? %lu %lu", start, end); - obj_sexp = cal_backend_object_sexp_new (query); - g_free (query); - - if (!obj_sexp) - return vfb; - - for (l = priv->comp; l; l = l->next) { - CalComponent *comp = l->data; - icalcomponent *icalcomp, *vcalendar_comp; - icalproperty *prop; - - icalcomp = cal_component_get_icalcomponent (comp); - if (!icalcomp) - continue; - - /* If the event is TRANSPARENT, skip it. */ - prop = icalcomponent_get_first_property (icalcomp, - ICAL_TRANSP_PROPERTY); - if (prop) { - icalproperty_transp transp_val = icalproperty_get_transp (prop); - if (transp_val == ICAL_TRANSP_TRANSPARENT || - transp_val == ICAL_TRANSP_TRANSPARENTNOCONFLICT) - continue; - } - - if (!cal_backend_object_sexp_match_comp (obj_sexp, l->data, CAL_BACKEND (cbfile))) - continue; - - vcalendar_comp = icalcomponent_get_parent (icalcomp); - cal_recur_generate_instances (comp, start, end, - free_busy_instance, - vfb, - resolve_tzid, - vcalendar_comp, - priv->default_zone); - } - - return vfb; -} - -/* Get_free_busy handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_free_busy (CalBackendSync *backend, Cal *cal, GList *users, - time_t start, time_t end, GList **freebusy) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - gchar *address, *name; - icalcomponent *vfb; - char *calobj; - GList *l; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (start != -1 && end != -1, GNOME_Evolution_Calendar_InvalidRange); - g_return_val_if_fail (start <= end, GNOME_Evolution_Calendar_InvalidRange); - - *freebusy = NULL; - - if (users == NULL) { - if (cal_backend_mail_account_get_default (priv->config_listener, &address, &name)) { - vfb = create_user_free_busy (cbfile, address, name, start, end); - calobj = icalcomponent_as_ical_string (vfb); - *freebusy = g_list_append (*freebusy, g_strdup (calobj)); - icalcomponent_free (vfb); - g_free (address); - g_free (name); - } - } else { - for (l = users; l != NULL; l = l->next ) { - address = l->data; - if (cal_backend_mail_account_is_valid (priv->config_listener, address, &name)) { - vfb = create_user_free_busy (cbfile, address, name, start, end); - calobj = icalcomponent_as_ical_string (vfb); - *freebusy = g_list_append (*freebusy, g_strdup (calobj)); - icalcomponent_free (vfb); - g_free (name); - } - } - } - - return GNOME_Evolution_Calendar_Success; -} - -typedef struct -{ - CalBackendFile *backend; - icalcomponent_kind kind; - GList *deletes; - EXmlHash *ehash; -} CalBackendFileComputeChangesData; - -static void -cal_backend_file_compute_changes_foreach_key (const char *key, gpointer data) -{ - CalBackendFileComputeChangesData *be_data = data; - - if (!lookup_component (be_data->backend, key)) { - CalComponent *comp; - - comp = cal_component_new (); - if (be_data->kind == ICAL_VTODO_COMPONENT) - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - else - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - - cal_component_set_uid (comp, key); - be_data->deletes = g_list_prepend (be_data->deletes, cal_component_get_as_string (comp)); - - e_xmlhash_remove (be_data->ehash, key); - } -} - -static CalBackendSyncStatus -cal_backend_file_compute_changes (CalBackendFile *cbfile, const char *change_id, - GList **adds, GList **modifies, GList **deletes) -{ - CalBackendFilePrivate *priv; - char *filename; - EXmlHash *ehash; - CalBackendFileComputeChangesData be_data; - GList *i; - - priv = cbfile->priv; - - /* FIXME Will this always work? */ - filename = g_strdup_printf ("%s/%s.db", priv->uri, change_id); - ehash = e_xmlhash_new (filename); - g_free (filename); - - /* Calculate adds and modifies */ - for (i = priv->comp; i != NULL; i = i->next) { - const char *uid; - char *calobj; - - cal_component_get_uid (i->data, &uid); - calobj = cal_component_get_as_string (i->data); - - g_assert (calobj != NULL); - - /* check what type of change has occurred, if any */ - switch (e_xmlhash_compare (ehash, uid, calobj)) { - case E_XMLHASH_STATUS_SAME: - break; - case E_XMLHASH_STATUS_NOT_FOUND: - *adds = g_list_prepend (*adds, g_strdup (calobj)); - e_xmlhash_add (ehash, uid, calobj); - break; - case E_XMLHASH_STATUS_DIFFERENT: - *modifies = g_list_prepend (*modifies, g_strdup (calobj)); - e_xmlhash_add (ehash, uid, calobj); - break; - } - - g_free (calobj); - } - - /* Calculate deletions */ - be_data.backend = cbfile; - be_data.kind = cal_backend_get_kind (CAL_BACKEND (cbfile)); - be_data.deletes = NULL; - be_data.ehash = ehash; - e_xmlhash_foreach_key (ehash, (EXmlHashFunc)cal_backend_file_compute_changes_foreach_key, &be_data); - - *deletes = be_data.deletes; - - e_xmlhash_write (ehash); - e_xmlhash_destroy (ehash); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_changes handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_changes (CalBackendSync *backend, Cal *cal, const char *change_id, - GList **adds, GList **modifies, GList **deletes) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return cal_backend_file_compute_changes (cbfile, change_id, adds, modifies, deletes); -} - -/* Discard_alarm handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_discard_alarm (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid) -{ - /* we just do nothing with the alarm */ - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_create_object (CalBackendSync *backend, Cal *cal, const char *calobj, char **uid) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - CalComponent *comp; - const char *comp_uid; - struct icaltimetype current; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - icalcomp = icalparser_parse_string ((char *) calobj); - if (!icalcomp) - return GNOME_Evolution_Calendar_InvalidObject; - - /* FIXME Check kind with the parent */ - kind = icalcomponent_isa (icalcomp); - if (kind != ICAL_VEVENT_COMPONENT && kind != ICAL_VTODO_COMPONENT) { - icalcomponent_free (icalcomp); - return GNOME_Evolution_Calendar_InvalidObject; - } - - /* Get the UID */ - comp_uid = icalcomponent_get_uid (icalcomp); - - /* check the object is not in our cache */ - if (lookup_component (cbfile, comp_uid)) { - icalcomponent_free (icalcomp); - return GNOME_Evolution_Calendar_CardIdAlreadyExists; - } - - /* Create the cal component */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); - - /* Set the created and last modified times on the component */ - current = icaltime_from_timet (time (NULL), 0); - cal_component_set_created (comp, ¤t); - cal_component_set_last_modified (comp, ¤t); - - /* Add the object */ - add_component (cbfile, comp, TRUE); - - /* Save the file */ - save (cbfile); - - /* Return the UID */ - if (uid) - *uid = g_strdup (comp_uid); - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_modify_object (CalBackendSync *backend, Cal *cal, const char *calobj, - CalObjModType mod, char **old_object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - const char *comp_uid, *rid; - char *real_rid; - CalComponent *comp, *recurrence; - CalBackendFileObject *obj_data; - struct icaltimetype current; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - icalcomp = icalparser_parse_string ((char *) calobj); - if (!icalcomp) - return GNOME_Evolution_Calendar_InvalidObject; - - /* check kind with the parent */ - kind = icalcomponent_isa (icalcomp); - if (kind != ICAL_VEVENT_COMPONENT && kind != ICAL_VTODO_COMPONENT) { - icalcomponent_free (icalcomp); - return GNOME_Evolution_Calendar_InvalidObject; - } - - /* Get the uid */ - comp_uid = icalcomponent_get_uid (icalcomp); - - /* Get the object from our cache */ - if (!(obj_data = g_hash_table_lookup (priv->comp_uid_hash, comp_uid))) { - icalcomponent_free (icalcomp); - return GNOME_Evolution_Calendar_ObjectNotFound; - } - - /* Create the cal component */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); - - /* Set the last modified time on the component */ - current = icaltime_from_timet (time (NULL), 0); - cal_component_set_last_modified (comp, ¤t); - - /* handle mod_type */ - switch (mod) { - case CALOBJ_MOD_THIS : - rid = get_rid_string (comp); - if (!rid || !*rid) { - g_object_unref (comp); - return GNOME_Evolution_Calendar_ObjectNotFound; - } - - if (g_hash_table_lookup_extended (obj_data->recurrences, rid, - &real_rid, &recurrence)) { - /* remove the component from our data */ - icalcomponent_remove_component (priv->icalcomp, - cal_component_get_icalcomponent (recurrence)); - priv->comp = g_list_remove (priv->comp, recurrence); - g_hash_table_remove (obj_data->recurrences, rid); - - /* free memory */ - g_free (real_rid); - g_object_unref (recurrence); - } else { - char *old, *new; - - old = cal_component_get_as_string (obj_data->full_object); - - cal_util_remove_instances (cal_component_get_icalcomponent (obj_data->full_object), - get_rid_icaltime (comp), - mod); - - new = cal_component_get_as_string (obj_data->full_object); - - cal_backend_notify_object_modified (CAL_BACKEND (backend), old, new); - - g_free (old); - g_free (new); - } - - /* add the detached instance */ - g_hash_table_insert (obj_data->recurrences, g_strdup (get_rid_string (comp)), comp); - break; - case CALOBJ_MOD_THISANDPRIOR : - break; - case CALOBJ_MOD_THISANDFUTURE : - break; - case CALOBJ_MOD_ALL : - /* in this case, we blow away all recurrences, and start over - with a clean component */ - /* Remove the old version */ - remove_component (cbfile, obj_data->full_object); - - /* Add the new object */ - add_component (cbfile, comp, TRUE); - break; - } - - save (cbfile); - - if (old_object) - *old_object = cal_component_get_as_string (comp); - - return GNOME_Evolution_Calendar_Success; -} - -static void -remove_instance (CalBackendFile *cbfile, CalBackendFileObject *obj_data, const char *rid) -{ - char *hash_rid; - CalComponent *comp; - GSList *categories; - - if (!rid || !*rid) - return; - - if (g_hash_table_lookup_extended (obj_data->recurrences, rid, &hash_rid, &comp)) { - /* remove the component from our data */ - icalcomponent_remove_component (cbfile->priv->icalcomp, - cal_component_get_icalcomponent (comp)); - cbfile->priv->comp = g_list_remove (cbfile->priv->comp, comp); - g_hash_table_remove (obj_data->recurrences, rid); - - /* update the set of categories */ - cal_component_get_categories_list (comp, &categories); - cal_backend_unref_categories (CAL_BACKEND (cbfile), categories); - cal_component_free_categories_list (categories); - - /* free memory */ - g_free (hash_rid); - g_object_unref (comp); - - return; - } - - /* remove the component from our data, temporarily */ - icalcomponent_remove_component (cbfile->priv->icalcomp, - cal_component_get_icalcomponent (obj_data->full_object)); - cbfile->priv->comp = g_list_remove (cbfile->priv->comp, obj_data->full_object); - - cal_util_remove_instances (cal_component_get_icalcomponent (obj_data->full_object), - icaltime_from_string (rid), CALOBJ_MOD_THIS); - - /* add the modified object to the beginning of the list, - so that it's always before any detached instance we - might have */ - cbfile->priv->comp = g_list_prepend (cbfile->priv->comp, obj_data->full_object); -} - -typedef struct { - CalBackendFile *cbfile; - CalBackendFileObject *obj_data; - const char *rid; - CalObjModType mod; -} RemoveRecurrenceData; - -static gboolean -remove_object_instance_cb (gpointer key, gpointer value, gpointer user_data) -{ - time_t fromtt, instancett; - GSList *categories; - char *rid = key; - CalComponent *instance = value; - RemoveRecurrenceData *rrdata = user_data; - - fromtt = icaltime_as_timet (icaltime_from_string (rrdata->rid)); - instancett = icaltime_as_timet (get_rid_icaltime (instance)); - - if (fromtt > 0 && instancett > 0) { - if ((rrdata->mod == CALOBJ_MOD_THISANDPRIOR && instancett <= fromtt) || - (rrdata->mod == CALOBJ_MOD_THISANDFUTURE && instancett >= fromtt)) { - /* remove the component from our data */ - icalcomponent_remove_component (rrdata->cbfile->priv->icalcomp, - cal_component_get_icalcomponent (instance)); - rrdata->cbfile->priv->comp = g_list_remove (rrdata->cbfile->priv->comp, instance); - - /* update the set of categories */ - cal_component_get_categories_list (instance, &categories); - cal_backend_unref_categories (CAL_BACKEND (rrdata->cbfile), categories); - cal_component_free_categories_list (categories); - - /* free memory */ - g_free (rid); - g_object_unref (instance); - - return TRUE; - } - } - - return FALSE; -} - -/* Remove_object handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_remove_object (CalBackendSync *backend, Cal *cal, - const char *uid, const char *rid, - CalObjModType mod, char **object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - CalComponent *comp; - GSList *categories; - RemoveRecurrenceData rrdata; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) - return GNOME_Evolution_Calendar_ObjectNotFound; - - comp = obj_data->full_object; - - switch (mod) { - case CALOBJ_MOD_ALL : - *object = cal_component_get_as_string (comp); - remove_component (cbfile, comp); - break; - case CALOBJ_MOD_THIS : - if (!rid || !*rid) - return GNOME_Evolution_Calendar_ObjectNotFound; - - remove_instance (cbfile, obj_data, rid); - break; - case CALOBJ_MOD_THISANDPRIOR : - case CALOBJ_MOD_THISANDFUTURE : - if (!rid || !*rid) - return GNOME_Evolution_Calendar_ObjectNotFound; - - /* remove the component from our data, temporarily */ - icalcomponent_remove_component (priv->icalcomp, - cal_component_get_icalcomponent (comp)); - priv->comp = g_list_remove (priv->comp, comp); - - cal_util_remove_instances (cal_component_get_icalcomponent (comp), - icaltime_from_string (rid), mod); - - /* now remove all detached instances */ - rrdata.cbfile = cbfile; - rrdata.obj_data = obj_data; - rrdata.rid = rid; - rrdata.mod = mod; - g_hash_table_foreach_remove (obj_data->recurrences, (GHRFunc) remove_object_instance_cb, &rrdata); - - /* add the modified object to the beginning of the list, - so that it's always before any detached instance we - might have */ - priv->comp = g_list_prepend (priv->comp, comp); - break; - } - - save (cbfile); - - return GNOME_Evolution_Calendar_Success; -} - -static gboolean -cancel_received_object (CalBackendFile *cbfile, icalcomponent *icalcomp) -{ - CalComponent *old_comp; - - /* Find the old version of the component. */ - old_comp = lookup_component (cbfile, icalcomponent_get_uid (icalcomp)); - if (!old_comp) - return FALSE; - - /* And remove it */ - remove_component (cbfile, old_comp); - - return TRUE; -} - -typedef struct { - GHashTable *zones; - - gboolean found; -} CalBackendFileTzidData; - -static void -check_tzids (icalparameter *param, void *data) -{ - CalBackendFileTzidData *tzdata = data; - const char *tzid; - - tzid = icalparameter_get_tzid (param); - if (!tzid || g_hash_table_lookup (tzdata->zones, tzid)) - tzdata->found = FALSE; -} - -/* Update_objects handler for the file backend. */ -static CalBackendSyncStatus -cal_backend_file_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icalcomponent *toplevel_comp, *icalcomp = NULL; - icalcomponent_kind kind; - icalproperty_method method; - icalcomponent *subcomp; - GList *comps, *l; - CalBackendFileTzidData tzdata; - CalBackendSyncStatus status = GNOME_Evolution_Calendar_Success; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_InvalidObject); - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject); - - /* Pull the component from the string and ensure that it is sane */ - toplevel_comp = icalparser_parse_string ((char *) calobj); - if (!toplevel_comp) - return GNOME_Evolution_Calendar_InvalidObject; - - kind = icalcomponent_isa (toplevel_comp); - if (kind != ICAL_VCALENDAR_COMPONENT) { - /* If its not a VCALENDAR, make it one to simplify below */ - icalcomp = toplevel_comp; - toplevel_comp = cal_util_new_top_level (); - icalcomponent_add_component (toplevel_comp, icalcomp); - } - - method = icalcomponent_get_method (toplevel_comp); - - /* Build a list of timezones so we can make sure all the objects have valid info */ - tzdata.zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - - subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_VTIMEZONE_COMPONENT); - while (subcomp) { - icaltimezone *zone; - - zone = icaltimezone_new (); - if (icaltimezone_set_component (zone, subcomp)) - g_hash_table_insert (tzdata.zones, g_strdup (icaltimezone_get_tzid (zone)), NULL); - - subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_VTIMEZONE_COMPONENT); - } - - /* First we make sure all the components are usuable */ - comps = NULL; - subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_ANY_COMPONENT); - while (subcomp) { - /* We ignore anything except VEVENT, VTODO and VJOURNAL - components. */ - icalcomponent_kind child_kind = icalcomponent_isa (subcomp); - - switch (child_kind) { - case ICAL_VEVENT_COMPONENT: - case ICAL_VTODO_COMPONENT: - case ICAL_VJOURNAL_COMPONENT: - tzdata.found = TRUE; - icalcomponent_foreach_tzid (subcomp, check_tzids, &tzdata); - - if (!tzdata.found) { - status = GNOME_Evolution_Calendar_InvalidObject; - goto error; - } - - if (!icalcomponent_get_uid (subcomp)) { - status = GNOME_Evolution_Calendar_InvalidObject; - goto error; - } - - comps = g_list_prepend (comps, subcomp); - break; - default: - /* Ignore it */ - break; - } - - subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_ANY_COMPONENT); - } - - /* Now we manipulate the components we care about */ - for (l = comps; l; l = l->next) { - subcomp = l->data; - - switch (method) { - case ICAL_METHOD_PUBLISH: - case ICAL_METHOD_REQUEST: - /* FIXME Need to see the new create/modify stuff before we set this up */ - break; - case ICAL_METHOD_REPLY: - /* FIXME Update the status of the user, if we are the organizer */ - break; - case ICAL_METHOD_ADD: - /* FIXME This should be doable once all the recurid stuff is done */ - break; - case ICAL_METHOD_COUNTER: - status = GNOME_Evolution_Calendar_UnsupportedMethod; - goto error; - break; - case ICAL_METHOD_DECLINECOUNTER: - status = GNOME_Evolution_Calendar_UnsupportedMethod; - goto error; - break; - case ICAL_METHOD_CANCEL: - /* FIXME Do we need to remove the subcomp so it isn't merged? */ - if (cancel_received_object (cbfile, subcomp)) { - const char *calobj = icalcomponent_as_ical_string (subcomp); - cal_backend_notify_object_removed (CAL_BACKEND (backend), icalcomponent_get_uid (subcomp), calobj); - } - break; - default: - status = GNOME_Evolution_Calendar_UnsupportedMethod; - goto error; - } - } - g_list_free (comps); - - /* Merge the iCalendar components with our existing VCALENDAR, - resolving any conflicting TZIDs. */ - icalcomponent_merge_component (priv->icalcomp, toplevel_comp); - - save (cbfile); - - error: - g_hash_table_destroy (tzdata.zones); - - return status; -} - -static CalBackendSyncStatus -cal_backend_file_send_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - /* FIXME Put in a util routine to send stuff via email */ - - return GNOME_Evolution_Calendar_Success; -} - -static icaltimezone * -cal_backend_file_internal_get_default_timezone (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - return priv->default_zone; -} - -static icaltimezone * -cal_backend_file_internal_get_timezone (CalBackend *backend, const char *tzid) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icaltimezone *zone; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - if (!strcmp (tzid, "UTC")) - zone = icaltimezone_get_utc_timezone (); - else { - zone = icalcomponent_get_timezone (priv->icalcomp, tzid); - if (!zone) - zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - } - - return zone; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_file_init (CalBackendFile *cbfile, CalBackendFileClass *class) -{ - CalBackendFilePrivate *priv; - - priv = g_new0 (CalBackendFilePrivate, 1); - cbfile->priv = priv; - - priv->uri = NULL; - priv->file_name = g_strdup ("calendar.ics"); - priv->read_only = FALSE; - priv->icalcomp = NULL; - priv->comp_uid_hash = NULL; - priv->comp = NULL; - - /* The timezone defaults to UTC. */ - priv->default_zone = icaltimezone_get_utc_timezone (); - - priv->config_listener = e_config_listener_new (); -} - -/* Class initialization function for the file backend */ -static void -cal_backend_file_class_init (CalBackendFileClass *class) -{ - GObjectClass *object_class; - CalBackendClass *backend_class; - CalBackendSyncClass *sync_class; - - object_class = (GObjectClass *) class; - backend_class = (CalBackendClass *) class; - sync_class = (CalBackendSyncClass *) class; - - parent_class = (CalBackendSyncClass *) g_type_class_peek_parent (class); - - object_class->dispose = cal_backend_file_dispose; - object_class->finalize = cal_backend_file_finalize; - - sync_class->is_read_only_sync = cal_backend_file_is_read_only; - sync_class->get_cal_address_sync = cal_backend_file_get_cal_address; - sync_class->get_alarm_email_address_sync = cal_backend_file_get_alarm_email_address; - sync_class->get_ldap_attribute_sync = cal_backend_file_get_ldap_attribute; - sync_class->get_static_capabilities_sync = cal_backend_file_get_static_capabilities; - sync_class->open_sync = cal_backend_file_open; - sync_class->remove_sync = cal_backend_file_remove; - sync_class->create_object_sync = cal_backend_file_create_object; - sync_class->modify_object_sync = cal_backend_file_modify_object; - sync_class->remove_object_sync = cal_backend_file_remove_object; - sync_class->discard_alarm_sync = cal_backend_file_discard_alarm; - sync_class->receive_objects_sync = cal_backend_file_receive_objects; - sync_class->send_objects_sync = cal_backend_file_send_objects; - sync_class->get_default_object_sync = cal_backend_file_get_default_object; - sync_class->get_object_sync = cal_backend_file_get_object; - sync_class->get_object_list_sync = cal_backend_file_get_object_list; - sync_class->get_timezone_sync = cal_backend_file_get_timezone; - sync_class->add_timezone_sync = cal_backend_file_add_timezone; - sync_class->set_default_timezone_sync = cal_backend_file_set_default_timezone; - sync_class->get_freebusy_sync = cal_backend_file_get_free_busy; - sync_class->get_changes_sync = cal_backend_file_get_changes; - - backend_class->is_loaded = cal_backend_file_is_loaded; - backend_class->start_query = cal_backend_file_start_query; - backend_class->get_mode = cal_backend_file_get_mode; - backend_class->set_mode = cal_backend_file_set_mode; - - backend_class->internal_get_default_timezone = cal_backend_file_internal_get_default_timezone; - backend_class->internal_get_timezone = cal_backend_file_internal_get_timezone; -} - - -/** - * cal_backend_file_get_type: - * @void: - * - * Registers the #CalBackendFile class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendFile class. - **/ -GType -cal_backend_file_get_type (void) -{ - static GType cal_backend_file_type = 0; - - if (!cal_backend_file_type) { - static GTypeInfo info = { - sizeof (CalBackendFileClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_file_class_init, - NULL, NULL, - sizeof (CalBackendFile), - 0, - (GInstanceInitFunc) cal_backend_file_init - }; - cal_backend_file_type = g_type_register_static (CAL_TYPE_BACKEND_SYNC, - "CalBackendFile", &info, 0); - } - - return cal_backend_file_type; -} - -void -cal_backend_file_set_file_name (CalBackendFile *cbfile, const char *file_name) -{ - CalBackendFilePrivate *priv; - - g_return_if_fail (cbfile != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE (cbfile)); - g_return_if_fail (file_name != NULL); - - priv = cbfile->priv; - - if (priv->file_name) - g_free (priv->file_name); - - priv->file_name = g_strdup (file_name); -} - -const char * -cal_backend_file_get_file_name (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - - g_return_val_if_fail (cbfile != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND_FILE (cbfile), NULL); - - priv = cbfile->priv; - - return priv->file_name; -} diff --git a/calendar/pcs/cal-backend-file.h b/calendar/pcs/cal-backend-file.h deleted file mode 100644 index ebe190cb2a..0000000000 --- a/calendar/pcs/cal-backend-file.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_BACKEND_FILE_H -#define CAL_BACKEND_FILE_H - -#include "pcs/cal-backend-sync.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_FILE_TYPE (cal_backend_file_get_type ()) -#define CAL_BACKEND_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_FILE_TYPE, \ - CalBackendFile)) -#define CAL_BACKEND_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_FILE_TYPE, \ - CalBackendFileClass)) -#define IS_CAL_BACKEND_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_FILE_TYPE)) -#define IS_CAL_BACKEND_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_FILE_TYPE)) - -typedef struct _CalBackendFile CalBackendFile; -typedef struct _CalBackendFileClass CalBackendFileClass; - -typedef struct _CalBackendFilePrivate CalBackendFilePrivate; - -struct _CalBackendFile { - CalBackendSync backend; - - /* Private data */ - CalBackendFilePrivate *priv; -}; - -struct _CalBackendFileClass { - CalBackendSyncClass parent_class; -}; - -GType cal_backend_file_get_type (void); - -void cal_backend_file_set_file_name (CalBackendFile *cbfile, - const char *file_name); -const char *cal_backend_file_get_file_name (CalBackendFile *cbfile); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-http.c b/calendar/pcs/cal-backend-http.c deleted file mode 100644 index d8cc343b3f..0000000000 --- a/calendar/pcs/cal-backend-http.c +++ /dev/null @@ -1,621 +0,0 @@ -/* Evolution calendar - iCalendar http backend - * - * Copyright (C) 2003 Novell, Inc. - * - * Authors: Hans Petter Jansson - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - * - * Based in part on the file backend. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "e-util/e-xml-hash-utils.h" -#include "cal-util/cal-recur.h" -#include "cal-util/cal-util.h" -#include "cal-backend-http.h" -#include "cal-backend-file.h" -#include "cal-backend-util.h" -#include "cal-backend-object-sexp.h" - - - -/* Private part of the CalBackendHttp structure */ -struct _CalBackendHttpPrivate { - /* URI to get remote calendar data from */ - char *uri; - - /* Local/remote mode */ - CalMode mode; - - /* Cached-file backend */ - CalBackendFile file_backend; - - /* The calendar's default timezone, used for resolving DATE and - floating DATE-TIME values. */ - icaltimezone *default_zone; - - /* The list of live queries */ - GList *queries; -}; - - - -static void cal_backend_http_dispose (GObject *object); -static void cal_backend_http_finalize (GObject *object); - -static CalBackendSyncClass *parent_class; - - - -/* Dispose handler for the file backend */ -static void -cal_backend_http_dispose (GObject *object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the file backend */ -static void -cal_backend_http_finalize (GObject *object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_HTTP (object)); - - cbfile = CAL_BACKEND_HTTP (object); - priv = cbfile->priv; - - /* Clean up */ - - if (priv->uri) { - g_free (priv->uri); - priv->uri = NULL; - } - - g_free (priv); - cbfile->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - - -/* Calendar backend methods */ - -/* Is_read_only handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_is_read_only (CalBackendSync *backend, Cal *cal, gboolean *read_only) -{ - CalBackendHttp *cbfile = backend; - - *read_only = TRUE; - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_email_address handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_cal_address (CalBackendSync *backend, Cal *cal, char **address) -{ - /* A file backend has no particular email address associated - * with it (although that would be a useful feature some day). - */ - *address = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_get_ldap_attribute (CalBackendSync *backend, Cal *cal, char **attribute) -{ - *attribute = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_get_alarm_email_address (CalBackendSync *backend, Cal *cal, char **address) -{ - /* A file backend has no particular email address associated - * with it (although that would be a useful feature some day). - */ - *address = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_get_static_capabilities (CalBackendSync *backend, Cal *cal, char **capabilities) -{ - *capabilities = CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS; - - return GNOME_Evolution_Calendar_Success; -} - -/* Open handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_open (CalBackendSync *backend, Cal *cal, gboolean only_if_exists) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - char *str_uri; - CalBackendSyncStatus status = GNOME_Evolution_Calendar_NoSuchCal; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_message ("Open URI '%s'.", cal_backend_get_uri (CAL_BACKEND (cbfile))); - - return status; -} - -static CalBackendSyncStatus -cal_backend_http_remove (CalBackendSync *backend, Cal *cal) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - char *str_uri; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return GNOME_Evolution_Calendar_OtherError; -} - -/* is_loaded handler for the file backend */ -static gboolean -cal_backend_http_is_loaded (CalBackend *backend) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return FALSE; -} - -/* is_remote handler for the file backend */ -static CalMode -cal_backend_http_get_mode (CalBackend *backend) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return priv->mode; -} - -#define cal_mode_to_corba(mode) \ - (mode == CAL_MODE_LOCAL ? GNOME_Evolution_Calendar_MODE_LOCAL : \ - mode == CAL_MODE_REMOTE ? GNOME_Evolution_Calendar_MODE_REMOTE : \ - GNOME_Evolution_Calendar_MODE_ANY) - -/* Set_mode handler for the file backend */ -static void -cal_backend_http_set_mode (CalBackend *backend, CalMode mode) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - GNOME_Evolution_Calendar_CalMode set_mode; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - switch (mode) { - case CAL_MODE_LOCAL: - case CAL_MODE_REMOTE: - priv->mode = mode; - set_mode = cal_mode_to_corba (mode); - break; - case CAL_MODE_ANY: - priv->mode = CAL_MODE_REMOTE; - set_mode = GNOME_Evolution_Calendar_MODE_REMOTE; - break; - default: - set_mode = GNOME_Evolution_Calendar_MODE_ANY; - break; - } - - if (set_mode == GNOME_Evolution_Calendar_MODE_ANY) - cal_backend_notify_mode (backend, - GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED, - cal_mode_to_corba (priv->mode)); - else - cal_backend_notify_mode (backend, - GNOME_Evolution_Calendar_Listener_MODE_SET, - set_mode); -} - -static CalBackendSyncStatus -cal_backend_http_get_default_object (CalBackendSync *backend, Cal *cal, char **object) -{ - CalComponent *comp; - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_object_component handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_object (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, char **object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - CalComponent *comp = NULL; - gboolean free_comp = FALSE; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_timezone_object handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_timezone (CalBackendSync *backend, Cal *cal, const char *tzid, char **object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icaltimezone *zone; - icalcomponent *icalcomp; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Add_timezone handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_add_timezone (CalBackendSync *backend, Cal *cal, const char *tzobj) -{ - icalcomponent *tz_comp; - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = (CalBackendHttp *) backend; - - g_return_val_if_fail (IS_CAL_BACKEND_HTTP (cbfile), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError); - - priv = cbfile->priv; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_set_default_timezone (CalBackendSync *backend, Cal *cal, const char *tzid) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icaltimezone *zone; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_objects_in_range handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_object_list (CalBackendSync *backend, Cal *cal, const char *sexp, GList **objects) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return GNOME_Evolution_Calendar_Success; -} - -/* get_query handler for the file backend */ -static void -cal_backend_http_start_query (CalBackend *backend, Query *query) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; -} - -/* Get_free_busy handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_free_busy (CalBackendSync *backend, Cal *cal, GList *users, - time_t start, time_t end, GList **freebusy) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - gchar *address, *name; - icalcomponent *vfb; - char *calobj; - GList *l; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (start != -1 && end != -1, GNOME_Evolution_Calendar_InvalidRange); - g_return_val_if_fail (start <= end, GNOME_Evolution_Calendar_InvalidRange); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_changes handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_changes (CalBackendSync *backend, Cal *cal, const char *change_id, - GList **adds, GList **modifies, GList **deletes) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Discard_alarm handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_discard_alarm (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid) -{ - /* we just do nothing with the alarm */ - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_create_object (CalBackendSync *backend, Cal *cal, const char *calobj, char **uid) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - CalComponent *comp; - const char *comp_uid; - struct icaltimetype current; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_modify_object (CalBackendSync *backend, Cal *cal, const char *calobj, - CalObjModType mod, char **old_object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - const char *comp_uid; - CalComponent *comp; - struct icaltimetype current; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Remove_object handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_remove_object (CalBackendSync *backend, Cal *cal, - const char *uid, const char *rid, - CalObjModType mod, char **object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - CalComponent *comp; - char *hash_rid; - GSList *categories; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Update_objects handler for the file backend. */ -static CalBackendSyncStatus -cal_backend_http_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icalcomponent *toplevel_comp, *icalcomp = NULL; - icalcomponent_kind kind; - icalproperty_method method; - icalcomponent *subcomp; - GList *comps, *l; - CalBackendSyncStatus status = GNOME_Evolution_Calendar_Success; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject); - - return status; -} - -static CalBackendSyncStatus -cal_backend_http_send_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - /* FIXME Put in a util routine to send stuff via email */ - - return GNOME_Evolution_Calendar_Success; -} - -static icaltimezone * -cal_backend_http_internal_get_default_timezone (CalBackend *backend) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - - return priv->default_zone; -} - -static icaltimezone * -cal_backend_http_internal_get_timezone (CalBackend *backend, const char *tzid) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icaltimezone *zone; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - if (!strcmp (tzid, "UTC")) - zone = icaltimezone_get_utc_timezone (); - else { - zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - } - - return zone; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_http_init (CalBackendHttp *cbfile, CalBackendHttpClass *class) -{ - CalBackendHttpPrivate *priv; - - g_message ("Webcal backend init."); - - priv = g_new0 (CalBackendHttpPrivate, 1); - cbfile->priv = priv; - - priv->uri = NULL; - -#if 0 - priv->config_listener = e_config_listener_new (); -#endif -} - -/* Class initialization function for the file backend */ -static void -cal_backend_http_class_init (CalBackendHttpClass *class) -{ - GObjectClass *object_class; - CalBackendClass *backend_class; - CalBackendSyncClass *sync_class; - - object_class = (GObjectClass *) class; - backend_class = (CalBackendClass *) class; - sync_class = (CalBackendSyncClass *) class; - - parent_class = (CalBackendSyncClass *) g_type_class_peek_parent (class); - - object_class->dispose = cal_backend_http_dispose; - object_class->finalize = cal_backend_http_finalize; - - sync_class->is_read_only_sync = cal_backend_http_is_read_only; - sync_class->get_cal_address_sync = cal_backend_http_get_cal_address; - sync_class->get_alarm_email_address_sync = cal_backend_http_get_alarm_email_address; - sync_class->get_ldap_attribute_sync = cal_backend_http_get_ldap_attribute; - sync_class->get_static_capabilities_sync = cal_backend_http_get_static_capabilities; - sync_class->open_sync = cal_backend_http_open; - sync_class->remove_sync = cal_backend_http_remove; - sync_class->create_object_sync = cal_backend_http_create_object; - sync_class->modify_object_sync = cal_backend_http_modify_object; - sync_class->remove_object_sync = cal_backend_http_remove_object; - sync_class->discard_alarm_sync = cal_backend_http_discard_alarm; - sync_class->receive_objects_sync = cal_backend_http_receive_objects; - sync_class->send_objects_sync = cal_backend_http_send_objects; - sync_class->get_default_object_sync = cal_backend_http_get_default_object; - sync_class->get_object_sync = cal_backend_http_get_object; - sync_class->get_object_list_sync = cal_backend_http_get_object_list; - sync_class->get_timezone_sync = cal_backend_http_get_timezone; - sync_class->add_timezone_sync = cal_backend_http_add_timezone; - sync_class->set_default_timezone_sync = cal_backend_http_set_default_timezone; - sync_class->get_freebusy_sync = cal_backend_http_get_free_busy; - sync_class->get_changes_sync = cal_backend_http_get_changes; - - backend_class->is_loaded = cal_backend_http_is_loaded; - backend_class->start_query = cal_backend_http_start_query; - backend_class->get_mode = cal_backend_http_get_mode; - backend_class->set_mode = cal_backend_http_set_mode; - - backend_class->internal_get_default_timezone = cal_backend_http_internal_get_default_timezone; - backend_class->internal_get_timezone = cal_backend_http_internal_get_timezone; -} - - -/** - * cal_backend_http_get_type: - * @void: - * - * Registers the #CalBackendHttp class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendHttp class. - **/ -GType -cal_backend_http_get_type (void) -{ - static GType cal_backend_http_type = 0; - - g_message (G_STRLOC); - - if (!cal_backend_http_type) { - static GTypeInfo info = { - sizeof (CalBackendHttpClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_http_class_init, - NULL, NULL, - sizeof (CalBackendHttp), - 0, - (GInstanceInitFunc) cal_backend_http_init - }; - cal_backend_http_type = g_type_register_static (CAL_TYPE_BACKEND_SYNC, - "CalBackendHttp", &info, 0); - } - - return cal_backend_http_type; -} diff --git a/calendar/pcs/cal-backend-http.h b/calendar/pcs/cal-backend-http.h deleted file mode 100644 index 35f47cae16..0000000000 --- a/calendar/pcs/cal-backend-http.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_BACKEND_HTTP_H -#define CAL_BACKEND_HTTP_H - -#include "pcs/cal-backend-sync.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_HTTP_TYPE (cal_backend_http_get_type ()) -#define CAL_BACKEND_HTTP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_HTTP_TYPE, \ - CalBackendHttp)) -#define CAL_BACKEND_HTTP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_HTTP_TYPE, \ - CalBackendHttpClass)) -#define IS_CAL_BACKEND_HTTP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_HTTP_TYPE)) -#define IS_CAL_BACKEND_HTTP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_HTTP_TYPE)) - -typedef struct _CalBackendHttp CalBackendHttp; -typedef struct _CalBackendHttpClass CalBackendHttpClass; - -typedef struct _CalBackendHttpPrivate CalBackendHttpPrivate; - -struct _CalBackendHttp { - CalBackendSync backend; - - /* Private data */ - CalBackendHttpPrivate *priv; -}; - -struct _CalBackendHttpClass { - CalBackendSyncClass parent_class; -}; - -GType cal_backend_http_get_type (void); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-object-sexp.c b/calendar/pcs/cal-backend-object-sexp.c deleted file mode 100644 index 4bc6b78ebe..0000000000 --- a/calendar/pcs/cal-backend-object-sexp.c +++ /dev/null @@ -1,1007 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * cal-backend-card-sexp.c - * Copyright 1999, 2000, 2001, Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include -#include -#include -#include -#include - -#include "cal-backend-object-sexp.h" - -static GObjectClass *parent_class; - -typedef struct _SearchContext SearchContext; - -struct _CalBackendObjectSExpPrivate { - ESExp *search_sexp; - char *text; - SearchContext *search_context; -}; - -struct _SearchContext { - CalComponent *comp; - CalBackend *backend; -}; - -static ESExpResult * -func_time_now (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - ESExpResult *result; - - if (argc != 0) { - e_sexp_fatal_error (esexp, _("time-now expects 0 arguments")); - return NULL; - } - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = time (NULL); - - return result; -} - -/* (make-time ISODATE) - * - * ISODATE - string, ISO 8601 date/time representation - * - * Constructs a time_t value for the specified date. - */ -static ESExpResult * -func_make_time (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - const char *str; - time_t t; - ESExpResult *result; - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("make-time expects 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_STRING) { - e_sexp_fatal_error (esexp, _("make-time expects argument 1 " - "to be a string")); - return NULL; - } - str = argv[0]->value.string; - - t = time_from_isodate (str); - if (t == -1) { - e_sexp_fatal_error (esexp, _("make-time argument 1 must be an " - "ISO 8601 date/time string")); - return NULL; - } - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = t; - - return result; -} - -/* (time-add-day TIME N) - * - * TIME - time_t, base time - * N - int, number of days to add - * - * Adds the specified number of days to a time value. - * - * FIXME: TIMEZONES - need to use a timezone or daylight saving changes will - * make the result incorrect. - */ -static ESExpResult * -func_time_add_day (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - ESExpResult *result; - time_t t; - int n; - - if (argc != 2) { - e_sexp_fatal_error (esexp, _("time-add-day expects 2 arguments")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("time-add-day expects argument 1 " - "to be a time_t")); - return NULL; - } - t = argv[0]->value.time; - - if (argv[1]->type != ESEXP_RES_INT) { - e_sexp_fatal_error (esexp, _("time-add-day expects argument 2 " - "to be an integer")); - return NULL; - } - n = argv[1]->value.number; - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = time_add_day (t, n); - - return result; -} - -/* (time-day-begin TIME) - * - * TIME - time_t, base time - * - * Returns the start of the day, according to the local time. - * - * FIXME: TIMEZONES - this uses the current Unix timezone. - */ -static ESExpResult * -func_time_day_begin (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - time_t t; - ESExpResult *result; - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("time-day-begin expects 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("time-day-begin expects argument 1 " - "to be a time_t")); - return NULL; - } - t = argv[0]->value.time; - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = time_day_begin (t); - - return result; -} - -/* (time-day-end TIME) - * - * TIME - time_t, base time - * - * Returns the end of the day, according to the local time. - * - * FIXME: TIMEZONES - this uses the current Unix timezone. - */ -static ESExpResult * -func_time_day_end (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - time_t t; - ESExpResult *result; - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("time-day-end expects 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("time-day-end expects argument 1 " - "to be a time_t")); - return NULL; - } - t = argv[0]->value.time; - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = time_day_end (t); - - return result; -} - -/* (get-vtype) - * - * Returns a string indicating the type of component (VEVENT, VTODO, VJOURNAL, - * VFREEBUSY, VTIMEZONE, UNKNOWN). - */ -static ESExpResult * -func_get_vtype (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - CalComponentVType vtype; - char *str; - ESExpResult *result; - - /* Check argument types */ - - if (argc != 0) { - e_sexp_fatal_error (esexp, _("get-vtype expects 0 arguments")); - return NULL; - } - - /* Get the type */ - - vtype = cal_component_get_vtype (ctx->comp); - - switch (vtype) { - case CAL_COMPONENT_EVENT: - str = g_strdup ("VEVENT"); - break; - - case CAL_COMPONENT_TODO: - str = g_strdup ("VTODO"); - break; - - case CAL_COMPONENT_JOURNAL: - str = g_strdup ("VJOURNAL"); - break; - - case CAL_COMPONENT_FREEBUSY: - str = g_strdup ("VFREEBUSY"); - break; - - case CAL_COMPONENT_TIMEZONE: - str = g_strdup ("VTIMEZONE"); - break; - - default: - str = g_strdup ("UNKNOWN"); - break; - } - - result = e_sexp_result_new (esexp, ESEXP_RES_STRING); - result->value.string = str; - - return result; -} - -/* (occur-in-time-range? START END) - * - * START - time_t, start of the time range - * END - time_t, end of the time range - * - * Returns a boolean indicating whether the component has any occurrences in the - * specified time range. - */ -static ESExpResult * -func_occur_in_time_range (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - time_t start, end, tt; - gboolean occurs; - ESExpResult *result; - CalComponentDateTime dt; - - /* Check argument types */ - - if (argc != 2) { - e_sexp_fatal_error (esexp, _("occur-in-time-range? expects 2 arguments")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("occur-in-time-range? expects argument 1 " - "to be a time_t")); - return NULL; - } - start = argv[0]->value.time; - - if (argv[1]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("occur-in-time-range? expects argument 2 " - "to be a time_t")); - return NULL; - } - end = argv[1]->value.time; - - /* See if the object occurs in the specified time range */ - occurs = FALSE; - - cal_component_get_dtstart (ctx->comp, &dt); - if (dt.value) { - icaltimezone *zone; - - if (dt.tzid) - zone = cal_backend_internal_get_timezone (ctx->backend, dt.tzid); - else - zone = cal_backend_internal_get_default_timezone (ctx->backend); - - tt = icaltime_as_timet_with_zone (*dt.value, zone); - if (tt >= start && tt <= end) - occurs = TRUE; - else { - cal_component_get_dtend (ctx->comp, &dt); - if (dt.value) { - if (dt.tzid) - zone = cal_backend_internal_get_timezone (ctx->backend, dt.tzid); - else - zone = cal_backend_internal_get_default_timezone (ctx->backend); - - tt = icaltime_as_timet_with_zone (*dt.value, zone); - if (tt >= start && tt <= end) - occurs = TRUE; - } - } - } - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = occurs; - - return result; -} - -/* Returns whether a list of CalComponentText items matches the specified string */ -static gboolean -matches_text_list (GSList *text_list, const char *str) -{ - GSList *l; - gboolean matches; - - matches = FALSE; - - for (l = text_list; l; l = l->next) { - CalComponentText *text; - - text = l->data; - g_assert (text->value != NULL); - - if (e_utf8_strstrcasedecomp (text->value, str) != NULL) { - matches = TRUE; - break; - } - } - - return matches; -} - -/* Returns whether the comments in a component matches the specified string */ -static gboolean -matches_comment (CalComponent *comp, const char *str) -{ - GSList *list; - gboolean matches; - - cal_component_get_comment_list (comp, &list); - matches = matches_text_list (list, str); - cal_component_free_text_list (list); - - return matches; -} - -/* Returns whether the description in a component matches the specified string */ -static gboolean -matches_description (CalComponent *comp, const char *str) -{ - GSList *list; - gboolean matches; - - cal_component_get_description_list (comp, &list); - matches = matches_text_list (list, str); - cal_component_free_text_list (list); - - return matches; -} - -/* Returns whether the summary in a component matches the specified string */ -static gboolean -matches_summary (CalComponent *comp, const char *str) -{ - CalComponentText text; - - cal_component_get_summary (comp, &text); - - if (!text.value) - return FALSE; - - return e_utf8_strstrcasedecomp (text.value, str) != NULL; -} - -/* Returns whether any text field in a component matches the specified string */ -static gboolean -matches_any (CalComponent *comp, const char *str) -{ - /* As an optimization, and to make life easier for the individual - * predicate functions, see if we are looking for the empty string right - * away. - */ - if (strlen (str) == 0) - return TRUE; - - return (matches_comment (comp, str) - || matches_description (comp, str) - || matches_summary (comp, str)); -} - -/* (contains? FIELD STR) - * - * FIELD - string, name of field to match (any, comment, description, summary) - * STR - string, match string - * - * Returns a boolean indicating whether the specified field contains the - * specified string. - */ -static ESExpResult * -func_contains (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - const char *field; - const char *str; - gboolean matches; - ESExpResult *result; - - /* Check argument types */ - - if (argc != 2) { - e_sexp_fatal_error (esexp, _("contains? expects 2 arguments")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_STRING) { - e_sexp_fatal_error (esexp, _("contains? expects argument 1 " - "to be a string")); - return NULL; - } - field = argv[0]->value.string; - - if (argv[1]->type != ESEXP_RES_STRING) { - e_sexp_fatal_error (esexp, _("contains? expects argument 2 " - "to be a string")); - return NULL; - } - str = argv[1]->value.string; - - /* See if it matches */ - - if (strcmp (field, "any") == 0) - matches = matches_any (ctx->comp, str); - else if (strcmp (field, "comment") == 0) - matches = matches_comment (ctx->comp, str); - else if (strcmp (field, "description") == 0) - matches = matches_description (ctx->comp, str); - else if (strcmp (field, "summary") == 0) - matches = matches_summary (ctx->comp, str); - else { - e_sexp_fatal_error (esexp, _("contains? expects argument 1 to " - "be one of \"any\", \"summary\", \"description\"")); - return NULL; - } - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = matches; - - return result; -} - -/* (has-alarms? #f|#t) - * - * A boolean value for components that have/dont have alarms. - * - * Returns: a boolean indicating whether the component has alarms or not. - */ -static ESExpResult * -func_has_alarms (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - ESExpResult *result; - gboolean has_to_have_alarms; - - /* Check argument types */ - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("has-alarms? expects at least 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_BOOL) { - e_sexp_fatal_error (esexp, _("has-alarms? excepts argument to be a boolean")); - return NULL; - } - - has_to_have_alarms = argv[0]->value.bool; - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - - if (has_to_have_alarms && cal_component_has_alarms (ctx->comp)) - result->value.bool = TRUE; - else if (!has_to_have_alarms && !cal_component_has_alarms (ctx->comp)) - result->value.bool = TRUE; - else - result->value.bool = FALSE; - - return result; -} - -/* (has-categories? STR+) - * (has-categories? #f) - * - * STR - At least one string specifying a category - * Or you can specify a single #f (boolean false) value for components - * that have no categories assigned to them ("unfiled"). - * - * Returns a boolean indicating whether the component has all the specified - * categories. - */ -static ESExpResult * -func_has_categories (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - gboolean unfiled; - int i; - GSList *categories; - gboolean matches; - ESExpResult *result; - - /* Check argument types */ - - if (argc < 1) { - e_sexp_fatal_error (esexp, _("has-categories? expects at least 1 argument")); - return NULL; - } - - if (argc == 1 && argv[0]->type == ESEXP_RES_BOOL) - unfiled = TRUE; - else - unfiled = FALSE; - - if (!unfiled) - for (i = 0; i < argc; i++) - if (argv[i]->type != ESEXP_RES_STRING) { - e_sexp_fatal_error (esexp, _("has-categories? expects all arguments " - "to be strings or one and only one " - "argument to be a boolean false (#f)")); - return NULL; - } - - /* Search categories. First, if there are no categories we return - * whether unfiled components are supposed to match. - */ - - cal_component_get_categories_list (ctx->comp, &categories); - if (!categories) { - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = unfiled; - - return result; - } - - /* Otherwise, we *do* have categories but unfiled components were - * requested, so this component does not match. - */ - if (unfiled) { - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = FALSE; - - return result; - } - - matches = TRUE; - - for (i = 0; i < argc; i++) { - const char *sought; - GSList *l; - gboolean has_category; - - sought = argv[i]->value.string; - - has_category = FALSE; - - for (l = categories; l; l = l->next) { - const char *category; - - category = l->data; - - if (strcmp (category, sought) == 0) { - has_category = TRUE; - break; - } - } - - if (!has_category) { - matches = FALSE; - break; - } - } - - cal_component_free_categories_list (categories); - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = matches; - - return result; -} - -/* (is-completed?) - * - * Returns a boolean indicating whether the component is completed (i.e. has - * a COMPLETED property. This is really only useful for TODO components. - */ -static ESExpResult * -func_is_completed (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - ESExpResult *result; - struct icaltimetype *t; - gboolean complete = FALSE; - - /* Check argument types */ - - if (argc != 0) { - e_sexp_fatal_error (esexp, _("is-completed? expects 0 arguments")); - return NULL; - } - - cal_component_get_completed (ctx->comp, &t); - if (t) { - complete = TRUE; - cal_component_free_icaltimetype (t); - } - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = complete; - - return result; -} - -/* (completed-before? TIME) - * - * TIME - time_t - * - * Returns a boolean indicating whether the component was completed on or - * before the given time (i.e. it checks the COMPLETED property). - * This is really only useful for TODO components. - */ -static ESExpResult * -func_completed_before (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - ESExpResult *result; - struct icaltimetype *tt; - icaltimezone *zone; - gboolean retval = FALSE; - time_t before_time, completed_time; - - /* Check argument types */ - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("completed-before? expects 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("completed-before? expects argument 1 " - "to be a time_t")); - return NULL; - } - before_time = argv[0]->value.time; - - cal_component_get_completed (ctx->comp, &tt); - if (tt) { - /* COMPLETED must be in UTC. */ - zone = icaltimezone_get_utc_timezone (); - completed_time = icaltime_as_timet_with_zone (*tt, zone); - -#if 0 - g_print ("Query Time : %s", ctime (&before_time)); - g_print ("Completed Time: %s", ctime (&completed_time)); -#endif - - /* We want to return TRUE if before_time is after - completed_time. */ - if (difftime (before_time, completed_time) > 0) { -#if 0 - g_print (" Returning TRUE\n"); -#endif - retval = TRUE; - } - - cal_component_free_icaltimetype (tt); - } - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = retval; - - return result; -} - -#if 0 -static struct prop_info { - ECardSimpleField field_id; - const char *query_prop; - const char *ecard_prop; -#define PROP_TYPE_NORMAL 0x01 -#define PROP_TYPE_LIST 0x02 -#define PROP_TYPE_LISTITEM 0x03 -#define PROP_TYPE_ID 0x04 - int prop_type; - gboolean (*list_compare)(ECardSimple *ecard, const char *str, - char *(*compare)(const char*, const char*)); - -} prop_info_table[] = { -#define NORMAL_PROP(f,q,e) {f, q, e, PROP_TYPE_NORMAL, NULL} -#define ID_PROP {0, "id", NULL, PROP_TYPE_ID, NULL} -#define LIST_PROP(q,e,c) {0, q, e, PROP_TYPE_LIST, c} - - /* query prop, ecard prop, type, list compare function */ - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_FILE_AS, "file_as", "file_as" ), - LIST_PROP ( "full_name", "full_name", compare_name), /* not really a list, but we need to compare both full and surname */ - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_URL, "url", "url" ), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_MAILER, "mailer", "mailer"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ORG, "org", "org"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ORG_UNIT, "org_unit", "org_unit"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_OFFICE, "office", "office"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_TITLE, "title", "title"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ROLE, "role", "role"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_MANAGER, "manager", "manager"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ASSISTANT, "assistant", "assistant"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_NICKNAME, "nickname", "nickname"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_SPOUSE, "spouse", "spouse" ), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_NOTE, "note", "note"), - ID_PROP, - LIST_PROP ( "email", "email", compare_email ), - LIST_PROP ( "phone", "phone", compare_phone ), - LIST_PROP ( "address", "address", compare_address ), - LIST_PROP ( "category", "category", compare_category ), - LIST_PROP ( "arbitrary", "arbitrary", compare_arbitrary ) -}; -static int num_prop_infos = sizeof(prop_info_table) / sizeof(prop_info_table[0]); - -static ESExpResult * -entry_compare(SearchContext *ctx, struct _ESExp *f, - int argc, struct _ESExpResult **argv, - char *(*compare)(const char*, const char*)) -{ - ESExpResult *r; - int truth = FALSE; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname; - struct prop_info *info = NULL; - int i; - gboolean any_field; - - propname = argv[0]->value.string; - - any_field = !strcmp(propname, "x-evolution-any-field"); - for (i = 0; i < num_prop_infos; i ++) { - if (any_field - || !strcmp (prop_info_table[i].query_prop, propname)) { - info = &prop_info_table[i]; - - if (info->prop_type == PROP_TYPE_NORMAL) { - char *prop = NULL; - /* searches where the query's property - maps directly to an ecard property */ - - prop = e_card_simple_get (ctx->card, info->field_id); - - if (prop && compare(prop, argv[1]->value.string)) { - truth = TRUE; - } - if ((!prop) && compare("", argv[1]->value.string)) { - truth = TRUE; - } - g_free (prop); - } else if (info->prop_type == PROP_TYPE_LIST) { - /* the special searches that match any of the list elements */ - truth = info->list_compare (ctx->card, argv[1]->value.string, compare); - } else if (info->prop_type == PROP_TYPE_ID) { - const char *prop = NULL; - /* searches where the query's property - maps directly to an ecard property */ - - prop = e_card_get_id (ctx->card->card); - - if (prop && compare(prop, argv[1]->value.string)) { - truth = TRUE; - } - if ((!prop) && compare("", argv[1]->value.string)) { - truth = TRUE; - } - } - - /* if we're looking at all fields and find a match, - or if we're just looking at this one field, - break. */ - if ((any_field && truth) - || !any_field) - break; - } - } - - } - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = truth; - - return r; -} -#endif - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - /* Time-related functions */ - { "time-now", func_time_now, 0 }, - { "make-time", func_make_time, 0 }, - { "time-add-day", func_time_add_day, 0 }, - { "time-day-begin", func_time_day_begin, 0 }, - { "time-day-end", func_time_day_end, 0 }, - - /* Component-related functions */ - { "get-vtype", func_get_vtype, 0 }, - { "occur-in-time-range?", func_occur_in_time_range, 0 }, - { "contains?", func_contains, 0 }, - { "has-alarms?", func_has_alarms, 0 }, - { "has-categories?", func_has_categories, 0 }, - { "is-completed?", func_is_completed, 0 }, - { "completed-before?", func_completed_before, 0 } -}; - -gboolean -cal_backend_object_sexp_match_comp (CalBackendObjectSExp *sexp, CalComponent *comp, CalBackend *backend) -{ - ESExpResult *r; - gboolean retval; - - sexp->priv->search_context->comp = g_object_ref (comp); - sexp->priv->search_context->backend = g_object_ref (backend); - - /* if it's not a valid vcard why is it in our db? :) */ - if (!sexp->priv->search_context->comp) - return FALSE; - - r = e_sexp_eval(sexp->priv->search_sexp); - - retval = (r && r->type == ESEXP_RES_BOOL && r->value.bool); - - g_object_unref (sexp->priv->search_context->comp); - g_object_unref (sexp->priv->search_context->backend); - - e_sexp_result_free(sexp->priv->search_sexp, r); - - return retval; -} - -gboolean -cal_backend_object_sexp_match_object (CalBackendObjectSExp *sexp, const char *object, CalBackend *backend) -{ - CalComponent *comp; - icalcomponent *icalcomp; - gboolean retval; - - icalcomp = icalcomponent_new_from_string ((char *) object); - if (!icalcomp) - return FALSE; - - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); - - retval = cal_backend_object_sexp_match_comp (sexp, comp, backend); - - g_object_unref (comp); - - return retval; -} - - - -/** - * cal_backend_card_sexp_new: - */ -CalBackendObjectSExp * -cal_backend_object_sexp_new (const char *text) -{ - CalBackendObjectSExp *sexp = g_object_new (CAL_TYPE_BACKEND_OBJECT_SEXP, NULL); - int esexp_error; - int i; - - sexp->priv->search_sexp = e_sexp_new(); - sexp->priv->text = g_strdup (text); - - for(i=0;ipriv->search_sexp, 0, symbols[i].name, - (ESExpIFunc *)symbols[i].func, sexp->priv->search_context); - } else { - e_sexp_add_function(sexp->priv->search_sexp, 0, symbols[i].name, - symbols[i].func, sexp->priv->search_context); - } - } - - e_sexp_input_text(sexp->priv->search_sexp, text, strlen(text)); - esexp_error = e_sexp_parse(sexp->priv->search_sexp); - - if (esexp_error == -1) { - g_object_unref (sexp); - sexp = NULL; - } - - return sexp; -} - -const char * -cal_backend_object_sexp_text (CalBackendObjectSExp *sexp) -{ - CalBackendObjectSExpPrivate *priv; - - g_return_val_if_fail (sexp != NULL, NULL); - g_return_val_if_fail (CAL_IS_BACKEND_OBJECT_SEXP (sexp), NULL); - - priv = sexp->priv; - - return priv->text; -} - -static void -cal_backend_object_sexp_dispose (GObject *object) -{ - CalBackendObjectSExp *sexp = CAL_BACKEND_OBJECT_SEXP (object); - - if (sexp->priv) { - e_sexp_unref(sexp->priv->search_sexp); - - g_free (sexp->priv->text); - - g_free (sexp->priv->search_context); - g_free (sexp->priv); - sexp->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -cal_backend_object_sexp_class_init (CalBackendObjectSExpClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - /* Set the virtual methods. */ - - object_class->dispose = cal_backend_object_sexp_dispose; -} - -static void -cal_backend_object_sexp_init (CalBackendObjectSExp *sexp) -{ - CalBackendObjectSExpPrivate *priv; - - priv = g_new0 (CalBackendObjectSExpPrivate, 1); - - sexp->priv = priv; - priv->search_context = g_new (SearchContext, 1); -} - -/** - * cal_backend_object_sexp_get_type: - */ -GType -cal_backend_object_sexp_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (CalBackendObjectSExpClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) cal_backend_object_sexp_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CalBackendObjectSExp), - 0, /* n_preallocs */ - (GInstanceInitFunc) cal_backend_object_sexp_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, "CalBackendObjectSExp", &info, 0); - } - - return type; -} diff --git a/calendar/pcs/cal-backend-object-sexp.h b/calendar/pcs/cal-backend-object-sexp.h deleted file mode 100644 index dbac3b6abc..0000000000 --- a/calendar/pcs/cal-backend-object-sexp.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * cal-backend-card-sexp.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __CAL_BACKEND_OBJECT_SEXP_H__ -#define __CAL_BACKEND_OBJECT_SEXP_H__ - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define CAL_TYPE_BACKEND_OBJECT_SEXP (cal_backend_object_sexp_get_type ()) -#define CAL_BACKEND_OBJECT_SEXP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CAL_TYPE_BACKEND_OBJECT_SEXP, CalBackendObjectSExp)) -#define CAL_BACKEND_OBJECT_SEXP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CAL_BACKEND_TYPE, CalBackendObjectSExpClass)) -#define CAL_IS_BACKEND_OBJECT_SEXP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CAL_TYPE_BACKEND_OBJECT_SEXP)) -#define CAL_IS_BACKEND_OBJECT_SEXP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CAL_TYPE_BACKEND_OBJECT_SEXP)) -#define CAL_BACKEND_OBJECT_SEXP_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAL_TYPE_BACKEND_OBJECT_SEXP, CALBackendObjectSExpClass)) - -typedef struct _CalBackendObjectSExpPrivate CalBackendObjectSExpPrivate; - -struct _CalBackendObjectSExp { - GObject parent_object; - - CalBackendObjectSExpPrivate *priv; -}; - -struct _CalBackendObjectSExpClass { - GObjectClass parent_class; -}; - -GType cal_backend_object_sexp_get_type (void); -CalBackendObjectSExp *cal_backend_object_sexp_new (const char *text); -const char *cal_backend_object_sexp_text (CalBackendObjectSExp *sexp); - - -gboolean cal_backend_object_sexp_match_object (CalBackendObjectSExp *sexp, - const char *object, - CalBackend *backend); -gboolean cal_backend_object_sexp_match_comp (CalBackendObjectSExp *sexp, - CalComponent *comp, - CalBackend *backend); - -G_END_DECLS - -#endif /* __CAL_BACKEND_OBJECT_SEXP_H__ */ diff --git a/calendar/pcs/cal-backend-sync.c b/calendar/pcs/cal-backend-sync.c deleted file mode 100644 index c385a89b72..0000000000 --- a/calendar/pcs/cal-backend-sync.c +++ /dev/null @@ -1,607 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Chris Toshok (toshok@ximian.com) - * - * Copyright (C) 2003, Ximian, Inc. - */ - -#ifdef CONFIG_H -#include -#endif - -#include "cal-backend-sync.h" - -struct _CalBackendSyncPrivate { - int mumble; -}; - -static GObjectClass *parent_class; - -G_LOCK_DEFINE_STATIC (cal_sync_mutex); -#define SYNC_LOCK() G_LOCK (cal_sync_mutex) -#define SYNC_UNLOCK() G_UNLOCK (cal_sync_mutex) - -CalBackendSyncStatus -cal_backend_sync_is_read_only (CalBackendSync *backend, Cal *cal, gboolean *read_only) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (read_only, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->is_read_only_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->is_read_only_sync) (backend, cal, read_only); -} - -CalBackendSyncStatus -cal_backend_sync_get_cal_address (CalBackendSync *backend, Cal *cal, char **address) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (address, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_cal_address_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_cal_address_sync) (backend, cal, address); -} - -CalBackendSyncStatus -cal_backend_sync_get_alarm_email_address (CalBackendSync *backend, Cal *cal, char **address) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (address, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_alarm_email_address_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_alarm_email_address_sync) (backend, cal, address); -} - -CalBackendSyncStatus -cal_backend_sync_get_ldap_attribute (CalBackendSync *backend, Cal *cal, char **attribute) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (attribute, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_ldap_attribute_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_ldap_attribute_sync) (backend, cal, attribute); -} - -CalBackendSyncStatus -cal_backend_sync_get_static_capabilities (CalBackendSync *backend, Cal *cal, char **capabilities) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (capabilities, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_static_capabilities_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_static_capabilities_sync) (backend, cal, capabilities); -} - -CalBackendSyncStatus -cal_backend_sync_open (CalBackendSync *backend, Cal *cal, gboolean only_if_exists) -{ - CalBackendSyncStatus status; - - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->open_sync); - - SYNC_LOCK (); - - status = (* CAL_BACKEND_SYNC_GET_CLASS (backend)->open_sync) (backend, cal, only_if_exists); - - SYNC_UNLOCK (); - - return status; -} - -CalBackendSyncStatus -cal_backend_sync_remove (CalBackendSync *backend, Cal *cal) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_sync) (backend, cal); -} - -CalBackendSyncStatus -cal_backend_sync_create_object (CalBackendSync *backend, Cal *cal, const char *calobj, char **uid) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->create_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->create_object_sync) (backend, cal, calobj, uid); -} - -CalBackendSyncStatus -cal_backend_sync_modify_object (CalBackendSync *backend, Cal *cal, const char *calobj, - CalObjModType mod, char **old_object) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->modify_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->modify_object_sync) (backend, cal, - calobj, mod, old_object); -} - -CalBackendSyncStatus -cal_backend_sync_remove_object (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, - CalObjModType mod, char **object) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync) (backend, cal, uid, rid, mod, object); -} - -CalBackendSyncStatus -cal_backend_sync_discard_alarm (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->discard_alarm_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->discard_alarm_sync) (backend, cal, uid, auid); -} - -CalBackendSyncStatus -cal_backend_sync_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync) (backend, cal, calobj); -} - -CalBackendSyncStatus -cal_backend_sync_send_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync) (backend, cal, calobj); -} - -CalBackendSyncStatus -cal_backend_sync_get_default_object (CalBackendSync *backend, Cal *cal, char **object) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (object, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_default_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_default_object_sync) (backend, cal, object); -} - -CalBackendSyncStatus -cal_backend_sync_get_object (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, char **object) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (object, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_object_sync) (backend, cal, uid, rid, object); -} - -CalBackendSyncStatus -cal_backend_sync_get_object_list (CalBackendSync *backend, Cal *cal, const char *sexp, GList **objects) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (objects, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_object_list_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_object_list_sync) (backend, cal, sexp, objects); -} - -CalBackendSyncStatus -cal_backend_sync_get_timezone (CalBackendSync *backend, Cal *cal, const char *tzid, char **object) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_timezone_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_timezone_sync) (backend, cal, tzid, object); -} - -CalBackendSyncStatus -cal_backend_sync_add_timezone (CalBackendSync *backend, Cal *cal, const char *tzobj) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->add_timezone_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->add_timezone_sync) (backend, cal, tzobj); -} - -CalBackendSyncStatus -cal_backend_sync_set_default_timezone (CalBackendSync *backend, Cal *cal, const char *tzid) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->set_default_timezone_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->set_default_timezone_sync) (backend, cal, tzid); -} - - -CalBackendSyncStatus -cal_backend_sync_get_changes (CalBackendSync *backend, Cal *cal, const char *change_id, - GList **adds, GList **modifies, GList **deletes) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync) (backend, cal, change_id, - adds, modifies, deletes); -} - -CalBackendSyncStatus -cal_backend_sync_get_free_busy (CalBackendSync *backend, Cal *cal, GList *users, - time_t start, time_t end, GList **freebusy) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_freebusy_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_freebusy_sync) (backend, cal, users, - start, end, freebusy); -} - - -static void -_cal_backend_is_read_only (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - gboolean read_only = TRUE; - - status = cal_backend_sync_is_read_only (CAL_BACKEND_SYNC (backend), cal, &read_only); - - cal_notify_read_only (cal, status, read_only); -} - -static void -_cal_backend_get_cal_address (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *address = NULL; - - status = cal_backend_sync_get_cal_address (CAL_BACKEND_SYNC (backend), cal, &address); - - cal_notify_cal_address (cal, status, address); - - g_free (address); -} - -static void -_cal_backend_get_alarm_email_address (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *address = NULL; - - status = cal_backend_sync_get_cal_address (CAL_BACKEND_SYNC (backend), cal, &address); - - cal_notify_alarm_email_address (cal, status, address); - - g_free (address); -} - -static void -_cal_backend_get_ldap_attribute (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *attribute = NULL; - - status = cal_backend_sync_get_cal_address (CAL_BACKEND_SYNC (backend), cal, &attribute); - - cal_notify_ldap_attribute (cal, status, attribute); - - g_free (attribute); -} - -static void -_cal_backend_get_static_capabilities (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *capabilities = NULL; - - status = cal_backend_sync_get_cal_address (CAL_BACKEND_SYNC (backend), cal, &capabilities); - - cal_notify_static_capabilities (cal, status, capabilities); - - g_free (capabilities); -} - -static void -_cal_backend_open (CalBackend *backend, Cal *cal, gboolean only_if_exists) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_open (CAL_BACKEND_SYNC (backend), cal, only_if_exists); - - cal_notify_open (cal, status); -} - -static void -_cal_backend_remove (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_remove (CAL_BACKEND_SYNC (backend), cal); - - cal_notify_remove (cal, status); -} - -static void -_cal_backend_create_object (CalBackend *backend, Cal *cal, const char *calobj) -{ - CalBackendSyncStatus status; - char *uid = NULL; - - status = cal_backend_sync_create_object (CAL_BACKEND_SYNC (backend), cal, calobj, &uid); - - cal_notify_object_created (cal, status, uid, calobj); - - if (uid) - g_free (uid); -} - -static void -_cal_backend_modify_object (CalBackend *backend, Cal *cal, const char *calobj, CalObjModType mod) -{ - CalBackendSyncStatus status; - char *old_object = NULL; - - status = cal_backend_sync_modify_object (CAL_BACKEND_SYNC (backend), cal, - calobj, mod, &old_object); - - cal_notify_object_modified (cal, status, old_object, calobj); -} - -static void -_cal_backend_remove_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod) -{ - CalBackendSyncStatus status; - char *object = NULL; - - status = cal_backend_sync_remove_object (CAL_BACKEND_SYNC (backend), cal, uid, rid, mod, &object); - - cal_notify_object_removed (cal, status, uid, object); -} - -static void -_cal_backend_discard_alarm (CalBackend *backend, Cal *cal, const char *uid, const char *auid) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_discard_alarm (CAL_BACKEND_SYNC (backend), cal, uid, auid); - - cal_notify_alarm_discarded (cal, status); -} - -static void -_cal_backend_receive_objects (CalBackend *backend, Cal *cal, const char *calobj) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_receive_objects (CAL_BACKEND_SYNC (backend), cal, calobj); - - cal_notify_objects_received (cal, status); -} - -static void -_cal_backend_send_objects (CalBackend *backend, Cal *cal, const char *calobj) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_send_objects (CAL_BACKEND_SYNC (backend), cal, calobj); - - cal_notify_objects_sent (cal, status); -} - -static void -_cal_backend_get_default_object (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *object = NULL; - - status = cal_backend_sync_get_default_object (CAL_BACKEND_SYNC (backend), cal, &object); - - cal_notify_default_object (cal, status, object); - - g_free (object); -} - -static void -_cal_backend_get_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid) -{ - CalBackendSyncStatus status; - char *object = NULL; - - status = cal_backend_sync_get_object (CAL_BACKEND_SYNC (backend), cal, uid, rid, &object); - - cal_notify_object (cal, status, object); - - g_free (object); -} - -static void -_cal_backend_get_object_list (CalBackend *backend, Cal *cal, const char *sexp) -{ - CalBackendSyncStatus status; - GList *objects = NULL, *l; - - status = cal_backend_sync_get_object_list (CAL_BACKEND_SYNC (backend), cal, sexp, &objects); - - cal_notify_object_list (cal, status, objects); - - for (l = objects; l; l = l->next) - g_free (l->data); - g_list_free (objects); -} - -static void -_cal_backend_get_timezone (CalBackend *backend, Cal *cal, const char *tzid) -{ - CalBackendSyncStatus status; - char *object = NULL; - - status = cal_backend_sync_get_timezone (CAL_BACKEND_SYNC (backend), cal, tzid, &object); - - cal_notify_timezone_requested (cal, status, object); -} - -static void -_cal_backend_add_timezone (CalBackend *backend, Cal *cal, const char *tzobj) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_add_timezone (CAL_BACKEND_SYNC (backend), cal, tzobj); - - cal_notify_timezone_added (cal, status, tzobj); -} - -static void -_cal_backend_set_default_timezone (CalBackend *backend, Cal *cal, const char *tzid) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_set_default_timezone (CAL_BACKEND_SYNC (backend), cal, tzid); - - cal_notify_default_timezone_set (cal, status); -} - -static void -_cal_backend_get_changes (CalBackend *backend, Cal *cal, const char *change_id) -{ - CalBackendSyncStatus status; - GList *adds = NULL, *modifies = NULL, *deletes = NULL, *l; - - status = cal_backend_sync_get_changes (CAL_BACKEND_SYNC (backend), cal, change_id, - &adds, &modifies, &deletes); - - cal_notify_changes (cal, status, adds, modifies, deletes); - - for (l = adds; l; l = l->next) - g_free (l->data); - g_list_free (adds); - - for (l = modifies; l; l = l->next) - g_free (l->data); - g_list_free (modifies); - - for (l = deletes; l; l = l->next) - g_free (l->data); - g_list_free (deletes); -} - -static void -_cal_backend_get_free_busy (CalBackend *backend, Cal *cal, GList *users, time_t start, time_t end) -{ - CalBackendSyncStatus status; - GList *freebusy = NULL, *l; - - status = cal_backend_sync_get_free_busy (CAL_BACKEND_SYNC (backend), cal, users, start, end, &freebusy); - - cal_notify_free_busy (cal, status, freebusy); - - for (l = freebusy; l; l = l->next) - g_free (l->data); - g_list_free (freebusy); -} - -static void -cal_backend_sync_init (CalBackendSync *backend) -{ - CalBackendSyncPrivate *priv; - - priv = g_new0 (CalBackendSyncPrivate, 1); - - backend->priv = priv; -} - -static void -cal_backend_sync_dispose (GObject *object) -{ - CalBackendSync *backend; - - backend = CAL_BACKEND_SYNC (object); - - if (backend->priv) { - g_free (backend->priv); - - backend->priv = NULL; - } - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -cal_backend_sync_class_init (CalBackendSyncClass *klass) -{ - GObjectClass *object_class; - CalBackendClass *backend_class = CAL_BACKEND_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class = (GObjectClass *) klass; - - backend_class->is_read_only = _cal_backend_is_read_only; - backend_class->get_cal_address = _cal_backend_get_cal_address; - backend_class->get_alarm_email_address = _cal_backend_get_alarm_email_address; - backend_class->get_ldap_attribute = _cal_backend_get_ldap_attribute; - backend_class->get_static_capabilities = _cal_backend_get_static_capabilities; - backend_class->open = _cal_backend_open; - backend_class->remove = _cal_backend_remove; - backend_class->create_object = _cal_backend_create_object; - backend_class->modify_object = _cal_backend_modify_object; - backend_class->remove_object = _cal_backend_remove_object; - backend_class->discard_alarm = _cal_backend_discard_alarm; - backend_class->receive_objects = _cal_backend_receive_objects; - backend_class->send_objects = _cal_backend_send_objects; - backend_class->get_default_object = _cal_backend_get_default_object; - backend_class->get_object = _cal_backend_get_object; - backend_class->get_object_list = _cal_backend_get_object_list; - backend_class->get_timezone = _cal_backend_get_timezone; - backend_class->add_timezone = _cal_backend_add_timezone; - backend_class->set_default_timezone = _cal_backend_set_default_timezone; - backend_class->get_changes = _cal_backend_get_changes; - backend_class->get_free_busy = _cal_backend_get_free_busy; - - object_class->dispose = cal_backend_sync_dispose; -} - -/** - * cal_backend_get_type: - */ -GType -cal_backend_sync_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (CalBackendSyncClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) cal_backend_sync_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CalBackendSync), - 0, /* n_preallocs */ - (GInstanceInitFunc) cal_backend_sync_init - }; - - type = g_type_register_static (CAL_BACKEND_TYPE, "CalBackendSync", &info, 0); - } - - return type; -} diff --git a/calendar/pcs/cal-backend-sync.h b/calendar/pcs/cal-backend-sync.h deleted file mode 100644 index 2953ac2afa..0000000000 --- a/calendar/pcs/cal-backend-sync.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - */ - -#ifndef __Cal_BACKEND_SYNC_H__ -#define __Cal_BACKEND_SYNC_H__ - -#include -#include -#include - -G_BEGIN_DECLS - -#define CAL_TYPE_BACKEND_SYNC (cal_backend_sync_get_type ()) -#define CAL_BACKEND_SYNC(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CAL_TYPE_BACKEND_SYNC, CalBackendSync)) -#define CAL_BACKEND_SYNC_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CAL_TYPE_BACKEND_SYNC, CalBackendSyncClass)) -#define CAL_IS_BACKEND_SYNC(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CAL_TYPE_BACKEND_SYNC)) -#define CAL_IS_BACKEND_SYNC_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CAL_TYPE_BACKEND_SYNC)) -#define CAL_BACKEND_SYNC_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((k), CAL_TYPE_BACKEND_SYNC, CalBackendSyncClass)) -typedef struct _CalBackendSync CalBackendSync; -typedef struct _CalBackendSyncClass CalBackendSyncClass; -typedef struct _CalBackendSyncPrivate CalBackendSyncPrivate; - -typedef GNOME_Evolution_Calendar_CallStatus CalBackendSyncStatus; - -struct _CalBackendSync { - CalBackend parent_object; - - CalBackendSyncPrivate *priv; -}; - -struct _CalBackendSyncClass { - CalBackendClass parent_class; - - /* Virtual methods */ - CalBackendSyncStatus (*is_read_only_sync) (CalBackendSync *backend, Cal *cal, gboolean *read_only); - CalBackendSyncStatus (*get_cal_address_sync) (CalBackendSync *backend, Cal *cal, char **address); - CalBackendSyncStatus (*get_alarm_email_address_sync) (CalBackendSync *backend, Cal *cal, char **address); - CalBackendSyncStatus (*get_ldap_attribute_sync) (CalBackendSync *backend, Cal *cal, char **attribute); - CalBackendSyncStatus (*get_static_capabilities_sync) (CalBackendSync *backend, Cal *cal, char **capabilities); - - CalBackendSyncStatus (*open_sync) (CalBackendSync *backend, Cal *cal, gboolean only_if_exists); - CalBackendSyncStatus (*remove_sync) (CalBackendSync *backend, Cal *cal); - - CalBackendSyncStatus (*create_object_sync) (CalBackendSync *backend, Cal *cal, const char *calobj, char **uid); - CalBackendSyncStatus (*modify_object_sync) (CalBackendSync *backend, Cal *cal, const char *calobj, CalObjModType mod, char **old_object); - CalBackendSyncStatus (*remove_object_sync) (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod, char **object); - - CalBackendSyncStatus (*discard_alarm_sync) (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid); - - CalBackendSyncStatus (*receive_objects_sync) (CalBackendSync *backend, Cal *cal, const char *calobj); - CalBackendSyncStatus (*send_objects_sync) (CalBackendSync *backend, Cal *cal, const char *calobj); - - CalBackendSyncStatus (*get_default_object_sync) (CalBackendSync *backend, Cal *cal, char **object); - CalBackendSyncStatus (*get_object_sync) (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, char **object); - CalBackendSyncStatus (*get_object_list_sync) (CalBackendSync *backend, Cal *cal, const char *sexp, GList **objects); - - CalBackendSyncStatus (*get_timezone_sync) (CalBackendSync *backend, Cal *cal, const char *tzid, char **object); - CalBackendSyncStatus (*add_timezone_sync) (CalBackendSync *backend, Cal *cal, const char *tzobj); - CalBackendSyncStatus (*set_default_timezone_sync) (CalBackendSync *backend, Cal *cal, const char *tzid); - - CalBackendSyncStatus (*get_changes_sync) (CalBackendSync *backend, Cal *cal, const char *change_id, GList **adds, GList **modifies, GList **deletes); - CalBackendSyncStatus (*get_freebusy_sync) (CalBackendSync *backend, Cal *cal, GList *users, time_t start, time_t end, GList **freebusy); - - /* Padding for future expansion */ - void (*_cal_reserved0) (void); - void (*_cal_reserved1) (void); - void (*_cal_reserved2) (void); - void (*_cal_reserved3) (void); - void (*_cal_reserved4) (void); - -}; - -typedef CalBackendSync * (*CalBackendSyncFactoryFn) (void); -GType cal_backend_sync_get_type (void); -CalBackendSyncStatus cal_backend_sync_is_read_only (CalBackendSync *backend, - Cal *cal, - gboolean *read_only); -CalBackendSyncStatus cal_backend_sync_get_cal_address (CalBackendSync *backend, - Cal *cal, - char **address); -CalBackendSyncStatus cal_backend_sync_get_alarm_email_address (CalBackendSync *backend, - Cal *cal, - char **address); -CalBackendSyncStatus cal_backend_sync_get_ldap_attribute (CalBackendSync *backend, - Cal *cal, - char **attribute); -CalBackendSyncStatus cal_backend_sync_get_static_capabilities (CalBackendSync *backend, - Cal *cal, - char **capabiliites); -CalBackendSyncStatus cal_backend_sync_open (CalBackendSync *backend, - Cal *cal, - gboolean only_if_exists); -CalBackendSyncStatus cal_backend_sync_remove (CalBackendSync *backend, - Cal *cal); -CalBackendSyncStatus cal_backend_sync_create_object (CalBackendSync *backend, - Cal *cal, - const char *calobj, - char **uid); -CalBackendSyncStatus cal_backend_sync_modify_object (CalBackendSync *backend, - Cal *cal, - const char *calobj, - CalObjModType mod, - char **old_object); -CalBackendSyncStatus cal_backend_sync_remove_object (CalBackendSync *backend, - Cal *cal, - const char *uid, - const char *rid, - CalObjModType mod, - char **object); -CalBackendSyncStatus cal_backend_sync_discard_alarm (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid); - -CalBackendSyncStatus cal_backend_sync_receive_objects (CalBackendSync *backend, - Cal *cal, - const char *calobj); -CalBackendSyncStatus cal_backend_sync_send_objects (CalBackendSync *backend, - Cal *cal, - const char *calobj); -CalBackendSyncStatus cal_backend_sync_get_default_object (CalBackendSync *backend, - Cal *cal, - char **object); - -CalBackendSyncStatus cal_backend_sync_get_object (CalBackendSync *backend, - Cal *cal, - const char *uid, - const char *rid, - char **object); - -CalBackendSyncStatus cal_backend_sync_get_object_list (CalBackendSync *backend, - Cal *cal, - const char *sexp, - GList **objects); - -CalBackendSyncStatus cal_backend_sync_get_timezone (CalBackendSync *backend, Cal *cal, const char *tzid, char **object); -CalBackendSyncStatus cal_backend_sync_add_timezone (CalBackendSync *backend, Cal *cal, const char *tzobj); -CalBackendSyncStatus cal_backend_sync_set_default_timezone (CalBackendSync *backend, Cal *cal, const char *tzid); - -CalBackendSyncStatus cal_backend_sync_get_changes (CalBackendSync *backend, Cal *cal, const char *change_id, GList **adds, GList **modifies, GList **deletes); -CalBackendSyncStatus cal_backend_sync_get_free_busy (CalBackendSync *backend, Cal *cal, GList *users, time_t start, time_t end, GList **freebusy); - -G_END_DECLS - -#endif /* ! __CAL_BACKEND_SYNC_H__ */ diff --git a/calendar/pcs/cal-backend-util.c b/calendar/pcs/cal-backend-util.c deleted file mode 100644 index 86bf761878..0000000000 --- a/calendar/pcs/cal-backend-util.c +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 -#include "cal-backend-util.h" -#include - -static EAccountList *accounts; - -gboolean -cal_backend_mail_account_get_default (EConfigListener *db, - char **address, - char **name) -{ - const EAccount *account; - - if (accounts == NULL) - accounts = e_account_list_new(gconf_client_get_default()); - - account = e_account_list_get_default(accounts); - if (account) { - *address = g_strdup(account->id->address); - *name = g_strdup(account->id->name); - } - - return account != NULL; -} - -gboolean -cal_backend_mail_account_is_valid (EConfigListener *db, char *user, char **name) -{ - const EAccount *account; - - if (accounts == NULL) - accounts = e_account_list_new(gconf_client_get_default()); - - account = e_account_list_find(accounts, E_ACCOUNT_FIND_ID_ADDRESS, user); - if (account) - *name = g_strdup(account->id->name); - - return account != NULL; -} diff --git a/calendar/pcs/cal-backend-util.h b/calendar/pcs/cal-backend-util.h deleted file mode 100644 index 228179b8c7..0000000000 --- a/calendar/pcs/cal-backend-util.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_BACKEND_UTIL_H -#define CAL_BACKEND_UTIL_H - -#include -#include - -G_BEGIN_DECLS - -/* - * Functions for accessing mail configuration - */ - -gboolean cal_backend_mail_account_get_default (EConfigListener *db, - char **address, char **name); -gboolean cal_backend_mail_account_is_valid (EConfigListener *db, - char *user, char **name); - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c deleted file mode 100644 index df2f7408e4..0000000000 --- a/calendar/pcs/cal-backend.c +++ /dev/null @@ -1,1199 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * JP Rosevear - * Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 -#include -#include -#include - -#include "cal-backend.h" -#include "libversit/vcc.h" - - - -/* A category that exists in some of the objects of the calendar */ -typedef struct { - /* Category name, also used as the key in the categories hash table */ - char *name; - - /* Number of objects that have this category */ - int refcount; -} CalBackendCategory; - -/* Private part of the CalBackend structure */ -struct _CalBackendPrivate { - /* The uri for this backend */ - char *uri; - - /* The kind of components for this backend */ - icalcomponent_kind kind; - - /* List of Cal objects */ - GMutex *clients_mutex; - GList *clients; - - GMutex *queries_mutex; - EList *queries; - - /* Hash table of live categories, temporary hash of - * added/removed categories, and idle handler for sending - * category_changed. - */ - GHashTable *categories; - GHashTable *changed_categories; - guint category_idle_id; -}; - -/* Property IDs */ -enum props { - PROP_0, - PROP_URI, - PROP_KIND -}; - -/* Signal IDs */ -enum { - LAST_CLIENT_GONE, - OPENED, - REMOVED, - LAST_SIGNAL -}; -static guint cal_backend_signals[LAST_SIGNAL]; - -static void cal_backend_class_init (CalBackendClass *class); -static void cal_backend_init (CalBackend *backend); -static void cal_backend_finalize (GObject *object); - -static void notify_categories_changed (CalBackend *backend); - -#define CLASS(backend) (CAL_BACKEND_CLASS (G_OBJECT_GET_CLASS (backend))) - -static GObjectClass *parent_class; - - - -/** - * cal_backend_get_type: - * @void: - * - * Registers the #CalBackend class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackend class. - **/ -GType -cal_backend_get_type (void) -{ - static GType cal_backend_type = 0; - - if (!cal_backend_type) { - static GTypeInfo info = { - sizeof (CalBackendClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_class_init, - NULL, NULL, - sizeof (CalBackend), - 0, - (GInstanceInitFunc) cal_backend_init, - }; - cal_backend_type = g_type_register_static (G_TYPE_OBJECT, "CalBackend", &info, 0); - } - - return cal_backend_type; -} - -static void -cal_backend_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - CalBackend *backend; - CalBackendPrivate *priv; - - backend = CAL_BACKEND (object); - priv = backend->priv; - - switch (property_id) { - case PROP_URI: - g_free (priv->uri); - priv->uri = g_value_dup_string (value); - break; - case PROP_KIND: - priv->kind = g_value_get_ulong (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -cal_backend_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - CalBackend *backend; - CalBackendPrivate *priv; - - backend = CAL_BACKEND (object); - priv = backend->priv; - - switch (property_id) { - case PROP_URI: - g_value_set_string (value, cal_backend_get_uri (backend)); - break; - case PROP_KIND: - g_value_set_ulong (value, cal_backend_get_kind (backend)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -/* Class initialization function for the calendar backend */ -static void -cal_backend_class_init (CalBackendClass *class) -{ - GObjectClass *object_class; - - parent_class = (GObjectClass *) g_type_class_peek_parent (class); - - object_class = (GObjectClass *) class; - - object_class->set_property = cal_backend_set_property; - object_class->get_property = cal_backend_get_property; - object_class->finalize = cal_backend_finalize; - - g_object_class_install_property (object_class, PROP_URI, - g_param_spec_string ("uri", NULL, NULL, "", - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_KIND, - g_param_spec_ulong ("kind", NULL, NULL, - ICAL_NO_COMPONENT, ICAL_XLICMIMEPART_COMPONENT, - ICAL_NO_COMPONENT, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_CONSTRUCT_ONLY)); - cal_backend_signals[LAST_CLIENT_GONE] = - g_signal_new ("last_client_gone", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalBackendClass, last_client_gone), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - cal_backend_signals[OPENED] = - g_signal_new ("opened", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalBackendClass, opened), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - G_TYPE_INT); - cal_backend_signals[REMOVED] = - g_signal_new ("removed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalBackendClass, removed), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - G_TYPE_INT); - - class->last_client_gone = NULL; - class->opened = NULL; - class->obj_updated = NULL; - - class->get_cal_address = NULL; - class->get_alarm_email_address = NULL; - class->get_static_capabilities = NULL; - class->open = NULL; - class->is_loaded = NULL; - class->is_read_only = NULL; - class->start_query = NULL; - class->get_mode = NULL; - class->set_mode = NULL; - class->get_object = NULL; - class->get_default_object = NULL; - class->get_object_list = NULL; - class->get_free_busy = NULL; - class->get_changes = NULL; - class->discard_alarm = NULL; - class->create_object = NULL; - class->modify_object = NULL; - class->remove_object = NULL; - class->receive_objects = NULL; - class->send_objects = NULL; - class->get_timezone = NULL; - class->add_timezone = NULL; - class->set_default_timezone = NULL; -} - -/* Object initialization func for the calendar backend */ -void -cal_backend_init (CalBackend *backend) -{ - CalBackendPrivate *priv; - - priv = g_new0 (CalBackendPrivate, 1); - backend->priv = priv; - - priv->clients = NULL; - priv->clients_mutex = g_mutex_new (); - - /* FIXME bonobo_object_ref/unref? */ - priv->queries = e_list_new((EListCopyFunc) g_object_ref, (EListFreeFunc) g_object_unref, NULL); - priv->queries_mutex = g_mutex_new (); - - priv->categories = g_hash_table_new (g_str_hash, g_str_equal); - priv->changed_categories = g_hash_table_new (g_str_hash, g_str_equal); -} - -/* Used from g_hash_table_foreach(), frees a CalBackendCategory structure */ -static void -free_category_cb (gpointer key, gpointer value, gpointer data) -{ - CalBackendCategory *c = value; - - g_free (c->name); - g_free (c); -} - -static gboolean -prune_changed_categories (gpointer key, gpointer value, gpointer data) -{ - CalBackendCategory *c = value; - - if (!c->refcount) - free_category_cb (key, value, data); - return TRUE; -} - -void -cal_backend_finalize (GObject *object) -{ - CalBackend *backend = (CalBackend *)object; - CalBackendPrivate *priv; - - priv = backend->priv; - - g_assert (priv->clients == NULL); - - g_object_unref (priv->queries); - - g_hash_table_foreach_remove (priv->changed_categories, prune_changed_categories, NULL); - g_hash_table_destroy (priv->changed_categories); - - g_hash_table_foreach (priv->categories, free_category_cb, NULL); - g_hash_table_destroy (priv->categories); - - g_mutex_free (priv->clients_mutex); - g_mutex_free (priv->queries_mutex); - - if (priv->category_idle_id) - g_source_remove (priv->category_idle_id); - - g_free (priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - - - -/** - * cal_backend_get_uri: - * @backend: A calendar backend. - * - * Queries the URI of a calendar backend, which must already have an open - * calendar. - * - * Return value: The URI where the calendar is stored. - **/ -const char * -cal_backend_get_uri (CalBackend *backend) -{ - CalBackendPrivate *priv; - - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - priv = backend->priv; - - return priv->uri; -} - -icalcomponent_kind -cal_backend_get_kind (CalBackend *backend) -{ - CalBackendPrivate *priv; - - g_return_val_if_fail (backend != NULL, ICAL_NO_COMPONENT); - g_return_val_if_fail (IS_CAL_BACKEND (backend), ICAL_NO_COMPONENT); - - priv = backend->priv; - - return priv->kind; -} - -static void -cal_destroy_cb (gpointer data, GObject *where_cal_was) -{ - CalBackend *backend = CAL_BACKEND (data); - - cal_backend_remove_client (backend, (Cal *) where_cal_was); -} - -static void -listener_died_cb (gpointer cnx, gpointer data) -{ - Cal *cal = CAL (data); - - cal_backend_remove_client (cal_get_backend (cal), cal); -} - -static void -last_client_gone (CalBackend *backend) -{ - g_signal_emit (backend, cal_backend_signals[LAST_CLIENT_GONE], 0); -} - -void -cal_backend_add_client (CalBackend *backend, Cal *cal) -{ - CalBackendPrivate *priv; - - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = backend->priv; - - bonobo_object_set_immortal (BONOBO_OBJECT (cal), TRUE); - - g_object_weak_ref (G_OBJECT (cal), cal_destroy_cb, backend); - - ORBit_small_listen_for_broken (cal_get_listener (cal), G_CALLBACK (listener_died_cb), cal); - - g_mutex_lock (priv->clients_mutex); - priv->clients = g_list_append (priv->clients, cal); - g_mutex_unlock (priv->clients_mutex); - - /* Tell the new client about the list of categories. - * (Ends up telling all the other clients too, but *shrug*.) - */ - /* FIXME This doesn't seem right at all */ - notify_categories_changed (backend); -} - -void -cal_backend_remove_client (CalBackend *backend, Cal *cal) -{ - CalBackendPrivate *priv; - - /* XXX this needs a bit more thinking wrt the mutex - we - should be holding it when we check to see if clients is - NULL */ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = backend->priv; - - /* Disconnect */ - g_mutex_lock (priv->clients_mutex); - priv->clients = g_list_remove (priv->clients, cal); - g_mutex_unlock (priv->clients_mutex); - - /* When all clients go away, notify the parent factory about it so that - * it may decide whether to kill the backend or not. - */ - if (!priv->clients) - last_client_gone (backend); -} - -void -cal_backend_add_query (CalBackend *backend, Query *query) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_mutex_lock (backend->priv->queries_mutex); - - e_list_append (backend->priv->queries, query); - - g_mutex_unlock (backend->priv->queries_mutex); -} - -EList * -cal_backend_get_queries (CalBackend *backend) -{ - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - return g_object_ref (backend->priv->queries); -} - - -/** - * cal_backend_get_cal_address: - * @backend: A calendar backend. - * - * Queries the cal address associated with a calendar backend, which - * must already have an open calendar. - * - * Return value: The cal address associated with the calendar. - **/ -void -cal_backend_get_cal_address (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_cal_address != NULL); - (* CLASS (backend)->get_cal_address) (backend, cal); -} - -void -cal_backend_get_alarm_email_address (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_alarm_email_address != NULL); - (* CLASS (backend)->get_alarm_email_address) (backend, cal); -} - -void -cal_backend_get_ldap_attribute (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_ldap_attribute != NULL); - (* CLASS (backend)->get_ldap_attribute) (backend, cal); -} - -void -cal_backend_get_static_capabilities (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_static_capabilities != NULL); - (* CLASS (backend)->get_static_capabilities) (backend, cal); -} - -/** - * cal_backend_open: - * @backend: A calendar backend. - * @uristr: URI that contains the calendar data. - * @only_if_exists: Whether the calendar should be opened only if it already - * exists. If FALSE, a new calendar will be created when the specified @uri - * does not exist. - * - * Opens a calendar backend with data from a calendar stored at the specified - * URI. - * - * Return value: An operation status code. - **/ -void -cal_backend_open (CalBackend *backend, Cal *cal, gboolean only_if_exists) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->open != NULL); - (* CLASS (backend)->open) (backend, cal, only_if_exists); -} - -void -cal_backend_remove (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->remove != NULL); - (* CLASS (backend)->remove) (backend, cal); -} - -/** - * cal_backend_is_loaded: - * @backend: A calendar backend. - * - * Queries whether a calendar backend has been loaded yet. - * - * Return value: TRUE if the backend has been loaded with data, FALSE - * otherwise. - **/ -gboolean -cal_backend_is_loaded (CalBackend *backend) -{ - gboolean result; - - g_return_val_if_fail (backend != NULL, FALSE); - g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - - g_assert (CLASS (backend)->is_loaded != NULL); - result = (* CLASS (backend)->is_loaded) (backend); - - return result; -} - -/** - * cal_backend_is_read_only - * @backend: A calendar backend. - * - * Queries whether a calendar backend is read only or not. - * - * Return value: TRUE if the calendar is read only, FALSE otherwise. - */ -void -cal_backend_is_read_only (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->is_read_only != NULL); - (* CLASS (backend)->is_read_only) (backend, cal); -} - -void -cal_backend_start_query (CalBackend *backend, Query *query) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->start_query != NULL); - (* CLASS (backend)->start_query) (backend, query); -} - -/** - * cal_backend_get_mode: - * @backend: A calendar backend. - * - * Queries whether a calendar backend is connected remotely. - * - * Return value: The current mode the calendar is in - **/ -CalMode -cal_backend_get_mode (CalBackend *backend) -{ - CalMode result; - - g_return_val_if_fail (backend != NULL, FALSE); - g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - - g_assert (CLASS (backend)->get_mode != NULL); - result = (* CLASS (backend)->get_mode) (backend); - - return result; -} - - -/** - * cal_backend_set_mode: - * @backend: A calendar backend - * @mode: Mode to change to - * - * Sets the mode of the calendar - * - **/ -void -cal_backend_set_mode (CalBackend *backend, CalMode mode) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->set_mode != NULL); - (* CLASS (backend)->set_mode) (backend, mode); -} - -void -cal_backend_get_default_object (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_default_object != NULL); - (* CLASS (backend)->get_default_object) (backend, cal); -} - -/** - * cal_backend_get_object: - * @backend: A calendar backend. - * @uid: Unique identifier for a calendar object. - * @rid: ID for the object's recurrence to get. - * - * Queries a calendar backend for a calendar object based on its unique - * identifier and its recurrence ID (if a recurrent appointment). - * - * Return value: The string representation of a complete calendar wrapping the - * the sought object, or NULL if no object had the specified UID. - **/ -void -cal_backend_get_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (uid != NULL); - - g_assert (CLASS (backend)->get_object != NULL); - (* CLASS (backend)->get_object) (backend, cal, uid, rid); -} - -/** - * cal_backend_get_object_list: - * @backend: - * @type: - * - * - * - * Return value: - **/ -void -cal_backend_get_object_list (CalBackend *backend, Cal *cal, const char *sexp) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_object_list != NULL); - return (* CLASS (backend)->get_object_list) (backend, cal, sexp); -} - -/** - * cal_backend_get_free_busy: - * @backend: A calendar backend. - * @users: List of users to get free/busy information for. - * @start: Start time for query. - * @end: End time for query. - * - * Gets a free/busy object for the given time interval - * - * Return value: a list of CalObj's - **/ -void -cal_backend_get_free_busy (CalBackend *backend, Cal *cal, GList *users, time_t start, time_t end) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (start != -1 && end != -1); - g_return_if_fail (start <= end); - - g_assert (CLASS (backend)->get_free_busy != NULL); - (* CLASS (backend)->get_free_busy) (backend, cal, users, start, end); -} - -/** - * cal_backend_get_changes: - * @backend: A calendar backend - * @change_id: A unique uid for the callers change list - * - * Builds a sequence of objects and the type of change that occurred on them since - * the last time the give change_id was seen - * - * Return value: A list of the objects that changed and the type of change - **/ -void -cal_backend_get_changes (CalBackend *backend, Cal *cal, const char *change_id) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (change_id != NULL); - - g_assert (CLASS (backend)->get_changes != NULL); - (* CLASS (backend)->get_changes) (backend, cal, change_id); -} - -/** - * cal_backend_discard_alarm - * @backend: A calendar backend. - * @uid: UID of the component to discard the alarm from. - * @auid: Alarm ID. - * - * Discards an alarm from the given component. This allows the specific backend - * to do whatever is needed to really discard the alarm. - * - **/ -void -cal_backend_discard_alarm (CalBackend *backend, Cal *cal, const char *uid, const char *auid) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (uid != NULL); - g_return_if_fail (auid != NULL); - - g_assert (CLASS (backend)->discard_alarm != NULL); - (* CLASS (backend)->discard_alarm) (backend, cal, uid, auid); -} - -void -cal_backend_create_object (CalBackend *backend, Cal *cal, const char *calobj) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (calobj != NULL); - - g_assert (CLASS (backend)->create_object != NULL); - (* CLASS (backend)->create_object) (backend, cal, calobj); -} - -void -cal_backend_modify_object (CalBackend *backend, Cal *cal, const char *calobj, CalObjModType mod) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (calobj != NULL); - - g_assert (CLASS (backend)->modify_object != NULL); - (* CLASS (backend)->modify_object) (backend, cal, calobj, mod); -} - -/** - * cal_backend_remove_object: - * @backend: A calendar backend. - * @uid: Unique identifier of the object to remove. - * @rid: A recurrence ID. - * - * Removes an object in a calendar backend. The backend will notify all of its - * clients about the change. - * - **/ -void -cal_backend_remove_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (uid != NULL); - - g_assert (CLASS (backend)->remove_object != NULL); - (* CLASS (backend)->remove_object) (backend, cal, uid, rid, mod); -} - -void -cal_backend_receive_objects (CalBackend *backend, Cal *cal, const char *calobj) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (calobj != NULL); - - g_assert (CLASS (backend)->receive_objects != NULL); - return (* CLASS (backend)->receive_objects) (backend, cal, calobj); -} - -void -cal_backend_send_objects (CalBackend *backend, Cal *cal, const char *calobj) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (calobj != NULL); - - g_assert (CLASS (backend)->send_objects != NULL); - return (* CLASS (backend)->send_objects) (backend, cal, calobj); -} - -/** - * cal_backend_get_timezone: - * @backend: A calendar backend. - * @tzid: Unique identifier of a VTIMEZONE object. Note that this must not be - * NULL. - * - * Returns the icaltimezone* corresponding to the TZID, or NULL if the TZID - * can't be found. - * - * Returns: The icaltimezone* corresponding to the given TZID, or NULL. - **/ -void -cal_backend_get_timezone (CalBackend *backend, Cal *cal, const char *tzid) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (tzid != NULL); - - g_assert (CLASS (backend)->get_timezone != NULL); - (* CLASS (backend)->get_timezone) (backend, cal, tzid); -} - -/** - * cal_backend_set_default_timezone: - * @backend: A calendar backend. - * @tzid: The TZID identifying the timezone. - * - * Sets the default timezone for the calendar, which is used to resolve - * DATE and floating DATE-TIME values. - * - * Returns: TRUE if the VTIMEZONE data for the timezone was found, or FALSE if - * not. - **/ -void -cal_backend_set_default_timezone (CalBackend *backend, Cal *cal, const char *tzid) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (tzid != NULL); - - g_assert (CLASS (backend)->set_default_timezone != NULL); - (* CLASS (backend)->set_default_timezone) (backend, cal, tzid); -} - -/** - * cal_backend_add_timezone - * @backend: A calendar backend. - * @tzobj: The timezone object, in a string. - * - * Add a timezone object to the given backend. - * - * Returns: TRUE if successful, or FALSE if not. - */ -void -cal_backend_add_timezone (CalBackend *backend, Cal *cal, const char *tzobj) -{ - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (tzobj != NULL); - g_return_if_fail (CLASS (backend)->add_timezone != NULL); - - (* CLASS (backend)->add_timezone) (backend, cal, tzobj); -} - -icaltimezone * -cal_backend_internal_get_default_timezone (CalBackend *backend) -{ - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - g_return_val_if_fail (CLASS (backend)->internal_get_default_timezone != NULL, NULL); - - return (* CLASS (backend)->internal_get_default_timezone) (backend); -} - -icaltimezone * -cal_backend_internal_get_timezone (CalBackend *backend, const char *tzid) -{ - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - g_return_val_if_fail (tzid != NULL, NULL); - g_return_val_if_fail (CLASS (backend)->internal_get_timezone != NULL, NULL); - - return (* CLASS (backend)->internal_get_timezone) (backend, tzid); -} - -/** - * cal_backend_notify_object_created: - * @backend: A calendar backend. - * @calobj: iCalendar representation of new object - * - * Notifies each of the backend's listeners about a new object. - * - * cal_notify_object_created() calls this for you. You only need to - * call cal_backend_notify_object_created() yourself to report objects - * created by non-PCS clients. - **/ -void -cal_backend_notify_object_created (CalBackend *backend, const char *calobj) -{ - EList *queries; - EIterator *iter; - Query *query; - - queries = cal_backend_get_queries (backend); - iter = e_list_get_iterator (queries); - - while (e_iterator_is_valid (iter)) { - query = QUERY (e_iterator_get (iter)); - - bonobo_object_ref (query); - if (query_object_matches (query, calobj)) - query_notify_objects_added_1 (query, calobj); - bonobo_object_unref (query); - - e_iterator_next (iter); - } - g_object_unref (iter); - g_object_unref (queries); -} - -/** - * cal_backend_notify_object_modified: - * @backend: A calendar backend. - * @old_object: iCalendar representation of the original form of the object - * @object: iCalendar representation of the new form of the object - * - * Notifies each of the backend's listeners about a modified object. - * - * cal_notify_object_modified() calls this for you. You only need to - * call cal_backend_notify_object_modified() yourself to report objects - * modified by non-PCS clients. - **/ -void -cal_backend_notify_object_modified (CalBackend *backend, - const char *old_object, const char *object) -{ - EList *queries; - EIterator *iter; - Query *query; - gboolean old_match, new_match; - - queries = cal_backend_get_queries (backend); - iter = e_list_get_iterator (queries); - - while (e_iterator_is_valid (iter)) { - query = QUERY (e_iterator_get (iter)); - - bonobo_object_ref (query); - - old_match = query_object_matches (query, old_object); - new_match = query_object_matches (query, object); - if (old_match && new_match) - query_notify_objects_modified_1 (query, object); - else if (new_match) - query_notify_objects_added_1 (query, object); - else /* if (old_match) */ { - icalcomponent *comp; - - comp = icalcomponent_new_from_string ((char *)old_object); - query_notify_objects_removed_1 (query, icalcomponent_get_uid (comp)); - icalcomponent_free (comp); - } - - bonobo_object_unref (query); - - e_iterator_next (iter); - } - g_object_unref (iter); - g_object_unref (queries); -} - -/** - * cal_backend_notify_object_removed: - * @backend: A calendar backend. - * @uid: the UID of the removed object - * @old_object: iCalendar representation of the removed object - * - * Notifies each of the backend's listeners about a removed object. - * - * cal_notify_object_removed() calls this for you. You only need to - * call cal_backend_notify_object_removed() yourself to report objects - * removed by non-PCS clients. - **/ -void -cal_backend_notify_object_removed (CalBackend *backend, const char *uid, - const char *old_object) -{ - EList *queries; - EIterator *iter; - Query *query; - - queries = cal_backend_get_queries (backend); - iter = e_list_get_iterator (queries); - - while (e_iterator_is_valid (iter)) { - query = QUERY (e_iterator_get (iter)); - - bonobo_object_ref (query); - if (query_object_matches (query, old_object)) - query_notify_objects_removed_1 (query, uid); - bonobo_object_unref (query); - - e_iterator_next (iter); - } - g_object_unref (iter); - g_object_unref (queries); -} - -/** - * cal_backend_notify_mode: - * @backend: A calendar backend. - * @status: Status of the mode set - * @mode: the current mode - * - * Notifies each of the backend's listeners about the results of a - * setMode call. - **/ -void -cal_backend_notify_mode (CalBackend *backend, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode) -{ - CalBackendPrivate *priv = backend->priv; - GList *l; - - for (l = priv->clients; l; l = l->next) - cal_notify_mode (l->data, status, mode); -} - -/** - * cal_backend_notify_error: - * @backend: A calendar backend. - * @message: Error message - * - * Notifies each of the backend's listeners about an error - **/ -void -cal_backend_notify_error (CalBackend *backend, const char *message) -{ - CalBackendPrivate *priv = backend->priv; - GList *l; - - for (l = priv->clients; l; l = l->next) - cal_notify_error (l->data, message); -} - -static void -add_category_cb (gpointer name, gpointer category, gpointer data) -{ - GNOME_Evolution_Calendar_StringSeq *seq = data; - - seq->_buffer[seq->_length++] = CORBA_string_dup (name); -} - -static void -notify_categories_changed (CalBackend *backend) -{ - CalBackendPrivate *priv = backend->priv; - GNOME_Evolution_Calendar_StringSeq *seq; - GList *l; - - /* Build the sequence of category names */ - seq = GNOME_Evolution_Calendar_StringSeq__alloc (); - seq->_length = 0; - seq->_maximum = g_hash_table_size (priv->categories); - seq->_buffer = CORBA_sequence_CORBA_string_allocbuf (seq->_maximum); - CORBA_sequence_set_release (seq, TRUE); - - g_hash_table_foreach (priv->categories, add_category_cb, seq); - - /* Notify the clients */ - for (l = priv->clients; l; l = l->next) - cal_notify_categories_changed (l->data, seq); - - CORBA_free (seq); -} - -static gboolean -idle_notify_categories_changed (gpointer data) -{ - CalBackend *backend = CAL_BACKEND (data); - CalBackendPrivate *priv = backend->priv; - - if (g_hash_table_size (priv->changed_categories)) { - notify_categories_changed (backend); - g_hash_table_foreach_remove (priv->changed_categories, prune_changed_categories, NULL); - } - - priv->category_idle_id = 0; - - return FALSE; -} - -/** - * cal_backend_ref_categories: - * @backend: A calendar backend - * @categories: a list of categories - * - * Adds 1 to the refcount of each of the named categories. If any of - * the categories are new, clients will be notified of the updated - * category list at idle time. - **/ -void -cal_backend_ref_categories (CalBackend *backend, GSList *categories) -{ - CalBackendPrivate *priv; - CalBackendCategory *c; - const char *name; - - priv = backend->priv; - - while (categories) { - name = categories->data; - c = g_hash_table_lookup (priv->categories, name); - - if (c) - c->refcount++; - else { - /* See if it was recently removed */ - - c = g_hash_table_lookup (priv->changed_categories, name); - if (c && c->refcount == 0) { - /* Move it back to the set of live categories */ - g_hash_table_remove (priv->changed_categories, c->name); - - c->refcount = 1; - g_hash_table_insert (priv->categories, c->name, c); - } else { - /* Create a new category */ - c = g_new (CalBackendCategory, 1); - c->name = g_strdup (name); - c->refcount = 1; - g_hash_table_insert (priv->categories, c->name, c); - g_hash_table_insert (priv->changed_categories, c->name, c); - } - } - - categories = categories->next; - } - - if (g_hash_table_size (priv->changed_categories) && - !priv->category_idle_id) - priv->category_idle_id = g_idle_add (idle_notify_categories_changed, backend); -} - -/** - * cal_backend_unref_categories: - * @backend: A calendar backend - * @categories: a list of categories - * - * Subtracts 1 from the refcount of each of the named categories. If - * any of the refcounts go down to 0, clients will be notified of the - * updated category list at idle time. - **/ -void -cal_backend_unref_categories (CalBackend *backend, GSList *categories) -{ - CalBackendPrivate *priv; - CalBackendCategory *c; - const char *name; - - priv = backend->priv; - - while (categories) { - name = categories->data; - c = g_hash_table_lookup (priv->categories, name); - - if (c) { - g_assert (c != NULL); - g_assert (c->refcount > 0); - - c->refcount--; - - if (c->refcount == 0) { - g_hash_table_remove (priv->categories, c->name); - g_hash_table_insert (priv->changed_categories, c->name, c); - } - } - - categories = categories->next; - } - - if (g_hash_table_size (priv->changed_categories) && - !priv->category_idle_id) - priv->category_idle_id = g_idle_add (idle_notify_categories_changed, backend); -} diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h deleted file mode 100644 index 5b4e59a6a8..0000000000 --- a/calendar/pcs/cal-backend.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_BACKEND_H -#define CAL_BACKEND_H - -#include -#include -#include -#include "pcs/evolution-calendar.h" -#include "pcs/cal-common.h" -#include "pcs/cal.h" -#include "pcs/query.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_TYPE (cal_backend_get_type ()) -#define CAL_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_TYPE, CalBackend)) -#define CAL_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_TYPE, \ - CalBackendClass)) -#define IS_CAL_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_TYPE)) -#define IS_CAL_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_TYPE)) - -typedef struct _CalBackendPrivate CalBackendPrivate; - -struct _CalBackend { - GObject object; - - CalBackendPrivate *priv; -}; - -struct _CalBackendClass { - GObjectClass parent_class; - - /* Notification signals */ - void (* last_client_gone) (CalBackend *backend); - void (* cal_added) (CalBackend *backend, Cal *cal); - - gboolean (* is_loaded) (CalBackend *backend); - - /* FIXME What to pass back here */ - void (* opened) (CalBackend *backend, int status); - void (* removed) (CalBackend *backend, int status); - void (* obj_updated) (CalBackend *backend, const char *uid); - - /* Virtual methods */ - void (* is_read_only) (CalBackend *backend, Cal *cal); - void (* get_cal_address) (CalBackend *backend, Cal *cal); - void (* get_alarm_email_address) (CalBackend *backend, Cal *cal); - void (* get_ldap_attribute) (CalBackend *backend, Cal *cal); - void (* get_static_capabilities) (CalBackend *backend, Cal *cal); - - void (* open) (CalBackend *backend, Cal *cal, gboolean only_if_exists); - void (* remove) (CalBackend *backend, Cal *cal); - - /* Object related virtual methods */ - void (* create_object) (CalBackend *backend, Cal *cal, const char *calobj); - void (* modify_object) (CalBackend *backend, Cal *cal, const char *calobj, CalObjModType mod); - void (* remove_object) (CalBackend *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod); - - void (* discard_alarm) (CalBackend *backend, Cal *cal, const char *uid, const char *auid); - - void (* receive_objects) (CalBackend *backend, Cal *cal, const char *calobj); - void (* send_objects) (CalBackend *backend, Cal *cal, const char *calobj); - - void (* get_default_object) (CalBackend *backend, Cal *cal); - void (* get_object) (CalBackend *backend, Cal *cal, const char *uid, const char *rid); - void (* get_object_list) (CalBackend *backend, Cal *cal, const char *sexp); - - /* Timezone related virtual methods */ - void (* get_timezone) (CalBackend *backend, Cal *cal, const char *tzid); - void (* add_timezone) (CalBackend *backend, Cal *cal, const char *object); - void (* set_default_timezone) (CalBackend *backend, Cal *cal, const char *tzid); - - void (* start_query) (CalBackend *backend, Query *query); - - /* Mode relate virtual methods */ - CalMode (* get_mode) (CalBackend *backend); - void (* set_mode) (CalBackend *backend, CalMode mode); - - void (* get_free_busy) (CalBackend *backend, Cal *cal, GList *users, time_t start, time_t end); - void (* get_changes) (CalBackend *backend, Cal *cal, const char *change_id); - - /* Internal methods for use only in the pcs */ - icaltimezone *(* internal_get_default_timezone) (CalBackend *backend); - icaltimezone *(* internal_get_timezone) (CalBackend *backend, const char *tzid); -}; - -GType cal_backend_get_type (void); - -const char *cal_backend_get_uri (CalBackend *backend); -icalcomponent_kind cal_backend_get_kind (CalBackend *backend); - -void cal_backend_add_client (CalBackend *backend, Cal *cal); -void cal_backend_remove_client (CalBackend *backend, Cal *cal); - -void cal_backend_add_query (CalBackend *backend, Query *query); -EList *cal_backend_get_queries (CalBackend *backend); - -void cal_backend_is_read_only (CalBackend *backend, Cal *cal); -void cal_backend_get_cal_address (CalBackend *backend, Cal *cal); -void cal_backend_get_alarm_email_address (CalBackend *backend, Cal *cal); -void cal_backend_get_ldap_attribute (CalBackend *backend, Cal *cal); -void cal_backend_get_static_capabilities (CalBackend *backend, Cal *cal); - -void cal_backend_open (CalBackend *backend, Cal *cal, gboolean only_if_exists); -void cal_backend_remove (CalBackend *backend, Cal *cal); - -void cal_backend_create_object (CalBackend *backend, Cal *cal, const char *calobj); -void cal_backend_modify_object (CalBackend *backend, Cal *cal, const char *calobj, CalObjModType mod); -void cal_backend_remove_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod); - -void cal_backend_discard_alarm (CalBackend *backend, Cal *cal, const char *uid, const char *auid); - -void cal_backend_receive_objects (CalBackend *backend, Cal *cal, const char *calobj); -void cal_backend_send_objects (CalBackend *backend, Cal *cal, const char *calobj); - -void cal_backend_get_default_object (CalBackend *backend, Cal *cal); -void cal_backend_get_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid); -void cal_backend_get_object_list (CalBackend *backend, Cal *cal, const char *sexp); - -gboolean cal_backend_is_loaded (CalBackend *backend); - -void cal_backend_start_query (CalBackend *backend, Query *query); - -CalMode cal_backend_get_mode (CalBackend *backend); -void cal_backend_set_mode (CalBackend *backend, CalMode mode); - -void cal_backend_get_timezone (CalBackend *backend, Cal *cal, const char *tzid); -void cal_backend_add_timezone (CalBackend *backend, Cal *cal, const char *object); -void cal_backend_set_default_timezone (CalBackend *backend, Cal *cal, const char *tzid); - -void cal_backend_get_changes (CalBackend *backend, Cal *cal, const char *change_id); -void cal_backend_get_free_busy (CalBackend *backend, Cal *cal, GList *users, time_t start, time_t end); - -icaltimezone* cal_backend_internal_get_default_timezone (CalBackend *backend); -icaltimezone* cal_backend_internal_get_timezone (CalBackend *backend, const char *tzid); - -void cal_backend_last_client_gone (CalBackend *backend); - -void cal_backend_notify_object_created (CalBackend *backend, const char *calobj); -void cal_backend_notify_object_modified (CalBackend *backend, const char *old_object, const char *object); -void cal_backend_notify_object_removed (CalBackend *backend, const char *uid, const char *old_object); - -void cal_backend_notify_mode (CalBackend *backend, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode); -void cal_backend_notify_error (CalBackend *backend, const char *message); -void cal_backend_ref_categories (CalBackend *backend, GSList *categories); -void cal_backend_unref_categories (CalBackend *backend, GSList *categories); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-common.h b/calendar/pcs/cal-common.h deleted file mode 100644 index 5a588c93c8..0000000000 --- a/calendar/pcs/cal-common.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Evolution calendar server - common declarations - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_COMMON_H -#define CAL_COMMON_H - -#include - -G_BEGIN_DECLS - - - -typedef struct _CalBackend CalBackend; -typedef struct _CalBackendClass CalBackendClass; - -typedef struct _Cal Cal; -typedef struct _CalClass CalClass; - -typedef struct _Query Query; -typedef struct _QueryClass QueryClass; - -typedef struct _CalBackendObjectSExp CalBackendObjectSExp; -typedef struct _CalBackendObjectSExpClass CalBackendObjectSExpClass; - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c deleted file mode 100644 index 2f72ec5911..0000000000 --- a/calendar/pcs/cal-factory.c +++ /dev/null @@ -1,482 +0,0 @@ -/* Evolution calendar factory - * - * Copyright (C) 2000-2003 Ximian, Inc. - * - * Authors: - * Federico Mena-Quintero - * JP Rosevear - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 -#include -#include -#include "e-util/e-url.h" -#include "evolution-calendar.h" -#include "cal-backend.h" -#include "cal.h" -#include "cal-factory.h" - -#define PARENT_TYPE BONOBO_TYPE_OBJECT -#define DEFAULT_CAL_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_CalendarFactory" - -static BonoboObjectClass *parent_class; - -/* Private part of the CalFactory structure */ -struct _CalFactoryPrivate { - /* Hash table from URI method strings to GType * for backend class types */ - GHashTable *methods; - - /* Hash table from GnomeVFSURI structures to CalBackend objects */ - GHashTable *backends; - - /* OAFIID of the factory */ - char *iid; - - /* Whether we have been registered with OAF yet */ - guint registered : 1; -}; - -/* Signal IDs */ -enum SIGNALS { - LAST_CALENDAR_GONE, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -/* Opening calendars */ -static icalcomponent_kind -calobjtype_to_icalkind (const GNOME_Evolution_Calendar_CalObjType type) -{ - switch (type){ - case GNOME_Evolution_Calendar_TYPE_EVENT: - return ICAL_VEVENT_COMPONENT; - case GNOME_Evolution_Calendar_TYPE_TODO: - return ICAL_VTODO_COMPONENT; - case GNOME_Evolution_Calendar_TYPE_JOURNAL: - return ICAL_VJOURNAL_COMPONENT; - } - - return ICAL_NO_COMPONENT; -} - -static GType -get_backend_type (GHashTable *methods, const char *method, icalcomponent_kind kind) -{ - GHashTable *kinds; - GType type; - - kinds = g_hash_table_lookup (methods, method); - if (!kinds) - return 0; - - type = GPOINTER_TO_INT (g_hash_table_lookup (kinds, GINT_TO_POINTER (kind))); - - return type; -} - -/* Looks up a calendar backend in a factory's hash table of uri->cal. If - * *non-NULL, orig_uri_return will be set to point to the original key in the - * *hash table. - */ -static CalBackend * -lookup_backend (CalFactory *factory, const char *uristr) -{ - CalFactoryPrivate *priv; - EUri *uri; - CalBackend *backend; - char *tmp; - - priv = factory->priv; - - uri = e_uri_new (uristr); - if (!uri) - return NULL; - - tmp = e_uri_to_string (uri, FALSE); - backend = g_hash_table_lookup (priv->backends, tmp); - g_free (tmp); - e_uri_free (uri); - - return backend; -} - -/* Callback used when a backend loses its last connected client */ -static void -backend_last_client_gone_cb (CalBackend *backend, gpointer data) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - CalBackend *ret_backend; - const char *uristr; - - fprintf (stderr, "backend_last_client_gone_cb() called!\n"); - - factory = CAL_FACTORY (data); - priv = factory->priv; - - /* Remove the backend from the hash table */ - - uristr = cal_backend_get_uri (backend); - g_assert (uristr != NULL); - - ret_backend = lookup_backend (factory, uristr); - g_assert (ret_backend != NULL); - g_assert (ret_backend == backend); - - g_hash_table_remove (priv->backends, uristr); - - /* Notify upstream if there are no more backends */ - - if (g_hash_table_size (priv->backends) == 0) - g_signal_emit (G_OBJECT (factory), signals[LAST_CALENDAR_GONE], 0); -} - - - -static GNOME_Evolution_Calendar_Cal -impl_CalFactory_getCal (PortableServer_Servant servant, - const CORBA_char *str_uri, - const GNOME_Evolution_Calendar_CalObjType type, - const GNOME_Evolution_Calendar_Listener listener, - CORBA_Environment *ev) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - Cal *cal = CORBA_OBJECT_NIL; - CalBackend *backend; - CORBA_Environment ev2; - GNOME_Evolution_Calendar_Listener listener_copy; - GType backend_type; - EUri *uri; - char *uri_string; - - factory = CAL_FACTORY (bonobo_object_from_servant (servant)); - priv = factory->priv; - - /* Parse the uri */ - uri = e_uri_new (str_uri); - if (!uri) { - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI); - - return CORBA_OBJECT_NIL; - } - uri_string = e_uri_to_string (uri, FALSE); - - /* Find the associated backend type (if any) */ - backend_type = get_backend_type (priv->methods, uri->protocol, calobjtype_to_icalkind (type)); - if (!backend_type) { - /* FIXME Distinguish between method and kind failures? */ - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod); - goto cleanup; - } - - /* Duplicate the listener object */ - CORBA_exception_init (&ev2); - listener_copy = CORBA_Object_duplicate (listener, &ev2); - - if (BONOBO_EX (&ev2)) { - g_warning (G_STRLOC ": could not duplicate the listener"); - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_NilListener); - CORBA_exception_free (&ev2); - goto cleanup; - } - CORBA_exception_free (&ev2); - - /* Look for an existing backend */ - backend = lookup_backend (factory, uri_string); - if (!backend) { - /* There was no existing backend, create a new one */ - backend = g_object_new (backend_type, "uri", uri_string, "kind", calobjtype_to_icalkind (type), NULL); - if (!backend) { - g_warning (G_STRLOC ": could not instantiate backend"); - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod); - goto cleanup; - } - - /* Track the backend */ - g_hash_table_insert (priv->backends, g_strdup (uri_string), backend); - - g_signal_connect (G_OBJECT (backend), "last_client_gone", - G_CALLBACK (backend_last_client_gone_cb), - factory); - } - - /* Create the corba calendar */ - cal = cal_new (backend, uri_string, listener); - if (!cal) { - g_warning (G_STRLOC ": could not create the corba calendar"); - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod); - goto cleanup; - } - - /* Let the backend know about its clients corba clients */ - cal_backend_add_client (backend, cal); - - cleanup: - e_uri_free (uri); - g_free (uri_string); - - return CORBA_Object_duplicate (BONOBO_OBJREF (cal), ev); -} - - - -/** - * cal_factory_new: - * @void: - * - * Creates a new #CalFactory object. - * - * Return value: A newly-created #CalFactory, or NULL if its corresponding CORBA - * object could not be created. - **/ -CalFactory * -cal_factory_new (void) -{ - CalFactory *factory; - - factory = g_object_new (CAL_FACTORY_TYPE, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL), - NULL); - - return factory; -} - -/* Destroy handler for the calendar */ -static void -cal_factory_finalize (GObject *object) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_FACTORY (object)); - - factory = CAL_FACTORY (object); - priv = factory->priv; - - g_hash_table_destroy (priv->methods); - priv->methods = NULL; - - /* Should we assert that there are no more backends? */ - g_hash_table_destroy (priv->backends); - priv->backends = NULL; - - if (priv->registered) { - bonobo_activation_active_server_unregister (priv->iid, BONOBO_OBJREF (factory)); - priv->registered = FALSE; - } - g_free (priv->iid); - - g_free (priv); - factory->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Class initialization function for the calendar factory */ -static void -cal_factory_class_init (CalFactoryClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - POA_GNOME_Evolution_Calendar_CalFactory__epv *epv = &klass->epv; - - parent_class = g_type_class_peek_parent (klass); - - signals[LAST_CALENDAR_GONE] = - g_signal_new ("last_calendar_gone", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalFactoryClass, last_calendar_gone), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /* Class method overrides */ - object_class->finalize = cal_factory_finalize; - - /* Epv methods */ - epv->getCal = impl_CalFactory_getCal; -} - -/* Object initialization function for the calendar factory */ -static void -cal_factory_init (CalFactory *factory, CalFactoryClass *klass) -{ - CalFactoryPrivate *priv; - - priv = g_new0 (CalFactoryPrivate, 1); - factory->priv = priv; - - priv->methods = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_destroy); - priv->backends = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref); - priv->registered = FALSE; -} - -BONOBO_TYPE_FUNC_FULL (CalFactory, - GNOME_Evolution_Calendar_CalFactory, - PARENT_TYPE, - cal_factory); - -/** - * cal_factory_register_storage: - * @factory: A calendar factory. - * @iid: OAFIID for the factory to be registered. - * - * Registers a calendar factory with the OAF object activation daemon. This - * function must be called before any clients can activate the factory. - * - * Return value: TRUE on success, FALSE otherwise. - **/ -gboolean -cal_factory_register_storage (CalFactory *factory, const char *iid) -{ - CalFactoryPrivate *priv; - Bonobo_RegistrationResult result; - char *tmp_iid; - - g_return_val_if_fail (factory != NULL, FALSE); - g_return_val_if_fail (IS_CAL_FACTORY (factory), FALSE); - - priv = factory->priv; - - g_return_val_if_fail (!priv->registered, FALSE); - - /* if iid is NULL, use the default factory OAFIID */ - if (iid) - tmp_iid = g_strdup (iid); - else - tmp_iid = g_strdup (DEFAULT_CAL_FACTORY_OAF_ID); - - result = bonobo_activation_active_server_register (tmp_iid, BONOBO_OBJREF (factory)); - - switch (result) { - case Bonobo_ACTIVATION_REG_SUCCESS: - priv->registered = TRUE; - priv->iid = tmp_iid; - return TRUE; - - case Bonobo_ACTIVATION_REG_NOT_LISTED: - g_warning (G_STRLOC ": cannot register the calendar factory (not listed)"); - break; - - case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE: - g_warning (G_STRLOC ": cannot register the calendar factory (already active)"); - break; - - case Bonobo_ACTIVATION_REG_ERROR: - default: - g_warning (G_STRLOC ": cannot register the calendar factory (generic error)"); - break; - } - - g_free (tmp_iid); - - return FALSE; -} - -/** - * cal_factory_register_method: - * @factory: A calendar factory. - * @method: Method for the URI, i.e. "http", "file", etc. - * @backend_type: Class type of the backend to create for this @method. - * - * Registers the type of a #CalBackend subclass that will be used to handle URIs - * with a particular method. When the factory is asked to open a particular - * URI, it will look in its list of registered methods and create a backend of - * the appropriate type. - **/ -void -cal_factory_register_method (CalFactory *factory, const char *method, icalcomponent_kind kind, GType backend_type) -{ - CalFactoryPrivate *priv; - char *method_str; - GHashTable *kinds; - GType type; - - g_return_if_fail (factory != NULL); - g_return_if_fail (IS_CAL_FACTORY (factory)); - g_return_if_fail (method != NULL); - g_return_if_fail (backend_type != 0); - g_return_if_fail (g_type_is_a (backend_type, CAL_BACKEND_TYPE)); - - priv = factory->priv; - - method_str = g_ascii_strdown (method, -1); - - kinds = g_hash_table_lookup (priv->methods, method_str); - if (kinds) { - type = GPOINTER_TO_INT (g_hash_table_lookup (kinds, GINT_TO_POINTER (kind))); - if (type) { - g_warning (G_STRLOC ": method `%s' already registered", method_str); - g_free (method_str); - - return; - } - } else { - kinds = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL); - g_hash_table_insert (priv->methods, method_str, kinds); - } - - g_hash_table_insert (kinds, GINT_TO_POINTER (kind), GINT_TO_POINTER (backend_type)); -} - -/** - * cal_factory_get_n_backends - * @factory: A calendar factory. - * - * Get the number of backends currently active in the given factory. - * - * Returns: the number of backends. - */ -int -cal_factory_get_n_backends (CalFactory *factory) -{ - CalFactoryPrivate *priv; - - g_return_val_if_fail (IS_CAL_FACTORY (factory), 0); - - priv = factory->priv; - return g_hash_table_size (priv->backends); -} - -/* Frees a uri/backend pair from the backends hash table */ -static void -dump_backend (gpointer key, gpointer value, gpointer data) -{ - char *uri; - CalBackend *backend; - - uri = key; - backend = value; - - g_message (" %s: %p", uri, backend); -} - -void -cal_factory_dump_active_backends (CalFactory *factory) -{ - CalFactoryPrivate *priv; - - g_message ("Active PCS backends"); - - priv = factory->priv; - g_hash_table_foreach (priv->backends, dump_backend, NULL); -} diff --git a/calendar/pcs/cal-factory.h b/calendar/pcs/cal-factory.h deleted file mode 100644 index d6d2b895ed..0000000000 --- a/calendar/pcs/cal-factory.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Evolution calendar factory - * - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_FACTORY_H -#define CAL_FACTORY_H - -#include -#include - -#include "pcs/evolution-calendar.h" - -G_BEGIN_DECLS - - - -#define CAL_FACTORY_TYPE (cal_factory_get_type ()) -#define CAL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_FACTORY_TYPE, CalFactory)) -#define CAL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_FACTORY_TYPE, \ - CalFactoryClass)) -#define IS_CAL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_FACTORY_TYPE)) -#define IS_CAL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_FACTORY_TYPE)) - -typedef struct _CalFactory CalFactory; -typedef struct _CalFactoryClass CalFactoryClass; - -typedef struct _CalFactoryPrivate CalFactoryPrivate; - -struct _CalFactory { - BonoboObject object; - - /* Private data */ - CalFactoryPrivate *priv; -}; - -struct _CalFactoryClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Calendar_CalFactory__epv epv; - - /* Notification signals */ - void (* last_calendar_gone) (CalFactory *factory); -}; - -GType cal_factory_get_type (void); -CalFactory *cal_factory_new (void); - -gboolean cal_factory_register_storage (CalFactory *factory, const char *iid); -void cal_factory_register_method (CalFactory *factory, - const char *method, - icalcomponent_kind kind, - GType backend_type); -int cal_factory_get_n_backends (CalFactory *factory); -void cal_factory_dump_active_backends (CalFactory *factory); - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c deleted file mode 100644 index aec1591da3..0000000000 --- a/calendar/pcs/cal.c +++ /dev/null @@ -1,1244 +0,0 @@ -/* Evolution calendar client interface object - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include "cal-backend.h" -#include "cal.h" - -#define PARENT_TYPE BONOBO_TYPE_OBJECT - -static BonoboObjectClass *parent_class; - -/* Private part of the Cal structure */ -struct _CalPrivate { - /* Our backend */ - CalBackend *backend; - - /* Listener on the client we notify */ - GNOME_Evolution_Calendar_Listener listener; -}; - -/* Cal::get_uri method */ -static CORBA_char * -impl_Cal_get_uri (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - const char *str_uri; - CORBA_char *str_uri_copy; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - str_uri = cal_backend_get_uri (priv->backend); - str_uri_copy = CORBA_string_dup (str_uri); - - return str_uri_copy; -} - -static void -impl_Cal_open (PortableServer_Servant servant, - CORBA_boolean only_if_exists, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_open (priv->backend, cal, only_if_exists); -} - -static void -impl_Cal_remove (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_remove (priv->backend, cal); -} - -/* Cal::isReadOnly method */ -static void -impl_Cal_isReadOnly (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_is_read_only (priv->backend, cal); -} - -/* Cal::getEmailAddress method */ -static void -impl_Cal_getCalAddress (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_cal_address (priv->backend, cal); -} - -/* Cal::get_alarm_email_address method */ -static void -impl_Cal_getAlarmEmailAddress (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_alarm_email_address (priv->backend, cal); -} - -/* Cal::get_ldap_attribute method */ -static void -impl_Cal_getLdapAttribute (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_ldap_attribute (priv->backend, cal); -} - -/* Cal::getSchedulingInformation method */ -static void -impl_Cal_getStaticCapabilities (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_static_capabilities (priv->backend, cal); -} - -/* Cal::setMode method */ -static void -impl_Cal_setMode (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CalMode mode, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_set_mode (priv->backend, mode); -} - -static void -impl_Cal_getDefaultObject (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_default_object (priv->backend, cal); -} - -/* Cal::getObject method */ -static void -impl_Cal_getObject (PortableServer_Servant servant, - const CORBA_char *uid, - const CORBA_char *rid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_object (priv->backend, cal, uid, rid); -} - -/* Cal::getObjectsInRange method */ -static void -impl_Cal_getObjectList (PortableServer_Servant servant, - const CORBA_char *query, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_object_list (priv->backend, cal, query); -} - -/* Cal::getChanges method */ -static void -impl_Cal_getChanges (PortableServer_Servant servant, - const CORBA_char *change_id, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_changes (priv->backend, cal, change_id); -} - -/* Cal::getFreeBusy method */ -static void -impl_Cal_getFreeBusy (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_UserList *user_list, - const GNOME_Evolution_Calendar_Time_t start, - const GNOME_Evolution_Calendar_Time_t end, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - GList *users = NULL; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - /* convert the CORBA user list to a GList */ - if (user_list) { - int i; - - for (i = 0; i < user_list->_length; i++) - users = g_list_append (users, user_list->_buffer[i]); - } - - /* call the backend's get_free_busy method */ - cal_backend_get_free_busy (priv->backend, cal, users, start, end); -} - -/* Cal::discardAlarm method */ -static void -impl_Cal_discardAlarm (PortableServer_Servant servant, - const CORBA_char *uid, - const CORBA_char *auid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_discard_alarm (priv->backend, cal, uid, auid); -} - -static void -impl_Cal_createObject (PortableServer_Servant servant, - const CORBA_char *calobj, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_create_object (priv->backend, cal, calobj); -} - -static void -impl_Cal_modifyObject (PortableServer_Servant servant, - const CORBA_char *calobj, - const GNOME_Evolution_Calendar_CalObjModType mod, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_modify_object (priv->backend, cal, calobj, mod); -} - -/* Cal::removeObject method */ -static void -impl_Cal_removeObject (PortableServer_Servant servant, - const CORBA_char *uid, - const CORBA_char *rid, - const GNOME_Evolution_Calendar_CalObjModType mod, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_remove_object (priv->backend, cal, uid, rid, mod); -} - -static void -impl_Cal_receiveObjects (PortableServer_Servant servant, const CORBA_char *calobj, CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_receive_objects (priv->backend, cal, calobj); -} - -static void -impl_Cal_sendObjects (PortableServer_Servant servant, const CORBA_char *calobj, CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_send_objects (priv->backend, cal, calobj); -} - -/* Cal::getQuery implementation */ -static void -impl_Cal_getQuery (PortableServer_Servant servant, - const CORBA_char *sexp, - GNOME_Evolution_Calendar_QueryListener ql, - CORBA_Environment *ev) -{ - - Cal *cal; - CalPrivate *priv; - Query *query; - CalBackendObjectSExp *obj_sexp; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - /* we handle this entirely here, since it doesn't require any - backend involvement now that we have pas_book_view_start to - actually kick off the search. */ - - obj_sexp = cal_backend_object_sexp_new (sexp); - if (!obj_sexp) { - cal_notify_query (cal, GNOME_Evolution_Calendar_InvalidQuery, NULL); - - return; - } - - query = query_new (priv->backend, ql, obj_sexp); - if (!query) { - g_object_unref (obj_sexp); - cal_notify_query (cal, GNOME_Evolution_Calendar_OtherError, NULL); - - return; - } - - cal_backend_add_query (priv->backend, query); - - cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query); - - g_object_unref (query); -} - - -/* Cal::getTimezone method */ -static void -impl_Cal_getTimezone (PortableServer_Servant servant, - const CORBA_char *tzid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_timezone (priv->backend, cal, tzid); -} - -/* Cal::addTimezone method */ -static void -impl_Cal_addTimezone (PortableServer_Servant servant, - const CORBA_char *tz, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_add_timezone (priv->backend, cal, tz); -} - -/* Cal::setDefaultTimezone method */ -static void -impl_Cal_setDefaultTimezone (PortableServer_Servant servant, - const CORBA_char *tzid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_set_default_timezone (priv->backend, cal, tzid); -} - -/** - * cal_construct: - * @cal: A calendar client interface. - * @corba_cal: CORBA object for the calendar. - * @backend: Calendar backend that this @cal presents an interface to. - * @listener: Calendar listener for notification. - * - * Constructs a calendar client interface object by binding the corresponding - * CORBA object to it. The calendar interface is bound to the specified - * @backend, and will notify the @listener about changes to the calendar. - * - * Return value: The same object as the @cal argument. - **/ -Cal * -cal_construct (Cal *cal, - CalBackend *backend, - GNOME_Evolution_Calendar_Listener listener) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_val_if_fail (cal != NULL, NULL); - g_return_val_if_fail (IS_CAL (cal), NULL); - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - priv = cal->priv; - - CORBA_exception_init (&ev); - priv->listener = CORBA_Object_duplicate (listener, &ev); - if (BONOBO_EX (&ev)) { - g_message ("cal_construct: could not duplicate the listener"); - priv->listener = CORBA_OBJECT_NIL; - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - priv->backend = backend; - - return cal; -} - -/** - * cal_new: - * @backend: A calendar backend. - * @listener: A calendar listener. - * - * Creates a new calendar client interface object and binds it to the specified - * @backend and @listener objects. - * - * Return value: A newly-created #Cal calendar client interface object, or NULL - * if its corresponding CORBA object could not be created. - **/ -Cal * -cal_new (CalBackend *backend, const char *uri, GNOME_Evolution_Calendar_Listener listener) -{ - Cal *cal, *retval; - - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - cal = CAL (g_object_new (CAL_TYPE, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL), - NULL)); - - retval = cal_construct (cal, backend, listener); - if (!retval) { - g_message (G_STRLOC ": could not construct the calendar client interface"); - bonobo_object_unref (BONOBO_OBJECT (cal)); - return NULL; - } - - return retval; -} - -CalBackend * -cal_get_backend (Cal *cal) -{ - g_return_val_if_fail (cal != NULL, NULL); - g_return_val_if_fail (IS_CAL (cal), NULL); - - return cal->priv->backend; -} - -GNOME_Evolution_Calendar_Listener -cal_get_listener (Cal *cal) -{ - g_return_val_if_fail (cal != NULL, NULL); - g_return_val_if_fail (IS_CAL (cal), NULL); - - return cal->priv->listener; -} - -/* Destroy handler for the calendar */ -static void -cal_finalize (GObject *object) -{ - Cal *cal; - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL (object)); - - cal = CAL (object); - priv = cal->priv; - - priv->backend = NULL; - - CORBA_exception_init (&ev); - bonobo_object_release_unref (priv->listener, &ev); - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not release the listener"); - - priv->listener = NULL; - CORBA_exception_free (&ev); - - g_free (priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - - -/* Class initialization function for the calendar */ -static void -cal_class_init (CalClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - POA_GNOME_Evolution_Calendar_Cal__epv *epv = &klass->epv; - - parent_class = g_type_class_peek_parent (klass); - - /* Class method overrides */ - object_class->finalize = cal_finalize; - - /* Epv methods */ - epv->_get_uri = impl_Cal_get_uri; - epv->open = impl_Cal_open; - epv->remove = impl_Cal_remove; - epv->isReadOnly = impl_Cal_isReadOnly; - epv->getCalAddress = impl_Cal_getCalAddress; - epv->getAlarmEmailAddress = impl_Cal_getAlarmEmailAddress; - epv->getLdapAttribute = impl_Cal_getLdapAttribute; - epv->getStaticCapabilities = impl_Cal_getStaticCapabilities; - epv->setMode = impl_Cal_setMode; - epv->getDefaultObject = impl_Cal_getDefaultObject; - epv->getObject = impl_Cal_getObject; - epv->getTimezone = impl_Cal_getTimezone; - epv->addTimezone = impl_Cal_addTimezone; - epv->setDefaultTimezone = impl_Cal_setDefaultTimezone; - epv->getObjectList = impl_Cal_getObjectList; - epv->getChanges = impl_Cal_getChanges; - epv->getFreeBusy = impl_Cal_getFreeBusy; - epv->discardAlarm = impl_Cal_discardAlarm; - epv->createObject = impl_Cal_createObject; - epv->modifyObject = impl_Cal_modifyObject; - epv->removeObject = impl_Cal_removeObject; - epv->receiveObjects = impl_Cal_receiveObjects; - epv->sendObjects = impl_Cal_sendObjects; - epv->getQuery = impl_Cal_getQuery; -} - - -/* Object initialization function for the calendar */ -static void -cal_init (Cal *cal, CalClass *klass) -{ - CalPrivate *priv; - - priv = g_new0 (CalPrivate, 1); - cal->priv = priv; - - priv->listener = CORBA_OBJECT_NIL; -} - -BONOBO_TYPE_FUNC_FULL (Cal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, cal); - -void -cal_notify_read_only (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyReadOnly (priv->listener, status, read_only, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of read only"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_cal_address (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCalAddress (priv->listener, status, address ? address : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of cal address"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_alarm_email_address (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyAlarmEmailAddress (priv->listener, status, address ? address : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of alarm address"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_ldap_attribute (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *attribute) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyLDAPAttribute (priv->listener, status, attribute ? attribute : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of ldap attribute"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_static_capabilities (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *capabilities) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyStaticCapabilities (priv->listener, status, - capabilities ? capabilities : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of static capabilities"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_open (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCalOpened (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of open"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_remove (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCalRemoved (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of remove"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object_created (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *uid, const char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - if (status == GNOME_Evolution_Calendar_Success) - cal_backend_notify_object_created (priv->backend, object); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectCreated (priv->listener, status, uid ? uid : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object creation"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object_modified (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *old_object, const char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - if (status == GNOME_Evolution_Calendar_Success) - cal_backend_notify_object_modified (priv->backend, old_object, object); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectModified (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object creation"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object_removed (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *uid, const char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - if (status == GNOME_Evolution_Calendar_Success) - cal_backend_notify_object_removed (priv->backend, uid, object); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectRemoved (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object removal"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectsReceived (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of objects received"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_alarm_discarded (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyAlarmDiscarded (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of alarm discarded"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_objects_sent (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectsSent (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of objects sent"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_default_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Listener_notifyDefaultObjectRequested (priv->listener, status, - object ? object : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of default object"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Listener_notifyObjectRequested (priv->listener, status, - object ? object : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object_list (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects) -{ - CalPrivate *priv; - CORBA_Environment ev; - GNOME_Evolution_Calendar_stringlist seq; - GList *l; - int i; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - seq._maximum = g_list_length (objects); - seq._length = 0; - seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum); - - for (l = objects, i = 0; l; l = l->next, i++) { - seq._buffer[i] = CORBA_string_dup (l->data); - seq._length++; - } - - GNOME_Evolution_Calendar_Listener_notifyObjectListRequested (priv->listener, status, &seq, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object list"); - - CORBA_exception_free (&ev); - - CORBA_free(seq._buffer); -} - -void -cal_notify_query (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, Query *query) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyQuery (priv->listener, status, BONOBO_OBJREF (query), &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of query"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_timezone_requested (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyTimezoneRequested (priv->listener, status, object ? object : "", &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of timezone requested"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_timezone_added (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *tzid) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyTimezoneAdded (priv->listener, status, tzid ? tzid : "", &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of timezone added"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_default_timezone_set (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyDefaultTimezoneSet (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of default timezone set"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_changes (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - GList *adds, GList *modifies, GList *deletes) -{ - CalPrivate *priv; - CORBA_Environment ev; - GNOME_Evolution_Calendar_CalObjChangeSeq seq; - GList *l; - int n, i; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - n = g_list_length (adds) + g_list_length (modifies) + g_list_length (deletes); - seq._maximum = n; - seq._length = n; - seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObjChange_allocbuf (n); - - i = 0; - for (l = adds; l; i++, l = l->next) { - GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i]; - - change->calobj = CORBA_string_dup (l->data); - change->type = GNOME_Evolution_Calendar_ADDED; - } - - for (l = modifies; l; i++, l = l->next) { - GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i]; - - change->calobj = CORBA_string_dup (l->data); - change->type = GNOME_Evolution_Calendar_MODIFIED; - } - - for (l = deletes; l; i++, l = l->next) { - GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i]; - - change->calobj = CORBA_string_dup (l->data); - change->type = GNOME_Evolution_Calendar_DELETED; - } - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyDefaultTimezoneSet (priv->listener, status, &ev); - - CORBA_free (seq._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of default timezone set"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_free_busy (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy) -{ - CalPrivate *priv; - CORBA_Environment ev; - GNOME_Evolution_Calendar_CalObjSeq seq; - GList *l; - int n, i; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - n = g_list_length (freebusy); - seq._maximum = n; - seq._length = n; - seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (n); - - for (i = 0, l = freebusy; l; i++, l = l->next) - seq._buffer[i] = CORBA_string_dup (l->data); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyDefaultTimezoneSet (priv->listener, status, &ev); - - CORBA_free (seq._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of freebusy"); - - CORBA_exception_free (&ev); -} - -/** - * cal_notify_mode: - * @cal: A calendar client interface. - * @status: Status of the mode set. - * @mode: The current mode. - * - * Notifys the listener of the results of a setMode call. - **/ -void -cal_notify_mode (Cal *cal, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCalSetMode (priv->listener, status, mode, &ev); - - if (BONOBO_EX (&ev)) - g_message ("cal_notify_mode(): could not notify the listener " - "about a mode change"); - - CORBA_exception_free (&ev); -} - -/** - * cal_notify_error - * @cal: A calendar client interface. - * @message: Error message. - * - * Notify a calendar client of an error occurred in the backend. - */ -void -cal_notify_error (Cal *cal, const char *message) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - g_return_if_fail (message != NULL); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyErrorOccurred (priv->listener, (char *) message, &ev); - - if (BONOBO_EX (&ev)) - g_message ("cal_notify_remove(): could not notify the listener " - "about a removed object"); - - CORBA_exception_free (&ev); -} - -/** - * cal_notify_categories_changed: - * @cal: A calendar client interface. - * @categories: List of categories. - * - * Notifies a listener attached to a calendar client interface object about the - * current set of categories in a calendar backend. - **/ -void -cal_notify_categories_changed (Cal *cal, GNOME_Evolution_Calendar_StringSeq *categories) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - g_return_if_fail (categories != NULL); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCategoriesChanged (priv->listener, categories, &ev); - - if (BONOBO_EX (&ev)) - g_message ("cal_notify_categories_changed(): Could not notify the listener " - "about the current set of categories"); - - CORBA_exception_free (&ev); -} diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h deleted file mode 100644 index f3d35f1f5f..0000000000 --- a/calendar/pcs/cal.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Evolution calendar client interface object - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Rodrigo Moya - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef CAL_H -#define CAL_H - -#include -#include "pcs/evolution-calendar.h" -#include "pcs/cal-common.h" -#include "pcs/query.h" - -G_BEGIN_DECLS - - - -#define CAL_TYPE (cal_get_type ()) -#define CAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_TYPE, Cal)) -#define CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_TYPE, CalClass)) -#define IS_CAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_TYPE)) -#define IS_CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_TYPE)) - -typedef struct _CalPrivate CalPrivate; - -struct _Cal { - BonoboObject object; - - /* Private data */ - CalPrivate *priv; -}; - -struct _CalClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Calendar_Cal__epv epv; -}; - -GType cal_get_type (void); - -Cal *cal_construct (Cal *cal, - CalBackend *backend, - GNOME_Evolution_Calendar_Listener listener); - -Cal *cal_new (CalBackend *backend, const char *uri, GNOME_Evolution_Calendar_Listener listener); - -CalBackend *cal_get_backend (Cal *cal); -GNOME_Evolution_Calendar_Listener cal_get_listener (Cal *cal); - -void cal_notify_read_only (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only); -void cal_notify_cal_address (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address); -void cal_notify_alarm_email_address (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address); -void cal_notify_ldap_attribute (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *attribute); -void cal_notify_static_capabilities (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *capabilities); - -void cal_notify_open (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); -void cal_notify_remove (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); - -void cal_notify_object_created (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *uid, const char *object); -void cal_notify_object_modified (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *old_object, const char *object); -void cal_notify_object_removed (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *uid, const char *object); -void cal_notify_alarm_discarded (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); - -void cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); -void cal_notify_objects_sent (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); - -void cal_notify_default_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object); -void cal_notify_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object); -void cal_notify_object_list (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects); - -void cal_notify_query (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, Query *query); - -void cal_notify_timezone_requested (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object); -void cal_notify_timezone_added (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *tzid); -void cal_notify_default_timezone_set (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); - -void cal_notify_changes (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *adds, GList *modifies, GList *deletes); -void cal_notify_free_busy (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy); - -void cal_notify_mode (Cal *cal, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode); -void cal_notify_error (Cal *cal, const char *message); - -void cal_notify_categories_changed (Cal *cal, GNOME_Evolution_Calendar_StringSeq *categories); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c deleted file mode 100644 index 453c1cc4ce..0000000000 --- a/calendar/pcs/query.c +++ /dev/null @@ -1,492 +0,0 @@ -/* Evolution calendar - Live search query implementation - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include "query.h" - - - -/* Private part of the Query structure */ -struct _QueryPrivate { - /* The backend we are monitoring */ - CalBackend *backend; - - /* The listener we report to */ - GNOME_Evolution_Calendar_QueryListener listener; - EComponentListener *component_listener; - - /* Sexp that defines the query */ - CalBackendObjectSExp *sexp; -}; - - - - -static void query_class_init (QueryClass *class); -static void query_init (Query *query, QueryClass *class); -static void query_finalize (GObject *object); - -static BonoboObjectClass *parent_class; - - - -BONOBO_TYPE_FUNC_FULL (Query, - GNOME_Evolution_Calendar_Query, - BONOBO_TYPE_OBJECT, - query); - -/* Property IDs */ -enum props { - PROP_0, - PROP_BACKEND, - PROP_LISTENER, - PROP_SEXP -}; - - -static void -listener_died_cb (EComponentListener *cl, gpointer data) -{ - Query *query = QUERY (data); - QueryPrivate *priv; - - priv = query->priv; - - g_object_unref (priv->component_listener); - priv->component_listener = NULL; - - bonobo_object_release_unref (priv->listener, NULL); - priv->listener = NULL; -} - -static void -impl_Query_start (PortableServer_Servant servant, CORBA_Environment *ev) -{ - Query *query; - QueryPrivate *priv; - - query = QUERY (bonobo_object_from_servant (servant)); - priv = query->priv; - - cal_backend_start_query (priv->backend, query); -} - -static void -query_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - Query *query; - QueryPrivate *priv; - CORBA_Environment ev; - - query = QUERY (object); - priv = query->priv; - - switch (property_id) { - case PROP_BACKEND: - priv->backend = CAL_BACKEND (g_value_dup_object (value)); - break; - case PROP_LISTENER: - CORBA_exception_init (&ev); - priv->listener = CORBA_Object_duplicate (g_value_get_pointer (value), &ev); - CORBA_exception_free (&ev); - - priv->component_listener = e_component_listener_new (priv->listener); - g_signal_connect (G_OBJECT (priv->component_listener), "component_died", - G_CALLBACK (listener_died_cb), query); - break; - case PROP_SEXP: - priv->sexp = CAL_BACKEND_OBJECT_SEXP (g_value_dup_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -query_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - Query *query; - QueryPrivate *priv; - - query = QUERY (object); - priv = query->priv; - - switch (property_id) { - case PROP_BACKEND: - g_value_set_object (value, priv->backend); - case PROP_LISTENER: - g_value_set_pointer (value, priv->listener); - break; - case PROP_SEXP: - g_value_set_object (value, priv->sexp); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -/* Class initialization function for the live search query */ -static void -query_class_init (QueryClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_Calendar_Query__epv *epv = &klass->epv; - GParamSpec *param; - - object_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - object_class->set_property = query_set_property; - object_class->get_property = query_get_property; - object_class->finalize = query_finalize; - - epv->start = impl_Query_start; - - param = g_param_spec_object ("backend", NULL, NULL, CAL_BACKEND_TYPE, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_BACKEND, param); - param = g_param_spec_pointer ("listener", NULL, NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_LISTENER, param); - param = g_param_spec_object ("sexp", NULL, NULL, CAL_TYPE_BACKEND_OBJECT_SEXP, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_SEXP, param); -} - -/* Object initialization function for the live search query */ -static void -query_init (Query *query, QueryClass *class) -{ - QueryPrivate *priv; - - priv = g_new0 (QueryPrivate, 1); - query->priv = priv; - - priv->backend = NULL; - priv->listener = NULL; - priv->component_listener = NULL; - priv->sexp = NULL; -} - -/* Finalize handler for the live search query */ -static void -query_finalize (GObject *object) -{ - Query *query; - QueryPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_QUERY (object)); - - query = QUERY (object); - priv = query->priv; - - if (priv->backend) - g_object_unref (priv->backend); - - if (priv->listener != NULL) - bonobo_object_release_unref (priv->listener, NULL); - - if (priv->component_listener != NULL) - g_object_unref (priv->component_listener); - - if (priv->sexp) - g_object_unref (priv->sexp); - - g_free (priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/** - * query_new: - * @backend: Calendar backend that the query object will monitor. - * @ql: Listener for query results. - * @sexp: Sexp that defines the query. - * - * Creates a new query engine object that monitors a calendar backend. - * - * Return value: A newly-created query object, or NULL on failure. - **/ -Query * -query_new (CalBackend *backend, - GNOME_Evolution_Calendar_QueryListener ql, - CalBackendObjectSExp *sexp) -{ - Query *query; - - query = g_object_new (QUERY_TYPE, "backend", backend, "listener", ql, - "sexp", sexp, NULL); - - return query; -} - -/** - * query_get_sexp - * @query: A #Query object. - * - * Get the expression used for the given query. - * - * Returns: the query expression used to search. - */ -const char * -query_get_text (Query *query) -{ - g_return_val_if_fail (IS_QUERY (query), NULL); - - return cal_backend_object_sexp_text (query->priv->sexp); -} - -CalBackendObjectSExp * -query_get_object_sexp (Query *query) -{ - g_return_val_if_fail (IS_QUERY (query), NULL); - - return query->priv->sexp; -} - -gboolean -query_object_matches (Query *query, const char *object) -{ - QueryPrivate *priv; - - g_return_val_if_fail (query != NULL, FALSE); - g_return_val_if_fail (IS_QUERY (query), FALSE); - g_return_val_if_fail (object != NULL, FALSE); - - priv = query->priv; - - return cal_backend_object_sexp_match_object (priv->sexp, object, priv->backend); -} - -void -query_notify_objects_added (Query *query, const GList *objects) -{ - QueryPrivate *priv; - GNOME_Evolution_Calendar_stringlist obj_list; - CORBA_Environment ev; - const GList *l; - int num_objs, i; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - num_objs = g_list_length ((GList*)objects); - obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (num_objs); - obj_list._maximum = num_objs; - obj_list._length = num_objs; - - for (l = objects, i = 0; l; l = l->next, i++) - obj_list._buffer[i] = CORBA_string_dup (l->data); - - GNOME_Evolution_Calendar_QueryListener_notifyObjectsAdded (priv->listener, &obj_list, &ev); - - CORBA_free (obj_list._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of object addition"); - - CORBA_exception_free (&ev); -} - -void -query_notify_objects_added_1 (Query *query, const char *object) -{ - QueryPrivate *priv; - GList objects; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - objects.next = objects.prev = NULL; - objects.data = (gpointer)object; - - query_notify_objects_added (query, &objects); -} - -void -query_notify_objects_modified (Query *query, const GList *objects) -{ - QueryPrivate *priv; - GNOME_Evolution_Calendar_CalObjUIDSeq obj_list; - CORBA_Environment ev; - const GList *l; - int num_objs, i; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - num_objs = g_list_length ((GList*)objects); - obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (num_objs); - obj_list._maximum = num_objs; - obj_list._length = num_objs; - - for (l = objects, i = 0; l; l = l->next, i++) - obj_list._buffer[i] = CORBA_string_dup (l->data); - - GNOME_Evolution_Calendar_QueryListener_notifyObjectsModified (priv->listener, &obj_list, &ev); - - CORBA_free (obj_list._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of object modification"); - - CORBA_exception_free (&ev); -} - -void -query_notify_objects_modified_1 (Query *query, const char *object) -{ - QueryPrivate *priv; - GList objects; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - objects.next = objects.prev = NULL; - objects.data = (gpointer)object; - - query_notify_objects_modified (query, &objects); -} - -void -query_notify_objects_removed (Query *query, const GList *uids) -{ - QueryPrivate *priv; - GNOME_Evolution_Calendar_CalObjUIDSeq uid_list; - CORBA_Environment ev; - const GList *l; - int num_uids, i; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - num_uids = g_list_length ((GList*)uids); - uid_list._buffer = GNOME_Evolution_Calendar_CalObjUIDSeq_allocbuf (num_uids); - uid_list._maximum = num_uids; - uid_list._length = num_uids; - - for (l = uids, i = 0; l; l = l->next, i ++) - uid_list._buffer[i] = CORBA_string_dup (l->data); - - GNOME_Evolution_Calendar_QueryListener_notifyObjectsRemoved (priv->listener, &uid_list, &ev); - - CORBA_free (uid_list._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of object removal"); - - - CORBA_exception_free (&ev); -} - -void -query_notify_objects_removed_1 (Query *query, const char *uid) -{ - QueryPrivate *priv; - GList uids; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - uids.next = uids.prev = NULL; - uids.data = (gpointer)uid; - - query_notify_objects_removed (query, &uids); -} - -void -query_notify_query_progress (Query *query, const char *message, int percent) -{ - QueryPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_QueryListener_notifyQueryProgress (priv->listener, message, percent, &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of query progress"); - - CORBA_exception_free (&ev); -} - -void -query_notify_query_done (Query *query, GNOME_Evolution_Calendar_CallStatus status) -{ - QueryPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_QueryListener_notifyQueryDone (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of query completion"); - - CORBA_exception_free (&ev); -} diff --git a/calendar/pcs/query.h b/calendar/pcs/query.h deleted file mode 100644 index 9c03aa2661..0000000000 --- a/calendar/pcs/query.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Evolution calendar - Live search query implementation - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef QUERY_H -#define QUERY_H - -#include -#include "pcs/cal-common.h" -#include "pcs/evolution-calendar.h" -#include "cal-backend-object-sexp.h" - -G_BEGIN_DECLS - - - -#define QUERY_TYPE (query_get_type ()) -#define QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QUERY_TYPE, Query)) -#define QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QUERY_TYPE, QueryClass)) -#define IS_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QUERY_TYPE)) -#define IS_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QUERY_TYPE)) - -typedef struct _QueryPrivate QueryPrivate; - -struct _Query { - BonoboObject xobject; - - /* Private data */ - QueryPrivate *priv; -}; - -struct _QueryClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Calendar_Query__epv epv; -}; - -GType query_get_type (void); -Query *query_new (CalBackend *backend, - GNOME_Evolution_Calendar_QueryListener ql, - CalBackendObjectSExp *sexp); -const char *query_get_text (Query *query); -CalBackendObjectSExp *query_get_object_sexp (Query *query); -gboolean query_object_matches (Query *query, const char *object); -void query_notify_objects_added (Query *query, - const GList *objects); -void query_notify_objects_added_1 (Query *query, - const char *object); -void query_notify_objects_modified (Query *query, - const GList *objects); -void query_notify_objects_modified_1 (Query *query, - const char *object); -void query_notify_objects_removed (Query *query, - const GList *uids); -void query_notify_objects_removed_1 (Query *query, - const char *uid); -void query_notify_query_progress (Query *query, - const char *message, - int percent); -void query_notify_query_done (Query *query, - GNOME_Evolution_Calendar_CallStatus status); - -G_END_DECLS - -#endif -- cgit v1.2.3