From 1b976a7fae70307732639067d4dafe6ef3d23a01 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 12 Sep 2005 18:20:21 +0000 Subject: [PATCH] * The "forward" button is now working, and it forwards the attachments. --- webcit/ChangeLog | 4 ++- webcit/messages.c | 92 +++++++++++++++++++++++++++++++++++------------ webcit/webcit.c | 1 + 3 files changed, 73 insertions(+), 24 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 31b23c822..b32d228a6 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 621.39 2005/09/12 18:20:21 ajc +* The "forward" button is now working, and it forwards the attachments. + Revision 621.38 2005/09/12 04:08:05 ajc * Built an initial version of the "forward message" function. It works perfectly on the message text now, but we cannot consider it finished @@ -2939,4 +2942,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/messages.c b/webcit/messages.c index b60e72b0c..3539b68da 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -940,7 +940,7 @@ void embed_message(void) { * in this function. Doing so would throw a JavaScript error in the * 'supplied text' argument to the editor. */ -void pullquote_message(long msgnum) { +void pullquote_message(long msgnum, int forward_attachments) { char buf[SIZ]; char mime_partnum[256]; char mime_filename[256]; @@ -949,6 +949,9 @@ void pullquote_message(long msgnum) { char mime_disposition[256]; int mime_length; char mime_http[SIZ]; + char *attachments = NULL; + int num_attachments = 0; + struct wc_attachment *att, *aptr; char m_subject[256]; char from[256]; char node[256]; @@ -959,9 +962,6 @@ void pullquote_message(long msgnum) { int nhdr = 0; int bq = 0; int i = 0; - char vcard_partnum[256]; - char cal_partnum[256]; - char *part_source = NULL; #ifdef HAVE_ICONV iconv_t ic = (iconv_t)(-1) ; char *ibuf; /* Buffer of characters to be converted */ @@ -975,8 +975,6 @@ void pullquote_message(long msgnum) { strcpy(node, ""); strcpy(rfca, ""); strcpy(reply_to, ""); - strcpy(vcard_partnum, ""); - strcpy(cal_partnum, ""); strcpy(mime_http, ""); strcpy(mime_content_type, "text/plain"); strcpy(mime_charset, "us-ascii"); @@ -1049,15 +1047,15 @@ void pullquote_message(long msgnum) { wprintf("%s ", now); } + /* + * Save attachment info for later. We can't start downloading them + * yet because we're in the middle of a server transaction. + */ if (!strncasecmp(buf, "part=", 5)) { - /* - * FIXME - * - * We must forward the attachments. This is to be done - * by downloading each attachment of the original - * message and inserting it into the new message's - * attachment chain. - */ + ++num_attachments; + attachments = realloc(attachments, (num_attachments * 1024)); + strcat(attachments, &buf[5]); + strcat(attachments, "\n"); } } @@ -1170,13 +1168,59 @@ void pullquote_message(long msgnum) { while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { } } - if (part_source) { - free(part_source); - part_source = NULL; - } - ENDBODY: /* end of body handler */ + + /* + * If there were attachments, we have to download them and insert them + * into the attachment chain for the forwarded message we are composing. + */ + if (num_attachments) { + for (i=0; ilength = mime_length; + strcpy(att->content_type, mime_content_type); + strcpy(att->filename, mime_filename); + att->next = NULL; + att->data = load_mimepart(msgnum, mime_partnum); + + /* And add it to the list. */ + if (WC->first_attachment == NULL) { + WC->first_attachment = att; + } + else { + aptr = WC->first_attachment; + while (aptr->next != NULL) aptr = aptr->next; + aptr->next = att; + } + } + + } + free(attachments); + } + #ifdef HAVE_ICONV if (ic != (iconv_t)(-1) ) { iconv_close(ic); @@ -2177,8 +2221,8 @@ void post_message(void) aptr->next = att; } - /* Netscape sends a simple filename, which is what we want, - * but Satan's browser sends an entire pathname. Reduce + /* Mozilla sends a simple filename, which is what we want, + * but Satan's Browser sends an entire pathname. Reduce * the path to just a filename if we need to. */ while (num_tokens(att->filename, '/') > 1) { @@ -2392,8 +2436,10 @@ void display_enter(void) "writeRichText('msgtext', '"); msgescputs(bstr("msgtext")); if (atol(bstr("pullquote")) > 0L) { - wprintf("
--- original message ---

"); - pullquote_message(atol(bstr("pullquote"))); + wprintf("
"); + wprintf(_("--- forwarded message ---")); + wprintf("

"); + pullquote_message(atol(bstr("pullquote")), 1); } wprintf("', '96%%', '200', true, false); \n" "
\n"); diff --git a/webcit/webcit.c b/webcit/webcit.c index 04ed98102..cf184f1b9 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -640,6 +640,7 @@ void output_mimepart() /* + * Read any MIME part of a message, from the server, into memory. */ char *load_mimepart(long msgnum, char *partnum) { -- 2.39.2