Changeset 66e409c for functions.c


Ignore:
Timestamp:
Apr 2, 2010, 10:40:39 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.6, release-1.7, release-1.8, release-1.9
Children:
8a5b5a1
Parents:
0fe69d2
git-author:
Geoffrey Thomas <geofft@mit.edu> (12/27/08 09:32:18)
git-committer:
Nelson Elhage <nelhage@mit.edu> (04/02/10 22:40:39)
Message:
Add the "narrow-related" variable.

This controls whether narrowing to a class includes variant class
names as well.

Signed-off-by: Geoffrey Thomas <geofft@mit.edu>
[nelhage@mit.edu: Change variable name from 'modnarrow']
Signed-off-by: Nelson Elhage <nelhage@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r9186c75 r66e409c  
    22802280 * instance is NULL then catch all messgaes in the class.  Returns the
    22812281 * name of the filter, which the caller must free.
     2282 * If 'related' is nonzero, encompass unclasses and .d classes as well.
    22822283 */
    2283 char *owl_function_classinstfilt(const char *c, const char *i)
     2284char *owl_function_classinstfilt(const char *c, const char *i, int related)
    22842285{
    22852286  owl_filter *f;
     
    22882289  char *class, *instance = NULL;
    22892290
    2290   class = owl_util_baseclass(c);
    2291   if(i) {
    2292     instance = owl_util_baseclass(i);
     2291  if (related) {
     2292    class = owl_util_baseclass(c);
     2293    if (i) {
     2294      instance = owl_util_baseclass(i);
     2295    }
     2296  } else {
     2297    class = owl_strdup(c);
     2298    if (i) {
     2299      instance = owl_strdup(i);
     2300    }
    22932301  }
    22942302
    22952303  /* name for the filter */
    22962304  if (!instance) {
    2297     filtname = owl_sprintf("class-%s", class);
    2298   } else {
    2299     filtname = owl_sprintf("class-%s-instance-%s", class, instance);
     2305    filtname = owl_sprintf("%sclass-%s", related ? "related-" : "", class);
     2306  } else {
     2307    filtname = owl_sprintf("%sclass-%s-instance-%s", related ? "related-" : "", class, instance);
    23002308  }
    23012309  /* downcase it */
     
    23292337  }
    23302338
    2331   argbuff = owl_sprintf("class ^(un)*%s(\\.d)*$", tmpclass);
     2339  argbuff = owl_sprintf(related ? "class ^(un)*%s(\\.d)*$" : "class ^%s$", tmpclass);
    23322340  if (tmpinstance) {
    23332341    char *tmp = argbuff;
    2334     argbuff = owl_sprintf("%s and ( instance ^(un)*%s(\\.d)*$ )", tmp, tmpinstance);
     2342    argbuff = owl_sprintf(related ? "%s and ( instance ^(un)*%s(\\.d)*$ )" : "%s and instance ^%s$", tmp, tmpinstance);
    23352343    owl_free(tmp);
    23362344  }
     
    25082516  const owl_message *m;
    25092517  char *zperson, *filtname=NULL;
    2510   const char *argv[1];
     2518  const char *argv[2];
     2519  int related = owl_global_is_narrow_related(&g);
    25112520 
    25122521  v=owl_global_get_current_view(&g);
     
    25532562    /* narrow class MESSAGE, instance foo, recip * messages to class, inst */
    25542563    if (!strcasecmp(owl_message_get_class(m), "message")) {
    2555       filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
     2564      filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m), related);
    25562565      return(filtname);
    25572566    }
     
    25592568    /* otherwise narrow to the class */
    25602569    if (type==0) {
    2561       filtname=owl_function_classinstfilt(owl_message_get_class(m), NULL);
     2570      filtname=owl_function_classinstfilt(owl_message_get_class(m), NULL, related);
    25622571    } else if (type==1) {
    2563       filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m));
     2572      filtname=owl_function_classinstfilt(owl_message_get_class(m), owl_message_get_instance(m), related);
    25642573    }
    25652574    return(filtname);
     
    25672576
    25682577  /* pass it off to perl */
    2569   if(type) {
    2570     argv[0] = "-i";
    2571   };
    2572   return owl_perlconfig_message_call_method(m, "smartfilter", type ? 1 : 0, argv);
     2578  argv[0] = type ? "1" : "0";
     2579  argv[1] = related ? "1" : "0";
     2580  return owl_perlconfig_message_call_method(m, "smartfilter", 2, argv);
    25732581}
    25742582
Note: See TracChangeset for help on using the changeset viewer.