* Display PARTSTAT for attendees
authorArt Cancro <ajc@citadel.org>
Sun, 5 Jan 2003 20:51:01 +0000 (20:51 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 5 Jan 2003 20:51:01 +0000 (20:51 +0000)
webcit/ChangeLog
webcit/calendar.c
webcit/calendar_tools.c
webcit/event.c
webcit/tools.c
webcit/webcit.h

index 23cb8acf703c492573ea77c590e1aa1348bddb8b..d296691cb59c01f99ef1c5d0c4c17dd517d5e2aa 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 400.76  2003/01/05 20:51:01  ajc
+* Display PARTSTAT for attendees
+
 Revision 400.75  2003/01/05 05:01:00  ajc
 * Add "today's calendar events" to the summary page.
 
@@ -1214,4 +1217,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index f1b20868f11c252532a62d93f6e1233f45f0ca7b..3b9bf2e862934d9a272017687e1a5f58b4117e1c 100644 (file)
@@ -200,11 +200,17 @@ void cal_process_object(icalcomponent *cal,
                wprintf("<TR><TD><B>Attendee:</B></TD><TD>");
                strcpy(buf, icalproperty_get_attendee(p));
                if (!strncasecmp(buf, "MAILTO:", 7)) {
+
+                       /* screen name or email address */
                        strcpy(buf, &buf[7]);
                        striplt(buf);
                        escputs(buf);
+                       wprintf(" ");
+
+                       /* participant status */
+                       partstat_as_string(buf, p);
+                       escputs(buf);
                }
-               /* FIXME add status */
                wprintf("</TD></TR>\n");
        }
 
index 9426716b355a21eb21bb8e74f8947c9d775a8703..85c348ce00f9e6381303f0f002220640267102f0 100644 (file)
@@ -178,5 +178,45 @@ void generate_new_uid(char *buf) {
                serv_info.serv_fqdn);
 }
 
+/*
+ * Render a PARTSTAT parameter as a string (and put it in parentheses)
+ */
+void partstat_as_string(char *buf, icalproperty *attendee) {
+       icalparameter *partstat_param;
+       icalparameter_partstat partstat;
+
+       strcpy(buf, "(status unknown)");
+
+       partstat_param = icalproperty_get_first_parameter(
+                               attendee,
+                               ICAL_PARTSTAT_PARAMETER
+       );
+       if (partstat_param == NULL) {
+               return;
+       }
+
+       partstat = icalparameter_get_partstat(partstat_param);
+       switch(partstat) {
+               case ICAL_PARTSTAT_X:
+                       strcpy(buf, "(x)");
+               case ICAL_PARTSTAT_NEEDSACTION:
+                       strcpy(buf, "(needs action)");
+               case ICAL_PARTSTAT_ACCEPTED:
+                       strcpy(buf, "(accepted)");
+               case ICAL_PARTSTAT_DECLINED:
+                       strcpy(buf, "(declined)");
+               case ICAL_PARTSTAT_TENTATIVE:
+                       strcpy(buf, "(tenative)");
+               case ICAL_PARTSTAT_DELEGATED:
+                       strcpy(buf, "(delegated)");
+               case ICAL_PARTSTAT_COMPLETED:
+                       strcpy(buf, "(completed)");
+               case ICAL_PARTSTAT_INPROCESS:
+                       strcpy(buf, "(in process)");
+               case ICAL_PARTSTAT_NONE:
+                       strcpy(buf, "(none)");
+       }
+}
+
 
 #endif
index 4bc59bca6b1790766266d1252a03ba9c0d42d8ed..45d1e2932f1b0751e017998a01633e4c727cd185 100644 (file)
@@ -281,10 +281,17 @@ 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)) {
+
+                       /* screen name or email address */
                        strcpy(attendee_string, &attendee_string[7]);
                        striplt(attendee_string);
                        if (i++) wprintf(", ");
                        escputs(attendee_string);
+                       wprintf(" ");
+
+                       /* participant status */
+                       partstat_as_string(buf, attendee);
+                       escputs(buf);
                }
        }
        wprintf("</TEXTAREA></TD></TR>\n");
@@ -492,7 +499,12 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                /*
                 * Add any new attendees listed in the web form
                 */
+
+               /* First, strip out the parenthesized partstats.  */
                strcpy(form_attendees, bstr("attendees"));
+               stripout(form_attendees, '(', ')');
+
+               /* Now iterate! */
                for (i=0; i<num_tokens(form_attendees, ','); ++i) {
                        extract_token(buf, form_attendees, i, ',');
                        striplt(buf);
index 647c2fefc0b9cc4198c894ddf1842684791b7187..6912515cae5e1e73393c7ad88cbeb2a8de6d4977 100644 (file)
@@ -376,3 +376,35 @@ void read_server_binary(char *buffer, size_t total_len) {
                }
        }
 }
+
+
+
+/*
+ * Strip a boundarized substring out of a string (for example, remove
+ * parentheses and anything inside them).
+ *
+ * This improved version can strip out *multiple* boundarized substrings.
+ */
+void stripout(char *str, char leftboundary, char rightboundary) {
+       int a;
+        int lb = (-1);
+        int rb = (-1);
+
+       do {
+               lb = (-1);
+               rb = (-1);
+       
+               for (a = 0; a < strlen(str); ++a) {
+                       if (str[a] == leftboundary) lb = a;
+                       if (str[a] == rightboundary) rb = a;
+               }
+
+               if ( (lb > 0) && (rb > lb) ) {
+                       strcpy(&str[lb - 1], &str[rb + 1]);
+               }
+
+       } while ( (lb > 0) && (rb > lb) );
+
+}
+
+
index 1588fbfc0ebaec1949dbada496a41fc29a914262..16cfe39f6a3a18291127776115cf1823542be670 100644 (file)
@@ -235,6 +235,7 @@ void url(char *buf);
 void escputs1(char *strbuf, int nbsp);
 long extract_long(char *source, long int parmnum);
 int extract_int(char *source, int parmnum);
+void stripout(char *str, char leftboundary, char rightboundary);
 void dump_vars(void);
 void embed_main_menu(void);
 void serv_read(char *buf, int bytes);
@@ -356,6 +357,7 @@ void display_calendar(long msgnum);
 void display_task(long msgnum);
 void do_calendar_view(void);
 void free_calendar_buffer(void);
+void calendar_summary_view(void);
 int load_msg_ptrs(char *servcmd);
 
 #ifdef HAVE_ICAL_H
@@ -371,6 +373,7 @@ void generate_new_uid(char *);
 void respond_to_request(void);
 void handle_rsvp(void);
 void ical_dezonify(icalcomponent *cal);
+void partstat_as_string(char *buf, icalproperty *attendee);
 #endif
 
 extern char *months[];