2
Common conversion routines for exchange2ical
6
Copyright (C) Julien Kerihuel 2008
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 3 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#include <libexchange2ical/libexchange2ical.h>
27
/*Taken from Samba4 code*/
29
this base64 decoder was taken from jitterbug (written by tridge).
30
we might need to replace it with a new version
32
static int ldb_base64_decode(char *s)
34
const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
35
int bit_offset=0, byte_offset, idx, i, n;
36
uint8_t *d = (uint8_t *)s;
41
while (*s && (p=strchr(b64,*s))) {
43
byte_offset = (i*6)/8;
45
d[byte_offset] &= ~((1<<(8-bit_offset))-1);
47
d[byte_offset] |= (idx << (2-bit_offset));
50
d[byte_offset] |= (idx >> (bit_offset-2));
52
d[byte_offset+1] |= (idx << (8-(bit_offset-2))) & 0xFF;
57
if (bit_offset >= 3) {
62
/* the only termination allowed */
74
void ical2exchange_property_ATTACH(struct ical2exchange *ical2exchange)
77
char *extension = NULL;
78
char *filename = NULL;
79
const char *fmttype = NULL;
80
icalattach *icalattach = NULL;
81
icalparameter *fmttypePar = NULL;
82
icalparameter *xfilePar = NULL;
83
const char *xname = NULL;
84
icalproperty *attachProp = NULL;
87
if(!ical2exchange->attachEvent) return;
89
attachProp=icalcomponent_get_first_property(ical2exchange->attachEvent, ICAL_ATTACH_PROPERTY);
92
icalattach = icalproperty_get_attach(attachProp);
93
data = ldb_base64_decode((char *) icalattach_get_data (icalattach));
96
fmttypePar = icalproperty_get_first_parameter(attachProp, ICAL_FMTTYPE_PARAMETER);
98
fmttype = icalparameter_get_fmttype(fmttypePar);
102
xfilePar = icalproperty_get_first_parameter(attachProp, ICAL_X_PARAMETER);
104
xname = icalparameter_get_xname(xfilePar);
105
if(!strcmp(xname,"X-FILENAME")){
106
filename = (char *) icalparameter_get_x(xfilePar);
115
strncpy(buff,filename, 255);
117
extension = strtok(buff, ".");
118
while((temp = strtok(NULL, "."))) extension = temp;
121
printf("Create a new attachment object with\n");
122
printf(" set PidTagAttachDataBinary to %d\n", data);
123
printf(" set PidTagAttachExtension to %s\n", extension);
124
printf(" set PidTagAttachFilename to %s\n", filename);
125
printf(" set PidTagAttachLongFilename to %s\n", filename);
126
printf(" set PidTagAttachMimeTag to %s\n", fmttype);
127
printf(" set PidTagAttachFlags to 0x00000000\n");
128
printf(" set PidTagAttachMethod to 0x00000001\n");
129
printf(" set PidTagAttachmentContactPhoto to FALSE\n");
130
printf(" set PidTagAttachmentFlags to 0x00000000\n");
131
printf(" set PidTagAttachEncoding to empty SBinary");
132
printf(" set PidTagAttachmentHidden to FALSE\n");
133
printf(" set PidTagAttachmentLinkId to 0x00000000\n");
134
printf(" set PidTagDisplayName to %s\n", filename);
135
printf(" set PidTagExceptionEndTime to 0x0CB34557A3DD4000\n");
136
printf(" set PidTagExceptionStartTime to 0x0CB34557A3DD4000\n");
137
printf(" set PidTagRenderingPosition to 0xFFFFFFFF\n");
139
attachProp=icalcomponent_get_next_property(ical2exchange->attachEvent, ICAL_ATTACH_PROPERTY);
145
void ical2exchange_property_CATEGORIES(struct ical2exchange *ical2exchange)
147
struct StringArray_r *sArray;
148
char **stringArray = NULL;
152
icalproperty *categoriesProp;
156
if(!ical2exchange->categoriesEvent) return;
158
sArray = talloc(ical2exchange->mem_ctx, struct StringArray_r);
160
categoriesProp = icalcomponent_get_first_property(ical2exchange->categoriesEvent, ICAL_CATEGORIES_PROPERTY);
162
while(categoriesProp){
164
value = strdup(icalproperty_get_categories(categoriesProp));
165
tok = strtok(value, ",");
168
stringArray = talloc_array(ical2exchange->mem_ctx, char *, 1);
170
stringArray = talloc_realloc(ical2exchange->mem_ctx, stringArray, char *, sArray->cValues+2);
174
if (strlen(string) == 255) break;
175
//remove beginning and ending white spaces
176
if((tok[i]!= ' ' || (tok[i+1] && tok[i+1] != ' ')) && (strlen(string) || tok[i]!=' ')){
177
strncat(string, &tok[i], 1);
181
stringArray[sArray->cValues] = talloc_strdup(ical2exchange->mem_ctx, string);
184
tok= strtok(NULL, ",");
186
categoriesProp = icalcomponent_get_next_property(ical2exchange->categoriesEvent, ICAL_CATEGORIES_PROPERTY);
189
sArray->lppszA= (const char **) stringArray;
192
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidNameKeywords,
193
(const void *) sArray);
196
void ical2exchange_property_CLASS(struct ical2exchange *ical2exchange)
198
enum icalproperty_class class;
203
if(!ical2exchange->classProp) return;
205
class = icalproperty_get_class(ical2exchange->classProp);
208
case ICAL_CLASS_PUBLIC:
214
case ICAL_CLASS_PRIVATE:
217
case ICAL_CLASS_CONFIDENTIAL:
220
case ICAL_CLASS_NONE:
224
tag = talloc(ical2exchange->mem_ctx, uint32_t);
228
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PR_SENSITIVITY,
232
void ical2exchange_property_COMMENT(struct ical2exchange *ical2exchange)
237
if(!ical2exchange->commentProp) return;
238
if(ical2exchange->method != ICAL_METHOD_COUNTER && ical2exchange->method != ICAL_METHOD_REPLY) return;
240
comment = icalproperty_get_comment(ical2exchange->commentProp);
241
comment = talloc_strdup(ical2exchange->mem_ctx, comment);
244
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PR_BODY,
245
(const void *) comment);
248
void ical2exchange_property_CONTACT(struct ical2exchange *ical2exchange)
250
struct StringArray_r *sArray;
252
char **stringArray = NULL;
253
icalproperty *contactProp;
256
if(!ical2exchange->contactEvent) return;
259
contactProp=icalcomponent_get_first_property(ical2exchange->contactEvent, ICAL_CONTACT_PROPERTY);
260
sArray = talloc(ical2exchange->mem_ctx, struct StringArray_r);
264
stringArray = talloc_array(ical2exchange->mem_ctx, char *, 1);
266
stringArray = talloc_realloc(ical2exchange->mem_ctx, stringArray, char *, sArray->cValues+2);
268
value = strdup(icalproperty_get_contact(contactProp));
269
if(strlen(value)<500){
270
stringArray[sArray->cValues] = talloc_strdup(ical2exchange->mem_ctx, value);
273
stringArray[sArray->cValues] = talloc_strndup(ical2exchange->mem_ctx, value, 500);
276
contactProp=icalcomponent_get_next_property(ical2exchange->contactEvent, ICAL_CONTACT_PROPERTY);
280
sArray->lppszA=(const char **) stringArray;
283
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidContacts,
284
(const void *) sArray);
288
void ical2exchange_property_DESCRIPTION(struct ical2exchange *ical2exchange)
290
const char *description;
293
if(!ical2exchange->descriptionProp) return;
295
if(ical2exchange->method == ICAL_METHOD_COUNTER || ical2exchange->method == ICAL_METHOD_REPLY) return;
297
description = icalproperty_get_description(ical2exchange->descriptionProp);
298
description = talloc_strdup(ical2exchange->mem_ctx, description);
301
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PR_BODY,
302
(const void *) description);
305
void ical2exchange_property_DTSTAMP(struct ical2exchange *ical2exchange)
308
icaltimetype dtstamp;
311
if(!ical2exchange->dtstampProp) return;
313
dtstamp = icalproperty_get_dtstamp(ical2exchange->dtstampProp);
314
ft = talloc(ical2exchange->mem_ctx, struct FILETIME);
315
*ft = get_FILETIME_from_icaltimetype(&dtstamp);
317
if(ical2exchange->method == ICAL_METHOD_COUNTER || ical2exchange->method == ICAL_METHOD_REPLY){
318
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAttendeeCriticalChange,
321
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidOwnerCriticalChange,
326
void ical2exchange_property_DTSTART_DTEND(struct ical2exchange *ical2exchange)
328
icaltimetype dtstart;
330
struct FILETIME *startft;
331
struct FILETIME *endft;
336
if(!ical2exchange->dtstartProp) return;
337
if(!ical2exchange->dtendProp) return;
340
dtstart = icalproperty_get_dtstart(ical2exchange->dtstartProp);
341
startft = talloc(ical2exchange->mem_ctx, struct FILETIME);
342
*startft = get_FILETIME_from_icaltimetype(&dtstart);
345
dtend = icalproperty_get_dtend(ical2exchange->dtendProp);
346
endft = talloc(ical2exchange->mem_ctx, struct FILETIME);
347
*endft = get_FILETIME_from_icaltimetype(&dtend);
349
if(ical2exchange->method == ICAL_METHOD_COUNTER){
350
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentProposedStartWhole,
351
(const void *) startft);
352
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentProposedEndWhole,
353
(const void *) endft);
355
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentStartWhole,
356
(const void *) startft);
357
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentEndWhole,
358
(const void *) endft);
360
/*duration property*/
361
duration = talloc(ical2exchange->mem_ctx, uint32_t);
362
difference = difftime(nt_time_to_unix(FILETIME_to_NTTIME(*endft)),
363
nt_time_to_unix(FILETIME_to_NTTIME(*startft)));
364
*duration = difference/60;
365
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentDuration,
366
(const void *) duration);
367
/*check if all day appointment*/
368
if(*duration==1440 && dtstart.hour==0 && dtstart.minute==0){
369
uint32_t *allday = talloc(ical2exchange->mem_ctx, uint32_t);
370
*allday = 0x00000001;
371
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentSubType,
372
(const void *) allday);
377
void ical2exchange_property_LOCATION(struct ical2exchange *ical2exchange)
380
char location[256] = "";
381
icalparameter *param = NULL;
386
if(!ical2exchange->locationProp) return;
388
value = icalproperty_get_location(ical2exchange->locationProp);
391
for(i=0; i<255; i++){
394
if(c !='\xD' && c!='\xA' )
395
strncat(location, &c, 1);
397
string = talloc_strdup(ical2exchange->mem_ctx, location);
400
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidLocation,
401
(const void *) string);
403
if((param=icalproperty_get_first_parameter(ical2exchange->locationProp, ICAL_LANGUAGE_PARAMETER))){
404
const char* langName;
405
langtag = talloc(ical2exchange->mem_ctx, uint32_t);
406
langName = icalparameter_get_language(param);
407
*langtag = mapi_get_lcid_from_language(langName);
408
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PR_MESSAGE_LOCALE_ID,
409
(const void *) langtag);
414
void ical2exchange_property_PRIORITY(struct ical2exchange *ical2exchange)
419
if(ical2exchange->x_importanceProp){
420
const char *value = icalproperty_get_x(ical2exchange->x_importanceProp);
432
} else if(ical2exchange->priorityProp){
433
switch(icalproperty_get_priority(ical2exchange->priorityProp)){
456
tag = talloc(ical2exchange->mem_ctx, uint32_t);
460
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentSequence,
465
void ical2exchange_property_RRULE_EXDATE_RDATE(struct ical2exchange *ical2exchange)
467
struct RecurrencePattern rp;
468
struct icalrecurrencetype irt;
469
struct icaltimetype next;
470
struct icaltimetype last;
471
icalrecur_iterator *ritr;
472
icaltimetype dtstart;
475
icalproperty *exdateProp;
476
icalproperty *rdateProp;
477
enum CalendarType calendarType;
478
enum EndType endType;
479
enum icalrecurrencetype_weekday weekday;
482
uint32_t occurrenceCount;
484
uint32_t modifiedInstanceDates[ical2exchange->rdateCount];
485
uint32_t deletedInstanceDates[ical2exchange->exdateCount+ical2exchange->rdateCount];
487
if(!ical2exchange->rruleProp) return;
488
if(!ical2exchange->dtstartProp) return;
490
irt = icalproperty_get_rrule(ical2exchange->rruleProp);
493
enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day);
494
dtstart = icalproperty_get_dtstart(ical2exchange->dtstartProp);
498
startTime = get_minutes_from_icaltimetype(dtstart);
501
if(irt.week_start == ICAL_NO_WEEKDAY){
502
weekday = icalrecurrencetype_day_day_of_week(icaltime_day_of_week(dtstart));
504
weekday = irt.week_start;
508
//if(ical2exchange->calscaleProp){
509
//calendarType = get_exchange_calendartype(icalproperty_get_x(ical2exchange->calscaleProp));
512
calendarType = CAL_DEFAULT;
515
/*endType occurrenceCount endTime*/
516
if(irt.count || !icaltime_is_null_time(irt.until)){
517
endType = END_AFTER_N_OCCURRENCES;
518
occurrenceCount = irt.count;
520
ritr = icalrecur_iterator_new(irt,dtstart);
521
next=icalrecur_iterator_next(ritr);
523
while (!icaltime_is_null_time(next)){
525
next=icalrecur_iterator_next(ritr);
527
if(!irt.count) occurrenceCount++;
530
endTime = get_minutes_from_icaltimetype(last);
531
icalrecur_iterator_free(ritr);
534
endType = END_NEVER_END;
535
occurrenceCount = 0x0000000A;
536
endTime = 0x5AE980DF;
539
/*Common values for all rrule*/
540
rp.ReaderVersion = 0x3004;
541
rp.WriterVersion = 0x3004;
542
rp.CalendarType = calendarType;
543
rp.FirstDateTime = startTime;
544
rp.SlidingFlag = 0x00000000;
545
rp.EndType = endType;
546
rp.OccurrenceCount = occurrenceCount;
547
rp.FirstDOW = get_exchange_day_from_ical(weekday);
548
rp.StartDate = startTime;
549
rp.EndDate = endTime;
553
case ICAL_DAILY_RECURRENCE:
554
rp.RecurFrequency = RecurFrequency_Daily;
555
rp.PatternType = PatternType_Day;
556
rp.Period = 1440 * irt.interval;
558
case ICAL_WEEKLY_RECURRENCE:
559
rp.RecurFrequency = RecurFrequency_Weekly;
560
rp.PatternType = PatternType_Day;
561
rp.Period = irt.interval;
563
case ICAL_MONTHLY_RECURRENCE:
564
rp.RecurFrequency = RecurFrequency_Monthly;
565
rp.Period = irt.interval;
567
if(irt.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX){
568
rp.PatternType = PatternType_Month;
570
if(irt.by_month_day[0] == -1){
571
rp.PatternTypeSpecific.Day = 0x0000001F;
573
rp.PatternTypeSpecific.Day = irt.by_month_day[0];
577
rp.PatternType = PatternType_MonthNth;
579
rp.PatternTypeSpecific.MonthRecurrencePattern.WeekRecurrencePattern = 0;
580
while( irt.by_day[i] != ICAL_RECURRENCE_ARRAY_MAX){
581
rp.PatternTypeSpecific.MonthRecurrencePattern.WeekRecurrencePattern |= get_exchange_rdfDays_from_ical(irt.by_day[i]);
584
if(irt.by_set_pos[0] == -1) rp.PatternTypeSpecific.MonthRecurrencePattern.N = RecurrenceN_Last;
585
else rp.PatternTypeSpecific.MonthRecurrencePattern.N = irt.by_set_pos[0];
588
case ICAL_YEARLY_RECURRENCE:
589
rp.RecurFrequency = RecurFrequency_Yearly;
590
rp.Period = 12 * irt.interval;
593
if(irt.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX){
594
rp.PatternType = PatternType_Month;
595
if(irt.by_month_day[0] == -1){
596
rp.PatternTypeSpecific.Day = 0x0000001F;
598
rp.PatternTypeSpecific.Day = irt.by_month_day[0];
601
rp.PatternType = PatternType_MonthNth;
603
rp.PatternTypeSpecific.MonthRecurrencePattern.WeekRecurrencePattern = 0;
604
while( irt.by_day[i] != ICAL_RECURRENCE_ARRAY_MAX){
605
rp.PatternTypeSpecific.MonthRecurrencePattern.WeekRecurrencePattern |= get_exchange_rdfDays_from_ical(irt.by_day[i]);
608
if(irt.by_set_pos[0] == -1) rp.PatternTypeSpecific.MonthRecurrencePattern.N = RecurrenceN_Last;
609
else rp.PatternTypeSpecific.MonthRecurrencePattern.N = irt.by_set_pos[0];
613
printf("not handled yet\n");
618
/*deletedInstanceDates & modifiedInstanceDates*/
619
if(ical2exchange->exdateEvent){
620
exdateProp=icalcomponent_get_first_property(ical2exchange->exdateEvent, ICAL_EXDATE_PROPERTY);
622
for(i=0; i<ical2exchange->exdateCount; i++){
623
exdate = icalproperty_get_exdate(exdateProp);
624
deletedInstanceDates[i] = get_minutes_from_icaltimetype(exdate);
625
exdateProp=icalcomponent_get_first_property(ical2exchange->exdateEvent, ICAL_EXDATE_PROPERTY);
629
if(ical2exchange->rdateEvent){
630
rdateProp = icalcomponent_get_first_property(ical2exchange->rdateEvent, ICAL_EXDATE_PROPERTY);
632
for(i=0; i<ical2exchange->rdateCount; i++){
633
rdate = icalproperty_get_exdate(rdateProp);
634
deletedInstanceDates[i + ical2exchange->exdateCount] = get_minutes_from_icaltimetype(rdate);
635
modifiedInstanceDates[i] = get_minutes_from_icaltimetype(rdate);
636
rdateProp = icalcomponent_get_first_property(ical2exchange->rdateEvent, ICAL_EXDATE_PROPERTY);
640
qsort(deletedInstanceDates, ical2exchange->rdateCount + ical2exchange->exdateCount, sizeof(uint32_t), compare_minutes);
641
qsort(modifiedInstanceDates, ical2exchange->rdateCount, sizeof(uint32_t), compare_minutes);
643
rp.DeletedInstanceCount = ical2exchange->rdateCount + ical2exchange->exdateCount;
644
rp.ModifiedInstanceCount = ical2exchange->rdateCount;
646
rp.DeletedInstanceDates = deletedInstanceDates;
647
rp.ModifiedInstanceDates = modifiedInstanceDates;
652
void ical2exchange_property_SEQUENCE(struct ical2exchange *ical2exchange)
657
if(ical2exchange->x_sequenceProp){
658
temp = atoi(icalproperty_get_x(ical2exchange->x_sequenceProp));
659
} else if(ical2exchange->sequenceProp){
660
temp = icalproperty_get_sequence(ical2exchange->sequenceProp);
663
tag = talloc(ical2exchange->mem_ctx, uint32_t);
667
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentSequence,
671
void ical2exchange_property_STATUS(struct ical2exchange *ical2exchange)
674
enum icalproperty_status status;
675
enum icalproperty_transp transp;
680
if(ical2exchange->x_busystatusProp){
681
prop=icalproperty_get_x(ical2exchange->x_busystatusProp);
683
if(!strcmp(prop, "FREE")){
685
} else if(!strcmp(prop, "TENTATIVE")){
687
} else if(!strcmp(prop, "BUSY")){
689
} else if(!strcmp(prop, "OOF")){
693
} else if(ical2exchange->transpProp){
694
transp = icalproperty_get_transp(ical2exchange->transpProp);
696
case ICAL_TRANSP_TRANSPARENT:
699
case ICAL_TRANSP_OPAQUE:
706
} else if(ical2exchange->statusProp){
707
status = icalproperty_get_status(ical2exchange->classProp);
709
case ICAL_STATUS_CANCELLED:
712
case ICAL_STATUS_TENTATIVE:
715
case ICAL_STATUS_CONFIRMED:
723
tag = talloc(ical2exchange->mem_ctx, uint32_t);
727
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidBusyStatus,
731
void ical2exchange_property_SUMMARY(struct ical2exchange *ical2exchange)
735
char summary[256] = "";
736
icalparameter *param = NULL;
740
if(!ical2exchange->summaryProp) return;
742
value = icalproperty_get_summary(ical2exchange->summaryProp);
746
for(i=0; i<255; i++){
749
if(c !='\xD' && c!='\xA' )
750
strncat(summary, &c, 1);
752
string = talloc_strdup(ical2exchange->mem_ctx, summary);
754
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PR_SUBJECT,
755
(const void *) string);
756
if((param=icalproperty_get_first_parameter(ical2exchange->summaryProp, ICAL_LANGUAGE_PARAMETER))){
757
const char *langName;
758
langName = icalparameter_get_language(param);
759
langtag = mapi_get_lcid_from_language(langName);
760
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PR_MESSAGE_LOCALE_ID,
761
(const void *) &langtag);
765
void ical2exchange_property_VALARM(struct ical2exchange *ical2exchange)
767
icalproperty *triggerProp = NULL;
769
icaltimetype dtstart;
770
icaltimetype current;
771
icaltimetype triggerSet;
774
const icaltimezone *timezone;
775
struct FILETIME *rtimeft;
776
struct FILETIME *rsignalft;
777
struct icalrecurrencetype irt;
778
icalrecur_iterator *ritr;
779
struct icaltriggertype trigger;
784
if(!ical2exchange->valarmEvent) return;
785
if(!ical2exchange->dtstartProp) return;
787
triggerProp = icalcomponent_get_first_property(ical2exchange->valarmEvent, ICAL_TRIGGER_PROPERTY);
788
if(!triggerProp) return;
790
trigger = icalproperty_get_trigger(triggerProp);
791
dtstart = icalproperty_get_dtstart(ical2exchange->dtstartProp);
792
duration = talloc(ical2exchange->mem_ctx, uint32_t);
794
if(trigger.duration.is_neg){
795
*duration = -trigger.duration.minutes;
797
*duration = trigger.duration.minutes;
800
timezone = icaltime_get_timezone(dtstart);
801
current = icaltime_current_time_with_zone(timezone);
803
if(icaltime_compare(dtstart, current)) {
804
rtimeft = talloc(ical2exchange->mem_ctx, struct FILETIME);
805
rsignalft = talloc(ical2exchange->mem_ctx, struct FILETIME);
807
*rtimeft = get_FILETIME_from_icaltimetype(&dtstart);
808
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidReminderTime,
809
(const void *) rtimeft);
811
triggerSet = icaltime_add(dtstart, trigger.duration);
812
*rsignalft = get_FILETIME_from_icaltimetype(&triggerSet);
813
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidReminderSignalTime,
814
(const void *) rsignalft);
815
} else if(ical2exchange->rruleProp) {
816
irt = icalproperty_get_rrule(ical2exchange->rruleProp);
817
ritr = icalrecur_iterator_new(irt,dtstart);
818
next = icalrecur_iterator_next(ritr);
820
while (!icaltime_is_null_time(next)){
821
if(icaltime_compare(next, current)) {
822
rtimeft = talloc(ical2exchange->mem_ctx, struct FILETIME);
823
rsignalft = talloc(ical2exchange->mem_ctx, struct FILETIME);
825
*rtimeft = get_FILETIME_from_icaltimetype(&next);
826
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidReminderTime,
827
(const void *) rtimeft);
829
triggerSet = icaltime_add(next, trigger.duration);
830
*rsignalft = get_FILETIME_from_icaltimetype(&triggerSet);
831
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidReminderSignalTime,
832
(const void *) &rsignalft);
835
next=icalrecur_iterator_next(ritr);
839
set = talloc(ical2exchange->mem_ctx, bool);
842
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidReminderSet,
844
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidReminderDelta,
845
(const void *) duration);
848
void ical2exchange_property_X_ALLOWEXTERNCHECK(struct ical2exchange *ical2exchange)
853
if(!ical2exchange->x_allowexterncheckProp) return;
855
prop=icalproperty_get_x(ical2exchange->x_allowexterncheckProp);
856
allow = talloc(ical2exchange->mem_ctx, bool);
858
if(strcmp(prop, "TRUE")){
863
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAllowExternalCheck,
864
(const void *) allow);
867
void ical2exchange_property_X_APPTSEQTIME(struct ical2exchange *ical2exchange)
872
if(!ical2exchange->x_apptseqtimeProp) return;
874
ft = talloc(ical2exchange->mem_ctx, struct FILETIME);
876
prop=icalproperty_get_x(ical2exchange->x_apptseqtimeProp);
877
*ft = get_FILETIME_from_string(prop);
879
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentSequenceTime,
883
void ical2exchange_property_X_APPTLASTSEQUENCE(struct ical2exchange *ical2exchange)
888
if(!ical2exchange->x_apptlastsequenceProp) return;
890
prop=icalproperty_get_x(ical2exchange->x_apptlastsequenceProp);
891
tag = talloc(ical2exchange->mem_ctx, uint32_t);
894
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentLastSequence,
898
void ical2exchange_property_X_ATTENDEE_CRITICAL_CHANGE(struct ical2exchange *ical2exchange)
903
if(!ical2exchange->x_attendeecriticalchangeProp) return;
905
prop=icalproperty_get_x(ical2exchange->x_attendeecriticalchangeProp);
906
ft = talloc(ical2exchange->mem_ctx, struct FILETIME);
907
*ft = get_FILETIME_from_string(prop);
909
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAttendeeCriticalChange,
913
void ical2exchange_property_X_AUTOFILLLOCATION(struct ical2exchange *ical2exchange)
918
if(!ical2exchange->x_autofilllocationProp) return;
920
prop=icalproperty_get_x(ical2exchange->x_autofilllocationProp);
921
autoFill = talloc(ical2exchange->mem_ctx, bool);
923
if(strcmp(prop, "TRUE")){
929
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAutoFillLocation,
930
(const void *) autoFill);
933
void ical2exchange_property_X_AUTOSTARTCHECK(struct ical2exchange *ical2exchange)
938
if(!ical2exchange->x_autostartcheckProp) return;
940
prop=icalproperty_get_x(ical2exchange->x_autostartcheckProp);
941
autoStart = talloc(ical2exchange->mem_ctx, bool);
943
if(strcmp(prop, "TRUE")){
949
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAutoStartCheck,
950
(const void *) autoStart);
953
void ical2exchange_property_X_COLLABORATEDDOC(struct ical2exchange *ical2exchange)
957
if(!ical2exchange->x_collaborateddocProp) return;
959
prop=icalproperty_get_x(ical2exchange->x_collaborateddocProp);
961
prop = talloc_strdup(ical2exchange->mem_ctx, prop);
963
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidCollaborateDoc,
964
(const void *) prop);
967
void ical2exchange_property_X_CONFCHECK(struct ical2exchange *ical2exchange)
972
if(!ical2exchange->x_confcheckProp) return;
974
prop=icalproperty_get_x(ical2exchange->x_confcheckProp);
975
confCheck = talloc(ical2exchange->mem_ctx, bool);
977
if(strcmp(prop, "TRUE")){
983
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidConferencingCheck,
984
(const void *) confCheck);
987
void ical2exchange_property_X_CONFTYPE(struct ical2exchange *ical2exchange)
992
if(!ical2exchange->x_conftypeProp) return;
994
prop=icalproperty_get_x(ical2exchange->x_conftypeProp);
995
tag = talloc(ical2exchange->mem_ctx, uint32_t);
998
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidConferencingType,
1002
void ical2exchange_property_X_DISALLOW_COUNTER(struct ical2exchange *ical2exchange)
1007
if(!ical2exchange->x_disallowcounterProp) return;
1009
prop=icalproperty_get_x(ical2exchange->x_disallowcounterProp);
1010
disallow = talloc(ical2exchange->mem_ctx, bool);
1012
if(strcmp(prop, "TRUE")){
1018
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentNotAllowPropose,
1019
(const void *) disallow);
1022
void ical2exchange_property_X_INTENDEDSTATUS(struct ical2exchange *ical2exchange)
1027
if(!ical2exchange->x_intendedProp) return;
1029
prop=icalproperty_get_x(ical2exchange->x_intendedProp);
1030
tag = talloc(ical2exchange->mem_ctx,uint32_t);
1032
if(!strcmp(prop, "FREE")){
1034
} else if(!strcmp(prop, "TENTATIVE")){
1036
} else if(!strcmp(prop, "BUSY")){
1038
} else if(!strcmp(prop, "OOF")){
1043
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidIntendedBusyStatus,
1044
(const void *) tag);
1047
void ical2exchange_property_X_ISDRAFT(struct ical2exchange *ical2exchange)
1052
isDraft = talloc(ical2exchange->mem_ctx, bool);
1054
if(ical2exchange->method == ICAL_METHOD_COUNTER || ical2exchange->method == ICAL_METHOD_REPLY
1055
|| ical2exchange->method == ICAL_METHOD_REQUEST || ical2exchange->method == ICAL_METHOD_CANCEL){
1059
if(ical2exchange->x_isdraftProp){
1060
prop=icalproperty_get_x(ical2exchange->x_isdraftProp);
1061
if(strcmp(prop, "TRUE")){
1071
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidFInvited,
1072
(const void *) isDraft);
1075
void ical2exchange_property_X_MWSURL(struct ical2exchange *ical2exchange)
1080
if(!ical2exchange->x_mwsurlProp) return;
1082
prop = icalproperty_get_x(ical2exchange->x_mwsurlProp);
1083
mwsurl = talloc_strdup(ical2exchange->mem_ctx, prop);
1085
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidMeetingWorkspaceUrl,
1086
(const void *) mwsurl);
1089
void ical2exchange_property_X_NETSHOWURL(struct ical2exchange *ical2exchange)
1094
if(!ical2exchange->x_netshowurlProp) return;
1096
prop = icalproperty_get_x(ical2exchange->x_netshowurlProp);
1097
netshow = talloc_strdup(ical2exchange->mem_ctx, prop);
1099
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidNetShowUrl,
1100
(const void *) netshow);
1103
void ical2exchange_property_X_ONLINEPASSWORD(struct ical2exchange *ical2exchange)
1108
if(!ical2exchange->x_onlinepasswordProp) return;
1110
prop = icalproperty_get_x(ical2exchange->x_onlinepasswordProp);
1111
onlinepass = talloc_strdup(ical2exchange->mem_ctx, prop);
1113
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidOnlinePassword,
1114
(const void *) onlinepass);
1117
void ical2exchange_property_X_ORGALIAS(struct ical2exchange *ical2exchange)
1122
if(!ical2exchange->x_orgaliasProp) return;
1124
prop = icalproperty_get_x(ical2exchange->x_orgaliasProp);
1125
orgalias = talloc_strdup(ical2exchange->mem_ctx, prop);
1127
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidOrganizerAlias,
1128
(const void *) orgalias);
1131
void ical2exchange_property_X_ORIGINALEND_ORIGINALSTART(struct ical2exchange *ical2exchange)
1137
struct FILETIME startft;
1138
struct FILETIME endft;
1141
if(!ical2exchange->x_originalendProp) return;
1142
if(!ical2exchange->x_originalstartProp) return;
1143
if(ical2exchange->method != ICAL_METHOD_COUNTER) return;
1145
start = icalproperty_get_x(ical2exchange->x_originalstartProp);
1146
end = icalproperty_get_x(ical2exchange->x_originalendProp);
1148
startft = get_FILETIME_from_string(start);
1149
endft = get_FILETIME_from_string(end);
1151
/*duration property*/
1152
difference = difftime(nt_time_to_unix(FILETIME_to_NTTIME(endft)),
1153
nt_time_to_unix(FILETIME_to_NTTIME(startft)));
1154
duration = difference/60;
1156
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentStartWhole,
1157
(const void *) &startft);
1158
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentEndWhole,
1159
(const void *) &endft);
1160
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentDuration,
1161
(const void *) &duration);
1165
void ical2exchange_property_X_OWNER_CRITICAL_CHANGE(struct ical2exchange *ical2exchange)
1170
if(!ical2exchange->x_ownercriticalchangeProp) return;
1172
prop=icalproperty_get_x(ical2exchange->x_ownercriticalchangeProp);
1173
ft = get_FILETIME_from_string(prop);
1175
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidOwnerCriticalChange,
1176
(const void *) &ft);
1179
void ical2exchange_property_X_OWNERAPPTID(struct ical2exchange *ical2exchange)
1184
if(!ical2exchange->x_ownerapptidProp) return;
1186
prop=icalproperty_get_x(ical2exchange->x_ownerapptidProp);
1188
tag = talloc(ical2exchange->mem_ctx, uint32_t);
1191
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PR_OWNER_APPT_ID,
1192
(const void *) tag);
1195
void ical2exchange_property_X_REPLYTIME(struct ical2exchange *ical2exchange)
1198
struct FILETIME *ft;
1200
if(!ical2exchange->x_replytimeProp) return;
1202
prop=icalproperty_get_x(ical2exchange->x_replytimeProp);
1203
ft = talloc(ical2exchange->mem_ctx, struct FILETIME);
1204
*ft = get_FILETIME_from_string(prop);
1207
ical2exchange->lpProps = add_SPropValue(ical2exchange->mem_ctx, ical2exchange->lpProps, &ical2exchange->cValues, PidLidAppointmentReplyTime,