~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to calendar/libedata-cal/e-data-cal-view.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
1
2
/* Evolution calendar - Live search query implementation
2
3
 *
3
4
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 
5
 * Copyright (C) 2009 Intel Corporation
4
6
 *
5
 
 * Author: Federico Mena-Quintero <federico@ximian.com>
 
7
 * Authors: Federico Mena-Quintero <federico@ximian.com>
 
8
 *          Ross Burton <ross@linux.intel.com>
6
9
 *
7
10
 * This program is free software; you can redistribute it and/or
8
11
 * modify it under the terms of version 2 of the GNU Lesser General Public
24
27
 
25
28
#include <string.h>
26
29
#include <glib.h>
27
 
#include <bonobo/bonobo-exception.h>
28
 
#include "libedataserver/e-component-listener.h"
 
30
 
 
31
#include <dbus/dbus.h>
 
32
#include <dbus/dbus-glib.h>
 
33
#include <glib-object.h>
 
34
 
29
35
#include "e-cal-backend-sexp.h"
30
36
#include "e-data-cal-view.h"
31
 
 
32
 
 
33
 
 
34
 
typedef struct {
35
 
        GNOME_Evolution_Calendar_CalViewListener listener;
36
 
        EComponentListener *component_listener;
37
 
 
38
 
        gboolean notified_start;
39
 
        gboolean notified_done;
40
 
} ListenerData;
41
 
 
42
 
/* Private part of the Query structure */
 
37
#include "e-data-cal-marshal.h"
 
38
 
 
39
extern DBusGConnection *connection;
 
40
 
 
41
static gboolean impl_EDataCalView_start (EDataCalView *query, GError **error);
 
42
#include "e-data-cal-view-glue.h"
 
43
 
 
44
#define THRESHOLD 32
 
45
 
43
46
struct _EDataCalViewPrivate {
44
47
        /* The backend we are monitoring */
45
48
        ECalBackend *backend;
46
49
 
47
50
        gboolean started;
48
51
        gboolean done;
49
 
        GNOME_Evolution_Calendar_CallStatus done_status;
50
 
 
51
 
        GHashTable *matched_objects;
52
 
 
53
 
        /* The listener we report to */
54
 
        GList *listeners;
 
52
        EDataCalCallStatus done_status;
55
53
 
56
54
        /* Sexp that defines the query */
57
55
        ECalBackendSExp *sexp;
 
56
 
 
57
        GArray *adds;
 
58
        GArray *changes;
 
59
        GArray *removes;
 
60
 
 
61
        GHashTable *ids;
 
62
 
 
63
        gchar *path;
58
64
};
59
65
 
60
 
 
 
66
G_DEFINE_TYPE (EDataCalView, e_data_cal_view, G_TYPE_OBJECT);
 
67
#define E_DATA_CAL_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_DATA_CAL_VIEW_TYPE, EDataCalViewPrivate))
61
68
 
62
 
static void e_data_cal_view_class_init (EDataCalViewClass *class);
63
 
static void e_data_cal_view_init (EDataCalView *query, EDataCalViewClass *class);
 
69
static void e_data_cal_view_dispose (GObject *object);
64
70
static void e_data_cal_view_finalize (GObject *object);
65
 
 
66
 
static BonoboObjectClass *parent_class;
67
 
 
68
 
 
69
 
 
70
 
BONOBO_TYPE_FUNC_FULL (EDataCalView,
71
 
                       GNOME_Evolution_Calendar_CalView,
72
 
                       BONOBO_TYPE_OBJECT,
73
 
                       e_data_cal_view)
 
71
static void e_data_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 
72
static void e_data_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
74
73
 
75
74
/* Property IDs */
76
75
enum props {
77
76
        PROP_0,
78
77
        PROP_BACKEND,
79
 
        PROP_LISTENER,
80
78
        PROP_SEXP
81
79
};
82
80
 
83
 
/* Signal IDs */
 
81
/* Signals */
84
82
enum {
85
 
        LAST_LISTENER_GONE,
86
 
        LAST_SIGNAL
 
83
  OBJECTS_ADDED,
 
84
  OBJECTS_MODIFIED,
 
85
  OBJECTS_REMOVED,
 
86
  PROGRESS,
 
87
  DONE,
 
88
  LAST_SIGNAL
87
89
};
88
90
 
89
 
static guint signals[LAST_SIGNAL];
90
 
 
91
 
static void
92
 
add_object_to_cache (EDataCalView *query, const gchar *calobj)
93
 
{
94
 
        ECalComponent *comp;
95
 
        gchar *real_uid;
96
 
        const gchar *uid;
97
 
        EDataCalViewPrivate *priv;
98
 
 
99
 
        priv = query->priv;
100
 
 
101
 
        comp = e_cal_component_new_from_string (calobj);
102
 
        if (!comp)
103
 
                return;
104
 
 
105
 
        e_cal_component_get_uid (comp, &uid);
106
 
        if (!uid || !*uid) {
107
 
                g_object_unref (comp);
108
 
                return;
109
 
        }
110
 
 
111
 
        if (e_cal_component_is_instance (comp)) {
112
 
                gchar *str;
113
 
                str = e_cal_component_get_recurid_as_string (comp);
114
 
                real_uid = g_strdup_printf ("%s@%s", uid, str);
115
 
                g_free (str);
116
 
        } else
117
 
                real_uid = g_strdup (uid);
118
 
 
119
 
        if (g_hash_table_lookup (priv->matched_objects, real_uid))
120
 
                g_hash_table_replace (priv->matched_objects, real_uid, g_strdup (calobj));
121
 
        else
122
 
                g_hash_table_insert (priv->matched_objects, real_uid, g_strdup (calobj));
123
 
 
124
 
        /* free memory */
125
 
        g_object_unref (comp);
126
 
}
127
 
 
128
 
static gboolean
129
 
uncache_with_id_cb (gpointer key, gpointer value, gpointer user_data)
130
 
{
131
 
        ECalComponent *comp;
132
 
        ECalComponentId *id;
133
 
        const gchar *this_uid;
134
 
        gchar *object;
135
 
        gboolean remove = FALSE;
136
 
 
137
 
        id = user_data;
138
 
        object = value;
139
 
 
140
 
        comp = e_cal_component_new_from_string (object);
141
 
        if (comp) {
142
 
                e_cal_component_get_uid (comp, &this_uid);
143
 
                if (this_uid && !strcmp (id->uid, this_uid)) {
144
 
                        if (id->rid && *id->rid) {
145
 
                                gchar *rid = e_cal_component_get_recurid_as_string (comp);
146
 
 
147
 
                                if (rid && !strcmp (id->rid, rid))
148
 
                                        remove = TRUE;
149
 
 
150
 
                                g_free (rid);
151
 
                        } else
152
 
                                remove = TRUE;
153
 
                }
154
 
 
155
 
                g_object_unref (comp);
156
 
        }
157
 
 
158
 
        return remove;
159
 
}
160
 
 
161
 
static void
162
 
remove_object_from_cache (EDataCalView *query, const ECalComponentId *id)
163
 
{
164
 
        EDataCalViewPrivate *priv;
165
 
 
166
 
        priv = query->priv;
167
 
 
168
 
        g_hash_table_foreach_remove (priv->matched_objects, (GHRFunc) uncache_with_id_cb, (gpointer) id);
169
 
}
170
 
 
171
 
static void
172
 
listener_died_cb (EComponentListener *cl, gpointer data)
173
 
{
174
 
        EDataCalView *query = QUERY (data);
175
 
        EDataCalViewPrivate *priv;
176
 
        GList *l;
177
 
 
178
 
        priv = query->priv;
179
 
 
180
 
        for (l = priv->listeners; l != NULL; l = l->next) {
181
 
                ListenerData *ld = l->data;
182
 
 
183
 
                if (ld->component_listener == cl) {
184
 
                        g_object_unref (ld->component_listener);
185
 
                        ld->component_listener = NULL;
186
 
 
187
 
                        bonobo_object_release_unref (ld->listener, NULL);
188
 
                        ld->listener = NULL;
189
 
 
190
 
                        priv->listeners = g_list_remove_link (priv->listeners, l);
191
 
                        g_list_free (l);
192
 
                        g_free (ld);
193
 
 
194
 
                        if (priv->listeners == NULL)
195
 
                                g_signal_emit (query, signals[LAST_LISTENER_GONE], 0);
196
 
 
197
 
                        break;
198
 
                }
199
 
        }
200
 
}
201
 
 
202
 
static void
203
 
notify_matched_object_cb (gpointer key, gpointer value, gpointer user_data)
204
 
{
205
 
        gchar *uid, *object;
206
 
        EDataCalView *query;
207
 
        EDataCalViewPrivate *priv;
208
 
        GList *l;
209
 
 
210
 
        uid = key;
211
 
        object = value;
212
 
        query = user_data;
213
 
        priv = query->priv;
214
 
 
215
 
        for (l = priv->listeners; l != NULL; l = l->next) {
216
 
                ListenerData *ld = l->data;
217
 
 
218
 
                if (!ld->notified_start) {
219
 
                        GNOME_Evolution_Calendar_stringlist obj_list;
220
 
                        CORBA_Environment ev;
221
 
 
222
 
                        obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (1);
223
 
                        obj_list._maximum = 1;
224
 
                        obj_list._length = 1;
225
 
                        obj_list._buffer[0] = CORBA_string_dup (object);
226
 
 
227
 
                        CORBA_exception_init (&ev);
228
 
                        GNOME_Evolution_Calendar_CalViewListener_notifyObjectsAdded (ld->listener, &obj_list, &ev);
229
 
                        CORBA_exception_free (&ev);
230
 
 
231
 
                        CORBA_free (obj_list._buffer);
232
 
                }
233
 
        }
234
 
}
235
 
 
236
 
static void
237
 
impl_EDataCalView_start (PortableServer_Servant servant, CORBA_Environment *ev)
238
 
{
239
 
        EDataCalView *query;
240
 
        EDataCalViewPrivate *priv;
241
 
        GList *l;
242
 
 
243
 
        query = QUERY (bonobo_object_from_servant (servant));
244
 
        priv = query->priv;
245
 
 
246
 
        if (priv->started) {
247
 
                g_hash_table_foreach (priv->matched_objects, (GHFunc) notify_matched_object_cb, query);
248
 
 
249
 
                /* notify all listeners correctly if the query is already done */
250
 
                for (l = priv->listeners; l != NULL; l = l->next) {
251
 
                        ListenerData *ld = l->data;
252
 
 
253
 
                        if (!ld->notified_start) {
254
 
                                ld->notified_start = TRUE;
255
 
 
256
 
                                if (priv->done && !ld->notified_done) {
257
 
 
258
 
                                        ld->notified_done = TRUE;
259
 
 
260
 
                                        CORBA_exception_init (ev);
261
 
                                        GNOME_Evolution_Calendar_CalViewListener_notifyQueryDone (
262
 
                                                ld->listener, priv->done_status, ev);
263
 
                                        CORBA_exception_free (ev);
264
 
                                }
265
 
                        }
266
 
                }
267
 
        } else {
268
 
                priv->started = TRUE;
269
 
                e_cal_backend_start_query (priv->backend, query);
270
 
 
271
 
                for (l = priv->listeners; l != NULL; l = l->next) {
272
 
                        ListenerData *ld = l->data;
273
 
 
274
 
                        ld->notified_start = TRUE;
275
 
                }
276
 
        }
277
 
}
278
 
 
279
 
static void
280
 
e_data_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
281
 
{
282
 
        EDataCalView *query;
283
 
        EDataCalViewPrivate *priv;
284
 
 
285
 
        query = QUERY (object);
286
 
        priv = query->priv;
287
 
 
288
 
        switch (property_id) {
289
 
        case PROP_BACKEND:
290
 
                priv->backend = E_CAL_BACKEND (g_value_dup_object (value));
291
 
                break;
292
 
        case PROP_LISTENER:
293
 
                e_data_cal_view_add_listener (query, g_value_get_pointer (value));
294
 
                break;
295
 
        case PROP_SEXP:
296
 
                priv->sexp = E_CAL_BACKEND_SEXP (g_value_dup_object (value));
297
 
                break;
298
 
        default:
299
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
300
 
                break;
301
 
        }
302
 
}
303
 
 
304
 
static void
305
 
e_data_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
306
 
{
307
 
        EDataCalView *query;
308
 
        EDataCalViewPrivate *priv;
309
 
 
310
 
        query = QUERY (object);
311
 
        priv = query->priv;
312
 
 
313
 
        switch (property_id) {
314
 
        case PROP_BACKEND:
315
 
                g_value_set_object (value, priv->backend);
316
 
        case PROP_LISTENER:
317
 
 
318
 
                if (priv->listeners) {
319
 
                        ListenerData *ld;
320
 
 
321
 
                        ld = priv->listeners->data;
322
 
                        g_value_set_pointer (value, ld->listener);
323
 
                }
324
 
                break;
325
 
        case PROP_SEXP:
326
 
                g_value_set_object (value, priv->sexp);
327
 
                break;
328
 
        default:
329
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
330
 
                break;
331
 
        }
332
 
}
333
 
 
334
 
/* Class initialization function for the live search query */
 
91
static guint signals[LAST_SIGNAL] = { 0 };
 
92
 
 
93
/* Class init */
335
94
static void
336
95
e_data_cal_view_class_init (EDataCalViewClass *klass)
337
96
{
338
 
        GObjectClass *object_class;
339
 
        POA_GNOME_Evolution_Calendar_CalView__epv *epv = &klass->epv;
340
97
        GParamSpec *param;
341
 
 
342
 
        object_class = (GObjectClass *) klass;
343
 
 
344
 
        parent_class = g_type_class_peek_parent (klass);
 
98
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
99
 
 
100
        g_type_class_add_private (klass, sizeof (EDataCalViewPrivate));
345
101
 
346
102
        object_class->set_property = e_data_cal_view_set_property;
347
103
        object_class->get_property = e_data_cal_view_get_property;
 
104
        object_class->dispose = e_data_cal_view_dispose;
348
105
        object_class->finalize = e_data_cal_view_finalize;
349
106
 
350
 
        epv->start = impl_EDataCalView_start;
351
 
 
352
107
        param =  g_param_spec_object ("backend", NULL, NULL, E_TYPE_CAL_BACKEND,
353
108
                                      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
354
109
        g_object_class_install_property (object_class, PROP_BACKEND, param);
355
 
        param =  g_param_spec_pointer ("listener", NULL, NULL,
356
 
                                      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
357
 
        g_object_class_install_property (object_class, PROP_LISTENER, param);
358
110
        param =  g_param_spec_object ("sexp", NULL, NULL, E_TYPE_CAL_BACKEND_SEXP,
359
111
                                      G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
360
112
        g_object_class_install_property (object_class, PROP_SEXP, param);
361
113
 
362
 
        signals[LAST_LISTENER_GONE] =
363
 
                g_signal_new ("last_listener_gone",
364
 
                              G_TYPE_FROM_CLASS (klass),
365
 
                              G_SIGNAL_RUN_FIRST,
366
 
                              G_STRUCT_OFFSET (EDataCalViewClass, last_listener_gone),
367
 
                              NULL, NULL,
368
 
                              g_cclosure_marshal_VOID__VOID,
369
 
                              G_TYPE_NONE, 0);
370
 
 
371
 
        klass->last_listener_gone = NULL;
372
 
}
373
 
 
374
 
/* Object initialization function for the live search query */
 
114
        signals[OBJECTS_ADDED] =
 
115
          g_signal_new ("objects-added",
 
116
                        G_OBJECT_CLASS_TYPE (klass),
 
117
                        G_SIGNAL_RUN_LAST,
 
118
                        0, NULL, NULL,
 
119
                        g_cclosure_marshal_VOID__BOXED,
 
120
                        G_TYPE_NONE, 1, G_TYPE_STRV);
 
121
 
 
122
        signals[OBJECTS_MODIFIED] =
 
123
          g_signal_new ("objects-modified",
 
124
                        G_OBJECT_CLASS_TYPE (klass),
 
125
                        G_SIGNAL_RUN_LAST,
 
126
                        0, NULL, NULL,
 
127
                        g_cclosure_marshal_VOID__BOXED,
 
128
                        G_TYPE_NONE, 1, G_TYPE_STRV);
 
129
 
 
130
        signals[OBJECTS_REMOVED] =
 
131
          g_signal_new ("objects-removed",
 
132
                        G_OBJECT_CLASS_TYPE (klass),
 
133
                        G_SIGNAL_RUN_LAST,
 
134
                        0, NULL, NULL,
 
135
                        g_cclosure_marshal_VOID__BOXED,
 
136
                        G_TYPE_NONE, 1, G_TYPE_STRV);
 
137
 
 
138
        signals[PROGRESS] =
 
139
          g_signal_new ("progress",
 
140
                        G_OBJECT_CLASS_TYPE (klass),
 
141
                        G_SIGNAL_RUN_LAST,
 
142
                        0, NULL, NULL,
 
143
                        e_data_cal_marshal_VOID__STRING_UINT,
 
144
                        G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_UINT);
 
145
 
 
146
        signals[DONE] =
 
147
          g_signal_new ("done",
 
148
                        G_OBJECT_CLASS_TYPE (klass),
 
149
                        G_SIGNAL_RUN_LAST,
 
150
                        0, NULL, NULL,
 
151
                        g_cclosure_marshal_VOID__UINT,
 
152
                        G_TYPE_NONE, 1, G_TYPE_UINT);
 
153
 
 
154
        dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), &dbus_glib_e_data_cal_view_object_info);
 
155
}
 
156
 
 
157
static guint
 
158
id_hash (gconstpointer key)
 
159
{
 
160
        const ECalComponentId *id = key;
 
161
        return g_str_hash (id->uid) ^ (id->rid ? g_str_hash (id->rid) : 0);
 
162
}
 
163
 
 
164
static gboolean
 
165
id_equal (gconstpointer a, gconstpointer b)
 
166
{
 
167
        const ECalComponentId *id_a = a, *id_b = b;
 
168
        return g_strcmp0 (id_a->uid, id_b->uid) == 0 && g_strcmp0 (id_a->rid, id_b->rid) == 0;
 
169
}
 
170
 
 
171
/* Instance init */
375
172
static void
376
 
e_data_cal_view_init (EDataCalView *query, EDataCalViewClass *class)
 
173
e_data_cal_view_init (EDataCalView *view)
377
174
{
378
 
        EDataCalViewPrivate *priv;
 
175
        EDataCalViewPrivate *priv = E_DATA_CAL_VIEW_GET_PRIVATE (view);
379
176
 
380
 
        priv = g_new0 (EDataCalViewPrivate, 1);
381
 
        query->priv = priv;
 
177
        view->priv = priv;
382
178
 
383
179
        priv->backend = NULL;
384
180
        priv->started = FALSE;
385
181
        priv->done = FALSE;
386
 
        priv->done_status = GNOME_Evolution_Calendar_Success;
387
 
        priv->matched_objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
388
 
        priv->listeners = NULL;
 
182
        priv->done_status = Success;
 
183
        priv->started = FALSE;
389
184
        priv->sexp = NULL;
390
 
}
391
 
 
392
 
/* Finalize handler for the live search query */
393
 
static void
394
 
e_data_cal_view_finalize (GObject *object)
395
 
{
396
 
        EDataCalView *query;
397
 
        EDataCalViewPrivate *priv;
398
 
 
399
 
        g_return_if_fail (object != NULL);
400
 
        g_return_if_fail (IS_QUERY (object));
401
 
 
402
 
        query = QUERY (object);
403
 
        priv = query->priv;
404
 
 
405
 
        if (priv->backend)
406
 
                g_object_unref (priv->backend);
407
 
 
408
 
        while (priv->listeners) {
409
 
                ListenerData *ld = priv->listeners->data;
410
 
 
411
 
                if (ld->listener)
412
 
                        bonobo_object_release_unref (ld->listener, NULL);
413
 
                if (ld->component_listener)
414
 
                        g_object_unref (ld->component_listener);
415
 
                priv->listeners = g_list_remove (priv->listeners, ld);
416
 
                g_free (ld);
417
 
        }
418
 
 
419
 
        if (priv->matched_objects)
420
 
                g_hash_table_destroy (priv->matched_objects);
421
 
 
422
 
        if (priv->sexp)
423
 
                g_object_unref (priv->sexp);
424
 
 
425
 
        g_free (priv);
426
 
 
427
 
        if (G_OBJECT_CLASS (parent_class)->finalize)
428
 
                (* G_OBJECT_CLASS (parent_class)->finalize) (object);
429
 
}
430
 
 
431
 
/**
432
 
 * e_data_cal_view_new:
433
 
 * @backend: Calendar backend that the query object will monitor.
434
 
 * @ql: Listener for query results.
435
 
 * @sexp: Sexp that defines the query.
436
 
 *
437
 
 * Creates a new query engine object that monitors a calendar backend.
438
 
 *
439
 
 * Return value: A newly-created query object, or NULL on failure.
440
 
 **/
 
185
 
 
186
        priv->adds = g_array_sized_new (TRUE, TRUE, sizeof (gchar *), THRESHOLD);
 
187
        priv->changes = g_array_sized_new (TRUE, TRUE, sizeof (gchar *), THRESHOLD);
 
188
        priv->removes = g_array_sized_new (TRUE, TRUE, sizeof (gchar *), THRESHOLD);
 
189
 
 
190
        priv->ids = g_hash_table_new_full (id_hash, id_equal, (GDestroyNotify)e_cal_component_free_id, NULL);
 
191
}
 
192
 
441
193
EDataCalView *
442
194
e_data_cal_view_new (ECalBackend *backend,
443
 
                     GNOME_Evolution_Calendar_CalViewListener ql,
444
 
                     ECalBackendSExp *sexp)
 
195
                     const gchar *path, ECalBackendSExp *sexp)
445
196
{
446
197
        EDataCalView *query;
447
198
 
448
 
        query = g_object_new (E_DATA_CAL_VIEW_TYPE, "backend", backend, "listener", ql,
449
 
                              "sexp", sexp, NULL);
 
199
        query = g_object_new (E_DATA_CAL_VIEW_TYPE, "backend", backend, "sexp", sexp, NULL);
 
200
        query->priv->path = g_strdup (path);
 
201
 
 
202
        dbus_g_connection_register_g_object (connection, path, G_OBJECT (query));
450
203
 
451
204
        return query;
452
205
}
453
206
 
454
207
/**
455
 
 * e_data_cal_view_add_listener:
456
 
 * @query: A #EDataCalView object.
457
 
 * @ql: A CORBA query listener to add to the list of listeners.
458
 
 *
459
 
 * Adds the given CORBA listener to a #EDataCalView object. This makes the view
460
 
 * object notify that listener when notifying the other listeners already attached
461
 
 * to the view.
462
 
 */
463
 
void
464
 
e_data_cal_view_add_listener (EDataCalView *query, GNOME_Evolution_Calendar_CalViewListener ql)
465
 
{
466
 
        ListenerData *ld;
467
 
        EDataCalViewPrivate *priv;
468
 
        CORBA_Environment ev;
469
 
 
470
 
        g_return_if_fail (IS_QUERY (query));
471
 
        g_return_if_fail (ql != CORBA_OBJECT_NIL);
472
 
 
473
 
        priv = query->priv;
474
 
 
475
 
        ld = g_new0 (ListenerData, 1);
476
 
 
477
 
        CORBA_exception_init (&ev);
478
 
        ld->listener = CORBA_Object_duplicate (ql, &ev);
479
 
        CORBA_exception_free (&ev);
480
 
 
481
 
        ld->component_listener = e_component_listener_new (ld->listener);
482
 
        g_signal_connect (G_OBJECT (ld->component_listener), "component_died",
483
 
                          G_CALLBACK (listener_died_cb), query);
484
 
 
485
 
        priv->listeners = g_list_prepend (priv->listeners, ld);
 
208
 * e_data_cal_view_get_dbus_path:
 
209
 * @view: an #EDataCalView
 
210
 *
 
211
 * Returns the D-Bus path for @view.
 
212
 *
 
213
 * Returns: the D-Bus path for @view
 
214
 *
 
215
 * Since: 2.30
 
216
 **/
 
217
const gchar *
 
218
e_data_cal_view_get_dbus_path (EDataCalView *view)
 
219
{
 
220
        g_return_val_if_fail (E_IS_DATA_CAL_VIEW (view), NULL);
 
221
 
 
222
        return view->priv->path;
 
223
}
 
224
 
 
225
static void
 
226
reset_array (GArray *array)
 
227
{
 
228
        gint i = 0;
 
229
        gchar *tmp = NULL;
 
230
 
 
231
        /* Free stored strings */
 
232
        for (i = 0; i < array->len; i++) {
 
233
                tmp = g_array_index (array, gchar *, i);
 
234
                g_free (tmp);
 
235
        }
 
236
 
 
237
        /* Force the array size to 0 */
 
238
        g_array_set_size (array, 0);
 
239
}
 
240
 
 
241
static void
 
242
send_pending_adds (EDataCalView *view)
 
243
{
 
244
        EDataCalViewPrivate *priv = view->priv;
 
245
 
 
246
        if (priv->adds->len == 0)
 
247
                return;
 
248
 
 
249
        g_signal_emit (view, signals[OBJECTS_ADDED], 0, priv->adds->data);
 
250
        reset_array (priv->adds);
 
251
}
 
252
 
 
253
static void
 
254
send_pending_changes (EDataCalView *view)
 
255
{
 
256
        EDataCalViewPrivate *priv = view->priv;
 
257
 
 
258
        if (priv->changes->len == 0)
 
259
                return;
 
260
 
 
261
        g_signal_emit (view, signals[OBJECTS_MODIFIED], 0, priv->changes->data);
 
262
        reset_array (priv->changes);
 
263
}
 
264
 
 
265
static void
 
266
send_pending_removes (EDataCalView *view)
 
267
{
 
268
        EDataCalViewPrivate *priv = view->priv;
 
269
 
 
270
        if (priv->removes->len == 0)
 
271
                return;
 
272
 
 
273
        /* TODO: send ECalComponentIds as a list of pairs */
 
274
        g_signal_emit (view, signals[OBJECTS_REMOVED], 0, priv->removes->data);
 
275
        reset_array (priv->removes);
 
276
}
 
277
 
 
278
static void
 
279
notify_add (EDataCalView *view, gchar *obj)
 
280
{
 
281
        EDataCalViewPrivate *priv = view->priv;
 
282
        ECalComponent *comp;
 
283
 
 
284
        send_pending_changes (view);
 
285
        send_pending_removes (view);
 
286
 
 
287
        if (priv->adds->len == THRESHOLD) {
 
288
                send_pending_adds (view);
 
289
        }
 
290
        g_array_append_val (priv->adds, obj);
 
291
 
 
292
        comp = e_cal_component_new_from_string (obj);
 
293
        g_hash_table_insert (priv->ids,
 
294
                             e_cal_component_get_id (comp),
 
295
                             GUINT_TO_POINTER (1));
 
296
        g_object_unref (comp);
 
297
}
 
298
 
 
299
static void
 
300
notify_change (EDataCalView *view, gchar *obj)
 
301
{
 
302
        EDataCalViewPrivate *priv = view->priv;
 
303
 
 
304
        send_pending_adds (view);
 
305
        send_pending_removes (view);
 
306
 
 
307
        g_array_append_val (priv->changes, obj);
 
308
}
 
309
 
 
310
static void
 
311
notify_remove (EDataCalView *view, ECalComponentId *id)
 
312
{
 
313
        EDataCalViewPrivate *priv = view->priv;
 
314
        gchar *uid;
 
315
 
 
316
        send_pending_adds (view);
 
317
        send_pending_changes (view);
 
318
 
 
319
        /* TODO: store ECalComponentId instead of just uid*/
 
320
        uid = g_strdup (id->uid);
 
321
        g_array_append_val (priv->removes, uid);
 
322
 
 
323
        g_hash_table_remove (priv->ids, id);
 
324
}
 
325
 
 
326
static void
 
327
notify_done (EDataCalView *view)
 
328
{
 
329
        EDataCalViewPrivate *priv = view->priv;
 
330
 
 
331
        send_pending_adds (view);
 
332
        send_pending_changes (view);
 
333
        send_pending_removes (view);
 
334
 
 
335
        g_signal_emit (view, signals[DONE], 0, priv->done_status);
 
336
}
 
337
 
 
338
static gboolean
 
339
impl_EDataCalView_start (EDataCalView *query, GError **error)
 
340
{
 
341
        EDataCalViewPrivate *priv;
 
342
 
 
343
        priv = query->priv;
 
344
 
 
345
        if (!priv->started) {
 
346
                priv->started = TRUE;
 
347
                e_cal_backend_start_query (priv->backend, query);
 
348
        }
 
349
 
 
350
        return TRUE;
 
351
}
 
352
 
 
353
static void
 
354
e_data_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 
355
{
 
356
        EDataCalView *query;
 
357
        EDataCalViewPrivate *priv;
 
358
 
 
359
        query = QUERY (object);
 
360
        priv = query->priv;
 
361
 
 
362
        switch (property_id) {
 
363
        case PROP_BACKEND:
 
364
                priv->backend = E_CAL_BACKEND (g_value_dup_object (value));
 
365
                break;
 
366
        case PROP_SEXP:
 
367
                priv->sexp = E_CAL_BACKEND_SEXP (g_value_dup_object (value));
 
368
                break;
 
369
        default:
 
370
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
371
                break;
 
372
        }
 
373
}
 
374
 
 
375
static void
 
376
e_data_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
 
377
{
 
378
        EDataCalView *query;
 
379
        EDataCalViewPrivate *priv;
 
380
 
 
381
        query = QUERY (object);
 
382
        priv = query->priv;
 
383
 
 
384
        switch (property_id) {
 
385
        case PROP_BACKEND:
 
386
                g_value_set_object (value, priv->backend);
 
387
                break;
 
388
        case PROP_SEXP:
 
389
                g_value_set_object (value, priv->sexp);
 
390
                break;
 
391
        default:
 
392
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
393
                break;
 
394
        }
 
395
}
 
396
 
 
397
static void
 
398
e_data_cal_view_dispose (GObject *object)
 
399
{
 
400
        EDataCalView *query;
 
401
        EDataCalViewPrivate *priv;
 
402
 
 
403
        g_return_if_fail (object != NULL);
 
404
        g_return_if_fail (IS_QUERY (object));
 
405
 
 
406
        query = QUERY (object);
 
407
        priv = query->priv;
 
408
 
 
409
        if (priv->backend) {
 
410
                g_object_unref (priv->backend);
 
411
                priv->backend = NULL;
 
412
        }
 
413
 
 
414
        if (priv->sexp) {
 
415
                g_object_unref (priv->sexp);
 
416
                priv->sexp = NULL;
 
417
        }
 
418
 
 
419
        (* G_OBJECT_CLASS (e_data_cal_view_parent_class)->dispose) (object);
 
420
}
 
421
 
 
422
static void
 
423
e_data_cal_view_finalize (GObject *object)
 
424
{
 
425
        EDataCalView *query;
 
426
        EDataCalViewPrivate *priv;
 
427
 
 
428
        g_return_if_fail (object != NULL);
 
429
        g_return_if_fail (IS_QUERY (object));
 
430
 
 
431
        query = QUERY (object);
 
432
        priv = query->priv;
 
433
 
 
434
        g_hash_table_destroy (priv->ids);
 
435
 
 
436
        g_free (priv->path);
 
437
 
 
438
        (* G_OBJECT_CLASS (e_data_cal_view_parent_class)->finalize) (object);
486
439
}
487
440
 
488
441
/**
491
444
 *
492
445
 * Get the expression used for the given query.
493
446
 *
494
 
 * Return value: the query expression used to search.
 
447
 * Returns: the query expression used to search.
495
448
 */
496
449
const gchar *
497
450
e_data_cal_view_get_text (EDataCalView *query)
507
460
 *
508
461
 * Get the #ECalBackendSExp object used for the given query.
509
462
 *
510
 
 * Return value: The expression object used to search.
 
463
 * Returns: The expression object used to search.
511
464
 */
512
465
ECalBackendSExp *
513
466
e_data_cal_view_get_object_sexp (EDataCalView *query)
525
478
 * Compares the given @object to the regular expression used for the
526
479
 * given query.
527
480
 *
528
 
 * Return value: TRUE if the object matches the expression, FALSE if not.
 
481
 * Returns: TRUE if the object matches the expression, FALSE if not.
529
482
 */
530
483
gboolean
531
484
e_data_cal_view_object_matches (EDataCalView *query, const gchar *object)
541
494
        return e_cal_backend_sexp_match_object (priv->sexp, object, priv->backend);
542
495
}
543
496
 
544
 
static void
545
 
add_object_to_list (gpointer key, gpointer value, gpointer user_data)
546
 
{
547
 
        GList **list = user_data;
548
 
 
549
 
        *list = g_list_append (*list, value);
550
 
}
551
 
 
552
497
/**
553
498
 * e_data_cal_view_get_matched_objects:
554
499
 * @query: A query object.
555
500
 *
556
501
 * Gets the list of objects already matched for the given query.
557
502
 *
558
 
 * Return value: A list of matched objects.
 
503
 * Returns: A list of matched objects.
559
504
 */
560
505
GList *
561
506
e_data_cal_view_get_matched_objects (EDataCalView *query)
562
507
{
563
 
        EDataCalViewPrivate *priv;
564
 
        GList *list = NULL;
565
 
 
566
508
        g_return_val_if_fail (IS_QUERY (query), NULL);
567
 
 
568
 
        priv = query->priv;
569
 
 
570
 
        g_hash_table_foreach (priv->matched_objects, (GHFunc) add_object_to_list, &list);
571
 
 
572
 
        return list;
 
509
        /* TODO e_data_cal_view_get_matched_objects */
 
510
        return NULL;
573
511
}
574
512
 
575
513
/**
578
516
 *
579
517
 * Checks whether the given query has already been started.
580
518
 *
581
 
 * Return value: TRUE if the query has already been started, FALSE otherwise.
 
519
 * Returns: TRUE if the query has already been started, FALSE otherwise.
582
520
 */
583
521
gboolean
584
 
e_data_cal_view_is_started (EDataCalView *query)
 
522
e_data_cal_view_is_started (EDataCalView *view)
585
523
{
586
 
        EDataCalViewPrivate *priv;
587
 
 
588
 
        g_return_val_if_fail (IS_QUERY (query), FALSE);
589
 
 
590
 
        priv = query->priv;
591
 
 
592
 
        return priv->started;
 
524
        g_return_val_if_fail (E_IS_DATA_CAL_VIEW (view), FALSE);
 
525
 
 
526
        return view->priv->started;
593
527
}
594
528
 
595
529
/**
601
535
 * changes will be sent. In fact, even after done, notifications will still be sent
602
536
 * if there are changes in the objects matching the query search expression.
603
537
 *
604
 
 * Return value: TRUE if the query is done, FALSE if still in progress.
 
538
 * Returns: TRUE if the query is done, FALSE if still in progress.
605
539
 */
606
540
gboolean
607
541
e_data_cal_view_is_done (EDataCalView *query)
622
556
 * Gets the status code obtained when the initial matching of objects was done
623
557
 * for the given query.
624
558
 *
625
 
 * Return value: The query status.
 
559
 * Returns: The query status.
626
560
 */
627
 
GNOME_Evolution_Calendar_CallStatus
 
561
EDataCalCallStatus
628
562
e_data_cal_view_get_done_status (EDataCalView *query)
629
563
{
630
564
        EDataCalViewPrivate *priv;
636
570
        if (priv->done)
637
571
                return priv->done_status;
638
572
 
639
 
        return GNOME_Evolution_Calendar_Success;
 
573
        return Success;
640
574
}
641
575
 
642
576
/**
647
581
 * Notifies all query listeners of the addition of a list of objects.
648
582
 */
649
583
void
650
 
e_data_cal_view_notify_objects_added (EDataCalView *query, const GList *objects)
 
584
e_data_cal_view_notify_objects_added (EDataCalView *view, const GList *objects)
651
585
{
652
586
        EDataCalViewPrivate *priv;
653
 
        GNOME_Evolution_Calendar_stringlist obj_list;
654
 
        CORBA_Environment ev;
655
587
        const GList *l;
656
 
        gint num_objs, i;
657
 
 
658
 
        g_return_if_fail (query != NULL);
659
 
        g_return_if_fail (IS_QUERY (query));
660
 
 
661
 
        priv = query->priv;
662
 
        g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
663
 
 
664
 
        num_objs = g_list_length ((GList*)objects);
665
 
        if (num_objs <= 0)
 
588
 
 
589
        g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
 
590
        priv = view->priv;
 
591
 
 
592
        if (objects == NULL)
666
593
                return;
667
594
 
668
 
        obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (num_objs);
669
 
        obj_list._maximum = num_objs;
670
 
        obj_list._length = num_objs;
671
 
 
672
 
        for (l = objects, i = 0; l; l = l->next, i++) {
673
 
                obj_list._buffer[i] = CORBA_string_dup (l->data);
674
 
 
675
 
                /* update our cache */
676
 
                add_object_to_cache (query, l->data);
677
 
        }
678
 
 
679
 
        for (l = priv->listeners; l != NULL; l = l->next) {
680
 
                ListenerData *ld = l->data;
681
 
 
682
 
                CORBA_exception_init (&ev);
683
 
 
684
 
                GNOME_Evolution_Calendar_CalViewListener_notifyObjectsAdded (ld->listener, &obj_list, &ev);
685
 
                if (BONOBO_EX (&ev))
686
 
                        g_warning (G_STRLOC ": could not notify the listener of object addition");
687
 
 
688
 
                CORBA_exception_free (&ev);
689
 
        }
690
 
 
691
 
        CORBA_free (obj_list._buffer);
 
595
        for (l = objects; l; l = l->next) {
 
596
                notify_add (view, g_strdup (l->data));
 
597
        }
 
598
 
 
599
        send_pending_adds (view);
692
600
}
693
601
 
694
602
/**
699
607
 * Notifies all the query listeners of the addition of a single object.
700
608
 */
701
609
void
702
 
e_data_cal_view_notify_objects_added_1 (EDataCalView *query, const gchar *object)
 
610
e_data_cal_view_notify_objects_added_1 (EDataCalView *view, const gchar *object)
703
611
{
704
 
        EDataCalViewPrivate *priv;
705
 
        GList objects;
706
 
 
707
 
        g_return_if_fail (query != NULL);
708
 
        g_return_if_fail (IS_QUERY (query));
709
 
        g_return_if_fail (object != NULL);
710
 
 
711
 
        priv = query->priv;
712
 
        g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
713
 
 
714
 
        objects.next = objects.prev = NULL;
715
 
        objects.data = (gpointer)object;
716
 
 
717
 
        e_data_cal_view_notify_objects_added (query, &objects);
 
612
        GList l = {0,};
 
613
 
 
614
        g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
 
615
        g_return_if_fail (object);
 
616
 
 
617
        l.data = (gpointer)object;
 
618
        e_data_cal_view_notify_objects_added (view, &l);
718
619
}
719
620
 
720
621
/**
725
626
 * Notifies all query listeners of the modification of a list of objects.
726
627
 */
727
628
void
728
 
e_data_cal_view_notify_objects_modified (EDataCalView *query, const GList *objects)
 
629
e_data_cal_view_notify_objects_modified (EDataCalView *view, const GList *objects)
729
630
{
730
631
        EDataCalViewPrivate *priv;
731
 
        GNOME_Evolution_Calendar_CalObjUIDSeq obj_list;
732
 
        CORBA_Environment ev;
733
632
        const GList *l;
734
 
        gint num_objs, i;
735
 
 
736
 
        g_return_if_fail (query != NULL);
737
 
        g_return_if_fail (IS_QUERY (query));
738
 
 
739
 
        priv = query->priv;
740
 
        g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
741
 
 
742
 
        num_objs = g_list_length ((GList*)objects);
743
 
        if (num_objs <= 0)
 
633
 
 
634
        g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
 
635
        priv = view->priv;
 
636
 
 
637
        if (objects == NULL)
744
638
                return;
745
639
 
746
 
        obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (num_objs);
747
 
        obj_list._maximum = num_objs;
748
 
        obj_list._length = num_objs;
749
 
 
750
 
        for (l = objects, i = 0; l; l = l->next, i++) {
751
 
                obj_list._buffer[i] = CORBA_string_dup (l->data);
752
 
 
753
 
                /* update our cache */
754
 
                add_object_to_cache (query, l->data);
755
 
        }
756
 
 
757
 
        for (l = priv->listeners; l != NULL; l = l->next) {
758
 
                ListenerData *ld = l->data;
759
 
 
760
 
                CORBA_exception_init (&ev);
761
 
 
762
 
                GNOME_Evolution_Calendar_CalViewListener_notifyObjectsModified (ld->listener, &obj_list, &ev);
763
 
                if (BONOBO_EX (&ev))
764
 
                        g_warning (G_STRLOC ": could not notify the listener of object modification");
765
 
 
766
 
                CORBA_exception_free (&ev);
767
 
        }
768
 
 
769
 
        CORBA_free (obj_list._buffer);
 
640
        for (l = objects; l; l = l->next) {
 
641
                /* TODO: send add/remove/change as relevant, based on ->ids */
 
642
                notify_change (view, g_strdup (l->data));
 
643
        }
 
644
 
 
645
        send_pending_changes (view);
770
646
}
771
647
 
772
648
/**
777
653
 * Notifies all query listeners of the modification of a single object.
778
654
 */
779
655
void
780
 
e_data_cal_view_notify_objects_modified_1 (EDataCalView *query, const gchar *object)
 
656
e_data_cal_view_notify_objects_modified_1 (EDataCalView *view, const gchar *object)
781
657
{
782
 
        EDataCalViewPrivate *priv;
783
 
        GList objects;
784
 
 
785
 
        g_return_if_fail (query != NULL);
786
 
        g_return_if_fail (IS_QUERY (query));
787
 
        g_return_if_fail (object != NULL);
788
 
 
789
 
        priv = query->priv;
790
 
        g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
791
 
 
792
 
        objects.next = objects.prev = NULL;
793
 
        objects.data = (gpointer)object;
794
 
 
795
 
        e_data_cal_view_notify_objects_modified (query, &objects);
 
658
        GList l = {0,};
 
659
 
 
660
        g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
 
661
        g_return_if_fail (object);
 
662
 
 
663
        l.data = (gpointer)object;
 
664
        e_data_cal_view_notify_objects_modified (view, &l);
796
665
}
797
666
 
798
667
/**
803
672
 * Notifies all query listener of the removal of a list of objects.
804
673
 */
805
674
void
806
 
e_data_cal_view_notify_objects_removed (EDataCalView *query, const GList *ids)
 
675
e_data_cal_view_notify_objects_removed (EDataCalView *view, const GList *ids)
807
676
{
808
677
        EDataCalViewPrivate *priv;
809
 
        GNOME_Evolution_Calendar_CalObjIDSeq id_list;
810
 
        CORBA_Environment ev;
811
678
        const GList *l;
812
 
        gint num_ids, i;
813
 
 
814
 
        g_return_if_fail (query != NULL);
815
 
        g_return_if_fail (IS_QUERY (query));
816
 
 
817
 
        priv = query->priv;
818
 
        g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
819
 
 
820
 
        num_ids = g_list_length ((GList*)ids);
821
 
        if (num_ids <= 0)
 
679
 
 
680
        g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
 
681
        priv = view->priv;
 
682
 
 
683
        if (ids == NULL)
822
684
                return;
823
685
 
824
 
        id_list._buffer = GNOME_Evolution_Calendar_CalObjIDSeq_allocbuf (num_ids);
825
 
        id_list._maximum = num_ids;
826
 
        id_list._length = num_ids;
827
 
 
828
 
        i = 0;
829
 
        for (l = ids; l; l = l->next, i++) {
 
686
        for (l = ids; l; l = l->next) {
830
687
                ECalComponentId *id = l->data;
831
 
                GNOME_Evolution_Calendar_CalObjID *c_id = &id_list._buffer[i];
832
 
 
833
 
                c_id->uid = CORBA_string_dup (id->uid);
834
 
 
835
 
                if (id->rid)
836
 
                        c_id->rid = CORBA_string_dup (id->rid);
837
 
                else
838
 
                        c_id->rid = CORBA_string_dup ("");
839
 
 
840
 
                /* update our cache */
841
 
                remove_object_from_cache (query, l->data);
842
 
        }
843
 
 
844
 
        for (l = priv->listeners; l != NULL; l = l->next) {
845
 
                ListenerData *ld = l->data;
846
 
 
847
 
                CORBA_exception_init (&ev);
848
 
 
849
 
                GNOME_Evolution_Calendar_CalViewListener_notifyObjectsRemoved (ld->listener, &id_list, &ev);
850
 
                if (BONOBO_EX (&ev))
851
 
                        g_warning (G_STRLOC ": could not notify the listener of object removal");
852
 
 
853
 
                CORBA_exception_free (&ev);
854
 
        }
855
 
 
856
 
        CORBA_free (id_list._buffer);
 
688
                if (g_hash_table_lookup (priv->ids, id))
 
689
                    notify_remove (view, id);
 
690
        }
 
691
 
 
692
        send_pending_removes (view);
857
693
}
858
694
 
859
695
/**
864
700
 * Notifies all query listener of the removal of a single object.
865
701
 */
866
702
void
867
 
e_data_cal_view_notify_objects_removed_1 (EDataCalView *query, const ECalComponentId *id)
 
703
e_data_cal_view_notify_objects_removed_1 (EDataCalView *view, const ECalComponentId *id)
868
704
{
869
 
        EDataCalViewPrivate *priv;
870
 
        GList ids;
871
 
 
872
 
        g_return_if_fail (query != NULL);
873
 
        g_return_if_fail (IS_QUERY (query));
874
 
        g_return_if_fail (id != NULL);
875
 
 
876
 
        priv = query->priv;
877
 
        g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
878
 
 
879
 
        ids.next = ids.prev = NULL;
880
 
        ids.data = (gpointer)id;
881
 
 
882
 
        e_data_cal_view_notify_objects_removed (query, &ids);
 
705
        GList l = {0,};
 
706
 
 
707
        g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
 
708
        g_return_if_fail (id);
 
709
 
 
710
        l.data = (gpointer)id;
 
711
        e_data_cal_view_notify_objects_removed (view, &l);
883
712
}
884
713
 
885
714
/**
891
720
 * Notifies all query listeners of progress messages.
892
721
 */
893
722
void
894
 
e_data_cal_view_notify_progress (EDataCalView *query, const gchar *message, gint percent)
 
723
e_data_cal_view_notify_progress (EDataCalView *view, const gchar *message, gint percent)
895
724
{
896
725
        EDataCalViewPrivate *priv;
897
 
        CORBA_Environment ev;
898
 
        GList *l;
899
 
 
900
 
        g_return_if_fail (query != NULL);
901
 
        g_return_if_fail (IS_QUERY (query));
902
 
 
903
 
        priv = query->priv;
904
 
        g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
905
 
 
906
 
        for (l = priv->listeners; l != NULL; l = l->next) {
907
 
                ListenerData *ld = l->data;
908
 
 
909
 
                CORBA_exception_init (&ev);
910
 
 
911
 
                GNOME_Evolution_Calendar_CalViewListener_notifyQueryProgress (ld->listener, message, percent, &ev);
912
 
                if (BONOBO_EX (&ev))
913
 
                        g_warning (G_STRLOC ": could not notify the listener of query progress");
914
 
 
915
 
                CORBA_exception_free (&ev);
916
 
        }
 
726
 
 
727
        g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
 
728
        priv = view->priv;
 
729
 
 
730
        if (!priv->started)
 
731
                return;
 
732
 
 
733
        g_signal_emit (view, signals[PROGRESS], 0, message, percent);
917
734
}
918
735
 
919
736
/**
925
742
 * status code.
926
743
 */
927
744
void
928
 
e_data_cal_view_notify_done (EDataCalView *query, GNOME_Evolution_Calendar_CallStatus status)
 
745
e_data_cal_view_notify_done (EDataCalView *view, GNOME_Evolution_Calendar_CallStatus status)
929
746
{
930
747
        EDataCalViewPrivate *priv;
931
 
        CORBA_Environment ev;
932
 
        GList *l;
933
 
 
934
 
        g_return_if_fail (query != NULL);
935
 
        g_return_if_fail (IS_QUERY (query));
936
 
 
937
 
        priv = query->priv;
938
 
        g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
 
748
 
 
749
        g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
 
750
        priv = view->priv;
 
751
 
 
752
        if (!priv->started)
 
753
                return;
939
754
 
940
755
        priv->done = TRUE;
941
756
        priv->done_status = status;
942
757
 
943
 
        for (l = priv->listeners; l != NULL; l = l->next) {
944
 
                ListenerData *ld = l->data;
945
 
 
946
 
                CORBA_exception_init (&ev);
947
 
 
948
 
                GNOME_Evolution_Calendar_CalViewListener_notifyQueryDone (ld->listener, status, &ev);
949
 
                if (BONOBO_EX (&ev))
950
 
                        g_warning (G_STRLOC ": could not notify the listener of query completion");
951
 
 
952
 
                CORBA_exception_free (&ev);
953
 
        }
 
758
        notify_done (view);
954
759
}