* any iCalendar objects and store them in a hash table. Later on, the second phase will
* use this hash table to render the calendar for display.
*/
-void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unread)
+void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unread, struct calview *calv)
{
icalproperty *ps = NULL;
struct icaltimetype dtstart, dtend;
Cal,
delete_cal);
-#ifdef TECH_PREVIEW
-
/* handle recurring events */
if (icaltime_is_null_time(dtstart)) return; /* Can't recur without a start time */
/*
* Just let libical iterate the recurrence, and keep looping back to the top of this function,
* 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 *should* automatically do the right
- * thing (but we'll have to see).
+ * stops or some outer bound is reached. The display code will automatically do the Right Thing.
*/
rrule = icalcomponent_get_first_property(Cal->cal, ICAL_RRULE_PROPERTY);
ritr = icalrecur_iterator_new(recur, dtstart);
if (!ritr) return;
- while (next = icalrecur_iterator_next(ritr), !icaltime_is_null_time(next) ) {
+ 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. */
icalcomponent_add_property(Cal->cal, ps);
}
- Put(WCC->disp_cal_items,
- (char*) &Cal->event_start,
- sizeof(Cal->event_start),
- Cal,
- delete_cal);
+ if ( (Cal->event_start > calv->lower_bound)
+ && (Cal->event_start < calv->upper_bound) ) {
+ Put(WCC->disp_cal_items,
+ (char*) &Cal->event_start,
+ sizeof(Cal->event_start),
+ Cal,
+ delete_cal
+ );
+ }
+ else {
+ delete_cal(Cal);
+ }
+
+ /* If an upper bound is set, stop when we go out of scope */
+ if (final_recurrence > calv->upper_bound) stop_rr = 1;
}
}
- lprintf(9, "Performed %d recurrences; final one is %s", num_recur, ctime(&final_recurrence));
-
-#endif /* TECH_PREVIEW */
+ icalrecur_iterator_free(ritr);
+ /* lprintf(9, "Performed %d recurrences; final one is %s", num_recur, ctime(&final_recurrence)); */
}
/*
* Display a task by itself (for editing)
*/
-void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from, int unread)
+void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from,
+ int unread, struct calview *calv)
{
icalcomponent *vtodo;
icalproperty *p;
icalcomponent_get_first_component(
vtodo, ICAL_VTODO_COMPONENT
),
- msgnum,
- from, unread
+ msgnum, from, unread, calv
);
return;
}
}
else
IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
- display_icaltimetype_as_webform(&IcalTime, "dtstart");
+ display_icaltimetype_as_webform(&IcalTime, "dtstart", 0);
wprintf("</TD></TR>\n");
wprintf("<TR><TD>");
}
else
IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
- display_icaltimetype_as_webform(&IcalTime, "due");
+ display_icaltimetype_as_webform(&IcalTime, "due", 0);
wprintf("</TD></TR>\n");
todoStatus = icalcomponent_get_status(vtodo);
* \param supplied_vtodo the task to save
* \param msgnum number of the mesage in our db
*/
-void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from, int unread)
+void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from, int unread,
+ struct calview *calv)
{
char buf[SIZ];
int delete_existing = 0;
save_individual_task(
icalcomponent_get_first_component(
vtodo, ICAL_VTODO_COMPONENT),
- msgnum, from, unread
+ msgnum, from, unread, calv
);
return;
}
* the relevant part, deserialize it into a libical component, filter it for
* the requested object type, and feed it to the specified handler.
*/
-void display_using_handler(long msgnum, int unread,
+void load_ical_object(long msgnum, int unread,
icalcomponent_kind which_kind,
- void (*callback)(icalcomponent *, long, char*, int)
+ void (*callback)(icalcomponent *, long, char*, int, struct calview *),
+ struct calview *calv
)
{
char buf[1024];
/* Simple components of desired type */
if (icalcomponent_isa(cal) == which_kind) {
- callback(cal, msgnum, from, unread);
+ callback(cal, msgnum, from, unread, calv);
}
/* Subcomponents of desired type */
for (c = icalcomponent_get_first_component(cal, which_kind);
(c != 0);
c = icalcomponent_get_next_component(cal, which_kind)) {
- callback(c, msgnum, from, unread);
+ callback(c, msgnum, from, unread, calv);
}
icalcomponent_free(cal);
}
/*
* Display a calendar item
*/
-void display_calendar(long msgnum, int unread) {
- display_using_handler(msgnum, unread, ICAL_VEVENT_COMPONENT, display_individual_cal);
+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);
}
/*
* Display task view
*/
-void display_task(long msgnum, int unread) {
- display_using_handler(msgnum, unread, ICAL_VTODO_COMPONENT, display_individual_cal);
+void display_task(message_summary *Msg, int unread) {
+ load_ical_object(Msg->msgnum, unread, ICAL_VTODO_COMPONENT, display_individual_cal, NULL);
}
/*
msgnum = lbstr("msgnum");
if (msgnum > 0L) {
/* existing task */
- display_using_handler(msgnum, 0,
+ load_ical_object(msgnum, 0,
ICAL_VTODO_COMPONENT,
- display_edit_individual_task);
+ display_edit_individual_task,
+ NULL
+ );
}
else {
/* new task */
- display_edit_individual_task(NULL, 0L, "", 0);
+ display_edit_individual_task(NULL, 0L, "", 0, NULL);
}
}
*/
void save_task(void) {
long msgnum = 0L;
-
msgnum = lbstr("msgnum");
if (msgnum > 0L) {
- display_using_handler(msgnum, 0, ICAL_VTODO_COMPONENT, save_individual_task);
+ load_ical_object(msgnum, 0, ICAL_VTODO_COMPONENT, save_individual_task, NULL);
}
else {
- save_individual_task(NULL, 0L, "", 0);
+ save_individual_task(NULL, 0L, "", 0, NULL);
}
}
msgnum = lbstr("msgnum");
if (msgnum > 0L) {
/* existing event */
- display_using_handler(msgnum, 0, ICAL_VEVENT_COMPONENT, display_edit_individual_event);
+ load_ical_object(msgnum, 0, ICAL_VEVENT_COMPONENT, display_edit_individual_event, NULL);
}
else {
/* new event */
- display_edit_individual_event(NULL, 0L, "", 0);
+ display_edit_individual_event(NULL, 0L, "", 0, NULL);
}
}
msgnum = lbstr("msgnum");
if (msgnum > 0L) {
- display_using_handler(msgnum, 0, ICAL_VEVENT_COMPONENT, save_individual_event);
+ load_ical_object(msgnum, 0, ICAL_VEVENT_COMPONENT, save_individual_event, NULL);
}
else {
- save_individual_event(NULL, 0L, "", 0);
+ save_individual_event(NULL, 0L, "", 0, NULL);
}
}
/*
* Anonymous request of freebusy data for a user
*/
-void do_freebusy(char *req) {
+void do_freebusy(const char *req) {
char who[SIZ];
char buf[SIZ];
int len;