X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fevent.c;h=b2bb386cc955cd0a2e8e8dbd04b11dc3aab967a7;hb=e81672b5553d0c2c4c6d6957106b2f02220c2908;hp=11ece54543922a827954ffa17bd6cd490db3b8ca;hpb=2f7a9932b1c1f14f5921c9f47863649cca9facd4;p=citadel.git diff --git a/webcit/event.c b/webcit/event.c index 11ece5454..b2bb386cc 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -37,7 +37,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) { icalcomponent *vevent; icalproperty *p; - struct icaltimetype t; + struct icaltimetype t_start, t_end; time_t now; int created_new_vevent = 0; @@ -104,23 +104,70 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) wprintf("Start\n"); p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY); if (p != NULL) { - t = icalproperty_get_dtstart(p); + t_start = icalproperty_get_dtstart(p); + if (t_start.is_date) { + t_start.hour = 0; + t_start.minute = 0; + t_start.second = 0; + } } else { - t = icaltime_from_timet(now, 0); + t_start = icaltime_from_timet(now, 0); } - display_icaltimetype_as_webform(&t, "dtstart"); + display_icaltimetype_as_webform(&t_start, "dtstart"); + + wprintf("All day event", + (t_start.is_date ? "CHECKED" : "" ) + ); + wprintf("\n"); + /* If this is an all-day-event, set the end time to be identical to + * the start time (the hour/minute/second will be set to midnight). + * Otherwise extract or create it. + */ wprintf("End\n"); - p = icalcomponent_get_first_property(vevent, ICAL_DTEND_PROPERTY); - if (p != NULL) { - t = icalproperty_get_dtend(p); + if (t_start.is_date) { + t_end = t_start; } else { - t = icaltime_from_timet(now, 0); + p = icalcomponent_get_first_property(vevent, + ICAL_DTEND_PROPERTY); + if (p != NULL) { + t_end = icalproperty_get_dtend(p); + } + else { + t_end = icaltime_from_timet(now, 0); + } } - display_icaltimetype_as_webform(&t, "dtend"); + display_icaltimetype_as_webform(&t_end, "dtend"); wprintf("\n"); wprintf("Notes\n" @@ -200,11 +247,32 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) { ICAL_DTSTART_PROPERTY), prop != NULL) { icalcomponent_remove_property(vevent, prop); } - event_start = icaltime_from_webform("dtstart"); - if (event_start.is_date) { - lprintf(9, "*** all day event ***\n"); + + if (!strcmp(bstr("alldayevent"), "yes")) { all_day_event = 1; + lprintf(9, "*** all day event ***\n"); } + else { + all_day_event = 0; + } + + event_start = icaltime_from_webform("dtstart"); + if (all_day_event) { + event_start.is_date = 1; + event_start.hour = 0; + event_start.minute = 0; + event_start.second = 0; + } + lprintf(9, "dtstart: %s\n", + icaltime_as_ical_string(event_start) + ); + + /* FIXME. Somewhere between here and when we save the event, we are + * somehow losing the "is_date" setting of dtstart. The problem might + * be with WebCit or it might be in libical. Check to see if this + * problem goes away when we upgrade libical. --IG + */ + icalcomponent_add_property(vevent, icalproperty_new_dtstart(event_start) ); @@ -217,10 +285,11 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) { ICAL_DURATION_PROPERTY), prop != NULL) { icalcomponent_remove_property(vevent, prop); } + if (all_day_event == 0) { icalcomponent_add_property(vevent, - icalproperty_new_dtend( - icaltime_from_webform("dtend") + icalproperty_new_dtend(icaltime_normalize( + icaltime_from_webform("dtend")) ) ); } @@ -233,7 +302,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) { icalproperty_new_uid(buf) ); } - + /* Serialize it and save it to the message base */ serv_puts("ENT0 1|||4"); serv_gets(buf);