Changeset e5da3fe


Ignore:
Timestamp:
Mar 24, 2011, 4:24:25 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
a5b5d00
Parents:
283ff1e
git-author:
DD Liu <liudi@mit.edu> (11/06/10 22:35:54)
git-committer:
David Benjamin <davidben@mit.edu> (03/24/11 16:24:25)
Message:
Create per-recipient copies of outgoing messages for non-CC'd personals

Fixes bug #63.

[davidben@mit.edu: Fix up comment, rebase to master]
[davidben@mit.edu: Address nitpicks]
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rc809f5e re5da3fe  
    250250}
    251251
    252 /* Create an outgoing zephyr message and return a pointer to it.  Does
    253  * not put it on the global queue, use owl_global_messagequeue_addmsg() for
    254  * that.
     252/* Queues outgoing zephyrs; if z sends to n people, queue n messages
     253 * (except in case of cc). If there are no recipients queues 1
     254 * message.
    255255 */
    256 owl_message *owl_function_make_outgoing_zephyr(const owl_zwrite *z)
    257 {
    258   owl_message *m;
    259 
    260   /* create the message */
    261   m=g_new(owl_message, 1);
    262   owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z));
    263 
    264   return(m);
     256void owl_function_add_outgoing_zephyrs(const owl_zwrite *z)
     257{
     258  if (z->cc || owl_zwrite_get_numrecips(z) == 0) {
     259    /* create the message */
     260    owl_message *m = g_new(owl_message, 1);
     261    owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), 0);
     262
     263    owl_global_messagequeue_addmsg(&g, m);
     264  } else {
     265    int i;
     266    for (i = 0; i < owl_zwrite_get_numrecips(z); i++) {
     267      /* create the message */
     268      owl_message *m = g_new(owl_message, 1);
     269      owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), i);
     270
     271      owl_global_messagequeue_addmsg(&g, m);
     272    }
     273  }
    265274}
    266275
     
    268277 * message or NULL if we're not logged into AIM (and thus unable to
    269278 * create the message).  Does not put it on the global queue.  Use
    270  * owl_global_messagequeue_addmsg() for that .
     279 * owl_global_messagequeue_addmsg() for that.
    271280 */
    272281owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
     
    378387}
    379388
    380 /* send, log and display an outgoing zephyr.  If 'msg' is NULL
    381  * the message is expected to be set from the zwrite line itself
     389/* send, log and display outgoing zephyrs.  If 'msg' is NULL the
     390 * message is expected to be set from the zwrite line itself
    382391 */
    383392#ifdef HAVE_LIBZEPHYR
    384393void owl_function_zwrite(owl_zwrite *z, const char *msg)
    385394{
    386   owl_message *m;
    387395  int ret;
    388396
     
    407415  if (owl_zwrite_is_personal(z)) {
    408416    /* create the outgoing message */
    409     m=owl_function_make_outgoing_zephyr(z);
    410 
    411     if (m) {
    412       owl_global_messagequeue_addmsg(&g, m);
    413     } else {
    414       owl_function_error("Could not create outgoing zephyr message");
    415     }
     417    owl_function_add_outgoing_zephyrs(z);
    416418  }
    417419}
     
    421423#endif
    422424
    423 /* send, log and display an outgoing zcrypt zephyr.  If 'msg' is NULL
     425/* send, log and display outgoing zcrypt zephyrs.  If 'msg' is NULL
    424426 * the message is expected to be set from the zwrite line itself
    425427 */
     
    427429{
    428430  char *cryptmsg;
    429   owl_message *m;
    430431  const char *argv[7];
    431432  char *zcrypt;
     
    469470    /* Create the outgoing message. Restore the un-crypted message for display. */
    470471    owl_zwrite_set_message_raw(z, old_msg);
    471     m=owl_function_make_outgoing_zephyr(z);
    472     if (m) {
    473       owl_global_messagequeue_addmsg(&g, m);
    474     } else {
    475       owl_function_error("Could not create outgoing zephyr message");
    476     }
     472    owl_function_add_outgoing_zephyrs(z);
    477473  }
    478474
  • logging.c

    re3a75ed re5da3fe  
    186186   */
    187187  m = g_new(owl_message, 1);
    188   owl_message_create_from_zwrite(m, zw, text);
     188  /* recip_index = 0 because there can only be one recipient anyway */
     189  owl_message_create_from_zwrite(m, zw, text, 0);
    189190  if (!owl_log_shouldlog_message(m)) {
    190191    owl_message_delete(m);
  • message.c

    rf54b07d re5da3fe  
    958958}
    959959
    960 void owl_message_create_from_zwrite(owl_message *m, const owl_zwrite *z, const char *body)
     960void owl_message_create_from_zwrite(owl_message *m, const owl_zwrite *z, const char *body, int recip_index)
    961961{
    962962  char *replyline;
     
    970970  owl_message_set_class(m, owl_zwrite_get_class(z));
    971971  owl_message_set_instance(m, owl_zwrite_get_instance(z));
    972   if (owl_zwrite_get_numrecips(z)>0) {
    973     char *longzuser = long_zuser(owl_zwrite_get_recip_n(z, 0));
    974     owl_message_set_recipient(m,
    975                               longzuser); /* only gets the first user, must fix */
     972  if (recip_index < owl_zwrite_get_numrecips(z)) {
     973    char *longzuser = long_zuser(owl_zwrite_get_recip_n(z, recip_index));
     974    owl_message_set_recipient(m, longzuser);
    976975    g_free(longzuser);
    977976  }
  • zephyr.c

    r7d969f3 re5da3fe  
    851851#ifdef HAVE_LIBZEPHYR
    852852  char *tmpbuff, *myuser, *to;
    853   owl_message *mout;
    854853  owl_zwrite *z;
    855854 
     
    898897
    899898  /* display the message as an admin message in the receive window */
    900   mout=owl_function_make_outgoing_zephyr(z);
    901   owl_global_messagequeue_addmsg(&g, mout);
     899  owl_function_add_outgoing_zephyrs(z);
    902900  owl_zwrite_delete(z);
    903901#endif
Note: See TracChangeset for help on using the changeset viewer.