\n");
- /** Innermost cell (contains hours etc.) */
+ /* Innermost cell (contains hours etc.) */
wprintf("");
wprintf("");
- /** Now the middle of the day... */
- for (hour = 0; hour < 24; ++hour) { /* could do HEIGHT=xx */
- wprintf("- ",
- (hour < daystart ? "before" : (hour > dayend ? "after" : "")),
+
+ /* Now the middle of the day... */
+
+ extratimeline = timeline / 3;
+
+ for (hour = 0; hour < daystart; ++hour) { /* could do HEIGHT=xx */
+ wprintf(" ",
(hour <= 12 ? hour : hour-12),
(hour < 12 ? "am" : "pm")
- );
+ );
}
wprintf("
");
-
+ }
- /* put the data here, stupid */
- calendar_day_view_display_events(today_t, year, month, day, hour, daystart, dayend);
+ gap = daystart * extratimeline;
+
+ for (hour = daystart; hour <= dayend; ++hour) { /* could do HEIGHT=xx */
+ wprintf("- "
+ "",
+ gap + ((hour - daystart) * timeline ), timeline,
+ year, month, day, hour
+ );
- }
+ if (time_format == WC_TIMEFORMAT_24) {
+ wprintf("%2d:00 ", hour);
+ }
+ else {
+ wprintf("%d:00%s ",
+ (hour <= 12 ? hour : hour-12),
+ (hour < 12 ? "am" : "pm")
+ );
+ }
+
+ wprintf("
");
+ }
+
+ gap = gap + ((dayend - daystart + 1) * timeline);
+
+ for (hour = (dayend + 1); hour < 24; ++hour) { /* could do HEIGHT=xx */
+ wprintf("");
+ }
+
+ /* Display events with start and end times on this day */
+ calendar_day_view_display_events(today_t, year, month, day, 0, daystart, dayend);
wprintf(" ");
wprintf(" | "); /* end of innermost table */
- /** Extra events on the middle */
+ /* Display extra events (start/end times not present or not today) in the middle column */
wprintf(""); /** begin stuff-on-the-right */
- /** Begin todays-date-with-left-and-right-arrows */
+ /* Begin todays-date-with-left-and-right-arrows */
wprintf("\n");
wprintf("");
- /** Left arrow */
+ /* Left arrow */
wprintf("");
wprintf("",
yesterday.year, yesterday.month, yesterday.day);
@@ -1082,10 +1212,10 @@ void calendar_day_view(int year, int month, int day) {
"%Y "
" | ",
&d_tm
- );
+ );
wprintf("%s", d_str);
- /** Right arrow */
+ /* Right arrow */
wprintf("");
wprintf("",
tomorrow.year, tomorrow.month, tomorrow.day);
@@ -1094,9 +1224,9 @@ void calendar_day_view(int year, int month, int day) {
wprintf(" | ");
wprintf(" \n");
- /** End todays-date-with-left-and-right-arrows */
+ /* End todays-date-with-left-and-right-arrows */
- /** Embed a mini month calendar in this space */
+ /* Embed a mini month calendar in this space */
wprintf(" \n");
embeddable_mini_calendar(year, month, "readfwd?calview=day&year=%d&month=%d&day=%d");
@@ -1114,11 +1244,15 @@ void calendar_day_view(int year, int month, int day) {
}
-/**
- * \brief Display today's events.
+/*
+ * Display today's events.
*/
void calendar_summary_view(void) {
- int i;
+ long hklen;
+ char *HashKey;
+ void *vCal;
+ HashPos *Pos;
+ disp_cal *Cal;
icalproperty *p;
struct icaltimetype t;
time_t event_tt;
@@ -1127,16 +1261,19 @@ void calendar_summary_view(void) {
time_t now;
int all_day_event = 0;
char timestring[SIZ];
+ struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
- if (WC->num_cal == 0) {
+ if (GetCount(WC->disp_cal_items) == 0) {
return;
}
now = time(NULL);
localtime_r(&now, &today_tm);
- for (i=0; i<(WC->num_cal); ++i) {
- p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
+ Pos = GetNewHashPos();
+ while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
+ Cal = (disp_cal*)vCal;
+ p = icalcomponent_get_first_property(Cal->cal,
ICAL_DTSTART_PROPERTY);
if (p != NULL) {
t = icalproperty_get_dtstart(p);
@@ -1157,44 +1294,29 @@ void calendar_summary_view(void) {
}
if ( (event_tm.tm_year == today_tm.tm_year)
- && (event_tm.tm_mon == today_tm.tm_mon)
- && (event_tm.tm_mday == today_tm.tm_mday)
- ) {
-
-
- p = icalcomponent_get_first_property(
- WC->disp_cal[i].cal,
- ICAL_SUMMARY_PROPERTY);
- if (p != NULL) {
- escputs((char *)
- icalproperty_get_comment(p));
- wprintf(" (%s) \n", timestring);
- }
- }
- }
- }
- free_calendar_buffer();
-}
+ && (event_tm.tm_mon == today_tm.tm_mon)
+ && (event_tm.tm_mday == today_tm.tm_mday)
+ ) {
-/**
- * \brief clean up ical memory
- * \todo this could get troubel with future ical versions
- */
-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].cal);
+ p = icalcomponent_get_first_property(
+ Cal->cal,
+ ICAL_SUMMARY_PROPERTY);
+ if (p != NULL) {
+ escputs((char *)
+ icalproperty_get_comment(p));
+ wprintf(" (%s) \n", timestring);
+ }
+ }
+ }
}
- WC->num_cal = 0;
- free(WC->disp_cal);
- WC->disp_cal = NULL;
+ DeleteHashPos(&Pos);
+ DeleteHash(&WC->disp_cal_items);
}
-
-/**
- * \brief do the whole calendar page
+/*
+ * do the whole calendar page
* view any part of the calender. decide which way, etc.
*/
void do_calendar_view(void) {
@@ -1203,27 +1325,27 @@ void do_calendar_view(void) {
int year, month, day;
char calview[SIZ];
- /** In case no date was specified, go with today */
+ /* In case no date was specified, go with today */
now = time(NULL);
localtime_r(&now, &tm);
year = tm.tm_year + 1900;
month = tm.tm_mon + 1;
day = tm.tm_mday;
- /** Now see if a date was specified */
- if (!IsEmptyStr(bstr("year"))) year = atoi(bstr("year"));
- if (!IsEmptyStr(bstr("month"))) month = atoi(bstr("month"));
- if (!IsEmptyStr(bstr("day"))) day = atoi(bstr("day"));
+ /* Now see if a date was specified */
+ if (havebstr("year")) year = ibstr("year");
+ if (havebstr("month")) month = ibstr("month");
+ if (havebstr("day")) day = ibstr("day");
- /** How would you like that cooked? */
- if (!IsEmptyStr(bstr("calview"))) {
+ /* How would you like that cooked? */
+ if (havebstr("calview")) {
strcpy(calview, bstr("calview"));
}
else {
strcpy(calview, "month");
}
- /** Display the selected view */
+ /* Display the selected view */
if (!strcasecmp(calview, "day")) {
calendar_day_view(year, month, day);
}
@@ -1239,17 +1361,13 @@ void do_calendar_view(void) {
}
}
- /** Free the calendar stuff */
- free_calendar_buffer();
-
+ /* Free the in-memory list of calendar items */
+ DeleteHash(&WC->disp_cal_items);
}
-/**
- * \brief get task due date
- * Helper function for do_tasks_view().
- * \param vtodo a task to get the due date
- * \return the date/time due.
+/*
+ * Helper function for do_tasks_view(). Returns the due date/time of a vtodo.
*/
time_t get_task_due_date(icalcomponent *vtodo) {
icalproperty *p;
@@ -1258,7 +1376,7 @@ time_t get_task_due_date(icalcomponent *vtodo) {
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.
@@ -1267,8 +1385,8 @@ time_t get_task_due_date(icalcomponent *vtodo) {
return get_task_due_date(
icalcomponent_get_first_component(
vtodo, ICAL_VTODO_COMPONENT
- )
- );
+ )
+ );
}
p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
@@ -1281,111 +1399,131 @@ time_t get_task_due_date(icalcomponent *vtodo) {
}
-/**
- * \brief Compare the due dates of two tasks (this is for sorting)
- * \param task1 first task to compare
- * \param task2 second task to compare
+/*
+ * Compare the due dates of two tasks (this is for sorting)
*/
-int task_due_cmp(const void *task1, const void *task2) {
+int task_due_cmp(const void *vtask1, const void *vtask2) {
+ disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
+ disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
+
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);
-
+ t1 = get_task_due_date(Task1->cal);
+ t2 = get_task_due_date(Task2->cal);
if (t1 < t2) return(-1);
if (t1 > t2) return(1);
return(0);
}
+/*
+ * qsort filter to move completed tasks to bottom of task list
+ */
+int task_completed_cmp(const void *vtask1, const void *vtask2) {
+ disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
+// disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
+ icalproperty_status t1 = icalcomponent_get_status((Task1)->cal);
+ // icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal);
+
+ if (t1 == ICAL_STATUS_COMPLETED)
+ return 1;
+ return 0;
+}
-/**
- * \brief do the whole task view stuff
+
+/*
+ * do the whole task view stuff
*/
void do_tasks_view(void) {
- int i;
+ long hklen;
+ char *HashKey;
+ void *vCal;
+ disp_cal *Cal;
+ HashPos *Pos;
+ int nItems;
time_t due;
- int bg = 0;
char buf[SIZ];
icalproperty *p;
+ struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
wprintf("\n");
+ /* Free the list */
+ DeleteHash(&WC->disp_cal_items);
+ DeleteHashPos(&Pos);
}
-#else /* WEBCIT_WITH_CALENDAR_SERVICE */
-
-/**\brief stub for non-libical builds */
-void do_calendar_view(void) {
- wprintf("");
- wprintf(_("The calendar view is not available."));
- wprintf(" \n");
-}
-
-/**\brief stub for non-libical builds */
-void do_tasks_view(void) {
- wprintf("");
- wprintf(_("The tasks view is not available."));
- wprintf(" \n");
-}
-
-/**\brief stub for non-libical builds */
-void ajax_mini_calendar(void) {
-}
-
-#endif /* WEBCIT_WITH_CALENDAR_SERVICE */
-
-/** @} */
|