aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/cal-client')
-rw-r--r--calendar/cal-client/.cvsignore15
-rw-r--r--calendar/cal-client/Makefile.am93
-rw-r--r--calendar/cal-client/cal-client-multi.c712
-rw-r--r--calendar/cal-client/cal-client-multi.h104
-rw-r--r--calendar/cal-client/cal-client-types.c52
-rw-r--r--calendar/cal-client/cal-client-types.h49
-rw-r--r--calendar/cal-client/cal-client.c3089
-rw-r--r--calendar/cal-client/cal-client.h235
-rw-r--r--calendar/cal-client/cal-listener.c398
-rw-r--r--calendar/cal-client/cal-listener.h105
-rw-r--r--calendar/cal-client/cal-query.c391
-rw-r--r--calendar/cal-client/cal-query.h84
-rw-r--r--calendar/cal-client/client-test.c235
-rw-r--r--calendar/cal-client/query-listener.c321
-rw-r--r--calendar/cal-client/query-listener.h97
-rw-r--r--calendar/cal-client/test.ics318
16 files changed, 0 insertions, 6298 deletions
diff --git a/calendar/cal-client/.cvsignore b/calendar/cal-client/.cvsignore
deleted file mode 100644
index 1537e6e01d..0000000000
--- a/calendar/cal-client/.cvsignore
+++ /dev/null
@@ -1,15 +0,0 @@
-Makefile.in
-.deps
-.libs
-.pure
-Makefile
-evolution-calendar-stubs.c
-evolution-calendar-skels.c
-evolution-calendar-common.c
-evolution-calendar.h
-evolution-calendar-common.lo
-evolution-calendar-skels.lo
-evolution-calendar-stubs.lo
-*.lo
-*.la
-client-test
diff --git a/calendar/cal-client/Makefile.am b/calendar/cal-client/Makefile.am
deleted file mode 100644
index 9efc3f13e7..0000000000
--- a/calendar/cal-client/Makefile.am
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-# libcal-client
-#
-
-CORBA_GENERATED_C = \
- evolution-calendar-common.c \
- evolution-calendar-skels.c \
- evolution-calendar-stubs.c
-CORBA_GENERATED_H = \
- evolution-calendar.h
-
-CORBA_GENERATED = $(CORBA_GENERATED_C) $(CORBA_GENERATED_H)
-
-idls = \
- $(srcdir)/../idl/evolution-calendar.idl
-
-idl_flags = $(IDL_INCLUDES)
-
-$(CORBA_GENERATED_H): $(idls)
- $(ORBIT_IDL) $(idl_flags) $(srcdir)/../idl/evolution-calendar.idl
-$(CORBA_GENERATED_C): $(CORBA_GENERATED_H)
-
-INCLUDES = \
- -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \
- -DG_LOG_DOMAIN=\"cal-client\" \
- -I$(top_srcdir)/calendar \
- -I$(srcdir) -I$(top_srcdir) \
- -I. \
- -I.. \
- -I$(top_builddir) \
- -I$(top_builddir)/libical/src/libical \
- -I$(top_srcdir)/libical/src/libical \
- -I$(top_builddir)/libwombat \
- -I$(top_srcdir)/libwombat \
- $(EVOLUTION_CALENDAR_CFLAGS)
-
-privlib_LTLIBRARIES = libcal-client.la
-
-libcal_clientincludedir = $(privincludedir)/cal-client
-
-libcal_client_la_SOURCES = \
- $(CORBA_GENERATED_C) \
- cal-client-multi.c \
- cal-client-types.c \
- cal-client.c \
- cal-listener.c \
- cal-listener.h \
- cal-query.c \
- query-listener.c \
- query-listener.h
-
-libcal_client_la_LIBADD = \
- $(top_builddir)/calendar/cal-util/libcal-util.la \
- $(top_builddir)/libwombat/libwombat.la \
- $(top_builddir)/e-util/libeutil.la
-
-libcal_clientinclude_HEADERS = \
- $(CORBA_GENERATED_H) \
- cal-client-multi.h \
- cal-client-types.h \
- cal-client.h \
- cal-query.h
-
-#
-# make a static library for use by calendar conduit's shared library
-#
-noinst_LTLIBRARIES = libcal-client-static.la
-libcal_client_static_la_SOURCES = $(libcal_client_la_SOURCES)
-libcal_client_static_la_LDFLAGS = --all-static
-
-
-#
-# client-test program
-#
-
-noinst_PROGRAMS = client-test
-
-client_test_SOURCES = \
- client-test.c
-
-client_test_INCLUDES = \
- $(INCLUDES) \
- -DG_LOG_DOMAIN=\"client-test\"
-
-client_test_LDADD = \
- libcal-client.la \
- $(EVOLUTION_CALENDAR_LIBS)
-
-BUILT_SOURCES = $(CORBA_GENERATED)
-CLEANFILES = $(BUILT_SOURCES)
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
diff --git a/calendar/cal-client/cal-client-multi.c b/calendar/cal-client/cal-client-multi.c
deleted file mode 100644
index 18b03c46ff..0000000000
--- a/calendar/cal-client/cal-client-multi.c
+++ /dev/null
@@ -1,712 +0,0 @@
-/* Evolution calendar client
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Rodrigo Moya <rodrigo@ximian.com>
- *
- * 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 <config.h>
-#endif
-#include "cal-util/cal-util-marshal.h"
-#include "cal-client-multi.h"
-
-/* Private part of the CalClientMulti structure */
-struct _CalClientMultiPrivate {
- GHashTable *calendars;
- GList *uris;
-};
-
-static void cal_client_multi_class_init (CalClientMultiClass *klass);
-static void cal_client_multi_init (CalClientMulti *multi, CalClientMultiClass *klass);
-static void cal_client_multi_finalize (GObject *object);
-
-/* signal IDs */
-enum {
- CAL_OPENED,
- OBJ_UPDATED,
- OBJ_REMOVED,
- CATEGORIES_CHANGED,
- FORGET_PASSWORD,
- LAST_SIGNAL
-};
-
-static guint cal_multi_signals[LAST_SIGNAL];
-static GObjectClass *parent_class = NULL;
-
-/*
- * Private functions
- */
-
-/**
- * cal_client_multi_get_type
- *
- * Registers the #CalClientMulti class if necessary, and returns the type ID
- * assigned to it.
- *
- * Returns: The type ID of the #CalClientMulti class
- */
-GType
-cal_client_multi_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static GTypeInfo info = {
- sizeof (CalClientMultiClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) cal_client_multi_class_init,
- NULL, NULL,
- sizeof (CalClientMulti),
- 0,
- (GInstanceInitFunc) cal_client_multi_init
- };
- type = g_type_register_static (G_TYPE_OBJECT, "CalClientMulti", &info, 0);
- }
-
- return type;
-}
-
-/* class initialization function for the multi calendar client */
-static void
-cal_client_multi_class_init (CalClientMultiClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- cal_multi_signals[CAL_OPENED] =
- g_signal_new ("cal_opened",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientMultiClass, cal_opened),
- NULL, NULL,
- cal_util_marshal_VOID__POINTER_ENUM,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER, G_TYPE_ENUM);
- cal_multi_signals[OBJ_UPDATED] =
- g_signal_new ("obj_updated",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientMultiClass, obj_updated),
- NULL, NULL,
- cal_util_marshal_VOID__POINTER_STRING,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER, G_TYPE_STRING);
- cal_multi_signals[OBJ_REMOVED] =
- g_signal_new ("obj_removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientMultiClass, obj_removed),
- NULL, NULL,
- cal_util_marshal_VOID__POINTER_STRING,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER, G_TYPE_STRING);
- cal_multi_signals[CATEGORIES_CHANGED] =
- g_signal_new ("categories_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientMultiClass, categories_changed),
- NULL, NULL,
- cal_util_marshal_VOID__POINTER_POINTER,
- G_TYPE_NONE, 2,
- G_TYPE_POINTER, G_TYPE_POINTER);
- cal_multi_signals[FORGET_PASSWORD] =
- g_signal_new ("forget_password",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientMultiClass, forget_password),
- NULL, NULL,
- cal_util_marshal_VOID__STRING_STRING,
- G_TYPE_NONE, 2,
- G_TYPE_STRING, G_TYPE_STRING);
-
- object_class->finalize = cal_client_multi_finalize;
-}
-
-/* object initialization function for the multi calendar client */
-static void
-cal_client_multi_init (CalClientMulti *multi, CalClientMultiClass *klass)
-{
- multi->priv = g_new0 (CalClientMultiPrivate, 1);
- multi->priv->calendars = g_hash_table_new (g_str_hash, g_str_equal);
- multi->priv->uris = NULL;
-}
-
-static void
-free_calendar (gpointer key, gpointer value, gpointer data)
-{
- CalClientMulti *multi = (CalClientMulti *) data;
-
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- multi->priv->uris = g_list_remove (multi->priv->uris, key);
-
- g_free (key);
- g_object_unref (G_OBJECT (value));
-}
-
-/* finalize handler for the multi calendar client */
-static void
-cal_client_multi_finalize (GObject *object)
-{
- CalClientMulti *multi = (CalClientMulti *) object;
-
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- /* free memory */
- g_hash_table_foreach (multi->priv->calendars, free_calendar, multi);
- g_hash_table_destroy (multi->priv->calendars);
- g_list_free (multi->priv->uris);
-
- g_free (multi->priv);
- multi->priv = NULL;
-
- /* chain to parent class' destroy handler */
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-/**
- * cal_client_multi_new
- *
- * Creates a new multi-calendar client. This allows you to merge several
- * #CalClient objects into one entity, making it easier to manage
- * multiple calendars.
- *
- * Returns: A newly-created multi-calendar client.
- */
-CalClientMulti *
-cal_client_multi_new (void)
-{
- CalClientMulti *multi;
-
- multi = g_object_new (CAL_CLIENT_MULTI_TYPE, NULL);
- return multi;
-}
-
-/* CalClient's signal handlers */
-static void
-client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer user_data)
-{
- CalClientMulti *multi = (CalClientMulti *) user_data;
-
- g_return_if_fail (IS_CAL_CLIENT (client));
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- g_signal_emit (G_OBJECT (multi),
- cal_multi_signals[CAL_OPENED], 0,
- client, status);
-}
-
-static void
-client_obj_updated_cb (CalClient *client, const char *uid, gpointer user_data)
-{
- CalClientMulti *multi = (CalClientMulti *) user_data;
-
- g_return_if_fail (IS_CAL_CLIENT (client));
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- g_signal_emit (G_OBJECT (multi),
- cal_multi_signals[OBJ_UPDATED], 0,
- client, uid);
-}
-
-static void
-client_obj_removed_cb (CalClient *client, const char *uid, gpointer user_data)
-{
- CalClientMulti *multi = (CalClientMulti *) user_data;
-
- g_return_if_fail (IS_CAL_CLIENT (client));
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- g_signal_emit (G_OBJECT (multi),
- cal_multi_signals[OBJ_REMOVED], 0,
- client, uid);
-}
-
-static void
-client_categories_changed_cb (CalClient *client, GPtrArray *categories, gpointer user_data)
-{
- CalClientMulti *multi = (CalClientMulti *) user_data;
-
- g_return_if_fail (IS_CAL_CLIENT (client));
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- g_signal_emit (G_OBJECT (multi),
- cal_multi_signals[CATEGORIES_CHANGED], 0,
- client, categories);
-}
-
-static void
-client_forget_password_cb (CalClient *client, const char *key, gpointer user_data)
-{
- CalClientMulti *multi = (CalClientMulti *) user_data;
-
- g_return_if_fail (IS_CAL_CLIENT (client));
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- g_signal_emit (G_OBJECT (multi),
- cal_multi_signals[FORGET_PASSWORD], 0,
- client, key);
-}
-/**
- * cal_client_multi_add_client
- * @multi: A #CalClientMulti object.
- * @client: The #CalClient object to be added.
- *
- * Aggregates the given #CalClient to a #CalClientMulti object,
- * thus adding it to the list of managed calendars.
- */
-void
-cal_client_multi_add_client (CalClientMulti *multi, CalClient *client)
-{
- char *uri;
- CalClient *old_client;
-
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
- g_return_if_fail (IS_CAL_CLIENT (client));
-
- uri = g_strdup (cal_client_get_uri (client));
- old_client = g_hash_table_lookup (multi->priv->calendars, uri);
- if (old_client) {
- g_free (uri);
- return;
- }
-
- g_object_ref (G_OBJECT (client));
- multi->priv->uris = g_list_append (multi->priv->uris, uri);
- g_hash_table_insert (multi->priv->calendars, uri, client);
-
- /* set up CalClient's signal handlers */
- g_signal_handlers_disconnect_matched (G_OBJECT (client),
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, multi);
- g_signal_connect (G_OBJECT (client),
- "cal_opened",
- G_CALLBACK (client_cal_opened_cb),
- multi);
- g_signal_connect (G_OBJECT (client),
- "obj_updated",
- G_CALLBACK (client_obj_updated_cb),
- multi);
- g_signal_connect (G_OBJECT (client),
- "obj_removed",
- G_CALLBACK (client_obj_removed_cb),
- multi);
- g_signal_connect (G_OBJECT (client),
- "categories_changed",
- G_CALLBACK (client_categories_changed_cb),
- multi);
- g_signal_connect (G_OBJECT (client),
- "forget_password",
- G_CALLBACK (client_forget_password_cb),
- multi);
-}
-
-typedef struct {
- CalClientAuthFunc func;
- gpointer user_data;
-} AuthFuncData;
-
-static void
-set_auth_func (gpointer key, gpointer value, gpointer user_data)
-{
- AuthFuncData *cb_data = (AuthFuncData *) user_data;
- CalClient *client = (CalClient *) value;
-
- g_return_if_fail (IS_CAL_CLIENT (client));
- g_return_if_fail (cb_data != NULL);
-
- cal_client_set_auth_func (client, cb_data->func, cb_data->user_data);
-}
-
-/**
- * cal_client_multi_set_auth_func
- * @multi: A #CalClientMulti object.
- * @func: The authentication function.
- * @user_data: Data to be passed to the authentication function.
- *
- * Sets the authentication function for all the clients in the
- * given #CalClientMulti.
- */
-void
-cal_client_multi_set_auth_func (CalClientMulti *multi,
- CalClientAuthFunc func,
- gpointer user_data)
-{
- AuthFuncData *cb_data;
-
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- cb_data = g_new0 (AuthFuncData, 1);
- cb_data->func = func;
- cb_data->user_data = user_data;
- g_hash_table_foreach (multi->priv->calendars, set_auth_func, cb_data);
-
- g_free (cb_data);
-}
-
-/**
- * cal_client_multi_open_calendar
- * @multi: A #CalClientMulti object.
- * @str_uri: The URI of the calendar to be open
- * @only_if_exists:
- *
- * Open a new calendar in the given #CalClientMulti object.
- *
- * Returns: a pointer to the new #CalClient
- */
-CalClient *
-cal_client_multi_open_calendar (CalClientMulti *multi,
- const char *str_uri,
- gboolean only_if_exists)
-{
- CalClient *client;
- gboolean result;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), FALSE);
-
- client = cal_client_new ();
-
- result = cal_client_open_calendar (client, str_uri, only_if_exists);
- if (result) {
- cal_client_multi_add_client (multi, client);
- g_object_unref (G_OBJECT (client));
- return client;
- }
-
- g_object_unref (G_OBJECT (client));
-
- return NULL;
-}
-
-/**
- * cal_client_multi_get_client_for_uri
- * @multi: A #CalClientMulti object.
- * @uri: The URI for the client.
- *
- * Returns the #CalClient object associated with the given
- * @uri for the given #CalClientMulti object.
- *
- * Returns: a pointer to the client or NULL if no client is
- * associated with that URI.
- */
-CalClient *
-cal_client_multi_get_client_for_uri (CalClientMulti *multi, const char *uri)
-{
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), NULL);
- g_return_val_if_fail (uri != NULL, NULL);
-
- return g_hash_table_lookup (multi->priv->calendars, uri);
-}
-
-/**
- * cal_client_multi_get_n_objects
- * @multi: A #CalClientMulti object.
- * @type: Type for objects
- *
- * Get the count of objects of the given type(s) for a #CalClientMulti
- * object.
- *
- * Returns: The count of objects of the given type(s).
- */
-int
-cal_client_multi_get_n_objects (CalClientMulti *multi,
- CalObjType type)
-{
- CalClient *client;
- GList *l;
- int count = 0;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), -1);
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client))
- count += cal_client_get_n_objects (client, type);
- }
-
- return count;
-}
-
-/**
- * cal_client_multi_get_object
- */
-CalClientGetStatus
-cal_client_multi_get_object (CalClientMulti *multi,
- const char *uid,
- CalComponent **comp)
-{
- CalClient *client;
- GList *l;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), CAL_CLIENT_GET_NOT_FOUND);
- g_return_val_if_fail (uid != NULL, CAL_CLIENT_GET_NOT_FOUND);
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client)) {
- CalClientGetStatus status;
-
- status = cal_client_get_object (client, uid, comp);
- if (status == CAL_CLIENT_GET_SUCCESS)
- return status;
- }
- }
-
- return CAL_CLIENT_GET_NOT_FOUND;
-}
-
-/**
- * cal_client_multi_get_timezone
- * @multi: A #CalClientMulti object.
- * @tzid: ID for the timezone to be retrieved.
- * @zone: A pointer to where the icaltimezone object will be copied.
- */
-CalClientGetStatus
-cal_client_multi_get_timezone (CalClientMulti *multi,
- const char *tzid,
- icaltimezone **zone)
-{
- CalClient *client;
- GList *l;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), CAL_CLIENT_GET_NOT_FOUND);
- g_return_val_if_fail (tzid != NULL, CAL_CLIENT_GET_NOT_FOUND);
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client)) {
- CalClientGetStatus status;
-
- status = cal_client_get_timezone (client, tzid, zone);
- if (status == CAL_CLIENT_GET_SUCCESS)
- return status;
- }
- }
-
- return CAL_CLIENT_GET_NOT_FOUND;
-}
-
-/**
- * cal_client_multi_get_uids
- * @multi: A #CalClientMulti object.
- * @type: Type of objects whose IDs will be returned.
- *
- * Returns a list of UIDs for all the objects of the given
- * type(s) that are in the calendars managed by a
- * #CalClientMulti object
- *
- * Returns: a GList of UIDs.
- */
-GList *
-cal_client_multi_get_uids (CalClientMulti *multi, CalObjType type)
-{
- CalClient *client;
- GList *l;
- GList *result = NULL;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), NULL);
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client)) {
- GList *tmp;
-
- tmp = cal_client_get_uids (client, type);
- if (tmp)
- result = g_list_concat (result, tmp);
- }
- }
-
- return result;
-}
-
-/**
- * cal_client_multi_get_changes
- * @multi: A #CalClientMulti object.
- * @type: Object type.
- * @change_id: Change ID.
- *
- * Returns a list of changes for the given #CalClientMulti
- * object.
- */
-GList *
-cal_client_multi_get_changes (CalClientMulti *multi,
- CalObjType type,
- const char *change_id)
-{
- CalClient *client;
- GList *l;
- GList *result = NULL;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), NULL);
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client)) {
- GList *tmp;
-
- tmp = cal_client_get_changes (client, type, change_id);
- if (tmp)
- result = g_list_concat (result, tmp);
- }
- }
-
- return result;
-}
-
-/**
- * cal_client_multi_get_objects_in_range
- * @multi: A #CalClientMulti object.
- * @type: Type for objects.
- * @start: Start time.
- * @end: End time.
- *
- * Retrieves a list of all calendar components that are
- * scheduled within the given time range. The information is
- * retrieved from all the calendars being managed by the
- * given #CalClientMulti object.
- *
- * Returns: A list of UID strings. This should be freed using the
- * #cal_obj_uid_list_free() function.
- **/
-GList *
-cal_client_multi_get_objects_in_range (CalClientMulti *multi,
- CalObjType type,
- time_t start,
- time_t end)
-{
- CalClient *client;
- GList *l;
- GList *result = NULL;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), NULL);
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client)) {
- GList *tmp;
-
- tmp = cal_client_get_objects_in_range (client, type, start, end);
- if (tmp)
- result = g_list_concat (result, tmp);
- }
- }
-
- return result;
-}
-
-/**
- * cal_client_multi_get_free_busy
- * @multi: A #CalClientMulti object.
- * @users: List of users to retrieve F/B information for.
- * @start: Start time.
- * @end: End time.
- *
- * Retrieves Free/Busy information for the given users in all
- * the calendars being managed by the given #CalClient multi
- * object.
- *
- * Returns: A GList of VFREEBUSY CalComponents
- */
-GList *
-cal_client_multi_get_free_busy (CalClientMulti *multi,
- GList *users,
- time_t start,
- time_t end)
-{
- CalClient *client;
- GList *l;
- GList *result = NULL;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), NULL);
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client)) {
- GList *tmp;
-
- tmp = cal_client_get_free_busy (client, users, start, end);
- if (tmp)
- result = g_list_concat (result, tmp);
- }
- }
-
- return result;
-}
-
-/**
- * cal_client_multi_generate_instances
- */
-void
-cal_client_multi_generate_instances (CalClientMulti *multi,
- CalObjType type,
- time_t start,
- time_t end,
- CalRecurInstanceFn cb,
- gpointer cb_data)
-{
- CalClient *client;
- GList *l;
-
- g_return_if_fail (IS_CAL_CLIENT_MULTI (multi));
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client)) {
- cal_client_generate_instances (
- client, type, start, end, cb, cb_data);
- }
- }
-}
-
-/**
- * cal_client_multi_get_alarms_in_range
- */
-GSList *
-cal_client_multi_get_alarms_in_range (CalClientMulti *multi, time_t start, time_t end)
-{
- CalClient *client;
- GList *l;
- GSList *result = NULL;
-
- g_return_val_if_fail (IS_CAL_CLIENT_MULTI (multi), NULL);
-
- for (l = multi->priv->uris; l; l = l->next) {
- client = cal_client_multi_get_client_for_uri (multi,
- (const char *) l->data);
- if (IS_CAL_CLIENT (client)) {
- GSList *tmp;
-
- tmp = cal_client_get_alarms_in_range (client, start, end);
- if (tmp)
- result = g_slist_concat (result, tmp);
- }
- }
-
- return result;
-}
diff --git a/calendar/cal-client/cal-client-multi.h b/calendar/cal-client/cal-client-multi.h
deleted file mode 100644
index dd4248bd80..0000000000
--- a/calendar/cal-client/cal-client-multi.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* Evolution calendar client
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Rodrigo Moya <rodrigo@ximian.com>
- *
- * 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_CLIENT_MULTI_H
-#define CAL_CLIENT_MULTI_H
-
-#include <cal-client/cal-client.h>
-
-G_BEGIN_DECLS
-
-#define CAL_CLIENT_MULTI_TYPE (cal_client_multi_get_type ())
-#define CAL_CLIENT_MULTI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_CLIENT_MULTI_TYPE, CalClientMulti))
-#define CAL_CLIENT_MULTI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_CLIENT_MULTI_TYPE, CalClientMultiClass))
-#define IS_CAL_CLIENT_MULTI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_CLIENT_MULTI_TYPE))
-#define IS_CAL_CLIENT_MULTI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_CLIENT_MULTI_TYPE))
-
-typedef struct _CalClientMulti CalClientMulti;
-typedef struct _CalClientMultiClass CalClientMultiClass;
-typedef struct _CalClientMultiPrivate CalClientMultiPrivate;
-
-struct _CalClientMulti {
- GObject object;
-
- /* Private data */
- CalClientMultiPrivate *priv;
-};
-
-struct _CalClientMultiClass {
- GObjectClass parent_class;
-
- /* notification signals */
- void (* cal_opened) (CalClientMulti *multi, CalClient *client, CalClientOpenStatus status);
-
- void (* obj_updated) (CalClientMulti *multi, CalClient *client, const char *uid);
- void (* obj_removed) (CalClientMulti *multi, CalClient *client, const char *uid);
-
- void (* categories_changed) (CalClientMulti *multi, CalClient *client, GPtrArray *categories);
-
- void (* forget_password) (CalClientMulti *multi, CalClient *client, const char *key);
-};
-
-GType cal_client_multi_get_type (void);
-
-CalClientMulti *cal_client_multi_new (void);
-
-void cal_client_multi_add_client (CalClientMulti *multi, CalClient *client);
-void cal_client_multi_set_auth_func (CalClientMulti *multi,
- CalClientAuthFunc func,
- gpointer user_data);
-
-CalClient *cal_client_multi_open_calendar (CalClientMulti *multi,
- const char *str_uri,
- gboolean only_if_exists);
-CalClient *cal_client_multi_get_client_for_uri (CalClientMulti *multi,
- const char *uri);
-
-int cal_client_multi_get_n_objects (CalClientMulti *multi, CalObjType type);
-CalClientGetStatus cal_client_multi_get_object (CalClientMulti *multi,
- const char *uid,
- CalComponent **comp);
-CalClientGetStatus cal_client_multi_get_timezone (CalClientMulti *multi,
- const char *tzid,
- icaltimezone **zone);
-GList *cal_client_multi_get_uids (CalClientMulti *multi, CalObjType type);
-GList *cal_client_multi_get_changes (CalClientMulti *multi,
- CalObjType type,
- const char *change_id);
-GList *cal_client_multi_get_objects_in_range (CalClientMulti *multi,
- CalObjType type,
- time_t start,
- time_t end);
-GList *cal_client_multi_get_free_busy (CalClientMulti *multi,
- GList *users,
- time_t start,
- time_t end);
-void cal_client_multi_generate_instances (CalClientMulti *multi,
- CalObjType type,
- time_t start,
- time_t end,
- CalRecurInstanceFn cb,
- gpointer cb_data);
-GSList *cal_client_multi_get_alarms_in_range (CalClientMulti *multi,
- time_t start, time_t end);
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/cal-client/cal-client-types.c b/calendar/cal-client/cal-client-types.c
deleted file mode 100644
index 36a524ec99..0000000000
--- a/calendar/cal-client/cal-client-types.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Evolution calendar utilities and types
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- * JP Rosevear <jpr@ximian.com>
- *
- * 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 <config.h>
-#include <stdlib.h>
-#include "cal-client-types.h"
-
-
-
-/**
- * cal_client_change_list_free:
- * @list: List of #CalClientChange structures.
- *
- * Frees a list of #CalClientChange structures.
- **/
-void
-cal_client_change_list_free (GList *list)
-{
- CalClientChange *c;
- GList *l;
-
- for (l = list; l; l = l->next) {
- c = l->data;
-
- g_assert (c != NULL);
- g_assert (c->comp != NULL);
-
- g_object_unref (G_OBJECT (c->comp));
- g_free (c);
- }
-
- g_list_free (list);
-}
diff --git a/calendar/cal-client/cal-client-types.h b/calendar/cal-client/cal-client-types.h
deleted file mode 100644
index c160a1fa94..0000000000
--- a/calendar/cal-client/cal-client-types.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Evolution calendar utilities and types
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- * JP Rosevear <jpr@ximian.com>
- *
- * 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_CLIENT_TYPES_H
-#define CAL_CLIENT_TYPES_H
-
-#include <cal-util/cal-component.h>
-
-G_BEGIN_DECLS
-
-
-
-typedef enum {
- CAL_CLIENT_CHANGE_ADDED = 1 << 0,
- CAL_CLIENT_CHANGE_MODIFIED = 1 << 1,
- CAL_CLIENT_CHANGE_DELETED = 1 << 2
-} CalClientChangeType;
-
-typedef struct
-{
- CalComponent *comp;
- CalClientChangeType type;
-} CalClientChange;
-
-void cal_client_change_list_free (GList *list);
-
-G_END_DECLS
-
-#endif
-
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
deleted file mode 100644
index 9e96c78d0e..0000000000
--- a/calendar/cal-client/cal-client.c
+++ /dev/null
@@ -1,3089 +0,0 @@
-/* Evolution calendar client
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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 <config.h>
-#endif
-
-#include <string.h>
-#include <bonobo-activation/bonobo-activation.h>
-#include <bonobo/bonobo-exception.h>
-#include <libgnome/gnome-util.h>
-
-#include "e-util/e-component-listener.h"
-#include "e-util/e-config-listener.h"
-#include "cal-util/cal-util-marshal.h"
-#include "cal-client-types.h"
-#include "cal-client.h"
-#include "cal-listener.h"
-#include "wombat-client.h"
-
-
-
-/* Private part of the CalClient structure */
-struct _CalClientPrivate {
- /* Load state to avoid multiple loads */
- CalClientLoadState load_state;
-
- /* URI of the calendar that is being loaded or is already loaded, or
- * NULL if we are not loaded.
- */
- char *uri;
-
- /* Email address associated with this calendar, or NULL */
- char *cal_address;
- char *alarm_email_address;
- char *ldap_attribute;
-
- /* Scheduling info */
- char *capabilities;
-
- /* The calendar factories we are contacting */
- GList *factories;
-
- /* Our calendar listener implementation */
- CalListener *listener;
-
- /* The calendar client interface object we are contacting */
- GNOME_Evolution_Calendar_Cal cal;
-
- /* The authentication function */
- CalClientAuthFunc auth_func;
- gpointer auth_user_data;
-
- /* The WombatClient */
- WombatClient *w_client;
-
- /* A cache of timezones retrieved from the server, to avoid getting
- them repeatedly for each get_object() call. */
- GHashTable *timezones;
-
- /* The default timezone to use to resolve DATE and floating DATE-TIME
- values. */
- icaltimezone *default_zone;
-
- /* The component listener to keep track of the lifetime of backends */
- EComponentListener *comp_listener;
-};
-
-
-
-/* Signal IDs */
-enum {
- CAL_OPENED,
- CAL_SET_MODE,
- OBJ_UPDATED,
- OBJ_REMOVED,
- BACKEND_ERROR,
- CATEGORIES_CHANGED,
- FORGET_PASSWORD,
- BACKEND_DIED,
- LAST_SIGNAL
-};
-
-static void cal_client_class_init (CalClientClass *klass);
-static void cal_client_init (CalClient *client, CalClientClass *klass);
-static void cal_client_finalize (GObject *object);
-
-static char *client_get_password_cb (WombatClient *w_client,
- const gchar *prompt,
- const gchar *key,
- gpointer user_data);
-static void client_forget_password_cb (WombatClient *w_client,
- const gchar *key,
- gpointer user_data);
-static void cal_client_get_object_timezones_cb (icalparameter *param,
- void *data);
-
-static guint cal_client_signals[LAST_SIGNAL];
-
-static GObjectClass *parent_class;
-
-
-
-/**
- * cal_client_get_type:
- *
- * Registers the #CalClient class if necessary, and returns the type ID assigned
- * to it.
- *
- * Return value: The type ID of the #CalClient class.
- **/
-GType
-cal_client_get_type (void)
-{
- static GType cal_client_type = 0;
-
- if (!cal_client_type) {
- static GTypeInfo info = {
- sizeof (CalClientClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) cal_client_class_init,
- NULL, NULL,
- sizeof (CalClient),
- 0,
- (GInstanceInitFunc) cal_client_init
- };
- cal_client_type = g_type_register_static (G_TYPE_OBJECT, "CalClient", &info, 0);
- }
-
- return cal_client_type;
-}
-
-GType
-cal_client_open_status_enum_get_type (void)
-{
- static GType cal_client_open_status_enum_type = 0;
-
- if (!cal_client_open_status_enum_type) {
- static GEnumValue values [] = {
- { CAL_CLIENT_OPEN_SUCCESS, "CalClientOpenSuccess", "success" },
- { CAL_CLIENT_OPEN_ERROR, "CalClientOpenError", "error" },
- { CAL_CLIENT_OPEN_NOT_FOUND, "CalClientOpenNotFound", "not-found" },
- { CAL_CLIENT_OPEN_PERMISSION_DENIED, "CalClientOpenPermissionDenied", "denied" },
- { CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED, "CalClientOpenMethodNotSupported", "unsupported" },
- { -1, NULL, NULL }
- };
-
- cal_client_open_status_enum_type = g_enum_register_static ("CalClientOpenStatusEnum", values);
- }
-
- return cal_client_open_status_enum_type;
-}
-
-GType
-cal_client_set_mode_status_enum_get_type (void)
-{
- static GType cal_client_set_mode_status_enum_type = 0;
-
- if (!cal_client_set_mode_status_enum_type) {
- static GEnumValue values [] = {
- { CAL_CLIENT_SET_MODE_SUCCESS, "CalClientSetModeSuccess", "success" },
- { CAL_CLIENT_SET_MODE_ERROR, "CalClientSetModeError", "error" },
- { CAL_CLIENT_SET_MODE_NOT_SUPPORTED, "CalClientSetModeNotSupported", "unsupported" },
- { -1, NULL, NULL }
- };
-
- cal_client_set_mode_status_enum_type =
- g_enum_register_static ("CalClientSetModeStatusEnum", values);
- }
-
- return cal_client_set_mode_status_enum_type;
-}
-
-GType
-cal_mode_enum_get_type (void)
-{
- static GType cal_mode_enum_type = 0;
-
- if (!cal_mode_enum_type) {
- static GEnumValue values [] = {
- { CAL_MODE_INVALID, "CalModeInvalid", "invalid" },
- { CAL_MODE_LOCAL, "CalModeLocal", "local" },
- { CAL_MODE_REMOTE, "CalModeRemote", "remote" },
- { CAL_MODE_ANY, "CalModeAny", "any" },
- { -1, NULL, NULL }
- };
-
- cal_mode_enum_type = g_enum_register_static ("CalModeEnum", values);
- }
-
- return cal_mode_enum_type;
-}
-
-/* Class initialization function for the calendar client */
-static void
-cal_client_class_init (CalClientClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = (GObjectClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- cal_client_signals[CAL_OPENED] =
- g_signal_new ("cal_opened",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientClass, cal_opened),
- NULL, NULL,
- g_cclosure_marshal_VOID__ENUM,
- G_TYPE_NONE, 1,
- CAL_CLIENT_OPEN_STATUS_ENUM_TYPE);
- cal_client_signals[CAL_SET_MODE] =
- g_signal_new ("cal_set_mode",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientClass, cal_set_mode),
- NULL, NULL,
- cal_util_marshal_VOID__ENUM_ENUM,
- G_TYPE_NONE, 2,
- CAL_CLIENT_SET_MODE_STATUS_ENUM_TYPE,
- CAL_MODE_ENUM_TYPE);
- cal_client_signals[OBJ_UPDATED] =
- g_signal_new ("obj_updated",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientClass, obj_updated),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
- cal_client_signals[OBJ_REMOVED] =
- g_signal_new ("obj_removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientClass, obj_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
- cal_client_signals[BACKEND_ERROR] =
- g_signal_new ("backend_error",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientClass, backend_error),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
- cal_client_signals[CATEGORIES_CHANGED] =
- g_signal_new ("categories_changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientClass, categories_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
- cal_client_signals[FORGET_PASSWORD] =
- g_signal_new ("forget_password",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientClass, forget_password),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
- cal_client_signals[BACKEND_DIED] =
- g_signal_new ("backend_died",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalClientClass, backend_died),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- klass->cal_opened = NULL;
- klass->obj_updated = NULL;
- klass->obj_removed = NULL;
- klass->categories_changed = NULL;
- klass->forget_password = NULL;
- klass->backend_died = NULL;
-
- object_class->finalize = cal_client_finalize;
-}
-
-/* Object initialization function for the calendar client */
-static void
-cal_client_init (CalClient *client, CalClientClass *klass)
-{
- CalClientPrivate *priv;
-
- priv = g_new0 (CalClientPrivate, 1);
- client->priv = priv;
-
- priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED;
- priv->uri = NULL;
- priv->cal_address = NULL;
- priv->alarm_email_address = NULL;
- priv->ldap_attribute = NULL;
- priv->capabilities = FALSE;
- priv->factories = NULL;
- priv->timezones = g_hash_table_new (g_str_hash, g_str_equal);
- priv->w_client = NULL;
- priv->default_zone = icaltimezone_get_utc_timezone ();
- priv->comp_listener = NULL;
-}
-
-/* Gets rid of the factories that a client knows about */
-static void
-destroy_factories (CalClient *client)
-{
- CalClientPrivate *priv;
- CORBA_Object factory;
- CORBA_Environment ev;
- int result;
- GList *f;
-
- priv = client->priv;
-
- CORBA_exception_init (&ev);
-
- for (f = priv->factories; f; f = f->next) {
- factory = f->data;
-
- result = CORBA_Object_is_nil (factory, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("destroy_factories(): could not see if a factory was nil");
- CORBA_exception_free (&ev);
-
- continue;
- }
-
- if (result)
- continue;
-
- CORBA_Object_release (factory, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("destroy_factories(): could not release a factory");
- CORBA_exception_free (&ev);
- }
- }
-
- g_list_free (priv->factories);
- priv->factories = NULL;
-}
-
-/* Gets rid of the calendar client interface object that a client knows about */
-static void
-destroy_cal (CalClient *client)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- int result;
-
- priv = client->priv;
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (priv->cal, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("destroy_cal(): could not see if the "
- "calendar client interface object was nil");
- priv->cal = CORBA_OBJECT_NIL;
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
-
- if (result)
- return;
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Cal_unref (priv->cal, &ev);
- if (BONOBO_EX (&ev))
- g_message ("destroy_cal(): could not unref the calendar client interface object");
-
- CORBA_exception_free (&ev);
-
- CORBA_exception_init (&ev);
- CORBA_Object_release (priv->cal, &ev);
- if (BONOBO_EX (&ev))
- g_message ("destroy_cal(): could not release the calendar client interface object");
-
- CORBA_exception_free (&ev);
- priv->cal = CORBA_OBJECT_NIL;
-
-}
-
-static void
-free_timezone (gpointer key, gpointer value, gpointer data)
-{
- /* Note that the key comes from within the icaltimezone value, so we
- don't free that. */
- icaltimezone_free (value, TRUE);
-}
-
-/* Finalize handler for the calendar client */
-static void
-cal_client_finalize (GObject *object)
-{
- CalClient *client;
- CalClientPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_CLIENT (object));
-
- client = CAL_CLIENT (object);
- priv = client->priv;
-
- if (priv->listener) {
- cal_listener_stop_notification (priv->listener);
- bonobo_object_unref (priv->listener);
- priv->listener = NULL;
- }
-
- if (priv->comp_listener) {
- g_signal_handlers_disconnect_matched (G_OBJECT (priv->comp_listener),
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL,
- client);
- g_object_unref (G_OBJECT (priv->comp_listener));
- priv->comp_listener = NULL;
- }
-
- priv->w_client = NULL;
- /* destroy_factories (client); */
- destroy_cal (client);
-
- priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED;
-
- if (priv->uri) {
- g_free (priv->uri);
- priv->uri = NULL;
- }
-
- if (priv->cal_address) {
- g_free (priv->cal_address);
- priv->cal_address = NULL;
- }
- if (priv->alarm_email_address) {
- g_free (priv->alarm_email_address);
- priv->alarm_email_address = NULL;
- }
- if (priv->ldap_attribute) {
- g_free (priv->ldap_attribute);
- priv->ldap_attribute = NULL;
- }
- if (priv->capabilities) {
- g_free (priv->capabilities);
- priv->capabilities = NULL;
- }
-
- g_hash_table_foreach (priv->timezones, free_timezone, NULL);
- g_hash_table_destroy (priv->timezones);
- priv->timezones = NULL;
-
- g_free (priv);
- client->priv = NULL;
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-
-static void
-backend_died_cb (EComponentListener *cl, gpointer user_data)
-{
- CalClientPrivate *priv;
- CalClient *client = (CalClient *) user_data;
-
- g_return_if_fail (IS_CAL_CLIENT (client));
-
- priv = client->priv;
- priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED;
- g_signal_emit (G_OBJECT (client), cal_client_signals[BACKEND_DIED], 0);
-}
-
-/* Signal handlers for the listener's signals */
-/* Handle the cal_opened notification from the listener */
-static void
-cal_opened_cb (CalListener *listener,
- GNOME_Evolution_Calendar_Listener_OpenStatus status,
- GNOME_Evolution_Calendar_Cal cal,
- gpointer data)
-{
- CalClient *client;
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_Cal cal_copy;
- CalClientOpenStatus client_status;
-
- client = CAL_CLIENT (data);
- priv = client->priv;
-
- g_assert (priv->load_state == CAL_CLIENT_LOAD_LOADING);
- g_assert (priv->uri != NULL);
-
- client_status = CAL_CLIENT_OPEN_ERROR;
-
- switch (status) {
- case GNOME_Evolution_Calendar_Listener_SUCCESS:
- CORBA_exception_init (&ev);
- cal_copy = CORBA_Object_duplicate (cal, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("cal_opened_cb(): could not duplicate the "
- "calendar client interface");
- CORBA_exception_free (&ev);
- goto error;
- }
- CORBA_exception_free (&ev);
-
- priv->cal = cal_copy;
- priv->load_state = CAL_CLIENT_LOAD_LOADED;
-
- client_status = CAL_CLIENT_OPEN_SUCCESS;
-
- /* setup component listener */
- priv->comp_listener = e_component_listener_new (priv->cal);
- g_signal_connect (G_OBJECT (priv->comp_listener), "component_died",
- G_CALLBACK (backend_died_cb), client);
- goto out;
-
- case GNOME_Evolution_Calendar_Listener_ERROR:
- client_status = CAL_CLIENT_OPEN_ERROR;
- goto error;
-
- case GNOME_Evolution_Calendar_Listener_NOT_FOUND:
- client_status = CAL_CLIENT_OPEN_NOT_FOUND;
- goto error;
-
- case GNOME_Evolution_Calendar_Listener_METHOD_NOT_SUPPORTED:
- client_status = CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED;
- goto error;
-
- case GNOME_Evolution_Calendar_Listener_PERMISSION_DENIED :
- client_status = CAL_CLIENT_OPEN_PERMISSION_DENIED;
- goto error;
-
- default:
- g_assert_not_reached ();
- }
-
- error:
-
- bonobo_object_unref (BONOBO_OBJECT (priv->listener));
- priv->listener = NULL;
-
- /* We free the priv->uri and set the priv->load_state until after the
- * "cal_opened" signal has been emitted so that handlers will be able to
- * access this information.
- */
-
- out:
-
- /* We are *not* inside a signal handler (this is just a simple callback
- * called from the listener), so there is not a temporary reference to
- * the client object. We ref() so that we can safely emit our own
- * signal and clean up.
- */
-
- g_object_ref (G_OBJECT (client));
-
- g_signal_emit (G_OBJECT (client), cal_client_signals[CAL_OPENED],
- 0, client_status);
-
- if (client_status != CAL_CLIENT_OPEN_SUCCESS) {
- priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED;
- g_free (priv->uri);
- priv->uri = NULL;
- }
-
- g_assert (priv->load_state != CAL_CLIENT_LOAD_LOADING);
-
- g_object_unref (G_OBJECT (client));
-}
-
-/* Handle the cal_set_mode notification from the listener */
-static void
-cal_set_mode_cb (CalListener *listener,
- GNOME_Evolution_Calendar_Listener_SetModeStatus status,
- GNOME_Evolution_Calendar_CalMode mode,
- gpointer data)
-{
- CalClient *client;
- CalClientPrivate *priv;
- CalClientSetModeStatus client_status;
-
- client = CAL_CLIENT (data);
- priv = client->priv;
-
- client_status = CAL_CLIENT_OPEN_ERROR;
-
- switch (status) {
- case GNOME_Evolution_Calendar_Listener_MODE_SET:
- client_status = CAL_CLIENT_SET_MODE_SUCCESS;
- break;
- case GNOME_Evolution_Calendar_Listener_MODE_NOT_SET:
- client_status = CAL_CLIENT_SET_MODE_ERROR;
- break;
- case GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED:
- client_status = CAL_CLIENT_SET_MODE_NOT_SUPPORTED;
- break;
- default:
- g_assert_not_reached ();
- }
-
- /* We are *not* inside a signal handler (this is just a simple callback
- * called from the listener), so there is not a temporary reference to
- * the client object. We ref() so that we can safely emit our own
- * signal and clean up.
- */
-
- g_object_ref (G_OBJECT (client));
-
- g_signal_emit (G_OBJECT (client), cal_client_signals[CAL_SET_MODE],
- 0, client_status, mode);
-
- g_object_unref (G_OBJECT (client));
-}
-
-/* Handle the obj_updated signal from the listener */
-static void
-obj_updated_cb (CalListener *listener, const CORBA_char *uid, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- g_signal_emit (G_OBJECT (client), cal_client_signals[OBJ_UPDATED], 0, uid);
-}
-
-/* Handle the obj_removed signal from the listener */
-static void
-obj_removed_cb (CalListener *listener, const CORBA_char *uid, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- g_signal_emit (G_OBJECT (client), cal_client_signals[OBJ_REMOVED], 0, uid);
-}
-
-/* Handle the error_occurred signal from the listener */
-static void
-backend_error_cb (CalListener *listener, const char *message, gpointer data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (data);
- g_signal_emit (G_OBJECT (client), cal_client_signals[BACKEND_ERROR], 0, message);
-}
-
-/* Handle the categories_changed signal from the listener */
-static void
-categories_changed_cb (CalListener *listener, const GNOME_Evolution_Calendar_StringSeq *categories,
- gpointer data)
-{
- CalClient *client;
- GPtrArray *cats;
- int i;
-
- client = CAL_CLIENT (data);
-
- cats = g_ptr_array_new ();
- g_ptr_array_set_size (cats, categories->_length);
-
- for (i = 0; i < categories->_length; i++)
- cats->pdata[i] = categories->_buffer[i];
-
- g_signal_emit (G_OBJECT (client), cal_client_signals[CATEGORIES_CHANGED], 0, cats);
-
- g_ptr_array_free (cats, TRUE);
-}
-
-
-/* Handle the get_password signal from the Wombatclient */
-static gchar *
-client_get_password_cb (WombatClient *w_client,
- const gchar *prompt,
- const gchar *key,
- gpointer user_data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (user_data);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- if (client->priv->auth_func)
- return client->priv->auth_func (client, prompt, key, client->priv->auth_user_data);
-
- return NULL;
-}
-
-/* Handle the forget_password signal from the WombatClient */
-static void
-client_forget_password_cb (WombatClient *w_client,
- const gchar *key,
- gpointer user_data)
-{
- CalClient *client;
-
- client = CAL_CLIENT (user_data);
- g_return_if_fail (IS_CAL_CLIENT (client));
-
- g_signal_emit (G_OBJECT (client),
- cal_client_signals [FORGET_PASSWORD],
- 0, key);
-}
-
-
-
-static GList *
-get_factories (void)
-{
- GList *factories = NULL;
- GNOME_Evolution_Calendar_CalFactory factory;
- Bonobo_ServerInfoList *servers;
- CORBA_Environment ev;
- int i;
-
- CORBA_exception_init (&ev);
-
- servers = bonobo_activation_query ("repo_ids.has ('IDL:GNOME/Evolution/Calendar/CalFactory:1.0')", NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("Cannot perform OAF query for Calendar servers.");
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- if (servers->_length == 0)
- g_warning ("No Calendar servers installed.");
-
- for (i = 0; i < servers->_length; i++) {
- const Bonobo_ServerInfo *info;
-
- info = servers->_buffer + i;
-
- factory = (GNOME_Evolution_Calendar_CalFactory)
- bonobo_activation_activate_from_id (info->iid, 0, NULL, &ev);
- if (BONOBO_EX (&ev)) {
-#if 0
- g_warning ("cal_client_construct: Could not activate calendar server %s", info->iid);
- CORBA_free (servers);
- CORBA_exception_free (&ev);
- return NULL;
-#endif
- }
- else
- factories = g_list_prepend (factories, factory);
- }
-
- CORBA_free (servers);
- CORBA_exception_free (&ev);
- return factories;
-}
-
-/**
- * cal_client_construct:
- * @client: A calendar client.
- *
- * Constructs a calendar client object by contacting all available
- * calendar factories.
- *
- * Return value: The same object as the @client argument, or NULL if the
- * calendar factory could not be contacted.
- **/
-CalClient *
-cal_client_construct (CalClient *client)
-{
- CalClientPrivate *priv;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- priv->factories = get_factories ();
-
- return client;
-}
-
-/**
- * cal_client_new:
- *
- * Creates a new calendar client. It should be initialized by calling
- * cal_client_open_calendar().
- *
- * Return value: A newly-created calendar client, or NULL if the client could
- * not be constructed because it could not contact the calendar server.
- **/
-CalClient *
-cal_client_new (void)
-{
- CalClient *client;
-
- client = g_object_new (CAL_CLIENT_TYPE, NULL);
-
- if (!cal_client_construct (client)) {
- g_message ("cal_client_new(): could not construct the calendar client");
- g_object_unref (G_OBJECT (client));
- return NULL;
- }
-
- return client;
-}
-
-/**
- * cal_client_set_auth_func
- * @client: A calendar client.
- * @func: The authentication function
- * @data: User data to be used when calling the authentication function
- *
- * Associates the given authentication function with a calendar client. This
- * function will be called any time the calendar server needs a password
- * from the client. So, calendar clients should provide such authentication
- * function, which, when called, should act accordingly (by showing a dialog
- * box, for example, to ask the user for the password).
- *
- * The authentication function must have the following form:
- * char * auth_func (CalClient *client,
- * const gchar *prompt,
- * const gchar *key,
- * gpointer user_data)
- */
-void
-cal_client_set_auth_func (CalClient *client, CalClientAuthFunc func, gpointer data)
-{
- g_return_if_fail (client != NULL);
- g_return_if_fail (IS_CAL_CLIENT (client));
-
- client->priv->auth_func = func;
- client->priv->auth_user_data = data;
-}
-
-static gboolean
-real_open_calendar (CalClient *client, const char *str_uri, gboolean only_if_exists, gboolean *supported)
-{
- CalClientPrivate *priv;
- GNOME_Evolution_Calendar_Listener corba_listener;
- int unsupported;
- GList *f;
- CORBA_Environment ev;
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_NOT_LOADED, FALSE);
- g_assert (priv->uri == NULL);
-
- g_return_val_if_fail (str_uri != NULL, FALSE);
-
- priv->listener = cal_listener_new (cal_opened_cb,
- cal_set_mode_cb,
- obj_updated_cb,
- obj_removed_cb,
- backend_error_cb,
- categories_changed_cb,
- client);
- if (!priv->listener) {
- g_message ("cal_client_open_calendar(): could not create the listener");
- return FALSE;
- }
-
- /* create the WombatClient */
- priv->w_client = wombat_client_new (
- (WombatClientGetPasswordFn) client_get_password_cb,
- (WombatClientForgetPasswordFn) client_forget_password_cb,
- (gpointer) client);
- bonobo_object_add_interface (BONOBO_OBJECT (priv->listener),
- BONOBO_OBJECT (priv->w_client));
-
- corba_listener = (GNOME_Evolution_Calendar_Listener) (BONOBO_OBJREF (priv->listener));
-
- priv->load_state = CAL_CLIENT_LOAD_LOADING;
- priv->uri = g_strdup (str_uri);
-
- unsupported = 0;
- for (f = priv->factories; f; f = f->next) {
- CORBA_exception_init (&ev);
-
- GNOME_Evolution_Calendar_CalFactory_open (f->data, str_uri,
- only_if_exists,
- corba_listener, &ev);
- if (!BONOBO_EX (&ev))
- break;
- else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod))
- unsupported++;
- }
-
- if (supported != NULL) {
- if (unsupported == g_list_length (priv->factories))
- *supported = FALSE;
- else
- *supported = TRUE;
- }
-
- if (BONOBO_EX (&ev)) {
- bonobo_object_unref (BONOBO_OBJECT (priv->listener));
- priv->listener = NULL;
- priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED;
- g_free (priv->uri);
- priv->uri = NULL;
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- * cal_client_open_calendar:
- * @client: A calendar client.
- * @str_uri: URI of calendar to open.
- * @only_if_exists: FALSE if the calendar should be opened even if there
- * was no storage for it, i.e. to create a new calendar or load an existing
- * one if it already exists. TRUE if it should only try to load calendars
- * that already exist.
- *
- * Makes a calendar client initiate a request to open a calendar. The calendar
- * client will emit the "cal_opened" signal when the response from the server is
- * received.
- *
- * Return value: TRUE on success, FALSE on failure to issue the open request.
- **/
-gboolean
-cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_if_exists)
-{
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- return real_open_calendar (client, str_uri, only_if_exists, NULL);
-}
-
-static char *
-get_fall_back_uri (gboolean tasks)
-{
- if (tasks)
- return g_concat_dir_and_file (g_get_home_dir (),
- "evolution/local/"
- "Tasks/tasks.ics");
- else
- return g_concat_dir_and_file (g_get_home_dir (),
- "evolution/local/"
- "Calendar/calendar.ics");
-}
-
-static char *
-get_default_uri (gboolean tasks)
-{
- EConfigListener *db;
- char *uri;
-
- db = e_config_listener_new ();
-
- if (tasks)
- uri = e_config_listener_get_string (db, "/apps/evolution/shell/default_folders/tasks_uri");
- else
- uri = e_config_listener_get_string (db, "/apps/evolution/shell/default_folders/calendar_uri");
- g_object_unref (G_OBJECT (db));
-
- if (!uri || *uri == '\0')
- uri = get_fall_back_uri (tasks);
- else
- uri = cal_util_expand_uri (uri, tasks);
-
- return uri;
-}
-
-gboolean
-cal_client_open_default_calendar (CalClient *client, gboolean only_if_exists)
-{
- char *default_uri, *fall_back;
- gboolean result, supported;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- default_uri = get_default_uri (FALSE);
- fall_back = get_fall_back_uri (FALSE);
-
- result = real_open_calendar (client, default_uri, only_if_exists, &supported);
- if (!supported && strcmp (fall_back, default_uri))
- result = real_open_calendar (client, fall_back, only_if_exists, NULL);
-
- g_free (default_uri);
- g_free (fall_back);
-
- return result;
-}
-
-gboolean
-cal_client_open_default_tasks (CalClient *client, gboolean only_if_exists)
-{
- char *default_uri, *fall_back;
- gboolean result, supported;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- default_uri = get_default_uri (TRUE);
- fall_back = get_fall_back_uri (TRUE);
-
- result = real_open_calendar (client, default_uri, only_if_exists, &supported);
- if (!supported && strcmp (fall_back, default_uri))
- result = real_open_calendar (client, fall_back, only_if_exists, NULL);
-
- g_free (default_uri);
- g_free (fall_back);
-
- return result;
-}
-
-/* Builds an URI list out of a CORBA string sequence */
-static GList *
-build_uri_list (GNOME_Evolution_Calendar_StringSeq *seq)
-{
- GList *uris = NULL;
- int i;
-
- for (i = 0; i < seq->_length; i++)
- uris = g_list_prepend (uris, g_strdup (seq->_buffer[i]));
-
- return uris;
-}
-
-/**
- * cal_client_uri_list:
- * @client: A calendar client
- * @type: type of uri's to get
- *
- *
- * Return value: A list of URI's open on the wombat
- **/
-GList *
-cal_client_uri_list (CalClient *client, CalMode mode)
-{
- CalClientPrivate *priv;
- GNOME_Evolution_Calendar_StringSeq *uri_seq;
- GList *uris = NULL;
- CORBA_Environment ev;
- GList *f;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- priv = client->priv;
-
- for (f = priv->factories; f; f = f->next) {
- CORBA_exception_init (&ev);
- uri_seq = GNOME_Evolution_Calendar_CalFactory_uriList (f->data, mode, &ev);
-
- if (BONOBO_EX (&ev)) {
- g_message ("cal_client_uri_list(): request failed");
-
- /* free memory and return */
- g_list_foreach (uris, (GFunc) g_free, NULL);
- g_list_free (uris);
- uris = NULL;
- break;
- }
- else {
- uris = g_list_concat (uris, build_uri_list (uri_seq));
- CORBA_free (uri_seq);
- }
-
- CORBA_exception_free (&ev);
- }
-
- return uris;
-}
-
-/**
- * cal_client_get_load_state:
- * @client: A calendar client.
- *
- * Queries the state of loading of a calendar client.
- *
- * Return value: A #CalClientLoadState value indicating whether the client has
- * not been loaded with cal_client_open_calendar() yet, whether it is being
- * loaded, or whether it is already loaded.
- **/
-CalClientLoadState
-cal_client_get_load_state (CalClient *client)
-{
- CalClientPrivate *priv;
-
- g_return_val_if_fail (client != NULL, CAL_CLIENT_LOAD_NOT_LOADED);
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_LOAD_NOT_LOADED);
-
- priv = client->priv;
- return priv->load_state;
-}
-
-/**
- * cal_client_get_uri:
- * @client: A calendar client.
- *
- * Queries the URI that is open in a calendar client.
- *
- * Return value: The URI of the calendar that is already loaded or is being
- * loaded, or NULL if the client has not started a load request yet.
- **/
-const char *
-cal_client_get_uri (CalClient *client)
-{
- CalClientPrivate *priv;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- return priv->uri;
-}
-
-/**
- * cal_client_is_read_only:
- * @client: A calendar client.
- *
- * Queries whether the calendar client can perform modifications
- * on the calendar or not.
- *
- * Return value: TRUE if the calendar is read-only, FALSE otherwise.
- */
-gboolean
-cal_client_is_read_only (CalClient *client)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- CORBA_boolean read_only;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- priv = client->priv;
-
- if (priv->load_state != CAL_CLIENT_LOAD_LOADED)
- return FALSE;
-
- CORBA_exception_init (&ev);
- read_only = GNOME_Evolution_Calendar_Cal_isReadOnly (priv->cal, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("cal_client_is_read_only: could not call isReadOnly method");
- }
- CORBA_exception_free (&ev);
-
- return read_only;
-}
-
-/**
- * cal_client_get_cal_address:
- * @client: A calendar client.
- *
- * Queries the calendar address associated with a calendar client.
- *
- * Return value: The calendar address associated with the calendar that
- * is loaded or being loaded, or %NULL if the client has not started a
- * load request yet or the calendar has no associated email address.
- **/
-const char *
-cal_client_get_cal_address (CalClient *client)
-{
- CalClientPrivate *priv;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL);
-
- if (priv->cal_address == NULL) {
- CORBA_Environment ev;
- CORBA_char *cal_address;
-
- CORBA_exception_init (&ev);
- cal_address = GNOME_Evolution_Calendar_Cal_getCalAddress (priv->cal, &ev);
- if (!BONOBO_EX (&ev)) {
- priv->cal_address = g_strdup (cal_address);
- CORBA_free (cal_address);
- }
- CORBA_exception_free (&ev);
- }
-
- return priv->cal_address;
-}
-
-const char *
-cal_client_get_alarm_email_address (CalClient *client)
-{
- CalClientPrivate *priv;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL);
-
- if (priv->alarm_email_address == NULL) {
- CORBA_Environment ev;
- CORBA_char *email_address;
-
- CORBA_exception_init (&ev);
- email_address = GNOME_Evolution_Calendar_Cal_getAlarmEmailAddress (priv->cal, &ev);
- if (!BONOBO_EX (&ev)) {
- priv->alarm_email_address = g_strdup (email_address);
- CORBA_free (email_address);
- }
- CORBA_exception_free (&ev);
- }
-
- return priv->alarm_email_address;
-}
-
-const char *
-cal_client_get_ldap_attribute (CalClient *client)
-{
- CalClientPrivate *priv;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL);
-
- if (priv->ldap_attribute == NULL) {
- CORBA_Environment ev;
- CORBA_char *ldap_attribute;
-
- CORBA_exception_init (&ev);
- ldap_attribute = GNOME_Evolution_Calendar_Cal_getLdapAttribute (priv->cal, &ev);
- if (!BONOBO_EX (&ev)) {
- priv->ldap_attribute = g_strdup (ldap_attribute);
- CORBA_free (ldap_attribute);
- }
- CORBA_exception_free (&ev);
- }
-
- return priv->ldap_attribute;
-}
-
-static void
-load_static_capabilities (CalClient *client)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- char *cap;
-
- priv = client->priv;
-
- if (priv->capabilities)
- return;
-
- CORBA_exception_init (&ev);
- cap = GNOME_Evolution_Calendar_Cal_getStaticCapabilities (priv->cal, &ev);
- if (!BONOBO_EX (&ev))
- priv->capabilities = g_strdup (cap);
- else
- priv->capabilities = g_strdup ("");
- CORBA_exception_free (&ev);
-}
-
-static gboolean
-check_capability (CalClient *client, const char *cap)
-{
- CalClientPrivate *priv;
-
- priv = client->priv;
-
- load_static_capabilities (client);
- if (strstr (priv->capabilities, cap))
- return TRUE;
-
- return FALSE;
-}
-
-gboolean
-cal_client_get_one_alarm_only (CalClient *client)
-{
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- return check_capability (client, CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY);
-}
-
-gboolean
-cal_client_get_organizer_must_attend (CalClient *client)
-{
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- return check_capability (client, CAL_STATIC_CAPABILITY_ORGANIZER_MUST_ATTEND);
-}
-
-gboolean
-cal_client_get_static_capability (CalClient *client, const char *cap)
-{
- return check_capability (client, cap);
-}
-
-gboolean
-cal_client_get_save_schedules (CalClient *client)
-{
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- return check_capability (client, CAL_STATIC_CAPABILITY_SAVE_SCHEDULES);
-}
-
-/* Converts our representation of a calendar component type into its CORBA representation */
-static GNOME_Evolution_Calendar_CalObjType
-corba_obj_type (CalObjType type)
-{
- return (((type & CALOBJ_TYPE_EVENT) ? GNOME_Evolution_Calendar_TYPE_EVENT : 0)
- | ((type & CALOBJ_TYPE_TODO) ? GNOME_Evolution_Calendar_TYPE_TODO : 0)
- | ((type & CALOBJ_TYPE_JOURNAL) ? GNOME_Evolution_Calendar_TYPE_JOURNAL : 0));
-}
-
-gboolean
-cal_client_set_mode (CalClient *client, CalMode mode)
-{
- CalClientPrivate *priv;
- gboolean retval = TRUE;
- CORBA_Environment ev;
-
- g_return_val_if_fail (client != NULL, -1);
- g_return_val_if_fail (IS_CAL_CLIENT (client), -1);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, -1);
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Cal_setMode (priv->cal, mode, &ev);
-
- if (BONOBO_EX (&ev))
- retval = FALSE;
-
- CORBA_exception_free (&ev);
-
- return retval;
-}
-
-/**
- * cal_client_get_n_objects:
- * @client: A calendar client.
- * @type: Type of objects that will be counted.
- *
- * Counts the number of calendar components of the specified @type. This can be
- * used to count how many events, to-dos, or journals there are, for example.
- *
- * Return value: Number of components.
- **/
-int
-cal_client_get_n_objects (CalClient *client, CalObjType type)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- int n;
- int t;
-
- g_return_val_if_fail (client != NULL, -1);
- g_return_val_if_fail (IS_CAL_CLIENT (client), -1);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, -1);
-
- t = corba_obj_type (type);
-
- CORBA_exception_init (&ev);
- n = GNOME_Evolution_Calendar_Cal_countObjects (priv->cal, t, &ev);
-
- if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_n_objects(): could not get the number of objects");
- CORBA_exception_free (&ev);
- return -1;
- }
-
- CORBA_exception_free (&ev);
- return n;
-}
-
-
-/* This is used in the callback which fetches all the timezones needed for an
- object. */
-typedef struct _CalClientGetTimezonesData CalClientGetTimezonesData;
-struct _CalClientGetTimezonesData {
- CalClient *client;
-
- /* This starts out at CAL_CLIENT_GET_SUCCESS. If an error occurs this
- contains the last error. */
- CalClientGetStatus status;
-};
-
-CalClientGetStatus
-cal_client_get_default_object (CalClient *client, CalObjType type, CalComponent **comp)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CalObj comp_str;
- CalClientGetStatus retval;
- icalcomponent *icalcomp;
- CalClientGetTimezonesData cb_data;
-
- g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_NOT_FOUND);
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_GET_NOT_FOUND);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_GET_NOT_FOUND);
-
- g_return_val_if_fail (comp != NULL, CAL_CLIENT_GET_NOT_FOUND);
-
- retval = CAL_CLIENT_GET_NOT_FOUND;
- *comp = NULL;
-
- CORBA_exception_init (&ev);
- comp_str = GNOME_Evolution_Calendar_Cal_getDefaultObject (priv->cal, type, &ev);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- goto out;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_object(): could not get the object");
- goto out;
- }
-
- icalcomp = icalparser_parse_string (comp_str);
- CORBA_free (comp_str);
-
- if (!icalcomp) {
- retval = CAL_CLIENT_GET_SYNTAX_ERROR;
- goto out;
- }
-
- *comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (*comp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (*comp);
- *comp = NULL;
-
- retval = CAL_CLIENT_GET_SYNTAX_ERROR;
- goto out;
- }
-
- /* Now make sure we have all timezones needed for this object.
- We do this to try to avoid any problems caused by getting a timezone
- in the middle of other code. Any calls to ORBit result in a
- recursive call of the GTK+ main loop, which can cause problems for
- code that doesn't expect it. Currently GnomeCanvas has problems if
- we try to get a timezone in the middle of a redraw, and there is a
- resize pending, which leads to an assert failure and an abort. */
- cb_data.client = client;
- cb_data.status = CAL_CLIENT_GET_SUCCESS;
- icalcomponent_foreach_tzid (icalcomp,
- cal_client_get_object_timezones_cb,
- &cb_data);
-
- retval = cb_data.status;
-
- out:
-
- CORBA_exception_free (&ev);
- return retval;
-}
-
-/**
- * cal_client_get_object:
- * @client: A calendar client.
- * @uid: Unique identifier for a calendar component.
- * @comp: Return value for the calendar component object.
- *
- * Queries a calendar for a calendar component object based on its unique
- * identifier.
- *
- * Return value: Result code based on the status of the operation.
- **/
-CalClientGetStatus
-cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CalObj comp_str;
- CalClientGetStatus retval;
- icalcomponent *icalcomp;
- CalClientGetTimezonesData cb_data;
-
- g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_NOT_FOUND);
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_GET_NOT_FOUND);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_GET_NOT_FOUND);
-
- g_return_val_if_fail (uid != NULL, CAL_CLIENT_GET_NOT_FOUND);
- g_return_val_if_fail (comp != NULL, CAL_CLIENT_GET_NOT_FOUND);
-
- retval = CAL_CLIENT_GET_NOT_FOUND;
- *comp = NULL;
-
- CORBA_exception_init (&ev);
- comp_str = GNOME_Evolution_Calendar_Cal_getObject (priv->cal, (char *) uid, &ev);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- goto out;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_object(): could not get the object");
- goto out;
- }
-
- icalcomp = icalparser_parse_string (comp_str);
- CORBA_free (comp_str);
-
- if (!icalcomp) {
- retval = CAL_CLIENT_GET_SYNTAX_ERROR;
- goto out;
- }
-
- *comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (*comp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (G_OBJECT (*comp));
- *comp = NULL;
-
- retval = CAL_CLIENT_GET_SYNTAX_ERROR;
- goto out;
- }
-
- /* Now make sure we have all timezones needed for this object.
- We do this to try to avoid any problems caused by getting a timezone
- in the middle of other code. Any calls to ORBit result in a
- recursive call of the GLib main loop, which can cause problems for
- code that doesn't expect it. Currently GnomeCanvas has problems if
- we try to get a timezone in the middle of a redraw, and there is a
- resize pending, which leads to an assert failure and an abort. */
- cb_data.client = client;
- cb_data.status = CAL_CLIENT_GET_SUCCESS;
- icalcomponent_foreach_tzid (icalcomp,
- cal_client_get_object_timezones_cb,
- &cb_data);
-
- retval = cb_data.status;
-
- out:
-
- CORBA_exception_free (&ev);
- return retval;
-}
-
-
-static void
-cal_client_get_object_timezones_cb (icalparameter *param,
- void *data)
-{
- CalClientGetTimezonesData *cb_data = data;
- const char *tzid;
- icaltimezone *zone;
- CalClientGetStatus status;
-
- tzid = icalparameter_get_tzid (param);
- if (!tzid) {
- cb_data->status = CAL_CLIENT_GET_SYNTAX_ERROR;
- return;
- }
-
- status = cal_client_get_timezone (cb_data->client, tzid, &zone);
- if (status != CAL_CLIENT_GET_SUCCESS)
- cb_data->status = status;
-}
-
-
-CalClientGetStatus
-cal_client_get_timezone (CalClient *client,
- const char *tzid,
- icaltimezone **zone)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CalObj comp_str;
- CalClientGetStatus retval;
- icalcomponent *icalcomp;
- icaltimezone *tmp_zone;
-
- g_return_val_if_fail (client != NULL, CAL_CLIENT_GET_NOT_FOUND);
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_GET_NOT_FOUND);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED,
- CAL_CLIENT_GET_NOT_FOUND);
-
- g_return_val_if_fail (zone != NULL, CAL_CLIENT_GET_NOT_FOUND);
-
- /* If tzid is NULL or "" we return NULL, since it is a 'local time'. */
- if (!tzid || !tzid[0]) {
- *zone = NULL;
- return CAL_CLIENT_GET_SUCCESS;
- }
-
- /* If it is UTC, we return the special UTC timezone. */
- if (!strcmp (tzid, "UTC")) {
- *zone = icaltimezone_get_utc_timezone ();
- return CAL_CLIENT_GET_SUCCESS;
- }
-
- /* See if we already have it in the cache. */
- tmp_zone = g_hash_table_lookup (priv->timezones, tzid);
- if (tmp_zone) {
- *zone = tmp_zone;
- return CAL_CLIENT_GET_SUCCESS;
- }
-
- retval = CAL_CLIENT_GET_NOT_FOUND;
- *zone = NULL;
-
- /* We don't already have it, so we try to get it from the server. */
- CORBA_exception_init (&ev);
- comp_str = GNOME_Evolution_Calendar_Cal_getTimezoneObject (priv->cal, (char *) tzid, &ev);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- goto out;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_timezone(): could not get the object");
- goto out;
- }
-
- icalcomp = icalparser_parse_string (comp_str);
- CORBA_free (comp_str);
-
- if (!icalcomp) {
- retval = CAL_CLIENT_GET_SYNTAX_ERROR;
- goto out;
- }
-
- tmp_zone = icaltimezone_new ();
- if (!tmp_zone) {
- /* FIXME: Needs better error code - out of memory. Or just
- abort like GLib does? */
- retval = CAL_CLIENT_GET_NOT_FOUND;
- goto out;
- }
-
- if (!icaltimezone_set_component (tmp_zone, icalcomp)) {
- retval = CAL_CLIENT_GET_SYNTAX_ERROR;
- goto out;
- }
-
- /* Now add it to the cache, to avoid the server call in future. */
- g_hash_table_insert (priv->timezones, icaltimezone_get_tzid (tmp_zone),
- tmp_zone);
-
- *zone = tmp_zone;
- retval = CAL_CLIENT_GET_SUCCESS;
-
- out:
-
- CORBA_exception_free (&ev);
- return retval;
-}
-
-/* Resolves TZIDs for the recurrence generator. */
-icaltimezone*
-cal_client_resolve_tzid_cb (const char *tzid, gpointer data)
-{
- CalClient *client;
- icaltimezone *zone = NULL;
- CalClientGetStatus status;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (data), NULL);
-
- client = CAL_CLIENT (data);
-
- /* FIXME: Handle errors. */
- status = cal_client_get_timezone (client, tzid, &zone);
-
- return zone;
-}
-
-
-/* Builds an UID list out of a CORBA UID sequence */
-static GList *
-build_uid_list (GNOME_Evolution_Calendar_CalObjUIDSeq *seq)
-{
- GList *uids;
- int i;
-
- uids = NULL;
-
- for (i = 0; i < seq->_length; i++)
- uids = g_list_prepend (uids, g_strdup (seq->_buffer[i]));
-
- return uids;
-}
-
-/**
- * cal_client_get_uids:
- * @client: A calendar client.
- * @type: Bitmask with types of objects to return.
- *
- * Queries a calendar for a list of unique identifiers corresponding to calendar
- * objects whose type matches one of the types specified in the @type flags.
- *
- * Return value: A list of strings that are the sought UIDs. This should be
- * freed using the cal_obj_uid_list_free() function.
- **/
-GList *
-cal_client_get_uids (CalClient *client, CalObjType type)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CalObjUIDSeq *seq;
- int t;
- GList *uids;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL);
-
- t = corba_obj_type (type);
-
- CORBA_exception_init (&ev);
-
- seq = GNOME_Evolution_Calendar_Cal_getUIDs (priv->cal, t, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_uids(): could not get the list of UIDs");
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- uids = build_uid_list (seq);
- CORBA_free (seq);
-
- return uids;
-}
-
-/* Builds a GList of CalClientChange structures from the CORBA sequence */
-static GList *
-build_change_list (GNOME_Evolution_Calendar_CalObjChangeSeq *seq)
-{
- GList *list = NULL;
- icalcomponent *icalcomp;
- int i;
-
- /* Create the list in reverse order */
- for (i = 0; i < seq->_length; i++) {
- GNOME_Evolution_Calendar_CalObjChange *corba_coc;
- CalClientChange *ccc;
-
- corba_coc = &seq->_buffer[i];
- ccc = g_new (CalClientChange, 1);
-
- icalcomp = icalparser_parse_string (corba_coc->calobj);
- if (!icalcomp)
- continue;
-
- ccc->comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (ccc->comp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (G_OBJECT (ccc->comp));
- continue;
- }
- ccc->type = corba_coc->type;
-
- list = g_list_prepend (list, ccc);
- }
-
- list = g_list_reverse (list);
-
- return list;
-}
-
-GList *
-cal_client_get_changes (CalClient *client, CalObjType type, const char *change_id)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CalObjChangeSeq *seq;
- int t;
- GList *changes;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL);
-
- t = corba_obj_type (type);
- CORBA_exception_init (&ev);
-
- seq = GNOME_Evolution_Calendar_Cal_getChanges (priv->cal, t, change_id, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_changes(): could not get the list of changes");
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- changes = build_change_list (seq);
- CORBA_free (seq);
-
- return changes;
-}
-
-/* FIXME: Not used? */
-#if 0
-/* Builds a GList of CalObjInstance structures from the CORBA sequence */
-static GList *
-build_object_instance_list (GNOME_Evolution_Calendar_CalObjInstanceSeq *seq)
-{
- GList *list;
- int i;
-
- /* Create the list in reverse order */
-
- list = NULL;
- for (i = 0; i < seq->_length; i++) {
- GNOME_Evolution_Calendar_CalObjInstance *corba_icoi;
- CalObjInstance *icoi;
-
- corba_icoi = &seq->_buffer[i];
- icoi = g_new (CalObjInstance, 1);
-
- icoi->uid = g_strdup (corba_icoi->uid);
- icoi->start = corba_icoi->start;
- icoi->end = corba_icoi->end;
-
- list = g_list_prepend (list, icoi);
- }
-
- list = g_list_reverse (list);
- return list;
-}
-#endif
-
-/**
- * cal_client_get_objects_in_range:
- * @client: A calendar client.
- * @type: Bitmask with types of objects to return.
- * @start: Start time for query.
- * @end: End time for query.
- *
- * Queries a calendar for the objects that occur or recur in the specified range
- * of time.
- *
- * Return value: A list of UID strings. This should be freed using the
- * cal_obj_uid_list_free() function.
- **/
-GList *
-cal_client_get_objects_in_range (CalClient *client, CalObjType type, time_t start, time_t end)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CalObjUIDSeq *seq;
- GList *uids;
- int t;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL);
-
- g_return_val_if_fail (start != -1 && end != -1, NULL);
- g_return_val_if_fail (start <= end, NULL);
-
- CORBA_exception_init (&ev);
-
- t = corba_obj_type (type);
-
- seq = GNOME_Evolution_Calendar_Cal_getObjectsInRange (priv->cal, t, start, end, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_objects_in_range(): could not get the objects");
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- uids = build_uid_list (seq);
- CORBA_free (seq);
-
- return uids;
-}
-
-/**
- * cal_client_get_free_busy
- * @client:: A calendar client.
- * @users: List of users to retrieve free/busy information for.
- * @start: Start time for query.
- * @end: End time for query.
- *
- * Gets free/busy information from the calendar server.
- *
- * Returns: a GList of VFREEBUSY CalComponents
- */
-GList *
-cal_client_get_free_busy (CalClient *client, GList *users,
- time_t start, time_t end)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_UserList *corba_list;
- GNOME_Evolution_Calendar_CalObjSeq *calobj_list;
- GList *l;
- GList *comp_list = NULL;
- int len, i;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL);
-
- g_return_val_if_fail (start != -1 && end != -1, NULL);
- g_return_val_if_fail (start <= end, NULL);
-
- /* create the CORBA user list to be passed to the backend */
- len = g_list_length (users);
-
- corba_list = GNOME_Evolution_Calendar_UserList__alloc ();
- CORBA_sequence_set_release (corba_list, TRUE);
- corba_list->_length = len;
- corba_list->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (len);
-
- for (l = g_list_first (users), i = 0; l; l = l->next, i++)
- corba_list->_buffer[i] = CORBA_string_dup ((CORBA_char *) l->data);
-
- /* call the method on the backend */
- CORBA_exception_init (&ev);
-
- calobj_list = GNOME_Evolution_Calendar_Cal_getFreeBusy (priv->cal, corba_list,
- start, end, &ev);
- CORBA_free (corba_list);
- if (BONOBO_EX (&ev) || !calobj_list) {
- if (!BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- g_message ("cal_client_get_free_busy(): could not get the objects");
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- for (i = 0; i < calobj_list->_length; i++) {
- CalComponent *comp;
- icalcomponent *icalcomp;
- icalcomponent_kind kind;
-
- icalcomp = icalparser_parse_string (calobj_list->_buffer[i]);
- if (!icalcomp)
- continue;
-
- kind = icalcomponent_isa (icalcomp);
- if (kind == ICAL_VFREEBUSY_COMPONENT) {
- comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (comp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (G_OBJECT (comp));
- continue;
- }
-
- comp_list = g_list_append (comp_list, comp);
- }
- else
- icalcomponent_free (icalcomp);
- }
-
- CORBA_exception_free (&ev);
- CORBA_free (calobj_list);
-
- return comp_list;
-}
-
-/* Callback used when an object is updated and we must update the copy we have */
-static void
-generate_instances_obj_updated_cb (CalClient *client, const char *uid, gpointer data)
-{
- GHashTable *uid_comp_hash;
- CalComponent *comp;
- CalClientGetStatus status;
- const char *comp_uid;
-
- uid_comp_hash = data;
-
- comp = g_hash_table_lookup (uid_comp_hash, uid);
- if (!comp)
- /* OK, so we don't care about new objects that may indeed be in
- * the requested time range. We only care about the ones that
- * were returned by the first query to
- * cal_client_get_objects_in_range().
- */
- return;
-
- g_hash_table_remove (uid_comp_hash, uid);
- g_object_unref (G_OBJECT (comp));
-
- status = cal_client_get_object (client, uid, &comp);
-
- switch (status) {
- case CAL_CLIENT_GET_SUCCESS:
- /* The hash key comes from the component's internal data */
- cal_component_get_uid (comp, &comp_uid);
- g_hash_table_insert (uid_comp_hash, (char *) comp_uid, comp);
- break;
-
- case CAL_CLIENT_GET_NOT_FOUND:
- /* No longer in the server, too bad */
- break;
-
- case CAL_CLIENT_GET_SYNTAX_ERROR:
- g_message ("obj_updated_cb(): Syntax error when getting "
- "object `%s'; ignoring...", uid);
- break;
-
- }
-}
-
-/* Callback used when an object is removed and we must delete the copy we have */
-static void
-generate_instances_obj_removed_cb (CalClient *client, const char *uid, gpointer data)
-{
- GHashTable *uid_comp_hash;
- CalComponent *comp;
-
- uid_comp_hash = data;
-
- comp = g_hash_table_lookup (uid_comp_hash, uid);
- if (!comp)
- return;
-
- g_hash_table_remove (uid_comp_hash, uid);
- g_object_unref (G_OBJECT (comp));
-}
-
-/* Adds a component to the list; called from g_hash_table_foreach() */
-static void
-add_component (gpointer key, gpointer value, gpointer data)
-{
- CalComponent *comp;
- GList **list;
-
- comp = CAL_COMPONENT (value);
- list = data;
-
- *list = g_list_prepend (*list, comp);
-}
-
-/* Gets a list of components that recur within the specified range of time. It
- * ensures that the resulting list of CalComponent objects contains only objects
- * that are actually in the server at the time the initial
- * cal_client_get_objects_in_range() query ends.
- */
-static GList *
-get_objects_atomically (CalClient *client, CalObjType type, time_t start, time_t end)
-{
- GList *uids;
- GHashTable *uid_comp_hash;
- GList *objects;
- guint obj_updated_id;
- guint obj_removed_id;
- GList *l;
-
- uids = cal_client_get_objects_in_range (client, type, start, end);
-
- uid_comp_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- /* While we are getting the actual object data, keep track of changes */
-
- obj_updated_id = g_signal_connect (G_OBJECT (client), "obj_updated",
- G_CALLBACK (generate_instances_obj_updated_cb),
- uid_comp_hash);
-
- obj_removed_id = g_signal_connect (G_OBJECT (client), "obj_removed",
- G_CALLBACK (generate_instances_obj_removed_cb),
- uid_comp_hash);
-
- /* Get the objects */
-
- for (l = uids; l; l = l->next) {
- CalComponent *comp;
- CalClientGetStatus status;
- char *uid;
- const char *comp_uid;
-
- uid = l->data;
-
- status = cal_client_get_object (client, uid, &comp);
-
- switch (status) {
- case CAL_CLIENT_GET_SUCCESS:
- /* The hash key comes from the component's internal data
- * instead of the duped UID from the list of UIDS.
- */
- cal_component_get_uid (comp, &comp_uid);
- g_hash_table_insert (uid_comp_hash, (char *) comp_uid, comp);
- break;
-
- case CAL_CLIENT_GET_NOT_FOUND:
- /* Object disappeared from the server, so don't log it */
- break;
-
- case CAL_CLIENT_GET_SYNTAX_ERROR:
- g_message ("get_objects_atomically(): Syntax error when getting "
- "object `%s'; ignoring...", uid);
- break;
-
- default:
- g_assert_not_reached ();
- }
- }
-
- cal_obj_uid_list_free (uids);
-
- /* Now our state is consistent with the server, so disconnect from the
- * notification signals and generate the final list of components.
- */
-
- g_signal_handler_disconnect (client, obj_updated_id);
- g_signal_handler_disconnect (client, obj_removed_id);
-
- objects = NULL;
- g_hash_table_foreach (uid_comp_hash, add_component, &objects);
- g_hash_table_destroy (uid_comp_hash);
-
- return objects;
-}
-
-struct comp_instance {
- CalComponent *comp;
- time_t start;
- time_t end;
-};
-
-/* Called from cal_recur_generate_instances(); adds an instance to the list */
-static gboolean
-add_instance (CalComponent *comp, time_t start, time_t end, gpointer data)
-{
- GList **list;
- struct comp_instance *ci;
-
- list = data;
-
- ci = g_new (struct comp_instance, 1);
-
- ci->comp = comp;
- g_object_ref (G_OBJECT (ci->comp));
-
- ci->start = start;
- ci->end = end;
-
- *list = g_list_prepend (*list, ci);
-
- return TRUE;
-}
-
-/* Used from g_list_sort(); compares two struct comp_instance structures */
-static gint
-compare_comp_instance (gconstpointer a, gconstpointer b)
-{
- const struct comp_instance *cia, *cib;
- time_t diff;
-
- cia = a;
- cib = b;
-
- diff = cia->start - cib->start;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
-}
-
-/**
- * cal_client_generate_instances:
- * @client: A calendar client.
- * @type: Bitmask with types of objects to return.
- * @start: Start time for query.
- * @end: End time for query.
- * @cb: Callback for each generated instance.
- * @cb_data: Closure data for the callback.
- *
- * Does a combination of cal_client_get_objects_in_range() and
- * cal_recur_generate_instances(). It fetches the list of objects in an atomic
- * way so that the generated instances are actually in the server at the time
- * the initial cal_client_get_objects_in_range() query ends.
- *
- * The callback function should do a g_object_ref() of the calendar component
- * it gets passed if it intends to keep it around.
- **/
-void
-cal_client_generate_instances (CalClient *client, CalObjType type,
- time_t start, time_t end,
- CalRecurInstanceFn cb, gpointer cb_data)
-{
- CalClientPrivate *priv;
- GList *objects;
- GList *instances;
- GList *l;
-
- g_return_if_fail (client != NULL);
- g_return_if_fail (IS_CAL_CLIENT (client));
-
- priv = client->priv;
- g_return_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED);
-
- g_return_if_fail (start != -1 && end != -1);
- g_return_if_fail (start <= end);
- g_return_if_fail (cb != NULL);
-
- /* Generate objects */
-
- objects = get_objects_atomically (client, type, start, end);
- instances = NULL;
-
- for (l = objects; l; l = l->next) {
- CalComponent *comp;
-
- comp = l->data;
- cal_recur_generate_instances (comp, start, end, add_instance, &instances,
- cal_client_resolve_tzid_cb, client,
- priv->default_zone);
- g_object_unref (G_OBJECT (comp));
- }
-
- g_list_free (objects);
-
- /* Generate instances and spew them out */
-
- instances = g_list_sort (instances, compare_comp_instance);
-
- for (l = instances; l; l = l->next) {
- struct comp_instance *ci;
- gboolean result;
-
- ci = l->data;
-
- result = (* cb) (ci->comp, ci->start, ci->end, cb_data);
-
- if (!result)
- break;
- }
-
- /* Clean up */
-
- for (l = instances; l; l = l->next) {
- struct comp_instance *ci;
-
- ci = l->data;
- g_object_unref (G_OBJECT (ci->comp));
- g_free (ci);
- }
-
- g_list_free (instances);
-}
-
-/* Builds a list of CalAlarmInstance structures */
-static GSList *
-build_alarm_instance_list (CalComponent *comp, GNOME_Evolution_Calendar_CalAlarmInstanceSeq *seq)
-{
- GSList *alarms;
- int i;
-
- alarms = NULL;
-
- for (i = 0; i < seq->_length; i++) {
- GNOME_Evolution_Calendar_CalAlarmInstance *corba_instance;
- CalComponentAlarm *alarm;
- const char *auid;
- CalAlarmInstance *instance;
-
- corba_instance = seq->_buffer + i;
-
- /* Since we want the in-commponent auid, we look for the alarm
- * in the component and fetch its "real" auid.
- */
-
- alarm = cal_component_get_alarm (comp, corba_instance->auid);
- if (!alarm)
- continue;
-
- auid = cal_component_alarm_get_uid (alarm);
- cal_component_alarm_free (alarm);
-
- instance = g_new (CalAlarmInstance, 1);
- instance->auid = auid;
- instance->trigger = corba_instance->trigger;
- instance->occur_start = corba_instance->occur_start;
- instance->occur_end = corba_instance->occur_end;
-
- alarms = g_slist_prepend (alarms, instance);
- }
-
- return g_slist_reverse (alarms);
-}
-
-/* Builds a list of CalComponentAlarms structures */
-static GSList *
-build_component_alarms_list (GNOME_Evolution_Calendar_CalComponentAlarmsSeq *seq)
-{
- GSList *comp_alarms;
- int i;
-
- comp_alarms = NULL;
-
- for (i = 0; i < seq->_length; i++) {
- GNOME_Evolution_Calendar_CalComponentAlarms *corba_alarms;
- CalComponent *comp;
- CalComponentAlarms *alarms;
- icalcomponent *icalcomp;
-
- corba_alarms = seq->_buffer + i;
-
- icalcomp = icalparser_parse_string (corba_alarms->calobj);
- if (!icalcomp)
- continue;
-
- comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (comp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (G_OBJECT (comp));
- continue;
- }
-
- alarms = g_new (CalComponentAlarms, 1);
- alarms->comp = comp;
- alarms->alarms = build_alarm_instance_list (comp, &corba_alarms->alarms);
-
- comp_alarms = g_slist_prepend (comp_alarms, alarms);
- }
-
- return comp_alarms;
-}
-
-/**
- * cal_client_get_alarms_in_range:
- * @client: A calendar client.
- * @start: Start time for query.
- * @end: End time for query.
- *
- * Queries a calendar for the alarms that trigger in the specified range of
- * time.
- *
- * Return value: A list of #CalComponentAlarms structures. This should be freed
- * using the cal_client_free_alarms() function, or by freeing each element
- * separately with cal_component_alarms_free() and then freeing the list with
- * g_slist_free().
- **/
-GSList *
-cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CalComponentAlarmsSeq *seq;
- GSList *alarms;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL);
-
- g_return_val_if_fail (start != -1 && end != -1, NULL);
- g_return_val_if_fail (start <= end, NULL);
-
- CORBA_exception_init (&ev);
-
- seq = GNOME_Evolution_Calendar_Cal_getAlarmsInRange (priv->cal, start, end, &ev);
- if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_alarms_in_range(): could not get the alarm range");
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- alarms = build_component_alarms_list (seq);
- CORBA_free (seq);
-
- return alarms;
-}
-
-/**
- * cal_client_free_alarms:
- * @comp_alarms: A list of #CalComponentAlarms structures.
- *
- * Frees a list of #CalComponentAlarms structures as returned by
- * cal_client_get_alarms_in_range().
- **/
-void
-cal_client_free_alarms (GSList *comp_alarms)
-{
- GSList *l;
-
- for (l = comp_alarms; l; l = l->next) {
- CalComponentAlarms *alarms;
-
- alarms = l->data;
- g_assert (alarms != NULL);
-
- cal_component_alarms_free (alarms);
- }
-
- g_slist_free (comp_alarms);
-}
-
-/**
- * cal_client_get_alarms_for_object:
- * @client: A calendar client.
- * @uid: Unique identifier for a calendar component.
- * @start: Start time for query.
- * @end: End time for query.
- * @alarms: Return value for the component's alarm instances. Will return NULL
- * if no instances occur within the specified time range. This should be freed
- * using the cal_component_alarms_free() function.
- *
- * Queries a calendar for the alarms of a particular object that trigger in the
- * specified range of time.
- *
- * Return value: TRUE on success, FALSE if the object was not found.
- **/
-gboolean
-cal_client_get_alarms_for_object (CalClient *client, const char *uid,
- time_t start, time_t end,
- CalComponentAlarms **alarms)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_CalComponentAlarms *corba_alarms;
- gboolean retval;
- icalcomponent *icalcomp;
- CalComponent *comp;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, FALSE);
-
- g_return_val_if_fail (uid != NULL, FALSE);
- g_return_val_if_fail (start != -1 && end != -1, FALSE);
- g_return_val_if_fail (start <= end, FALSE);
- g_return_val_if_fail (alarms != NULL, FALSE);
-
- *alarms = NULL;
- retval = FALSE;
-
- CORBA_exception_init (&ev);
-
- corba_alarms = GNOME_Evolution_Calendar_Cal_getAlarmsForObject (priv->cal, (char *) uid,
- start, end, &ev);
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- goto out;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_get_alarms_for_object(): could not get the alarm range");
- goto out;
- }
-
- icalcomp = icalparser_parse_string (corba_alarms->calobj);
- if (!icalcomp)
- goto out;
-
- comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (comp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (G_OBJECT (comp));
- goto out;
- }
-
- retval = TRUE;
-
- *alarms = g_new (CalComponentAlarms, 1);
- (*alarms)->comp = comp;
- (*alarms)->alarms = build_alarm_instance_list (comp, &corba_alarms->alarms);
- CORBA_free (corba_alarms);
-
- out:
- CORBA_exception_free (&ev);
- return retval;
-}
-
-/**
- * cal_client_discard_alarm
- * @client: A calendar client.
- * @comp: The component to discard the alarm from.
- * @auid: Unique identifier of the alarm to be discarded.
- *
- * Tells the calendar backend to get rid of the alarm identified by the
- * @auid argument in @comp. Some backends might remove the alarm or
- * update internal information about the alarm be discarded, or, like
- * the file backend does, ignore the operation.
- *
- * Return value: a #CalClientResult value indicating the result of the
- * operation.
- */
-CalClientResult
-cal_client_discard_alarm (CalClient *client, CalComponent *comp, const char *auid)
-{
- CalClientPrivate *priv;
- CalClientResult retval;
- CORBA_Environment ev;
- const char *uid;
-
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_NOT_FOUND);
- g_return_val_if_fail (IS_CAL_COMPONENT (comp), CAL_CLIENT_RESULT_NOT_FOUND);
- g_return_val_if_fail (auid != NULL, CAL_CLIENT_RESULT_NOT_FOUND);
-
- priv = client->priv;
-
- cal_component_get_uid (comp, &uid);
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Cal_discardAlarm (priv->cal, uid, auid, &ev);
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- retval = CAL_CLIENT_RESULT_NOT_FOUND;
- else if (BONOBO_EX (&ev))
- retval = CAL_CLIENT_RESULT_CORBA_ERROR;
- else
- retval = CAL_CLIENT_RESULT_SUCCESS;
-
- CORBA_exception_free (&ev);
- return retval;
-}
-
-typedef struct _ForeachTZIDCallbackData ForeachTZIDCallbackData;
-struct _ForeachTZIDCallbackData {
- CalClient *client;
- GHashTable *timezone_hash;
- gboolean include_all_timezones;
- gboolean success;
-};
-
-/* This adds the VTIMEZONE given by the TZID parameter to the GHashTable in
- data. */
-static void
-foreach_tzid_callback (icalparameter *param, void *cbdata)
-{
- ForeachTZIDCallbackData *data = cbdata;
- CalClientPrivate *priv;
- const char *tzid;
- icaltimezone *zone;
- icalcomponent *vtimezone_comp;
- char *vtimezone_as_string;
-
- priv = data->client->priv;
-
- /* Get the TZID string from the parameter. */
- tzid = icalparameter_get_tzid (param);
- if (!tzid)
- return;
-
- /* Check if we've already added it to the GHashTable. */
- if (g_hash_table_lookup (data->timezone_hash, tzid))
- return;
-
- if (data->include_all_timezones) {
- CalClientGetStatus status;
-
- status = cal_client_get_timezone (data->client, tzid, &zone);
- if (status != CAL_CLIENT_GET_SUCCESS) {
- data->success = FALSE;
- return;
- }
- } else {
- /* Check if it is in our cache. If it is, it must already be
- on the server so return. */
- if (g_hash_table_lookup (priv->timezones, tzid))
- return;
-
- /* Check if it is a builtin timezone. If it isn't, return. */
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone)
- return;
- }
-
- /* Convert it to a string and add it to the hash. */
- vtimezone_comp = icaltimezone_get_component (zone);
- if (!vtimezone_comp)
- return;
-
- vtimezone_as_string = icalcomponent_as_ical_string (vtimezone_comp);
-
- g_hash_table_insert (data->timezone_hash, (char*) tzid,
- g_strdup (vtimezone_as_string));
-}
-
-/* This appends the value string to the GString given in data. */
-static void
-append_timezone_string (gpointer key, gpointer value, gpointer data)
-{
- GString *vcal_string = data;
-
- g_string_append (vcal_string, value);
- g_free (value);
-}
-
-
-/* This simply frees the hash values. */
-static void
-free_timezone_string (gpointer key, gpointer value, gpointer data)
-{
- g_free (value);
-}
-
-
-/* This converts the VEVENT/VTODO to a string. If include_all_timezones is
- TRUE, it includes all the VTIMEZONE components needed for the VEVENT/VTODO.
- If not, it only includes builtin timezones that may not be on the server.
-
- To do that we check every TZID in the component to see if it is a builtin
- timezone. If it is, we see if it it in our cache. If it is in our cache,
- then we know the server already has it and we don't need to send it.
- If it isn't in our cache, then we need to send it to the server.
- If we need to send any timezones to the server, then we have to create a
- complete VCALENDAR object, otherwise we can just send a single VEVENT/VTODO
- as before. */
-static char*
-cal_client_get_component_as_string_internal (CalClient *client,
- CalComponent *comp,
- gboolean include_all_timezones)
-{
- GHashTable *timezone_hash;
- GString *vcal_string;
- int initial_vcal_string_len;
- ForeachTZIDCallbackData cbdata;
- char *obj_string;
-
- CalClientPrivate *priv;
-
- priv = client->priv;
-
- timezone_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- /* Add any timezones needed to the hash. We use a hash since we only
- want to add each timezone once at most. */
- cbdata.client = client;
- cbdata.timezone_hash = timezone_hash;
- cbdata.include_all_timezones = include_all_timezones;
- cbdata.success = TRUE;
- icalcomponent_foreach_tzid (cal_component_get_icalcomponent (comp),
- foreach_tzid_callback, &cbdata);
- if (!cbdata.success) {
- g_hash_table_foreach (timezone_hash, free_timezone_string,
- NULL);
- return NULL;
- }
-
- /* Create the start of a VCALENDAR, to add the VTIMEZONES to,
- and remember its length so we know if any VTIMEZONEs get added. */
- vcal_string = g_string_new (NULL);
- g_string_append (vcal_string,
- "BEGIN:VCALENDAR\n"
- "PRODID:-//Ximian//NONSGML Evolution Calendar//EN\n"
- "VERSION:2.0\n"
- "METHOD:PUBLISH\n");
- initial_vcal_string_len = vcal_string->len;
-
- /* Now concatenate all the timezone strings. This also frees the
- timezone strings as it goes. */
- g_hash_table_foreach (timezone_hash, append_timezone_string,
- vcal_string);
-
- /* Get the string for the VEVENT/VTODO. */
- obj_string = cal_component_get_as_string (comp);
-
- /* If there were any timezones to send, create a complete VCALENDAR,
- else just send the VEVENT/VTODO string. */
- if (!include_all_timezones
- && vcal_string->len == initial_vcal_string_len) {
- g_string_free (vcal_string, TRUE);
- } else {
- g_string_append (vcal_string, obj_string);
- g_string_append (vcal_string, "END:VCALENDAR\n");
- g_free (obj_string);
- obj_string = vcal_string->str;
- g_string_free (vcal_string, FALSE);
- }
-
- g_hash_table_destroy (timezone_hash);
-
- return obj_string;
-}
-
-/**
- * cal_client_get_component_as_string:
- * @client: A calendar client.
- * @comp: A calendar component object.
- *
- * Gets a calendar component as an iCalendar string, with a toplevel
- * VCALENDAR component and all VTIMEZONEs needed for the component.
- *
- * Return value: the component as a complete iCalendar string, or NULL on
- * failure. The string should be freed after use.
- **/
-char*
-cal_client_get_component_as_string (CalClient *client,
- CalComponent *comp)
-{
- return cal_client_get_component_as_string_internal (client, comp,
- TRUE);
-}
-
-CalClientResult
-cal_client_update_object_with_mod (CalClient *client, CalComponent *comp, CalObjModType mod)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- CalClientResult retval;
- char *obj_string;
-
- g_return_val_if_fail (client != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- g_return_val_if_fail (comp != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- cal_component_commit_sequence (comp);
-
- obj_string = cal_client_get_component_as_string_internal (client,
- comp, FALSE);
- if (obj_string == NULL)
- return CAL_CLIENT_RESULT_INVALID_OBJECT;
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Cal_updateObjects (priv->cal, obj_string, mod, &ev);
- g_free (obj_string);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject))
- retval = CAL_CLIENT_RESULT_INVALID_OBJECT;
- else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- retval = CAL_CLIENT_RESULT_NOT_FOUND;
- else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied))
- retval = CAL_CLIENT_RESULT_PERMISSION_DENIED;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_update_object(): could not update the object");
- retval = CAL_CLIENT_RESULT_CORBA_ERROR;
- }
- else
- retval = CAL_CLIENT_RESULT_SUCCESS;
-
- CORBA_exception_free (&ev);
- return retval;
-}
-
-
-/**
- * cal_client_update_object:
- * @client: A calendar client.
- * @comp: A calendar component object.
- *
- * Asks a calendar to update a component. Any existing component with the
- * specified component's UID will be replaced. The client program should not
- * assume that the object is actually in the server's storage until it has
- * received the "obj_updated" notification signal.
- *
- * Return value: a #CalClientResult value indicating the result of the
- * operation.
- **/
-CalClientResult
-cal_client_update_object (CalClient *client, CalComponent *comp)
-{
-
- return cal_client_update_object_with_mod (client, comp, CALOBJ_MOD_ALL);
-}
-
-/**
- * cal_client_update_objects:
- * @client: A calendar client.
- * @icalcomp: A toplevel VCALENDAR libical component.
- *
- * Asks a calendar to add or update one or more components, possibly including
- * VTIMEZONE data. Any existing components with the same UIDs will be
- * replaced. The VTIMEZONE data will be compared to existing VTIMEZONEs in
- * the calendar, and the VTIMEZONEs may possibly be renamed, as well as all
- * references to them throughout the VCALENDAR.
- *
- * The client program should not assume that the objects are actually in the
- * server's storage until it has received the "obj_updated" notification
- * signal.
- *
- * Return value: a #CalClientResult value indicating the result of the
- * operation.
- **/
-CalClientResult
-cal_client_update_objects (CalClient *client, icalcomponent *icalcomp)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- CalClientResult retval;
- char *obj_string;
-
- g_return_val_if_fail (client != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED,
- CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- g_return_val_if_fail (icalcomp != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- /* Libical owns this memory, using one of its temporary buffers. */
- obj_string = icalcomponent_as_ical_string (icalcomp);
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Cal_updateObjects (priv->cal, obj_string, GNOME_Evolution_Calendar_MOD_ALL, &ev);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject))
- retval = CAL_CLIENT_RESULT_INVALID_OBJECT;
- else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- retval = CAL_CLIENT_RESULT_NOT_FOUND;
- else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied))
- retval = CAL_CLIENT_RESULT_PERMISSION_DENIED;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_update_objects(): could not update the objects");
- retval = CAL_CLIENT_RESULT_CORBA_ERROR;
- }
- else
- retval = CAL_CLIENT_RESULT_SUCCESS;
-
- CORBA_exception_free (&ev);
- return retval;
-}
-
-CalClientResult
-cal_client_remove_object_with_mod (CalClient *client, const char *uid, CalObjModType mod)
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- CalClientResult retval;
-
- g_return_val_if_fail (client != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- g_return_val_if_fail (uid != NULL, CAL_CLIENT_RESULT_NOT_FOUND);
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Cal_removeObject (priv->cal, (char *) uid, mod, &ev);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject))
- retval = CAL_CLIENT_RESULT_INVALID_OBJECT;
- else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- retval = CAL_CLIENT_RESULT_NOT_FOUND;
- else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied))
- retval = CAL_CLIENT_RESULT_PERMISSION_DENIED;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_remove_object(): could not remove the object");
- retval = CAL_CLIENT_RESULT_CORBA_ERROR;
- }
- else
- retval = CAL_CLIENT_RESULT_SUCCESS;
-
- CORBA_exception_free (&ev);
- return retval;
-}
-
-/**
- * cal_client_remove_object:
- * @client: A calendar client.
- * @uid: Unique identifier of the calendar component to remove.
- *
- * Asks a calendar to remove a component. If the server is able to remove the
- * component, all clients will be notified and they will emit the "obj_removed"
- * signal.
- *
- * Return value: a #CalClientResult value indicating the result of the
- * operation.
- **/
-CalClientResult
-cal_client_remove_object (CalClient *client, const char *uid)
-{
- return cal_client_remove_object_with_mod (client, uid, CALOBJ_MOD_ALL);
-}
-
-CalClientResult
-cal_client_send_object (CalClient *client, icalcomponent *icalcomp,
- icalcomponent **new_icalcomp, GList **users,
- char error_msg[256])
-{
- CalClientPrivate *priv;
- CORBA_Environment ev;
- CalClientResult retval;
- GNOME_Evolution_Calendar_UserList *user_list;
- char *obj_string;
- int i;
-
- g_return_val_if_fail (client != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
- g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED,
- CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- g_return_val_if_fail (icalcomp != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
-
- /* Libical owns this memory, using one of its temporary buffers. */
- obj_string = icalcomponent_as_ical_string (icalcomp);
-
- CORBA_exception_init (&ev);
- obj_string = GNOME_Evolution_Calendar_Cal_sendObject (priv->cal, obj_string, &user_list, &ev);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject)) {
- retval = CAL_CLIENT_SEND_INVALID_OBJECT;
- } else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_Busy)) {
- retval = CAL_CLIENT_SEND_BUSY;
- strcpy (error_msg,
- ((GNOME_Evolution_Calendar_Cal_Busy *)(CORBA_exception_value (&ev)))->errorMsg);
- } else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied)) {
- retval = CAL_CLIENT_SEND_PERMISSION_DENIED;
- } else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_update_objects(): could not send the objects");
- retval = CAL_CLIENT_SEND_CORBA_ERROR;
- } else {
- retval = CAL_CLIENT_RESULT_SUCCESS;
-
- *new_icalcomp = icalparser_parse_string (obj_string);
- CORBA_free (obj_string);
-
- if (*new_icalcomp == NULL) {
- retval = CAL_CLIENT_RESULT_INVALID_OBJECT;
- } else {
- *users = NULL;
- for (i = 0; i < user_list->_length; i++)
- *users = g_list_append (*users, g_strdup (user_list->_buffer[i]));
- CORBA_free (user_list);
- }
- }
-
- CORBA_exception_free (&ev);
-
- return retval;
-}
-
-/**
- * cal_client_get_query:
- * @client: A calendar client.
- * @sexp: S-expression representing the query.
- *
- * Creates a live query object from a loaded calendar.
- *
- * Return value: A query object that will emit notification signals as calendar
- * components are added and removed from the query in the server.
- **/
-CalQuery *
-cal_client_get_query (CalClient *client, const char *sexp)
-{
- CalClientPrivate *priv;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
-
- priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, FALSE);
-
- g_return_val_if_fail (sexp != NULL, NULL);
-
- return cal_query_new (priv->cal, sexp);
-}
-
-
-/* This ensures that the given timezone is on the server. We use this to pass
- the default timezone to the server, so it can resolve DATE and floating
- DATE-TIME values into specific times. (Most of our IDL interface uses
- time_t values to pass specific times from the server to the client.) */
-static gboolean
-cal_client_ensure_timezone_on_server (CalClient *client, icaltimezone *zone)
-{
- CalClientPrivate *priv;
- char *tzid, *obj_string;
- icaltimezone *tmp_zone;
- GString *vcal_string;
- gboolean retval = FALSE;
- icalcomponent *vtimezone_comp;
- char *vtimezone_as_string;
- CORBA_Environment ev;
-
- priv = client->priv;
-
- /* If the zone is NULL or UTC we don't need to do anything. */
- if (!zone)
- return TRUE;
-
- tzid = icaltimezone_get_tzid (zone);
-
- if (!strcmp (tzid, "UTC"))
- return TRUE;
-
- /* See if we already have it in the cache. If we do, it must be on
- the server already. */
- tmp_zone = g_hash_table_lookup (priv->timezones, tzid);
- if (tmp_zone)
- return TRUE;
-
- /* Now we have to send it to the server, in case it doesn't already
- have it. */
-
- vcal_string = g_string_new (NULL);
- g_string_append (vcal_string,
- "BEGIN:VCALENDAR\n"
- "PRODID:-//Ximian//NONSGML Evolution Calendar//EN\n"
- "VERSION:2.0\n");
-
- /* Convert the timezone to a string and add it. */
- vtimezone_comp = icaltimezone_get_component (zone);
- if (!vtimezone_comp) {
- g_string_free (vcal_string, TRUE);
- return FALSE;
- }
-
- /* We don't need to free this string as libical owns it. */
- vtimezone_as_string = icalcomponent_as_ical_string (vtimezone_comp);
- g_string_append (vcal_string, vtimezone_as_string);
-
- g_string_append (vcal_string, "END:VCALENDAR\n");
-
- obj_string = vcal_string->str;
- g_string_free (vcal_string, FALSE);
-
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Cal_updateObjects (priv->cal, obj_string, GNOME_Evolution_Calendar_MOD_ALL, &ev);
- g_free (obj_string);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject))
- goto out;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_ensure_timezone_on_server(): could not add the timezone to the server");
- goto out;
- }
-
- retval = TRUE;
-
- out:
- CORBA_exception_free (&ev);
- return retval;
-}
-
-
-gboolean
-cal_client_set_default_timezone (CalClient *client, icaltimezone *zone)
-{
- CalClientPrivate *priv;
- gboolean retval = FALSE;
- CORBA_Environment ev;
- const char *tzid;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE);
- g_return_val_if_fail (zone != NULL, FALSE);
-
- priv = client->priv;
-
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED,
- FALSE);
-
- /* Make sure the server has the VTIMEZONE data. */
- if (!cal_client_ensure_timezone_on_server (client, zone))
- return FALSE;
-
- /* Now set the default timezone on the server. */
- CORBA_exception_init (&ev);
- tzid = icaltimezone_get_tzid (zone);
- GNOME_Evolution_Calendar_Cal_setDefaultTimezone (priv->cal,
- (char *) tzid, &ev);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- goto out;
- else if (BONOBO_EX (&ev)) {
- g_message ("cal_client_set_default_timezone(): could not set the default timezone");
- goto out;
- }
-
- retval = TRUE;
-
- priv->default_zone = zone;
-
- out:
-
- CORBA_exception_free (&ev);
- return retval;
-}
-
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
deleted file mode 100644
index 556049f831..0000000000
--- a/calendar/cal-client/cal-client.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/* Evolution calendar client
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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_CLIENT_H
-#define CAL_CLIENT_H
-
-#include <glib-object.h>
-#include <cal-util/cal-recur.h>
-#include <cal-util/cal-util.h>
-#include <cal-client/cal-query.h>
-
-G_BEGIN_DECLS
-
-
-
-#define CAL_CLIENT_TYPE (cal_client_get_type ())
-#define CAL_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_CLIENT_TYPE, CalClient))
-#define CAL_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_CLIENT_TYPE, CalClientClass))
-#define IS_CAL_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_CLIENT_TYPE))
-#define IS_CAL_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_CLIENT_TYPE))
-
-#define CAL_CLIENT_OPEN_STATUS_ENUM_TYPE (cal_client_open_status_enum_get_type ())
-#define CAL_CLIENT_SET_MODE_STATUS_ENUM_TYPE (cal_client_set_mode_status_enum_get_type ())
-#define CAL_MODE_ENUM_TYPE (cal_mode_enum_get_type ())
-
-typedef struct _CalClient CalClient;
-typedef struct _CalClientClass CalClientClass;
-
-typedef struct _CalClientPrivate CalClientPrivate;
-
-/* Open status for the cal_opened signal */
-typedef enum {
- CAL_CLIENT_OPEN_SUCCESS,
- CAL_CLIENT_OPEN_ERROR,
- CAL_CLIENT_OPEN_NOT_FOUND,
- CAL_CLIENT_OPEN_PERMISSION_DENIED,
- CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED
-} CalClientOpenStatus;
-
-/* Set mode status for the cal_client_set_mode function */
-typedef enum {
- CAL_CLIENT_SET_MODE_SUCCESS,
- CAL_CLIENT_SET_MODE_ERROR,
- CAL_CLIENT_SET_MODE_NOT_SUPPORTED
-} CalClientSetModeStatus;
-
-/* Get status for the cal_client_get_object() function */
-typedef enum {
- CAL_CLIENT_GET_SUCCESS,
- CAL_CLIENT_GET_NOT_FOUND,
- CAL_CLIENT_GET_SYNTAX_ERROR
-} CalClientGetStatus;
-
-/* Status for update_object(s) and remove_object */
-typedef enum {
- CAL_CLIENT_RESULT_SUCCESS,
- CAL_CLIENT_RESULT_CORBA_ERROR,
- CAL_CLIENT_RESULT_INVALID_OBJECT,
- CAL_CLIENT_RESULT_NOT_FOUND,
- CAL_CLIENT_RESULT_PERMISSION_DENIED
-} CalClientResult;
-
-typedef enum {
- CAL_CLIENT_SEND_SUCCESS,
- CAL_CLIENT_SEND_CORBA_ERROR,
- CAL_CLIENT_SEND_INVALID_OBJECT,
- CAL_CLIENT_SEND_BUSY,
- CAL_CLIENT_SEND_PERMISSION_DENIED
-} CalClientSendResult;
-
-/* Whether the client is not loaded, is being loaded, or is already loaded */
-typedef enum {
- CAL_CLIENT_LOAD_NOT_LOADED,
- CAL_CLIENT_LOAD_LOADING,
- CAL_CLIENT_LOAD_LOADED
-} CalClientLoadState;
-
-struct _CalClient {
- GObject object;
-
- /* Private data */
- CalClientPrivate *priv;
-};
-
-struct _CalClientClass {
- GObjectClass parent_class;
-
- /* Notification signals */
-
- void (* cal_opened) (CalClient *client, CalClientOpenStatus status);
- void (* cal_set_mode) (CalClient *client, CalClientSetModeStatus status, CalMode mode);
-
- void (* obj_updated) (CalClient *client, const char *uid);
- void (* obj_removed) (CalClient *client, const char *uid);
-
- void (* backend_error) (CalClient *client, const char *message);
-
- void (* categories_changed) (CalClient *client, GPtrArray *categories);
-
- void (* forget_password) (CalClient *client, const char *key);
-
- void (* backend_died) (CalClient *client);
-};
-
-typedef gchar * (* CalClientAuthFunc) (CalClient *client,
- const gchar *prompt,
- const gchar *key,
- gpointer user_data);
-
-GType cal_client_get_type (void);
-
-GType cal_client_open_status_enum_get_type (void);
-GType cal_client_set_mode_status_enum_get_type (void);
-GType cal_mode_enum_get_type (void);
-
-CalClient *cal_client_construct (CalClient *client);
-
-CalClient *cal_client_new (void);
-
-void cal_client_set_auth_func (CalClient *client, CalClientAuthFunc func, gpointer data);
-
-/* Sets the default timezone to use to resolve DATE and floating DATE-TIME
- values. This will typically be from the user's timezone setting. Call this
- before using any other functions. It will pass the default timezone on to
- the server. Returns TRUE on success. */
-gboolean cal_client_set_default_timezone (CalClient *client, icaltimezone *zone);
-
-gboolean cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_if_exists);
-gboolean cal_client_open_default_calendar (CalClient *client, gboolean only_if_exists);
-gboolean cal_client_open_default_tasks (CalClient *client, gboolean only_if_exists);
-
-GList *cal_client_uri_list (CalClient *client, CalMode mode);
-
-CalClientLoadState cal_client_get_load_state (CalClient *client);
-
-const char *cal_client_get_uri (CalClient *client);
-
-gboolean cal_client_is_read_only (CalClient *client);
-
-const char *cal_client_get_cal_address (CalClient *client);
-const char *cal_client_get_alarm_email_address (CalClient *client);
-const char *cal_client_get_ldap_attribute (CalClient *client);
-
-gboolean cal_client_get_one_alarm_only (CalClient *client);
-gboolean cal_client_get_organizer_must_attend (CalClient *client);
-gboolean cal_client_get_save_schedules (CalClient *client);
-gboolean cal_client_get_static_capability (CalClient *client, const char *cap);
-
-gboolean cal_client_set_mode (CalClient *client, CalMode mode);
-
-int cal_client_get_n_objects (CalClient *client, CalObjType type);
-
-CalClientGetStatus cal_client_get_default_object (CalClient *client,
- CalObjType type,
- CalComponent **comp);
-
-CalClientGetStatus cal_client_get_object (CalClient *client,
- const char *uid,
- CalComponent **comp);
-
-CalClientGetStatus cal_client_get_timezone (CalClient *client,
- const char *tzid,
- icaltimezone **zone);
-
-GList *cal_client_get_uids (CalClient *client, CalObjType type);
-GList *cal_client_get_changes (CalClient *client, CalObjType type, const char *change_id);
-
-GList *cal_client_get_objects_in_range (CalClient *client, CalObjType type,
- time_t start, time_t end);
-
-GList *cal_client_get_free_busy (CalClient *client, GList *users,
- time_t start, time_t end);
-
-void cal_client_generate_instances (CalClient *client, CalObjType type,
- time_t start, time_t end,
- CalRecurInstanceFn cb, gpointer cb_data);
-
-GSList *cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end);
-
-void cal_client_free_alarms (GSList *comp_alarms);
-
-gboolean cal_client_get_alarms_for_object (CalClient *client, const char *uid,
- time_t start, time_t end,
- CalComponentAlarms **alarms);
-
-CalClientResult cal_client_discard_alarm (CalClient *client, CalComponent *comp, const char *auid);
-
-/* Add or update a single object. When adding an object only builtin timezones
- are allowed. To use external VTIMEZONE data call update_objects() instead.*/
-CalClientResult cal_client_update_object (CalClient *client, CalComponent *comp);
-CalClientResult cal_client_update_object_with_mod (CalClient *client, CalComponent *comp, CalObjModType mod);
-
-/* Add or update multiple objects, possibly including VTIMEZONE data. */
-CalClientResult cal_client_update_objects (CalClient *client, icalcomponent *icalcomp);
-
-CalClientResult cal_client_remove_object (CalClient *client, const char *uid);
-CalClientResult cal_client_remove_object_with_mod (CalClient *client, const char *uid, CalObjModType mod);
-
-CalClientSendResult cal_client_send_object (CalClient *client, icalcomponent *icalcomp,
- icalcomponent **new_icalcomp, GList **users,
- char error_msg[256]);
-
-CalQuery *cal_client_get_query (CalClient *client, const char *sexp);
-
-/* Resolves TZIDs for the recurrence generator. */
-icaltimezone *cal_client_resolve_tzid_cb (const char *tzid, gpointer data);
-
-/* Returns a complete VCALENDAR for a VEVENT/VTODO including all VTIMEZONEs
- used by the component. It also includes a 'METHOD:PUBLISH' property. */
-char* cal_client_get_component_as_string (CalClient *client,
- CalComponent *comp);
-
-
-
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c
deleted file mode 100644
index c7beef8c97..0000000000
--- a/calendar/cal-client/cal-listener.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/* Evolution calendar listener
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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 <config.h>
-#include "cal-listener.h"
-
-
-
-/* Private part of the CalListener structure */
-struct CalListenerPrivate {
- /* Notification functions and their closure data */
- CalListenerCalOpenedFn cal_opened_fn;
- CalListenerCalSetModeFn cal_set_mode_fn;
- CalListenerObjUpdatedFn obj_updated_fn;
- CalListenerObjRemovedFn obj_removed_fn;
- CalListenerErrorOccurredFn error_occurred_fn;
- CalListenerCategoriesChangedFn categories_changed_fn;
- gpointer fn_data;
-
- /* Whether notification is desired */
- gboolean notify : 1;
-};
-
-
-
-static void cal_listener_class_init (CalListenerClass *klass);
-static void cal_listener_init (CalListener *listener, CalListenerClass *klass);
-static void cal_listener_finalize (GObject *object);
-
-static void impl_notifyCalOpened (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_Listener_OpenStatus status,
- GNOME_Evolution_Calendar_Cal cal,
- CORBA_Environment *ev);
-static void impl_notifyCalSetMode (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_Listener_SetModeStatus status,
- GNOME_Evolution_Calendar_CalMode mode,
- CORBA_Environment *ev);
-static void impl_notifyObjUpdated (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev);
-static void impl_notifyObjRemoved (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev);
-static void impl_notifyErrorOccurred (PortableServer_Servant servant,
- const CORBA_char *message,
- CORBA_Environment *ev);
-static void impl_notifyCategoriesChanged (PortableServer_Servant servant,
- const GNOME_Evolution_Calendar_StringSeq *categories,
- CORBA_Environment *ev);
-
-static BonoboObjectClass *parent_class;
-
-
-
-BONOBO_TYPE_FUNC_FULL (CalListener,
- GNOME_Evolution_Calendar_Listener,
- BONOBO_TYPE_OBJECT,
- cal_listener);
-
-/* Class initialization function for the calendar listener */
-static void
-cal_listener_class_init (CalListenerClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = (GObjectClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- klass->epv.notifyCalOpened = impl_notifyCalOpened;
- klass->epv.notifyCalSetMode = impl_notifyCalSetMode;
- klass->epv.notifyObjUpdated = impl_notifyObjUpdated;
- klass->epv.notifyObjRemoved = impl_notifyObjRemoved;
- klass->epv.notifyErrorOccurred = impl_notifyErrorOccurred;
- klass->epv.notifyCategoriesChanged = impl_notifyCategoriesChanged;
-
- object_class->finalize = cal_listener_finalize;
-}
-
-/* Object initialization function for the calendar listener */
-static void
-cal_listener_init (CalListener *listener, CalListenerClass *klass)
-{
- CalListenerPrivate *priv;
-
- priv = g_new0 (CalListenerPrivate, 1);
- listener->priv = priv;
-
- priv->cal_opened_fn = NULL;
- priv->obj_updated_fn = NULL;
- priv->obj_removed_fn = NULL;
- priv->error_occurred_fn = NULL;
- priv->categories_changed_fn = NULL;
-
- priv->notify = TRUE;
-}
-
-/* Finalize handler for the calendar listener */
-static void
-cal_listener_finalize (GObject *object)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_LISTENER (object));
-
- listener = CAL_LISTENER (object);
- priv = listener->priv;
-
- priv->cal_opened_fn = NULL;
- priv->obj_updated_fn = NULL;
- priv->obj_removed_fn = NULL;
- priv->error_occurred_fn = NULL;
- priv->categories_changed_fn = NULL;
- priv->fn_data = NULL;
-
- priv->notify = FALSE;
-
- g_free (priv);
- listener->priv = NULL;
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-
-/* CORBA servant implementation */
-
-/* ::notifyCalOpened method */
-static void
-impl_notifyCalOpened (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_Listener_OpenStatus status,
- GNOME_Evolution_Calendar_Cal cal,
- CORBA_Environment *ev)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
- CORBA_Environment aev;
- GNOME_Evolution_Calendar_Cal cal_copy;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (!priv->notify)
- return;
-
- CORBA_exception_init (&aev);
- cal_copy = CORBA_Object_duplicate (cal, &aev);
-
- if (aev._major != CORBA_NO_EXCEPTION) {
- g_message ("Listener_notifyCalOpened(): could not duplicate the calendar");
- CORBA_exception_free (&aev);
- return;
- }
- CORBA_exception_free (&aev);
-
- g_assert (priv->cal_opened_fn != NULL);
- (* priv->cal_opened_fn) (listener, status, cal, priv->fn_data);
-}
-
-/* ::notifyCalSetMode method */
-static void
-impl_notifyCalSetMode (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_Listener_SetModeStatus status,
- GNOME_Evolution_Calendar_CalMode mode,
- CORBA_Environment *ev)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->cal_set_mode_fn != NULL);
- (* priv->cal_set_mode_fn) (listener, status, mode, priv->fn_data);
-}
-
-/* ::notifyObjUpdated method */
-static void
-impl_notifyObjUpdated (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->obj_updated_fn != NULL);
- (* priv->obj_updated_fn) (listener, uid, priv->fn_data);
-}
-
-/* ::notifyObjRemoved method */
-static void
-impl_notifyObjRemoved (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->obj_removed_fn != NULL);
- (* priv->obj_removed_fn) (listener, uid, priv->fn_data);
-}
-
-/* ::notifyErrorOccurred method */
-static void
-impl_notifyErrorOccurred (PortableServer_Servant servant,
- const CORBA_char *message,
- CORBA_Environment *ev)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->error_occurred_fn != NULL);
- (* priv->error_occurred_fn) (listener, message, priv->fn_data);
-}
-
-/* ::notifyCategoriesChanged method */
-static void
-impl_notifyCategoriesChanged (PortableServer_Servant servant,
- const GNOME_Evolution_Calendar_StringSeq *categories,
- CORBA_Environment *ev)
-{
- CalListener *listener;
- CalListenerPrivate *priv;
-
- listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- priv = listener->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->categories_changed_fn != NULL);
- (* priv->categories_changed_fn) (listener, categories, priv->fn_data);
-}
-
-
-
-/**
- * cal_listener_construct:
- * @listener: A calendar listener.
- * @cal_opened_fn: Function that will be called to notify that a calendar was
- * opened.
- * @obj_updated_fn: Function that will be called to notify that an object in the
- * calendar was updated.
- * @obj_removed_fn: Function that will be called to notify that an object in the
- * calendar was removed.
- * @error_occurred_fn: Function that will be called to notify errors.
- * @categories_changed_fn: Function that will be called to notify that the list
- * of categories that are present in the calendar's objects has changed.
- * @fn_data: Closure data pointer that will be passed to the notification
- * functions.
- *
- * Constructs a calendar listener by setting the callbacks that it will use for
- * notification from the calendar server.
- *
- * Return value: the same object as the @listener argument.
- **/
-CalListener *
-cal_listener_construct (CalListener *listener,
- CalListenerCalOpenedFn cal_opened_fn,
- CalListenerCalSetModeFn cal_set_mode_fn,
- CalListenerObjUpdatedFn obj_updated_fn,
- CalListenerObjRemovedFn obj_removed_fn,
- CalListenerErrorOccurredFn error_occurred_fn,
- CalListenerCategoriesChangedFn categories_changed_fn,
- gpointer fn_data)
-{
- CalListenerPrivate *priv;
-
- g_return_val_if_fail (listener != NULL, NULL);
- g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL);
- g_return_val_if_fail (cal_opened_fn != NULL, NULL);
- g_return_val_if_fail (cal_set_mode_fn != NULL, NULL);
- g_return_val_if_fail (obj_updated_fn != NULL, NULL);
- g_return_val_if_fail (obj_removed_fn != NULL, NULL);
- g_return_val_if_fail (error_occurred_fn != NULL, NULL);
- g_return_val_if_fail (categories_changed_fn != NULL, NULL);
-
- priv = listener->priv;
-
- priv->cal_opened_fn = cal_opened_fn;
- priv->cal_set_mode_fn = cal_set_mode_fn;
- priv->obj_updated_fn = obj_updated_fn;
- priv->obj_removed_fn = obj_removed_fn;
- priv->error_occurred_fn = error_occurred_fn;
- priv->categories_changed_fn = categories_changed_fn;
- priv->fn_data = fn_data;
-
- return listener;
-}
-
-/**
- * cal_listener_new:
- * @cal_opened_fn: Function that will be called to notify that a calendar was
- * opened.
- * @obj_updated_fn: Function that will be called to notify that an object in the
- * calendar was updated.
- * @obj_removed_fn: Function that will be called to notify that an object in the
- * calendar was removed.
- * @error_occurred_fn: Function that will be called to notify errors.
- * @categories_changed_fn: Function that will be called to notify that the list
- * of categories that are present in the calendar's objects has changed.
- * @fn_data: Closure data pointer that will be passed to the notification
- * functions.
- *
- * Creates a new #CalListener object.
- *
- * Return value: A newly-created #CalListener object.
- **/
-CalListener *
-cal_listener_new (CalListenerCalOpenedFn cal_opened_fn,
- CalListenerCalSetModeFn cal_set_mode_fn,
- CalListenerObjUpdatedFn obj_updated_fn,
- CalListenerObjRemovedFn obj_removed_fn,
- CalListenerErrorOccurredFn error_occurred_fn,
- CalListenerCategoriesChangedFn categories_changed_fn,
- gpointer fn_data)
-{
- CalListener *listener;
-
- g_return_val_if_fail (cal_opened_fn != NULL, NULL);
- g_return_val_if_fail (obj_updated_fn != NULL, NULL);
- g_return_val_if_fail (obj_removed_fn != NULL, NULL);
- g_return_val_if_fail (error_occurred_fn != NULL, NULL);
- g_return_val_if_fail (categories_changed_fn != NULL, NULL);
-
- listener = g_object_new (CAL_LISTENER_TYPE, NULL);
- return cal_listener_construct (listener,
- cal_opened_fn,
- cal_set_mode_fn,
- obj_updated_fn,
- obj_removed_fn,
- error_occurred_fn,
- categories_changed_fn,
- fn_data);
-}
-
-/**
- * cal_listener_stop_notification:
- * @listener: A calendar listener.
- *
- * Informs a calendar listener that no further notification is desired. The
- * callbacks specified when the listener was created will no longer be invoked
- * after this function is called.
- **/
-void
-cal_listener_stop_notification (CalListener *listener)
-{
- CalListenerPrivate *priv;
-
- g_return_if_fail (listener != NULL);
- g_return_if_fail (IS_CAL_LISTENER (listener));
-
- priv = listener->priv;
- g_return_if_fail (priv->notify != FALSE);
-
- priv->notify = FALSE;
-}
diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h
deleted file mode 100644
index d0f9a718a4..0000000000
--- a/calendar/cal-client/cal-listener.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Evolution calendar listener
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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_LISTENER_H
-#define CAL_LISTENER_H
-
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-
-G_BEGIN_DECLS
-
-
-
-#define CAL_LISTENER_TYPE (cal_listener_get_type ())
-#define CAL_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_LISTENER_TYPE, CalListener))
-#define CAL_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_LISTENER_TYPE, \
- CalListenerClass))
-#define IS_CAL_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_LISTENER_TYPE))
-#define IS_CAL_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_LISTENER_TYPE))
-
-typedef struct CalListenerPrivate CalListenerPrivate;
-
-typedef struct {
- BonoboObject xobject;
-
- /* Private data */
- CalListenerPrivate *priv;
-} CalListener;
-
-typedef struct {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Calendar_Listener__epv epv;
-} CalListenerClass;
-
-/* Notification functions */
-typedef void (* CalListenerCalOpenedFn) (CalListener *listener,
- GNOME_Evolution_Calendar_Listener_OpenStatus status,
- GNOME_Evolution_Calendar_Cal cal,
- gpointer data);
-
-typedef void (* CalListenerCalSetModeFn) (CalListener *listener,
- GNOME_Evolution_Calendar_Listener_SetModeStatus status,
- GNOME_Evolution_Calendar_CalMode mode,
- gpointer data);
-
-typedef void (* CalListenerObjUpdatedFn) (CalListener *listener,
- const CORBA_char *uid,
- gpointer data);
-typedef void (* CalListenerObjRemovedFn) (CalListener *listener,
- const CORBA_char *uid,
- gpointer data);
-
-typedef void (* CalListenerErrorOccurredFn) (CalListener *listener,
- const char *message,
- gpointer data);
-
-typedef void (* CalListenerCategoriesChangedFn) (CalListener *listener,
- const GNOME_Evolution_Calendar_StringSeq *categories,
- gpointer data);
-
-
-GType cal_listener_get_type (void);
-
-CalListener *cal_listener_construct (CalListener *listener,
- CalListenerCalOpenedFn cal_opened_fn,
- CalListenerCalSetModeFn cal_set_mode_fn,
- CalListenerObjUpdatedFn obj_updated_fn,
- CalListenerObjRemovedFn obj_removed_fn,
- CalListenerErrorOccurredFn error_occurred_fn,
- CalListenerCategoriesChangedFn categories_changed_fn,
- gpointer fn_data);
-
-CalListener *cal_listener_new (CalListenerCalOpenedFn cal_opened_fn,
- CalListenerCalSetModeFn cal_set_mode_fn,
- CalListenerObjUpdatedFn obj_updated_fn,
- CalListenerObjRemovedFn obj_removed_fn,
- CalListenerErrorOccurredFn error_occurred_fn,
- CalListenerCategoriesChangedFn categories_changed_fn,
- gpointer fn_data);
-
-void cal_listener_stop_notification (CalListener *listener);
-
-
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/cal-client/cal-query.c b/calendar/cal-client/cal-query.c
deleted file mode 100644
index 77b18af1ff..0000000000
--- a/calendar/cal-client/cal-query.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/* Evolution calendar - Live query client object
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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 <config.h>
-#endif
-
-#include <string.h>
-#include <bonobo/bonobo-exception.h>
-#include "cal-util/cal-util-marshal.h"
-#include "cal-query.h"
-#include "query-listener.h"
-
-
-
-/* Private part of the CalQuery structure */
-struct _CalQueryPrivate {
- /* Our query listener implementation */
- QueryListener *ql;
-
- /* Handle to the query in the server */
- GNOME_Evolution_Calendar_Query corba_query;
-};
-
-
-
-static void cal_query_class_init (CalQueryClass *klass);
-static void cal_query_init (CalQuery *query, CalQueryClass *klass);
-static void cal_query_finalize (GObject *object);
-
-/* Signal IDs */
-enum {
- OBJ_UPDATED,
- OBJ_REMOVED,
- QUERY_DONE,
- EVAL_ERROR,
- LAST_SIGNAL
-};
-
-static guint query_signals[LAST_SIGNAL];
-
-static GObjectClass *parent_class;
-
-
-
-/**
- * cal_query_get_type:
- *
- * Registers the #CalQuery class if necessary, and returns the type ID assigned
- * to it.
- *
- * Return value: The type ID of the #CalQuery class.
- **/
-GType
-cal_query_get_type (void)
-{
- static GType cal_query_type = 0;
-
- if (!cal_query_type) {
- static GTypeInfo info = {
- sizeof (CalQueryClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) cal_query_class_init,
- NULL, NULL,
- sizeof (CalQuery),
- 0,
- (GInstanceInitFunc) cal_query_init
- };
- cal_query_type = g_type_register_static (G_TYPE_OBJECT, "CalQuery", &info, 0);
- }
-
- return cal_query_type;
-}
-
-GType
-cal_query_done_status_enum_get_type (void)
-{
- static GType cal_query_done_status_enum_type = 0;
-
- if (!cal_query_done_status_enum_type) {
- static GEnumValue values [] = {
- { CAL_QUERY_DONE_SUCCESS, "CalQueryDoneSuccess", "success" },
- { CAL_QUERY_DONE_PARSE_ERROR, "CalQueryDoneParseError", "parse-error" },
- { -1, NULL, NULL }
- };
-
- cal_query_done_status_enum_type =
- g_enum_register_static ("CalQueryDoneStatusEnum", values);
- }
-
- return cal_query_done_status_enum_type;
-}
-
-/* Class initialization function for the calendar query */
-static void
-cal_query_class_init (CalQueryClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = (GObjectClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- query_signals[OBJ_UPDATED] =
- g_signal_new ("obj_updated",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalQueryClass, obj_updated),
- NULL, NULL,
- cal_util_marshal_VOID__STRING_BOOLEAN_INT_INT,
- G_TYPE_NONE, 4,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN,
- G_TYPE_INT,
- G_TYPE_INT);
- query_signals[OBJ_REMOVED] =
- g_signal_new ("obj_removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalQueryClass, obj_removed),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
- query_signals[QUERY_DONE] =
- g_signal_new ("query_done",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalQueryClass, query_done),
- NULL, NULL,
- cal_util_marshal_VOID__ENUM_STRING,
- G_TYPE_NONE, 2,
- CAL_QUERY_DONE_STATUS_ENUM_TYPE,
- G_TYPE_STRING);
- query_signals[EVAL_ERROR] =
- g_signal_new ("eval_error",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (CalQueryClass, eval_error),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1,
- G_TYPE_STRING);
-
- klass->obj_updated = NULL;
- klass->obj_removed = NULL;
- klass->query_done = NULL;
- klass->eval_error = NULL;
-
- object_class->finalize = cal_query_finalize;
-}
-
-/* Object initialization function for the calendar query */
-static void
-cal_query_init (CalQuery *query, CalQueryClass *klass)
-{
- CalQueryPrivate *priv;
-
- priv = g_new0 (CalQueryPrivate, 1);
- query->priv = priv;
-
- priv->ql = NULL;
- priv->corba_query = CORBA_OBJECT_NIL;
-}
-
-/* Finalize handler for the calendar query */
-static void
-cal_query_finalize (GObject *object)
-{
- CalQuery *query;
- CalQueryPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_CAL_QUERY (object));
-
- query = CAL_QUERY (object);
- priv = query->priv;
-
- /* The server keeps a copy of the query listener, so we must unref it */
- query_listener_stop_notification (priv->ql);
- bonobo_object_unref (BONOBO_OBJECT (priv->ql));
- priv->ql = NULL;
-
- if (priv->corba_query != CORBA_OBJECT_NIL) {
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (priv->corba_query, &ev);
-
- if (BONOBO_EX (&ev))
- g_message ("cal_query_destroy(): Could not release/unref the query");
-
- CORBA_exception_free (&ev);
- priv->corba_query = CORBA_OBJECT_NIL;
- }
-
- g_free (priv);
- query->priv = NULL;
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-
-/* Callback used when an object is updated in the query */
-static void
-obj_updated_cb (QueryListener *ql,
- const GNOME_Evolution_Calendar_CalObjUIDSeq *uids,
- CORBA_boolean query_in_progress,
- CORBA_long n_scanned,
- CORBA_long total,
- gpointer data)
-{
- CalQuery *query;
- int n;
-
- query = CAL_QUERY (data);
-
- for (n = 0; n < uids->_length; n++) {
- g_signal_emit (G_OBJECT (query), query_signals[OBJ_UPDATED], 0,
- uids->_buffer[n], query_in_progress,
- (int) n_scanned, (int) total);
- }
-}
-
-/* Callback used when an object is removed from the query */
-static void
-obj_removed_cb (QueryListener *ql,
- const CORBA_char *uid,
- gpointer data)
-{
- CalQuery *query;
-
- query = CAL_QUERY (data);
-
- g_signal_emit (G_OBJECT (query), query_signals[OBJ_REMOVED],
- 0, uid);
-}
-
-/* Callback used when the query terminates */
-static void
-query_done_cb (QueryListener *ql,
- GNOME_Evolution_Calendar_QueryListener_QueryDoneStatus corba_status,
- const CORBA_char *error_str,
- gpointer data)
-{
- CalQuery *query;
- CalQueryDoneStatus status;
-
- query = CAL_QUERY (data);
-
- switch (corba_status) {
- case GNOME_Evolution_Calendar_QueryListener_SUCCESS:
- status = CAL_QUERY_DONE_SUCCESS;
- break;
-
- case GNOME_Evolution_Calendar_QueryListener_PARSE_ERROR:
- status = CAL_QUERY_DONE_PARSE_ERROR;
- break;
-
- default:
- g_assert_not_reached ();
- return;
- }
-
- g_signal_emit (G_OBJECT (query), query_signals[QUERY_DONE], 0,
- status, error_str);
-}
-
-/* Callback used when an error occurs when evaluating the query */
-static void
-eval_error_cb (QueryListener *ql,
- const CORBA_char *error_str,
- gpointer data)
-{
- CalQuery *query;
-
- query = CAL_QUERY (data);
-
- g_signal_emit (G_OBJECT (query), query_signals[EVAL_ERROR], 0,
- error_str);
-}
-
-/**
- * cal_query_construct:
- * @query: A calendar query.
- * @cal: Handle to an open calendar.
- * @sexp: S-expression that defines the query.
- *
- * Constructs a query object by issuing the query creation request to the
- * calendar server.
- *
- * Return value: The same value as @query on success, or NULL if the request
- * failed.
- **/
-CalQuery *
-cal_query_construct (CalQuery *query,
- GNOME_Evolution_Calendar_Cal cal,
- const char *sexp)
-{
- CalQueryPrivate *priv;
- GNOME_Evolution_Calendar_QueryListener corba_ql;
- CORBA_Environment ev;
-
- g_return_val_if_fail (query != NULL, NULL);
- g_return_val_if_fail (IS_CAL_QUERY (query), NULL);
- g_return_val_if_fail (sexp != NULL, NULL);
-
- priv = query->priv;
-
- priv->ql = query_listener_new (obj_updated_cb,
- obj_removed_cb,
- query_done_cb,
- eval_error_cb,
- query);
- if (!priv->ql) {
- g_message ("cal_query_construct(): Could not create the query listener");
- return NULL;
- }
-
- corba_ql = BONOBO_OBJREF (priv->ql);
-
- CORBA_exception_init (&ev);
- priv->corba_query = GNOME_Evolution_Calendar_Cal_getQuery (cal, sexp, corba_ql, &ev);
-
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_CouldNotCreate)) {
- g_message ("cal_query_construct(): The server could not create the query");
- goto error;
- } else if (BONOBO_EX (&ev)) {
- g_message ("cal_query_construct(): Could not issue the getQuery() request");
- goto error;
- }
-
- CORBA_exception_free (&ev);
-
- return query;
-
- error:
-
- CORBA_exception_free (&ev);
-
- bonobo_object_unref (BONOBO_OBJECT (priv->ql));
- priv->ql = NULL;
- priv->corba_query = CORBA_OBJECT_NIL;
- return NULL;
-}
-
-/**
- * cal_query_new:
- * @cal: Handle to an open calendar.
- * @sexp: S-expression that defines the query.
- *
- * Creates a new query object by issuing the query creation request to the
- * calendar server.
- *
- * Return value: A newly-created query object, or NULL if the request failed.
- **/
-CalQuery *
-cal_query_new (GNOME_Evolution_Calendar_Cal cal,
- const char *sexp)
-{
- CalQuery *query;
-
- query = g_object_new (CAL_QUERY_TYPE, NULL);
-
- if (!cal_query_construct (query, cal, sexp)) {
- g_object_unref (G_OBJECT (query));
- return NULL;
- }
-
- return query;
-}
diff --git a/calendar/cal-client/cal-query.h b/calendar/cal-client/cal-query.h
deleted file mode 100644
index 9464e7ae6e..0000000000
--- a/calendar/cal-client/cal-query.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Evolution calendar - Live query client object
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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_QUERY_H
-#define CAL_QUERY_H
-
-#include <glib-object.h>
-
-#include "evolution-calendar.h"
-
-G_BEGIN_DECLS
-
-
-
-#define CAL_QUERY_TYPE (cal_query_get_type ())
-#define CAL_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_QUERY_TYPE, CalQuery))
-#define CAL_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_QUERY_TYPE, CalQueryClass))
-#define IS_CAL_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_QUERY_TYPE))
-#define IS_CAL_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_QUERY_TYPE))
-
-#define CAL_QUERY_DONE_STATUS_ENUM_TYPE (cal_query_done_status_enum_get_type ())
-
-/* Status values when a query terminates */
-typedef enum {
- CAL_QUERY_DONE_SUCCESS,
- CAL_QUERY_DONE_PARSE_ERROR
-} CalQueryDoneStatus;
-
-typedef struct _CalQueryPrivate CalQueryPrivate;
-
-typedef struct {
- GObject object;
-
- /* Private data */
- CalQueryPrivate *priv;
-} CalQuery;
-
-typedef struct {
- GObjectClass parent_class;
-
- /* Notification signals */
-
- void (* obj_updated) (CalQuery *query, const char *uid,
- gboolean query_in_progress, int n_scanned, int total);
- void (* obj_removed) (CalQuery *query, const char *uid);
-
- void (* query_done) (CalQuery *query, CalQueryDoneStatus status, const char *error_str);
-
- void (* eval_error) (CalQuery *query, const char *error_str);
-} CalQueryClass;
-
-GType cal_query_get_type (void);
-
-GType cal_query_done_status_enum_get_type (void);
-
-CalQuery *cal_query_construct (CalQuery *query,
- GNOME_Evolution_Calendar_Cal cal,
- const char *sexp);
-
-CalQuery *cal_query_new (GNOME_Evolution_Calendar_Cal cal,
- const char *sexp);
-
-
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/cal-client/client-test.c b/calendar/cal-client/client-test.c
deleted file mode 100644
index cb6eed17b2..0000000000
--- a/calendar/cal-client/client-test.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* Evolution calendar client - test program
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Copyright (C) 2000 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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 <config.h>
-#include <stdlib.h>
-#include <bonobo-activation/bonobo-activation.h>
-#include <bonobo/bonobo-i18n.h>
-#include <bonobo/bonobo-main.h>
-#include "cal-client.h"
-#include "cal-util/cal-component.h"
-
-static CalClient *client1;
-static CalClient *client2;
-
-/* Prints a message with a client identifier */
-static void
-cl_printf (CalClient *client, const char *format, ...)
-{
- va_list args;
-
- va_start (args, format);
- printf ("Client %s: ",
- client == client1 ? "1" :
- client == client2 ? "2" :
- "UNKNOWN");
- vprintf (format, args);
- va_end (args);
-}
-
-/* Dumps some interesting data from a component */
-static void
-dump_component (CalComponent *comp)
-{
- const char *uid;
- CalComponentText summary;
-
- cal_component_get_uid (comp, &uid);
-
- printf ("UID %s\n", uid);
-
- cal_component_get_summary (comp, &summary);
- if (summary.value)
- printf ("\tSummary: `%s', altrep `%s'\n",
- summary.value,
- summary.altrep ? summary.altrep : "NONE");
- else
- printf ("\tNo summary\n");
-}
-
-/* Lists the UIDs of objects in a calendar, called as an idle handler */
-static gboolean
-list_uids (gpointer data)
-{
- CalClient *client;
- GList *uids;
- GList *l;
-
- client = CAL_CLIENT (data);
-
- uids = cal_client_get_uids (client, CALOBJ_TYPE_ANY);
-
- cl_printf (client, "UIDs: ");
-
- if (!uids)
- printf ("none\n");
- else {
- for (l = uids; l; l = l->next) {
- char *uid;
-
- uid = l->data;
- printf ("`%s' ", uid);
- }
-
- printf ("\n");
-
- for (l = uids; l; l = l->next) {
- char *uid;
- CalComponent *comp;
- CalClientGetStatus status;
-
- uid = l->data;
- status = cal_client_get_object (client, uid, &comp);
-
- if (status == CAL_CLIENT_GET_SUCCESS) {
- printf ("------------------------------\n");
- dump_component (comp);
- printf ("------------------------------\n");
- g_object_unref (comp);
- } else {
- printf ("FAILED: %d\n", status);
- }
- }
- }
-
- cal_obj_uid_list_free (uids);
-
- g_object_unref (client);
-
- return FALSE;
-}
-
-/* Callback used when a calendar is opened */
-static void
-cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data)
-{
- cl_printf (client, "Load/create %s\n",
- ((status == CAL_CLIENT_OPEN_SUCCESS) ? "success" :
- (status == CAL_CLIENT_OPEN_ERROR) ? "error" :
- (status == CAL_CLIENT_OPEN_NOT_FOUND) ? "not found" :
- (status == CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED) ? "method not supported" :
- "unknown status value"));
-
- if (status == CAL_CLIENT_OPEN_SUCCESS) {
- GList *comp_list;
-
- /* get free/busy information */
- comp_list = cal_client_get_free_busy (client, NULL, 0, time (NULL));
- if (comp_list) {
- GList *l;
-
- for (l = comp_list; l; l = l->next) {
- char *comp_str;
-
- comp_str = cal_component_get_as_string (CAL_COMPONENT (l->data));
- g_object_unref (l->data);
- cl_printf (client, "Free/Busy -> %s\n", comp_str);
- g_free (comp_str);
- }
- g_list_free (comp_list);
- }
-
- g_idle_add (list_uids, client);
- }
- else
- g_object_unref (client);
-}
-
-/* Callback used when an object is updated */
-static void
-obj_updated_cb (CalClient *client, const char *uid, gpointer data)
-{
- cl_printf (client, "Object updated: %s\n", uid);
-}
-
-/* Callback used when a client is destroyed */
-static void
-client_destroy_cb (GObject *object, gpointer data)
-{
- if (CAL_CLIENT (object) == client1)
- client1 = NULL;
- else if (CAL_CLIENT (object) == client2)
- client2 = NULL;
- else
- g_assert_not_reached ();
-
- if (!client1 && !client2)
- bonobo_main_quit ();
-}
-
-/* Creates a calendar client and tries to load the specified URI into it */
-static void
-create_client (CalClient **client, const char *uri, gboolean only_if_exists)
-{
- gboolean result;
-
- *client = cal_client_new ();
- if (!*client) {
- g_message ("create_client(): could not create the client");
- exit (1);
- }
-
- g_signal_connect (*client, "destroy",
- G_CALLBACK (client_destroy_cb),
- NULL);
-
- g_signal_connect (*client, "cal_opened",
- G_CALLBACK (cal_opened_cb),
- NULL);
- g_signal_connect (*client, "obj_updated",
- G_CALLBACK (obj_updated_cb),
- NULL);
-
- printf ("Calendar loading `%s'...\n", uri);
-
- result = cal_client_open_calendar (*client, uri, only_if_exists);
-
- if (!result) {
- g_message ("create_client(): failure when issuing calendar open request `%s'",
- uri);
- exit (1);
- }
-}
-
-int
-main (int argc, char **argv)
-{
- char *dir;
-
- bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR);
- textdomain (GETTEXT_PACKAGE);
-
- g_type_init ();
- bonobo_activation_init (argc, argv);
-
- if (!bonobo_init (&argc, argv)) {
- g_message ("main(): could not initialize Bonobo");
- exit (1);
- }
-
- dir = g_strdup_printf ("%s/evolution/local/Calendar/calendar.ics", g_get_home_dir ());
- create_client (&client1, dir, FALSE);
- g_free (dir);
- create_client (&client2, "/cvs/evolution/calendar/cal-client/test.ics", TRUE);
-
- bonobo_main ();
- return 0;
-}
diff --git a/calendar/cal-client/query-listener.c b/calendar/cal-client/query-listener.c
deleted file mode 100644
index 6bd7bfc6f7..0000000000
--- a/calendar/cal-client/query-listener.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/* Evolution calendar - Live search query listener convenience object
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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 <config.h>
-#endif
-
-#include "query-listener.h"
-
-
-
-/* Private part of the QueryListener structure */
-
-struct _QueryListenerPrivate {
- /* Callbacks for notification and their closure data */
- QueryListenerObjUpdatedFn obj_updated_fn;
- QueryListenerObjRemovedFn obj_removed_fn;
- QueryListenerQueryDoneFn query_done_fn;
- QueryListenerEvalErrorFn eval_error_fn;
- gpointer fn_data;
-
- /* Whether notification is desired */
- gboolean notify : 1;
-};
-
-
-
-static void query_listener_class_init (QueryListenerClass *class);
-static void query_listener_init (QueryListener *ql, QueryListenerClass *class);
-static void query_listener_finalize (GObject *object);
-
-static void impl_notifyObjUpdated (PortableServer_Servant servant,
- const GNOME_Evolution_Calendar_CalObjUIDSeq *uids,
- CORBA_boolean query_in_progress,
- CORBA_long n_scanned,
- CORBA_long total,
- CORBA_Environment *ev);
-
-static void impl_notifyObjRemoved (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev);
-
-static void impl_notifyQueryDone (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_QueryListener_QueryDoneStatus corba_status,
- const CORBA_char *error_str,
- CORBA_Environment *ev);
-
-static void impl_notifyEvalError (PortableServer_Servant servant,
- const CORBA_char *error_str,
- CORBA_Environment *ev);
-
-static BonoboObjectClass *parent_class;
-
-
-
-BONOBO_TYPE_FUNC_FULL (QueryListener,
- GNOME_Evolution_Calendar_QueryListener,
- BONOBO_TYPE_OBJECT,
- query_listener);
-
-/* Class initialization function for the live search query listener */
-static void
-query_listener_class_init (QueryListenerClass *class)
-{
- GObjectClass *object_class;
-
- object_class = (GObjectClass *) class;
-
- parent_class = g_type_class_peek_parent (class);
-
- object_class->finalize = query_listener_finalize;
-
- class->epv.notifyObjUpdated = impl_notifyObjUpdated;
- class->epv.notifyObjRemoved = impl_notifyObjRemoved;
- class->epv.notifyQueryDone = impl_notifyQueryDone;
- class->epv.notifyEvalError = impl_notifyEvalError;
-}
-
-/* Object initialization function for the live search query listener */
-static void
-query_listener_init (QueryListener *ql, QueryListenerClass *class)
-{
- QueryListenerPrivate *priv;
-
- priv = g_new0 (QueryListenerPrivate, 1);
- ql->priv = priv;
-
- priv->obj_updated_fn = NULL;
- priv->obj_removed_fn = NULL;
- priv->query_done_fn = NULL;
- priv->eval_error_fn = NULL;
- priv->fn_data = NULL;
-
- priv->notify = TRUE;
-}
-
-/* Finalize handler for the live search query listener */
-static void
-query_listener_finalize (GObject *object)
-{
- QueryListener *ql;
- QueryListenerPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_QUERY_LISTENER (object));
-
- ql = QUERY_LISTENER (object);
- priv = ql->priv;
-
- priv->obj_updated_fn = NULL;
- priv->obj_removed_fn = NULL;
- priv->query_done_fn = NULL;
- priv->eval_error_fn = NULL;
- priv->fn_data = NULL;
-
- priv->notify = FALSE;
-
- g_free (priv);
- ql->priv = NULL;
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-
-/* CORBA method implementations */
-
-/* ::notifyObjUpdated() method */
-static void
-impl_notifyObjUpdated (PortableServer_Servant servant,
- const GNOME_Evolution_Calendar_CalObjUIDSeq *uids,
- CORBA_boolean query_in_progress,
- CORBA_long n_scanned,
- CORBA_long total,
- CORBA_Environment *ev)
-{
- QueryListener *ql;
- QueryListenerPrivate *priv;
-
- ql = QUERY_LISTENER (bonobo_object_from_servant (servant));
- priv = ql->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->obj_updated_fn != NULL);
- (* priv->obj_updated_fn) (ql, uids, query_in_progress, n_scanned, total, priv->fn_data);
-}
-
-/* ::notifyObjRemoved() method */
-static void
-impl_notifyObjRemoved (PortableServer_Servant servant,
- const CORBA_char *uid,
- CORBA_Environment *ev)
-{
- QueryListener *ql;
- QueryListenerPrivate *priv;
-
- ql = QUERY_LISTENER (bonobo_object_from_servant (servant));
- priv = ql->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->obj_removed_fn != NULL);
- (* priv->obj_removed_fn) (ql, uid, priv->fn_data);
-}
-
-/* ::notifyQueryDone() method */
-static void
-impl_notifyQueryDone (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_QueryListener_QueryDoneStatus corba_status,
- const CORBA_char *error_str,
- CORBA_Environment *ev)
-{
- QueryListener *ql;
- QueryListenerPrivate *priv;
-
- ql = QUERY_LISTENER (bonobo_object_from_servant (servant));
- priv = ql->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->query_done_fn != NULL);
- (* priv->query_done_fn) (ql, corba_status, error_str, priv->fn_data);
-}
-
-/* ::notifyEvalError() method */
-static void
-impl_notifyEvalError (PortableServer_Servant servant,
- const CORBA_char *error_str,
- CORBA_Environment *ev)
-{
- QueryListener *ql;
- QueryListenerPrivate *priv;
-
- ql = QUERY_LISTENER (bonobo_object_from_servant (servant));
- priv = ql->priv;
-
- if (!priv->notify)
- return;
-
- g_assert (priv->eval_error_fn != NULL);
- (* priv->eval_error_fn) (ql, error_str, priv->fn_data);
-}
-
-
-
-/**
- * query_listener_construct:
- * @ql: A query listener.
- * @obj_updated_fn: Callback to use when a component is updated in the query.
- * @obj_removed_fn: Callback to use when a component is removed from the query.
- * @query_done_fn: Callback to use when a query is done.
- * @eval_error_fn: Callback to use when an evaluation error happens during a query.
- * @fn_data: Closure data to pass to the callbacks.
- *
- * Constructs a query listener by setting the callbacks it will use for
- * notification from the calendar server.
- *
- * Return value: The same value as @ql.
- **/
-QueryListener *
-query_listener_construct (QueryListener *ql,
- QueryListenerObjUpdatedFn obj_updated_fn,
- QueryListenerObjRemovedFn obj_removed_fn,
- QueryListenerQueryDoneFn query_done_fn,
- QueryListenerEvalErrorFn eval_error_fn,
- gpointer fn_data)
-{
- QueryListenerPrivate *priv;
-
- g_return_val_if_fail (ql != NULL, NULL);
- g_return_val_if_fail (IS_QUERY_LISTENER (ql), NULL);
- g_return_val_if_fail (obj_updated_fn != NULL, NULL);
- g_return_val_if_fail (obj_removed_fn != NULL, NULL);
- g_return_val_if_fail (query_done_fn != NULL, NULL);
- g_return_val_if_fail (eval_error_fn != NULL, NULL);
-
- priv = ql->priv;
-
- priv->obj_updated_fn = obj_updated_fn;
- priv->obj_removed_fn = obj_removed_fn;
- priv->query_done_fn = query_done_fn;
- priv->eval_error_fn = eval_error_fn;
- priv->fn_data = fn_data;
-
- return ql;
-}
-
-/**
- * query_listener_new:
- * @obj_updated_fn: Callback to use when a component is updated in the query.
- * @obj_removed_fn: Callback to use when a component is removed from the query.
- * @query_done_fn: Callback to use when a query is done.
- * @eval_error_fn: Callback to use when an evaluation error happens during a query.
- * @fn_data: Closure data to pass to the callbacks.
- *
- * Creates a new query listener object.
- *
- * Return value: A newly-created query listener object.
- **/
-QueryListener *
-query_listener_new (QueryListenerObjUpdatedFn obj_updated_fn,
- QueryListenerObjRemovedFn obj_removed_fn,
- QueryListenerQueryDoneFn query_done_fn,
- QueryListenerEvalErrorFn eval_error_fn,
- gpointer fn_data)
-{
- QueryListener *ql;
-
- ql = g_object_new (QUERY_LISTENER_TYPE, NULL);
-
- return query_listener_construct (ql,
- obj_updated_fn,
- obj_removed_fn,
- query_done_fn,
- eval_error_fn,
- fn_data);
-}
-
-/**
- * query_listener_stop_notification:
- * @ql: A query listener.
- *
- * Informs a query listener that no further notification is desired. The
- * callbacks specified when the listener was created will no longer be invoked
- * after this function is called.
- **/
-void
-query_listener_stop_notification (QueryListener *ql)
-{
- QueryListenerPrivate *priv;
-
- g_return_if_fail (ql != NULL);
- g_return_if_fail (IS_QUERY_LISTENER (ql));
-
- priv = ql->priv;
- g_return_if_fail (priv->notify != FALSE);
-
- priv->notify = FALSE;
-}
diff --git a/calendar/cal-client/query-listener.h b/calendar/cal-client/query-listener.h
deleted file mode 100644
index eeb42afc7e..0000000000
--- a/calendar/cal-client/query-listener.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Evolution calendar - Live search query listener implementation
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Author: Federico Mena-Quintero <federico@ximian.com>
- *
- * 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_LISTENER_H
-#define QUERY_LISTENER_H
-
-#include <bonobo/bonobo-object.h>
-#include "evolution-calendar.h"
-
-G_BEGIN_DECLS
-
-
-
-#define QUERY_LISTENER_TYPE (query_listener_get_type ())
-#define QUERY_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QUERY_LISTENER_TYPE, QueryListener))
-#define QUERY_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QUERY_LISTENER_TYPE, \
- QueryListenerClass))
-#define IS_QUERY_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QUERY_LISTENER_TYPE))
-#define IS_QUERY_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QUERY_LISTENER_TYPE))
-
-typedef struct _QueryListenerPrivate QueryListenerPrivate;
-
-typedef struct {
- BonoboObject xobject;
-
- /* Private data */
- QueryListenerPrivate *priv;
-} QueryListener;
-
-typedef struct {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Calendar_QueryListener__epv epv;
-} QueryListenerClass;
-
-/* Notification functions */
-
-typedef void (* QueryListenerObjUpdatedFn) (QueryListener *ql,
- const GNOME_Evolution_Calendar_CalObjUIDSeq *uids,
- CORBA_boolean query_in_progress,
- CORBA_long n_scanned,
- CORBA_long total,
- gpointer data);
-
-typedef void (* QueryListenerObjRemovedFn) (QueryListener *ql,
- const CORBA_char *uid,
- gpointer data);
-
-typedef void (* QueryListenerQueryDoneFn) (
- QueryListener *ql,
- GNOME_Evolution_Calendar_QueryListener_QueryDoneStatus status,
- const CORBA_char *error_str,
- gpointer data);
-
-typedef void (* QueryListenerEvalErrorFn) (QueryListener *ql,
- const CORBA_char *error_str,
- gpointer data);
-
-GType query_listener_get_type (void);
-
-QueryListener *query_listener_construct (QueryListener *ql,
- QueryListenerObjUpdatedFn obj_updated_fn,
- QueryListenerObjRemovedFn obj_removed_fn,
- QueryListenerQueryDoneFn query_done_fn,
- QueryListenerEvalErrorFn eval_error_fn,
- gpointer fn_data);
-
-QueryListener *query_listener_new (QueryListenerObjUpdatedFn obj_updated_fn,
- QueryListenerObjRemovedFn obj_removed_fn,
- QueryListenerQueryDoneFn query_done_fn,
- QueryListenerEvalErrorFn eval_error_fn,
- gpointer fn_data);
-
-void query_listener_stop_notification (QueryListener *ql);
-
-
-
-G_END_DECLS
-
-#endif
diff --git a/calendar/cal-client/test.ics b/calendar/cal-client/test.ics
deleted file mode 100644
index 128251ee11..0000000000
--- a/calendar/cal-client/test.ics
+++ /dev/null
@@ -1,318 +0,0 @@
-BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//hacksw/handcal//NONSGML v1.0//EN
-
-BEGIN:VEVENT
-DTSTART:19970714T170000Z
-DTEND:19970715T035959Z
-SUMMARY:Bastille Day Party
-END:VEVENT
-
-BEGIN:VEVENT
-UID:19970901T130000Z-123401@host.com
-DTSTAMP:19970901T1300Z
-DTSTART:19970903T163000Z
-DTEND:19970903T190000Z
-SUMMARY:Annual Employee Review
-CLASS:PRIVATE
-CATEGORIES:BUSINESS,HUMAN RESOURCES
-END:VEVENT
-
-BEGIN:VEVENT
-UID:19970901T130000Z-123402@host.com
-DTSTAMP:19970901T1300Z
-DTSTART:19970401T163000Z
-DTEND:19970402T010000Z
-SUMMARY:Laurel is in sensitivity awareness class.
-CLASS:PUBLIC
-CATEGORIES:BUSINESS,HUMAN RESOURCES
-TRANSP:TRANSPARENT
-END:VEVENT
-
-BEGIN:VEVENT
-UID:19970901T130000Z-123403@host.com
-DTSTAMP:19970901T1300Z
-DTSTART:19971102
-SUMMARY:Our Blissful Anniversary
-CLASS:CONFIDENTIAL
-CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION
-RRULE:FREQ=YEARLY
-END:VEVENT
-
-BEGIN:VTODO
-UID:19970901T130000Z-123404@host.com
-DTSTAMP:19970901T1300Z
-DTSTART:19970415T133000Z
-DUE:19970416T045959Z
-SUMMARY:1996 Income Tax Preparation
-CLASS:CONFIDENTIAL
-CATEGORIES:FAMILY,FINANCE
-PRIORITY:1
-STATUS:NEEDS-ACTION
-END:VTODO
-
-BEGIN:VJOURNAL
-UID:19970901T130000Z-123405@host.com
-DTSTAMP:19970901T1300Z
-DTSTART;VALUE=DATE:19970317
-SUMMARY:Staff meeting minutes
-DESCRIPTION:1. Staff meeting: Participants include Joe\, Lisa
- and Bob. Aurora project plans were reviewed. There is currently
- no budget reserves for this project. Lisa will escalate to
- management. Next meeting on Tuesday.\n
- 2. Telephone Conference: ABC Corp. sales representative called
- to discuss new printer. Promised to get us a demo by Friday.\n
- 3. Henry Miller (Handsoff Insurance): Car was totaled by tree.
- Is looking into a loaner car. 654-2323 (tel).
-END:VJOURNAL
-
-BEGIN:VFREEBUSY
-ORGANIZER:MAILTO:jane_doe@host1.com
-ATTENDEE:MAILTO:john_public@host2.com
-DTSTART:19971015T050000Z
-DTEND:19971016T050000Z
-DTSTAMP:19970901T083000Z
-END:VFREEBUSY
-
-BEGIN:VFREEBUSY
-ORGANIZER:MAILTO:jane_doe@host1.com
-ATTENDEE:MAILTO:john_public@host2.com
-DTSTAMP:19970901T100000Z
-FREEBUSY;VALUE=PERIOD:19971015T050000Z/PT8H30M,
- 19971015T160000Z/PT5H30M,19971015T223000Z/PT6H30M
-URL:http://host2.com/pub/busy/jpublic-01.ifb
-COMMENT:This iCalendar file contains busy time information for
- the next three months.
-END:VFREEBUSY
-
-BEGIN:VFREEBUSY
-ORGANIZER:jsmith@host.com
-DTSTART:19980313T141711Z
-DTEND:19980410T141711Z
-FREEBUSY:19980314T233000Z/19980315T003000Z
-FREEBUSY:19980316T153000Z/19980316T163000Z
-FREEBUSY:19980318T030000Z/19980318T040000Z
-URL:http://www.host.com/calendar/busytime/jsmith.ifb
-END:VFREEBUSY
-
-BEGIN:VTIMEZONE
-TZID:US-Eastern
-LAST-MODIFIED:19870101T000000Z
-BEGIN:STANDARD
-DTSTART:19971026T020000
-RDATE:19971026T020000
-TZOFFSETFROM:-0400
-TZOFFSETTO:-0500
-TZNAME:EST
-END:STANDARD
-BEGIN:DAYLIGHT
-DTSTART:19971026T020000
-RDATE:19970406T020000
-TZOFFSETFROM:-0500
-TZOFFSETTO:-0400
-TZNAME:EDT
-END:DAYLIGHT
-END:VTIMEZONE
-
-BEGIN:VTIMEZONE
-TZID:US-Eastern
-LAST-MODIFIED:19870101T000000Z
-TZURL:http://zones.stds_r_us.net/tz/US-Eastern
-BEGIN:STANDARD
-DTSTART:19671029T020000
-RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
-TZOFFSETFROM:-0400
-TZOFFSETTO:-0500
-TZNAME:EST
-END:STANDARD
-BEGIN:DAYLIGHT
-DTSTART:19870405T020000
-RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
-TZOFFSETFROM:-0500
-TZOFFSETTO:-0400
-TZNAME:EDT
-END:DAYLIGHT
-END:VTIMEZONE
-
-BEGIN:VTIMEZONE
-TZID:US--Fictitious-Eastern
-LAST-MODIFIED:19870101T000000Z
-BEGIN:STANDARD
-DTSTART:19671029T020000
-RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
-TZOFFSETFROM:-0400
-TZOFFSETTO:-0500
-TZNAME:EST
-END:STANDARD
-BEGIN:DAYLIGHT
-DTSTART:19870405T020000
-RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4;UNTIL=19980404T070000Z
-TZOFFSETFROM:-0500
-TZOFFSETTO:-0400
-TZNAME:EDT
-END:DAYLIGHT
-END:VTIMEZONE
-
-BEGIN:VTIMEZONE
-TZID:US--Fictitious-Eastern
-LAST-MODIFIED:19870101T000000Z
-BEGIN:STANDARD
-DTSTART:19671029T020000
-RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
-TZOFFSETFROM:-0400
-TZOFFSETTO:-0500
-TZNAME:EST
-END:STANDARD
-BEGIN:DAYLIGHT
-DTSTART:19870405T020000
-RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4;UNTIL=19980404T070000Z
-TZOFFSETFROM:-0500
-TZOFFSETTO:-0400
-TZNAME:EDT
-END:DAYLIGHT
-BEGIN:DAYLIGHT
-DTSTART:19990424T020000
-RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=4
-TZOFFSETFROM:-0500
-TZOFFSETTO:-0400
-TZNAME:EDT
-END:DAYLIGHT
-END:VTIMEZONE
-
-BEGIN:VALARM
-TRIGGER;VALUE=DATE-TIME:19970317T133000Z
-REPEAT:4
-DURATION:PT15M
-ACTION:AUDIO
-ATTACH;FMTTYPE=audio/basic:ftp://host.com/pub/sounds/bell-01.aud
-END:VALARM
-BEGIN:VALARM
-TRIGGER:-PT30M
-REPEAT:2
-DURATION:PT15M
-ACTION:DISPLAY
-DESCRIPTION:Breakfast meeting with executive\n
- team at 8:30 AM EST.
-END:VALARM
-
-BEGIN:VALARM
-TRIGGER:-P2D
-ACTION:EMAIL
-ATTENDEE:MAILTO:john_doe@host.com
-SUMMARY:*** REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING ***
-DESCRIPTION:A draft agenda needs to be sent out to the attendees
- to the weekly managers meeting (MGR-LIST). Attached is a
- pointer the document template for the agenda file.
-ATTACH;FMTTYPE=application/binary:http://host.com/templates/agen
- da.doc
-END:VALARM
-
-BEGIN:VALARM
-TRIGGER;VALUE=DATE-TIME:19980101T050000Z
-REPEAT:23
-DURATION:PT1H
-ACTION:PROCEDURE
-ATTACH;FMTTYPE=application/binary:ftp://host.com/novo-
- procs/felizano.exe
-END:VALARM
-
-BEGIN:VTIMEZONE
-TZID:US-Eastern
-BEGIN:STANDARD
-DTSTART:19981025T020000
-RDATE:19981025T020000
-TZOFFSETFROM:-0400
-TZOFFSETTO:-0500
-TZNAME:EST
-END:STANDARD
-BEGIN:DAYLIGHT
-DTSTART:19990404T020000
-RDATE:19990404T020000
-TZOFFSETFROM:-0500
-TZOFFSETTO:-0400
-TZNAME:EDT
-END:DAYLIGHT
-END:VTIMEZONE
-
-BEGIN:VEVENT
-DTSTAMP:19980309T231000Z
-UID:guid-1.host1.com
-ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com
-ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:
- MAILTO:employee-A@host.com
-DESCRIPTION:Project XYZ Review Meeting
-CATEGORIES:MEETING
-CLASS:PUBLIC
-CREATED:19980309T130000Z
-SUMMARY:XYZ Project Review
-DTSTART;TZID=US-Eastern:19980312T083000
-DTEND;TZID=US-Eastern:19980312T093000
-LOCATION:1CP Conference Room 4350
-END:VEVENT
-
-BEGIN:VEVENT
-DTSTAMP:19970324T1200Z
-SEQUENCE:0
-UID:uid3@host1.com
-ORGANIZER:MAILTO:jdoe@host1.com
-DTSTART:19970324T123000Z
-DTEND:19970324T210000Z
-CATEGORIES:MEETING,PROJECT
-CLASS:PUBLIC
-SUMMARY:Calendaring Interoperability Planning Meeting
-DESCRIPTION:Discuss how we can test c&s interoperability\n
- using iCalendar and other IETF standards.
-LOCATION:LDB Lobby
-ATTACH;FMTTYPE=application/postscript:ftp://xyzCorp.com/pub/
- conf/bkgrnd.ps
-END:VEVENT
-
-BEGIN:VTODO
-DTSTAMP:19980130T134500Z
-SEQUENCE:2
-UID:uid4@host1.com
-ORGANIZER:MAILTO:unclesam@us.gov
-ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:jqpublic@host.com
-DUE:19980415T235959
-STATUS:NEEDS-ACTION
-SUMMARY:Submit Income Taxes
-BEGIN:VALARM
-ACTION:AUDIO
-TRIGGER:19980403T120000
-ATTACH;FMTTYPE=audio/basic:http://host.com/pub/audio-
- files/ssbanner.aud
-REPEAT:4
-DURATION:PT1H
-END:VALARM
-END:VTODO
-
-BEGIN:VJOURNAL
-DTSTAMP:19970324T120000Z
-UID:uid5@host1.com
-ORGANIZER:MAILTO:jsmith@host.com
-STATUS:DRAFT
-CLASS:PUBLIC
-CATEGORIES:Project Report, XYZ, Weekly Meeting
-DESCRIPTION:Project xyz Review Meeting Minutes\n
- Agenda\n1. Review of project version 1.0 requirements.\n2.
- Definition
- of project processes.\n3. Review of project schedule.\n
- Participants: John Smith\, Jane Doe\, Jim Dandy\n-It was
- decided that the requirements need to be signed off by
- product marketing.\n-Project processes were accepted.\n
- -Project schedule needs to account for scheduled holidays
- and employee vacation time. Check with HR for specific
- dates.\n-New schedule will be distributed by Friday.\n-
- Next weeks meeting is cancelled. No meeting until 3/23.
-END:VJOURNAL
-
-BEGIN:VFREEBUSY
-ORGANIZER:MAILTO:jsmith@host.com
-DTSTART:19980313T141711Z
-DTEND:19980410T141711Z
-FREEBUSY:19980314T233000Z/19980315T003000Z
-FREEBUSY:19980316T153000Z/19980316T163000Z
-FREEBUSY:19980318T030000Z/19980318T040000Z
-URL:http://www.host.com/calendar/busytime/jsmith.ifb
-END:VFREEBUSY
-END:VCALENDAR