From: Art Cancro Date: Mon, 11 Nov 2002 04:17:24 +0000 (+0000) Subject: * More work on reply to meeting invitation X-Git-Tag: v7.86~6131 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=bd8746e0a2ca92def691be6b963db1bbe1871055 * More work on reply to meeting invitation --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 04da10171..84d729305 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 601.64 2002/11/11 04:17:24 ajc + * More work on reply to meeting invitation + Revision 601.63 2002/11/10 09:21:57 error * messages.c: fixed eader command @@ -4203,4 +4206,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 5d6c5833c..2f69288a2 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2159,7 +2159,7 @@ void quickie_message(char *from, char *to, char *room, char *text, /* - * Back end function used by make_message() and similar functions + * Back end function used by CtdlMakeMessage() and similar functions */ char *CtdlReadMessageBody(char *terminator, /* token signalling EOT */ size_t maxlen, /* maximum message length */ @@ -2243,16 +2243,21 @@ char *CtdlReadMessageBody(char *terminator, /* token signalling EOT */ /* * Build a binary message to be saved on disk. + * (NOTE: if you supply 'preformatted_text', the buffer you give it + * will become part of the message. This means you are no longer + * responsible for managing that memory -- it will be freed along with + * the rest of the fields when CtdlFreeMessage() is called.) */ -static struct CtdlMessage *make_message( +struct CtdlMessage *CtdlMakeMessage( struct usersupp *author, /* author's usersupp structure */ char *recipient, /* NULL if it's not mail */ char *room, /* room where it's going */ int type, /* see MES_ types in header file */ int format_type, /* variformat, plain text, MIME... */ char *fake_name, /* who we're masquerading as */ - char *subject /* Subject (optional) */ + char *subject, /* Subject (optional) */ + char *preformatted_text /* ...or NULL to read text from client */ ) { char dest_node[SIZ]; char buf[SIZ]; @@ -2308,8 +2313,13 @@ static struct CtdlMessage *make_message( } } - msg->cm_fields['M'] = CtdlReadMessageBody("000", + if (preformatted_text != NULL) { + msg->cm_fields['M'] = preformatted_text; + } + else { + msg->cm_fields['M'] = CtdlReadMessageBody("000", config.c_maxmsglen, NULL); + } return(msg); } @@ -2641,9 +2651,9 @@ void cmd_ent0(char *entargs) /* Read in the message from the client. */ cprintf("%d send message\n", SEND_LISTING); - msg = make_message(&CC->usersupp, recp, + msg = CtdlMakeMessage(&CC->usersupp, recp, CC->quickroom.QRname, anonymous, format_type, - masquerade_as, subject); + masquerade_as, subject, NULL); if (msg != NULL) { CtdlSubmitMsg(msg, valid, ""); diff --git a/citadel/msgbase.h b/citadel/msgbase.h index cfa6aa7f5..ba37dc734 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -126,3 +126,13 @@ int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n); void CtdlSetSeen(long target_msgnum, int target_setting); struct recptypes *validate_recipients(char *recipients); void CtdlGetSeen(char *buf); +struct CtdlMessage *CtdlMakeMessage( + struct usersupp *author, /* author's usersupp structure */ + char *recipient, /* NULL if it's not mail */ + char *room, /* room where it's going */ + int type, /* see MES_ types in header file */ + int format_type, /* variformat, plain text, MIME... */ + char *fake_name, /* who we're masquerading as */ + char *subject, /* Subject (optional) */ + char *preformatted_text /* ...or NULL to read text from client */ +); diff --git a/citadel/serv_calendar.c b/citadel/serv_calendar.c index 522319de7..c18ce1090 100644 --- a/citadel/serv_calendar.c +++ b/citadel/serv_calendar.c @@ -105,6 +105,9 @@ void ical_add(icalcomponent *cal, int recursion_level) { * * 'request' is the invitation to reply to. * 'action' is the string "accept" or "decline". + * + * (Sorry about this being more than 80 columns ... there was just + * no easy way to break it down sensibly.) */ void ical_send_a_reply(icalcomponent *request, char *action) { icalcomponent *the_reply = NULL; @@ -116,6 +119,10 @@ void ical_send_a_reply(icalcomponent *request, char *action) { icalproperty *me_attend = NULL; struct recptypes *recp = NULL; icalparameter *partstat = NULL; + char *serialized_reply = NULL; + char *reply_message_text = NULL; + struct CtdlMessage *msg = NULL; + struct recptypes *valid = NULL; strcpy(organizer_string, ""); @@ -133,8 +140,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) { /* Change the method from REQUEST to REPLY */ icalcomponent_set_method(the_reply, ICAL_METHOD_REPLY); - vevent = icalcomponent_get_first_component(the_reply, - ICAL_VEVENT_COMPONENT); + vevent = icalcomponent_get_first_component(the_reply, ICAL_VEVENT_COMPONENT); if (vevent != NULL) { /* Hunt for attendees, removing ones that aren't us. * (Actually, remove them all, cloning our own one so we can @@ -146,8 +152,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) { if (icalproperty_get_attendee(attendee)) { strcpy(attendee_string, icalproperty_get_attendee(attendee) ); - if (!strncasecmp(attendee_string, "MAILTO:", - 7)) { + if (!strncasecmp(attendee_string, "MAILTO:", 7)) { strcpy(attendee_string, &attendee_string[7]); striplt(attendee_string); recp = validate_recipients(attendee_string); @@ -201,15 +206,30 @@ void ical_send_a_reply(icalcomponent *request, char *action) { } } - /********* FIXME ********** - All we have to do now is send the reply. Generate it with: - icalcomponent_as_ical_string(the_reply) - ...and send it to 'organizer_string' - (I'm just too tired to do it now) - **********************************/ + /* Now generate the reply message and send it out. */ + serialized_reply = strdoop(icalcomponent_as_ical_string(the_reply)); + icalcomponent_free(the_reply); /* don't need this anymore */ + if (serialized_reply == NULL) return; + + reply_message_text = mallok(strlen(serialized_reply) + SIZ); + if (reply_message_text != NULL) { + sprintf(reply_message_text, + "Content-type: text/calendar\r\n\r\n%s\r\n", + serialized_reply + ); - /* clean up */ - icalcomponent_free(the_reply); + /* FIXME this still causes crashy crashy badness. */ + msg = CtdlMakeMessage(&CC->usersupp, organizer_string, + CC->quickroom.QRname, 0, FMT_RFC822, + NULL, "FIXME subject", reply_message_text); + + if (msg != NULL) { + valid = validate_recipients(organizer_string); + CtdlSubmitMsg(msg, valid, ""); + CtdlFreeMessage(msg); + } + } + phree(serialized_reply); }