$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 <H>eader command
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
/*
- * 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 */
/*
* 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];
}
}
- 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);
}
/* 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, "");
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 */
+);
*
* '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;
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, "");
/* 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
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);
}
}
- /********* 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);
}