~ubuntu-branches/ubuntu/natty/evolution-exchange/natty

« back to all changes in this revision

Viewing changes to calendar/e-cal-backend-exchange.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Trudel-Lapierre, Didier Roche, Mathieu Trudel-Lapierre
  • Date: 2010-11-03 16:17:46 UTC
  • mfrom: (1.1.68 upstream)
  • Revision ID: james.westby@ubuntu.com-20101103161746-rs4gpelhc6hc3yxi
Tags: 2.32.0-0ubuntu1
[ Didier Roche ]
* debian/rules:
  - add debug flag for helping upstream to get more info
    (--with-ek2-debug) (LP: #660034)
* debian/patches/01_try_fixing_duplicate_symbols.patch, debian/rules:
  - disabling stripping -Bsymbolic-functions and set some lib as private lib
    to hopefully avoid duplicate symbols. That needs confirmation by people
    having this setup.

[ Mathieu Trudel-Lapierre ]
* new upstream release 2.32.0
  - Evolution forgets password on any error (LP: #245589, #272414)
  - Appointments don't display in Windows Mobile 5 (LP: #115913, #141231)
  - Properly free unused message infos periodically (LP: #507972)
* debian/patches/90_disable_deprecation_warning.patch: refreshed
* debian/control: bump (Build-)Depends for evolution packages to 2.32.0
* debian/control: bump libgtk2.0-dev Build-Depends to 2.20.0
* debian/patches/92_lresolv_detection.patch: look harder to see whether we
  should link with -lresolv. This fixes build failures on Natty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <string.h>
30
30
#include <unistd.h>
31
31
#include <libedataserver/e-time-utils.h>
 
32
#include <libedataserver/e-data-server-util.h>
32
33
 
33
34
#include <glib.h>
34
35
#include <gio/gio.h>
35
36
#include <glib/gstdio.h>
36
37
 
37
 
#include <camel/camel-mime-message.h>
38
 
#include <camel/camel-multipart.h>
39
 
#include <camel/camel-stream-mem.h>
40
 
#include <camel/camel-file-utils.h>
 
38
#include <camel/camel.h>
41
39
 
42
40
#include "e-cal-backend-exchange.h"
43
41
#include "e2k-cal-utils.h"
87
85
static icaltimezone *
88
86
internal_get_timezone (ECalBackend *backend, const gchar *tzid);
89
87
 
90
 
static ECalBackendSyncStatus
91
 
is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
 
88
static void
 
89
is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror)
92
90
{
93
91
        ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
94
92
 
95
93
        d(printf("ecbe_is_read_only(%p, %p) -> %d\n", backend, cal, cbex->priv->read_only));
96
94
 
97
95
        *read_only = cbex->priv->read_only;
98
 
        return GNOME_Evolution_Calendar_Success;
99
96
}
100
97
 
101
 
static ECalBackendSyncStatus
102
 
get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
 
98
static void
 
99
get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
103
100
{
104
101
        ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
105
102
        ExchangeHierarchy *hier;
107
104
        hier = e_folder_exchange_get_hierarchy (cbex->folder);
108
105
        d(printf("ecbe_get_cal_address(%p, %p) -> %s\n", backend, cal, hier->owner_email));
109
106
        *address = g_strdup (hier->owner_email);
110
 
 
111
 
        return GNOME_Evolution_Calendar_Success;
112
107
}
113
108
 
114
109
static void
123
118
        *name = g_strdup (hier->owner_name);
124
119
}
125
120
 
126
 
static ECalBackendSyncStatus
127
 
get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
 
121
static void
 
122
get_alarm_email_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
128
123
{
129
124
        d(printf("ecbe_get_alarm_email_address(%p, %p)\n", backend, cal));
130
125
 
132
127
         * This should not have been called.
133
128
         */
134
129
        *address = NULL;
135
 
        return GNOME_Evolution_Calendar_OtherError;
 
130
 
 
131
        g_propagate_error (perror, EDC_ERROR (NotSupported));
136
132
}
137
133
 
138
 
static ECalBackendSyncStatus
139
 
get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
 
134
static void
 
135
get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **perror)
140
136
{
141
137
        d(printf("ecbe_get_ldap_attribute(%p, %p)\n", backend, cal));
142
138
 
143
 
        if (!attribute)
144
 
                return GNOME_Evolution_Calendar_InvalidObject;
 
139
        if (!attribute) {
 
140
                g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
141
                return;
 
142
        }
145
143
 
146
144
        /* This is just a hack for SunONE */
147
145
        *attribute = NULL;
148
 
        return GNOME_Evolution_Calendar_Success;
149
146
}
150
147
 
151
 
static ECalBackendSyncStatus
152
 
get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
 
148
static void
 
149
get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **perror)
153
150
{
154
151
        d(printf("ecbe_get_static_capabilities(%p, %p)\n", backend, cal));
155
152
 
159
156
                CAL_STATIC_CAPABILITY_NO_THISANDFUTURE ","
160
157
                CAL_STATIC_CAPABILITY_NO_THISANDPRIOR ","
161
158
                CAL_STATIC_CAPABILITY_REMOVE_ALARMS);
162
 
 
163
 
        return GNOME_Evolution_Calendar_Success;
164
159
}
165
160
 
166
 
static ECalBackendSyncStatus
167
 
load_cache (ECalBackendExchange *cbex, E2kUri *e2kuri)
 
161
static gboolean
 
162
load_cache (ECalBackendExchange *cbex, E2kUri *e2kuri, GError **perror)
168
163
{
169
164
        icalcomponent *vcalcomp, *comp, *tmp_comp;
170
165
        struct icaltimetype comp_last_mod, folder_last_mod;
171
166
        icalcomponent_kind kind;
172
167
        icalproperty *prop;
173
168
        gchar *lastmod, *mangled_uri, *storage_dir;
 
169
        const gchar *user_cache_dir;
174
170
        const gchar *uristr;
175
171
        gint i;
176
172
        struct stat buf;
180
176
                e_folder_exchange_get_storage_file (cbex->folder, "cache.ics");
181
177
        if (!cbex->priv->object_cache_file) {
182
178
                printf ("could not load cache for %s\n", uristr);
183
 
                return GNOME_Evolution_Calendar_OfflineUnavailable;
 
179
                g_propagate_error (perror, EDC_ERROR (OfflineUnavailable));
 
180
                return FALSE;
184
181
        }
185
182
 
186
183
        /* Fixme : Try avoiding to do this everytime we come here */
198
195
                        mangled_uri[i] = '_';
199
196
                }
200
197
        }
201
 
        cbex->priv->local_attachment_store = g_strdup_printf ("%s/.evolution/exchange/%s", g_get_home_dir (), mangled_uri);
 
198
 
 
199
        user_cache_dir = e_get_user_cache_dir ();
 
200
        cbex->priv->local_attachment_store = g_build_filename (
 
201
                user_cache_dir, "calendar", mangled_uri, NULL);
202
202
        storage_dir = g_path_get_dirname (cbex->priv->object_cache_file);
203
203
 
204
204
        if (g_lstat(cbex->priv->local_attachment_store , &buf) < 0) {
217
217
       /* Check if the cache file is present. If it is not present the account might
218
218
          be newly created one. It will be created while save the cache */
219
219
       if (!g_file_test (cbex->priv->object_cache_file, G_FILE_TEST_EXISTS))
220
 
               return GNOME_Evolution_Calendar_Success;
 
220
               return TRUE;
221
221
 
222
222
        vcalcomp = e_cal_util_parse_ics_file (cbex->priv->object_cache_file);
223
 
        if (!vcalcomp)
224
 
                return GNOME_Evolution_Calendar_InvalidObject;
 
223
        if (!vcalcomp) {
 
224
                g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
225
                return FALSE;
 
226
        }
225
227
 
226
228
        if (icalcomponent_isa (vcalcomp) != ICAL_VCALENDAR_COMPONENT) {
227
229
                icalcomponent_free (vcalcomp);
228
 
                return GNOME_Evolution_Calendar_InvalidObject;
 
230
                g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
231
                return FALSE;
229
232
        }
230
233
 
231
234
        kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbex));
252
255
             comp = icalcomponent_get_next_component (vcalcomp, ICAL_VTIMEZONE_COMPONENT)) {
253
256
                tmp_comp = icalcomponent_new_clone (comp);
254
257
                if (tmp_comp) {
255
 
                        e_cal_backend_exchange_add_timezone (cbex, tmp_comp);
 
258
                        e_cal_backend_exchange_add_timezone (cbex, tmp_comp, perror);
256
259
                        icalcomponent_free (tmp_comp);
257
260
                }
258
261
        }
259
262
 
260
263
        icalcomponent_free (vcalcomp);
261
 
        return GNOME_Evolution_Calendar_Success;
 
264
        return !perror || !*perror;
262
265
}
263
266
 
264
267
static void
339
342
                                                     cbex);
340
343
}
341
344
 
342
 
static ECalBackendSyncStatus
 
345
static void
343
346
open_calendar (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
344
 
               const gchar *username, const gchar *password)
 
347
               const gchar *username, const gchar *password, GError **perror)
345
348
{
346
349
        ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
347
350
        const gchar *uristr;
349
352
        ExchangeAccountResult acresult;
350
353
        const gchar *prop = PR_ACCESS;
351
354
        E2kHTTPStatus status;
352
 
        ECalBackendSyncStatus load_status;
 
355
        gboolean load_result;
353
356
        E2kResult *results;
354
357
        E2kUri *euri = NULL;
355
358
        gint nresults = 0;
373
376
 
374
377
                if (!display_contents || !g_str_equal (display_contents, "1")) {
375
378
                        g_mutex_unlock (cbex->priv->open_lock);
376
 
                        return GNOME_Evolution_Calendar_RepositoryOffline;
 
379
                        g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
 
380
                        return;
377
381
                }
378
382
 
379
383
                cbex->account = exchange_share_config_listener_get_account_for_uri (NULL, uristr);
387
391
 
388
392
                if (cbex->priv->is_loaded) {
389
393
                        g_mutex_unlock (cbex->priv->open_lock);
390
 
                        return GNOME_Evolution_Calendar_Success;
 
394
                        return;
391
395
                }
392
396
 
393
397
                euri = e2k_uri_new (uristr);
394
 
                load_status = load_cache (cbex, euri);
 
398
                load_result = load_cache (cbex, euri, perror);
395
399
                e2k_uri_free (euri);
396
400
 
397
 
                if (load_status == GNOME_Evolution_Calendar_Success)
 
401
                if (load_result)
398
402
                        cbex->priv->is_loaded = TRUE;
399
403
                g_mutex_unlock (cbex->priv->open_lock);
400
 
                return load_status;
 
404
                return;
401
405
        }
402
406
 
403
407
        /* What else to check */
404
408
        if (cbex->priv->is_loaded && cbex->account && exchange_account_get_context (cbex->account)) {
405
409
                g_mutex_unlock (cbex->priv->open_lock);
406
 
                return GNOME_Evolution_Calendar_Success;
 
410
                return;
407
411
        }
408
412
 
409
413
        /* Make sure we have an open connection */
414
418
 
415
419
        if (!cbex->account) {
416
420
                g_mutex_unlock (cbex->priv->open_lock);
417
 
                return GNOME_Evolution_Calendar_NoSuchCal;
 
421
                g_propagate_error (perror, EDC_ERROR (NoSuchCal));
 
422
                return;
418
423
        }
419
424
 
420
425
        exchange_account_set_online (cbex->account);
422
427
        exchange_account_connect (cbex->account, password, &acresult);
423
428
        if (acresult != EXCHANGE_ACCOUNT_CONNECT_SUCCESS) {
424
429
                g_mutex_unlock (cbex->priv->open_lock);
425
 
                e_cal_backend_notify_error (E_CAL_BACKEND (cbex), _("Authentication failed"));
426
 
                return GNOME_Evolution_Calendar_AuthenticationFailed;
 
430
                g_propagate_error (perror, EDC_ERROR (AuthenticationFailed));
 
431
                return;
427
432
        }
428
433
 
429
434
        cbex->folder = exchange_account_get_folder (cbex->account, uristr);
444
449
 
445
450
                        path = strrchr (uristr, ';');
446
451
                        split_path = g_strsplit (++path, "/", -1);
447
 
                        email = split_path [0];
 
452
                        email = split_path[0];
448
453
 
449
454
                        exchange_account_scan_foreign_hierarchy (cbex->account, email);
450
455
 
461
466
                        hier_to_rescan = exchange_account_get_hierarchy_by_type (cbex->account, EXCHANGE_HIERARCHY_PERSONAL);
462
467
                        if (!hier_to_rescan) {
463
468
                                g_mutex_unlock (cbex->priv->open_lock);
464
 
                                return GNOME_Evolution_Calendar_RepositoryOffline;
 
469
                                g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
 
470
                                return;
465
471
                        }
466
472
                }
467
473
 
473
479
                        g_object_unref (hier_to_rescan->toplevel);
474
480
 
475
481
                        cbex->folder = exchange_account_get_folder (cbex->account, uristr);
476
 
                        if (!cbex->folder)
477
 
                                e_cal_backend_notify_error (E_CAL_BACKEND (cbex), _("Could not find the calendar"));
478
482
                }
479
483
 
480
484
                if (!cbex->folder) {
481
485
                        g_mutex_unlock (cbex->priv->open_lock);
482
 
                        return GNOME_Evolution_Calendar_NoSuchCal;
 
486
                        g_propagate_error (perror, EDC_ERROR (NoSuchCal));
 
487
                        return;
483
488
                }
484
489
        }
485
490
        g_object_ref (cbex->folder);
505
510
                g_mutex_unlock (cbex->priv->open_lock);
506
511
                if (nresults)
507
512
                        e2k_results_free (results, nresults);
508
 
                return GNOME_Evolution_Calendar_PermissionDenied;
 
513
                g_propagate_error (perror, EDC_ERROR (PermissionDenied));
 
514
                return;
509
515
        }
510
516
 
511
517
        cbex->priv->read_only = ((access & MAPI_ACCESS_CREATE_CONTENTS) == 0);
512
518
 
513
 
        load_status = load_cache (cbex, euri);
514
 
 
515
 
        if (load_status == GNOME_Evolution_Calendar_Success)
 
519
        if (load_cache (cbex, euri, perror))
516
520
                cbex->priv->is_loaded = TRUE;
517
521
 
518
522
        g_mutex_unlock (cbex->priv->open_lock);
519
523
 
520
524
        if (nresults)
521
525
                e2k_results_free (results, nresults);
522
 
        return load_status;
523
526
}
524
527
 
525
 
static ECalBackendSyncStatus
526
 
remove_calendar (ECalBackendSync *backend, EDataCal *cal)
 
528
static void
 
529
remove_calendar (ECalBackendSync *backend, EDataCal *cal, GError **perror)
527
530
{
528
531
        ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
529
532
        ExchangeAccountFolderResult result;
534
537
        /* If we do not have a folder, then that means there is no corresponding folder on the server,
535
538
           thus pretend we removed it successfully. It's not there anyway, thus should be fine. */
536
539
        if (!cbex->folder)
537
 
                return GNOME_Evolution_Calendar_Success;
 
540
                return;
538
541
 
539
542
        uri = e_folder_exchange_get_internal_uri (cbex->folder);
540
543
        result = exchange_account_remove_folder (cbex->account, uri);
541
544
        if (result == EXCHANGE_ACCOUNT_FOLDER_OK)
542
 
                return GNOME_Evolution_Calendar_Success;
 
545
                /* Success */;
543
546
        else if (result == EXCHANGE_ACCOUNT_FOLDER_DOES_NOT_EXIST)
544
 
                return GNOME_Evolution_Calendar_NoSuchCal;
 
547
                g_propagate_error (perror, EDC_ERROR (NoSuchCal));
545
548
        else if (result == EXCHANGE_ACCOUNT_FOLDER_UNSUPPORTED_OPERATION)
546
 
                return GNOME_Evolution_Calendar_PermissionDenied;
 
549
                g_propagate_error (perror, EDC_ERROR (PermissionDenied));
547
550
        else if (result == EXCHANGE_ACCOUNT_FOLDER_OFFLINE)
548
 
                return GNOME_Evolution_Calendar_OfflineUnavailable;
 
551
                g_propagate_error (perror, EDC_ERROR (OfflineUnavailable));
549
552
        else if (result == EXCHANGE_ACCOUNT_FOLDER_PERMISSION_DENIED)
550
 
                return GNOME_Evolution_Calendar_PermissionDenied;
 
553
                g_propagate_error (perror, EDC_ERROR (PermissionDenied));
551
554
        else
552
 
                return GNOME_Evolution_Calendar_OtherError;
 
555
                g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "Failed with FolderResult %d", result));
553
556
}
554
557
 
555
558
static void
591
594
                rtime = e2k_parse_timestamp (rid);
592
595
                new_rid = icaltime_from_timet (rtime, FALSE);
593
596
 
594
 
                f_zone = internal_get_timezone ((ECalBackend *) cbex, recur_id.datetime.tzid);
 
597
                f_zone = (recur_id.datetime.tzid && *recur_id.datetime.tzid) ? internal_get_timezone ((ECalBackend *) cbex, recur_id.datetime.tzid) : icaltimezone_get_utc_timezone ();
595
598
                recur_id.datetime.value->zone = f_zone;
596
599
                inst_rid = icaltime_convert_to_zone (*recur_id.datetime.value, icaltimezone_get_utc_timezone ());
597
600
 
881
884
        return TRUE;
882
885
}
883
886
 
884
 
static ECalBackendSyncStatus
 
887
static void
885
888
discard_alarm (ECalBackendSync *backend, EDataCal *cal,
886
 
               const gchar *uid, const gchar *auid)
 
889
               const gchar *uid, const gchar *auid, GError **perror)
887
890
{
888
891
        /* To be called from the Calendar derived class */
889
 
        return GNOME_Evolution_Calendar_OtherError;
 
892
        g_propagate_error (perror, EDC_ERROR (NotSupported));
890
893
}
891
894
 
892
895
/*To be overriden by Calendar and Task classes*/
893
 
static ECalBackendSyncStatus
 
896
static void
894
897
create_object (ECalBackendSync *backend, EDataCal *cal,
895
 
               gchar **calobj, gchar **uid)
 
898
               gchar **calobj, gchar **uid, GError **perror)
896
899
{
897
 
        return GNOME_Evolution_Calendar_OtherError;
 
900
        g_propagate_error (perror, EDC_ERROR (NotSupported));
898
901
}
899
902
 
900
903
/*To be overriden by Calendar and Task classes*/
901
 
static ECalBackendSyncStatus
 
904
static void
902
905
modify_object (ECalBackendSync *backend, EDataCal *cal,
903
 
                        const gchar * calobj, CalObjModType mod, gchar **old_object, gchar **new_object)
 
906
                        const gchar * calobj, CalObjModType mod, gchar **old_object, gchar **new_object, GError **perror)
904
907
{
905
 
        return GNOME_Evolution_Calendar_OtherError;
 
908
        g_propagate_error (perror, EDC_ERROR (NotSupported));
906
909
}
907
910
 
908
911
void
944
947
 
945
948
}
946
949
 
947
 
static ECalBackendSyncStatus
 
950
static void
948
951
get_object (ECalBackendSync *backend, EDataCal *cal,
949
 
            const gchar *uid, const gchar *rid, gchar **object)
 
952
            const gchar *uid, const gchar *rid, gchar **object, GError **error)
950
953
{
951
954
        ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
952
955
        ECalBackendExchangeComponent *ecomp;
953
956
 
954
957
        d(printf("ecbe_get_object(%p, %p, uid=%s, rid=%s)\n", backend, cal, uid, rid));
955
958
 
956
 
        g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_InvalidObject);
 
959
        e_return_data_cal_error_if_fail (uid != NULL, InvalidArg);
957
960
        /*any other asserts?*/
958
961
 
959
962
        *object = NULL;
962
965
        ecomp = g_hash_table_lookup (cbex->priv->objects, uid);
963
966
        if (!ecomp) {
964
967
                g_mutex_unlock (cbex->priv->cache_lock);
965
 
                return GNOME_Evolution_Calendar_ObjectNotFound;
 
968
                g_propagate_error (error, EDC_ERROR (ObjectNotFound));
 
969
                return;
966
970
        }
967
971
 
968
972
        if (!rid && (!(ecomp->icomp)))  {
969
973
                g_mutex_unlock (cbex->priv->cache_lock);
970
 
                return GNOME_Evolution_Calendar_ObjectNotFound;
 
974
                g_propagate_error (error, EDC_ERROR (ObjectNotFound));
 
975
                return;
971
976
        }
972
977
 
973
978
        if (rid && *rid) {
996
1001
                                new_inst = e_cal_util_construct_instance (ecomp->icomp, itt);
997
1002
                                if (!new_inst) {
998
1003
                                        g_mutex_unlock (cbex->priv->cache_lock);
999
 
                                        return GNOME_Evolution_Calendar_ObjectNotFound;
 
1004
                                        g_propagate_error (error, EDC_ERROR (ObjectNotFound));
 
1005
                                        return;
1000
1006
                                }
1001
1007
 
1002
1008
                                *object = icalcomponent_as_ical_string_r (new_inst);
1004
1010
                        } else {
1005
1011
                                /* Oops. No instance and no master as well !! */
1006
1012
                                g_mutex_unlock (cbex->priv->cache_lock);
1007
 
                                return GNOME_Evolution_Calendar_ObjectNotFound;
 
1013
                                g_propagate_error (error, EDC_ERROR (ObjectNotFound));
 
1014
                                return;
1008
1015
                        } /* Close check for master object */
1009
1016
                } /* Close check for instance */
1010
1017
        }/* Close check if rid is being asked */
1030
1037
                }
1031
1038
        }
1032
1039
        g_mutex_unlock (cbex->priv->cache_lock);
1033
 
 
1034
 
        return GNOME_Evolution_Calendar_Success;
1035
1040
}
1036
1041
 
1037
 
ECalBackendSyncStatus
 
1042
gboolean
1038
1043
e_cal_backend_exchange_extract_components (const gchar *calobj,
1039
1044
                                           icalproperty_method *method,
1040
 
                                           GList **comp_list)
 
1045
                                           GList **comp_list, GError **perror)
1041
1046
{
1042
1047
        icalcomponent *icalcomp, *comp = NULL;
1043
1048
        icalcomponent *subcomp;
1044
1049
        icalcomponent_kind kind;
1045
1050
        GList *comps;
1046
 
        ECalBackendSyncStatus status = GNOME_Evolution_Calendar_Success;
1047
1051
 
1048
1052
        icalcomp = icalparser_parse_string (calobj);
1049
 
        if (!icalcomp)
1050
 
                return GNOME_Evolution_Calendar_InvalidObject;
 
1053
        if (!icalcomp) {
 
1054
                g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
1055
                return FALSE;
 
1056
        }
1051
1057
 
1052
1058
        kind = icalcomponent_isa (icalcomp);
1053
1059
        if (kind != ICAL_VCALENDAR_COMPONENT) {
1063
1069
        /*time zone?*/
1064
1070
        subcomp = icalcomponent_get_first_component (icalcomp, ICAL_VTIMEZONE_COMPONENT);
1065
1071
        while (subcomp) {
1066
 
                e_cal_backend_exchange_add_timezone (cbex, icalcomponent_new_clone (subcomp));
 
1072
                e_cal_backend_exchange_add_timezone (cbex, icalcomponent_new_clone (subcomp), perror);
1067
1073
                subcomp = icalcomponent_get_next_component (icalcomp, ICAL_VTIMEZONE_COMPONENT);
1068
1074
        }
1069
1075
#endif
1082
1088
                                */
1083
1089
 
1084
1090
                                if (!icalcomponent_get_uid (subcomp)) {
1085
 
                                        status = GNOME_Evolution_Calendar_InvalidObject;
1086
 
                                        goto error;
 
1091
                                        g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
1092
                                        return FALSE;
1087
1093
                                }
1088
1094
                                comps = g_list_prepend (comps, subcomp);
1089
1095
                                break;
1095
1101
        }
1096
1102
 
1097
1103
        *comp_list = comps;
1098
 
error:
1099
 
        return status;
 
1104
 
 
1105
        return TRUE;
1100
1106
}
1101
1107
 
1102
 
static ECalBackendSyncStatus
 
1108
static void
1103
1109
send_objects (ECalBackendSync *backend, EDataCal *cal,
1104
1110
              const gchar *calobj,
1105
 
              GList **users, gchar **modified_calobj)
 
1111
              GList **users, gchar **modified_calobj, GError **perror)
1106
1112
{
1107
1113
        d(printf("ecbe_send_objects(%p, %p, %s)\n", backend, cal, calobj));
1108
1114
 
1109
 
        /* FIXME */
1110
 
        return GNOME_Evolution_Calendar_OtherError;
 
1115
        g_propagate_error (perror, EDC_ERROR (NotSupported));
1111
1116
}
1112
1117
 
1113
 
static ECalBackendSyncStatus
1114
 
get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
 
1118
static void
 
1119
get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
1115
1120
{
1116
1121
        icalcomponent *comp;
1117
1122
        gchar *ical_obj;
1123
1128
        *object = ical_obj;
1124
1129
 
1125
1130
        icalcomponent_free (comp);
1126
 
 
1127
 
        return GNOME_Evolution_Calendar_Success;
1128
1131
}
1129
1132
 
1130
1133
typedef struct {
1193
1196
                        match_data);
1194
1197
}
1195
1198
 
1196
 
static ECalBackendSyncStatus
 
1199
static void
1197
1200
get_object_list (ECalBackendSync *backend, EDataCal *cal,
1198
 
                 const gchar *sexp, GList **objects)
 
1201
                 const gchar *sexp, GList **objects, GError **perror)
1199
1202
{
1200
1203
 
1201
1204
        ECalBackendExchange *cbex;
1215
1218
                match_data.search_needed = FALSE;
1216
1219
 
1217
1220
        match_data.obj_sexp = e_cal_backend_sexp_new (sexp);
1218
 
        if (!match_data.obj_sexp)
1219
 
                return GNOME_Evolution_Calendar_InvalidQuery;
 
1221
        if (!match_data.obj_sexp) {
 
1222
                g_propagate_error (perror, EDC_ERROR (InvalidQuery));
 
1223
                return;
 
1224
        }
1220
1225
 
1221
1226
        g_mutex_lock (priv->cache_lock);
1222
1227
        g_hash_table_foreach (cbex->priv->objects, (GHFunc) match_object_sexp, &match_data);
1225
1230
        *objects = match_data.obj_list;
1226
1231
 
1227
1232
        g_object_unref (match_data.obj_sexp);
1228
 
 
1229
 
        return GNOME_Evolution_Calendar_Success;
1230
1233
}
1231
1234
 
1232
1235
icaltimezone *
1240
1243
        return priv->default_timezone;
1241
1244
}
1242
1245
 
1243
 
ECalBackendSyncStatus
 
1246
void
1244
1247
e_cal_backend_exchange_add_timezone (ECalBackendExchange *cbex,
1245
 
                                     icalcomponent *vtzcomp)
 
1248
                                     icalcomponent *vtzcomp, GError **perror)
1246
1249
{
1247
1250
        icalproperty *prop;
1248
1251
        icaltimezone *zone;
1251
1254
        d(printf("ecbe_add_timezone(%p)\n", cbex));
1252
1255
 
1253
1256
        prop = icalcomponent_get_first_property (vtzcomp, ICAL_TZID_PROPERTY);
1254
 
        if (!prop)
1255
 
                return GNOME_Evolution_Calendar_InvalidObject;
 
1257
        if (!prop) {
 
1258
                g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
1259
                return;
 
1260
        }
1256
1261
        tzid = icalproperty_get_tzid (prop);
1257
1262
        d(printf("ecbe_add_timezone: tzid = %s\n", tzid));
1258
 
        if (g_hash_table_lookup (cbex->priv->timezones, tzid))
1259
 
                return GNOME_Evolution_Calendar_ObjectIdAlreadyExists;
 
1263
        if (g_hash_table_lookup (cbex->priv->timezones, tzid)) {
 
1264
                g_propagate_error (perror, EDC_ERROR (ObjectIdAlreadyExists));
 
1265
                return;
 
1266
        }
1260
1267
 
1261
1268
        zone = icaltimezone_new ();
1262
1269
        if (!icaltimezone_set_component (zone, icalcomponent_new_clone (vtzcomp))) {
1263
1270
                icaltimezone_free (zone, TRUE);
1264
 
                return GNOME_Evolution_Calendar_InvalidObject;
 
1271
                g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
1272
                return;
1265
1273
        }
1266
1274
 
1267
1275
        g_hash_table_insert (cbex->priv->timezones, g_strdup (tzid), zone);
1268
 
        return GNOME_Evolution_Calendar_Success;
1269
1276
}
1270
1277
 
1271
 
static ECalBackendSyncStatus
 
1278
static void
1272
1279
add_timezone (ECalBackendSync *backend, EDataCal *cal,
1273
 
              const gchar *tzobj)
 
1280
              const gchar *tzobj, GError **perror)
1274
1281
{
1275
1282
        ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
1276
 
        GNOME_Evolution_Calendar_CallStatus status;
1277
1283
        icalcomponent *vtzcomp;
 
1284
        GError *err = NULL;
1278
1285
 
1279
 
        if (!tzobj)
1280
 
                return GNOME_Evolution_Calendar_InvalidObject;
 
1286
        if (!tzobj) {
 
1287
                g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
1288
                return;
 
1289
        }
1281
1290
 
1282
1291
        vtzcomp = icalcomponent_new_from_string ((gchar *)tzobj);
1283
 
        if (!vtzcomp)
1284
 
                return GNOME_Evolution_Calendar_InvalidObject;
 
1292
        if (!vtzcomp) {
 
1293
                g_propagate_error (perror, EDC_ERROR (InvalidObject));
 
1294
                return;
 
1295
        }
1285
1296
 
1286
 
        status = e_cal_backend_exchange_add_timezone (cbex, vtzcomp);
1287
 
        switch (status) {
1288
 
        case GNOME_Evolution_Calendar_ObjectIdAlreadyExists:
 
1297
        e_cal_backend_exchange_add_timezone (cbex, vtzcomp, &err);
 
1298
        switch (err ? err->code : Success) {
 
1299
        case ObjectIdAlreadyExists:
1289
1300
                /* fall through */
1290
1301
 
1291
 
        case GNOME_Evolution_Calendar_Success:
1292
 
                icalcomponent_free (vtzcomp);
1293
 
                return GNOME_Evolution_Calendar_Success;
 
1302
        case Success:
 
1303
                break;
1294
1304
 
1295
1305
        default:
1296
 
                icalcomponent_free (vtzcomp);
1297
 
                return status;
 
1306
                g_propagate_error (perror, err);
1298
1307
        }
1299
1308
        icalcomponent_free (vtzcomp);
1300
1309
}
1301
1310
 
1302
 
static ECalBackendSyncStatus
1303
 
set_default_timezone (ECalBackendSync *backend, EDataCal *cal,
1304
 
                      const gchar *tzid)
 
1311
static void
 
1312
set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tz, GError **perror)
1305
1313
{
1306
1314
        ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
 
1315
        icalcomponent *icalcomp = icalparser_parse_string (tz);
 
1316
        icaltimezone *zone = NULL;
1307
1317
 
1308
 
        d(printf("ecbe_set_default_timezone(%p, %p, %s)\n", backend, cal, tzid));
 
1318
        d(printf("ecbe_set_default_zone(%p, %p, %s)\n", backend, cal, tz));
1309
1319
        /*
1310
1320
           We call this function before calling e_cal_open in client and
1311
1321
           hence we set the timezone directly.  In the implementation of
1312
1322
           e_cal_open, we set this timezone to every-objects that we create.
1313
1323
        */
1314
1324
 
1315
 
        cbex->priv->default_timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
1316
 
        return GNOME_Evolution_Calendar_Success;
 
1325
        if (icalcomp) {
 
1326
                const gchar *tzid;
 
1327
 
 
1328
                zone = icaltimezone_new ();
 
1329
                icaltimezone_set_component (zone, icalcomp);
 
1330
 
 
1331
                tzid = icaltimezone_get_tzid (zone);
 
1332
 
 
1333
                if (tzid) {
 
1334
                        icaltimezone *known_zone;
 
1335
 
 
1336
                        known_zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
 
1337
                        if (!known_zone)
 
1338
                                known_zone = g_hash_table_lookup (cbex->priv->timezones, tzid);
 
1339
 
 
1340
                        if (known_zone) {
 
1341
                                icaltimezone_free (zone, 1);
 
1342
                                zone = known_zone;
 
1343
                        } else {
 
1344
                                g_hash_table_insert (cbex->priv->timezones, g_strdup (tzid), zone);
 
1345
                        }
 
1346
                } else {
 
1347
                        icaltimezone_free (zone, 1);
 
1348
                        zone = NULL;
 
1349
                }
 
1350
        }
 
1351
 
 
1352
        cbex->priv->default_timezone = zone;
1317
1353
}
1318
1354
 
1319
1355
static void
1320
1356
start_query (ECalBackend *backend, EDataCalView *view)
1321
1357
{
1322
1358
        const gchar *sexp = NULL;
1323
 
        ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
1324
1359
        GList *m, *objects = NULL;
 
1360
        GError *error = NULL;
1325
1361
 
1326
1362
        d(printf("ecbe_start_query(%p, %p)\n", backend, view));
1327
1363
 
1328
1364
        sexp = e_data_cal_view_get_text (view);
1329
1365
        if (!sexp) {
1330
 
                e_data_cal_view_notify_done (view, GNOME_Evolution_Calendar_InvalidQuery);
 
1366
                error = EDC_ERROR (InvalidQuery);
 
1367
                e_data_cal_view_notify_done (view, error);
 
1368
                g_error_free (error);
1331
1369
                return;
1332
1370
        }
1333
 
        status = get_object_list (E_CAL_BACKEND_SYNC (backend), NULL, sexp, &objects);
1334
 
        if (status != GNOME_Evolution_Calendar_Success) {
1335
 
                 e_data_cal_view_notify_done (view, status);
1336
 
                 return;
 
1371
        get_object_list (E_CAL_BACKEND_SYNC (backend), NULL, sexp, &objects, &error);
 
1372
        if (error) {
 
1373
                e_data_cal_view_notify_done (view, error);
 
1374
                g_error_free (error);
 
1375
                return;
1337
1376
        }
1338
1377
 
1339
1378
        if (objects) {
1344
1383
                g_list_free (objects);
1345
1384
        }
1346
1385
 
1347
 
        e_data_cal_view_notify_done (view, GNOME_Evolution_Calendar_Success);
 
1386
        e_data_cal_view_notify_done (view, NULL /* Success */);
1348
1387
}
1349
1388
 
1350
1389
gboolean
1396
1435
 
1397
1436
        if (priv->mode == mode) {
1398
1437
                e_cal_backend_notify_mode (
1399
 
                        backend, GNOME_Evolution_Calendar_CalListener_MODE_SET,
 
1438
                        backend, ModeSet,
1400
1439
                        cal_mode_to_corba (mode));
1401
1440
        }
1402
1441
 
1408
1447
 
1409
1448
        case CAL_MODE_REMOTE:
1410
1449
                        e_cal_backend_notify_mode (backend,
1411
 
                                GNOME_Evolution_Calendar_CalListener_MODE_SET,
1412
 
                                GNOME_Evolution_Calendar_MODE_REMOTE);
 
1450
                                ModeSet,
 
1451
                                Remote);
1413
1452
                        /* FIXME : Test if available for read already */
1414
1453
                        priv->read_only = FALSE;
1415
1454
                        priv->mode = CAL_MODE_REMOTE;
1423
1462
                                        priv->mode = CAL_MODE_LOCAL;
1424
1463
                        priv->read_only = TRUE;
1425
1464
                        e_cal_backend_notify_mode (backend,
1426
 
                                GNOME_Evolution_Calendar_CalListener_MODE_SET,
1427
 
                                GNOME_Evolution_Calendar_MODE_LOCAL);
 
1465
                                ModeSet,
 
1466
                                Local);
1428
1467
                        break;
1429
1468
 
1430
1469
        default :
1431
1470
                e_cal_backend_notify_mode (
1432
 
                        backend, GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
 
1471
                        backend, ModeNotSupported,
1433
1472
                        cal_mode_to_corba (mode));
1434
1473
        }
1435
1474
        g_mutex_unlock (priv->set_lock);
1436
1475
}
1437
1476
 
1438
 
static ECalBackendSyncStatus
 
1477
static void
1439
1478
get_freebusy (ECalBackendSync *backend, EDataCal *cal,
1440
1479
              GList *users, time_t start, time_t end,
1441
 
              GList **freebusy)
 
1480
              GList **freebusy, GError **perror)
1442
1481
{
1443
1482
        d(printf("ecbe_get_free_busy(%p, %p)\n", backend, cal));
1444
1483
 
1445
 
        /* FIXME */
1446
 
        return GNOME_Evolution_Calendar_OtherError;
 
1484
        g_propagate_error (perror, EDC_ERROR (NotSupported));
1447
1485
}
1448
1486
 
1449
1487
/**
1482
1520
                        gchar **name, gchar **email)
1483
1521
{
1484
1522
        ECalComponentOrganizer org;
1485
 
        ECalBackendSyncStatus status;
1486
1523
 
1487
1524
        g_return_if_fail (E_IS_CAL_BACKEND_EXCHANGE (backend));
1488
1525
 
1492
1529
                *email = g_strdup (org.value);
1493
1530
        } else {
1494
1531
                get_cal_owner (backend, name);
1495
 
                status = get_cal_address (backend, NULL, email);
 
1532
                get_cal_address (backend, NULL, email, NULL);
1496
1533
        }
1497
1534
}
1498
1535
 
1511
1548
}
1512
1549
 
1513
1550
/* Do not internationalize */
1514
 
static const gchar *e2k_rfc822_months [] = {
 
1551
static const gchar *e2k_rfc822_months[] = {
1515
1552
        "Jan", "Feb", "Mar", "Apr", "May", "Jun",
1516
1553
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
1517
1554
};
1680
1717
 
1681
1718
        d(printf ("dest_file is :%s\n", dest_file));
1682
1719
 
1683
 
        /* Write it to our local exchange store in .evolution */
 
1720
        /* Write it to our local exchange store. */
1684
1721
        fd = g_open (dest_file, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
1685
1722
        if (fd < 0) {
1686
1723
                d(printf ("open of destination file for attachments failed\n"));
1687
1724
                goto end;
1688
1725
        }
1689
1726
 
1690
 
        if (camel_write (fd, file_contents, len) < 0) {
 
1727
        if (camel_write (fd, file_contents, len, NULL) < 0) {
1691
1728
                d(printf ("camel write to attach file failed\n"));
1692
1729
                goto end;
1693
1730
        }
1716
1753
 
1717
1754
        stream = camel_stream_mem_new_with_buffer (body, len);
1718
1755
        msg = camel_mime_message_new ();
1719
 
        camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream);
1720
 
        camel_object_unref (stream);
 
1756
        camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg), stream, NULL);
 
1757
        g_object_unref (stream);
1721
1758
 
1722
 
        msg_content = camel_medium_get_content_object (CAMEL_MEDIUM (msg));
 
1759
        msg_content = camel_medium_get_content (CAMEL_MEDIUM (msg));
1723
1760
        if (msg_content && CAMEL_IS_MULTIPART (msg_content)) {
1724
1761
                multipart = (CamelMultipart *)msg_content;
1725
1762
 
1727
1764
                        part = camel_multipart_get_part (multipart, i);
1728
1765
                        filename = camel_mime_part_get_filename (part);
1729
1766
                        if (filename) {
1730
 
                                GByteArray *mem_bytes = g_byte_array_new ();
1731
 
 
1732
 
                                content = camel_medium_get_content_object (CAMEL_MEDIUM (part));
1733
 
 
1734
 
                                stream = camel_stream_mem_new_with_byte_array (mem_bytes);
1735
 
 
1736
 
                                camel_data_wrapper_decode_to_stream (content, stream);
1737
 
                                attach_data = g_memdup (mem_bytes->data, mem_bytes->len);
 
1767
                                GByteArray *byte_array;
 
1768
 
 
1769
                                content = camel_medium_get_content (CAMEL_MEDIUM (part));
 
1770
 
 
1771
                                byte_array = g_byte_array_new ();
 
1772
                                stream = camel_stream_mem_new_with_byte_array (byte_array);
 
1773
                                camel_data_wrapper_decode_to_stream (content, stream, NULL);
 
1774
                                attach_data = g_memdup (byte_array->data, byte_array->len);
1738
1775
                                attach_file = g_strdup_printf ("%s/%s-%s", cbex->priv->local_attachment_store, uid, filename);
1739
1776
                                // Attach
1740
 
                                attach_file_url = save_attach_file (attach_file, (gchar *) attach_data, mem_bytes->len);
 
1777
                                attach_file_url = save_attach_file (attach_file, (gchar *) attach_data, byte_array->len);
1741
1778
                                g_free (attach_data);
1742
1779
                                g_free (attach_file);
1743
1780
                                d(printf ("attach file name : %s\n", attach_file_url));
1744
1781
                                list = g_slist_append (list, attach_file_url);
1745
1782
 
1746
 
                                camel_object_unref (stream);
 
1783
                                g_object_unref (stream);
1747
1784
                        }
1748
1785
                } /* Loop through each multipart */
1749
1786
        }
1750
1787
 
1751
 
        camel_object_unref (msg);
 
1788
        g_object_unref (msg);
1752
1789
        return list;
1753
1790
}
1754
1791
 
1773
1810
        if (len > 0) {
1774
1811
                file_contents = g_malloc0 (len + 1);
1775
1812
 
1776
 
                if (camel_read (fd, file_contents, len) < 0) {
 
1813
                if (camel_read (fd, file_contents, len, NULL) < 0) {
1777
1814
                        d(printf ("reading from the attachment file failed\n"));
1778
1815
                        g_free (file_contents);
1779
1816
                        file_contents = NULL;
1780
1817
                        goto end;
1781
1818
                }
1782
 
                file_contents [len] = '\0';
 
1819
                file_contents[len] = '\0';
1783
1820
        }
1784
1821
 
1785
1822
end :
1934
1971
build_msg ( ECalBackendExchange *cbex, ECalComponent *comp, const gchar *subject, gchar **boundary)
1935
1972
{
1936
1973
        CamelMimeMessage *msg;
1937
 
        CamelStream *mem_content;
1938
1974
        CamelMimePart *mime_part;
1939
1975
        CamelDataWrapper *dw, *wrapper;
1940
1976
        CamelMultipart *multipart;
1941
1977
        CamelInternetAddress *from;
1942
1978
        CamelStream *stream;
1943
1979
        CamelContentType *type;
1944
 
        GByteArray *mem_bytes;
 
1980
        GByteArray *byte_array;
1945
1981
        const gchar *uid;
1946
1982
        gchar *buffer = NULL, *cid;
1947
1983
        gchar *from_name = NULL, *from_email = NULL;
1966
2002
        camel_mime_message_set_from (msg, from);
1967
2003
        g_free (from_name);
1968
2004
        g_free (from_email);
1969
 
        camel_object_unref (from);
 
2005
        g_object_unref (from);
1970
2006
 
1971
2007
        e_cal_component_get_uid (comp, &uid);
1972
2008
        e_cal_component_get_attachment_list (comp, &attach_list);
2013
2049
                /* Content */
2014
2050
                stream = camel_stream_mem_new_with_buffer (file_contents, len);
2015
2051
                wrapper = camel_data_wrapper_new ();
2016
 
                camel_data_wrapper_construct_from_stream (wrapper, stream);
2017
 
                camel_object_unref (stream);
 
2052
                camel_data_wrapper_construct_from_stream (wrapper, stream, NULL);
 
2053
                g_object_unref (stream);
2018
2054
 
2019
2055
                mime_type = get_mime_type (dest_url);
2020
2056
                if (mime_type) {
2026
2062
 
2027
2063
                mime_part = camel_mime_part_new ();
2028
2064
 
2029
 
                camel_medium_set_content_object (CAMEL_MEDIUM (mime_part), wrapper);
 
2065
                camel_medium_set_content (CAMEL_MEDIUM (mime_part), wrapper);
2030
2066
                camel_mime_part_set_filename (mime_part, mime_filename);
2031
2067
                camel_mime_part_set_encoding (mime_part, CAMEL_TRANSFER_ENCODING_BASE64);
2032
2068
                cid = camel_header_msgid_generate ();
2037
2073
                camel_multipart_set_boundary (multipart, NULL);
2038
2074
                *boundary = g_strdup (camel_multipart_get_boundary (multipart));
2039
2075
                camel_multipart_add_part (multipart, mime_part);
2040
 
                camel_object_unref (mime_part);
 
2076
                g_object_unref (mime_part);
2041
2077
                g_free (cid);
2042
2078
        }
2043
2079
        if (!new_attach_list) {
2044
 
                camel_object_unref (multipart);
2045
 
                camel_object_unref (msg);
 
2080
                g_object_unref (multipart);
 
2081
                g_object_unref (msg);
2046
2082
                return NULL;
2047
2083
        }
2048
2084
        e_cal_component_set_attachment_list (comp, new_attach_list);
2049
2085
 
2050
 
        camel_medium_set_content_object (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER (multipart));
2051
 
        camel_object_unref (multipart);
 
2086
        camel_medium_set_content (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER (multipart));
 
2087
        g_object_unref (multipart);
2052
2088
 
2053
 
        mem_bytes = g_byte_array_new ();
2054
 
        mem_content = camel_stream_mem_new_with_byte_array (mem_bytes);
2055
 
        dw = camel_medium_get_content_object (CAMEL_MEDIUM (msg));
2056
 
        camel_data_wrapper_decode_to_stream (dw, mem_content);
2057
 
        buffer = g_strndup ((const gchar *)mem_bytes->data, mem_bytes->len);
 
2089
        byte_array = g_byte_array_new ();
 
2090
        stream = camel_stream_mem_new_with_byte_array (byte_array);
 
2091
        dw = camel_medium_get_content (CAMEL_MEDIUM (msg));
 
2092
        camel_data_wrapper_decode_to_stream (dw, stream, NULL);
 
2093
        buffer = g_memdup (byte_array->data, byte_array->len);
 
2094
        buffer[byte_array->len] = '\0';
2058
2095
        d(printf ("|| Buffer: \n%s\n", buffer));
2059
 
        camel_object_unref (mem_content);
2060
 
        camel_object_unref (msg);
 
2096
        g_object_unref (stream);
 
2097
        g_object_unref (msg);
2061
2098
 
2062
2099
        return buffer;
2063
2100
}
2064
2101
 
2065
 
static ECalBackendSyncStatus
 
2102
static void
2066
2103
get_changes (ECalBackendSync *backend, EDataCal *cal,
2067
2104
             const gchar *change_id,
2068
 
             GList **adds, GList **modifies, GList **deletes)
 
2105
             GList **adds, GList **modifies, GList **deletes, GError **error)
2069
2106
{
2070
2107
        ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
2071
2108
        gchar *path, *filename;
2075
2112
 
2076
2113
        d(printf("ecbe_get_changes(%p, %p, %s)\n", backend, cal, change_id));
2077
2114
 
2078
 
        g_return_val_if_fail (E_IS_CAL_BACKEND_EXCHANGE (cbex), GNOME_Evolution_Calendar_OtherError);
2079
 
        g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
 
2115
        e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_EXCHANGE (cbex), InvalidArg);
 
2116
        e_return_data_cal_error_if_fail (change_id != NULL, ObjectNotFound);
2080
2117
 
2081
2118
        /* open the changes file */
2082
2119
        filename = g_strdup_printf ("%s.changes", change_id);
2106
2143
 
2107
2144
        e_xmlhash_write (ehash);
2108
2145
        e_xmlhash_destroy (ehash);
2109
 
 
2110
 
        return GNOME_Evolution_Calendar_Success;
2111
2146
}
2112
2147
 
2113
2148
static icaltimezone *
2274
2309
        sync_class->get_object_sync = get_object;
2275
2310
        sync_class->get_object_list_sync = get_object_list;
2276
2311
        sync_class->add_timezone_sync = add_timezone;
2277
 
        sync_class->set_default_timezone_sync = set_default_timezone;
 
2312
        sync_class->set_default_zone_sync = set_default_zone;
2278
2313
        sync_class->get_freebusy_sync = get_freebusy;
2279
2314
        sync_class->get_changes_sync = get_changes;
2280
2315
        sync_class->create_object_sync = create_object;