* More work on reply to meeting invitation
authorArt Cancro <ajc@citadel.org>
Mon, 11 Nov 2002 04:17:24 +0000 (04:17 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 11 Nov 2002 04:17:24 +0000 (04:17 +0000)
citadel/ChangeLog
citadel/msgbase.c
citadel/msgbase.h
citadel/serv_calendar.c

index 04da10171c40df7287170561805fe593b7c3a1ba..84d729305dc399ae80fcdf2bd4adf7cd9ef0be0f 100644 (file)
@@ -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 <H>eader command
 
@@ -4203,4 +4206,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 5d6c5833c9cf0e9a1b4381be16acaa26b735badd..2f69288a2d3956bf3005dbe0293787591d1a4dcd 100644 (file)
@@ -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, "");
index cfa6aa7f5b1d768c871afe9ef6415bd912d13a81..ba37dc734ab6df73e55c1d201d6bb10c218af9bc 100644 (file)
@@ -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 */
+);
index 522319de7abae03fb8c972be4537daaf5b10a6ca..c18ce10907ef2ce7ee96c2ac83d7bc864dc82ae0 100644 (file)
@@ -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);
 }