From: Art Cancro Date: Wed, 4 Aug 2004 03:52:24 +0000 (+0000) Subject: * Tasks view is now pretty. X-Git-Tag: v7.86~5326 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=f33d1d12b6d8de28cb449c129e1b4ddf0471c7bf;p=citadel.git * Tasks view is now pretty. * Tasks view now displays date due for each task. * Tasks view is now sorted by date due. * Tasks view now displays overdue tasks in red. --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index a2a53c814..8d6960a17 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,10 @@ $Log$ +Revision 522.21 2004/08/04 03:52:23 ajc +* Tasks view is now pretty. +* Tasks view now displays date due for each task. +* Tasks view is now sorted by date due. +* Tasks view now displays overdue tasks in red. + Revision 522.20 2004/08/03 03:55:37 ajc * Tasks view now uses the same buffer/dump logic as the calendar views, so we can sort them by due date and do a prettier display. (Only the logic is @@ -1994,4 +2000,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/calendar.c b/webcit/calendar.c index f1f23b7aa..300d0ebb8 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -472,12 +472,10 @@ void display_individual_cal(icalcomponent *cal, long msgnum) { WC->num_cal += 1; WC->disp_cal = realloc(WC->disp_cal, - (sizeof(icalcomponent *) * WC->num_cal) ); - WC->disp_cal[WC->num_cal - 1] = icalcomponent_new_clone(cal); + (sizeof(struct disp_cal) * WC->num_cal) ); + WC->disp_cal[WC->num_cal - 1].cal = icalcomponent_new_clone(cal); - WC->cal_msgnum = realloc(WC->cal_msgnum, - (sizeof(long) * WC->num_cal) ); - WC->cal_msgnum[WC->num_cal - 1] = msgnum; + WC->disp_cal[WC->num_cal - 1].cal_msgnum = msgnum; } diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index 70c4d537d..42829f9ab 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -62,7 +62,7 @@ void calendar_month_view_display_events(time_t thetime) { year = today_tm.tm_year + 1900; for (i=0; i<(WC->num_cal); ++i) { - p = icalcomponent_get_first_property(WC->disp_cal[i], + p = icalcomponent_get_first_property(WC->disp_cal[i].cal, ICAL_DTSTART_PROPERTY); if (p != NULL) { t = icalproperty_get_dtstart(p); @@ -92,7 +92,7 @@ lprintf(9, "Event: %04d/%02d/%02d, Now: %04d/%02d/%02d\n", && (event_tm.tm_mday == today_tm.tm_mday)) { p = icalcomponent_get_first_property( - WC->disp_cal[i], + WC->disp_cal[i].cal, ICAL_SUMMARY_PROPERTY); if (p != NULL) { @@ -104,7 +104,7 @@ lprintf(9, "Event: %04d/%02d/%02d, Now: %04d/%02d/%02d\n", wprintf("" "", - WC->cal_msgnum[i], + WC->disp_cal[i].cal_msgnum, bstr("calview"), bstr("year"), bstr("month"), @@ -274,7 +274,7 @@ void calendar_day_view_display_events(int year, int month, } for (i=0; i<(WC->num_cal); ++i) { - p = icalcomponent_get_first_property(WC->disp_cal[i], + p = icalcomponent_get_first_property(WC->disp_cal[i].cal, ICAL_DTSTART_PROPERTY); if (p != NULL) { t = icalproperty_get_dtstart(p); @@ -296,7 +296,7 @@ void calendar_day_view_display_events(int year, int month, p = icalcomponent_get_first_property( - WC->disp_cal[i], + WC->disp_cal[i].cal, ICAL_SUMMARY_PROPERTY); if (p != NULL) { @@ -308,7 +308,7 @@ void calendar_day_view_display_events(int year, int month, wprintf("" "", - WC->cal_msgnum[i], + WC->disp_cal[i].cal_msgnum, year, month, day ); escputs((char *) @@ -488,7 +488,7 @@ void calendar_summary_view(void) { memcpy(&today_tm, localtime(&now), sizeof(struct tm)); for (i=0; i<(WC->num_cal); ++i) { - p = icalcomponent_get_first_property(WC->disp_cal[i], + p = icalcomponent_get_first_property(WC->disp_cal[i].cal, ICAL_DTSTART_PROPERTY); if (p != NULL) { t = icalproperty_get_dtstart(p); @@ -510,7 +510,7 @@ void calendar_summary_view(void) { p = icalcomponent_get_first_property( - WC->disp_cal[i], + WC->disp_cal[i].cal, ICAL_SUMMARY_PROPERTY); if (p != NULL) { escputs((char *) @@ -528,13 +528,11 @@ void calendar_summary_view(void) { void free_calendar_buffer(void) { int i; if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) { - icalcomponent_free(WC->disp_cal[i]); + icalcomponent_free(WC->disp_cal[i].cal); } WC->num_cal = 0; free(WC->disp_cal); WC->disp_cal = NULL; - free(WC->cal_msgnum); - WC->cal_msgnum = NULL; } @@ -583,27 +581,116 @@ void do_calendar_view(void) { } +/* + * Helper function for do_tasks_view(). Returns the date/time due. + */ +time_t get_task_due_date(icalcomponent *vtodo) { + icalproperty *p; + + if (vtodo == NULL) { + return(0L); + } + + /* If we're looking at a fully encapsulated VCALENDAR + * rather than a VTODO component, recurse into the data + * structure until we get a VTODO. + */ + if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) { + return get_task_due_date( + icalcomponent_get_first_component( + vtodo, ICAL_VTODO_COMPONENT + ) + ); + } + + p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY); + if (p != NULL) { + return(icaltime_as_timet(icalproperty_get_due(p))); + } + else { + return(0L); + } +} + + +/* + * Compare the due dates of two tasks (this is for sorting) + */ +int task_due_cmp(const void *task1, const void *task2) { + time_t t1; + time_t t2; + + t1 = get_task_due_date(((struct disp_cal *)task1)->cal); + t2 = get_task_due_date(((struct disp_cal *)task2)->cal); + + if (t1 < t2) return(-1); + if (t1 > t2) return(1); + return(0); +} + + + + + void do_tasks_view(void) { int i; + time_t due; + int bg = 0; + char buf[SIZ]; icalproperty *p; + do_template("beginbox_nt"); + + wprintf("\n\n" + "\n" + "\n" + ); + + /* Sort them if necessary */ + if (WC->num_cal > 1) { + qsort(WC->disp_cal, + WC->num_cal, + sizeof(struct disp_cal), + task_due_cmp + ); + } + if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) { - p = icalcomponent_get_first_property(WC->disp_cal[i], + + bg = 1 - bg; + wprintf("\n"); + + due = get_task_due_date(WC->disp_cal[i].cal); + fmt_date(buf, due); + wprintf("\n", buf); } - wprintf("

" + wprintf("
Name of taskDate due
", + (bg ? "DDDDDD" : "FFFFFF") + ); + + p = icalcomponent_get_first_property(WC->disp_cal[i].cal, ICAL_SUMMARY_PROPERTY); wprintf("cal_msgnum[i] ); + WC->disp_cal[i].cal_msgnum ); urlescputs(WC->wc_roomname); wprintf("\">"); if (p != NULL) { escputs((char *)icalproperty_get_comment(p)); } - wprintf("
\n"); + wprintf("\n"); + wprintf("
%s
\n"); + + wprintf("
" "Add new task\n" ); + do_template("endbox"); + /* Free the list */ free_calendar_buffer(); diff --git a/webcit/messages.c b/webcit/messages.c index e30cc1820..37fc21196 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -1582,18 +1582,24 @@ void display_enter(void) bstr("recp")); wprintf("\n", now); + + wprintf("\n"); + wprintf(""); + wprintf("
"); wprintf("\""); /* "onLoad=\"document.enterform.msgtext.focus();\" " */ wprintf("Subject (optional):" "" + wprintf("\" SIZE=40 MAXLENGTH=70>" " " ); + wprintf(""); wprintf("" " " "
\n"); + wprintf("
\n"); wprintf("\n" diff --git a/webcit/webcit.h b/webcit/webcit.h index 435bd1df8..e1b4a46d7 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -220,8 +220,10 @@ struct wcsession { char http_host[SIZ]; /* HTTP Host: header */ char *preferences; #ifdef WEBCIT_WITH_CALENDAR_SERVICE - icalcomponent **disp_cal; /* store calendar items for display */ - long *cal_msgnum; /* store calendar msgids for display */ + struct disp_cal { + icalcomponent *cal; /* cal items for display */ + long cal_msgnum; /* cal msgids for display */ + } *disp_cal; int num_cal; #endif struct wc_attachment *first_attachment;