Here it is, the new thread interface.
[citadel.git] / citadel / modules / calendar / serv_calendar.c
index d9505b33230654840926bf7713756e25b936335f..a560993376eddc6e92a9d8e82deb1e47e38bcf81 100644 (file)
@@ -19,6 +19,7 @@
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
 #endif
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "citserver.h"
@@ -26,9 +27,7 @@
 #include "config.h"
 #include "user_ops.h"
 #include "room_ops.h"
-#include "tools.h"
 #include "msgbase.h"
-#include "mime_parser.h"
 #include "internet_addressing.h"
 #include "serv_calendar.h"
 #include "euidindex.h"
@@ -126,6 +125,7 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
                encaps = ical_encapsulate_subcomponent(tmp);
                ical_write_to_cal(u, encaps);
                icalcomponent_free(tmp);
+               icalcomponent_free(encaps);
                return;
        }
 
@@ -1286,7 +1286,6 @@ void ical_freebusy(char *who) {
        if (fb == NULL) {
                cprintf("%d Internal error: cannot allocate memory.\n",
                        ERROR + INTERNAL_ERROR);
-               icalcomponent_free(encaps);
                getroom(&CC->room, hold_rm);
                return;
        }
@@ -2168,16 +2167,19 @@ void ical_fixed_output(char *ptr, int len) {
  */
 CTDL_MODULE_INIT(calendar)
 {
+       if (!threading)
+       {
 #ifdef CITADEL_WITH_CALENDAR_SERVICE
-       CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE);
-       CtdlRegisterMessageHook(ical_obj_aftersave, EVT_AFTERSAVE);
-       CtdlRegisterSessionHook(ical_create_room, EVT_LOGIN);
-       CtdlRegisterProtoHook(cmd_ical, "ICAL", "Citadel iCal commands");
-       CtdlRegisterSessionHook(ical_session_startup, EVT_START);
-       CtdlRegisterSessionHook(ical_session_shutdown, EVT_STOP);
-       CtdlRegisterFixedOutputHook("text/calendar", ical_fixed_output);
+               CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE);
+               CtdlRegisterMessageHook(ical_obj_aftersave, EVT_AFTERSAVE);
+               CtdlRegisterSessionHook(ical_create_room, EVT_LOGIN);
+               CtdlRegisterProtoHook(cmd_ical, "ICAL", "Citadel iCal commands");
+               CtdlRegisterSessionHook(ical_session_startup, EVT_START);
+               CtdlRegisterSessionHook(ical_session_shutdown, EVT_STOP);
+               CtdlRegisterFixedOutputHook("text/calendar", ical_fixed_output);
 #endif
-
+       }
+       
        /* return our Subversion id for the Log */
        return "$Id$";
 }