Changeset 89ab5c8 for message.c


Ignore:
Timestamp:
May 23, 2010, 12:47:20 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
7cc1092
Parents:
aa0a0b5 (diff), ecaec21 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge remote branch 'origin/narrow-cc'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • message.c

    rc314f39 r89ab5c8  
    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.