Changes in / [89ab5c8:aa0a0b5]


Ignore:
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r2cfc6d7 r2cfc6d7  
    25012501}
    25022502
    2503 static 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 
    25312503/* Create a filter based on the current message.  Returns the name of
    25322504 * a filter or null.  The caller must free this name.
     
    25822554  if (owl_message_is_type_zephyr(m)) {
    25832555    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 
    25882556      if (owl_message_is_direction_in(m)) {
    25892557        zperson=short_zuser(owl_message_get_sender(m));
  • logging.c

    r839697d r91634ec  
    128128  char filename[MAXPATHLEN], *logpath;
    129129  char *to, *temp;
    130   GList *cc;
    131130
    132131  /* expand ~ in path names */
     
    136135  if (owl_message_is_type_zephyr(m)) {
    137136    /* If this has CC's, do all but the "recipient" which we'll do below */
    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 
     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    }
    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 *temp;
    328     GList *cc;
     327    char *cc, *temp;
    329328    cc = owl_message_get_cc_without_recipient(m);
    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);
     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, " ");
    335338      }
    336 
    337       owl_free(cc->data);
    338       cc = g_list_delete_link(cc, cc);
     339      owl_free(cc);
    339340    }
    340341  }
  • message.c

    rc314f39 rc314f39  
    593593
    594594/* caller must free return value */
    595 GList *owl_message_get_cc_without_recipient(const owl_message *m)
    596 {
    597   char *cc, *shortuser, *recip;
     595char *owl_message_get_cc_without_recipient(const owl_message *m)
     596{
     597  char *cc, *out, *end, *shortuser, *recip;
    598598  const char *user;
    599   GList *out = NULL;
    600599
    601600  cc = owl_message_get_cc(m);
     
    604603
    605604  recip = short_zuser(owl_message_get_recipient(m));
     605  out = owl_malloc(strlen(cc) + 2);
     606  end = out;
    606607
    607608  user = strtok(cc, " ");
     
    609610    shortuser = short_zuser(user);
    610611    if (strcasecmp(shortuser, recip) != 0) {
    611       out = g_list_prepend(out, owl_strdup(user));
     612      strcpy(end, user);
     613      end[strlen(user)] = ' ';
     614      end += strlen(user) + 1;
    612615    }
    613616    owl_free(shortuser);
    614617    user = strtok(NULL, " ");
    615618  }
     619  end[0] = '\0';
    616620
    617621  owl_free(recip);
    618622  owl_free(cc);
     623
     624  if (strlen(out) == 0) {
     625    owl_free(out);
     626    out = NULL;
     627  }
    619628
    620629  return(out);
     
    732741  owl_message_set_recipient(m, "looprecip");
    733742  owl_message_set_isprivate(m);
    734 }
    735 
    736 void 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   }
    769743}
    770744
     
    904878    }
    905879  }
    906 
    907   owl_message_save_ccs(m);
    908880}
    909881#else
     
    1000972    owl_message_set_isprivate(m);
    1001973  }
    1002 
    1003   owl_message_save_ccs(m);
    1004974}
    1005975
Note: See TracChangeset for help on using the changeset viewer.