* src/matcher_parser_parse.y
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Fri, 2 Apr 2004 22:56:58 +0000 (22:56 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Fri, 2 Apr 2004 22:56:58 +0000 (22:56 +0000)
  src/matcher.[ch]
  prepare address look up matcher type; marginally
  tested, and not hooked into the UI yet.

  basically it accepts the result of the left hand
  side of the matcher (the "criteria"):

  from all_in_addressbook ""
  ~to_or_cc any_in_addressbook ""

  the first case matches all addresses found in the
  from header, and the second case matches if any
  (at least one) of the addresses in to or cc headers
  are not in the address book.

  the string argument is not used yet, but is intended
  to match a group of addresses

ChangeLog.claws
configure.ac
src/matcher.c
src/matcher.h
src/matcher_parser_parse.y

index 076dc53b9ed455b4382d6e58c54922bbcd2916c1..a1f8b860bf7ff1b9d22f81970fd3dff24f38a740 100644 (file)
@@ -1,3 +1,24 @@
+2004-04-03 [alfons]    0.9.10claws38
+
+       * src/matcher_parser_parse.y
+         src/matcher.[ch]
+               prepare address look up matcher type; marginally
+               tested, and not hooked into the UI yet.
+
+               basically it accepts the result of the left hand
+               side of the matcher (the "criteria"):
+
+                       from all_in_addressbook ""
+                       ~to_or_cc any_in_addressbook ""
+               
+               the first case matches all addresses found in the
+               from header, and the second case matches if any
+               (at least one) of the addresses in to or cc headers 
+               are not in the address book.
+
+               the string argument is not used yet, but is intended
+               to match a group of addresses 
+
 2004-04-02 [luke]      0.9.10claws37
 
        * src/prefs_folder_item.c
 2004-04-02 [luke]      0.9.10claws37
 
        * src/prefs_folder_item.c
index bba0c810ed920d265d856991a032ee4e55820efd..c7691e81ea38bb84beedd43ad1ad765bc34904a0 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=37
+EXTRA_VERSION=38
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index d7313e01d38550dce0cde31b332e91bbbef882e0..9edb7d2d2685ff402303c20b11f40fca3f77d248 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2002 by the Sylpheed Claws Team and Hiroyuki Yamamoto
+ * Copyright (C) 2002-2004 by the Sylpheed Claws Team and Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
 #include "intl.h"
 #include "matcher_parser.h"
 #include "prefs_gtk.h"
 #include "intl.h"
 #include "matcher_parser.h"
 #include "prefs_gtk.h"
+#include "addr_compl.h"
 #include <ctype.h>
 
 /*!
 #include <ctype.h>
 
 /*!
@@ -109,6 +110,8 @@ static const MatchParser matchparser_tab[] = {
        {MATCHTYPE_MATCH, "match"},
        {MATCHTYPE_REGEXPCASE, "regexpcase"},
        {MATCHTYPE_REGEXP, "regexp"},
        {MATCHTYPE_MATCH, "match"},
        {MATCHTYPE_REGEXPCASE, "regexpcase"},
        {MATCHTYPE_REGEXP, "regexp"},
+       {MATCHTYPE_ANY_IN_ADDRESSBOOK, "any_in_addressbook"},
+       {MATCHTYPE_ALL_IN_ADDRESSBOOK, "all_in_addressbook"},
 
        /* actions */
        {MATCHACTION_SCORE, "score"},    /* for backward compatibility */
 
        /* actions */
        {MATCHACTION_SCORE, "score"},    /* for backward compatibility */
@@ -262,6 +265,36 @@ MatcherProp *matcherprop_copy(const MatcherProp *src)
 
 /* ************** match ******************************/
 
 
 /* ************** match ******************************/
 
+static gboolean match_with_addresses_in_addressbook
+       (MatcherProp *prop, const gchar *str, gint type)
+{
+       GSList *address_list = NULL;
+       GSList *walk;
+       gboolean res = FALSE;
+
+       if (str == NULL || *str == 0) 
+               return FALSE;
+       
+       /* XXX: perhaps complete with comments too */
+       address_list = address_list_append(address_list, str);
+       if (!address_list) 
+               return FALSE;
+
+       start_address_completion();             
+       res = FALSE;
+       for (walk = address_list; walk != NULL; walk = walk->next) {
+               gboolean found = complete_address(walk->data) ? TRUE : FALSE;
+               if (!found && type == MATCHTYPE_ALL_IN_ADDRESSBOOK) {
+                       res = FALSE;
+                       break;
+               } else if (found) 
+                       res = TRUE;
+       }
+
+       end_address_completion();
+       return res;
+}
+
 /*!
  *\brief       Find out if a string matches a condition
  *
 /*!
  *\brief       Find out if a string matches a condition
  *
@@ -301,6 +334,11 @@ static gboolean matcherprop_string_match(MatcherProp *prop, const gchar *str)
                        return TRUE;
                else
                        return FALSE;
                        return TRUE;
                else
                        return FALSE;
+                       
+       case MATCHTYPE_ALL_IN_ADDRESSBOOK:      
+       case MATCHTYPE_ANY_IN_ADDRESSBOOK:
+               return match_with_addresses_in_addressbook
+                       (prop, str, prop->matchtype);
 
        case MATCHTYPE_MATCH:
                return (strstr(str, prop->expr) != NULL);
 
        case MATCHTYPE_MATCH:
                return (strstr(str, prop->expr) != NULL);
@@ -1077,6 +1115,8 @@ gchar *matcherprop_to_string(MatcherProp *matcher)
        case MATCHTYPE_MATCHCASE:
        case MATCHTYPE_REGEXP:
        case MATCHTYPE_REGEXPCASE:
        case MATCHTYPE_MATCHCASE:
        case MATCHTYPE_REGEXP:
        case MATCHTYPE_REGEXPCASE:
+       case MATCHTYPE_ALL_IN_ADDRESSBOOK:
+       case MATCHTYPE_ANY_IN_ADDRESSBOOK:
                quoted_expr = matcher_quote_str(matcher->expr);
                if (matcher->header) {
                        gchar * quoted_header;
                quoted_expr = matcher_quote_str(matcher->expr);
                if (matcher->header) {
                        gchar * quoted_header;
index 8cfb0cf4f368389a7c6f1ebc54dd7bca6e0304d8..c8d2484b7f197faa02a084b365e78912881ae5d0 100644 (file)
@@ -104,6 +104,8 @@ enum {
        MT_(MATCH),
        MT_(REGEXPCASE),
        MT_(REGEXP),
        MT_(MATCH),
        MT_(REGEXPCASE),
        MT_(REGEXP),
+       MT_(ANY_IN_ADDRESSBOOK),
+       MT_(ALL_IN_ADDRESSBOOK),
        /* actions */
        MA_(SCORE),
        MA_(EXECUTE),
        /* actions */
        MA_(SCORE),
        MA_(EXECUTE),
index a376763ca6d8d7559b2d3342d4df232bb7a10b1f..d9b16519c82e03bc8eac2db8046881ca2300b4ea 100644 (file)
@@ -225,6 +225,7 @@ int matcher_parserwrap(void)
 %token MATCHER_NOT_MESSAGE  MATCHER_BODY_PART  MATCHER_NOT_BODY_PART
 %token MATCHER_TEST  MATCHER_NOT_TEST  MATCHER_MATCHCASE  MATCHER_MATCH
 %token MATCHER_REGEXPCASE  MATCHER_REGEXP  MATCHER_SCORE  MATCHER_MOVE
 %token MATCHER_NOT_MESSAGE  MATCHER_BODY_PART  MATCHER_NOT_BODY_PART
 %token MATCHER_TEST  MATCHER_NOT_TEST  MATCHER_MATCHCASE  MATCHER_MATCH
 %token MATCHER_REGEXPCASE  MATCHER_REGEXP  MATCHER_SCORE  MATCHER_MOVE
+%token MATCHER_ANY_IN_ADDRESSBOOK MATCHER_ALL_IN_ADDRESSBOOK
 %token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK
 %token MATCHER_LOCK MATCHER_UNLOCK
 %token MATCHER_EXECUTE
 %token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK
 %token MATCHER_LOCK MATCHER_UNLOCK
 %token MATCHER_EXECUTE
@@ -395,6 +396,14 @@ MATCHER_MATCHCASE
 {
        match_type = MATCHTYPE_REGEXP;
 }
 {
        match_type = MATCHTYPE_REGEXP;
 }
+| MATCHER_ANY_IN_ADDRESSBOOK
+{
+       match_type = MATCHTYPE_ANY_IN_ADDRESSBOOK;
+}
+| MATCHER_ALL_IN_ADDRESSBOOK
+{
+       match_type = MATCHTYPE_ALL_IN_ADDRESSBOOK;
+}
 ;
 
 condition:
 ;
 
 condition: