aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-04-03 13:35:48 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-04-03 13:35:48 +0800
commit7a4bd61930f826ceabf144bf1d4ca06592565e90 (patch)
treee05e3a2e25f54c8b7015c33311b121131ffb7777 /calendar
parent44882da7a7193185f7b593ac3799758c5065f6e4 (diff)
downloadgsoc2013-evolution-7a4bd61930f826ceabf144bf1d4ca06592565e90.tar.gz
gsoc2013-evolution-7a4bd61930f826ceabf144bf1d4ca06592565e90.tar.zst
gsoc2013-evolution-7a4bd61930f826ceabf144bf1d4ca06592565e90.zip
Plug leak.
2001-04-02 Federico Mena Quintero <federico@ximian.com> * gui/e-tasks.c (e_tasks_setup_menus): Plug leak. * gui/event-editor.c (obj_updated_cb): Do nothing for now until we think of something sensible to do. (obj_removed_cb): Likewise. * gui/dialogs/task-editor.c (obj_updated_cb): Likewise. (obj_removed_cb): Likewise. * gui/event-editor.c (dialog_to_comp_object): Plug leak. svn path=/trunk/; revision=9124
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog9
-rw-r--r--calendar/cal-client/Makefile.am20
-rw-r--r--calendar/cal-client/cal-client.c36
-rw-r--r--calendar/cal-client/cal-client.h6
-rw-r--r--calendar/cal-client/cal-listener.c1
-rw-r--r--calendar/cal-client/cal-listener.h8
-rw-r--r--calendar/cal-client/cal-query.c406
-rw-r--r--calendar/cal-client/cal-query.h81
-rw-r--r--calendar/cal-client/query-listener.c281
-rw-r--r--calendar/cal-client/query-listener.h96
-rw-r--r--calendar/gui/dialogs/task-editor.c8
-rw-r--r--calendar/gui/e-tasks.c7
-rw-r--r--calendar/gui/event-editor.c8
13 files changed, 942 insertions, 25 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 1e3d917b65..92905c93c4 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,14 @@
2001-04-02 Federico Mena Quintero <federico@ximian.com>
+ * gui/e-tasks.c (e_tasks_setup_menus): Plug leak.
+
+ * gui/event-editor.c (obj_updated_cb): Do nothing for now until we
+ think of something sensible to do.
+ (obj_removed_cb): Likewise.
+
+ * gui/dialogs/task-editor.c (obj_updated_cb): Likewise.
+ (obj_removed_cb): Likewise.
+
* gui/event-editor.c (dialog_to_comp_object): Plug leak.
2001-04-01 Federico Mena Quintero <federico@ximian.com>
diff --git a/calendar/cal-client/Makefile.am b/calendar/cal-client/Makefile.am
index f241bf6ce1..28949c8721 100644
--- a/calendar/cal-client/Makefile.am
+++ b/calendar/cal-client/Makefile.am
@@ -3,11 +3,13 @@
#
CORBA_GENERATED = \
- evolution-calendar.h \
evolution-calendar-common.c \
evolution-calendar-skels.c \
evolution-calendar-stubs.c
+CORBA_HEADERS_GENERATED = \
+ evolution-calendar.h
+
idls = \
$(srcdir)/../idl/evolution-calendar.idl
@@ -37,12 +39,16 @@ libcal_client_la_SOURCES = \
cal-client-types.c \
cal-client.c \
cal-listener.c \
- cal-listener.h
-
-libcal_clientinclude_HEADERS = \
- cal-client-types.h \
- cal-client.h
-
+ cal-listener.h \
+ cal-query.c \
+ query-listener.c \
+ query-listener.h
+
+libcal_clientinclude_HEADERS = \
+ $(CORBA_HEADERS_GENERATED) \
+ cal-client-types.h \
+ cal-client.h \
+ cal-query.h
#
# make a static library for use by calendar conduit's shared library
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index e81ff9afa3..cd8c8713d6 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -1,8 +1,6 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Evolution calendar client
*
- * Copyright (C) 2000 Helix Code, Inc.
- * Copyright (C) 2000 Ximian, Inc.
+ * Copyright (C) 2001 Ximian, Inc.
*
* Author: Federico Mena-Quintero <federico@ximian.com>
*
@@ -21,7 +19,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <gtk/gtksignal.h>
#include <liboaf/liboaf.h>
@@ -44,7 +45,7 @@ struct _CalClientPrivate {
/* The calendar factory we are contacting */
GNOME_Evolution_Calendar_CalFactory factory;
- /* Our calendar listener */
+ /* Our calendar listener implementation */
CalListener *listener;
/* The calendar client interface object we are contacting */
@@ -73,7 +74,6 @@ static GtkObjectClass *parent_class;
/**
* cal_client_get_type:
- * @void:
*
* Registers the #CalClient class if necessary, and returns the type ID assigned
* to it.
@@ -1505,3 +1505,29 @@ cal_client_remove_object (CalClient *client, const char *uid)
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);
+}
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index 9e17b22b2b..1f0211ef32 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -1,7 +1,6 @@
/* Evolution calendar client
*
- * Copyright (C) 2000 Helix Code, Inc.
- * Copyright (C) 2000 Ximian, Inc.
+ * Copyright (C) 2001 Ximian, Inc.
*
* Author: Federico Mena-Quintero <federico@ximian.com>
*
@@ -27,6 +26,7 @@
#include <gtk/gtkobject.h>
#include <cal-util/cal-recur.h>
#include <cal-util/cal-util.h>
+#include <cal-client/cal-query.h>
BEGIN_GNOME_DECLS
@@ -124,6 +124,8 @@ gboolean cal_client_update_object (CalClient *client, CalComponent *comp);
gboolean cal_client_remove_object (CalClient *client, const char *uid);
+CalQuery *cal_client_get_query (CalClient *client, const char *sexp);
+
END_GNOME_DECLS
diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c
index b5c3bdbd6b..32da6136f7 100644
--- a/calendar/cal-client/cal-listener.c
+++ b/calendar/cal-client/cal-listener.c
@@ -21,7 +21,6 @@
*/
#include <config.h>
-#include <gtk/gtksignal.h>
#include "cal-listener.h"
diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h
index 612d1d889f..7997cbb69c 100644
--- a/calendar/cal-client/cal-listener.h
+++ b/calendar/cal-client/cal-listener.h
@@ -52,14 +52,6 @@ struct _CalListener {
struct _CalListenerClass {
BonoboObjectClass parent_class;
-
- /* Notification signals */
-
- void (* cal_opened) (CalListener *listener,
- GNOME_Evolution_Calendar_Listener_OpenStatus status,
- GNOME_Evolution_Calendar_Cal cal);
- void (* obj_updated) (CalListener *listener, const GNOME_Evolution_Calendar_CalObjUID uid);
- void (* obj_removed) (CalListener *listener, const GNOME_Evolution_Calendar_CalObjUID uid);
};
/* Notification functions */
diff --git a/calendar/cal-client/cal-query.c b/calendar/cal-client/cal-query.c
new file mode 100644
index 0000000000..1a3fd241f9
--- /dev/null
+++ b/calendar/cal-client/cal-query.c
@@ -0,0 +1,406 @@
+/* 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 the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtksignal.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 *class);
+static void cal_query_init (CalQuery *query);
+static void cal_query_destroy (GtkObject *object);
+
+/* Signal IDs */
+enum {
+ OBJ_UPDATED,
+ OBJ_REMOVED,
+ QUERY_DONE,
+ EVAL_ERROR,
+ LAST_SIGNAL
+};
+
+static void marshal_obj_updated (GtkObject *object,
+ GtkSignalFunc func, gpointer func_data,
+ GtkArg *args);
+static void marshal_query_done (GtkObject *object,
+ GtkSignalFunc func, gpointer func_data,
+ GtkArg *args);
+
+static guint query_signals[LAST_SIGNAL];
+
+static GtkObjectClass *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.
+ **/
+GtkType
+cal_query_get_type (void)
+{
+ static GtkType cal_query_type = 0;
+
+ if (!cal_query_type) {
+ static const GtkTypeInfo cal_query_info = {
+ "CalQuery",
+ sizeof (CalQuery),
+ sizeof (CalQueryClass),
+ (GtkClassInitFunc) cal_query_class_init,
+ (GtkObjectInitFunc) cal_query_init,
+ NULL, /* reserved_1 */
+ NULL, /* reserved_2 */
+ (GtkClassInitFunc) NULL
+ };
+
+ cal_query_type = gtk_type_unique (GTK_TYPE_OBJECT, &cal_query_info);
+ }
+
+ return cal_query_type;
+}
+
+/* Class initialization function for the calendar query */
+static void
+cal_query_class_init (CalQueryClass *class)
+{
+ GtkObjectClass *object_class;
+
+ object_class = (GtkObjectClass *) class;
+
+ parent_class = gtk_type_class (GTK_TYPE_OBJECT);
+
+ query_signals[OBJ_UPDATED] =
+ gtk_signal_new ("obj_updated",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (CalQueryClass, obj_updated),
+ marshal_obj_updated,
+ GTK_TYPE_NONE, 4,
+ GTK_TYPE_STRING,
+ GTK_TYPE_BOOL,
+ GTK_TYPE_INT,
+ GTK_TYPE_INT);
+ query_signals[OBJ_REMOVED] =
+ gtk_signal_new ("obj_removed",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (CalQueryClass, obj_removed),
+ gtk_marshal_NONE__STRING,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_STRING);
+ query_signals[QUERY_DONE] =
+ gtk_signal_new ("query_done",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (CalQueryClass, query_done),
+ marshal_query_done,
+ GTK_TYPE_NONE, 2,
+ GTK_TYPE_ENUM,
+ GTK_TYPE_STRING);
+ query_signals[EVAL_ERROR] =
+ gtk_signal_new ("eval_error",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (CalQueryClass, eval_error),
+ gtk_marshal_NONE__STRING,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_STRING);
+
+ gtk_object_class_add_signals (object_class, query_signals, LAST_SIGNAL);
+
+ class->obj_updated = NULL;
+ class->obj_removed = NULL;
+ class->query_done = NULL;
+ class->eval_error = NULL;
+
+ object_class->destroy = cal_query_destroy;
+}
+
+/* Object initialization function for the calendar query */
+static void
+cal_query_init (CalQuery *query)
+{
+ CalQueryPrivate *priv;
+
+ priv = g_new0 (CalQueryPrivate, 1);
+ query->priv = priv;
+
+ priv->ql = NULL;
+ priv->corba_query = CORBA_OBJECT_NIL;
+}
+
+/* Destroy handler for the calendar query */
+static void
+cal_query_destroy (GtkObject *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 unrefs the query listener, so we just NULL it out here */
+ 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 (ev._major != CORBA_NO_EXCEPTION)
+ 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 (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
+
+/* Marshalers */
+
+typedef void (* ObjUpdatedFunc) (QueryListener *ql, const char *uid,
+ gboolean query_in_progress, int n_scanned, int total,
+ gpointer data);
+
+static void
+marshal_obj_updated (GtkObject *object, GtkSignalFunc func, gpointer func_data, GtkArg *args)
+{
+ ObjUpdatedFunc f;
+
+ f = (ObjUpdatedFunc) func;
+
+ (* f) (QUERY_LISTENER (object), GTK_VALUE_STRING (args[0]),
+ GTK_VALUE_BOOL (args[1]), GTK_VALUE_INT (args[2]), GTK_VALUE_INT (args[3]),
+ func_data);
+}
+
+typedef void (* QueryDoneFunc) (QueryListener *ql, CalQueryDoneStatus status, const char *error_str,
+ gpointer data);
+
+static void
+marshal_query_done (GtkObject *object, GtkSignalFunc func, gpointer func_data, GtkArg *args)
+{
+ QueryDoneFunc f;
+
+ f = (QueryDoneFunc) func;
+
+ (* f) (QUERY_LISTENER (object), GTK_VALUE_ENUM (args[0]), GTK_VALUE_STRING (args[1]),
+ func_data);
+}
+
+
+
+/* Callback used when an object is updated in the query */
+static void
+obj_updated_cb (QueryListener *ql,
+ const GNOME_Evolution_Calendar_CalObjUID uid,
+ CORBA_boolean query_in_progress,
+ CORBA_long n_scanned,
+ CORBA_long total,
+ gpointer data)
+{
+ CalQuery *query;
+
+ query = CAL_QUERY (data);
+
+ gtk_signal_emit (GTK_OBJECT (query), query_signals[OBJ_UPDATED],
+ uid, 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 GNOME_Evolution_Calendar_CalObjUID uid,
+ gpointer data)
+{
+ CalQuery *query;
+
+ query = CAL_QUERY (data);
+
+ gtk_signal_emit (GTK_OBJECT (query), query_signals[OBJ_REMOVED],
+ 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;
+ }
+
+ gtk_signal_emit (GTK_OBJECT (query), query_signals[QUERY_DONE],
+ 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);
+
+ gtk_signal_emit (GTK_OBJECT (query), query_signals[EVAL_ERROR],
+ 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 (ev._major == CORBA_USER_EXCEPTION
+ && strcmp (CORBA_exception_id (&ev),
+ ex_GNOME_Evolution_Calendar_Cal_CouldNotCreate) == 0) {
+ g_message ("cal_query_construct(): The server could not create the query");
+ goto error;
+ } else if (ev._major != CORBA_NO_EXCEPTION) {
+ 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;
+ 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 = gtk_type_new (CAL_QUERY_TYPE);
+
+ if (!cal_query_construct (query, cal, sexp)) {
+ gtk_object_unref (GTK_OBJECT (query));
+ return NULL;
+ }
+
+ return query;
+}
diff --git a/calendar/cal-client/cal-query.h b/calendar/cal-client/cal-query.h
new file mode 100644
index 0000000000..8db6f29f7a
--- /dev/null
+++ b/calendar/cal-client/cal-query.h
@@ -0,0 +1,81 @@
+/* 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 the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef CAL_QUERY_H
+#define CAL_QUERY_H
+
+#include <libgnome/gnome-defs.h>
+#include <gtk/gtkobject.h>
+#include <cal-client/evolution-calendar.h>
+
+BEGIN_GNOME_DECLS
+
+
+
+#define CAL_QUERY_TYPE (cal_query_get_type ())
+#define CAL_QUERY(obj) (GTK_CHECK_CAST ((obj), CAL_QUERY_TYPE, CalQuery))
+#define CAL_QUERY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), CAL_QUERY_TYPE, CalQueryClass))
+#define IS_CAL_QUERY(obj) (GTK_CHECK_TYPE ((obj), CAL_QUERY_TYPE))
+#define IS_CAL_QUERY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), CAL_QUERY_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 {
+ GtkObject object;
+
+ /* Private data */
+ CalQueryPrivate *priv;
+} CalQuery;
+
+typedef struct {
+ GtkObjectClass 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;
+
+GtkType cal_query_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);
+
+
+
+END_GNOME_DECLS
+
+#endif
diff --git a/calendar/cal-client/query-listener.c b/calendar/cal-client/query-listener.c
new file mode 100644
index 0000000000..980b0a1ece
--- /dev/null
+++ b/calendar/cal-client/query-listener.c
@@ -0,0 +1,281 @@
+/* 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 the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#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;
+};
+
+
+
+static void query_listener_class_init (QueryListenerClass *class);
+static void query_listener_init (QueryListener *ql);
+static void query_listener_destroy (GtkObject *object);
+
+static void impl_notifyObjUpdated (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_CalObjUID uid,
+ CORBA_boolean query_in_progress,
+ CORBA_long n_scanned,
+ CORBA_long total,
+ CORBA_Environment *ev);
+
+static void impl_notifyObjRemoved (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_CalObjUID 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 BonoboXObjectClass *parent_class;
+
+
+
+BONOBO_X_TYPE_FUNC_FULL (QueryListener,
+ GNOME_Evolution_Calendar_QueryListener,
+ BONOBO_X_OBJECT_TYPE,
+ query_listener);
+
+/* Class initialization function for the live search query listener */
+static void
+query_listener_class_init (QueryListenerClass *class)
+{
+ GtkObjectClass *object_class;
+
+ object_class = (GtkObjectClass *) class;
+
+ parent_class = gtk_type_class (BONOBO_X_OBJECT_TYPE);
+
+ object_class->destroy = query_listener_destroy;
+
+ 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)
+{
+ 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;
+}
+
+/* Destroy handler for the live search query listener */
+static void
+query_listener_destroy (GtkObject *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;
+
+ g_free (priv);
+ ql->priv = NULL;
+
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
+
+/* CORBA method implementations */
+
+/* ::notifyObjUpdated() method */
+static void
+impl_notifyObjUpdated (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_CalObjUID uid,
+ 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;
+
+ g_assert (priv->obj_updated_fn != NULL);
+ (* priv->obj_updated_fn) (ql, uid, query_in_progress, n_scanned, total, priv->fn_data);
+}
+
+/* ::notifyObjRemoved() method */
+static void
+impl_notifyObjRemoved (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_CalObjUID uid,
+ CORBA_Environment *ev)
+{
+ QueryListener *ql;
+ QueryListenerPrivate *priv;
+
+ ql = QUERY_LISTENER (bonobo_object_from_servant (servant));
+ priv = ql->priv;
+
+ 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;
+
+ 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;
+
+ 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 = gtk_type_new (QUERY_LISTENER_TYPE);
+
+ return query_listener_construct (ql,
+ obj_updated_fn,
+ obj_removed_fn,
+ query_done_fn,
+ eval_error_fn,
+ fn_data);
+}
diff --git a/calendar/cal-client/query-listener.h b/calendar/cal-client/query-listener.h
new file mode 100644
index 0000000000..53be9f3229
--- /dev/null
+++ b/calendar/cal-client/query-listener.h
@@ -0,0 +1,96 @@
+/* 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 the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef QUERY_LISTENER_H
+#define QUERY_LISTENER_H
+
+#include <bonobo/bonobo-xobject.h>
+#include "evolution-calendar.h"
+
+BEGIN_GNOME_DECLS
+
+
+
+#define QUERY_LISTENER_TYPE (query_listener_get_type ())
+#define QUERY_LISTENER(obj) (GTK_CHECK_CAST ((obj), QUERY_LISTENER_TYPE, QueryListener))
+#define QUERY_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), QUERY_LISTENER_TYPE, \
+ QueryListenerClass))
+#define IS_QUERY_LISTENER(obj) (GTK_CHECK_TYPE ((obj), QUERY_LISTENER_TYPE))
+#define IS_QUERY_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), QUERY_LISTENER_TYPE))
+
+typedef struct _QueryListenerPrivate QueryListenerPrivate;
+
+typedef struct {
+ BonoboXObject xobject;
+
+ /* Private data */
+ QueryListenerPrivate *priv;
+} QueryListener;
+
+typedef struct {
+ BonoboXObjectClass parent_class;
+
+ POA_GNOME_Evolution_Calendar_QueryListener__epv epv;
+} QueryListenerClass;
+
+/* Notification functions */
+
+typedef void (* QueryListenerObjUpdatedFn) (QueryListener *ql,
+ const GNOME_Evolution_Calendar_CalObjUID uid,
+ CORBA_boolean query_in_progress,
+ CORBA_long n_scanned,
+ CORBA_long total,
+ gpointer data);
+
+typedef void (* QueryListenerObjRemovedFn) (QueryListener *ql,
+ const GNOME_Evolution_Calendar_CalObjUID 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);
+
+GtkType 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);
+
+
+
+END_GNOME_DECLS
+
+#endif
diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c
index 64e73e30f5..30e5987eea 100644
--- a/calendar/gui/dialogs/task-editor.c
+++ b/calendar/gui/dialogs/task-editor.c
@@ -553,6 +553,8 @@ task_editor_set_cal_client (TaskEditor *tedit,
static void
obj_updated_cb (CalClient *client, const char *uid, gpointer data)
{
+ /* FIXME: Do something sensible if the component changes under our feet */
+#if 0
TaskEditor *tedit;
TaskEditorPrivate *priv;
CalComponent *comp;
@@ -595,12 +597,17 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
}
raise_and_focus (priv->app);
+#endif
}
/* Callback used when the calendar client tells us that an object was removed */
static void
obj_removed_cb (CalClient *client, const char *uid, gpointer data)
{
+ /* FIXME: Do something sensible if the component is removed under our
+ * feet.
+ */
+#if 0
TaskEditor *tedit;
TaskEditorPrivate *priv;
const gchar *editing_uid;
@@ -621,6 +628,7 @@ obj_removed_cb (CalClient *client, const char *uid, gpointer data)
raise_and_focus (priv->app);
+#endif
}
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index 69e6ddaeb4..e69b2a4037 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -551,12 +551,15 @@ e_tasks_setup_menus (ETasks *tasks,
GalViewMenus *views;
GalViewFactory *factory;
ETableSpecification *spec;
+ char *dir;
collection = gal_view_collection_new();
- /* FIXME: Memory leak. */
+
+ dir = gnome_util_prepend_user_home ("/evolution/views/tasks/");
gal_view_collection_set_storage_directories (collection,
EVOLUTION_DATADIR "/evolution/views/tasks/",
- gnome_util_prepend_user_home ("/evolution/views/tasks/"));
+ dir);
+ g_free (dir);
spec = e_table_specification_new ();
e_table_specification_load_from_string (spec, e_calendar_table_get_spec());
diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c
index 8e3f86c92f..30abe1ae9a 100644
--- a/calendar/gui/event-editor.c
+++ b/calendar/gui/event-editor.c
@@ -2600,6 +2600,8 @@ raise_and_focus (GtkWidget *widget)
static void
obj_updated_cb (CalClient *client, const char *uid, gpointer data)
{
+ /* FIXME: Do something sensible if the component changes under our feet */
+#if 0
EventEditor *ee;
EventEditorPrivate *priv;
CalComponent *comp;
@@ -2642,12 +2644,17 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
}
raise_and_focus (priv->app);
+#endif
}
/* Callback used when the calendar client tells us that an object was removed */
static void
obj_removed_cb (CalClient *client, const char *uid, gpointer data)
{
+ /* FIXME: Do something sensible if the component is removed under our
+ * feet.
+ */
+#if 0
EventEditor *ee;
EventEditorPrivate *priv;
const gchar *editing_uid;
@@ -2668,6 +2675,7 @@ obj_removed_cb (CalClient *client, const char *uid, gpointer data)
raise_and_focus (priv->app);
+#endif
}
/**