]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/calendar/serv_calendar.c
* give the flag to the CtdlDoIHavePermissionToPostInThisRoom in through the parameter...
[citadel.git] / citadel / modules / calendar / serv_calendar.c
index a8ae3b7c9e8a7c5f47527837b7fc33e483558f9c..526d737c50b124e2141e4dd21418e6dac48e44f6 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"
@@ -114,6 +113,7 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
        char *ser = NULL;
        icalcomponent *encaps = NULL;
        struct CtdlMessage *msg = NULL;
+       icalcomponent *tmp=NULL;
 
        if (cal == NULL) return;
 
@@ -121,8 +121,10 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
         * a full VCALENDAR component, and save that instead.
         */
        if (icalcomponent_isa(cal) != ICAL_VCALENDAR_COMPONENT) {
-               encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(cal));
+               tmp = icalcomponent_new_clone(cal);
+               encaps = ical_encapsulate_subcomponent(tmp);
                ical_write_to_cal(u, encaps);
+               icalcomponent_free(tmp);
                icalcomponent_free(encaps);
                return;
        }
@@ -173,7 +175,7 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
        }
 
        /* In either case, now we can free the serialized calendar object */
-       free(ser);
+//     free(ser);
 }
 
 
@@ -262,7 +264,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                                if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
                                        strcpy(attendee_string, &attendee_string[7]);
                                        striplt(attendee_string);
-                                       recp = validate_recipients(attendee_string);
+                                       recp = validate_recipients(attendee_string, 0);
                                        if (recp != NULL) {
                                                if (!strcasecmp(recp->recp_local, CC->user.fullname)) {
                                                        if (me_attend) icalproperty_free(me_attend);
@@ -348,7 +350,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                        reply_message_text);
        
                if (msg != NULL) {
-                       valid = validate_recipients(organizer_string);
+                       valid = validate_recipients(organizer_string, 0);
                        CtdlSubmitMsg(msg, valid, "");
                        CtdlFreeMessage(msg);
                        free_recipients(valid);
@@ -1212,7 +1214,7 @@ void ical_freebusy(char *who) {
        /* If not found, try it as an unqualified email address. */
        if (found_user != 0) {
                strcpy(buf, who);
-               recp = validate_recipients(buf);
+               recp = validate_recipients(buf, 0);
                lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
@@ -1228,7 +1230,7 @@ void ical_freebusy(char *who) {
        if (found_user != 0) {
                snprintf(buf, sizeof buf, "%s@%s", who, config.c_fqdn);
                lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
-               recp = validate_recipients(buf);
+               recp = validate_recipients(buf, 0);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
                                found_user = getuser(&usbuf, recp->recp_local);
@@ -1251,7 +1253,7 @@ void ical_freebusy(char *who) {
                           || (!strcasecmp(type, "directory")) ) {
                                snprintf(buf, sizeof buf, "%s@%s", who, host);
                                lprintf(CTDL_DEBUG, "Trying <%s>\n", buf);
-                               recp = validate_recipients(buf);
+                               recp = validate_recipients(buf, 0);
                                if (recp != NULL) {
                                        if (recp->num_local == 1) {
                                                found_user = getuser(&usbuf, recp->recp_local);
@@ -1284,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;
        }
@@ -1793,7 +1794,7 @@ void ical_send_out_invitations(icalcomponent *cal) {
                        request_message_text);
        
                if (msg != NULL) {
-                       valid = validate_recipients(attendees_string);
+                       valid = validate_recipients(attendees_string, 0);
                        CtdlSubmitMsg(msg, valid, "");
                        CtdlFreeMessage(msg);
                        free_recipients(valid);
@@ -2159,6 +2160,12 @@ void ical_fixed_output(char *ptr, int len) {
 }
 
 
+
+void serv_calendar_destroy(void)
+{
+       icaltimezone_free_builtin_timezones();
+}
+
 #endif /* CITADEL_WITH_CALENDAR_SERVICE */
 
 /*
@@ -2166,25 +2173,21 @@ 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);
+               CtdlRegisterCleanupHook(serv_calendar_destroy);
 #endif
-
+       }
+       
        /* return our Subversion id for the Log */
        return "$Id$";
 }
 
-
-
-void serv_calendar_destroy(void)
-{
-#ifdef CITADEL_WITH_CALENDAR_SERVICE
-       icaltimezone_free_builtin_timezones();
-#endif
-}