87
85
static icaltimezone *
88
86
internal_get_timezone (ECalBackend *backend, const gchar *tzid);
90
static ECalBackendSyncStatus
91
is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
89
is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only, GError **perror)
93
91
ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
95
93
d(printf("ecbe_is_read_only(%p, %p) -> %d\n", backend, cal, cbex->priv->read_only));
97
95
*read_only = cbex->priv->read_only;
98
return GNOME_Evolution_Calendar_Success;
101
static ECalBackendSyncStatus
102
get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address)
99
get_cal_address (ECalBackendSync *backend, EDataCal *cal, gchar **address, GError **perror)
104
101
ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
105
102
ExchangeHierarchy *hier;
132
127
* This should not have been called.
135
return GNOME_Evolution_Calendar_OtherError;
131
g_propagate_error (perror, EDC_ERROR (NotSupported));
138
static ECalBackendSyncStatus
139
get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute)
135
get_ldap_attribute (ECalBackendSync *backend, EDataCal *cal, gchar **attribute, GError **perror)
141
137
d(printf("ecbe_get_ldap_attribute(%p, %p)\n", backend, cal));
144
return GNOME_Evolution_Calendar_InvalidObject;
140
g_propagate_error (perror, EDC_ERROR (InvalidObject));
146
144
/* This is just a hack for SunONE */
147
145
*attribute = NULL;
148
return GNOME_Evolution_Calendar_Success;
151
static ECalBackendSyncStatus
152
get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities)
149
get_static_capabilities (ECalBackendSync *backend, EDataCal *cal, gchar **capabilities, GError **perror)
154
151
d(printf("ecbe_get_static_capabilities(%p, %p)\n", backend, cal));
505
510
g_mutex_unlock (cbex->priv->open_lock);
507
512
e2k_results_free (results, nresults);
508
return GNOME_Evolution_Calendar_PermissionDenied;
513
g_propagate_error (perror, EDC_ERROR (PermissionDenied));
511
517
cbex->priv->read_only = ((access & MAPI_ACCESS_CREATE_CONTENTS) == 0);
513
load_status = load_cache (cbex, euri);
515
if (load_status == GNOME_Evolution_Calendar_Success)
519
if (load_cache (cbex, euri, perror))
516
520
cbex->priv->is_loaded = TRUE;
518
522
g_mutex_unlock (cbex->priv->open_lock);
521
525
e2k_results_free (results, nresults);
525
static ECalBackendSyncStatus
526
remove_calendar (ECalBackendSync *backend, EDataCal *cal)
529
remove_calendar (ECalBackendSync *backend, EDataCal *cal, GError **perror)
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;
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;
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));
552
return GNOME_Evolution_Calendar_OtherError;
555
g_propagate_error (perror, e_data_cal_create_error_fmt (OtherError, "Failed with FolderResult %d", result));
884
static ECalBackendSyncStatus
885
888
discard_alarm (ECalBackendSync *backend, EDataCal *cal,
886
const gchar *uid, const gchar *auid)
889
const gchar *uid, const gchar *auid, GError **perror)
888
891
/* To be called from the Calendar derived class */
889
return GNOME_Evolution_Calendar_OtherError;
892
g_propagate_error (perror, EDC_ERROR (NotSupported));
892
895
/*To be overriden by Calendar and Task classes*/
893
static ECalBackendSyncStatus
894
897
create_object (ECalBackendSync *backend, EDataCal *cal,
895
gchar **calobj, gchar **uid)
898
gchar **calobj, gchar **uid, GError **perror)
897
return GNOME_Evolution_Calendar_OtherError;
900
g_propagate_error (perror, EDC_ERROR (NotSupported));
900
903
/*To be overriden by Calendar and Task classes*/
901
static ECalBackendSyncStatus
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)
905
return GNOME_Evolution_Calendar_OtherError;
908
g_propagate_error (perror, EDC_ERROR (NotSupported));
1097
1103
*comp_list = comps;
1102
static ECalBackendSyncStatus
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)
1107
1113
d(printf("ecbe_send_objects(%p, %p, %s)\n", backend, cal, calobj));
1110
return GNOME_Evolution_Calendar_OtherError;
1115
g_propagate_error (perror, EDC_ERROR (NotSupported));
1113
static ECalBackendSyncStatus
1114
get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object)
1119
get_default_object (ECalBackendSync *backend, EDataCal *cal, gchar **object, GError **perror)
1116
1121
icalcomponent *comp;
1117
1122
gchar *ical_obj;
1251
1254
d(printf("ecbe_add_timezone(%p)\n", cbex));
1253
1256
prop = icalcomponent_get_first_property (vtzcomp, ICAL_TZID_PROPERTY);
1255
return GNOME_Evolution_Calendar_InvalidObject;
1258
g_propagate_error (perror, EDC_ERROR (InvalidObject));
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));
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));
1267
1275
g_hash_table_insert (cbex->priv->timezones, g_strdup (tzid), zone);
1268
return GNOME_Evolution_Calendar_Success;
1271
static ECalBackendSyncStatus
1272
1279
add_timezone (ECalBackendSync *backend, EDataCal *cal,
1280
const gchar *tzobj, GError **perror)
1275
1282
ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
1276
GNOME_Evolution_Calendar_CallStatus status;
1277
1283
icalcomponent *vtzcomp;
1280
return GNOME_Evolution_Calendar_InvalidObject;
1287
g_propagate_error (perror, EDC_ERROR (InvalidObject));
1282
1291
vtzcomp = icalcomponent_new_from_string ((gchar *)tzobj);
1284
return GNOME_Evolution_Calendar_InvalidObject;
1293
g_propagate_error (perror, EDC_ERROR (InvalidObject));
1286
status = e_cal_backend_exchange_add_timezone (cbex, vtzcomp);
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 */
1291
case GNOME_Evolution_Calendar_Success:
1292
icalcomponent_free (vtzcomp);
1293
return GNOME_Evolution_Calendar_Success;
1296
icalcomponent_free (vtzcomp);
1306
g_propagate_error (perror, err);
1299
1308
icalcomponent_free (vtzcomp);
1302
static ECalBackendSyncStatus
1303
set_default_timezone (ECalBackendSync *backend, EDataCal *cal,
1312
set_default_zone (ECalBackendSync *backend, EDataCal *cal, const gchar *tz, GError **perror)
1306
1314
ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
1315
icalcomponent *icalcomp = icalparser_parse_string (tz);
1316
icaltimezone *zone = NULL;
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));
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.
1315
cbex->priv->default_timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
1316
return GNOME_Evolution_Calendar_Success;
1328
zone = icaltimezone_new ();
1329
icaltimezone_set_component (zone, icalcomp);
1331
tzid = icaltimezone_get_tzid (zone);
1334
icaltimezone *known_zone;
1336
known_zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
1338
known_zone = g_hash_table_lookup (cbex->priv->timezones, tzid);
1341
icaltimezone_free (zone, 1);
1344
g_hash_table_insert (cbex->priv->timezones, g_strdup (tzid), zone);
1347
icaltimezone_free (zone, 1);
1352
cbex->priv->default_timezone = zone;
1320
1356
start_query (ECalBackend *backend, EDataCalView *view)
1322
1358
const gchar *sexp = NULL;
1323
ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
1324
1359
GList *m, *objects = NULL;
1360
GError *error = NULL;
1326
1362
d(printf("ecbe_start_query(%p, %p)\n", backend, view));
1328
1364
sexp = e_data_cal_view_get_text (view);
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);
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);
1371
get_object_list (E_CAL_BACKEND_SYNC (backend), NULL, sexp, &objects, &error);
1373
e_data_cal_view_notify_done (view, error);
1374
g_error_free (error);
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);
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));
1435
1474
g_mutex_unlock (priv->set_lock);
1438
static ECalBackendSyncStatus
1439
1478
get_freebusy (ECalBackendSync *backend, EDataCal *cal,
1440
1479
GList *users, time_t start, time_t end,
1480
GList **freebusy, GError **perror)
1443
1482
d(printf("ecbe_get_free_busy(%p, %p)\n", backend, cal));
1446
return GNOME_Evolution_Calendar_OtherError;
1484
g_propagate_error (perror, EDC_ERROR (NotSupported));
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 ();
1732
content = camel_medium_get_content_object (CAMEL_MEDIUM (part));
1734
stream = camel_stream_mem_new_with_byte_array (mem_bytes);
1736
camel_data_wrapper_decode_to_stream (content, stream);
1737
attach_data = g_memdup (mem_bytes->data, mem_bytes->len);
1767
GByteArray *byte_array;
1769
content = camel_medium_get_content (CAMEL_MEDIUM (part));
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);
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);
1746
camel_object_unref (stream);
1783
g_object_unref (stream);
1748
1785
} /* Loop through each multipart */
1751
camel_object_unref (msg);
1788
g_object_unref (msg);
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);
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);
2048
2084
e_cal_component_set_attachment_list (comp, new_attach_list);
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);
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);
2065
static ECalBackendSyncStatus
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)
2070
2107
ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
2071
2108
gchar *path, *filename;