[2969] in BarnOwl Developers

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

[PATCH 2/2] In duplicated outgoing zephyrs only reply on the relevant recipient

daemon@ATHENA.MIT.EDU (David Benjamin)
Fri Mar 11 18:21:00 2011

From: David Benjamin <davidben@MIT.EDU>
To: barnowl-dev@mit.edu
Date: Fri, 11 Mar 2011 18:20:53 -0500
In-Reply-To: <1299885653-22467-1-git-send-email-davidben@mit.edu>

Fixes the other half of bug #63.
---
 message.c |    2 +-
 zwrite.c  |   15 +++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/message.c b/message.c
index 0acedac..140cdcc 100644
--- a/message.c
+++ b/message.c
@@ -979,7 +979,7 @@ void owl_message_create_from_zwrite(owl_message *m, const owl_zwrite *z, const c
 
   /* Although not strictly the zwriteline, anyone using the unsantized version
    * of it probably has a bug. */
-  replyline = owl_zwrite_get_replyline(z);
+  replyline = owl_zwrite_get_replyline(z, recip_index);
   owl_message_set_zwriteline(m, replyline);
   g_free(replyline);
 
diff --git a/zwrite.c b/zwrite.c
index 852e2df..08c4b4a 100644
--- a/zwrite.c
+++ b/zwrite.c
@@ -381,8 +381,10 @@ void owl_zwrite_cleanup(owl_zwrite *z)
  * Returns a zwrite line suitable for replying, specifically the
  * message field is stripped out. Result should be freed with
  * g_free.
+ *
+ * If not a CC, only the recip_index'th user will be replied to.
  */
-char *owl_zwrite_get_replyline(const owl_zwrite *z)
+char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
 {
   /* Match ordering in zwrite help. */
   GString *buf = g_string_new("");
@@ -414,9 +416,14 @@ char *owl_zwrite_get_replyline(const owl_zwrite *z)
     g_string_append(buf, " -O ");
     owl_string_append_quoted_arg(buf, z->opcode);
   }
-  for (i = 0; i < owl_list_get_size(&(z->recips)); i++) {
-    g_string_append_c(buf, ' ');
-    owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), i));
+  if (z->cc) {
+    for (i = 0; i < owl_list_get_size(&(z->recips)); i++) {
+      g_string_append_c(buf, ' ');
+      owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), i));
+    }
+  } else if (recip_index < owl_list_get_size(&(z->recips))) {
+      g_string_append_c(buf, ' ');
+      owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), recip_index));
   }
 
   return g_string_free(buf, false);
-- 
1.7.3.3.399.g06ddf


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