]> code.citadel.org Git - citadel.git/blobdiff - webcit/event.c
* QP encode ical text fields; work on bug 351
[citadel.git] / webcit / event.c
index 9f7bdfc2b4dbb9c59c17d7ac791fd61b0f2afe07..ea4e848511943b45ad29d6a98c87422512fbd3d6 100644 (file)
@@ -242,25 +242,34 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                }
        }
        else {
-               /*
-                * 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.
-                */
-               if (t_start.is_date) {
-                       t_end = t_start;
+               if (created_new_vevent == 1) {
+                       /* set default duration */
+                       if (t_start.is_date) {
+                               /*
+                                * 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).
+                                */
+                               t_end = t_start;
+                       }
+                       else {
+                               /*
+                                * If this is not an all-day event and there is no
+                                * end time specified, make the default one hour
+                                * from the start time.
+                                */
+                               t_end = t_start;
+                               t_end.hour += 1;
+                               t_end.second = 0;
+                               t_end = icaltime_normalize(t_end);
+                               /* t_end = icaltime_from_timet(now, 0); */
+                       }
                }
                else {
                        /*
-                        * If this is not an all-day event and there is no
-                        * end time specified, make the default one hour
-                        * from the start time.
+                        * If an existing event has no end date/time this is
+                        * supposed to mean end = start.
                         */
                        t_end = t_start;
-                       t_end.hour += 1;
-                       t_end.second = 0;
-                       t_end = icaltime_normalize(t_end);
-                       /* t_end = icaltime_from_timet(now, 0); */
                }
        }
        display_icaltimetype_as_webform(&t_end, "dtend", 0);
@@ -284,7 +293,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
         */
        if (icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY)
           == NULL) {
-               sprintf(organizer_string, "MAILTO:%s", WC->cs_inet_email);
+               sprintf(organizer_string, "MAILTO:%s", ChrPtr(WC->cs_inet_email));
                icalcomponent_add_property(vevent,
                        icalproperty_new_organizer(organizer_string)
                );
@@ -802,7 +811,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
 
        if ( (havebstr("save_button"))
           || (havebstr("check_button")) ) {
-
+               StrBuf *Buf = NewStrBuf();
                /* Replace values in the component with ones from the form */
 
                while (prop = icalcomponent_get_first_property(vevent,
@@ -812,11 +821,20 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                }
 
                if (havebstr("summary")) {
-                       icalcomponent_add_property(vevent,
-                                       icalproperty_new_summary(bstr("summary")));
+                       FlushStrBuf(Buf);
+                       StrBufRFC2047encode(&Buf, sbstr("summary"));
+                       icalcomponent_add_property(
+                               vevent,
+                               icalproperty_new_summary(ChrPtr(Buf)));
                } else {
-                       icalcomponent_add_property(vevent,
-                                       icalproperty_new_summary(_("Untitled Event")));
+                       StrBuf *Untitled;
+                       FlushStrBuf(Buf);
+                       Untitled = NewStrBufPlain(_("Untitled Event"), -1);
+                       StrBufRFC2047encode(&Buf, Untitled);
+                       FreeStrBuf(&Untitled);
+                       icalcomponent_add_property(
+                               vevent,
+                               icalproperty_new_summary(ChrPtr(Buf)));
                }
        
                while (prop = icalcomponent_get_first_property(vevent,
@@ -825,8 +843,11 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                        icalproperty_free(prop);
                }
                if (havebstr("location")) {
-                       icalcomponent_add_property(vevent,
-                                       icalproperty_new_location(bstr("location")));
+                       FlushStrBuf(Buf);
+                       StrBufRFC2047encode(&Buf, sbstr("location"));
+                       icalcomponent_add_property(
+                               vevent,
+                               icalproperty_new_location(ChrPtr(Buf)));
                }
                while (prop = icalcomponent_get_first_property(vevent,
                                  ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
@@ -834,8 +855,11 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                        icalproperty_free(prop);
                }
                if (havebstr("description")) {
-                       icalcomponent_add_property(vevent,
-                               icalproperty_new_description(bstr("description")));
+                       FlushStrBuf(Buf);
+                       StrBufRFC2047encode(&Buf, sbstr("description"));
+                       icalcomponent_add_property(
+                               vevent,
+                               icalproperty_new_description(ChrPtr(Buf)));
                }
 
                while (prop = icalcomponent_get_first_property(vevent,
@@ -1146,7 +1170,7 @@ STARTOVER:        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                        icalcomponent_free(encaps);
                        encaps = NULL;
                }
-
+               FreeStrBuf(&Buf);
        }
 
        /*