<?xml version="1.0"?>
<filterdescription>
<partset>
 <part name="sender">
  <title>Sender</title>
   <input type="optionlist" name="sender-type">
    <option value="contains">
        <title>contains</title>
       <code>(match-all (header-contains "From" ${sender}))</code>
    </option>
    <option value="not contains">
        <title>does not contain</title>
        <code>(match-all (not (header-contains "From" ${sender})))</code>
    </option>
    <option value="is">
        <title>is</title>
       <code>(match-all (header-matches "From" ${sender}))</code>
    </option>
    <option value="is not">
        <title>is not</title>
        <code>(match-all (not (header-matches "From" ${sender})))</code>
    </option>
    <option value="starts with">
     <title>starts with</title>
     <code>
        (match-all (header-starts-with "From" ${sender}))
     </code>
    </option>
    <option value="not starts with">
     <title>does not start with</title>
     <code>
        (match-all (not (header-starts-with "From" ${sender})))
     </code>
    </option>
    <option value="ends with">
     <title>ends with</title>
     <code>
        (match-all (header-ends-with "From" ${sender}))
     </code>
    </option>
    <option value="not ends with">
     <title>does not end with</title>
     <code>
        (match-all (not (header-ends-with "From" ${sender})))
     </code>
    </option>
   </input>
   <input type="string" name="sender"/>
 </part>

 <!-- NOTE: Do not include Bcc addresses in this search until Camel
            includes Bcc addresses in its summary database.  Otherwise
            it kills our search performance by forcing entire messages
            to be downloaded just to examine their Bcc headers. -->
 <part name="to">
   <title>Recipients</title>
   <input type="optionlist" name="recipient-type">
    <option value="contains">
     <title>contains</title>
     <code>
       (match-all (or (header-contains "To" ${recipient})
                      (header-contains "Cc" ${recipient})))
     </code>
    </option>
    <option value="not contains">
     <title>does not contain</title>
     <code>
       (match-all (not (or
                          (header-contains "To" ${recipient})
                         (header-contains "Cc" ${recipient}))))
     </code>
    </option>
    <option value="is">
     <title>is</title>
     <code>
       (match-all (or (header-matches "To" ${recipient})
                         (header-matches "Cc" ${recipient})))
     </code>
    </option>
    <option value="is not">
     <title>is not</title>
     <code>
       (match-all (not (or
               (header-matches "To" ${recipient})
              (header-matches "Cc" ${recipient}))))
     </code>
    </option>
    <option value="starts with">
     <title>starts with</title>
     <code>
        (match-all (or (header-starts-with "To" ${recipient})
                         (header-starts-with "Cc" ${recipient})))
     </code>
    </option>
    <option value="not starts with">
     <title>does not start with</title>
     <code>
        (match-all (not (or
               (header-starts-with "To" ${recipient})
              (header-starts-with "Cc" ${recipient}))))
     </code>
    </option>
    <option value="ends with">
     <title>ends with</title>
     <code>
        (match-all (or (header-ends-with "To" ${recipient})
                         (header-ends-with "Cc" ${recipient})))
     </code>
    </option>
    <option value="not ends with">
     <title>does not end with</title>
     <code>
        (match-all (not (or
               (header-ends-with "To" ${recipient})
              (header-ends-with "Cc" ${recipient}))))
     </code>
    </option>
   </input>
   <input type="address" name="recipient"/>
 </part>

 <part name="cc">
   <title>CC</title>
   <input type="optionlist" name="recipient-type">
    <option value="contains">
     <title>contains</title>
     <code>
       (match-all (header-contains "Cc" ${recipient}))
     </code>
    </option>
    <option value="not contains">
     <title>does not contain</title>
     <code>
       (match-all (not (header-contains "Cc" ${recipient})))
     </code>
    </option>
    <option value="is">
     <title>is</title>
     <code>
       (match-all (header-matches "Cc" ${recipient}))
     </code>
    </option>
    <option value="is not">
     <title>is not</title>
     <code>
       (match-all (not (header-matches "Cc" ${recipient})))
     </code>
    </option>
    <option value="starts with">
     <title>starts with</title>
     <code>
        (match-all (header-starts-with "Cc" ${recipient}))
     </code>
    </option>
    <option value="not starts with">
     <title>does not start with</title>
     <code>
        (match-all (not (header-starts-with "Cc" ${recipient})))
     </code>
    </option>
    <option value="ends with">
     <title>ends with</title>
     <code>
        (match-all (header-ends-with "Cc" ${recipient}))
     </code>
    </option>
    <option value="not ends with">
     <title>does not end with</title>
     <code>
        (match-all (not (header-ends-with "Cc" ${recipient})))
     </code>
    </option>
    <option value="matches soundex">
     <title>sounds like</title>
     <code>
       (match-all (header-soundex "Cc" ${recipient}))
     </code>
    </option>
    <option value="not match soundex">
     <title>does not sound like</title>
     <code>
       (match-all (not (header-soundex "Cc" ${recipient})))
     </code>
    </option>
   </input>
   <input type="address" name="recipient"/>
 </part>

 <part name="bcc">
   <title>BCC</title>
   <input type="optionlist" name="recipient-type">
    <option value="contains">
     <title>contains</title>
     <code>
       (match-all (header-contains "Bcc" ${recipient}))
     </code>
    </option>
    <option value="not contains">
     <title>does not contain</title>
     <code>
       (match-all (not (header-contains "Bcc" ${recipient})))
     </code>
    </option>
    <option value="is">
     <title>is</title>
     <code>
       (match-all (header-matches "Bcc" ${recipient}))
     </code>
    </option>
    <option value="is not">
     <title>is not</title>
     <code>
       (match-all (not (header-matches "Bcc" ${recipient})))
     </code>
    </option>
    <option value="starts with">
     <title>starts with</title>
     <code>
        (match-all (header-starts-with "Bcc" ${recipient}))
     </code>
    </option>
    <option value="not starts with">
     <title>does not start with</title>
     <code>
        (match-all (not (header-starts-with "Bcc" ${recipient})))
     </code>
    </option>
    <option value="ends with">
     <title>ends with</title>
     <code>
        (match-all (header-ends-with "Bcc" ${recipient}))
     </code>
    </option>
    <option value="not ends with">
     <title>does not end with</title>
     <code>
        (match-all (not (header-ends-with "Bcc" ${recipient})))
     </code>
    </option>
    <option value="matches soundex">
     <title>sounds like</title>
     <code>
       (match-all (header-soundex "Bcc" ${recipient}))
     </code>
    </option>
    <option value="not match soundex">
     <title>does not sound like</title>
     <code>
       (match-all (not (header-soundex "Bcc" ${recipient})))
     </code>
    </option>
   </input>
   <input type="address" name="recipient"/>
 </part>

 <part name="senderto">
   <title>Sender or Recipients</title>
   <input type="optionlist" name="recipient-type">
    <option value="contains">
     <title>contains</title>
     <code>
       (match-all (or (header-contains "From" ${recipient})
                      (header-contains "To" ${recipient})
                      (header-contains "Cc" ${recipient})))
     </code>
    </option>
    <option value="not contains">
     <title>does not contain</title>
     <code>
       (match-all (not (or
                          (header-contains "From" ${recipient})
                          (header-contains "To" ${recipient})
                          (header-contains "Cc" ${recipient}))))
     </code>
    </option>
    <option value="is">
     <title>is</title>
     <code>
       (match-all (or (header-matches "From" ${recipient})
                         (header-matches "To" ${recipient})
                         (header-matches "Cc" ${recipient})))
     </code>
    </option>
    <option value="is not">
     <title>is not</title>
     <code>
       (match-all (not (or
               (header-matches "From" ${recipient})
               (header-matches "To" ${recipient})
               (header-matches "Cc" ${recipient}))))
     </code>
    </option>
    <option value="starts with">
     <title>starts with</title>
     <code>
        (match-all (or (header-starts-with "From" ${recipient})
                         (header-starts-with "To" ${recipient})
                         (header-starts-with "Cc" ${recipient})))
     </code>
    </option>
    <option value="not starts with">
     <title>does not start with</title>
     <code>
        (match-all (not (or
               (header-starts-with "From" ${recipient})
               (header-starts-with "To" ${recipient})
               (header-starts-with "Cc" ${recipient}))))
     </code>
    </option>
    <option value="ends with">
     <title>ends with</title>
     <code>
        (match-all (or (header-ends-with "From" ${recipient})
                         (header-ends-with "To" ${recipient})
                         (header-ends-with "Cc" ${recipient})))
     </code>
    </option>
    <option value="not ends with">
     <title>does not end with</title>
     <code>
        (match-all (not (or
               (header-ends-with "From" ${recipient})
               (header-ends-with "To" ${recipient})
               (header-ends-with "Cc" ${recipient}))))
     </code>
    </option>
   </input>
   <input type="string" name="recipient"/>
 </part>

 <part name="subject">
   <title>Subject</title>
   <input type="optionlist" name="subject-type">
    <option value="contains">
     <title>contains</title>
     <code>
       (match-all (header-contains "Subject" ${subject}))
     </code>
    </option>
    <option value="not contains">
     <title>does not contain</title>
     <code>
       (match-all (not (header-contains "Subject" ${subject})))
     </code>
    </option>
    <option value="has-words">
     <title>has words</title>
     <code>
	(match-all (header-has-words "Subject" ${subject}))
     </code>
    </option>
    <option value="not has-words">
     <title>does not have words</title>
     <code>
	(match-all (not (header-has-words "Subject" ${subject})))
     </code>
    </option>
    <option value="is">
     <title>is</title>
     <code>
       (match-all (header-matches "Subject" ${subject}))
     </code>
    </option>
    <option value="is not">
     <title>is not</title>
     <code>
       (match-all (not (header-matches "Subject" ${subject})))
     </code>
    </option>
    <option value="starts with">
     <title>starts with</title>
     <code>
       (match-all (header-starts-with "Subject" ${subject}))
     </code>
    </option>
    <option value="not starts with">
     <title>does not start with</title>
     <code>
       (match-all (not (header-starts-with "Subject" ${subject})))
     </code>
    </option>
    <option value="ends with">
     <title>ends with</title>
     <code>
       (match-all (header-ends-with "Subject" ${subject}))
     </code>
    </option>
    <option value="not ends with">
     <title>does not end with</title>
     <code>
       (match-all (not (header-ends-with "Subject" ${subject})))
     </code>
    </option>
   </input>
   <input type="string" name="subject"/>
 </part>

 <part name="header">
   <title>Specific header</title>
   <input type="string" name="header-field"/>
   <input type="optionlist" name="header-type">
    <option value="contains">
     <title>contains</title>
     <code>
       (match-all (header-contains ${header-field} ${word}))
     </code>
    </option>
    <option value="not contains">
     <title>does not contain</title>
     <code>
       (match-all (not (header-contains ${header-field} ${word})))
     </code>
    </option>
    <option value="has-words">
     <title>has words</title>
     <code>
	(match-all (header-has-words ${header-field} ${word}))
     </code>
    </option>
    <option value="not has-words">
     <title>does not have words</title>
     <code>
	(match-all (not (header-has-words ${header-field} ${word})))
     </code>
    </option>
    <option value="is">
     <title>is</title>
     <code>
       (match-all (header-matches ${header-field} ${word}))
     </code>
    </option>
    <option value="is not">
     <title>is not</title>
     <code>
       (match-all (not (header-matches ${header-field} ${word})))
     </code>
    </option>
    <option value="starts with">
     <title>starts with</title>
     <code>
       (match-all (header-starts-with ${header-field} ${word}))
     </code>
    </option>
    <option value="not starts with">
     <title>does not start with</title>
     <code>
       (match-all (not (header-starts-with ${header-field} ${word})))
     </code>
    </option>
    <option value="ends with">
     <title>ends with</title>
     <code>
       (match-all (header-ends-with ${header-field} ${word}))
     </code>
    </option>
    <option value="not ends with">
     <title>does not end with</title>
     <code>
       (match-all (not (header-ends-with ${header-field} ${word})))
     </code>
    </option>
    <option value="exists">
     <title>exists</title>
     <code>
       (match-all (header-exists ${header-field}))
     </code>
    </option>
    <option value="not exists">
     <title>does not exist</title>
     <code>
       (match-all (not (header-exists ${header-field})))
     </code>
    </option>
    <option value="matches soundex">
     <title>sounds like</title>
     <code>
        (match-all (header-soundex ${header-field} ${word}))
     </code>
    </option>
    <option value="not match soundex">
     <title>does not sound like</title>
     <code>
        (match-all (not (header-soundex ${header-field} ${word})))
     </code>
    </option>
   </input>
   <input type="string" name="word"/>
 </part>

 <part name="body">
   <title>Message Body</title>
   <input type="optionlist" name="body-type">
    <option value="contains">
     <title>contains</title>
     <code>
       (body-contains ${word})
     </code>
    </option>
    <option value="not contains">
     <title>does not contain</title>
     <code>
       (not (body-contains ${word}))
     </code>
    </option>
   </input>
   <input type="string" name="word"/>
 </part>
 <part name="sexp">
   <title>Expression</title>
   <input type="code" name="code"/>
 </part>

 <part name="sent-date">
  <title>Date sent</title>
  <input type="optionlist" name="date-spec-type">
   <option value="is">
    <title>is</title>
    <code>
       (match-all (= (get-sent-date) ${versus}))
    </code>
   </option>
   <option value="is-not">
    <title>is not</title>
    <code>
       (match-all (not (= (get-sent-date) ${versus})))
    </code>
   </option>
   <option value="before">
    <title>is before</title>
    <code>
       (match-all (&lt; (get-sent-date) ${versus}))
    </code>
   </option>
   <option value="after">
    <title>is after</title>
    <code>
       (match-all (&gt; (get-sent-date) ${versus}))
    </code>
   </option>
  </input>    
  <input type="datespec" name="versus"/>
 </part>

 <part name="recv-date">
  <title>Date received</title>
  <input type="optionlist" name="date-spec-type">
   <option value="is">
    <title>is</title>
    <code>
       (match-all (= (get-received-date) ${versus}))
    </code>
   </option>
   <option value="is-not">
    <title>is not</title>
    <code>
       (match-all (not (= (get-received-date) ${versus})))
    </code>
   </option>
   <option value="before">
    <title>is before</title>
    <code>
       (match-all (&lt; (get-received-date) ${versus}))
    </code>
   </option>
   <option value="after">
    <title>is after</title>
    <code>
       (match-all (&gt; (get-received-date) ${versus}))
    </code>
   </option>
  </input>    
  <input type="datespec" name="versus"/>
 </part>

 <part name="label">
  <title>Label</title>
  <input type="optionlist" name="label-type">
   <option value="is">
    <title>is</title>
    <code>
       (match-all (or (= (user-tag "label") ${versus}) (user-flag (+ "$Label" ${versus})) (user-flag ${versus})))
    </code>
   </option>
   <option value="is-not">
    <title>is not</title>
    <code>
       (match-all (not (or (= (user-tag "label") ${versus}) (user-flag (+ "$Label" ${versus})) (user-flag ${versus}))))
    </code>
   </option>
  </input>
  <input type="optionlist" name="versus">
     <dynamic func="e_mail_labels_get_filter_options"/>
  </input>
 </part>

 <part name="score">
  <title>Score</title>
  <input type="optionlist" name="score-type">
   <option value="is">
    <title>is</title>
    <code>
       (match-all (= (cast-int (user-tag "score")) ${versus}))
    </code>
   </option>
   <option value="is-not">
    <title>is not</title>
    <code>
       (match-all (not (= (cast-int (user-tag "score")) ${versus})))
    </code>
   </option>
   <option value="greater-than">
    <title>is greater than</title>
    <code>
       (match-all (&gt; (cast-int (user-tag "score")) ${versus}))
    </code>
   </option>
   <option value="less-than">
    <title>is less than</title>
    <code>
       (match-all (&lt; (cast-int (user-tag "score")) ${versus}))
    </code>
   </option>
  </input>
  <input type="score" name="versus"/>
 </part>

 <part name="size">
  <title>Size (kB)</title>
  <input type="optionlist" name="size-type">
   <option value="greater-than">
    <title>is greater than</title>
    <code>
       (match-all (&gt; (get-size) ${versus}))
    </code>
   </option>
   <option value="less-than">
    <title>is less than</title>
    <code>
       (match-all (&lt; (get-size) ${versus}))
    </code>
   </option>
  </input>
  <input type="integer" name="versus"/>
 </part>

 <part name="status">
  <title>Status</title>
  <input type="optionlist" name="match-type">
   <option value="is">
    <title>is</title>
    <code>
     (match-all (system-flag ${flag}))
    </code>
   </option>
   <option value="is not">
    <title>is not</title>
    <code>
     (match-all (not (system-flag ${flag})))
    </code>
   </option>
  </input>
  <input type="optionlist" name="flag">
   <option value="Answered">
    <title>Replied to</title>
   </option>
   <option value="Deleted">
    <title>Deleted</title>
   </option>
   <option value="Draft">
    <title>Draft</title>
   </option>
   <option value="Flagged">
    <title>Important</title>
   </option>
   <option value="Seen">
    <title>Read</title>
   </option>
  </input>
 </part>

 <part name="follow-up">
  <title>Follow Up</title>
  <input type="optionlist" name="match-type">
   <option value="is">
    <title>is Flagged</title>
    <code>
     (match-all (not (= (user-tag "follow-up") "")))
    </code>
   </option>
   <option value="is not">
    <title>is not Flagged</title>
    <code>
     (match-all (= (user-tag "follow-up") ""))
    </code>
   </option>
  </input>
 </part>

 <part name="completed-on">
  <title>Completed On</title>
  <input type="optionlist" name="date-spec-type">
   <option value="is set">
    <title>is set</title>
    <code>
       (match-all (not (= (user-tag "completed-on") "")))
    </code>
   </option>
   <option value="is not set">
    <title>is not set</title>
    <code>
       (match-all (= (user-tag "completed-on") ""))
    </code>
   </option>
  </input>    
 </part>

 <part name="attachments">
  <title>Attachments</title>
  <input type="optionlist" name="match-type">
   <option value="exist">
    <title>Exist</title>
    <code>
     (match-all (system-flag "Attachments"))
    </code>
   </option>
   <option value="not exist">
    <title>Do Not Exist</title>
    <code>
     (match-all (not (system-flag "Attachments")))
    </code>
   </option>
  </input>
 </part>

 <part name="mlist">
  <title>Mailing list</title>
   <input type="optionlist" name="mlist-type">
    <option value="is">
        <title>is</title>
        <code>(match-all (header-matches "x-camel-mlist" ${mlist}))</code>
    </option>
    <option value="is not">
        <title>is not</title>
        <code>(match-all (not (header-matches "x-camel-mlist" ${mlist})))</code>
    </option>
    <option value="contains">
        <title>contains</title>
        <code>(match-all (header-contains "x-camel-mlist" ${mlist}))</code>
    </option>
    <option value="not contains">
        <title>does not contain</title>
        <code>(match-all (not (header-contains "x-camel-mlist" ${mlist})))</code>
    </option>
   </input>
   <input type="string" name="mlist"/>
 </part>

 <part name="regex">
  <title>Regex Match</title>
  <input type="optionlist" name="match-type">
   <option value="header">
    <title>Message Header</title>
    <code>
       (match-all (header-full-regex ${expression}))
    </code>
   </option>
   <option value="body">
    <title>Message Body</title>
    <code>
       (match-all (body-regex ${expression}))
    </code>
   </option>
  </input>
  <input type="regex" name="expression"/>
 </part>

    <part name="all">
      <title>Match All</title>
      <code>
       (match-all #t)
      </code>
    </part>

</partset>

  <ruleset>
    <rule grouping="any" source="demand">
      <_title>Subject or Addresses contains</_title>
      <partset>
        <part name="subject">
          <value name="subject-type" type="option" value="contains"/>
          <value name="subject" type="string"/>
        </part>
        <part name="sender">
          <value name="sender-type" type="option" value="contains"/>
          <value name="sender" type="string"/>
        </part>
        <part name="to">
          <value name="recipient-type" type="option" value="contains"/>
          <value name="recipient" type="address"/>
        </part>
      </partset>
      <sources/>
    </rule>

    <rule grouping="any" source="demand">
      <_title>Recipients contain</_title>
      <partset>
        <part name="to">
          <value name="recipient-type" type="option" value="contains"/>
          <value name="recipient" type="address"/>
        </part>
      </partset>
      <sources/>
    </rule>

    <rule grouping="any" source="demand">
      <_title>Message contains</_title>
      <partset>
        <part name="subject">
          <value name="subject-type" type="option" value="contains"/>
          <value name="subject" type="string"/>
        </part>
        <part name="body">
          <value name="body-type" type="option" value="contains"/>
          <value name="word" type="string"/>
        </part>
        <part name="sender">
          <value name="sender-type" type="option" value="contains"/>
          <value name="sender" type="string"/>
        </part>
        <part name="to">
          <value name="recipient-type" type="option" value="contains"/>
          <value name="recipient" type="address"/>
        </part>
      </partset>
      <sources/>
    </rule>

    <rule grouping="any" source="demand">
      <_title>Subject contains</_title>
      <partset>
        <part name="subject">
          <value name="subject-type" type="option" value="contains"/>
          <value name="subject" type="string"/>
        </part>
      </partset>
      <sources/>
    </rule>

    <rule grouping="any" source="demand">
      <_title>Sender contains</_title>
      <partset>
        <part name="sender">
          <value name="sender-type" type="option" value="contains"/>
          <value name="sender" type="string"/>
        </part>
      </partset>
      <sources/>
    </rule>

    <rule grouping="any" source="demand">
      <_title>Body contains</_title>
      <partset>
        <part name="body">
          <value name="body-type" type="option" value="contains"/>
          <value name="word" type="string"/>
        </part>
      </partset>
      <sources/>
    </rule>

  </ruleset>
</filterdescription>
