4 * Functions which handle calendar objects and their processing/display.
14 #include <sys/types.h>
16 #include <sys/socket.h>
18 #include <netinet/in.h>
27 #include "webserver.h"
37 * Handler stub for builds with no calendar library available
39 void cal_process_attachment(char *part_source) {
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"
50 #else /* HAVE_ICAL_H */
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().
59 void cal_process_subcomponent(icalcomponent *cal) {
60 wprintf("cal_process_subcomponent() called<BR>\n");
61 wprintf("cal_process_subcomponent() exiting<BR>\n");
69 * Process a calendar object
70 * ...at this point it's already been deserialized by cal_process_attachment()
72 void cal_process_object(icalcomponent *cal) {
74 int num_subcomponents = 0;
76 wprintf("cal_process_object() called<BR>\n");
78 /* Iterate through all subcomponents */
79 wprintf("Iterating through all sub-components<BR>\n");
80 for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT);
82 c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
83 cal_process_subcomponent(c);
87 /* Iterate through all subcomponents */
88 wprintf("Iterating through VEVENTs<BR>\n");
89 for (c = icalcomponent_get_first_component(cal, ICAL_VEVENT_COMPONENT);
91 c = icalcomponent_get_next_component(cal, ICAL_VEVENT_COMPONENT)) {
92 cal_process_subcomponent(c);
96 /* Iterate through all subcomponents */
97 wprintf("Iterating through VTODOs<BR>\n");
98 for (c = icalcomponent_get_first_component(cal, ICAL_VTODO_COMPONENT);
100 c = icalcomponent_get_next_component(cal, ICAL_VTODO_COMPONENT)) {
101 cal_process_subcomponent(c);
105 /* Iterate through all subcomponents */
106 wprintf("Iterating through VJOURNALs<BR>\n");
107 for (c = icalcomponent_get_first_component(cal, ICAL_VJOURNAL_COMPONENT);
109 c = icalcomponent_get_next_component(cal, ICAL_VJOURNAL_COMPONENT)) {
110 cal_process_subcomponent(c);
114 /* Iterate through all subcomponents */
115 wprintf("Iterating through VCALENDARs<BR>\n");
116 for (c = icalcomponent_get_first_component(cal, ICAL_VCALENDAR_COMPONENT);
118 c = icalcomponent_get_next_component(cal, ICAL_VCALENDAR_COMPONENT)) {
119 cal_process_subcomponent(c);
123 /* Iterate through all subcomponents */
124 wprintf("Iterating through VFREEBUSYs<BR>\n");
125 for (c = icalcomponent_get_first_component(cal, ICAL_VFREEBUSY_COMPONENT);
127 c = icalcomponent_get_next_component(cal, ICAL_VFREEBUSY_COMPONENT)) {
128 cal_process_subcomponent(c);
132 /* Iterate through all subcomponents */
133 wprintf("Iterating through VALARMs<BR>\n");
134 for (c = icalcomponent_get_first_component(cal, ICAL_VALARM_COMPONENT);
136 c = icalcomponent_get_next_component(cal, ICAL_VALARM_COMPONENT)) {
137 cal_process_subcomponent(c);
141 /* Iterate through all subcomponents */
142 wprintf("Iterating through VTIMEZONEs<BR>\n");
143 for (c = icalcomponent_get_first_component(cal, ICAL_VTIMEZONE_COMPONENT);
145 c = icalcomponent_get_next_component(cal, ICAL_VTIMEZONE_COMPONENT)) {
146 cal_process_subcomponent(c);
150 /* Iterate through all subcomponents */
151 wprintf("Iterating through VSCHEDULEs<BR>\n");
152 for (c = icalcomponent_get_first_component(cal, ICAL_VSCHEDULE_COMPONENT);
154 c = icalcomponent_get_next_component(cal, ICAL_VSCHEDULE_COMPONENT)) {
155 cal_process_subcomponent(c);
159 /* Iterate through all subcomponents */
160 wprintf("Iterating through VQUERYs<BR>\n");
161 for (c = icalcomponent_get_first_component(cal, ICAL_VQUERY_COMPONENT);
163 c = icalcomponent_get_next_component(cal, ICAL_VQUERY_COMPONENT)) {
164 cal_process_subcomponent(c);
168 /* Iterate through all subcomponents */
169 wprintf("Iterating through VCARs<BR>\n");
170 for (c = icalcomponent_get_first_component(cal, ICAL_VCAR_COMPONENT);
172 c = icalcomponent_get_next_component(cal, ICAL_VCAR_COMPONENT)) {
173 cal_process_subcomponent(c);
177 /* Iterate through all subcomponents */
178 wprintf("Iterating through VCOMMANDs<BR>\n");
179 for (c = icalcomponent_get_first_component(cal, ICAL_VCOMMAND_COMPONENT);
181 c = icalcomponent_get_next_component(cal, ICAL_VCOMMAND_COMPONENT)) {
182 cal_process_subcomponent(c);
186 if (num_subcomponents != 0) {
187 wprintf("Warning: %d subcomponents unhandled<BR>\n",
191 wprintf("cal_process_object() exiting<BR>\n");
196 * Deserialize a calendar object in a message so it can be processed.
197 * (This is the main entry point for these things)
199 void cal_process_attachment(char *part_source) {
202 wprintf("Processing calendar attachment<BR>\n");
203 cal = icalcomponent_new_from_string(part_source);
206 wprintf("Error parsing calendar object: %s<BR>\n",
207 icalerror_strerror(icalerrno));
211 cal_process_object(cal);
213 /* Free the memory we obtained from libical's constructor */
214 icalcomponent_free(cal);
217 #endif /* HAVE_ICAL_H */