>  Thu Jun 11 2009 04:35:46 PM EDT from   samjam @ Uncensored  Subject:
>save-to-drafts better patch
>
>    
>
>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  
>
>
>
>  

  

Is this fragment better for deciding if it is a room-post or an email that is
being saved?  

if (save_to_drafts) {
 int recipient_required = 0;
 /** First test to see whether this is a room that requires recipients to be
entered */
 serv_puts("ENT0 0");
 serv_getln(buf, sizeof buf);
 if (!strncmp(buf, "570", 3)) {          /** 570 means that we need
a recipient here */
 recipient_required = 1;
 }

 /* 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));
 if (! recipient_required) {
 serv_printf("X-Citadel-Room: %s", ChrPtr(WC->wc_roomname));
 }
 }
  

On resume, if X-Citadel-Room is set, then we'll do a gotoroom and carry on
from there. Is it possible to post to the current room AND email users? If
not, then if X-Citadel-Room is set AND Bcc, Cc or To then I'll presume the
message has been edited outside of citadel and ignore X-Citadel-Room.  

I'll convert the saved message for editing in a similar way to Forward,
saving none of the message headers and only extracting To, Cc, Bcc,
References and Subject.  

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")>">
+&nbsp;
 <?!("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)>
 &nbsp;

--------------1.5.4.3--


Reply via email to