Changes in / [aa0a0b5:89ab5c8]


Ignore:
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r2cfc6d7 r2cfc6d7  
    25012501}
    25022502
     2503static char *owl_function_smartfilter_cc(const owl_message *m) {
     2504  const char *ccs;
     2505  char *filtname;
     2506  char *text;
     2507  owl_filter *f;
     2508
     2509  ccs = owl_message_get_attribute_value(m, "zephyr_ccs");
     2510
     2511  filtname = owl_sprintf("conversation-%s", ccs);
     2512  owl_text_tr(filtname, ' ', '-');
     2513
     2514  if (owl_global_get_filter(&g, filtname)) {
     2515    return filtname;
     2516  }
     2517
     2518  text = owl_sprintf("type ^zephyr$ and filter personal and "
     2519                     "zephyr_ccs ^%s%s%s$",
     2520                     owl_getquoting(ccs), ccs, owl_getquoting(ccs));
     2521
     2522  f = owl_filter_new_fromstring(filtname, text);
     2523
     2524  owl_global_add_filter(&g, f);
     2525
     2526  owl_free(text);
     2527
     2528  return filtname;
     2529}
     2530
    25032531/* Create a filter based on the current message.  Returns the name of
    25042532 * a filter or null.  The caller must free this name.
     
    25542582  if (owl_message_is_type_zephyr(m)) {
    25552583    if (owl_message_is_personal(m) || owl_message_is_loginout(m)) {
     2584      if (owl_message_get_attribute_value(m, "zephyr_ccs") != NULL) {
     2585        return owl_function_smartfilter_cc(m);
     2586      }
     2587
    25562588      if (owl_message_is_direction_in(m)) {
    25572589        zperson=short_zuser(owl_message_get_sender(m));
  • logging.c

    r91634ec r839697d  
    128128  char filename[MAXPATHLEN], *logpath;
    129129  char *to, *temp;
     130  GList *cc;
    130131
    131132  /* expand ~ in path names */
     
    135136  if (owl_message_is_type_zephyr(m)) {
    136137    /* If this has CC's, do all but the "recipient" which we'll do below */
    137     to = owl_message_get_cc_without_recipient(m);
    138     if (to != NULL) {
    139       temp = strtok(to, " ");
    140       while (temp != NULL) {
    141           temp = short_zuser(temp);
    142           snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
    143           owl_log_append(m, filename);
    144           temp = strtok(NULL, " ");
    145       }
    146       owl_free(to);
    147     }
     138    cc = owl_message_get_cc_without_recipient(m);
     139    while (cc != NULL) {
     140      temp = short_zuser(cc->data);
     141      snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
     142      owl_log_append(m, filename);
     143
     144      owl_free(cc->data);
     145      cc = g_list_delete_link(cc, cc);
     146    }
     147
    148148    to = short_zuser(owl_message_get_recipient(m));
    149149  } else if (owl_message_is_type_jabber(m)) {
     
    325325     * the sender, as well.
    326326     */
    327     char *cc, *temp;
     327    char *temp;
     328    GList *cc;
    328329    cc = owl_message_get_cc_without_recipient(m);
    329     if (cc != NULL) {
    330       temp = strtok(cc, " ");
    331       while (temp != NULL) {
    332         temp = short_zuser(temp);
    333         if (strcasecmp(temp, frombuff) != 0) {
    334           snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
    335           owl_log_append(m, filename);
    336         }
    337         temp = strtok(NULL, " ");
     330    while (cc != NULL) {
     331      temp = short_zuser(cc->data);
     332      if (strcasecmp(temp, frombuff) != 0) {
     333        snprintf(filename, MAXPATHLEN, "%s/%s", logpath, temp);
     334        owl_log_append(m, filename);
    338335      }
    339       owl_free(cc);
     336
     337      owl_free(cc->data);
     338      cc = g_list_delete_link(cc, cc);
    340339    }
    341340  }
  • message.c

    rc314f39 rc314f39  
    593593
    594594/* caller must free return value */
    595 char *owl_message_get_cc_without_recipient(const owl_message *m)
    596 {
    597   char *cc, *out, *end, *shortuser, *recip;
     595GList *owl_message_get_cc_without_recipient(const owl_message *m)
     596{
     597  char *cc, *shortuser, *recip;
    598598  const char *user;
     599  GList *out = NULL;
    599600
    600601  cc = owl_message_get_cc(m);
     
    603604
    604605  recip = short_zuser(owl_message_get_recipient(m));
    605   out = owl_malloc(strlen(cc) + 2);
    606   end = out;
    607606
    608607  user = strtok(cc, " ");
     
    610609    shortuser = short_zuser(user);
    611610    if (strcasecmp(shortuser, recip) != 0) {
    612       strcpy(end, user);
    613       end[strlen(user)] = ' ';
    614       end += strlen(user) + 1;
     611      out = g_list_prepend(out, owl_strdup(user));
    615612    }
    616613    owl_free(shortuser);
    617614    user = strtok(NULL, " ");
    618615  }
    619   end[0] = '\0';
    620616
    621617  owl_free(recip);
    622618  owl_free(cc);
    623 
    624   if (strlen(out) == 0) {
    625     owl_free(out);
    626     out = NULL;
    627   }
    628619
    629620  return(out);
     
    741732  owl_message_set_recipient(m, "looprecip");
    742733  owl_message_set_isprivate(m);
     734}
     735
     736void owl_message_save_ccs(owl_message *m) {
     737  GList *cc;
     738  char *tmp;
     739
     740  cc = owl_message_get_cc_without_recipient(m);
     741
     742  if (cc != NULL) {
     743    GString *recips = g_string_new("");
     744    cc = g_list_prepend(cc, short_zuser(owl_message_get_sender(m)));
     745    cc = g_list_prepend(cc, short_zuser(owl_message_get_recipient(m)));
     746    cc = g_list_sort(cc, (GCompareFunc)strcasecmp);
     747
     748    while(cc != NULL) {
     749      /* Collapse any identical entries */
     750      while (cc->next && strcasecmp(cc->data, cc->next->data) == 0) {
     751        owl_free(cc->data);
     752        cc = g_list_delete_link(cc, cc);
     753      }
     754
     755      tmp = short_zuser(cc->data);
     756      g_string_append(recips, tmp);
     757
     758      owl_free(tmp);
     759      owl_free(cc->data);
     760      cc = g_list_delete_link(cc, cc);
     761
     762      if (cc)
     763        g_string_append_c(recips, ' ');
     764    }
     765
     766    owl_message_set_attribute(m, "zephyr_ccs", recips->str);
     767    g_string_free(recips, true);
     768  }
    743769}
    744770
     
    878904    }
    879905  }
     906
     907  owl_message_save_ccs(m);
    880908}
    881909#else
     
    9721000    owl_message_set_isprivate(m);
    9731001  }
     1002
     1003  owl_message_save_ccs(m);
    9741004}
    9751005
Note: See TracChangeset for help on using the changeset viewer.