Convert CtdlMessages to respect cm_lengths[]
[citadel.git] / citadel / modules / calendar / serv_calendar.c
index a70baada454a2f2542ba6e3c23b993cf64abe9e5..8d3fe42cbb8ee13106532ac429de4f7c581c1d0b 100644 (file)
@@ -30,6 +30,7 @@
 #include "msgbase.h"
 #include "internet_addressing.h"
 #include "serv_calendar.h"
+#include "room_ops.h"
 #include "euidindex.h"
 #include "ical_dezonify.h"
 
@@ -159,7 +160,7 @@ void ical_write_to_cal(struct ctdluser *u, icalcomponent *cal) {
        
                /* Now write the data */
                CtdlSubmitMsg(msg, NULL, "", QP_EADDR);
-               CtdlFreeMessage(msg);
+               CM_Free(msg);
        }
 
        /* In either case, now we can free the serialized calendar object */
@@ -184,13 +185,13 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
        icalproperty *summary = NULL;
        char summary_string[SIZ];
        icalproperty *me_attend = NULL;
-       struct recptypes *recp = NULL;
+       recptypes *recp = NULL;
        icalparameter *partstat = NULL;
        char *serialized_reply = NULL;
        char *reply_message_text = NULL;
        const char *ch;
        struct CtdlMessage *msg = NULL;
-       struct recptypes *valid = NULL;
+       recptypes *valid = NULL;
 
        *organizer_string = '\0';
        strcpy(summary_string, "Calendar item");
@@ -311,7 +312,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                if (msg != NULL) {
                        valid = validate_recipients(organizer_string, NULL, 0);
                        CtdlSubmitMsg(msg, valid, "", QP_EADDR);
-                       CtdlFreeMessage(msg);
+                       CM_Free(msg);
                        free_recipients(valid);
                }
        }
@@ -396,7 +397,7 @@ void ical_respond(long msgnum, char *partnum, char *action) {
        /* We're done with the incoming message, because we now have a
         * calendar object in memory.
         */
-       CtdlFreeMessage(msg);
+       CM_Free(msg);
 
        /*
         * Here is the real meat of this function.  Handle the event.
@@ -648,7 +649,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
                &oec,                           /* user data */
                0
        );
-       CtdlFreeMessage(msg);
+       CM_Free(msg);
 
        original_event = oec.c;
        if (original_event == NULL) {
@@ -688,7 +689,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
                if (msg != NULL) {
                        CIT_ICAL->avoid_sending_invitations = 1;
                        CtdlSubmitMsg(msg, NULL, roomname, QP_EADDR);
-                       CtdlFreeMessage(msg);
+                       CM_Free(msg);
                        CIT_ICAL->avoid_sending_invitations = 0;
                }
        }
@@ -739,7 +740,7 @@ void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
        /* We're done with the incoming message, because we now have a
         * calendar object in memory.
         */
-       CtdlFreeMessage(msg);
+       CM_Free(msg);
 
        /*
         * Here is the real meat of this function.  Handle the event.
@@ -1167,7 +1168,7 @@ void ical_hunt_for_conflicts_backend(long msgnum, void *data) {
                (void *) &ird,                  /* user data */
                0
        );
-       CtdlFreeMessage(msg);
+       CM_Free(msg);
 
        if (ird.cal == NULL) return;
 
@@ -1237,7 +1238,7 @@ void ical_conflicts(long msgnum, char *partnum) {
                0
        );
 
-       CtdlFreeMessage(msg);
+       CM_Free(msg);
 
        if (ird.cal != NULL) {
                ical_hunt_for_conflicts(ird.cal);
@@ -1417,7 +1418,7 @@ void ical_freebusy_backend(long msgnum, void *data) {
                (void *) &ird,                  /* user data */
                0
        );
-       CtdlFreeMessage(msg);
+       CM_Free(msg);
 
        if (ird.cal) {
                ical_add_to_freebusy(fb, ird.cal);              /* Add VEVENT times to VFREEBUSY */
@@ -1438,7 +1439,7 @@ void ical_freebusy(char *who) {
        icalcomponent *encaps = NULL;
        icalcomponent *fb = NULL;
        int found_user = (-1);
-       struct recptypes *recp = NULL;
+       recptypes *recp = NULL;
        char buf[256];
        char host[256];
        char type[256];
@@ -1618,7 +1619,7 @@ void ical_getics_backend(long msgnum, void *data) {
                (void *) &ird,                  /* user data */
                0
        );
-       CtdlFreeMessage(msg);
+       CM_Free(msg);
 
        if (ird.cal == NULL) return;
 
@@ -1998,7 +1999,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
        icalcomponent *encaps = NULL;
        char *request_message_text = NULL;
        struct CtdlMessage *msg = NULL;
-       struct recptypes *valid = NULL;
+       recptypes *valid = NULL;
        char attendees_string[SIZ];
        int num_attendees = 0;
        char this_attendee[256];
@@ -2210,7 +2211,7 @@ void ical_send_out_invitations(icalcomponent *top_level_cal, icalcomponent *cal)
                if (msg != NULL) {
                        valid = validate_recipients(attendees_string, NULL, 0);
                        CtdlSubmitMsg(msg, valid, "", QP_EADDR);
-                       CtdlFreeMessage(msg);
+                       CM_Free(msg);
                        free_recipients(valid);
                }
        }
@@ -2392,7 +2393,7 @@ void ical_obj_beforesave_backend(char *name, char *filename, char *partnum,
  * If the message is being saved, we also set various message header fields
  * using data found in the iCalendar object.
  */
-int ical_obj_beforesave(struct CtdlMessage *msg)
+int ical_obj_beforesave(struct CtdlMessage *msg, recptypes *recp)
 {
        /* First determine if this is a calendar or tasks room */
        if (  (CC->room.QRdefaultview != VIEW_CALENDAR)
@@ -2407,7 +2408,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg)
                return(1);              /* You tried to save a non-RFC822 message! */
        }
 
-       if (msg->cm_fields[eMesageText] == NULL) {
+       if (CM_IsEmpty(msg, eMesageText)) {
                return(1);              /* You tried to save a null message! */
        }
 
@@ -2460,7 +2461,7 @@ void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
  * (This will start back end tasks such as automatic generation of invitations,
  * if such actions are appropriate.)
  */
-int ical_obj_aftersave(struct CtdlMessage *msg)
+int ical_obj_aftersave(struct CtdlMessage *msg, recptypes *recp)
 {
        char roomname[ROOMNAMELEN];
 
@@ -2478,7 +2479,7 @@ int ical_obj_aftersave(struct CtdlMessage *msg)
        if (msg->cm_format_type != 4) return(1);
 
        /* Reject null messages */
-       if (msg->cm_fields[eMesageText] == NULL) return(1);
+       if (CM_IsEmpty(msg, eMesageText)) return(1);
        
        /* Now recurse through it looking for our icalendar data */
        mime_parser(msg->cm_fields[eMesageText],