* Getting closer to doing the availability check. Created new source
[citadel.git] / webcit / availability.c
1 /*
2  * $Id$
3  *
4  * Check attendee availability for scheduling a meeting.
5  *
6  */
7
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <stdio.h>
12 #include <fcntl.h>
13 #include <signal.h>
14 #include <sys/types.h>
15 #include <sys/wait.h>
16 #include <sys/socket.h>
17 #include <limits.h>
18 #include <netinet/in.h>
19 #include <netdb.h>
20 #include <string.h>
21 #include <pwd.h>
22 #include <errno.h>
23 #include <stdarg.h>
24 #include <pthread.h>
25 #include <signal.h>
26 #include <time.h>
27 #include "webcit.h"
28 #include "webserver.h"
29
30
31 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
32
33 /*
34  * Display an event by itself (for editing)
35  */
36 void check_attendee_availability(icalcomponent *vevent) {
37         icalproperty *attendee = NULL;
38         char attendee_string[SIZ];
39
40         if (vevent == NULL) {
41                 return;
42         }
43
44         /* If we're looking at a fully encapsulated VCALENDAR
45          * rather than a VEVENT component, attempt to use the first
46          * relevant VEVENT subcomponent.  If there is none, the
47          * NULL returned by icalcomponent_get_first_component() will
48          * tell the next iteration of this function to create a
49          * new one.
50          */
51         if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
52                 check_attendee_availability(
53                         icalcomponent_get_first_component(
54                                 vevent, ICAL_VEVENT_COMPONENT
55                         )
56                 );
57                 return;
58         }
59
60
61         /*
62          * Iterate through attendees.  FIXME do something useful.
63          */
64         for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
65             attendee != NULL;
66             attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
67
68                 strcpy(attendee_string, icalproperty_get_attendee(attendee));
69                 if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
70
71                         /* screen name or email address */
72                         strcpy(attendee_string, &attendee_string[7]);
73                         striplt(attendee_string);
74
75                         /* FIXME do something with attendee_string */
76                         lprintf(9, "FIXME with <%s>\n", attendee_string);
77
78                         /* participant status 
79                         partstat_as_string(buf, attendee); */
80                 }
81         }
82
83 }
84
85
86 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */