From 3245ec482158b2e402472f7f6de62d04eb571ce4 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 29 Sep 2002 21:25:45 +0000 Subject: [PATCH] * minor cleanup --- webcit/calendar.c | 14 ++++++++++++-- webcit/calendar_tools.c | 11 +++++++++++ webcit/calendar_view.c | 4 ++-- webcit/event.c | 33 ++++++++++++++++++++++++++++++++- webcit/webcit.h | 1 + 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/webcit/calendar.c b/webcit/calendar.c index fd677b722..283043842 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -44,11 +44,19 @@ void cal_process_attachment(char *part_source) { } void display_calendar(long msgnum) { - wprintf("Cannot display calendar item
\n"); + wprintf("" + "Cannot display calendar item. You are seeing this error " + "because your WebCit service has not been installed with " + "calendar support. Please contact your system administrator." + "
\n"); } void display_task(long msgnum) { - wprintf("Cannot display item from task list
\n"); + wprintf("" + "Cannot display to-do item. You are seeing this error " + "because your WebCit service has not been installed with " + "calendar support. Please contact your system administrator." + "
\n"); } #else /* HAVE_ICAL_H */ @@ -57,6 +65,8 @@ void display_task(long msgnum) { /****** End of handler stubs. Everything below this line is real. ******/ + + /* * Process a single calendar component. * It won't be a compound component at this point because those have diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index b7cf8fbe7..49fbcb764 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -144,6 +144,17 @@ struct icaltimetype icaltime_from_webform(char *prefix) { } +/* + * Generae a new, globally unique UID parameter for a calendar object. + */ +void generate_new_uid(char *buf) { + static int seq = 0; + + sprintf(buf, "%ld-%d@%s", + (long)time(NULL), + (seq++), + serv_info.serv_fqdn); +} #endif diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index d43e49103..28550be8e 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -76,7 +76,7 @@ void calendar_month_view_display_events(time_t thetime) { ); escputs((char *) icalproperty_get_comment(p)); - wprintf("\n"); + wprintf("
\n"); } } @@ -242,7 +242,7 @@ void calendar_day_view_display_events(int year, int month, ); escputs((char *) icalproperty_get_comment(p)); - wprintf("\n"); + wprintf("
\n"); } } diff --git a/webcit/event.c b/webcit/event.c index df2b63a21..1411b5e7c 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -58,6 +58,13 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) "
\n" ); + wprintf("UID == "); + p = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY); + if (p != NULL) { + escputs((char *)icalproperty_get_comment(p)); + } + wprintf(" (FIXME remove this when done)
\n"); + wprintf("
\n"); wprintf("\n", msgnum); @@ -70,7 +77,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) wprintf("\n", bstr("day")); - /* Put it in a borderless table so it lines up nicely */ wprintf("\n"); @@ -83,6 +89,15 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) } wprintf("\">\n"); + wprintf("\n"); + wprintf("
Location\n" + "
Start\n"); p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY); if (p != NULL) { @@ -162,6 +177,13 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) { icalcomponent_add_property(vevent, icalproperty_new_summary(bstr("summary"))); + while (prop = icalcomponent_get_first_property(vevent, + ICAL_LOCATION_PROPERTY), prop != NULL) { + icalcomponent_remove_property(vevent, prop); + } + icalcomponent_add_property(vevent, + icalproperty_new_location(bstr("location"))); + while (prop = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY), prop != NULL) { icalcomponent_remove_property(vevent, prop); @@ -188,6 +210,15 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) { icaltime_from_webform("due") ) ); + + /* Give this event a UID if it doesn't have one. */ + if (icalcomponent_get_first_property(vevent, + ICAL_UID_PROPERTY) == NULL) { + generate_new_uid(buf); + icalcomponent_add_property(vevent, + icalproperty_new_uid(buf) + ); + } /* Serialize it and save it to the message base */ serv_puts("ENT0 1|||4"); diff --git a/webcit/webcit.h b/webcit/webcit.h index d94a69cc7..6ec0e4655 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -360,6 +360,7 @@ void display_icaltimetype_as_webform(struct icaltimetype *, char *); struct icaltimetype icaltime_from_webform(char *prefix); void display_edit_individual_event(icalcomponent *supplied_vtodo, long msgnum); void save_individual_event(icalcomponent *supplied_vtodo, long msgnum); +void generate_new_uid(char *); #endif extern char *months[]; -- 2.39.2