]> code.citadel.org Git - citadel.git/blobdiff - webcit/calendar_view.c
* persistantly handle the bufferlengths for dates; snprintf doesn't terminate strings...
[citadel.git] / webcit / calendar_view.c
index 635e96a00ea3e20dd5265f3fd903077238808dd7..6d71049a9b406e8120eb57017ad6220daa9a5a24 100644 (file)
@@ -245,6 +245,10 @@ void calendar_month_view_display_events(int year, int month, int day)
                 */
                if (show_event) {
                        p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
+                       if (p == NULL) {
+                               p = icalproperty_new_summary(_("Untitled Event"));
+                               icalcomponent_add_property(Cal->cal, p);
+                       }
                        if (p != NULL) {
 
                                if (all_day_event) {
@@ -331,7 +335,7 @@ void calendar_month_view_display_events(int year, int month, int day)
                                                }
                                                else {
                                                        tt = icaltime_as_timet(t);
-                                                       webcit_fmt_date(buf, tt, DATEFMT_BRIEF);
+                                                       webcit_fmt_date(buf, 256, tt, DATEFMT_BRIEF);
                                                        if (no_end || !icaltime_compare(t, end_t)) {
                                                                wprintf("<i>%s</i> %s<br>",
                                                                        _("Date/time:"), buf);
@@ -340,7 +344,7 @@ void calendar_month_view_display_events(int year, int month, int day)
                                                                wprintf("<i>%s</i> %s<br>",
                                                                        _("Starting date/time:"), buf);
                                                                tt = icaltime_as_timet(end_t);
-                                                               webcit_fmt_date(buf, tt, DATEFMT_BRIEF);
+                                                               webcit_fmt_date(buf, 256, tt, DATEFMT_BRIEF);
                                                                wprintf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
                                                        }
                                                        
@@ -438,6 +442,10 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
                        p = icalcomponent_get_first_property(
                                Cal->cal,
                                ICAL_SUMMARY_PROPERTY);
+                       if (p == NULL) {
+                               p = icalproperty_new_summary(_("Untitled Event"));
+                               icalcomponent_add_property(Cal->cal, p);
+                       }
                        e = icalcomponent_get_first_property(
                                Cal->cal, 
                                ICAL_DTEND_PROPERTY);
@@ -908,6 +916,10 @@ void calendar_day_view_display_events(time_t thetime,
                /* If we determined that this event occurs today, then display it.
                 */
                p = icalcomponent_get_first_property(Cal->cal,ICAL_SUMMARY_PROPERTY);
+               if (p == NULL) {
+                       p = icalproperty_new_summary(_("Untitled Event"));
+                       icalcomponent_add_property(Cal->cal, p);
+               }
 
                if ((show_event) && (p != NULL)) {
 
@@ -934,13 +946,13 @@ void calendar_day_view_display_events(time_t thetime,
                                         wprintf("<br />");
                                }
                                if (!icaltime_compare(t, end_t)) { /* one day only */
-                                       webcit_fmt_date(buf, event_tt, DATEFMT_LOCALEDATE);
+                                       webcit_fmt_date(buf, 256, event_tt, DATEFMT_LOCALEDATE);
                                        wprintf("<i>%s</i> %s<br>", _("Date:"), buf);
                                }
                                else {
-                                       webcit_fmt_date(buf, event_tt, DATEFMT_LOCALEDATE);
+                                       webcit_fmt_date(buf, 256, event_tt, DATEFMT_LOCALEDATE);
                                        wprintf("<i>%s</i> %s<br>", _("Starting date:"), buf);
-                                       webcit_fmt_date(buf, event_tte, DATEFMT_LOCALEDATE);
+                                       webcit_fmt_date(buf, 256, event_tte, DATEFMT_LOCALEDATE);
                                        wprintf("<i>%s</i> %s<br>", _("Ending date:"), buf);
                                }
                                q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
@@ -975,9 +987,9 @@ void calendar_day_view_display_events(time_t thetime,
                                         escputs((char *)icalproperty_get_comment(q));
                                         wprintf("<br />");
                                                                }
-                                webcit_fmt_date(buf, event_tt, DATEFMT_BRIEF);
+                                webcit_fmt_date(buf, 256, event_tt, DATEFMT_BRIEF);
                                 wprintf("<i>%s</i> %s<br>", _("Starting date/time:"), buf);
-                                webcit_fmt_date(buf, event_tte, DATEFMT_BRIEF);
+                                webcit_fmt_date(buf, 256, event_tte, DATEFMT_BRIEF);
                                 wprintf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
                                 q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
                                 if (q) {
@@ -1055,13 +1067,13 @@ void calendar_day_view_display_events(time_t thetime,
                                         wprintf("<br />");
                                                                }
                                if (!icaltime_compare(t, end_t)) { /* one day only */
-                                       webcit_fmt_date(buf, event_tt, DATEFMT_BRIEF);
+                                       webcit_fmt_date(buf, 256, event_tt, DATEFMT_BRIEF);
                                        wprintf("<i>%s</i> %s<br>", _("Date/time:"), buf);
                                }
                                else {
-                                       webcit_fmt_date(buf, event_tt, DATEFMT_BRIEF);
+                                       webcit_fmt_date(buf, 256, event_tt, DATEFMT_BRIEF);
                                        wprintf("<i>%s</i> %s<br>", _("Starting date/time:"), buf);
-                                       webcit_fmt_date(buf, event_tte, DATEFMT_BRIEF);
+                                       webcit_fmt_date(buf, 256, event_tte, DATEFMT_BRIEF);
                                        wprintf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
                                }
                                q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
@@ -1347,7 +1359,7 @@ int calendar_summary_view(void) {
                        else {
                                all_day_event = 0;
                        }
-                       fmt_time(timestring, event_tt);
+                       fmt_time(timestring, SIZ, event_tt);
 
                        if (all_day_event) {
                                gmtime_r(&event_tt, &event_tm);
@@ -1362,6 +1374,10 @@ int calendar_summary_view(void) {
                        ) {
 
                                p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
+                               if (p == NULL) {
+                                       p = icalproperty_new_summary(_("Untitled Task"));
+                                       icalcomponent_add_property(Cal->cal, p);
+                               }
                                if (p != NULL) {
 
 
@@ -1643,7 +1659,7 @@ void do_tasks_view(void) {
                due = get_task_due_date(Cal->cal, &is_date);
                wprintf("<td><span");
                if (due > 0) {
-                       webcit_fmt_date(buf, due, is_date ? DATEFMT_RAWDATE : DATEFMT_FULL);
+                       webcit_fmt_date(buf, SIZ, due, is_date ? DATEFMT_RAWDATE : DATEFMT_FULL);
                        wprintf(">%s",buf);
                }
                else {