]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_calendar.c
* Any "delete message" operation which is synchronous to a client is now
[citadel.git] / citadel / serv_calendar.c
index 08e090a9bb8079665e279c79e4ef61386f66f161..fbc5ec510279dcf2ef599ed0516831c7b0fcaa8f 100644 (file)
@@ -337,7 +337,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
  * and turns them into calendar objects
  */
 void ical_locate_part(char *name, char *filename, char *partnum, char *disp,
-               void *content, char *cbtype, size_t length, char *encoding,
+               void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
                void *cbuserdata) {
 
        struct ical_respond_data *ird = NULL;
@@ -428,7 +428,7 @@ void ical_respond(long msgnum, char *partnum, char *action) {
                /* Now that we've processed this message, we don't need it
                 * anymore.  So delete it.
                 */
-               CtdlDeleteMessages(CC->room.QRname, msgnum, "");
+               CtdlDeleteMessages(CC->room.QRname, msgnum, "", 1);
 
                /* Free the memory we allocated and return a response. */
                icalcomponent_free(ird.cal);
@@ -495,7 +495,7 @@ struct original_event_container {
  * to fetch the object being updated)
  */
 void ical_locate_original_event(char *name, char *filename, char *partnum, char *disp,
-               void *content, char *cbtype, size_t length, char *encoding,
+               void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
                void *cbuserdata) {
 
        struct original_event_container *oec = NULL;
@@ -779,7 +779,7 @@ void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
                /* Now that we've processed this message, we don't need it
                 * anymore.  So delete it.  (Maybe make this optional?)
                 */
-               CtdlDeleteMessages(CC->room.QRname, msgnum, "");
+               CtdlDeleteMessages(CC->room.QRname, msgnum, "", 1);
 
                /* Free the memory we allocated and return a response. */
                icalcomponent_free(ird.cal);
@@ -1175,9 +1175,9 @@ void ical_freebusy(char *who) {
        icalcomponent *fb = NULL;
        int found_user = (-1);
        struct recptypes *recp = NULL;
-       char buf[SIZ];
-       char host[SIZ];
-       char type[SIZ];
+       char buf[256];
+       char host[256];
+       char type[256];
        int i = 0;
        int config_lines = 0;
 
@@ -1218,9 +1218,9 @@ void ical_freebusy(char *who) {
        if (found_user != 0) {
                config_lines = num_tokens(inetcfg, '\n');
                for (i=0; ((i < config_lines) && (found_user != 0)); ++i) {
-                       extract_token(buf, inetcfg, i, '\n');
-                       extract_token(host, buf, 0, '|');
-                       extract_token(type, buf, 1, '|');
+                       extract_token(buf, inetcfg, i, '\n', sizeof buf);
+                       extract_token(host, buf, 0, '|', sizeof host);
+                       extract_token(type, buf, 1, '|', sizeof type);
 
                        if ( (!strcasecmp(type, "localhost"))
                           || (!strcasecmp(type, "directory")) ) {
@@ -1336,13 +1336,13 @@ void ical_freebusy(char *who) {
  */
 void cmd_ical(char *argbuf)
 {
-       char subcmd[SIZ];
+       char subcmd[64];
        long msgnum;
-       char partnum[SIZ];
-       char action[SIZ];
-       char who[SIZ];
+       char partnum[256];
+       char action[256];
+       char who[256];
 
-       extract(subcmd, argbuf, 0);
+       extract_token(subcmd, argbuf, 0, '|', sizeof subcmd);
 
        /* Allow "test" and "freebusy" subcommands without logging in. */
 
@@ -1352,7 +1352,7 @@ void cmd_ical(char *argbuf)
        }
 
        if (!strcasecmp(subcmd, "freebusy")) {
-               extract(who, argbuf, 1);
+               extract_token(who, argbuf, 1, '|', sizeof who);
                ical_freebusy(who);
                return;
        }
@@ -1369,23 +1369,23 @@ void cmd_ical(char *argbuf)
 
        if (!strcasecmp(subcmd, "respond")) {
                msgnum = extract_long(argbuf, 1);
-               extract(partnum, argbuf, 2);
-               extract(action, argbuf, 3);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+               extract_token(action, argbuf, 3, '|', sizeof action);
                ical_respond(msgnum, partnum, action);
                return;
        }
 
        if (!strcasecmp(subcmd, "handle_rsvp")) {
                msgnum = extract_long(argbuf, 1);
-               extract(partnum, argbuf, 2);
-               extract(action, argbuf, 3);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+               extract_token(action, argbuf, 3, '|', sizeof action);
                ical_handle_rsvp(msgnum, partnum, action);
                return;
        }
 
        if (!strcasecmp(subcmd, "conflicts")) {
                msgnum = extract_long(argbuf, 1);
-               extract(partnum, argbuf, 2);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
                ical_conflicts(msgnum, partnum);
                return;
        }
@@ -1471,7 +1471,7 @@ void ical_send_out_invitations(icalcomponent *cal) {
        struct recptypes *valid = NULL;
        char attendees_string[SIZ];
        int num_attendees = 0;
-       char this_attendee[SIZ];
+       char this_attendee[256];
        icalproperty *attendee = NULL;
        char summary_string[SIZ];
        icalproperty *summary = NULL;
@@ -1515,11 +1515,11 @@ void ical_send_out_invitations(icalcomponent *cal) {
        strcpy(attendees_string, "");
        for (attendee = icalcomponent_get_first_property(the_request, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(the_request, ICAL_ATTENDEE_PROPERTY)) {
                if (icalproperty_get_attendee(attendee)) {
-                       strcpy(this_attendee, icalproperty_get_attendee(attendee) );
+                       safestrncpy(this_attendee, icalproperty_get_attendee(attendee), sizeof this_attendee);
                        if (!strncasecmp(this_attendee, "MAILTO:", 7)) {
                                strcpy(this_attendee, &this_attendee[7]);
 
-                               if (!CtdlIsMe(this_attendee)) { /* don't send an invitation to myself! */
+                               if (!CtdlIsMe(this_attendee, sizeof this_attendee)) {   /* don't send an invitation to myself! */
                                        snprintf(&attendees_string[strlen(attendees_string)],
                                                sizeof(attendees_string) - strlen(attendees_string),
                                                "%s, ",
@@ -1639,7 +1639,7 @@ void ical_saving_vevent(icalcomponent *cal) {
                         * If the user saving the event is listed as the
                         * organizer, then send out invitations.
                         */
-                       if (CtdlIsMe(organizer_string)) {
+                       if (CtdlIsMe(organizer_string, sizeof organizer_string)) {
                                ical_send_out_invitations(cal);
                        }
                }
@@ -1664,10 +1664,10 @@ void ical_saving_vevent(icalcomponent *cal) {
  * and the start time (becomes message date/time).
  */
 void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
-               char *disp, void *content, char *cbtype, size_t length,
+               char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
                char *encoding, void *cbuserdata)
 {
-       icalcomponent *cal;
+       icalcomponent *cal, *nested_event, *nested_todo;
        icalproperty *p;
        struct icalmessagemod *imm;
        char new_uid[SIZ];
@@ -1683,9 +1683,18 @@ void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
                cal = icalcomponent_new_from_string(content);
                if (cal != NULL) {
                        if (icalcomponent_isa(cal) == ICAL_VCALENDAR_COMPONENT) {
-                               cal = icalcomponent_get_first_component(
+                               nested_event = icalcomponent_get_first_component(
                                        cal, ICAL_VEVENT_COMPONENT
                                );
+                               nested_todo = icalcomponent_get_first_component(
+                                       cal, ICAL_VTODO_COMPONENT
+                               );
+                               if (nested_event != NULL) {
+                                       cal = nested_event;
+                               }
+                               else if (nested_todo != NULL) {
+                                       cal = nested_todo;
+                               }
                        }
                }
                if (cal != NULL) {
@@ -1698,14 +1707,11 @@ void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
                        }
                        if (p != NULL) {
                                strcpy(imm->uid, icalproperty_get_comment(p));
-                               strcpy(imm->subject,
-                                               icalproperty_get_comment(p));
+                               /* strcpy(imm->subject, icalproperty_get_comment(p)); old aethera hack */
                        }
                        p = ical_ctdl_get_subprop(cal, ICAL_SUMMARY_PROPERTY);
                        if (p != NULL) {
-                               strcat(imm->subject, " ");
-                               strcat(imm->subject,
-                                               icalproperty_get_comment(p));
+                               strcpy(imm->subject, icalproperty_get_comment(p));
                        }
                        p = ical_ctdl_get_subprop(cal, ICAL_DTSTART_PROPERTY);
                        if (p != NULL) {
@@ -1733,7 +1739,6 @@ void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
  */
 int ical_obj_beforesave(struct CtdlMessage *msg)
 {
-       char roomname[ROOMNAMELEN];
        char *p;
        int a;
        struct icalmessagemod imm;
@@ -1801,7 +1806,7 @@ int ical_obj_beforesave(struct CtdlMessage *msg)
  * Things we need to do after saving a calendar event.
  */
 void ical_obj_aftersave_backend(char *name, char *filename, char *partnum,
-               char *disp, void *content, char *cbtype, size_t length,
+               char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
                char *encoding, void *cbuserdata)
 {
        icalcomponent *cal;
@@ -1875,10 +1880,14 @@ int ical_obj_aftersave(struct CtdlMessage *msg)
 
 
 void ical_session_startup(void) {
-       CtdlAllocUserData(SYM_CIT_ICAL, sizeof(struct cit_ical));
+       CIT_ICAL = malloc(sizeof(struct cit_ical));
        memset(CIT_ICAL, 0, sizeof(struct cit_ical));
 }
 
+void ical_session_shutdown(void) {
+       free(CIT_ICAL);
+}
+
 
 #endif /* CITADEL_WITH_CALENDAR_SERVICE */
 
@@ -1893,6 +1902,7 @@ char *serv_calendar_init(void)
        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);
 #endif
        return "$Id$";
 }