307
310
free_calendar_data (cbfile);
312
source = e_cal_backend_get_source (E_CAL_BACKEND (cbfile));
314
g_signal_handlers_disconnect_matched (source, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, cbfile);
309
316
if (G_OBJECT_CLASS (parent_class)->dispose)
310
317
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
1233
1240
return add || to_remove != NULL;
1244
source_changed_cb (ESource *source, ECalBackend *backend)
1248
g_return_if_fail (source != NULL);
1249
g_return_if_fail (backend != NULL);
1250
g_return_if_fail (E_IS_CAL_BACKEND (backend));
1252
value = e_source_get_property (source, "custom-file");
1253
if (value && *value) {
1254
ECalBackendFile *cbfile;
1255
gboolean forced_readonly;
1257
cbfile = E_CAL_BACKEND_FILE (backend);
1258
g_return_if_fail (cbfile != NULL);
1260
value = e_source_get_property (source, "custom-file-readonly");
1261
forced_readonly = value && g_str_equal (value, "1");
1263
if ((forced_readonly != FALSE) != (cbfile->priv->read_only != FALSE)) {
1264
cbfile->priv->read_only = forced_readonly;
1265
if (!forced_readonly) {
1266
gchar *str_uri = get_uri_string (backend);
1268
g_return_if_fail (str_uri != NULL);
1270
cbfile->priv->read_only = g_access (str_uri, W_OK) != 0;
1275
e_cal_backend_notify_readonly (backend, cbfile->priv->read_only);
1236
1280
/* Open handler for the file backend */
1237
1281
static ECalBackendSyncStatus
1238
1282
e_cal_backend_file_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
1275
1319
if (!priv->read_only) {
1276
1320
ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (backend));
1278
if (source && e_source_get_property (source, "custom-file-readonly") && g_str_equal (e_source_get_property (source, "custom-file-readonly"), "1"))
1279
priv->read_only = TRUE;
1323
g_signal_connect (source, "changed", G_CALLBACK (source_changed_cb), backend);
1325
if (e_source_get_property (source, "custom-file-readonly") && g_str_equal (e_source_get_property (source, "custom-file-readonly"), "1"))
1326
priv->read_only = TRUE;
1282
1330
if (priv->default_zone && add_timezone (priv->icalcomp, priv->default_zone)) {
1512
1560
return GNOME_Evolution_Calendar_Success;
1515
/* Get_timezone_object handler for the file backend */
1516
static ECalBackendSyncStatus
1517
e_cal_backend_file_get_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzid, gchar **object)
1519
ECalBackendFile *cbfile;
1520
ECalBackendFilePrivate *priv;
1522
icalcomponent *icalcomp;
1524
cbfile = E_CAL_BACKEND_FILE (backend);
1525
priv = cbfile->priv;
1527
g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal);
1528
g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound);
1530
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
1532
if (!strcmp (tzid, "UTC")) {
1533
zone = icaltimezone_get_utc_timezone ();
1535
zone = icalcomponent_get_timezone (priv->icalcomp, tzid);
1537
zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
1539
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
1540
return GNOME_Evolution_Calendar_ObjectNotFound;
1545
icalcomp = icaltimezone_get_component (zone);
1547
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
1548
return GNOME_Evolution_Calendar_InvalidObject;
1551
*object = icalcomponent_as_ical_string_r (icalcomp);
1553
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
1554
return GNOME_Evolution_Calendar_Success;
1557
1563
/* Add_timezone handler for the file backend */
1558
1564
static ECalBackendSyncStatus
1559
1565
e_cal_backend_file_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj)
2077
2083
zone = icaltimezone_get_utc_timezone ();
2079
2085
zone = icalcomponent_get_timezone (priv->icalcomp, tzid);
2081
zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
2083
2087
if (!zone && E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone)
2084
2088
zone = E_CAL_BACKEND_CLASS (parent_class)->internal_get_timezone (backend, tzid);
2508
2513
icaltime_from_string (rid), CALOBJ_MOD_THIS);
2510
2515
/* Since we are only removing one instance of recurrence
2511
event, update the last modified time on the component */
2512
struct icaltimetype current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
2516
event, update the last modified time on the component */
2517
current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
2513
2518
e_cal_component_set_last_modified (obj_data->full_object, ¤t);
2515
2520
/* add the modified object to the beginning of the list,
3103
3108
sync_class->get_object_sync = e_cal_backend_file_get_object;
3104
3109
sync_class->get_object_list_sync = e_cal_backend_file_get_object_list;
3105
3110
sync_class->get_attachment_list_sync = e_cal_backend_file_get_attachment_list;
3106
sync_class->get_timezone_sync = e_cal_backend_file_get_timezone;
3107
3111
sync_class->add_timezone_sync = e_cal_backend_file_add_timezone;
3108
3112
sync_class->set_default_zone_sync = e_cal_backend_file_set_default_zone;
3109
3113
sync_class->get_freebusy_sync = e_cal_backend_file_get_free_busy;
3118
3122
backend_class->internal_get_timezone = e_cal_backend_file_internal_get_timezone;
3122
* e_cal_backend_file_get_type:
3125
* Registers the #ECalBackendFile class if necessary, and returns the type ID
3128
* Return value: The type ID of the #ECalBackendFile class.
3131
e_cal_backend_file_get_type (void)
3133
static GType e_cal_backend_file_type = 0;
3135
if (!e_cal_backend_file_type) {
3136
static GTypeInfo info = {
3137
sizeof (ECalBackendFileClass),
3138
(GBaseInitFunc) NULL,
3139
(GBaseFinalizeFunc) NULL,
3140
(GClassInitFunc) e_cal_backend_file_class_init,
3142
sizeof (ECalBackendFile),
3144
(GInstanceInitFunc) e_cal_backend_file_init
3146
e_cal_backend_file_type = g_type_register_static (E_TYPE_CAL_BACKEND_SYNC,
3147
"ECalBackendFile", &info, 0);
3150
return e_cal_backend_file_type;
3154
3126
e_cal_backend_file_set_file_name (ECalBackendFile *cbfile, const gchar *file_name)