buybuy plaintext important message.
[citadel.git] / webcit / event.c
index f7b6b30e0a733a8a507b60bc3bd5b4731fd19161..6ae2a5ac35adb25d6d0603633c2ed6ae5b53703f 100644 (file)
@@ -44,7 +44,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        char buf[SIZ];
        int organizer_is_me = 0;
        int i, j = 0;
+       /************************************************************
+        * Uncomment this to see the UID in calendar events for debugging
        int sequence = 0;
+       */
        char weekday_labels[7][32];
        char month_labels[12][32];
        long weekstart = 0;
@@ -65,7 +68,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        int which_rrend_is_preselected;
        int which_rryeartype_is_preselected;
 
-
+       const char *ch;
        char *tabnames[3];
        const char *frequency_units[8];
        const char *ordinals[6];
@@ -95,7 +98,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        get_pref_long("weekstart", &weekstart, 17);
        if (weekstart > 6) weekstart = 0;
 
-       lprintf(9, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
+       syslog(9, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
                msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day")
        );
 
@@ -157,10 +160,12 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        /* Learn the sequence */
        p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
+       /************************************************************
+        * Uncomment this to see the UID in calendar events for debugging
        if (p != NULL) {
                sequence = icalproperty_get_sequence(p);
        }
-
+       */
        /* Begin output */
        output_headers(1, 1, 2, 0, 0, 0);
        wc_printf("<div id=\"banner\">\n");
@@ -178,8 +183,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        if (p != NULL) {
                escputs((char *)icalproperty_get_comment(p));
        }
-       wc_printf("<br />\n");
-       wc_printf("SEQUENCE == %d<br />\n", sequence);
+       wc_printf("<br>\n");
+       wc_printf("SEQUENCE == %d<br>\n", sequence);
        *************************************************************/
 
        wc_printf("<form name=\"EventForm\" method=\"POST\" action=\"save_event\">\n");
@@ -436,7 +441,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf("<table border='0' width='100%%'>\n");        /* same table style as the event tab */
        wc_printf("<tr><td><b>");
        wc_printf(_("Attendees"));
-       wc_printf("</b><br />"
+       wc_printf("</b><br>"
                "<font size='-2'>");
        wc_printf(_("(One per line)"));
        wc_printf("</font>\n");
@@ -445,7 +450,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf(
                "&nbsp;<a href=\"javascript:PopOpenAddressBook('attendees_box|%s');\" "
                "title=\"%s\">"
-               "<img alt='' align='middle' border='0' width='24' height='24' src=\"static/viewcontacts_24x.gif\">"
+               "<img alt='' align='middle' border='0' width='16' height='16' src=\"static/webcit_icons/essen/16x16/contact.png\">"
                "</a>",
                _("Attendees"),
                _("Contacts")
@@ -463,11 +468,11 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
            attendee != NULL;
            attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
-               strcpy(attendee_string, icalproperty_get_attendee(attendee));
-               if (!strncasecmp(attendee_string, "mailto:", 7)) {
+               ch = icalproperty_get_attendee(attendee);
+               if ((ch != NULL) && !strncasecmp(ch, "mailto:", 7)) {
 
                        /* screen name or email address */
-                       strcpy(attendee_string, &attendee_string[7]);
+                       safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                        striplt(attendee_string);
                        if (i++) wc_printf("\n");
                        escputs(attendee_string);
@@ -592,7 +597,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        }
 
        wc_printf(_("on day %s%d%s of the month"), "<span id=\"rrmday\">", rrmday, "</span>");
-       wc_printf("<br />\n");
+       wc_printf("<br>\n");
 
        wc_printf("<input type=\"radio\" name=\"rrmonthtype\" id=\"rrmonthtype_wday\" "
                "value=\"rrmonthtype_wday\" "
@@ -624,7 +629,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        }
        wc_printf("</select>");
 
-       wc_printf(" %s<br />\n", _("of the month"));
+       wc_printf(" %s<br>\n", _("of the month"));
 
        wc_printf("</div>\n");                          /* end 'monthday_selector' div */
 
@@ -654,7 +659,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                ((which_rryeartype_is_preselected == 0) ? "checked='checked'" : "")
        );
        wc_printf(_("every "));
-       wc_printf("<span id=\"ymday\">%s</span><br />", _("year on this date"));
+       wc_printf("<span id=\"ymday\">%s</span><br>", _("year on this date"));
 
        wc_printf("<input type=\"radio\" name=\"rryeartype\" id=\"rryeartype_ywday\" "
                "value=\"rryeartype_ywday\" "
@@ -698,7 +703,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                );
        }
        wc_printf("</select>");
-       wc_printf("<br />\n");
+       wc_printf("<br>\n");
 
        wc_printf("</div>\n");                          /* end 'yearday_selector' div */
 
@@ -718,7 +723,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                "%s onChange=\"RecurrenceShowHide();\">",
                ((which_rrend_is_preselected == 0) ? "checked='checked'" : "")
        );
-       wc_printf("%s<br />\n", _("No ending date"));
+       wc_printf("%s<br>\n", _("No ending date"));
 
        wc_printf("<input type=\"radio\" name=\"rrend\" id=\"rrend_count\" "
                "value=\"rrend_count\" "
@@ -729,7 +734,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf(" <input type=\"text\" name=\"rrcount\" id=\"rrcount\" maxlength=\"3\" size=\"3\" ");
        wc_printf("value=\"%d\"> ", recur.count);
        wc_printf(_("times"));
-       wc_printf("<br />\n");
+       wc_printf("<br>\n");
 
        wc_printf("<input type=\"radio\" name=\"rrend\" id=\"rrend_until\" "
                "value=\"rrend_until\" "
@@ -742,7 +747,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                recur.until = icaltime_add(t_start, icaldurationtype_from_int(604800));
        }
        display_icaltimetype_as_webform(&recur.until, "rruntil", 1);
-       wc_printf("<br />\n");
+       wc_printf("<br>\n");
 
        wc_printf("</td></tr>\n");
 
@@ -805,6 +810,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
        char organizer_string[SIZ];
        int sequence = 0;
        enum icalproperty_transp formtransp = ICAL_TRANSP_NONE;
+       const char *ch;
 
        if (supplied_vevent != NULL) {
                vevent = supplied_vevent;
@@ -1099,15 +1105,15 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                                foundit = 0;
 
                                for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
-                                       if (!strcasecmp(attendee_string,
-                                          icalproperty_get_attendee(attendee)))
+                                       ch = icalproperty_get_attendee(attendee);
+                                       if ((ch != NULL) && !strcasecmp(attendee_string, ch))
                                                ++foundit;
                                }
 
 
                                if (foundit == 0) {
                                        icalcomponent_add_property(vevent,
-                                               icalproperty_new_attendee(attendee_string)
+                                                                  icalproperty_new_attendee(attendee_string)
                                        );
                                }
                        }
@@ -1117,9 +1123,9 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                 * Remove any attendees *not* listed in the web form
                 */
 STARTOVER:     for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
-                       strcpy(attendee_string, icalproperty_get_attendee(attendee));
-                       if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
-                               strcpy(attendee_string, &attendee_string[7]);
+                       ch = icalproperty_get_attendee(attendee);
+                       if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
+                               safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                                striplt(attendee_string);
                                foundit = 0;
                                for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
@@ -1153,8 +1159,10 @@ STARTOVER:       for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                        serv_getln(buf, sizeof buf);
                        if (buf[0] == '8') {
                                serv_puts("Content-type: text/calendar");
+                               serv_puts("Content-Transfer-Encoding: quoted-printable");
                                serv_puts("");
-                               serv_puts(icalcomponent_as_ical_string(encaps));
+                               text_to_server_qp(icalcomponent_as_ical_string(encaps));
+//                             serv_puts(icalcomponent_as_ical_string(encaps));
                                serv_puts("000");
                        }
                        if ( (buf[0] == '8') || (buf[0] == '4') ) {
@@ -1162,7 +1170,7 @@ STARTOVER:        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                                }
                        }
                        if (buf[0] == '2') {
-                               strcpy(WC->ImportantMessage, &buf[4]);
+                               StrBufAppendBufPlain(WC->ImportantMsg, buf, -1, 4);
                        }
                        icalmemory_free_ring ();
                        icalcomponent_free(encaps);
@@ -1203,7 +1211,7 @@ STARTOVER:        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
        /* If this was a save or delete, go back to the calendar or summary view. */
        if (!havebstr("check_button")) {
                if (!strcasecmp(bstr("calview"), "summary")) {
-                       summary();
+                       do_template("summary_page");
                }
                else {
                        readloop(readfwd, eUseDefault);