* Process calendar object subcomponents
[citadel.git] / webcit / calendar.c
1 /*
2  * $Id$
3  *
4  * Functions which handle calendar objects and their processing/display.
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 "webcit.h"
27 #include "webserver.h"
28
29 #ifdef HAVE_ICAL_H
30 #include <ical.h>
31 #endif
32
33
34 #ifndef HAVE_ICAL_H
35
36 /*
37  * Handler stub for builds with no calendar library available
38  */
39 void cal_process_attachment(char *part_source) {
40
41         wprintf("<I>This message contains calendaring/scheduling information,"
42                 " but support for calendars is not available on this "
43                 "particular system.  Please ask your system administrator to "
44                 "install a new version of the Citadel web service with "
45                 "calendaring enabled.</I><BR>\n"
46         );
47
48 }
49
50 #else /* HAVE_ICAL_H */
51
52
53
54 /*
55  * Process a single calendar component.
56  * It won't be a compound component at this point because those have
57  * already been broken down by cal_process_object().
58  */
59 void cal_process_subcomponent(icalcomponent *cal) {
60
61         wprintf("cal_process_subcomponent() called<BR>\n");
62         wprintf("cal_process_subcomponent() exiting<BR>\n");
63 }
64
65
66
67
68
69 /*
70  * Process a calendar object
71  * ...at this point it's already been deserialized by cal_process_attachment()
72  */
73 void cal_process_object(icalcomponent *cal) {
74         icalcomponent *c;
75
76         wprintf("cal_process_object() called<BR>\n");
77
78         /* Iterate through all subcomponents */
79         for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
80             (c != 0);
81             c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
82
83                 cal_process_subcomponent(c);
84
85         }
86
87         wprintf("cal_process_object() exiting<BR>\n");
88
89 }
90
91
92 /*
93  * Deserialize a calendar object in a message so it can be processed.
94  * (This is the main entry point for these things)
95  */
96 void cal_process_attachment(char *part_source) {
97         icalcomponent *cal;
98
99         wprintf("Processing calendar attachment<BR>\n");
100         cal = icalcomponent_new_from_string(part_source);
101
102         if (cal == NULL) {
103                 wprintf("Error parsing calendar object: %s<BR>\n",
104                         icalerror_strerror(icalerrno));
105                 return;
106         }
107
108         cal_process_object(cal);
109
110         /* Free the memory we obtained from libical's constructor */
111         icalcomponent_free(cal);
112 }
113
114 #endif /* HAVE_ICAL_H */