aboutsummaryrefslogblamecommitdiffstats
path: root/calendar/cal-client/cal-client-multi.c
blob: aeebc72fda79629dd63a921e5000f5bc6b1fb825 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706





                                            


                                                                   
























































































































































































































































































































































































































































































































































































































































































































                                                                                            
/* 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 <gtk/gtksignal.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);
static void cal_client_multi_destroy    (GtkObject *object);

/* signal IDs */
enum {
    CAL_OPENED,
    OBJ_UPDATED,
    OBJ_REMOVED,
    CATEGORIES_CHANGED,
    FORGET_PASSWORD,
    LAST_SIGNAL
};

static guint cal_multi_signals[LAST_SIGNAL];
static GtkObjectClass *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
 */
GtkType
cal_client_multi_get_type (void)
{
    static GtkType type = 0;

    if (!type) {
        static const GtkTypeInfo info = {
            "CalClientMulti",
            sizeof (CalClientMulti),
            sizeof (CalClientMultiClass),
            (GtkClassInitFunc) cal_client_multi_class_init,
            (GtkObjectInitFunc) cal_client_multi_init,
            NULL,
            NULL,
            (GtkClassInitFunc) NULL
        };

        type = gtk_type_unique (GTK_TYPE_OBJECT, &info);
    }

    return type;
}

/* class initialization function for the multi calendar client */
static void
cal_client_multi_class_init (CalClientMultiClass *klass)
{
    GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);

    parent_class = gtk_type_class (GTK_TYPE_OBJECT);
    
    cal_multi_signals[CAL_OPENED] =
        gtk_signal_new ("cal_opened",
                GTK_RUN_FIRST,
                object_class->type,
                GTK_SIGNAL_OFFSET (CalClientMultiClass, cal_opened),
                gtk_marshal_NONE__POINTER_INT,
                GTK_TYPE_NONE, 2,
                GTK_TYPE_POINTER, GTK_TYPE_ENUM);
    cal_multi_signals[OBJ_UPDATED] =
        gtk_signal_new ("obj_updated",
                GTK_RUN_FIRST,
                object_class->type,
                GTK_SIGNAL_OFFSET (CalClientMultiClass, obj_updated),
                gtk_marshal_NONE__POINTER_POINTER,
                GTK_TYPE_NONE, 2,
                GTK_TYPE_POINTER, GTK_TYPE_STRING);
    cal_multi_signals[OBJ_REMOVED] =
        gtk_signal_new ("obj_removed",
                GTK_RUN_FIRST,
                object_class->type,
                GTK_SIGNAL_OFFSET (CalClientMultiClass, obj_removed),
                gtk_marshal_NONE__POINTER_POINTER,
                GTK_TYPE_NONE, 2,
                GTK_TYPE_POINTER, GTK_TYPE_STRING);
    cal_multi_signals[CATEGORIES_CHANGED] =
        gtk_signal_new ("categories_changed",
                GTK_RUN_FIRST,
                object_class->type,
                GTK_SIGNAL_OFFSET (CalClientMultiClass, categories_changed),
                gtk_marshal_NONE__POINTER_POINTER,
                GTK_TYPE_NONE, 2,
                GTK_TYPE_POINTER, GTK_TYPE_POINTER);
    cal_multi_signals[FORGET_PASSWORD] =
        gtk_signal_new ("forget_password",
                GTK_RUN_FIRST,
                                object_class->type,
                                GTK_SIGNAL_OFFSET (CalClientMultiClass, forget_password),
                                gtk_marshal_NONE__POINTER_POINTER,
                                GTK_TYPE_NONE, 2,
                                GTK_TYPE_STRING, GTK_TYPE_STRING);

    object_class->destroy = cal_client_multi_destroy;
}

/* object initialization function for the multi calendar client */
static void
cal_client_multi_init (CalClientMulti *multi)
{
    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);
    gtk_object_unref (GTK_OBJECT (value));
}

/* destroy handler for the multi calendar client */
static void
cal_client_multi_destroy (GtkObject *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 (GTK_OBJECT_CLASS (parent_class)->destroy)
        (* GTK_OBJECT_CLASS (parent_class)->destroy) (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 = gtk_type_new (CAL_CLIENT_MULTI_TYPE);
    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));

    gtk_signal_emit (GTK_OBJECT (multi),
             cal_multi_signals[CAL_OPENED],
             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));

    gtk_signal_emit (GTK_OBJECT (multi),
             cal_multi_signals[OBJ_UPDATED],
             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));

    gtk_signal_emit (GTK_OBJECT (multi),
             cal_multi_signals[OBJ_REMOVED],
             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));

    gtk_signal_emit (GTK_OBJECT (multi),
             cal_multi_signals[CATEGORIES_CHANGED],
             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));

    gtk_signal_emit (GTK_OBJECT (multi),
             cal_multi_signals[FORGET_PASSWORD],
             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;
    }

    gtk_object_ref (GTK_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 */
    gtk_signal_disconnect_by_data (GTK_OBJECT (client), multi);
    gtk_signal_connect (GTK_OBJECT (client),
                "cal_opened",
                GTK_SIGNAL_FUNC (client_cal_opened_cb),
                multi);
    gtk_signal_connect (GTK_OBJECT (client),
                "obj_updated",
                GTK_SIGNAL_FUNC (client_obj_updated_cb),
                multi);
    gtk_signal_connect (GTK_OBJECT (client),
                "obj_removed",
                GTK_SIGNAL_FUNC (client_obj_removed_cb),
                multi);
    gtk_signal_connect (GTK_OBJECT (client),
                "categories_changed",
                GTK_SIGNAL_FUNC (client_categories_changed_cb),
                multi);
    gtk_signal_connect (GTK_OBJECT (client),
                "forget_password",
                GTK_SIGNAL_FUNC (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);
        gtk_object_unref (GTK_OBJECT (client));
        return client;
    }

    gtk_object_unref (GTK_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;
}