-/*@}*/
-/*-----------------------------------------------------------------------**/
-
-
-/**
- * \defgroup MsgDisplayHandlers Display handlers for message reading
- * \ingroup Calendaring
- */
-
-/*@{*/
-
-int Flathash(const char *str, long len)
-{
- if (len != sizeof (int))
- return 0;
- else return *(int*)str;
-}
-
-
-
-/**
- * \brief clean up ical memory
- * todo this could get trouble with future ical versions
+/*
+ * free memory allocated using libical
*/
void delete_cal(void *vCal)
{
icalproperty *ps = NULL;
struct icaltimetype dtstart, dtend;
struct icaldurationtype dur;
- struct wcsession *WCC = WC;
+ wcsession *WCC = WC;
disp_cal *Cal;
size_t len;
time_t final_recurrence = 0;
+ icalcomponent *cptr = NULL;
/* recur variables */
icalproperty *rrule = NULL;
/* Note: anything we do here, we also have to do below for the recurrences. */
Cal = (disp_cal*) malloc(sizeof(disp_cal));
memset(Cal, 0, sizeof(disp_cal));
-
Cal->cal = icalcomponent_new_clone(cal);
- ical_dezonify(Cal->cal); /* just-in-time dezonify is necessary */
+
+ /* Dezonify and decapsulate at the very last moment */
+ /* lprintf(9, "INITIAL: %s\n", icaltime_as_ical_string(icalproperty_get_dtstart(
+ icalcomponent_get_first_property(icalcomponent_get_first_component(
+ Cal->cal, ICAL_VEVENT_COMPONENT), ICAL_DTSTART_PROPERTY)))
+ ); */
+ ical_dezonify(Cal->cal);
+ if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
+ cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
+ if (cptr) {
+ cptr = icalcomponent_new_clone(cptr);
+ icalcomponent_free(Cal->cal);
+ Cal->cal = cptr;
+ }
+ }
+
Cal->unread = unread;
len = strlen(from);
Cal->from = (char*)malloc(len+ 1);
if (ps != NULL) {
dtstart = icalproperty_get_dtstart(ps);
Cal->event_start = icaltime_as_timet(dtstart);
- lprintf(9, "\e[31mINITIAL: %s, is_utc=%d, tzid=%s\e[0m\n",
- icaltime_as_ical_string(dtstart),
- icaltime_is_utc(dtstart),
- icaltime_get_tzid(dtstart)
- );
}
/* Do the same for the ending date and time. It makes the day view much easier to render. */
ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
if (ps != NULL) {
- dtend = icalproperty_get_dtstart(ps);
+ dtend = icalproperty_get_dtend(ps);
Cal->event_end = icaltime_as_timet(dtend);
}
Cal,
delete_cal);
- /* handle recurring events */
+ /****************************** handle recurring events ******************************/
if (icaltime_is_null_time(dtstart)) return; /* Can't recur without a start time */
* adding new hash entries that all point back to the same msgnum, until either the iteration
* stops or some outer bound is reached. The display code will automatically do the Right Thing.
*/
- rrule = icalcomponent_get_first_property(cal, ICAL_RRULE_PROPERTY);
+ cptr = cal;
+ if (icalcomponent_isa(cptr) != ICAL_VEVENT_COMPONENT) {
+ cptr = icalcomponent_get_first_component(cptr, ICAL_VEVENT_COMPONENT);
+ }
+ if (!cptr) return;
+ ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
+ if (ps == NULL) return;
+ dtstart = icalproperty_get_dtstart(ps);
+ rrule = icalcomponent_get_first_property(cptr, ICAL_RRULE_PROPERTY);
if (!rrule) return;
recur = icalproperty_get_rrule(rrule);
ritr = icalrecur_iterator_new(recur, dtstart);
int stop_rr = 0;
while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next))&&(!stop_rr)) ) {
++num_recur;
-
if (num_recur > 1) { /* Skip the first one. We already did it at the root. */
+ /* lprintf(9, "REPEATS: %s\n", icaltime_as_ical_string(next)); */
/* Note: anything we do here, we also have to do above for the root event. */
Cal = (disp_cal*) malloc(sizeof(disp_cal));
memset(Cal, 0, sizeof(disp_cal));
-
Cal->cal = icalcomponent_new_clone(cal);
Cal->unread = unread;
len = strlen(from);
Cal->from = (char*)malloc(len+ 1);
memcpy(Cal->from, from, len + 1);
Cal->cal_msgnum = msgnum;
-
- ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
- if (ps != NULL) {
- icalcomponent_remove_property(Cal->cal, ps);
- ps = icalproperty_new_dtstart(next);
- icalcomponent_add_property(Cal->cal, ps);
- /*ical_dezonify(Cal->cal);*/ /* dezonify every recurrence - we may
- * have hit the start/end of DST */
- Cal->event_start = icaltime_as_timet(next);
- lprintf(9, "\e[32mREPEATS: %s, is_utc=%d, tzid=%s\e[0m\n",
- icaltime_as_ical_string(next),
- icaltime_is_utc(next),
- icaltime_get_tzid(next)
- );
- final_recurrence = Cal->event_start;
+
+ icalcomponent *cptr;
+ if (icalcomponent_isa(Cal->cal) == ICAL_VEVENT_COMPONENT) {
+ cptr = Cal->cal;
}
+ else {
+ cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
+ }
+ if (cptr) {
+ ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
+ if (ps != NULL) {
+ icalcomponent_remove_property(cptr, ps);
+ ps = icalproperty_new_dtstart(next);
+ icalcomponent_add_property(cptr, ps);
- ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
- if (ps != NULL) {
- icalcomponent_remove_property(Cal->cal, ps);
+ Cal->event_start = icaltime_as_timet(next);
+ final_recurrence = Cal->event_start;
+ }
- /* Make a new dtend */
- ps = icalproperty_new_dtend(icaltime_add(next, dur));
+ ps = icalcomponent_get_first_property(cptr, ICAL_DTEND_PROPERTY);
+ if (ps != NULL) {
+ icalcomponent_remove_property(cptr, ps);
- /* and stick it somewhere */
- icalcomponent_add_property(Cal->cal, ps);
+ /* Make a new dtend */
+ ps = icalproperty_new_dtend(icaltime_add(next, dur));
+
+ /* and stick it somewhere */
+ icalcomponent_add_property(cptr, ps);
+ }
+
}
-
+
+ /* Dezonify and decapsulate at the very last moment */
+ ical_dezonify(Cal->cal);
+ if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
+ cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
+ if (cptr) {
+ cptr = icalcomponent_new_clone(cptr);
+ icalcomponent_free(Cal->cal);
+ Cal->cal = cptr;
+ }
+ }
+
if ( (Cal->event_start > calv->lower_bound)
&& (Cal->event_start < calv->upper_bound) ) {
Put(WCC->disp_cal_items,
}
/** Go back to the task list */
- readloop("readfwd");
+ readloop(readfwd);
}
cal = icalcomponent_new_from_string(relevant_source);
if (cal != NULL) {
- /* FIXME temp */
- lprintf(9, "HERE WE GO:\n%s\n", icalcomponent_as_ical_string(cal));
- icalproperty *p;
- p = icalcomponent_get_first_property(cal, ICAL_DTSTART_PROPERTY);
- if (p) {
- lprintf(9, "DTSTART IS %s\n",
- icaltime_as_ical_string(
- icalproperty_get_dtstart(p)
- )
- );
- }
- /* */
-
/* A which_kind of (-1) means just load the whole thing */
if (which_kind == (-1)) {
* Display a calendar item
*/
void load_calendar_item(message_summary *Msg, int unread, struct calview *c) {
- load_ical_object(Msg->msgnum, unread, ICAL_VEVENT_COMPONENT, display_individual_cal, c);
- /* load_ical_object(Msg->msgnum, unread, (-1), display_individual_cal, c); */
+ /*load_ical_object(Msg->msgnum, unread, ICAL_VEVENT_COMPONENT, display_individual_cal, c);*/
+ load_ical_object(Msg->msgnum, unread, (-1), display_individual_cal, c);
}
/*
msgnum = lbstr("msgnum");
if (msgnum > 0L) {
- load_ical_object(msgnum, 0, ICAL_VEVENT_COMPONENT, save_individual_event, NULL);
+ /* load_ical_object(msgnum, 0, ICAL_VEVENT_COMPONENT, save_individual_event, NULL); */
+ load_ical_object(msgnum, 0, (-1), save_individual_event, NULL);
}
else {
save_individual_event(NULL, 0L, "", 0, NULL);