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

« back to all changes in this revision

Viewing changes to calendar/libedata-cal/e-cal-backend-sync.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:
13
13
#include "e-cal-backend-sync.h"
14
14
#include <libical/icaltz-util.h>
15
15
 
 
16
G_DEFINE_TYPE (ECalBackendSync, e_cal_backend_sync, E_TYPE_CAL_BACKEND)
 
17
 
16
18
struct _ECalBackendSyncPrivate {
17
19
        GMutex *sync_mutex;
18
20
 
56
58
 *
57
59
 * Calls the is_read_only method on the given backend.
58
60
 *
59
 
 * Return value: Status code.
 
61
 * Returns: Status code.
60
62
 */
61
63
ECalBackendSyncStatus
62
64
e_cal_backend_sync_is_read_only  (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
79
81
 *
80
82
 * Calls the get_cal_address method on the given backend.
81
83
 *
82
 
 * Return value: Status code.
 
84
 * Returns: Status code.
83
85
 */
84
86
ECalBackendSyncStatus
85
87
e_cal_backend_sync_get_cal_address  (ECalBackendSync *backend, EDataCal *cal, gchar **address)
102
104
 *
103
105
 * Calls the get_alarm_email_address method on the given backend.
104
106
 *
105
 
 * Return value: Status code.
 
107
 * Returns: Status code.
106
108
 */
107
109
ECalBackendSyncStatus
108
110
e_cal_backend_sync_get_alarm_email_address  (ECalBackendSync *backend, EDataCal *cal, gchar **address)
125
127
 *
126
128
 * Calls the get_ldap_attribute method on the given backend.
127
129
 *
128
 
 * Return value: Status code.
 
130
 * Returns: Status code.
129
131
 */
130
132
ECalBackendSyncStatus
131
133
e_cal_backend_sync_get_ldap_attribute  (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
148
150
 *
149
151
 * Calls the get_capabilities method on the given backend.
150
152
 *
151
 
 * Return value: Status code.
 
153
 * Returns: Status code.
152
154
 */
153
155
ECalBackendSyncStatus
154
156
e_cal_backend_sync_get_static_capabilities  (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
174
176
 *
175
177
 * Calls the open method on the given backend.
176
178
 *
177
 
 * Return value: Status code.
 
179
 * Returns: Status code.
178
180
 */
179
181
ECalBackendSyncStatus
180
182
e_cal_backend_sync_open  (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
196
198
 *
197
199
 * Calls the remove method on the given backend.
198
200
 *
199
 
 * Return value: Status code.
 
201
 * Returns: Status code.
200
202
 */
201
203
ECalBackendSyncStatus
202
204
e_cal_backend_sync_remove  (ECalBackendSync *backend, EDataCal *cal)
211
213
}
212
214
 
213
215
/**
 
216
 * e_cal_backend_sync_refresh:
 
217
 * @backend: An ECalBackendSync object.
 
218
 * @cal: An EDataCal object.
 
219
 *
 
220
 * Calls the refresh method on the given backend.
 
221
 *
 
222
 * Returns: Status code.
 
223
 *
 
224
 * Since: 2.30
 
225
 */
 
226
ECalBackendSyncStatus
 
227
e_cal_backend_sync_refresh  (ECalBackendSync *backend, EDataCal *cal)
 
228
{
 
229
        ECalBackendSyncStatus status;
 
230
 
 
231
        g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
 
232
        g_return_val_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->refresh_sync != NULL,
 
233
                              GNOME_Evolution_Calendar_UnsupportedMethod);
 
234
 
 
235
        LOCK_WRAPPER (refresh_sync, (backend, cal));
 
236
 
 
237
        return status;
 
238
}
 
239
 
 
240
/**
214
241
 * e_cal_backend_sync_create_object:
215
242
 * @backend: An ECalBackendSync object.
216
243
 * @cal: An EDataCal object.
219
246
 *
220
247
 * Calls the create_object method on the given backend.
221
248
 *
222
 
 * Return value: Status code.
 
249
 * Returns: Status code.
223
250
 */
224
251
ECalBackendSyncStatus
225
252
e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, gchar **calobj, gchar **uid)
248
275
 *
249
276
 * Calls the modify_object method on the given backend.
250
277
 *
251
 
 * Return value: Status code.
 
278
 * Returns: Status code.
252
279
 */
253
280
ECalBackendSyncStatus
254
281
e_cal_backend_sync_modify_object (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj,
281
308
 *
282
309
 * Calls the remove_object method on the given backend.
283
310
 *
284
 
 * Return value: Status code.
 
311
 * Returns: Status code.
285
312
 */
286
313
ECalBackendSyncStatus
287
314
e_cal_backend_sync_remove_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid,
307
334
 *
308
335
 * Calls the discard_alarm method on the given backend.
309
336
 *
310
 
 * Return value: Status code.
 
337
 * Returns: Status code.
311
338
 */
312
339
ECalBackendSyncStatus
313
340
e_cal_backend_sync_discard_alarm (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
331
358
 *
332
359
 * Calls the receive_objects method on the given backend.
333
360
 *
334
 
 * Return value: Status code.
 
361
 * Returns: Status code.
335
362
 */
336
363
ECalBackendSyncStatus
337
364
e_cal_backend_sync_receive_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj)
357
384
 *
358
385
 * Calls the send_objects method on the given backend.
359
386
 *
360
 
 * Return value: Status code.
 
387
 * Returns: Status code.
361
388
 */
362
389
ECalBackendSyncStatus
363
390
e_cal_backend_sync_send_objects (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, GList **users,
382
409
 *
383
410
 * Calls the get_default_object method on the given backend.
384
411
 *
385
 
 * Return value: Status code.
 
412
 * Returns: Status code.
386
413
 */
387
414
ECalBackendSyncStatus
388
415
e_cal_backend_sync_get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
408
435
 *
409
436
 * Calls the get_object method on the given backend.
410
437
 *
411
 
 * Return value: Status code.
 
438
 * Returns: Status code.
412
439
 */
413
440
ECalBackendSyncStatus
414
441
e_cal_backend_sync_get_object (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, gchar **object)
432
459
 *
433
460
 * Calls the get_object_list method on the given backend.
434
461
 *
435
 
 * Return value: Status code.
 
462
 * Returns: Status code.
436
463
 */
437
464
ECalBackendSyncStatus
438
465
e_cal_backend_sync_get_object_list (ECalBackendSync *backend, EDataCal *cal, const gchar *sexp, GList **objects)
457
484
 *
458
485
 * Calls the get_attachment_list method on the given backend.
459
486
 *
460
 
 * Return value: Status code.
 
487
 * Returns: Status code.
461
488
 */
462
489
ECalBackendSyncStatus
463
490
e_cal_backend_sync_get_attachment_list (ECalBackendSync *backend, EDataCal *cal, const gchar *uid, const gchar *rid, GSList **attachments)
479
506
 * @tzid: ID of the timezone to retrieve.
480
507
 * @object: Placeholder for the returned timezone.
481
508
 *
482
 
 * Calls the get_timezone method on the given backend.
 
509
 * Calls the get_timezone_sync method on the given backend.
 
510
 * This method is not mandatory on the backend, because here
 
511
 * is used internal_get_timezone call to fetch timezone from
 
512
 * it and that is transformed to a string. In other words,
 
513
 * any object deriving from ECalBackendSync can implement only
 
514
 * internal_get_timezone and can skip implementation of
 
515
 * get_timezone_sync completely.
483
516
 *
484
 
 * Return value: Status code.
 
517
 * Returns: Status code.
485
518
 */
486
519
ECalBackendSyncStatus
487
520
e_cal_backend_sync_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
488
521
{
489
 
        ECalBackendSyncStatus status;
 
522
        ECalBackendSyncStatus status = GNOME_Evolution_Calendar_ObjectNotFound;
490
523
 
491
524
        g_return_val_if_fail (E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError);
492
525
 
493
 
        LOCK_WRAPPER (get_timezone_sync, (backend, cal, tzid, object));
 
526
        if (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->get_timezone_sync) {
 
527
                LOCK_WRAPPER (get_timezone_sync, (backend, cal, tzid, object));
 
528
        }
 
529
 
 
530
        if (object && !*object) {
 
531
                icaltimezone *zone = NULL;
 
532
 
 
533
                if (backend->priv->mutex_lock)
 
534
                        g_mutex_lock (backend->priv->sync_mutex);
 
535
                zone = e_cal_backend_internal_get_timezone (E_CAL_BACKEND (backend), tzid);
 
536
                if (backend->priv->mutex_lock)
 
537
                        g_mutex_unlock (backend->priv->sync_mutex);
 
538
 
 
539
                if (!zone) {
 
540
                        status = GNOME_Evolution_Calendar_ObjectNotFound;
 
541
                } else {
 
542
                        icalcomponent *icalcomp;
 
543
 
 
544
                        icalcomp = icaltimezone_get_component (zone);
 
545
 
 
546
                        if (!icalcomp) {
 
547
                                status = GNOME_Evolution_Calendar_InvalidObject;
 
548
                        } else {
 
549
                                *object = icalcomponent_as_ical_string_r (icalcomp);
 
550
                                status = GNOME_Evolution_Calendar_Success;
 
551
                        }
 
552
                }
 
553
        }
494
554
 
495
555
        return status;
496
556
}
503
563
 *
504
564
 * Calls the add_timezone method on the given backend.
505
565
 *
506
 
 * Return value: Status code.
 
566
 * Returns: Status code.
507
567
 */
508
568
ECalBackendSyncStatus
509
569
e_cal_backend_sync_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
525
585
 *
526
586
 * Calls the set_default_timezone method on the given backend.
527
587
 *
528
 
 * Return value: Status code.
 
588
 * Returns: Status code.
529
589
 */
530
590
ECalBackendSyncStatus
531
591
e_cal_backend_sync_set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tz)
569
629
 *
570
630
 * Calls the set_default_timezone method on the given backend.
571
631
 *
572
 
 * Return value: Status code.
 
632
 * Returns: Status code.
573
633
 */
574
634
ECalBackendSyncStatus
575
635
e_cal_backend_sync_set_default_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid)
594
654
 *
595
655
 * Calls the get_changes method on the given backend.
596
656
 *
597
 
 * Return value: Status code.
 
657
 * Returns: Status code.
598
658
 */
599
659
ECalBackendSyncStatus
600
660
e_cal_backend_sync_get_changes (ECalBackendSync *backend, EDataCal *cal, const gchar *change_id,
620
680
 *
621
681
 * Calls the get_free_busy method on the given backend.
622
682
 *
623
 
 * Return value: Status code.
 
683
 * Returns: Status code.
624
684
 */
625
685
ECalBackendSyncStatus
626
686
e_cal_backend_sync_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GList *users,
647
707
}
648
708
 
649
709
static void
650
 
_e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal)
 
710
_e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
651
711
{
652
712
        ECalBackendSyncStatus status;
653
713
        gchar *address = NULL;
654
714
 
655
715
        status = e_cal_backend_sync_get_cal_address (E_CAL_BACKEND_SYNC (backend), cal, &address);
656
716
 
657
 
        e_data_cal_notify_cal_address (cal, status, address);
 
717
        e_data_cal_notify_cal_address (cal, context, status, address);
658
718
 
659
719
        g_free (address);
660
720
}
661
721
 
662
722
static void
663
 
_e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal)
 
723
_e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
664
724
{
665
725
        ECalBackendSyncStatus status;
666
726
        gchar *address = NULL;
667
727
 
668
728
        status = e_cal_backend_sync_get_alarm_email_address (E_CAL_BACKEND_SYNC (backend), cal, &address);
669
729
 
670
 
        e_data_cal_notify_alarm_email_address (cal, status, address);
 
730
        e_data_cal_notify_alarm_email_address (cal, context, status, address);
671
731
 
672
732
        g_free (address);
673
733
}
674
734
 
675
735
static void
676
 
_e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal)
 
736
_e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
677
737
{
678
738
        ECalBackendSyncStatus status;
679
739
        gchar *attribute = NULL;
680
740
 
681
741
        status = e_cal_backend_sync_get_ldap_attribute (E_CAL_BACKEND_SYNC (backend), cal, &attribute);
682
742
 
683
 
        e_data_cal_notify_ldap_attribute (cal, status, attribute);
 
743
        e_data_cal_notify_ldap_attribute (cal, context, status, attribute);
684
744
 
685
745
        g_free (attribute);
686
746
}
687
747
 
688
748
static void
689
 
_e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal)
 
749
_e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
690
750
{
691
751
        ECalBackendSyncStatus status;
692
752
        gchar *capabilities = NULL;
693
753
 
694
754
        status = e_cal_backend_sync_get_static_capabilities (E_CAL_BACKEND_SYNC (backend), cal, &capabilities);
695
755
 
696
 
        e_data_cal_notify_static_capabilities (cal, status, capabilities);
 
756
        e_data_cal_notify_static_capabilities (cal, context, status, capabilities);
697
757
 
698
758
        g_free (capabilities);
699
759
}
700
760
 
701
761
static void
702
 
_e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists,
 
762
_e_cal_backend_open (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, gboolean only_if_exists,
703
763
                     const gchar *username, const gchar *password)
704
764
{
705
765
        ECalBackendSyncStatus status;
706
766
 
707
767
        status = e_cal_backend_sync_open (E_CAL_BACKEND_SYNC (backend), cal, only_if_exists, username, password);
708
768
 
709
 
        e_data_cal_notify_open (cal, status);
710
 
}
711
 
 
712
 
static void
713
 
_e_cal_backend_remove (ECalBackend *backend, EDataCal *cal)
 
769
        e_data_cal_notify_open (cal, context, status);
 
770
}
 
771
 
 
772
static void
 
773
_e_cal_backend_refresh (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
 
774
{
 
775
        ECalBackendSyncStatus status;
 
776
 
 
777
        status = e_cal_backend_sync_refresh (E_CAL_BACKEND_SYNC (backend), cal);
 
778
 
 
779
        e_data_cal_notify_refresh (cal, context, status);
 
780
}
 
781
 
 
782
static void
 
783
_e_cal_backend_remove (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
714
784
{
715
785
        ECalBackendSyncStatus status;
716
786
 
717
787
        status = e_cal_backend_sync_remove (E_CAL_BACKEND_SYNC (backend), cal);
718
788
 
719
 
        e_data_cal_notify_remove (cal, status);
 
789
        e_data_cal_notify_remove (cal, context, status);
720
790
}
721
791
 
722
792
static void
723
 
_e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
 
793
_e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
724
794
{
725
795
        ECalBackendSyncStatus status;
726
796
        gchar *uid = NULL, *modified_calobj = (gchar *) calobj;
727
797
 
728
798
        status = e_cal_backend_sync_create_object (E_CAL_BACKEND_SYNC (backend), cal, &modified_calobj, &uid);
729
799
 
730
 
        e_data_cal_notify_object_created (cal, status, uid, modified_calobj);
 
800
        e_data_cal_notify_object_created (cal, context, status, uid, modified_calobj);
731
801
 
732
802
        /* free memory */
733
803
        if (uid)
738
808
}
739
809
 
740
810
static void
741
 
_e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod)
 
811
_e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj, CalObjModType mod)
742
812
{
743
813
        ECalBackendSyncStatus status;
744
814
        gchar *old_object = NULL;
748
818
                                                   calobj, mod, &old_object, &new_object);
749
819
 
750
820
        if (new_object)
751
 
                e_data_cal_notify_object_modified (cal, status, old_object, new_object);
 
821
                e_data_cal_notify_object_modified (cal, context, status, old_object, new_object);
752
822
        else
753
 
                e_data_cal_notify_object_modified (cal, status, old_object, calobj);
 
823
                e_data_cal_notify_object_modified (cal, context, status, old_object, calobj);
754
824
 
755
825
        g_free (old_object);
756
826
        g_free (new_object);
757
827
}
758
828
 
759
829
static void
760
 
_e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid, CalObjModType mod)
 
830
_e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid, CalObjModType mod)
761
831
{
762
832
        ECalBackendSyncStatus status;
763
833
        gchar *object = NULL, *old_object = NULL;
773
843
                        id->rid = g_strdup (rid);
774
844
 
775
845
                if (!object)
776
 
                        e_data_cal_notify_object_removed (cal, status, id, old_object, object);
 
846
                        e_data_cal_notify_object_removed (cal, context, status, id, old_object, object);
777
847
                else
778
 
                        e_data_cal_notify_object_modified (cal, status, old_object, object);
 
848
                        e_data_cal_notify_object_modified (cal, context, status, old_object, object);
779
849
 
780
850
                e_cal_component_free_id (id);
781
851
        } else
782
 
                e_data_cal_notify_object_removed (cal, status, NULL, old_object, object);
 
852
                e_data_cal_notify_object_removed (cal, context, status, NULL, old_object, object);
783
853
 
784
854
        g_free (old_object);
785
855
        g_free (object);
786
856
}
787
857
 
788
858
static void
789
 
_e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *auid)
 
859
_e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *auid)
790
860
{
791
861
        ECalBackendSyncStatus status;
792
862
 
793
863
        status = e_cal_backend_sync_discard_alarm (E_CAL_BACKEND_SYNC (backend), cal, uid, auid);
794
864
 
795
 
        e_data_cal_notify_alarm_discarded (cal, status);
 
865
        e_data_cal_notify_alarm_discarded (cal, context, status);
796
866
}
797
867
 
798
868
static void
799
 
_e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
 
869
_e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
800
870
{
801
871
        ECalBackendSyncStatus status;
802
872
 
803
873
        status = e_cal_backend_sync_receive_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj);
804
874
 
805
 
        e_data_cal_notify_objects_received (cal, status);
 
875
        e_data_cal_notify_objects_received (cal, context, status);
806
876
}
807
877
 
808
878
static void
809
 
_e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj)
 
879
_e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *calobj)
810
880
{
811
881
        ECalBackendSyncStatus status;
812
882
        GList *users = NULL;
813
883
        gchar *modified_calobj = NULL;
814
884
 
815
885
        status = e_cal_backend_sync_send_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj, &users, &modified_calobj);
816
 
        e_data_cal_notify_objects_sent (cal, status, users, modified_calobj);
 
886
        e_data_cal_notify_objects_sent (cal, context, status, users, modified_calobj);
817
887
 
818
888
        g_list_foreach (users, (GFunc) g_free, NULL);
819
889
        g_list_free (users);
821
891
}
822
892
 
823
893
static void
824
 
_e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal)
 
894
_e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context)
825
895
{
826
896
        ECalBackendSyncStatus status;
827
897
        gchar *object = NULL;
828
898
 
829
899
        status = e_cal_backend_sync_get_default_object (E_CAL_BACKEND_SYNC (backend), cal, &object);
830
900
 
831
 
        e_data_cal_notify_default_object (cal, status, object);
 
901
        e_data_cal_notify_default_object (cal, context, status, object);
832
902
 
833
903
        g_free (object);
834
904
}
835
905
 
836
906
static void
837
 
_e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid)
 
907
_e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
838
908
{
839
909
        ECalBackendSyncStatus status;
840
910
        gchar *object = NULL;
841
911
 
842
912
        status = e_cal_backend_sync_get_object (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &object);
843
913
 
844
 
        e_data_cal_notify_object (cal, status, object);
 
914
        e_data_cal_notify_object (cal, context, status, object);
845
915
 
846
916
        g_free (object);
847
917
}
848
918
 
849
919
static void
850
 
_e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, const gchar *uid, const gchar *rid)
 
920
_e_cal_backend_get_attachment_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *uid, const gchar *rid)
851
921
{
852
922
        ECalBackendSyncStatus status;
853
923
        GSList *list = NULL;
854
924
 
855
925
        status = e_cal_backend_sync_get_attachment_list (E_CAL_BACKEND_SYNC (backend), cal, uid, rid, &list);
856
926
 
857
 
        e_data_cal_notify_attachment_list (cal, status, list);
 
927
        e_data_cal_notify_attachment_list (cal, context, status, list);
858
928
 
859
929
        g_slist_foreach (list, (GFunc) g_free, NULL);
860
930
        g_free (list);
861
931
}
862
932
 
863
933
static void
864
 
_e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const gchar *sexp)
 
934
_e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *sexp)
865
935
{
866
936
        ECalBackendSyncStatus status;
867
937
        GList *objects = NULL, *l;
868
938
 
869
939
        status = e_cal_backend_sync_get_object_list (E_CAL_BACKEND_SYNC (backend), cal, sexp, &objects);
870
940
 
871
 
        e_data_cal_notify_object_list (cal, status, objects);
 
941
        e_data_cal_notify_object_list (cal, context, status, objects);
872
942
 
873
943
        for (l = objects; l; l = l->next)
874
944
                g_free (l->data);
876
946
}
877
947
 
878
948
static void
879
 
_e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid)
 
949
_e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
880
950
{
881
951
        ECalBackendSyncStatus status;
882
952
        gchar *object = NULL;
929
999
                        e_cal_backend_sync_add_timezone (E_CAL_BACKEND_SYNC (backend), cal, object);
930
1000
        }
931
1001
 
932
 
        e_data_cal_notify_timezone_requested (cal, status, object);
 
1002
        e_data_cal_notify_timezone_requested (cal, context, status, object);
933
1003
 
934
1004
        g_free (object);
935
1005
}
936
1006
 
937
1007
static void
938
 
_e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzobj)
 
1008
_e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzobj)
939
1009
{
940
1010
        ECalBackendSyncStatus status;
941
1011
 
942
1012
        status = e_cal_backend_sync_add_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzobj);
943
1013
 
944
 
        e_data_cal_notify_timezone_added (cal, status, tzobj);
 
1014
        e_data_cal_notify_timezone_added (cal, context, status, tzobj);
945
1015
}
946
1016
 
 
1017
/* The default implementation is looking for timezone in the ical's builtin timezones,
 
1018
   and if that fails, then it tries to extract the location from the tzid and get the
 
1019
   timezone based on it. If even that fails, then it's returning UTC timezone.
 
1020
   That means, that any object deriving from ECalBackendSync is supposed to implement
 
1021
   this function for checking for a timezone in its own timezone cache, and if that
 
1022
   fails, then call parent's object internal_get_timezone, and that's all.
 
1023
 */
947
1024
static icaltimezone *
948
1025
_e_cal_backend_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
949
1026
{
950
 
        gint i, slashes = 0;
 
1027
        icaltimezone *zone = NULL;
951
1028
 
952
1029
        if (!tzid || !*tzid)
953
1030
                return NULL;
954
1031
 
955
 
        for (i = 0; tzid [i]; i++) {
956
 
                if (tzid [i] == '/')
957
 
                        slashes++;
 
1032
        zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
 
1033
 
 
1034
        if (!zone) {
 
1035
                const gchar *s, *slash1 = NULL, *slash2 = NULL;
 
1036
 
 
1037
                /* get builtin by a location, if any */
 
1038
                for (s = tzid; *s; s++) {
 
1039
                        if (*s == '/') {
 
1040
                                slash1 = slash2;
 
1041
                                slash2 = s;
 
1042
                        }
 
1043
                }
 
1044
 
 
1045
                if (slash1)
 
1046
                        zone = icaltimezone_get_builtin_timezone (slash1 + 1);
 
1047
                else if (slash2)
 
1048
                        zone = icaltimezone_get_builtin_timezone (tzid);
958
1049
        }
959
1050
 
960
 
        /* try if it contains only location of the timezone */
961
 
        return slashes == 1 ? icaltimezone_get_builtin_timezone (tzid) : NULL;
 
1051
        if (!zone)
 
1052
                zone = icaltimezone_get_utc_timezone ();
 
1053
 
 
1054
        return zone;
962
1055
}
963
1056
 
964
1057
static void
965
 
_e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, const gchar *tz)
 
1058
_e_cal_backend_set_default_zone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tz)
966
1059
{
967
1060
        ECalBackendSyncStatus status;
968
1061
 
969
1062
        status = e_cal_backend_sync_set_default_zone (E_CAL_BACKEND_SYNC (backend), cal, tz);
970
1063
 
971
 
        e_data_cal_notify_default_timezone_set (cal, status);
 
1064
        e_data_cal_notify_default_timezone_set (cal, context, status);
972
1065
}
973
1066
 
974
1067
static void
975
 
_e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const gchar *tzid)
 
1068
_e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *tzid)
976
1069
{
977
1070
        ECalBackendSyncStatus status;
978
1071
 
979
1072
        status = e_cal_backend_sync_set_default_timezone (E_CAL_BACKEND_SYNC (backend), cal, tzid);
980
1073
 
981
 
        e_data_cal_notify_default_timezone_set (cal, status);
 
1074
        e_data_cal_notify_default_timezone_set (cal, context, status);
982
1075
}
983
1076
 
984
1077
static void
985
 
_e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const gchar *change_id)
 
1078
_e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, const gchar *change_id)
986
1079
{
987
1080
        ECalBackendSyncStatus status;
988
1081
        GList *adds = NULL, *modifies = NULL, *deletes = NULL, *l;
990
1083
        status = e_cal_backend_sync_get_changes (E_CAL_BACKEND_SYNC (backend), cal, change_id,
991
1084
                                               &adds, &modifies, &deletes);
992
1085
 
993
 
        e_data_cal_notify_changes (cal, status, adds, modifies, deletes);
 
1086
        e_data_cal_notify_changes (cal, context, status, adds, modifies, deletes);
994
1087
 
995
1088
        for (l = adds; l; l = l->next)
996
1089
                g_free (l->data);
1006
1099
}
1007
1100
 
1008
1101
static void
1009
 
_e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users, time_t start, time_t end)
 
1102
_e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, EServerMethodContext context, GList *users, time_t start, time_t end)
1010
1103
{
1011
1104
        ECalBackendSyncStatus status;
1012
1105
        GList *freebusy = NULL, *l;
1013
1106
 
1014
1107
        status = e_cal_backend_sync_get_free_busy (E_CAL_BACKEND_SYNC (backend), cal, users, start, end, &freebusy);
1015
1108
 
1016
 
        e_data_cal_notify_free_busy (cal, status, freebusy);
 
1109
        e_data_cal_notify_free_busy (cal, context, status, freebusy);
1017
1110
 
1018
1111
        for (l = freebusy; l; l = l->next)
1019
1112
                g_free (l->data);
1064
1157
        backend_class->get_ldap_attribute = _e_cal_backend_get_ldap_attribute;
1065
1158
        backend_class->get_static_capabilities = _e_cal_backend_get_static_capabilities;
1066
1159
        backend_class->open = _e_cal_backend_open;
 
1160
        backend_class->refresh = _e_cal_backend_refresh;
1067
1161
        backend_class->remove = _e_cal_backend_remove;
1068
1162
        backend_class->create_object = _e_cal_backend_create_object;
1069
1163
        backend_class->modify_object = _e_cal_backend_modify_object;
1085
1179
 
1086
1180
        object_class->dispose = e_cal_backend_sync_dispose;
1087
1181
}
1088
 
 
1089
 
/**
1090
 
 * e_cal_backend_get_type:
1091
 
 *
1092
 
 * Registers the ECalBackendSync class if needed.
1093
 
 *
1094
 
 * Return value: The ID of the ECalBackendSync class.
1095
 
 */
1096
 
GType
1097
 
e_cal_backend_sync_get_type (void)
1098
 
{
1099
 
        static GType type = 0;
1100
 
 
1101
 
        if (! type) {
1102
 
                GTypeInfo info = {
1103
 
                        sizeof (ECalBackendSyncClass),
1104
 
                        NULL, /* base_class_init */
1105
 
                        NULL, /* base_class_finalize */
1106
 
                        (GClassInitFunc)  e_cal_backend_sync_class_init,
1107
 
                        NULL, /* class_finalize */
1108
 
                        NULL, /* class_data */
1109
 
                        sizeof (ECalBackendSync),
1110
 
                        0,    /* n_preallocs */
1111
 
                        (GInstanceInitFunc) e_cal_backend_sync_init
1112
 
                };
1113
 
 
1114
 
                type = g_type_register_static (E_TYPE_CAL_BACKEND, "ECalBackendSync", &info, 0);
1115
 
        }
1116
 
 
1117
 
        return type;
1118
 
}