28
28
#include "exchange-mapi-cal-recur-utils.h"
30
30
/* Reader/Writer versions */
31
#define READER_VERSION 0x3004
32
#define WRITER_VERSION 0x3004
31
#define READER_VERSION 0x3004
32
#define WRITER_VERSION 0x3004
33
33
#define READER_VERSION2 0x3006
34
34
#define WRITER_VERSION2 0x3009
37
37
struct ChangeHighlight {
43
43
struct ExtendedException {
44
struct ChangeHighlight ch;
44
struct ChangeHighlight ch;
45
45
uint32_t ReservedEE1Size;
46
46
uint32_t ReservedEE1;
47
uint32_t StartDateTime;
49
uint32_t OrigStartDate;
50
uint16_t WideCharSubjectLength;
51
gchar *WideCharSubject;
52
uint16_t WideCharLocationLength;
53
gchar *WideCharLocation;
47
uint32_t StartDateTime;
49
uint32_t OrigStartDate;
50
uint16_t WideCharSubjectLength;
51
gchar *WideCharSubject;
52
uint16_t WideCharLocationLength;
53
gchar *WideCharLocation;
54
54
uint32_t ReservedEE2Size;
55
55
uint32_t ReservedEE2;
58
58
struct ExceptionInfo {
59
uint32_t StartDateTime;
61
uint32_t OrigStartDate;
62
uint16_t OverrideFlags;
63
uint16_t SubjectLength;
64
uint16_t SubjectLength2;
67
uint32_t ReminderDelta;
69
uint16_t LocationLength;
70
uint16_t LocationLength2;
75
uint32_t AppointmentColor;
59
uint32_t StartDateTime;
61
uint32_t OrigStartDate;
62
uint16_t OverrideFlags;
63
uint16_t SubjectLength;
64
uint16_t SubjectLength2;
67
uint32_t ReminderDelta;
69
uint16_t LocationLength;
70
uint16_t LocationLength2;
75
uint32_t AppointmentColor;
79
static icalrecurrencetype_weekday
80
get_ical_weekstart (uint32_t fdow)
79
static icalrecurrencetype_weekday
80
get_ical_weekstart (uint32_t fdow)
83
case FirstDOW_Sunday : return ICAL_SUNDAY_WEEKDAY;
84
case FirstDOW_Monday : return ICAL_MONDAY_WEEKDAY;
85
case FirstDOW_Tuesday : return ICAL_TUESDAY_WEEKDAY;
83
case FirstDOW_Sunday : return ICAL_SUNDAY_WEEKDAY;
84
case FirstDOW_Monday : return ICAL_MONDAY_WEEKDAY;
85
case FirstDOW_Tuesday : return ICAL_TUESDAY_WEEKDAY;
86
86
case FirstDOW_Wednesday : return ICAL_WEDNESDAY_WEEKDAY;
87
case FirstDOW_Thursday : return ICAL_THURSDAY_WEEKDAY;
88
case FirstDOW_Friday : return ICAL_FRIDAY_WEEKDAY;
89
case FirstDOW_Saturday : return ICAL_SATURDAY_WEEKDAY;
90
default : return ICAL_SUNDAY_WEEKDAY;
87
case FirstDOW_Thursday : return ICAL_THURSDAY_WEEKDAY;
88
case FirstDOW_Friday : return ICAL_FRIDAY_WEEKDAY;
89
case FirstDOW_Saturday : return ICAL_SATURDAY_WEEKDAY;
90
default : return ICAL_SUNDAY_WEEKDAY;
95
get_mapi_weekstart (icalrecurrencetype_weekday weekstart)
95
get_mapi_weekstart (icalrecurrencetype_weekday weekstart)
97
97
switch (weekstart) {
98
98
case ICAL_SUNDAY_WEEKDAY : return FirstDOW_Sunday;
102
102
case ICAL_THURSDAY_WEEKDAY : return FirstDOW_Thursday;
103
103
case ICAL_FRIDAY_WEEKDAY : return FirstDOW_Friday;
104
104
case ICAL_SATURDAY_WEEKDAY : return FirstDOW_Saturday;
105
default : return FirstDOW_Sunday;
105
default : return FirstDOW_Sunday;
110
110
get_mapi_day (icalrecurrencetype_weekday someday)
112
112
switch (someday) {
117
117
case ICAL_THURSDAY_WEEKDAY : return olThursday;
118
118
case ICAL_FRIDAY_WEEKDAY : return olFriday;
119
119
case ICAL_SATURDAY_WEEKDAY : return olSaturday;
125
get_ical_pos (uint32_t pos)
125
get_ical_pos (uint32_t pos)
128
case RecurrenceN_First : return 1;
128
case RecurrenceN_First : return 1;
129
129
case RecurrenceN_Second : return 2;
130
case RecurrenceN_Third : return 3;
130
case RecurrenceN_Third : return 3;
131
131
case RecurrenceN_Fourth : return 4;
132
case RecurrenceN_Last : return (-1);
132
case RecurrenceN_Last : return (-1);
138
get_mapi_pos (int32_t pos)
138
get_mapi_pos (int32_t pos)
141
case 1 : return RecurrenceN_First;
142
case 2 : return RecurrenceN_Second;
143
case 3 : return RecurrenceN_Third;
144
case 4 : return RecurrenceN_Fourth;
141
case 1 : return RecurrenceN_First;
142
case 2 : return RecurrenceN_Second;
143
case 3 : return RecurrenceN_Third;
144
case 4 : return RecurrenceN_Fourth;
145
145
case -1 : return RecurrenceN_Last;
146
146
default : return 0;
154
154
convert_recurrence_minutes_to_date (uint32_t minutes, struct FILETIME *ft)
158
nt = (NTTIME) minutes * (60 * cFileTimeUnitsPerSecond);
160
ft->dwLowDateTime = (uint32_t)((nt << 32) >> 32);
161
ft->dwHighDateTime = (uint32_t)(nt >> 32);
158
nt = (NTTIME) minutes * (60 * cFileTimeUnitsPerSecond);
160
ft->dwLowDateTime = (uint32_t)((nt << 32) >> 32);
161
ft->dwHighDateTime = (uint32_t)(nt >> 32);
169
minutes = ft->dwHighDateTime;
169
minutes = ft->dwHighDateTime;
170
170
minutes = minutes << 32;
171
171
minutes |= ft->dwLowDateTime;
173
minutes = minutes / (60 * cFileTimeUnitsPerSecond);
173
minutes = minutes / (60 * cFileTimeUnitsPerSecond);
175
175
return (uint32_t)(minutes);
179
179
convert_filetime_to_timet (const struct FILETIME *ft)
183
183
time = ft->dwHighDateTime;
184
184
time = time << 32;
187
187
return nt_time_to_unix (time);
191
191
convert_timet_to_filetime (time_t t, struct FILETIME *ft)
195
195
unix_to_nt_time (&nt, t);
197
ft->dwLowDateTime = (uint32_t)((nt << 32) >> 32);
198
ft->dwHighDateTime = (uint32_t)(nt >> 32);
197
ft->dwLowDateTime = (uint32_t)((nt << 32) >> 32);
198
ft->dwHighDateTime = (uint32_t)(nt >> 32);
203
203
convert_recurrence_minutes_to_timet (uint32_t minutes)
207
nt = (NTTIME) minutes * (60 * cFileTimeUnitsPerSecond);
207
nt = (NTTIME) minutes * (60 * cFileTimeUnitsPerSecond);
209
209
return nt_time_to_unix (nt);
217
217
unix_to_nt_time (&minutes, t);
219
minutes = minutes / (60 * cFileTimeUnitsPerSecond);
219
minutes = minutes / (60 * cFileTimeUnitsPerSecond);
221
221
return (uint32_t)(minutes);
225
check_calendar_type (guint16 type)
225
check_calendar_type (guint16 type)
227
227
/* Calendar Type - We support Gregorian only. */
228
228
if (type == CAL_DEFAULT || type == CAL_GREGORIAN)
231
g_warning ("Calendar type = 0x%04X - Evolution does not handle such calendar types.", type);
231
g_warning ("Calendar type = 0x%04X - Evolution does not handle such calendar types.", type);
485
485
else if (flag32 == olSaturday)
486
486
rt.by_day[0] = ICAL_SATURDAY_WEEKDAY;
492
492
/* RecurrenceN */
493
493
flag32 = *((guint32 *)ptr);
494
494
ptr += sizeof (guint32);
495
495
if (!post_process) {
496
rt.by_set_pos[0] = get_ical_pos (flag32);
496
rt.by_set_pos[0] = get_ical_pos (flag32);
497
497
if (rt.by_set_pos[0] == 0)
500
500
if (mask == (olSunday | olMonday | olTuesday | olWednesday | olThursday | olFriday | olSaturday)) {
501
rt.by_month_day[0] = get_ical_pos (flag32);
501
rt.by_month_day[0] = get_ical_pos (flag32);
502
502
if (rt.by_month_day[0] == 0)
505
505
/* FIXME: Can we/LibICAL support any other types here? Namely, weekday and weekend-day */
506
g_warning ("Encountered a recurrence type Evolution cannot handle. ");
506
g_warning ("Encountered a recurrence type Evolution cannot handle. ");
610
610
ptr += sizeof (guint32);
612
612
for (i = 0; i < flag32; ++i) {
614
struct icaltimetype tt, *val;
615
ECalComponentDateTime *dt = g_new0 (ECalComponentDateTime, 1);
614
struct icaltimetype tt, *val;
615
ECalComponentDateTime *dt = g_new0 (ECalComponentDateTime, 1);
617
617
exdate = *((guint32 *)ptr);
618
618
ptr += sizeof (guint32);
620
620
tt = icaltime_from_timet_with_zone (convert_recurrence_minutes_to_timet (exdate), 1, 0);
622
val = g_new0(struct icaltimetype, 1);
623
memcpy (val, &tt, sizeof(struct icaltimetype));
626
dt->tzid = g_strdup ("UTC");
628
exdate_list = g_slist_append (exdate_list, dt);
622
val = g_new0(struct icaltimetype, 1);
623
memcpy (val, &tt, sizeof(struct icaltimetype));
626
dt->tzid = g_strdup ("UTC");
628
exdate_list = g_slist_append (exdate_list, dt);
695
695
e_cal_component_set_rrule_list (comp, &l);
698
698
/* FIXME: this also has modified instances */
699
e_cal_component_set_exdate_list (comp, exdate_list);
699
e_cal_component_set_exdate_list (comp, exdate_list);
701
701
g_print ("\n== MAPI to ICAL == The recurrence blob data is as follows:\n");
702
702
for (i = 0; i < ba->len; ++i)
703
703
g_print ("0x%02X ", ba->data[i]);
704
g_print("\n== End of stream ==\n");
704
g_print("\n== End of stream ==\n");
710
710
compute_startdate (ECalComponent *comp)
712
ECalComponentDateTime dtstart;
712
ECalComponentDateTime dtstart;
715
715
e_cal_component_get_dtstart (comp, &dtstart);
716
dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
716
dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
717
717
flag32 = convert_timet_to_recurrence_minutes (icaltime_as_timet_with_zone (*(dtstart.value), 0));
719
e_cal_component_free_datetime (&dtstart);
719
e_cal_component_free_datetime (&dtstart);
731
731
compute_rweekly_firstdatetime (ECalComponent *comp, icalrecurrencetype_weekday week_start, guint32 period)
733
ECalComponentDateTime dtstart;
735
int cur_weekday = 0, weekstart_weekday = 0, diff = 0;
733
ECalComponentDateTime dtstart;
735
gint cur_weekday = 0, weekstart_weekday = 0, diff = 0;
738
738
e_cal_component_get_dtstart (comp, &dtstart);
739
dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
739
dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
740
740
cur_weekday = icaltime_day_of_week (*(dtstart.value));
741
741
t = icaltime_as_timet_with_zone (*(dtstart.value), 0);
742
e_cal_component_free_datetime (&dtstart);
742
e_cal_component_free_datetime (&dtstart);
744
744
switch (week_start) {
745
case ICAL_SUNDAY_WEEKDAY : weekstart_weekday = 1; break;
746
case ICAL_MONDAY_WEEKDAY : weekstart_weekday = 2; break;
747
case ICAL_TUESDAY_WEEKDAY : weekstart_weekday = 3; break;
748
case ICAL_WEDNESDAY_WEEKDAY : weekstart_weekday = 4; break;
749
case ICAL_THURSDAY_WEEKDAY : weekstart_weekday = 5; break;
750
case ICAL_FRIDAY_WEEKDAY : weekstart_weekday = 6; break;
751
case ICAL_SATURDAY_WEEKDAY : weekstart_weekday = 7; break;
752
default : weekstart_weekday = 1; break;
745
case ICAL_SUNDAY_WEEKDAY : weekstart_weekday = 1; break;
746
case ICAL_MONDAY_WEEKDAY : weekstart_weekday = 2; break;
747
case ICAL_TUESDAY_WEEKDAY : weekstart_weekday = 3; break;
748
case ICAL_WEDNESDAY_WEEKDAY : weekstart_weekday = 4; break;
749
case ICAL_THURSDAY_WEEKDAY : weekstart_weekday = 5; break;
750
case ICAL_FRIDAY_WEEKDAY : weekstart_weekday = 6; break;
751
case ICAL_SATURDAY_WEEKDAY : weekstart_weekday = 7; break;
752
default : weekstart_weekday = 1; break;
755
diff = cur_weekday - weekstart_weekday;
755
diff = cur_weekday - weekstart_weekday;
758
758
else if (diff > 0)
759
759
t -= (diff * 24 * 60 * 60);
760
760
else if (diff < 0)
770
770
compute_rmonthly_firstdatetime (ECalComponent *comp, guint32 period)
772
772
const guint8 dinm[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
773
ECalComponentDateTime dtstart;
774
guint32 flag32, monthindex, i;
773
ECalComponentDateTime dtstart;
774
guint32 flag32, monthindex, i;
776
776
e_cal_component_get_dtstart (comp, &dtstart);
777
monthindex = (guint32)((((guint64)(12) * (dtstart.value->year - 1601)) + (dtstart.value->month - 1)) % period);
778
e_cal_component_free_datetime (&dtstart);
777
monthindex = (guint32)((((guint64)(12) * (dtstart.value->year - 1601)) + (dtstart.value->month - 1)) % period);
778
e_cal_component_free_datetime (&dtstart);
780
780
for (flag32 = 0, i = 0; i < monthindex; ++i)
781
781
flag32 += dinm[(i % 12) + 1] * 24 * 60;
787
787
calculate_no_of_occurrences (ECalComponent *comp, const struct icalrecurrencetype *rt)
789
ECalComponentDateTime dtstart;
790
icalrecur_iterator *iter;
791
struct icaltimetype next;
789
ECalComponentDateTime dtstart;
790
icalrecur_iterator *iter;
791
struct icaltimetype next;
794
794
e_cal_component_get_dtstart (comp, &dtstart);
796
for (iter = icalrecur_iterator_new (*rt, *(dtstart.value)),
796
for (iter = icalrecur_iterator_new (*rt, *(dtstart.value)),
797
797
next = icalrecur_iterator_next(iter);
798
798
!icaltime_is_null_time(next);
799
799
next = icalrecur_iterator_next(iter))
802
icalrecur_iterator_free (iter);
803
e_cal_component_free_datetime (&dtstart);
802
icalrecur_iterator_free (iter);
803
e_cal_component_free_datetime (&dtstart);
809
809
compare_guint32 (gconstpointer a, gconstpointer b, gpointer user_data)
811
811
return (*((guint32 *) a) - *((guint32 *) b));
817
817
struct icalrecurrencetype *rt;
819
819
guint32 flag32, end_type;
821
GSList *rrule_list = NULL, *exdate_list = NULL;
821
GSList *rrule_list = NULL, *exdate_list = NULL;
822
822
GByteArray *ba = NULL;
824
824
if (!e_cal_component_has_recurrences (comp))
827
e_cal_component_get_rrule_list (comp, &rrule_list);
828
e_cal_component_get_exdate_list (comp, &exdate_list);
827
e_cal_component_get_rrule_list (comp, &rrule_list);
828
e_cal_component_get_exdate_list (comp, &exdate_list);
830
830
if (g_slist_length (rrule_list) != 1)
833
833
rt = (struct icalrecurrencetype *)(rrule_list->data);
835
ba = g_byte_array_new ();
835
ba = g_byte_array_new ();
837
837
/* Reader Version */
838
838
flag16 = READER_VERSION;
846
846
flag16 = RecurFrequency_Daily;
847
847
ba = g_byte_array_append (ba, (const guint8 *)&flag16, sizeof (guint16));
849
/* Pattern Type - it would be PatternType_Day since we have only "Daily every N days"
850
* The other type would be parsed as a weekly recurrence.
849
/* Pattern Type - it would be PatternType_Day since we have only "Daily every N days"
850
* The other type would be parsed as a weekly recurrence.
852
852
flag16 = PatternType_Day;
853
853
ba = g_byte_array_append (ba, (const guint8 *)&flag16, sizeof (guint16));
855
855
/* Calendar Type */
856
flag16 = CAL_DEFAULT;
856
flag16 = CAL_DEFAULT;
857
857
ba = g_byte_array_append (ba, (const guint8 *)&flag16, sizeof (guint16));
859
859
/* FirstDateTime */
861
861
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
864
flag32 = (rt->interval * (60 * 24));
864
flag32 = (rt->interval * (60 * 24));
865
865
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
867
867
/* This would be 0 for the stuff we handle */
898
898
for (flag32 = 0x0, i = 0; i < ICAL_BY_DAY_SIZE; ++i) {
899
899
if (rt->by_day[i] == ICAL_SUNDAY_WEEKDAY)
901
901
else if (rt->by_day[i] == ICAL_MONDAY_WEEKDAY)
903
903
else if (rt->by_day[i] == ICAL_TUESDAY_WEEKDAY)
905
905
else if (rt->by_day[i] == ICAL_WEDNESDAY_WEEKDAY)
906
flag32 |= olWednesday;
906
flag32 |= olWednesday;
907
907
else if (rt->by_day[i] == ICAL_THURSDAY_WEEKDAY)
908
flag32 |= olThursday;
908
flag32 |= olThursday;
909
909
else if (rt->by_day[i] == ICAL_FRIDAY_WEEKDAY)
911
911
else if (rt->by_day[i] == ICAL_SATURDAY_WEEKDAY)
912
flag32 |= olSaturday;
912
flag32 |= olSaturday;
916
916
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
918
918
} else if (rt->freq == ICAL_MONTHLY_RECURRENCE) {
919
guint16 pattern = 0x0; guint32 mask = 0x0, flag = 0x0;
919
guint16 pattern = 0x0; guint32 mask = 0x0, flag = 0x0;
921
921
flag16 = RecurFrequency_Monthly;
922
922
ba = g_byte_array_append (ba, (const guint8 *)&flag16, sizeof (guint16));
924
924
if (rt->by_month_day[0] >= 1 && rt->by_month_day[0] <= 31) {
925
925
pattern = PatternType_Month;
926
flag = rt->by_month_day[0];
926
flag = rt->by_month_day[0];
927
927
} else if (rt->by_month_day[0] == -1) {
928
pattern = PatternType_MonthNth;
929
mask = (olSunday | olMonday | olTuesday | olWednesday | olThursday | olFriday | olSaturday);
930
flag = RecurrenceN_Last;
928
pattern = PatternType_MonthNth;
929
mask = (olSunday | olMonday | olTuesday | olWednesday | olThursday | olFriday | olSaturday);
930
flag = RecurrenceN_Last;
931
931
} else if (rt->by_day[0] >= ICAL_SUNDAY_WEEKDAY && rt->by_day[0] <= ICAL_SATURDAY_WEEKDAY) {
932
932
pattern = PatternType_MonthNth;
933
933
mask = get_mapi_day (rt->by_day[0]);
959
959
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
962
g_warning ("Possibly setting incorrect values in the stream. ");
962
g_warning ("Possibly setting incorrect values in the stream. ");
963
963
} else if (pattern == PatternType_MonthNth) {
965
965
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
968
968
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
970
970
if (!(flag && mask))
971
g_warning ("Possibly setting incorrect values in the stream. ");
973
g_warning ("Possibly setting incorrect values in the stream. ");
971
g_warning ("Possibly setting incorrect values in the stream. ");
973
g_warning ("Possibly setting incorrect values in the stream. ");
975
975
} else if (rt->freq == ICAL_YEARLY_RECURRENCE) {
976
976
flag16 = RecurFrequency_Yearly;
989
989
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
991
991
/* INTERVAL - should be 12 for yearly recurrence */
993
993
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
995
995
/* This would be 0 for the stuff we handle */
1001
ECalComponentDateTime dtstart;
1001
ECalComponentDateTime dtstart;
1002
1002
e_cal_component_get_dtstart (comp, &dtstart);
1003
flag32 = dtstart.value->day;
1004
e_cal_component_free_datetime (&dtstart);
1003
flag32 = dtstart.value->day;
1004
e_cal_component_free_datetime (&dtstart);
1006
1006
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1010
1010
/* End Type followed by Occurence count */
1011
1011
if (!icaltime_is_null_time (rt->until)) {
1012
1012
flag32 = END_AFTER_DATE;
1013
1013
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1015
flag32 = calculate_no_of_occurrences (comp, rt);
1015
flag32 = calculate_no_of_occurrences (comp, rt);
1016
1016
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1018
1018
end_type = END_AFTER_DATE;
1038
flag32 = get_mapi_weekstart (rt->week_start);
1038
flag32 = get_mapi_weekstart (rt->week_start);
1039
1039
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1041
1041
/* DeletedInstances */
1042
1042
flag32 = g_slist_length (exdate_list);
1043
1043
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1046
1046
guint32 *sorted_list = g_new0(guint32, flag32);
1047
1047
/* FIXME: This should include modified dates */
1048
1048
for (i = 0, l = exdate_list; l; ++i, l = l->next) {
1049
ECalComponentDateTime *dt = (ECalComponentDateTime *)(l->data);
1050
dt->value->hour = dt->value->minute = dt->value->second = 0;
1051
sorted_list[i] = convert_timet_to_recurrence_minutes (icaltime_as_timet_with_zone (*(dt->value), 0));
1049
ECalComponentDateTime *dt = (ECalComponentDateTime *)(l->data);
1050
dt->value->hour = dt->value->minute = dt->value->second = 0;
1051
sorted_list[i] = convert_timet_to_recurrence_minutes (icaltime_as_timet_with_zone (*(dt->value), 0));
1054
g_qsort_with_data (sorted_list, flag32, sizeof (guint32), compare_guint32, NULL);
1054
g_qsort_with_data (sorted_list, flag32, sizeof (guint32), compare_guint32, NULL);
1056
1056
for (i = 0; i < flag32; ++i)
1057
1057
ba = g_byte_array_append (ba, (const guint8 *)&(sorted_list[i]), sizeof (guint32));
1069
1069
/* StartDate */
1070
flag32 = compute_startdate (comp);
1070
flag32 = compute_startdate (comp);
1071
1071
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1075
if (end_type == END_NEVER_END)
1076
flag32 = 0x5AE980DF;
1075
if (end_type == END_NEVER_END)
1076
flag32 = 0x5AE980DF;
1077
1077
else if (end_type == END_AFTER_N_OCCURRENCES) {
1078
ECalComponentDateTime dtstart;
1079
gchar *rrule_str = icalrecurrencetype_as_string_r (rt);
1080
time_t *array = g_new0 (time_t, rt->count);
1078
ECalComponentDateTime dtstart;
1079
gchar *rrule_str = icalrecurrencetype_as_string_r (rt);
1080
time_t *array = g_new0 (time_t, rt->count);
1082
1082
e_cal_component_get_dtstart (comp, &dtstart);
1083
dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
1085
icalrecur_expand_recurrence (rrule_str, icaltime_as_timet_with_zone (*(dtstart.value), 0), rt->count, array);
1087
flag32 = convert_timet_to_recurrence_minutes (array[(rt->count) - 1]);
1091
e_cal_component_free_datetime (&dtstart);
1083
dtstart.value->hour = dtstart.value->minute = dtstart.value->second = 0;
1085
icalrecur_expand_recurrence (rrule_str, icaltime_as_timet_with_zone (*(dtstart.value), 0), rt->count, array);
1087
flag32 = convert_timet_to_recurrence_minutes (array[(rt->count) - 1]);
1091
e_cal_component_free_datetime (&dtstart);
1092
1092
} else if (end_type == END_AFTER_DATE) {
1093
struct icaltimetype until;
1093
struct icaltimetype until;
1094
1094
memcpy (&until, &(rt->until), sizeof(struct icaltimetype));
1095
until.hour = until.minute = until.second = 0;
1095
until.hour = until.minute = until.second = 0;
1096
1096
flag32 = convert_timet_to_recurrence_minutes (icaltime_as_timet_with_zone (until, 0));
1100
1100
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1110
1110
/* StartTimeOffset */
1112
ECalComponentDateTime dtstart;
1112
ECalComponentDateTime dtstart;
1113
1113
e_cal_component_get_dtstart (comp, &dtstart);
1114
flag32 = (dtstart.value->hour * 60) + dtstart.value->minute;
1115
e_cal_component_free_datetime (&dtstart);
1114
flag32 = (dtstart.value->hour * 60) + dtstart.value->minute;
1115
e_cal_component_free_datetime (&dtstart);
1117
1117
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1119
1119
/* EndTimeOffset */
1121
ECalComponentDateTime dtend;
1121
ECalComponentDateTime dtend;
1122
1122
e_cal_component_get_dtend (comp, &dtend);
1123
flag32 = (dtend.value->hour * 60) + dtend.value->minute;
1124
e_cal_component_free_datetime (&dtend);
1123
flag32 = (dtend.value->hour * 60) + dtend.value->minute;
1124
e_cal_component_free_datetime (&dtend);
1126
1126
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1128
1128
/* FIXME: Add support for modified instances */
1129
1129
/* ModifiedExceptionCount */
1131
1131
ba = g_byte_array_append (ba, (const guint8 *)&flag16, sizeof (guint16));
1133
1133
/* FIXME: Add the ExceptionInfo here */
1143
1143
ba = g_byte_array_append (ba, (const guint8 *)&flag32, sizeof (guint32));
1146
1146
e_cal_component_free_exdate_list (exdate_list);
1147
1147
e_cal_component_free_recur_list (rrule_list);
1149
1149
g_print ("\n== ICAL to MAPI == The recurrence blob data is as follows:\n");
1150
1150
for (i = 0; i < ba->len; ++i)
1151
1151
g_print ("0x%02X ", ba->data[i]);
1152
g_print("\n== End of stream ==\n");
1152
g_print("\n== End of stream ==\n");