1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000 Ximian Inc.
5 * Authors: Michael Zucchi <notzed@ximian.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of version 2 of the GNU Lesser General Public
9 * License as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #ifndef _CAMEL_FOLDER_SEARCH_H
23 #define _CAMEL_FOLDER_SEARCH_H
25 #include <libedataserver/e-sexp.h>
26 #include <camel/camel-folder.h>
27 #include <camel/camel-object.h>
28 #include <camel/camel-index.h>
30 #define CAMEL_FOLDER_SEARCH_TYPE (camel_folder_search_get_type ())
31 #define CAMEL_FOLDER_SEARCH(obj) CAMEL_CHECK_CAST (obj, camel_folder_search_get_type (), CamelFolderSearch)
32 #define CAMEL_FOLDER_SEARCH_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_folder_search_get_type (), CamelFolderSearchClass)
33 #define CAMEL_IS_FOLDER_SEARCH(obj) CAMEL_CHECK_TYPE (obj, camel_folder_search_get_type ())
37 typedef struct _CamelFolderSearchClass CamelFolderSearchClass;
39 struct _CamelFolderSearch {
42 struct _CamelFolderSearchPrivate *priv;
44 ESExp *sexp; /* s-exp evaluator */
45 char *last_search; /* last searched expression */
47 /* these are only valid during the search, and are reset afterwards */
48 CamelFolder *folder; /* folder for current search */
49 GPtrArray *summary; /* summary array for current search */
50 GPtrArray *summary_set; /* subset of summary to actually include in search */
51 GHashTable *summary_hash; /* hashtable of summary items */
52 CamelMessageInfo *current; /* current message info, when searching one by one */
53 CamelMimeMessage *current_message; /* cache of current message, if required */
54 CamelIndex *body_index;
57 struct _CamelFolderSearchClass {
58 CamelObjectClass parent_class;
60 /* general bool/comparison options, usually these wont need to be set, unless it is compiling into another language */
61 ESExpResult * (*and)(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFolderSearch *s);
62 ESExpResult * (*or)(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFolderSearch *s);
63 ESExpResult * (*not)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
64 ESExpResult * (*lt)(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFolderSearch *s);
65 ESExpResult * (*gt)(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFolderSearch *s);
66 ESExpResult * (*eq)(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFolderSearch *s);
69 /* (match-all [boolean expression]) Apply match to all messages */
70 ESExpResult * (*match_all)(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFolderSearch *s);
72 /* (match-threads "type" [array expression]) add all related threads */
73 ESExpResult * (*match_threads)(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFolderSearch *s);
75 /* (body-contains "string1" "string2" ...) Returns a list of matches, or true if in single-message mode */
76 ESExpResult * (*body_contains)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
78 /* (header-contains "headername" "string1" ...) List of matches, or true if in single-message mode */
79 ESExpResult * (*header_contains)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
81 /* (header-matches "headername" "string") */
82 ESExpResult * (*header_matches)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
84 /* (header-starts-with "headername" "string") */
85 ESExpResult * (*header_starts_with)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
87 /* (header-ends-with "headername" "string") */
88 ESExpResult * (*header_ends_with)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
90 /* (header-exists "headername") */
91 ESExpResult * (*header_exists)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
93 /* (user-flag "flagname" "flagname" ...) If one of user-flag set */
94 ESExpResult * (*user_flag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
96 /* (user-tag "flagname") Returns the value of a user tag. Can only be used in match-all */
97 ESExpResult * (*user_tag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
99 /* (system-flag "flagname") Returns the value of a system flag. Can only be used in match-all */
100 ESExpResult * (*system_flag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
102 /* (get-sent-date) Retrieve the date that the message was sent on as a time_t */
103 ESExpResult * (*get_sent_date)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
105 /* (get-received-date) Retrieve the date that the message was received on as a time_t */
106 ESExpResult * (*get_received_date)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
108 /* (get-current-date) Retrieve 'now' as a time_t */
109 ESExpResult * (*get_current_date)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
111 /* (get-size) Retrieve message size as an int (in kilobytes) */
112 ESExpResult * (*get_size)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
114 /* (uid "uid" ...) True if the uid is in the list */
115 ESExpResult * (*uid)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s);
118 CamelType camel_folder_search_get_type (void);
119 CamelFolderSearch *camel_folder_search_new (void);
120 void camel_folder_search_construct (CamelFolderSearch *search);
122 /* This stuff currently gets cleared when you run a search ... what on earth was i thinking ... */
123 void camel_folder_search_set_folder(CamelFolderSearch *search, CamelFolder *folder);
124 void camel_folder_search_set_summary(CamelFolderSearch *search, GPtrArray *summary);
125 void camel_folder_search_set_body_index(CamelFolderSearch *search, CamelIndex *index);
126 /* this interface is deprecated */
127 GPtrArray *camel_folder_search_execute_expression(CamelFolderSearch *search, const char *expr, CamelException *ex);
129 GPtrArray *camel_folder_search_search(CamelFolderSearch *search, const char *expr, GPtrArray *uids, CamelException *ex);
130 void camel_folder_search_free_result(CamelFolderSearch *search, GPtrArray *);
134 #endif /* ! _CAMEL_FOLDER_SEARCH_H */