* 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;
/* 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);
* 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;
* reply's copy will have the same address, but an updated
* status.)
*/
- TRACE;
icalcomponent_remove_property(event, e_attendee);
- TRACE;
icalproperty_free(e_attendee);
- TRACE;
icalcomponent_remove_property(reply, r_attendee);
- TRACE;
icalcomponent_add_property(event, r_attendee);
- TRACE;
/* Since we diddled both sets of attendees, we have to start
* the iteration over again. This will not create an infinite
/* 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);
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;
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")) ) {
*/
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. */
}
if (!strcasecmp(subcmd, "freebusy")) {
- extract(who, argbuf, 1);
+ extract_token(who, argbuf, 1, '|', sizeof who);
ical_freebusy(who);
return;
}
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;
}
/* Set the view to a calendar view */
CtdlGetRelationship(&vbuf, &CC->user, &qr);
- vbuf.v_view = 3; /* 3 = calendar */
+ vbuf.v_view = VIEW_CALENDAR;
CtdlSetRelationship(&vbuf, &CC->user, &qr);
/* Create the tasks list room if it doesn't already exist */
return;
}
qr.QRep.expire_mode = EXPIRE_MANUAL;
- qr.QRdefaultview = VIEW_TASKS; /* 4 = tasks view */
+ qr.QRdefaultview = VIEW_TASKS;
lputroom(&qr);
/* Set the view to a task list view */
CtdlGetRelationship(&vbuf, &CC->user, &qr);
- vbuf.v_view = 4; /* 4 = tasks */
+ vbuf.v_view = VIEW_TASKS;
+ CtdlSetRelationship(&vbuf, &CC->user, &qr);
+
+ /* Create the notes room if it doesn't already exist */
+ create_room(USERNOTESROOM, 4, "", 0, 1, 0, VIEW_NOTES);
+
+ /* Set expiration policy to manual; otherwise objects will be lost! */
+ if (lgetroom(&qr, USERNOTESROOM)) {
+ lprintf(CTDL_CRIT, "Couldn't get the user calendar room!\n");
+ return;
+ }
+ qr.QRep.expire_mode = EXPIRE_MANUAL;
+ qr.QRdefaultview = VIEW_NOTES;
+ lputroom(&qr);
+
+ /* Set the view to a notes view */
+ CtdlGetRelationship(&vbuf, &CC->user, &qr);
+ vbuf.v_view = VIEW_NOTES;
CtdlSetRelationship(&vbuf, &CC->user, &qr);
return;
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;
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, ",
* 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);
}
}
* the summary of the event (becomes message subject),
* and the start time (becomes message date/time).
*/
-void ical_ctdl_set_extended_msgid(char *name, char *filename, char *partnum,
- char *disp, void *content, char *cbtype, size_t length,
+void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
+ 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];
imm = (struct icalmessagemod *)cbuserdata;
/* If this is a text/calendar object, hunt for the UID and drop it in
* the "user data" pointer for the MIME parser. When
- * ical_obj_beforesave() sees it there, it'll set the Extended msgid
+ * ical_obj_beforesave() sees it there, it'll set the Exclusive msgid
* to that string.
*/
if (!strcasecmp(cbtype, "text/calendar")) {
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) {
p = ical_ctdl_get_subprop(cal, ICAL_UID_PROPERTY);
+ if (p == NULL) {
+ /* If there's no uid we must generate one */
+ generate_uuid(new_uid);
+ icalcomponent_add_property(cal, icalproperty_new_uid(new_uid));
+ p = ical_ctdl_get_subprop(cal, ICAL_UID_PROPERTY);
+ }
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) {
/*
* See if we need to prevent the object from being saved (we don't allow
- * MIME types other than text/calendar in the Calendar> room). Also, when
- * saving an event to the calendar, set the message's Citadel extended message
- * ID to the UID of the object. This causes our replication checker to
+ * MIME types other than text/calendar in "calendar" or "tasks" rooms). Also,
+ * when saving an event to the calendar, set the message's Citadel exclusive
+ * message ID to the UID of the object. This causes our replication checker to
* automatically delete any existing instances of the same object. (Isn't
* that cool?)
*
*/
int ical_obj_beforesave(struct CtdlMessage *msg)
{
- char roomname[ROOMNAMELEN];
char *p;
int a;
struct icalmessagemod imm;
- int do_this_hook = 0;
-
- /*
- * Only messages with content-type text/calendar
- * may be saved to Calendar>. If the message is bound for
- * Calendar> but doesn't have this content-type, throw an error
- * so that the message may not be posted.
- */
- /* First determine if this is the user's calendar or tasks room */
- do_this_hook = 0;
- MailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM);
- if (!strcasecmp(roomname, CC->room.QRname)) {
- do_this_hook = 1;
- }
- MailboxName(roomname, sizeof roomname, &CC->user, USERTASKSROOM);
- if (!strcasecmp(roomname, CC->room.QRname)) {
- do_this_hook = 1;
+ /* First determine if this is a calendar or tasks room */
+ if ( (CC->curr_view != VIEW_CALENDAR)
+ &&(CC->curr_view != VIEW_TASKS) ) {
+ return(0); /* Not a vCalendar-centric room */
}
- if (!do_this_hook) {
- return; /* Not a vCalendar-centric room */
- }
-
- /* Then determine content-type of the message */
-
/* It must be an RFC822 message! */
- /* FIXME: Not handling MIME multipart messages; implement with IMIP */
- if (msg->cm_format_type != 4)
+ if (msg->cm_format_type != 4) {
return 1; /* You tried to save a non-RFC822 message! */
+ }
/* Find the Content-Type: header */
p = msg->cm_fields['M'];
memset(&imm, 0, sizeof(struct icalmessagemod));
mime_parser(msg->cm_fields['M'],
NULL,
- *ical_ctdl_set_extended_msgid,
+ *ical_ctdl_set_exclusive_msgid,
NULL, NULL,
(void *)&imm,
0
* 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;
/* If this is a text/calendar object, hunt for the UID and drop it in
* the "user data" pointer for the MIME parser. When
- * ical_obj_beforesave() sees it there, it'll set the Extended msgid
+ * ical_obj_beforesave() sees it there, it'll set the Exclusive msgid
* to that string.
*/
if (!strcasecmp(cbtype, "text/calendar")) {
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 */
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$";
}