\n");
- /** Now do 35 days */
+ /* Now do 35 days */
for (i = 0; i < 35; ++i) {
char weeknumber[255];
char weekday_name[32];
@@ -553,37 +712,37 @@ void calendar_brief_month_view(int year, int month, int day) {
localtime_r(&thetime, &tm);
- /** Before displaying Sunday, start a new CELL */
+ /* Before displaying Sunday, start a new CELL */
if ((i % 7) == 0) {
wc_strftime(&weeknumber[0], sizeof(weeknumber), "%U", &tm);
- wprintf(" %s %s | "
- " %s | %s | %s | %s | \n",
- _("Week"),
- weeknumber,
- _("Hours"),
- _("Subject"),
- _("Start"),
- _("End")
- );
+ wprintf(" %s %s | "
+ " %s | %s | %s | %s | \n",
+ _("Week"),
+ weeknumber,
+ _("Hours"),
+ _("Subject"),
+ _("Start"),
+ _("End")
+ );
}
daycolor=((tm.tm_mon != month-1) ? "DDDDDD" :
- ((tm.tm_wday==0 || tm.tm_wday==6) ? "EEEECC" :
- "FFFFFF"));
+ ((tm.tm_wday==0 || tm.tm_wday==6) ? "EEEECC" :
+ "FFFFFF"));
- /** Day Header */
+ /* Day Header */
wc_strftime(weekday_name, sizeof weekday_name, "%A", &tm);
wprintf(" %s,%i."
- " |
| \n",
- daycolor,
- weekday_name,tm.tm_mday,
- daycolor);
+ "
| \n",
+ daycolor,
+ weekday_name,tm.tm_mday,
+ daycolor);
- /** put the data of one day here, stupid */
+ /* put the data of one day here, stupid */
calendar_month_view_brief_events(thetime, daycolor);
- /** After displaying Saturday, end the row */
+ /* After displaying Saturday, end the row */
if ((i % 7) == 6) {
wprintf(" \n");
}
@@ -596,62 +755,67 @@ void calendar_brief_month_view(int year, int month, int day) {
"\n");
}
-/**
- * \brief view one week
- * this should view just one week, but it's not here yet.
- * \todo ny implemented
- * \param year the year
- * \param month the month
- * \param day the day which we want to see the week around
+/*
+ * Calendar week view -- not implemented yet, this is a stub function
*/
void calendar_week_view(int year, int month, int day) {
wprintf("week view FIXME \n");
}
-/**
- * \brief display one day
+/*
+ * display one day
* Display events for a particular hour of a particular day.
* (Specify hour < 0 to show "all day" events)
- * \param year the year
- * \param month the month
- * \param day the day
- * \param hour the hour we want to start displaying
- * \param dstart daystart
- * \param dend dayend
+ *
+ * dstart and dend indicate which hours our "daytime" begins and end
*/
-void calendar_day_view_display_events(time_t thetime, int year, int month,
- int day, int hour,
- int dstart, int dend) {
- int i;
+void calendar_day_view_display_events(time_t thetime,
+ int year,
+ int month,
+ int day,
+ int notime_events,
+ int dstart,
+ int dend)
+{
+ long hklen;
+ const char *HashKey;
+ void *vCal;
+ HashPos *Pos;
icalproperty *p = NULL;
icalproperty *q = NULL;
- time_t event_start;
- time_t event_end;
+ time_t event_tt;
+ time_t event_tte;
struct tm event_te;
struct tm event_tm;
int show_event = 0;
int all_day_event = 0;
+ int ongoing_event = 0;
struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
- struct disp_cal *Cal;
+ disp_cal *Cal;
struct icaltimetype t;
struct icaltimetype end_t;
struct icaltimetype today_start_t;
struct icaltimetype today_end_t;
struct tm starting_tm;
struct tm ending_tm;
-
-
- if (WCC->num_cal == 0) {
- // \todo FIXME wprintf("
\n");
+ int top = 0;
+ int bottom = 0;
+ int gap = 1;
+ int startmin = 0;
+ int diffmin = 0;
+ int endmin = 0;
+
+ char buf[256];
+ struct tm d_tm;
+ char d_str[32];
+
+ if (GetCount(WCC->disp_cal_items) == 0) {
+ /* nothing to display */
return;
}
- event_start = thetime + 60 * 60 * hour;
- event_end = thetime + 60 * 60 * (hour + 1);
-
-
- /* Create an imaginary event which spans the 24 hours of today. Any events which
+ /* Create an imaginary event which spans the current day. Any events which
* overlap with this one take place at least partially in this day.
*/
memset(&starting_tm, 0, sizeof(struct tm));
@@ -674,13 +838,18 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
/* Now loop through our list of events to see which ones occur today.
*/
- for (i=0; i<(WCC->num_cal); ++i) {
- Cal = &WCC->disp_cal[i];
+ Pos = GetNewHashPos();
+ while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
+ Cal = (disp_cal*)vCal;
all_day_event = 0;
+ ongoing_event=0;
+
q = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
if (q != NULL) {
t = icalproperty_get_dtstart(q);
+ event_tt = icaltime_as_timet(t);
+ localtime_r(&event_tt, &event_te);
}
else {
memset(&t, 0, sizeof t);
@@ -688,6 +857,8 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
q = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
if (q != NULL) {
end_t = icalproperty_get_dtend(q);
+ event_tte = icaltime_as_timet(end_t);
+ localtime_r(&event_tte, &event_tm);
}
else {
memset(&end_t, 0, sizeof end_t);
@@ -696,7 +867,7 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
if (all_day_event)
{
- show_event = ((t.year == year) && (t.month == month) && (t.day == day));
+ show_event = ((t.year == year) && (t.month == month) && (t.day == day) && (notime_events));
}
else
{
@@ -706,63 +877,196 @@ void calendar_day_view_display_events(time_t thetime, int year, int month,
/* If we determined that this event occurs today, then display it.
*/
p = icalcomponent_get_first_property(Cal->cal,ICAL_SUMMARY_PROPERTY);
+
if ((show_event) && (p != NULL)) {
- if (all_day_event)
+
+ if ((event_te.tm_mday != day) || (event_tm.tm_mday != day)) ongoing_event = 1;
+
+ if (all_day_event && notime_events)
{
- wprintf("",
- Cal->cal_msgnum, year, month, day, hour);
+ wprintf(" "
+ "unread)?"_unread":"_read",
+ Cal->cal_msgnum, year, month, day);
+ wprintf("%s ", _("All day event"));
+ wprintf("%s: %s ", _("From"), Cal->from);
+ wprintf("%s ", _("Summary:"));
+ escputs((char *) icalproperty_get_comment(p));
+ wprintf(" ");
+ q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
+ if (q) {
+ wprintf("%s ", _("Location:"));
+ escputs((char *)icalproperty_get_comment(q));
+ wprintf(" ");
+ }
+ memset(&d_tm, 0, sizeof d_tm);
+ d_tm.tm_year = t.year - 1900;
+ d_tm.tm_mon = t.month - 1;
+ d_tm.tm_mday = t.day;
+ wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
+ wprintf("%s %s ",_("Date:"), d_str);
+ q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
+ if (q) {
+ wprintf("%s ", _("Notes:"));
+ escputs((char *)icalproperty_get_comment(q));
+ wprintf(" ");
+ }
+ wprintf("\">");
+ escputs((char *) icalproperty_get_comment(p));
+ wprintf(" (");
+ wprintf(_("All day event"));
+ wprintf(")\n");
+ }
+ else if (ongoing_event && notime_events)
+ {
+ wprintf(" "
+ "unread)?"_unread":"_read",
+ Cal->cal_msgnum, year, month, day);
+ wprintf("%s ", _("Ongoing event"));
+ wprintf("%s: %s ", _("From"), Cal->from);
+ wprintf("%s ", _("Summary:"));
+ escputs((char *) icalproperty_get_comment(p));
+ wprintf(" ");
+ q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
+ if (q) {
+ wprintf("%s ", _("Location:"));
+ escputs((char *)icalproperty_get_comment(q));
+ wprintf(" ");
+ }
+ webcit_fmt_date(buf, event_tt, 1);
+ wprintf("%s %s ", _("Starting date/time:"), buf);
+ webcit_fmt_date(buf, event_tte, 1);
+ wprintf("%s %s ", _("Ending date/time:"), buf);
+ q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
+ if (q) {
+ wprintf("%s ", _("Notes:"));
+ escputs((char *)icalproperty_get_comment(q));
+ wprintf(" ");
+ }
+ wprintf("\">");
escputs((char *) icalproperty_get_comment(p));
- wprintf("\n");
+ wprintf(" (");
+ wprintf(_("Ongoing event"));
+ wprintf(")\n");
}
- else
+ else if (!all_day_event && !notime_events)
{
- wprintf("= dstart) && (event_te.tm_hour <= dend)) {
+ startmin = diffmin = (event_te.tm_min / 2);
+ top = (dstart * 10) + ((event_te.tm_hour - dstart) * 30) + startmin;
+ }
+ else if (event_te.tm_hour >dend) {
+ startmin = diffmin = event_te.tm_min / 6;
+ top = (dstart * 10) + ((dend - dstart - 1) * 30) + ((event_tm.tm_hour - dend + 1) * 10) + startmin ;
+ }
+ else {
+ /* should never get here */
+ }
+
+ /* Calculate the location of the bottom of the box */
+ if (event_tm.tm_hour < dstart) {
+ endmin = diffmin = event_tm.tm_min / 6;
+ bottom = (event_tm.tm_hour * 10) + endmin;
+ }
+ else if ((event_tm.tm_hour >= dstart) && (event_tm.tm_hour <= dend)) {
+ endmin = diffmin = (event_tm.tm_min / 2);
+ bottom = (dstart * 10) + ((event_tm.tm_hour - dstart) * 30) + endmin ;
+ }
+ else if (event_tm.tm_hour >dend) {
+ endmin = diffmin = event_tm.tm_min / 6;
+ bottom = (dstart * 10) + ((dend - dstart + 1) * 30) + ((event_tm.tm_hour - dend - 1) * 10) + endmin;
+ }
+ else {
+ /* should never get here */
+ }
+
+ wprintf("",
- (100 + (event_tm.tm_min / 2) + (event_te.tm_hour - hour) + (hour * 30) - (dstart * 30)),
- (((event_te.tm_min - event_tm.tm_min) / 2) +(event_te.tm_hour - hour) * 30)
- );
- wprintf("",
- Cal->cal_msgnum, year, month, day, hour);
+ (Cal->unread)?"_unread":"_read",
+ top, (gap * 40), (bottom-top)
+ );
+ wprintf("cal_msgnum, year, month, day, t.hour);
+ wprintf("%s: %s ", _("From"), Cal->from);
+ wprintf("%s ", _("Summary:"));
+ escputs((char *) icalproperty_get_comment(p));
+ wprintf(" ");
+ q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
+ if (q) {
+ wprintf("%s ", _("Location:"));
+ escputs((char *)icalproperty_get_comment(q));
+ wprintf(" ");
+ }
+ webcit_fmt_date(buf, event_tt, 1);
+ wprintf("%s %s ", _("Starting date/time:"), buf);
+ webcit_fmt_date(buf, event_tte, 1);
+ wprintf("%s %s ", _("Ending date/time:"), buf);
+ q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
+ if (q) {
+ wprintf("%s ", _("Notes:"));
+ escputs((char *)icalproperty_get_comment(q));
+ wprintf(" ");
+ }
+ wprintf("\">");
+
escputs((char *) icalproperty_get_comment(p));
wprintf("\n");
}
}
}
+ DeleteHashPos(&Pos);
}
-/**
- * \brief view one day
- * \param year the year
- * \param month the month
- * \param day the day we want to display
+/*
+ * view one day
*/
void calendar_day_view(int year, int month, int day) {
int hour;
struct icaltimetype today, yesterday, tomorrow;
- int daystart = 8;
- int dayend = 17;
- char daystart_str[16], dayend_str[16];
+ long daystart;
+ long dayend;
struct tm d_tm;
char d_str[128];
int time_format;
time_t today_t;
+ int timeline = 30;
+ int extratimeline = 0;
+ int gap = 0;
time_format = get_time_format_cached ();
- get_preference("daystart", daystart_str, sizeof daystart_str);
- if (!IsEmptyStr(daystart_str)) daystart = atoi(daystart_str);
- get_preference("dayend", dayend_str, sizeof dayend_str);
- if (!IsEmptyStr(dayend_str)) dayend = atoi(dayend_str);
+ get_pref_long("daystart", &daystart, 8);
+ get_pref_long("dayend", &dayend, 17);
- /** Today's date */
+ /* Today's date */
memset(&d_tm, 0, sizeof d_tm);
d_tm.tm_year = year - 1900;
d_tm.tm_mon = month - 1;
d_tm.tm_mday = day;
today_t = mktime(&d_tm);
- /** Figure out the dates for "yesterday" and "tomorrow" links */
+ /* Figure out the dates for "yesterday" and "tomorrow" links */
memset(&today, 0, sizeof(struct icaltimetype));
today.year = year;
@@ -780,19 +1084,29 @@ void calendar_day_view(int year, int month, int day) {
wprintf(" |