[75] in bug-owl

home help back first fref pref prev next nref lref last post

reply to zaway

daemon@ATHENA.MIT.EDU (Jeremy Daniel)
Sat Aug 24 01:10:26 2002

To: bug-owl@MIT.EDU
From: Jeremy Daniel <jdaniel@MIT.EDU>
Date: 24 Aug 2002 01:10:24 -0400
Message-ID: <skek7mg970f.fsf@multics.mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii

This patch sets the zwriteline for outgoing zaway messages so they can
be replied to like normal outgoing messages.  The main bulk of the
patch comes from moving the functionality of composing a zwriteline
out of functions.c where it was in the middle owl_function_reply() and
into a separate procedure which I called owl_message_make_zwriteline()
in message.c.  I'm not sure if this is exactly the right place for it,
but this allows it to be used from both places which is a definite
win.  Suggestions are welcome if you don't like it as is.

/mit/jdaniel/project/owl/build-cvs/patches/zaway_reply.patch
----------
Index: functions.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/functions.c,v
retrieving revision 1.21
diff -u -r1.21 functions.c
--- functions.c	2002/08/17 22:04:36	1.21
+++ functions.c	2002/08/24 04:33:44
@@ -1480,15 +1480,13 @@
    * if enter = 0 then allow the command to be edited
    * if enter = 1 then don't wait for editing
    */
-  char *buff, *oldbuff;
+  char *buff;
   owl_message *m;
   owl_filter *f;
   
   if (owl_view_get_size(owl_global_get_current_view(&g))==0) {
     owl_function_makemsg("No message selected");
   } else {
-    char *class, *inst, *to, *cc=NULL;
-    
     m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g));
     if (!m) {
       owl_function_makemsg("No message selected");
@@ -1513,54 +1511,7 @@
 	owl_function_makemsg("You cannot reply to this admin message");
       }
     } else {
-      if (owl_message_is_login(m)) {
-	class="MESSAGE";
-	inst="PERSONAL";
-	to=owl_message_get_sender(m);
-      } else if (type==1) {
-	class="MESSAGE";
-	inst="PERSONAL";
-	to=owl_message_get_sender(m);
-      } else {
-	class=owl_message_get_class(m);
-	inst=owl_message_get_instance(m);
-	to=owl_message_get_recipient(m);
-	cc=owl_message_get_cc(m);
-	if (!strcmp(to, "") || !strcmp(to, "*")) {
-	  to="";
-	} else if (to[0]=='@') {
-	  /* leave it, to get the realm */
-	} else {
-	  to=owl_message_get_sender(m);
-	}
-      }
-      
-      /* create the command line */
-      buff = owl_strdup("zwrite");
-      if (strcasecmp(class, "message")) {
-	buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));
-	owl_free(oldbuff);
-      }
-      if (strcasecmp(inst, "personal")) {
-	buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));
-	owl_free(oldbuff);
-      }
-      if (*to != '\0') {
-	char *tmp, *oldtmp;
-	tmp=pretty_sender(to);
-	if (cc) {
-	  tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
-	  owl_free(oldtmp);
-	  buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);
-	  owl_free(oldbuff);
-	} else {
-	  tmp=pretty_sender(to);
-	  buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
-	  owl_free(oldbuff);
-	}
-	owl_free(tmp);
-      }
-      if (cc) owl_free(cc);
+      buff = owl_message_make_zwriteline(m, type);
 
       if (enter) {
 	owl_history *hist = owl_global_get_cmd_history(&g);
Index: message.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/message.c,v
retrieving revision 1.4
diff -u -r1.4 message.c
--- message.c	2002/08/17 14:31:35	1.4
+++ message.c	2002/08/24 04:39:09
@@ -417,6 +417,64 @@
   return(m->zwriteline);
 }
 
+char *owl_message_make_zwriteline(owl_message *m, int type) {
+  /* if type = 0 then normal reply.
+   * if type = 1 then it's a reply to sender
+   */
+  char *buff, *oldbuff;
+  char *class, *inst, *to, *cc=NULL;
+
+  if (owl_message_is_login(m)) {
+    class="MESSAGE";
+    inst="PERSONAL";
+    to=owl_message_get_sender(m);
+  } else if (type==1) {
+    class="MESSAGE";
+    inst="PERSONAL";
+    to=owl_message_get_sender(m);;
+  } else {
+    class=owl_message_get_class(m);
+    inst=owl_message_get_instance(m);
+    to=owl_message_get_recipient(m);
+    cc=owl_message_get_cc(m);
+    if (!strcmp(to, "") || !strcmp(to, "*")) {
+      to="";
+    } else if (to[0]=='@') {
+      /* leave it, to get the realm */
+    } else {
+      to=owl_message_get_sender(m);
+    }
+  }
+  
+  /* create the command line */
+  buff = owl_strdup("zwrite");
+  if (strcasecmp(class, "message")) {
+    buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));
+    owl_free(oldbuff);
+  }
+  if (strcasecmp(inst, "personal")) {
+    buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));
+    owl_free(oldbuff);
+  }
+  if (*to != '\0') {
+    char *tmp, *oldtmp;
+    tmp=pretty_sender(to);
+    if (cc) {
+      tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
+      owl_free(oldtmp);
+      buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);
+      owl_free(oldbuff);
+    } else {
+      tmp=pretty_sender(to);
+      buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
+      owl_free(oldbuff);
+    }
+    owl_free(tmp);
+  }
+  if (cc) owl_free(cc);
+  return(buff);
+}
+
 int owl_message_is_delete(owl_message *m) {
   if (m == NULL) return(0);
   if (m->delete==1) return(1);
Index: zephyr.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/zephyr.c,v
retrieving revision 1.3
diff -u -r1.3 zephyr.c
--- zephyr.c	2002/06/30 20:58:16	1.3
+++ zephyr.c	2002/08/24 04:52:52
@@ -408,8 +408,8 @@
 	      owl_global_get_zaway_msg(&g));
 
   /* display the message as an admin message in the receive window */
-  tmpbuff = owl_sprintf("Message sent to %s", owl_message_get_sender(m));
-  owl_function_adminmsg(tmpbuff, owl_global_get_zaway_msg(&g));
+  tmpbuff = owl_sprintf("Message sent to %s", pretty_sender(owl_message_get_sender(m)));
+  owl_function_adminmsg_outgoing(tmpbuff, owl_global_get_zaway_msg(&g), owl_message_make_zwriteline(m,0));
   owl_free(tmpbuff);
 }
 



-- 


				Jer


------------------------------------------------------------------
Tulgey Wood - tulgeywood@attbi.com     Cell Phone: 617-429-8573 / 
4 Farragut Ave (617-629-3983)             jdaniel-phone@mit.edu
Somerville, MA 02144-1709              AIM: jdanielmit      
                                    
Zephyr athena users over the web:  http://webzephyr.mit.edu/

home help back first fref pref prev next nref lref last post