60
static ECalBackendSyncStatus modify_object_with_href (ECalBackendSync *backend, EDataCal *cal, const char *calobj, CalObjModType mod, char **old_object, char **new_object, const char *href, const char *rid_to_remove);
60
static ECalBackendSyncStatus modify_object_with_href (ECalBackendSync *backend, EDataCal *cal, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object, const gchar *href, const gchar *rid_to_remove);
62
static icalproperty *find_attendee_prop (icalcomponent *ical_comp, const char *address);
62
static icalproperty *find_attendee_prop (icalcomponent *ical_comp, const gchar *address);
63
63
static gboolean check_owner_partstatus_for_declined (ECalBackendSync *backend,
64
64
icalcomponent *icalcomp);
97
97
add_vevent (ECalBackendExchange *cbex,
98
const char *href, const char *lastmod,
98
const gchar *href, const gchar *lastmod,
99
99
icalcomponent *icalcomp)
101
101
icalproperty *prop, *transp;
109
109
/* Check all X-MICROSOFT-CDO properties to fix any needed stuff */
110
110
prop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
112
const char *x_name, *x_val;
112
const gchar *x_name, *x_val;
113
113
struct icaltimetype itt;
115
115
x_name = icalproperty_get_x_name (prop);
189
189
/* Add the event to the cache, Notify the backend if it is sucessfully added */
191
add_ical (ECalBackendExchange *cbex, const char *href, const char *lastmod,
192
const char *uid, const char *body, int len, int receipts)
191
add_ical (ECalBackendExchange *cbex, const gchar *href, const gchar *lastmod,
192
const gchar *uid, const gchar *body, gint len, gint receipts)
194
const char *start, *end;
194
const gchar *start, *end;
196
196
icalcomponent *icalcomp, *subcomp, *new_comp;
197
197
icalcomponent_kind kind;
198
198
icalproperty *icalprop;
246
246
status = add_vevent (cbex, href, lastmod, icalcomp);
249
char *object = icalcomponent_as_ical_string_r (icalcomp);
249
gchar *object = icalcomponent_as_ical_string_r (icalcomp);
250
250
e_cal_backend_notify_object_created (backend, object);
289
289
status = add_vevent (cbex, href, lastmod, new_comp);
292
char *object = icalcomponent_as_ical_string_r (new_comp);
292
gchar *object = icalcomponent_as_ical_string_r (new_comp);
293
293
e_cal_backend_notify_object_created (backend, object);
318
318
PR_READ_RECEIPT_REQUESTED,
319
319
PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED
321
static const int n_event_properties = G_N_ELEMENTS (event_properties);
321
static const gint n_event_properties = G_N_ELEMENTS (event_properties);
323
static const char *new_event_properties[] = {
323
static const gchar *new_event_properties[] = {
324
324
PR_INTERNET_CONTENT,
325
325
PR_READ_RECEIPT_REQUESTED,
326
326
PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED
328
static const int n_new_event_properties = G_N_ELEMENTS (new_event_properties);
328
static const gint n_new_event_properties = G_N_ELEMENTS (new_event_properties);
331
331
get_changed_events (ECalBackendExchange *cbex)
336
336
E2kRestriction *rn;
337
337
E2kResultIter *iter;
338
338
E2kResult *result;
339
const char *prop, *uid, *modtime, *attach_prop, *receipts, *rid;
339
const gchar *prop, *uid, *modtime, *attach_prop, *receipts, *rid;
342
int i, status_tracking = EX_NO_RECEIPTS;
343
const char *since = NULL;
342
gint i, status_tracking = EX_NO_RECEIPTS;
343
const gchar *since = NULL;
344
344
ECalBackendExchangeCalendar *cbexc = E_CAL_BACKEND_EXCHANGE_CALENDAR (cbex);
346
346
g_return_val_if_fail (E_IS_CAL_BACKEND_EXCHANGE (cbex), SOUP_STATUS_CANCELLED);
458
458
PR_INTERNET_CONTENT property. Fetch events created from OWA */
459
459
prop = PR_INTERNET_CONTENT;
460
460
iter = e_folder_exchange_bpropfind_start (cbex->folder, NULL,
461
(const char **)hrefs->pdata,
461
(const gchar **)hrefs->pdata,
463
463
new_event_properties, n_new_event_properties);
464
464
for (i = 0; i < hrefs->len; i++)
496
496
/* The icaldata already has the attachment. So no need to
497
497
re-fetch it from the server. */
498
498
add_ical (cbex, result->href, modtime, uid,
499
(char *) ical_data->data, ical_data->len, status_tracking);
499
(gchar *) ical_data->data, ical_data->len, status_tracking);
501
501
status = e2k_result_iter_free (iter);
555
555
/* folder subscription notify callback */
557
notify_changes (E2kContext *ctx, const char *uri,
557
notify_changes (E2kContext *ctx, const gchar *uri,
558
558
E2kContextChangeType type, gpointer user_data)
570
570
static ECalBackendSyncStatus
571
571
open_calendar (ECalBackendSync *backend, EDataCal *cal,
572
572
gboolean only_if_exists,
573
const char *username, const char *password)
573
const gchar *username, const gchar *password)
575
575
ECalBackendSyncStatus status;
576
576
GThread *thread = NULL;
616
add_timezone_cb (icalparameter *param, void *data)
616
add_timezone_cb (icalparameter *param, gpointer data)
618
618
struct _cb_data *cbdata = (struct _cb_data *) data;
619
619
icalcomponent *vtzcomp;
623
623
g_return_if_fail (cbdata != NULL);
643
643
icalproperty *icalprop;
644
644
gboolean exists = FALSE;
645
const char *x_name, *x_val;
645
const gchar *x_name, *x_val;
647
647
icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
648
648
while (icalprop && !exists) {
683
683
for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY);
685
685
prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) {
686
const char *attendee;
686
const gchar *attendee;
689
689
attendee = icalproperty_get_value_as_string_r (prop);
729
729
static ECalBackendSyncStatus
730
730
create_object (ECalBackendSync *backend, EDataCal *cal,
731
char **calobj, char **uid)
731
gchar **calobj, gchar **uid)
733
733
/* FIXME : Return some value in uid */
734
734
ECalBackendExchangeCalendar *cbexc;
736
736
icalcomponent *icalcomp, *real_icalcomp;
737
737
icalcomponent_kind kind;
738
738
icalproperty *icalprop;
739
const char *temp_comp_uid;
739
const gchar *temp_comp_uid;
741
741
struct icaltimetype current;
742
char *location = NULL, *ru_header = NULL;
742
gchar *location = NULL, *ru_header = NULL;
743
743
ECalComponent *comp;
744
char *body_crlf, *msg;
747
char *attach_body = NULL;
748
char *attach_body_crlf = NULL;
749
char *boundary = NULL;
744
gchar *body_crlf, *msg;
746
const gchar *summary;
747
gchar *attach_body = NULL;
748
gchar *attach_body_crlf = NULL;
749
gchar *boundary = NULL;
750
750
E2kHTTPStatus http_status;
751
751
E2kProperties *props = e2k_properties_new ();
752
752
E2kContext *e2kctx;
959
959
icalcomponent *icalcomp;
960
960
icalproperty *icalprop;
961
const char *x_name, *x_val;
961
const gchar *x_name, *x_val;
962
962
ECalComponentTransparency transp;
963
963
ECalComponentDateTime dtstart;
965
const char *busystatus, *insttype, *allday, *importance;
965
const gchar *busystatus, *insttype, *allday, *importance;
967
967
GSList *props = NULL, *l = NULL;
969
969
e_cal_component_get_transparency (comp, &transp);
992
992
importance = "1";
994
994
/* Go through the existing X-MICROSOFT-CDO- properties first */
995
icalcomp = e_cal_component_get_icalcomponent (comp);
995
icalcomp = e_cal_component_get_icalcomponent (comp);
996
996
icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
997
997
while (icalprop) {
998
998
x_name = icalproperty_get_x_name (icalprop);
1064
1064
static ECalBackendSyncStatus
1065
1065
modify_object (ECalBackendSync *backend, EDataCal *cal,
1066
const char *calobj, CalObjModType mod,
1067
char **old_object, char **new_object)
1066
const gchar *calobj, CalObjModType mod,
1067
gchar **old_object, gchar **new_object)
1069
1069
ECalBackendSyncStatus status;
1078
1078
static ECalBackendSyncStatus
1079
1079
modify_object_with_href (ECalBackendSync *backend, EDataCal *cal,
1080
const char *calobj, CalObjModType mod,
1081
char **old_object, char **new_object, const char *href, const char *rid_to_remove)
1080
const gchar *calobj, CalObjModType mod,
1081
gchar **old_object, gchar **new_object, const gchar *href, const gchar *rid_to_remove)
1083
1083
ECalBackendExchangeCalendar *cbexc;
1084
1084
ECalBackendExchangeComponent *ecomp;
1085
1085
ECalBackendExchange *cbex;
1086
1086
icalcomponent *icalcomp, *real_icalcomp, *updated_icalcomp;
1087
1087
ECalComponent *real_ecomp, *cached_ecomp = NULL, *updated_ecomp;
1088
const char *comp_uid;
1089
char *updated_ecomp_str, *real_comp_str;
1090
char *body_crlf, *msg;
1091
char *attach_body = NULL;
1092
char *attach_body_crlf = NULL;
1093
char *boundary = NULL;
1088
const gchar *comp_uid;
1089
gchar *updated_ecomp_str, *real_comp_str;
1090
gchar *body_crlf, *msg;
1091
gchar *attach_body = NULL;
1092
gchar *attach_body_crlf = NULL;
1093
gchar *boundary = NULL;
1094
1094
struct icaltimetype last_modified, key_rid;
1095
1095
icalcomponent_kind kind;
1096
1096
ECalComponentDateTime dt;
1097
1097
struct _cb_data *cbdata;
1098
1098
icalproperty *icalprop;
1099
1099
E2kHTTPStatus http_status;
1101
const char *summary, *new_href;
1101
const gchar *summary, *new_href;
1102
1102
gboolean send_options;
1103
1103
E2kContext *ctx;
1104
1104
E2kProperties *props = e2k_properties_new ();
1262
1262
dt.value->hour = dt.value->minute = dt.value->second = 0;
1263
1263
dt.value->zone = zone;
1265
g_free ((char *)dt.tzid);
1265
g_free ((gchar *)dt.tzid);
1266
1266
dt.tzid = g_strdup (icaltimezone_get_tzid (zone));
1267
1267
e_cal_component_set_dtstart (real_ecomp, &dt);
1268
1268
e_cal_component_free_datetime (&dt);
1273
1273
dt.value->hour = dt.value->minute = dt.value->second = 0;
1274
1274
dt.value->zone = zone;
1276
g_free ((char *)dt.tzid);
1276
g_free ((gchar *)dt.tzid);
1277
1277
dt.tzid = g_strdup (icaltimezone_get_tzid (zone));
1278
1278
e_cal_component_set_dtend (real_ecomp, &dt);
1296
1296
if (dt.tzid == NULL)
1297
1297
from_zone = icaltimezone_get_utc_timezone ();
1299
gchar *izone = NULL;
1300
1300
get_timezone (backend, cal, dt.tzid, &izone);
1301
1301
from_zone = icalcomponent_get_timezone (icalcomponent_new_from_string (izone),
1456
1456
new_href = ecomp->href;
1458
1458
http_status = e2k_context_put (ctx, NULL, new_href, "message/rfc822",
1459
msg, strlen (msg), NULL);
1459
msg, strlen (msg), NULL);
1461
1461
if ((E2K_HTTP_STATUS_IS_SUCCESSFUL (http_status)) && send_options)
1462
1462
http_status = e2k_context_proppatch (ctx, NULL, new_href, props, FALSE, NULL);
1489
1489
static ECalBackendSyncStatus
1490
1490
remove_object (ECalBackendSync *backend, EDataCal *cal,
1491
const char *uid, const char *rid, CalObjModType mod,
1492
char **old_object, char **object)
1491
const gchar *uid, const gchar *rid, CalObjModType mod,
1492
gchar **old_object, gchar **object)
1494
1494
ECalBackendExchangeCalendar *cbexc;
1495
1495
ECalBackendExchange *cbex;
1497
1497
E2kHTTPStatus status;
1498
1498
E2kContext *ctx;
1499
1499
ECalComponent *comp;
1500
char *calobj, *obj = NULL;
1500
gchar *calobj, *obj = NULL;
1501
1501
struct icaltimetype time_rid;
1502
1502
ECalBackendSyncStatus ebs_status;
1533
1533
/*TODO How handle multiple detached intances with no master object ?*/
1534
1534
if (mod == CALOBJ_MOD_THIS && rid && *rid && ecomp->icomp) {
1535
char *new_object = NULL;
1535
gchar *new_object = NULL;
1537
1537
/*remove a single instance of a recurring event and modify */
1538
1538
time_rid = icaltime_from_string (rid);
1539
1539
e_cal_util_remove_instances (ecomp->icomp, time_rid, mod);
1540
calobj = (char *) icalcomponent_as_ical_string_r (ecomp->icomp);
1540
calobj = (gchar *) icalcomponent_as_ical_string_r (ecomp->icomp);
1542
1542
e_cal_backend_exchange_cache_unlock (cbex);
1543
1543
ebs_status = modify_object_with_href (backend, cal, calobj, mod, &obj, &new_object, NULL, rid);
1578
1578
static ECalBackendSyncStatus
1579
1579
receive_objects (ECalBackendSync *backend, EDataCal *cal,
1580
const gchar *calobj)
1582
1582
ECalBackendExchangeCalendar *cbexc;
1583
1583
ECalBackendExchange *cbex;
1626
1626
icalcomponent_free (icalcomp);
1628
1628
for (l = comps; l; l= l->next) {
1630
char *icalobj, *rid = NULL;
1631
char *object = NULL;
1630
gchar *icalobj, *rid = NULL;
1631
gchar *object = NULL;
1633
1633
subcomp = l->data;
1649
1649
case ICAL_METHOD_REPLY:
1650
1650
e_cal_backend_exchange_cache_lock (cbex);
1651
1651
if ((ecomp = get_exchange_comp (E_CAL_BACKEND_EXCHANGE (cbexc), uid)) != NULL ) {
1652
char *old_object = NULL;
1652
gchar *old_object = NULL;
1654
1654
d(printf ("uid : %s : found in the cache\n", uid));
1668
1668
old_object, NULL);
1669
1669
e_cal_component_free_id (id);
1671
char *new_object = NULL;
1671
gchar *new_object = NULL;
1672
1672
CalObjModType mod = CALOBJ_MOD_ALL;
1674
1674
if (e_cal_util_component_is_instance (subcomp))
1675
1675
mod = CALOBJ_MOD_THIS;
1677
icalobj = (char *) icalcomponent_as_ical_string_r (subcomp);
1677
icalobj = (gchar *) icalcomponent_as_ical_string_r (subcomp);
1678
1678
status = modify_object_with_href (backend, cal, icalobj,
1680
1680
&old_object, &new_object, NULL, NULL);
1694
1694
g_free (old_object);
1695
1695
} else if (!check_owner_partstatus_for_declined (backend, subcomp)) {
1696
char *returned_uid, *object;
1696
gchar *returned_uid, *object;
1697
1697
d(printf ("object : %s .. not found in the cache\n", uid));
1698
icalobj = (char *) icalcomponent_as_ical_string_r (subcomp);
1698
icalobj = (gchar *) icalcomponent_as_ical_string_r (subcomp);
1699
1699
d(printf ("Create a new object : %s\n", icalobj));
1701
1701
e_cal_backend_exchange_cache_unlock (cbex);
1722
1722
case ICAL_METHOD_CANCEL:
1723
icalobj = (char *) icalcomponent_as_ical_string_r (subcomp);
1723
icalobj = (gchar *) icalcomponent_as_ical_string_r (subcomp);
1725
1725
status = remove_object (backend, cal, uid, rid, CALOBJ_MOD_THIS, &icalobj, &object);
1767
1767
static ECalBackendExchangeBookingResult
1768
1768
book_resource (ECalBackendExchange *cbex,
1770
const char *resource_email,
1770
const gchar *resource_email,
1771
1771
ECalComponent *comp,
1772
1772
icalproperty_method method,
1773
1773
icalparameter *part_param)
1785
1785
icaltimezone *izone;
1786
1786
guint32 access = 0;
1788
const char *uid, *prop_name = PR_ACCESS;
1789
const char *access_prop = NULL, *meeting_prop = NULL, *cal_uid = NULL;
1788
const gchar *uid, *prop_name = PR_ACCESS;
1789
const gchar *access_prop = NULL, *meeting_prop = NULL, *cal_uid = NULL;
1790
1790
gboolean bookable;
1791
char *top_uri = NULL, *cal_uri = NULL, *returned_uid = NULL;
1792
char *startz, *endz, *href = NULL, *old_object = NULL, *calobj = NULL, *new_object = NULL;
1791
gchar *top_uri = NULL, *cal_uri = NULL, *returned_uid = NULL;
1792
gchar *startz, *endz, *href = NULL, *old_object = NULL, *calobj = NULL, *new_object = NULL;
1793
1793
E2kRestriction *rn;
1795
1795
ECalBackendExchangeBookingResult retval = E_CAL_BACKEND_EXCHANGE_BOOKING_ERROR;
1796
const char *localfreebusy_path = "NON_IPM_SUBTREE/Freebusy%20Data/LocalFreebusy.EML";
1796
const gchar *localfreebusy_path = "NON_IPM_SUBTREE/Freebusy%20Data/LocalFreebusy.EML";
1798
1798
g_object_ref (comp);
1872
1872
e_cal_backend_exchange_cache_unlock (cbex);
1874
1874
if (method == ICAL_METHOD_CANCEL) {
1875
char *object = NULL;
1875
gchar *object = NULL;
1877
1877
/* g_object_unref (comp); */
1878
1878
/* If there is nothing to cancel, we're good */
1968
1968
icalparameter_set_partstat (part_param, ICAL_PARTSTAT_ACCEPTED);
1970
1970
e_cal_component_commit_sequence (comp);
1971
calobj = (char *) e_cal_component_get_as_string (comp);
1971
calobj = (gchar *) e_cal_component_get_as_string (comp);
1973
1973
/* status = e_cal_component_update (comp, method, FALSE ); */
2012
2012
static ECalBackendSyncStatus
2013
2013
send_objects (ECalBackendSync *backend, EDataCal *cal,
2015
GList **users, char **modified_calobj)
2014
const gchar *calobj,
2015
GList **users, gchar **modified_calobj)
2017
2017
ECalBackendExchange *cbex = (ECalBackendExchange *) backend;
2018
2018
ECalBackendSyncStatus retval = GNOME_Evolution_Calendar_Success;
2104
2104
result = book_resource (cbex, cal, attendee + 7, comp, method, param);
2105
2105
switch (result) {
2106
2106
case E_CAL_BACKEND_EXCHANGE_BOOKING_OK:
2107
*users = g_list_append (*users, g_strdup (attendee)) ;
2107
*users = g_list_append (*users, g_strdup (attendee));
2110
2110
case E_CAL_BACKEND_EXCHANGE_BOOKING_BUSY:
2182
set_freebusy_info (icalcomponent *vfb, const char *data, time_t start)
2182
set_freebusy_info (icalcomponent *vfb, const gchar *data, time_t start)
2184
const char *span_start, *span_end;
2184
const gchar *span_start, *span_end;
2185
2185
E2kBusyStatus busy;
2186
2186
icalproperty *prop;
2204
2204
static ECalBackendSyncStatus
2205
2205
discard_alarm (ECalBackendSync *backend, EDataCal *cal,
2206
const char *uid, const char *auid)
2206
const gchar *uid, const gchar *auid)
2208
2208
ECalBackendSyncStatus result = GNOME_Evolution_Calendar_Success;
2209
2209
ECalBackendExchange *cbex = NULL;
2210
2210
ECalBackendExchangeComponent *ecbexcomp;
2211
2211
ECalComponent *ecomp;
2213
2213
icalcomponent *icalcomp = NULL;
2215
2215
g_return_val_if_fail (E_IS_CAL_BACKEND_EXCHANGE_CALENDAR (backend),
2293
2293
g_string_append (uri, "&interval=30");
2294
2294
for (l = users; l; l = l->next) {
2295
2295
g_string_append (uri, "&u=SMTP:");
2296
g_string_append (uri, (char *) l->data);
2296
g_string_append (uri, (gchar *) l->data);
2298
2298
g_free (start_str);
2299
2299
g_free (end_str);
2341
2341
if (node && node->children && node->children->content) {
2342
2342
icalparameter *cn;
2344
content = (char *) node->children->content;
2344
content = (gchar *) node->children->content;
2345
2345
cn = icalparameter_new_cn (content);
2346
2346
icalproperty_add_parameter (organizer, cn);
2351
2351
icalcomponent_set_dtend (vfb, icaltime_from_timet_with_zone (end, 0, utc));
2352
2352
icalcomponent_add_property (vfb, organizer);
2354
content = (char *) fbdata->children->content;
2354
content = (gchar *) fbdata->children->content;
2355
2355
set_freebusy_info (vfb, content, start);
2357
2357
calobj = icalcomponent_as_ical_string_r (vfb);
2407
2407
sync_class->remove_object_sync = remove_object;
2408
2408
sync_class->receive_objects_sync = receive_objects;
2409
2409
sync_class->send_objects_sync = send_objects;
2410
sync_class->get_freebusy_sync = get_free_busy;
2410
sync_class->get_freebusy_sync = get_free_busy;
2411
2411
sync_class->discard_alarm_sync = discard_alarm;
2413
2413
object_class->dispose = dispose;