Changeset 66e409c for functions.c
- Timestamp:
- Apr 2, 2010, 10:40:39 PM (14 years ago)
- Branches:
- master, release-1.10, 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r9186c75 r66e409c 2280 2280 * instance is NULL then catch all messgaes in the class. Returns the 2281 2281 * name of the filter, which the caller must free. 2282 * If 'related' is nonzero, encompass unclasses and .d classes as well. 2282 2283 */ 2283 char *owl_function_classinstfilt(const char *c, const char *i )2284 char *owl_function_classinstfilt(const char *c, const char *i, int related) 2284 2285 { 2285 2286 owl_filter *f; … … 2288 2289 char *class, *instance = NULL; 2289 2290 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 } 2293 2301 } 2294 2302 2295 2303 /* name for the filter */ 2296 2304 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); 2300 2308 } 2301 2309 /* downcase it */ … … 2329 2337 } 2330 2338 2331 argbuff = owl_sprintf( "class ^(un)*%s(\\.d)*$", tmpclass);2339 argbuff = owl_sprintf(related ? "class ^(un)*%s(\\.d)*$" : "class ^%s$", tmpclass); 2332 2340 if (tmpinstance) { 2333 2341 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); 2335 2343 owl_free(tmp); 2336 2344 } … … 2508 2516 const owl_message *m; 2509 2517 char *zperson, *filtname=NULL; 2510 const char *argv[1]; 2518 const char *argv[2]; 2519 int related = owl_global_is_narrow_related(&g); 2511 2520 2512 2521 v=owl_global_get_current_view(&g); … … 2553 2562 /* narrow class MESSAGE, instance foo, recip * messages to class, inst */ 2554 2563 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); 2556 2565 return(filtname); 2557 2566 } … … 2559 2568 /* otherwise narrow to the class */ 2560 2569 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); 2562 2571 } 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); 2564 2573 } 2565 2574 return(filtname); … … 2567 2576 2568 2577 /* 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); 2573 2581 } 2574 2582
Note: See TracChangeset
for help on using the changeset viewer.