Sorry, the patch I posted was the wrong one; I forgot to "stg refresh" some rework before git format-patch.
Please consider this patch before I write the resume-from-drafts code. Sam
From 8dbc0708b926f0747b73691d85c069a42d173dba Mon Sep 17 00:00:00 2001 From: Sam Liddicott <s...@liddicott.com> Date: Wed, 10 Jun 2009 21:08:46 +0100 Subject: [PATCH] Add save to drafts to edit mode MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1.5.4.3" This is a multi-part message in MIME format. --------------1.5.4.3 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Recipients are saved in To, Cc, Bcc headers (if any), otherwise the post-room is saved in X-Citadel-Room These will need examining in the next patch to follow were we resume from Drafts folder. We probably need a psuedo folder _DRAFTS_ Signed-off-by: Sam Liddicott <s...@liddicott.com> --- webcit/messages.c | 43 +++++++++++++++++++++++++++++++++--- webcit/static/t/edit_message.html | 2 + 2 files changed, 41 insertions(+), 4 deletions(-) --------------1.5.4.3 Content-Type: text/x-patch; name="8dbc0708b926f0747b73691d85c069a42d173dba.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="8dbc0708b926f0747b73691d85c069a42d173dba.diff" diff --git a/webcit/messages.c b/webcit/messages.c index da9797e..9a7be07 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -1356,6 +1356,7 @@ void post_message(void) const StrBuf *my_email_addr = NULL; StrBuf *CmdBuf = NULL; StrBuf *references = NULL; + int save_to_drafts = havebstr("save_button"); if (havebstr("references")) { @@ -1382,6 +1383,20 @@ void post_message(void) Wikipage = sbstr("wikipage"); my_email_addr = sbstr("my_email_addr"); + if (save_to_drafts) { + /** temp move to the new room */ + /* I guess we need a _DRAFTS_ */ + serv_printf("GOTO %s", "Drafts"); + serv_getln(buf, sizeof buf); + if (buf[0] != '2') { + /* You probably don't even have a dumb Drafts folder */ + lprintf(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, buf); + sprintf(WC->ImportantMessage, "%s %s", _("Saved to Drafts failed"), &buf[4]); + display_enter(); + return; + } + } + CmdBuf = NewStrBufPlain(NULL, sizeof (CMD) + StrLength(Recp) + @@ -1394,12 +1409,12 @@ void post_message(void) StrBufPrintf(CmdBuf, CMD, - ChrPtr(Recp), + save_to_drafts?"":ChrPtr(Recp), is_anonymous, ChrPtr(encoded_subject), ChrPtr(display_name), - ChrPtr(Cc), - ChrPtr(Bcc), + save_to_drafts?"":ChrPtr(Cc), + save_to_drafts?"":ChrPtr(Bcc), ChrPtr(Wikipage), ChrPtr(my_email_addr), ChrPtr(references)); @@ -1411,8 +1426,25 @@ void post_message(void) FreeStrBuf(&CmdBuf); FreeStrBuf(&encoded_subject); if (buf[0] == '4') { + if (save_to_drafts) { + if ( (havebstr("recp")) + || (havebstr("cc" )) + || (havebstr("bcc" )) ) { + /* save recipient headers or room to post to */ + serv_printf("To: %s", ChrPtr(Recp)); + serv_printf("Cc: %s", ChrPtr(Cc)); + serv_printf("Bcc: %s", ChrPtr(Bcc)); + } else { + serv_printf("X-Citadel-Room: %s", ChrPtr(WC->wc_roomname)); + } + } post_mime_to_server(); - if ( (havebstr("recp")) + if (save_to_drafts) { + sprintf(WCC->ImportantMessage, _("Message has been saved to Drafts.\n")); + gotoroom(WC->wc_roomname); + display_enter(); + return; + } else if ( (havebstr("recp")) || (havebstr("cc" )) || (havebstr("bcc" )) ) { @@ -1425,6 +1457,9 @@ void post_message(void) } else { lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf); sprintf(WC->ImportantMessage, "%s", &buf[4]); + if (save_to_drafts) { + gotoroom(WC->wc_roomname); + } display_enter(); return; } diff --git a/webcit/static/t/edit_message.html b/webcit/static/t/edit_message.html index 201fc7d..f954263 100644 --- a/webcit/static/t/edit_message.html +++ b/webcit/static/t/edit_message.html @@ -10,6 +10,8 @@ <input type="hidden" name="references" value="<?BSTR("references")>"> <p class="send_edit_msg"> + <input type="submit" name="save_button" value="<?_("Save to Drafts")>"> + <?!("COND:SUBST", 1, "RCPTREQUIRED")><input type="submit" name="send_button" value="<?_("Send message")>"><?!("X", 1)> <??("COND:SUBST", 2, "RCPTREQUIRED")><input type="submit" name="send_button" value="<?_("Post message")>"><?!("X", 2)> --------------1.5.4.3--