$Log$
+Revision 400.75 2003/01/05 05:01:00 ajc
+* Add "today's calendar events" to the summary page.
+
Revision 400.74 2003/01/05 04:27:28 ajc
* Add "Tasks" to the summary page
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
+
}
+/*
+ * Display today's events.
+ */
+void calendar_summary_view(void) {
+ int i;
+ icalproperty *p;
+ struct icaltimetype t;
+ time_t event_tt;
+ struct tm event_tm;
+ struct tm today_tm;
+ time_t now;
+ int all_day_event = 0;
+ char timestring[SIZ];
+
+ if (WC->num_cal == 0) {
+ return;
+ }
+ now = time(NULL);
+ memcpy(&today_tm, localtime(&now), sizeof(struct tm));
+ wprintf("<UL>");
-void do_calendar_view(void) {
+ for (i=0; i<(WC->num_cal); ++i) {
+ p = icalcomponent_get_first_property(WC->disp_cal[i],
+ ICAL_DTSTART_PROPERTY);
+ if (p != NULL) {
+ t = icalproperty_get_dtstart(p);
+ event_tt = icaltime_as_timet(t);
+ fmt_time(timestring, event_tt);
+ memcpy(&event_tm, localtime(&event_tt), sizeof(struct tm));
+ 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)
+ ) {
+
+ if (t.is_date) all_day_event = 1;
+
+ p = icalcomponent_get_first_property(
+ WC->disp_cal[i],
+ ICAL_SUMMARY_PROPERTY);
+ if (p != NULL) {
+ wprintf("<LI>");
+ escputs((char *)
+ icalproperty_get_comment(p));
+ wprintf(" (%s)\n", timestring);
+ }
+ }
+ }
+ }
+ wprintf("</UL>\n");
+ free_calendar_buffer();
+}
+
+
+
+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]);
+ }
+ WC->num_cal = 0;
+ free(WC->disp_cal);
+ WC->disp_cal = NULL;
+ free(WC->cal_msgnum);
+ WC->cal_msgnum = NULL;
+}
+
+
+
+
+void do_calendar_view(void) {
time_t now;
struct tm tm;
int year, month, day;
}
/* Free the calendar stuff */
- if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
- icalcomponent_free(WC->disp_cal[i]);
- }
- WC->num_cal = 0;
- free(WC->disp_cal);
- WC->disp_cal = NULL;
- free(WC->cal_msgnum);
- WC->cal_msgnum = NULL;
-}
+ free_calendar_buffer();
+}
#endif /* HAVE_ICAL_H */
int num_msgs = 0;
int i;
+ section_title("Tasks");
gotoroom("Tasks", 0);
if (strcasecmp(WC->wc_roomname, "Tasks")) {
wprintf("<i>(You do not have a task list)</i><BR>\n");
return;
}
+ wprintf("<UL>");
for (i=0; i<num_msgs; ++i) {
display_task(WC->msgarr[i]);
}
+ wprintf("</UL>\n");
+}
+
+
+/*
+ * Calendar section
+ */
+void calendar_section(void) {
+ int num_msgs = 0;
+ int i;
+
+ section_title("Today on your calendar");
+#ifdef HAVE_ICAL_H
+ gotoroom("Calendar", 0);
+ if (strcasecmp(WC->wc_roomname, "Calendar")) {
+ wprintf("<i>(You do not have a calendar)</i><BR>\n");
+ return;
+ }
+
+ num_msgs = load_msg_ptrs("MSGS ALL");
+ if (num_msgs < 1) {
+ wprintf("<i>(Nothing)</i><BR>\n");
+ return;
+ }
+
+ for (i=0; i<num_msgs; ++i) {
+ display_calendar(WC->msgarr[i]);
+ }
+
+ calendar_summary_view();
+#endif /* HAVE_ICAL_H */
}
output_headers(7);
wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
- "<FONT SIZE=+1 COLOR=\"FFFFFF\""
+ "<FONT SIZE=+1 COLOR=\"FFFFFF\">"
"<B>Summary page for ");
escputs(WC->wc_username);
wprintf("</B><FONT></TD><TD>\n");
offer_start_page();
- wprintf("</TD></TR></TABLE>\n");
-
- wprintf("<DIV ALIGN=RIGHT>");
+ wprintf("</TD><TD ALIGN=RIGHT><FONT COLOR=\"FFFFFF\">");
output_date();
- wprintf("</DIV>\n");
+ wprintf("</FONT></TD></TR></TABLE>\n");
/*
* Now let's do three columns of crap. All portals and all groupware
*/
wprintf("</TD><TD>");
new_messages_section();
+ wprintf("<BR><BR>");
+ calendar_section();
/*
* End of columns
+/*
+ * Format TIME ONLY for output
+ */
+void fmt_time(char *buf, time_t thetime) {
+ struct tm *tm;
+ int hour;
+
+ strcpy(buf, "");
+ tm = localtime(&thetime);
+ hour = tm->tm_hour;
+ if (hour == 0) hour = 12;
+ else if (hour > 12) hour = hour - 12;
+
+ sprintf(buf, "%d:%02d%s",
+ hour,
+ tm->tm_min,
+ ( (tm->tm_hour > 12) ? "pm" : "am" )
+ );
+}
+
+
+
/*
* Format a date/time stamp to the format used in HTTP headers
void worker_entry(void);
void session_loop(struct httprequest *);
void fmt_date(char *buf, time_t thetime);
+void fmt_time(char *buf, time_t thetime);
void httpdate(char *buf, time_t thetime);
void end_webcit_session(void);
void page_popup(void);
void display_calendar(long msgnum);
void display_task(long msgnum);
void do_calendar_view(void);
+void free_calendar_buffer(void);
int load_msg_ptrs(char *servcmd);
#ifdef HAVE_ICAL_H