* minor cleanup
authorArt Cancro <ajc@citadel.org>
Sun, 29 Sep 2002 21:25:45 +0000 (21:25 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 29 Sep 2002 21:25:45 +0000 (21:25 +0000)
webcit/calendar.c
webcit/calendar_tools.c
webcit/calendar_view.c
webcit/event.c
webcit/webcit.h

index fd677b722bdec6a86a3b889bc5d230c0e2de717f..28304384266a574b9c6cd1b1e16101081d970589 100644 (file)
@@ -44,11 +44,19 @@ void cal_process_attachment(char *part_source) {
 }
 
 void display_calendar(long msgnum) {
-       wprintf("<i>Cannot display calendar item</i><br>\n");
+       wprintf("<i>"
+               "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."
+               "</i><br>\n");
 }
 
 void display_task(long msgnum) {
-       wprintf("<i>Cannot display item from task list</i><br>\n");
+       wprintf("<i>"
+               "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."
+               "</i><br>\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
index b7cf8fbe7130e3df373992363db4efb03402b48f..49fbcb7642310420283712fec97cf6b07b1bf691 100644 (file)
@@ -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
index d43e4910320d3bba7e3b30d82710f15b9f613378..28550be8e48cc5ff91c37aa94cc7b9d503fd2ed9 100644 (file)
@@ -76,7 +76,7 @@ void calendar_month_view_display_events(time_t thetime) {
                                        );
                                        escputs((char *)
                                                icalproperty_get_comment(p));
-                                       wprintf("</A></FONT>\n");
+                                       wprintf("</A></FONT><BR>\n");
                                }
 
                        }
@@ -242,7 +242,7 @@ void calendar_day_view_display_events(int year, int month,
                                        );
                                        escputs((char *)
                                                icalproperty_get_comment(p));
-                                       wprintf("</A></FONT>\n");
+                                       wprintf("</A></FONT><BR>\n");
                                }
 
                        }
index df2b63a21eef3ae0702c7270cf9233bcb91fb727..1411b5e7cb5913bd2e91123e990e88a664d94c39 100644 (file)
@@ -58,6 +58,13 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                "</FONT></TD></TR></TABLE><BR>\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)<BR>\n");
+
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/save_event\">\n");
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
                msgnum);
@@ -70,7 +77,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"day\" VALUE=\"%s\">\n",
                bstr("day"));
 
-
        /* Put it in a borderless table so it lines up nicely */
        wprintf("<TABLE border=0 width=100%%>\n");
 
@@ -83,6 +89,15 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        }
        wprintf("\"></TD></TR>\n");
 
+       wprintf("<TR><TD><B>Location</B></TD><TD>\n"
+               "<INPUT TYPE=\"text\" NAME=\"location\" "
+               "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
+       p = icalcomponent_get_first_property(vevent, ICAL_LOCATION_PROPERTY);
+       if (p != NULL) {
+               escputs((char *)icalproperty_get_comment(p));
+       }
+       wprintf("\"></TD></TR>\n");
+
        wprintf("<TR><TD><B>Start</B></TD><TD>\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");
index d94a69cc74d000c84fa63f4552fc62d92b27c161..6ec0e4655544b0d531884404bab35a1783d0a876 100644 (file)
@@ -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[];