aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-12-22 03:50:09 +0800
committerDan Winship <danw@src.gnome.org>2000-12-22 03:50:09 +0800
commitb1ed87891b6d5df213ac2168572d46ee1924f9ff (patch)
tree2dde5702c0cf51c83ccaadc513f4d98ae1767f9e /camel
parentfbf92961aa7fd925a7283ccd134739363d3cb9b9 (diff)
downloadgsoc2013-evolution-b1ed87891b6d5df213ac2168572d46ee1924f9ff.tar
gsoc2013-evolution-b1ed87891b6d5df213ac2168572d46ee1924f9ff.tar.gz
gsoc2013-evolution-b1ed87891b6d5df213ac2168572d46ee1924f9ff.tar.bz2
gsoc2013-evolution-b1ed87891b6d5df213ac2168572d46ee1924f9ff.tar.lz
gsoc2013-evolution-b1ed87891b6d5df213ac2168572d46ee1924f9ff.tar.xz
gsoc2013-evolution-b1ed87891b6d5df213ac2168572d46ee1924f9ff.tar.zst
gsoc2013-evolution-b1ed87891b6d5df213ac2168572d46ee1924f9ff.zip
New CamelFolderSearch subclass that just reimplements body_contains (using
* providers/imap/camel-imap-search.c: New CamelFolderSearch subclass that just reimplements body_contains (using the IMAP SEARCH command). All other kinds of searching are done against the local summary. * providers/imap/camel-imap-folder.c (imap_search_by_expression): Use a CamelImapSearch to do searching. * providers/imap/camel-imap-utils.c (imap_translate_sexp, etc): No longer needed. * camel-folder-search.h: Add missing CAMEL_FOLDER_SEARCH_TYPE #define svn path=/trunk/; revision=7119
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog16
-rw-r--r--camel/camel-folder-search.h1
-rw-r--r--camel/providers/imap/Makefile.am2
-rw-r--r--camel/providers/imap/camel-imap-folder.c71
-rw-r--r--camel/providers/imap/camel-imap-folder.h1
-rw-r--r--camel/providers/imap/camel-imap-search.c131
-rw-r--r--camel/providers/imap/camel-imap-search.h52
-rw-r--r--camel/providers/imap/camel-imap-utils.c393
-rw-r--r--camel/providers/imap/camel-imap-utils.h2
9 files changed, 228 insertions, 441 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 272f058ad4..a13109fe80 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,21 @@
2000-12-21 Dan Winship <danw@helixcode.com>
+ * providers/imap/camel-imap-search.c: New CamelFolderSearch
+ subclass that just reimplements body_contains (using the IMAP
+ SEARCH command). All other kinds of searching are done against the
+ local summary.
+
+ * providers/imap/camel-imap-folder.c (imap_search_by_expression):
+ Use a CamelImapSearch to do searching.
+
+ * providers/imap/camel-imap-utils.c (imap_translate_sexp, etc): No
+ longer needed.
+
+ * camel-folder-search.h: Add missing CAMEL_FOLDER_SEARCH_TYPE
+ #define
+
+2000-12-21 Dan Winship <danw@helixcode.com>
+
* camel-stream-buffer.c (camel_stream_buffer_gets): Update the
doc comment: since it always NUL-terminates the buffer, it reads
at most @max-1 bytes, not @max.
diff --git a/camel/camel-folder-search.h b/camel/camel-folder-search.h
index 34869c1e5e..df3c7f5da6 100644
--- a/camel/camel-folder-search.h
+++ b/camel/camel-folder-search.h
@@ -28,6 +28,7 @@
#include <libibex/ibex.h>
#include <camel/camel-folder.h>
+#define CAMEL_FOLDER_SEARCH_TYPE (camel_folder_search_get_type ())
#define CAMEL_FOLDER_SEARCH(obj) CAMEL_CHECK_CAST (obj, camel_folder_search_get_type (), CamelFolderSearch)
#define CAMEL_FOLDER_SEARCH_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_folder_search_get_type (), CamelFolderSearchClass)
#define CAMEL_IS_FOLDER_SEARCH(obj) CAMEL_CHECK_TYPE (obj, camel_folder_search_get_type ())
diff --git a/camel/providers/imap/Makefile.am b/camel/providers/imap/Makefile.am
index 19646f1960..03dec12608 100644
--- a/camel/providers/imap/Makefile.am
+++ b/camel/providers/imap/Makefile.am
@@ -25,6 +25,7 @@ libcamelimap_la_SOURCES = \
camel-imap-command.c \
camel-imap-folder.c \
camel-imap-provider.c \
+ camel-imap-search.c \
camel-imap-store.c \
camel-imap-summary.c \
camel-imap-utils.c
@@ -33,6 +34,7 @@ libcamelimapinclude_HEADERS = \
camel-imap-auth.h \
camel-imap-command.h \
camel-imap-folder.h \
+ camel-imap-search.h \
camel-imap-store.h \
camel-imap-stream.h \
camel-imap-summary.h \
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 0647681613..9da5103b68 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -39,6 +39,7 @@
#include "camel-imap-folder.h"
#include "camel-imap-command.h"
+#include "camel-imap-search.h"
#include "camel-imap-store.h"
#include "camel-imap-stream.h"
#include "camel-imap-summary.h"
@@ -93,6 +94,7 @@ static void imap_update_summary (CamelFolder *folder, int first, int last,
/* searching */
static GPtrArray *imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex);
+static void imap_search_free (CamelFolder *folder, GPtrArray *uids);
/* flag methods */
static guint32 imap_get_message_flags (CamelFolder *folder, const char *uid);
@@ -132,6 +134,7 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->free_summary = camel_folder_free_nop;
camel_folder_class->search_by_expression = imap_search_by_expression;
+ camel_folder_class->search_free = imap_search_free;
camel_folder_class->get_message_flags = imap_get_message_flags;
camel_folder_class->set_message_flags = imap_set_message_flags;
@@ -234,6 +237,8 @@ imap_finalize (CamelObject *object)
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (object);
camel_object_unref ((CamelObject *)imap_folder->summary);
+ if (imap_folder->search)
+ camel_object_unref ((CamelObject *)imap_folder->search);
}
static void
@@ -728,53 +733,27 @@ imap_get_message_info (CamelFolder *folder, const char *uid)
static GPtrArray *
imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex)
{
- CamelImapResponse *response;
- GPtrArray *uids = NULL;
- char *result, *sexp, *p;
-
- d(fprintf (stderr, "camel sexp: '%s'\n", expression));
- sexp = imap_translate_sexp (expression);
- d(fprintf (stderr, "imap sexp: '%s'\n", sexp));
-
- uids = g_ptr_array_new ();
-
- if (!folder->has_search_capability) {
- g_free (sexp);
- return uids;
- }
-
- response = camel_imap_command (CAMEL_IMAP_STORE (folder->parent_store),
- folder, NULL, "UID SEARCH %s", sexp);
- g_free (sexp);
- if (!response)
- return uids;
+ CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
- result = camel_imap_response_extract (response, "SEARCH", NULL);
- if (!result)
- return uids;
-
- if ((p = strstr (result, "* SEARCH"))) {
- char *word;
-
- word = imap_next_word (p); /* word now points to SEARCH */
-
- for (word = imap_next_word (word); *word && *word != '*'; word = imap_next_word (word)) {
- gboolean word_is_numeric = TRUE;
- char *ep;
-
- /* find the end of this word and make sure it's a numeric uid */
- for (ep = word; *ep && *ep != ' ' && *ep != '\n'; ep++)
- if (*ep < '0' || *ep > '9')
- word_is_numeric = FALSE;
-
- if (word_is_numeric)
- g_ptr_array_add (uids, g_strndup (word, (gint)(ep - word)));
- }
- }
-
- g_free (result);
-
- return uids;
+ if (!imap_folder->search)
+ imap_folder->search = camel_imap_search_new ();
+
+ camel_folder_search_set_folder (imap_folder->search, folder);
+ camel_folder_search_set_summary (
+ imap_folder->search, imap_folder->summary->messages);
+
+ return camel_folder_search_execute_expression (imap_folder->search,
+ expression, ex);
+}
+
+static void
+imap_search_free (CamelFolder *folder, GPtrArray *uids)
+{
+ CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
+
+ g_return_if_fail (imap_folder->search);
+
+ camel_folder_search_free_result (imap_folder->search, uids);
}
static guint32
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index 2b574a3f1f..3183a8816d 100644
--- a/camel/providers/imap/camel-imap-folder.h
+++ b/camel/providers/imap/camel-imap-folder.h
@@ -44,6 +44,7 @@ extern "C" {
typedef struct {
CamelFolder parent_object;
+ CamelFolderSearch *search;
CamelFolderSummary *summary;
int exists;
} CamelImapFolder;
diff --git a/camel/providers/imap/camel-imap-search.c b/camel/providers/imap/camel-imap-search.c
new file mode 100644
index 0000000000..1aa6b55bc5
--- /dev/null
+++ b/camel/providers/imap/camel-imap-search.c
@@ -0,0 +1,131 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-imap-search.c: IMAP folder search */
+
+/*
+ * Authors:
+ * Dan Winship <danw@helixcode.com>
+ *
+ * Copyright 2000 Helix Code, Inc. (www.helixcode.com)
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <string.h>
+
+#include "camel-imap-command.h"
+#include "camel-imap-folder.h"
+#include "camel-imap-search.h"
+
+static ESExpResult *
+imap_body_contains (struct _ESExp *f, int argc, struct _ESExpResult **argv,
+ CamelFolderSearch *s);
+
+static void
+camel_imap_search_class_init (CamelImapSearchClass *camel_imap_search_class)
+{
+ /* virtual method overload */
+ CamelFolderSearchClass *camel_folder_search_class =
+ CAMEL_FOLDER_SEARCH_CLASS (camel_imap_search_class);
+
+ /* virtual method overload */
+ camel_folder_search_class->body_contains = imap_body_contains;
+}
+
+CamelType
+camel_imap_search_get_type (void)
+{
+ static CamelType camel_imap_search_type = CAMEL_INVALID_TYPE;
+
+ if (camel_imap_search_type == CAMEL_INVALID_TYPE) {
+ camel_imap_search_type = camel_type_register (
+ CAMEL_FOLDER_SEARCH_TYPE, "CamelImapSearch",
+ sizeof (CamelImapSearch),
+ sizeof (CamelImapSearchClass),
+ (CamelObjectClassInitFunc) camel_imap_search_class_init,
+ NULL, NULL, NULL);
+ }
+
+ return camel_imap_search_type;
+}
+
+static ESExpResult *
+imap_body_contains (struct _ESExp *f, int argc, struct _ESExpResult **argv,
+ CamelFolderSearch *s)
+{
+ CamelImapStore *store = CAMEL_IMAP_STORE (s->folder->parent_store);
+ CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (s->folder);
+ char *value = argv[0]->value.string;
+ CamelImapResponse *response;
+ char *result, *p, *lasts = NULL;
+ const char *uid;
+ ESExpResult *r;
+ CamelMessageInfo *info;
+
+ if (s->current) {
+ uid = camel_message_info_uid (s->current);
+ r = e_sexp_result_new (ESEXP_RES_BOOL);
+ r->value.bool = FALSE;
+ response = camel_imap_command (store, s->folder, NULL,
+ "UID SEARCH UID %s BODY \"%s\"",
+ uid, value);
+ } else {
+ r = e_sexp_result_new(ESEXP_RES_ARRAY_PTR);
+ r->value.ptrarray = g_ptr_array_new ();
+ response = camel_imap_command (store, s->folder, NULL,
+ "UID SEARCH BODY \"%s\"",
+ value);
+ }
+ if (!response)
+ return r;
+ result = camel_imap_response_extract (response, "SEARCH", NULL);
+ if (!result)
+ return r;
+
+ p = result + sizeof ("* SEARCH");
+ for (p = strtok_r (p, " ", &lasts); p; p = strtok_r (NULL, " ", &lasts)) {
+ if (s->current) {
+ if (!strcmp (uid, p)) {
+ r->value.bool = TRUE;
+ break;
+ }
+ } else {
+ /* FIXME: The strings added to the array must be
+ * static...
+ */
+ info = camel_folder_summary_uid (imap_folder->summary, p);
+ g_ptr_array_add (r->value.ptrarray, (char *)camel_message_info_uid (info));
+ }
+ }
+
+ return r;
+}
+
+/**
+ * camel_imap_search_new:
+ *
+ * Return value: A new CamelImapSearch widget.
+ **/
+CamelFolderSearch *
+camel_imap_search_new (void)
+{
+ CamelFolderSearch *new = CAMEL_FOLDER_SEARCH (camel_object_new (camel_imap_search_get_type ()));
+
+ camel_folder_search_construct (new);
+ return new;
+}
diff --git a/camel/providers/imap/camel-imap-search.h b/camel/providers/imap/camel-imap-search.h
new file mode 100644
index 0000000000..c588459577
--- /dev/null
+++ b/camel/providers/imap/camel-imap-search.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-imap-search.h: IMAP folder search */
+
+/*
+ * Authors:
+ * Dan Winship <danw@helixcode.com>
+ *
+ * Copyright 2000 Helix Code, Inc. (www.helixcode.com)
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _CAMEL_IMAP_SEARCH_H
+#define _CAMEL_IMAP_SEARCH_H
+
+#include <camel/camel-folder-search.h>
+
+#define CAMEL_IMAP_SEARCH_TYPE (camel_imap_search_get_type ())
+#define CAMEL_IMAP_SEARCH(obj) CAMEL_CHECK_CAST (obj, camel_imap_search_get_type (), CamelImapSearch)
+#define CAMEL_IMAP_SEARCH_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_imap_search_get_type (), CamelImapSearchClass)
+#define CAMEL_IS_IMAP_SEARCH(obj) CAMEL_CHECK_TYPE (obj, camel_imap_search_get_type ())
+
+typedef struct _CamelImapSearchClass CamelImapSearchClass;
+typedef struct _CamelImapSearch CamelImapSearch;
+
+struct _CamelImapSearch {
+ CamelFolderSearch parent;
+
+};
+
+struct _CamelImapSearchClass {
+ CamelFolderSearchClass parent_class;
+
+};
+
+guint camel_imap_search_get_type (void);
+CamelFolderSearch *camel_imap_search_new (void);
+
+#endif /* ! _CAMEL_IMAP_SEARCH_H */
diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c
index 05c9d01d5e..3e3f4af031 100644
--- a/camel/providers/imap/camel-imap-utils.c
+++ b/camel/providers/imap/camel-imap-utils.c
@@ -125,399 +125,6 @@ imap_parse_list_response (const char *buf, int *flags, char *sep, char **folder)
return TRUE;
}
-static ESExpResult *
-func_and (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- ESExpResult *r;
-
- d(fprintf (stderr, "in AND func (argc = %d)\n", argc));
- if (argc > 0) {
- char **strings;
- int i;
-
- strings = g_new (char*, argc+1);
- strings[argc] = NULL;
-
- for (i = 0; i < argc; i++) {
- GList *list_head = *list;
-
- d(fprintf (stderr, "\tAND func: %s\n", (*list) ? (char *) (*list)->data : "(null)"));
- strings[argc - (i+1)] = (*list) ? (*list)->data : g_strdup ("");
- *list = g_list_remove_link (*list, *list);
- g_list_free_1 (list_head);
- }
-
- *list = g_list_prepend (*list, g_strjoinv (" ", strings));
- d(fprintf (stderr, "%s\n", (char *) (*list)->data));
-
- for (i = 0 ; i < argc; i ++)
- g_free (strings[i]);
-
- g_free (strings);
- }
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_or (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- ESExpResult *r;
-
- d(fprintf (stderr, "in OR func (argc = %d)\n", argc));
- if (argc == 2 && (*list)->data && (*list)->next && (*list)->next->data) {
- char **strings;
- int i;
-
- strings = g_new (char*, argc+2);
- strings[0] = g_strdup ("OR");
- strings[argc+2 - 1] = NULL;
-
- for (i = 0; i < 2; i++) {
- GList *list_head = *list;
-
- d(fprintf (stderr, "\tOR func: %s\n", (*list) ? (char *) (*list)->data : "(null)"));
- strings[argc - i] = (*list) ? (*list)->data : g_strdup ("");
- *list = g_list_remove_link (*list, *list);
- g_list_free_1 (list_head);
- }
-
- *list = g_list_prepend (*list, g_strjoinv (" ", strings));
- d(fprintf (stderr, "%s\n", (char *) (*list)->data));
-
- for (i = 0 ; i < argc + 2; i ++)
- g_free (strings[i]);
-
- g_free (strings);
- }
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_not (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- ESExpResult *r;
-
- d(fprintf (stderr, "in NOT func\n"));
- /* just replace the head of the list with the NOT of it. */
- if (argc > 0) {
- char *term = (*list)->data;
-
- (*list)->data = g_strdup_printf ("NOT %s", term);
- d(fprintf (stderr, "%s\n", (char *) (*list)->data));
- g_free (term);
- }
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static char *tz_months [] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-
-static char *
-format_date (time_t time, int offset)
-{
- struct tm tm;
-
- time += ((offset / 100) * (60*60)) + (offset % 100)*60;
-
- d(printf("converting date %s", ctime (&time)));
-
- memcpy (&tm, gmtime (&time), sizeof (tm));
-
- return g_strdup_printf ("%d-%s-%04d",
- tm.tm_mday, tz_months[tm.tm_mon],
- tm.tm_year + 1900);
-}
-
-static ESExpResult *
-func_lt (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- char *type = (*list)->data;
- time_t date = (time_t) (argv[1])->value.number;
- ESExpResult *r;
-
- d(fprintf (stderr, "in less-than func: (%d) (%s) (%d)\n", argc, type, (int) date));
- if (argc > 0) {
- char *string, *date_str;
-
- date_str = format_date (date, 0);
-
- if (!strcmp ("SENT", type)) {
- string = g_strdup_printf ("SENTBEFORE \"%s\"", date_str);
- } else {
- string = g_strdup_printf ("BEFORE \"%s\"", date_str);
- }
-
- (*list)->data = string;
- g_free (type);
- }
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_gt (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- char *type = (*list)->data;
- time_t date = (time_t) (argv[1])->value.number;
- ESExpResult *r;
-
- d(fprintf (stderr, "in greater-than func: (%d) (%s) (%d)\n", argc, type, (int) date));
- if (argc > 0) {
- char *string, *date_str;
-
- date_str = format_date (date, 0);
-
- if (!strcmp ("SENT", type)) {
- string = g_strdup_printf ("SENTSINCE \"%s\"", date_str);
- } else {
- string = g_strdup_printf ("SINCE \"%s\"", date_str);
- }
-
- (*list)->data = string;
- g_free (type);
- }
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_eq (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- char *type = (*list)->data;
- time_t date = (time_t) (argv[1])->value.number;
- ESExpResult *r;
-
- d(fprintf (stderr, "in equal-to func: (%d) (%s) (%d)\n", argc, type, (int) date));
- if (argc > 0) {
- char *string, *date_str;
-
- date_str = format_date (date, 0);
-
- if (!strcmp ("SENT", type)) {
- string = g_strdup_printf ("SENTON \"%s\"", date_str);
- } else {
- string = g_strdup_printf ("ON \"%s\"", date_str);
- }
-
- (*list)->data = string;
- g_free (type);
- }
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_match_all (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- /* match-all doesn't have a IMAP equiv */
- ESExpResult *r;
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_body_contains (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- char *value = (*argv)->value.string;
- ESExpResult *r;
-
- if (argc > 0) {
- char *string;
-
- string = g_strdup_printf ("BODY \"%s\"", value);
-
- *list = g_list_prepend (*list, string);
- }
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_header_contains (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- char *header = (argv[0])->value.string;
- char *match = (argv[1])->value.string;
- ESExpResult *r;
-
- if (argc == 2) {
- char *string;
- string = g_strdup_printf ("HEADER %s \"%s\"", header, match);
-
- *list = g_list_prepend (*list, string);
- }
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_user_tag (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- /* FIXME: what do I do here? */
- ESExpResult *r;
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_user_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- /* FIXME: what do I do here? */
- ESExpResult *r;
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_get_sent_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- ESExpResult *r;
-
- *list = g_list_prepend (*list, g_strdup ("SENT"));
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_get_received_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- GList **list = data;
- ESExpResult *r;
-
- *list = g_list_prepend (*list, g_strdup ("RECEIVED"));
-
- r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = FALSE;
-
- return r;
-}
-
-static ESExpResult *
-func_get_current_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data)
-{
- ESExpResult *r;
-
- r = e_sexp_result_new (ESEXP_RES_INT);
- r->value.number = time (NULL);
-
- return r;
-}
-
-/* builtin functions */
-static struct {
- char *name;
- ESExpFunc *func;
- int type; /* set to 1 if a function can perform shortcut evaluation, or
- doesn't execute everything, 0 otherwise */
-} symbols[] = {
- { "and", (ESExpFunc *) func_and, 0 },
- { "or", (ESExpFunc *) func_or, 0 },
- { "not", (ESExpFunc *) func_not, 0 },
- { "<", (ESExpFunc *) func_lt, 0 },
- { ">", (ESExpFunc *) func_gt, 0 },
- { "=", (ESExpFunc *) func_eq, 0 },
- { "match-all", (ESExpFunc *) func_match_all, 0 },
- { "body-contains", (ESExpFunc *) func_body_contains, 0 },
- { "header-contains", (ESExpFunc *) func_header_contains, 0 },
- { "user-tag", (ESExpFunc *) func_user_tag, 1 },
- { "user-flag", (ESExpFunc *) func_user_flag, 1 },
- { "get-sent-date", (ESExpFunc *) func_get_sent_date, 1 },
- { "get-received-date", (ESExpFunc *) func_get_received_date, 1 },
- { "get-current-date", (ESExpFunc *) func_get_current_date, 1 }
-};
-
-char *
-imap_translate_sexp (const char *expression)
-{
- ESExp *sexp;
- ESExpResult *r;
- gchar *retval;
- GList *list = NULL;
- int i;
-
- sexp = e_sexp_new ();
-
- for (i = 0; i < sizeof (symbols) / sizeof (symbols[0]); i++) {
- if (symbols[i].type == 1) {
- e_sexp_add_ifunction (sexp, 0, symbols[i].name,
- (ESExpIFunc *)symbols[i].func, &list);
- } else {
- e_sexp_add_function (sexp, 0, symbols[i].name,
- symbols[i].func, &list);
- }
- }
-
- e_sexp_input_text (sexp, expression, strlen (expression));
-
- e_sexp_parse (sexp);
-
- r = e_sexp_eval (sexp);
-
- gtk_object_unref (GTK_OBJECT (sexp));
- e_sexp_result_free (r);
-
- if (list->next) {
- g_warning ("conversion to IMAP SEARCH string failed");
- retval = NULL;
- g_list_foreach (list, (GFunc)g_free, NULL);
- } else {
- retval = list->data;
- }
-
- g_list_free (list);
-
- return retval;
-}
-
char *
imap_create_flag_list (guint32 flags)
{
diff --git a/camel/providers/imap/camel-imap-utils.h b/camel/providers/imap/camel-imap-utils.h
index e7b009f426..015ad91e16 100644
--- a/camel/providers/imap/camel-imap-utils.h
+++ b/camel/providers/imap/camel-imap-utils.h
@@ -38,8 +38,6 @@ char *imap_next_word (const char *buf);
#define IMAP_LIST_FLAG_UNMARKED (1 << 3)
gboolean imap_parse_list_response (const char *buf, int *flags, char *sep, char **folder);
-char *imap_translate_sexp (const char *expression);
-
char *imap_create_flag_list (guint32 flags);
guint32 imap_parse_flag_list (const char *flag_list);