diff options
author | Not Zed <NotZed@Ximian.com> | 2004-03-03 14:36:44 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-03-03 14:36:44 +0800 |
commit | d6443cd2ca8b523e941d9c184b34a8bcccdc7cc1 (patch) | |
tree | 6bf1db2eb68dde7ada301ade040777e5aef4dcb7 /camel | |
parent | 3181ad6bfa6bc0d5f0049a1fe510ec94f186ebe5 (diff) | |
download | gsoc2013-evolution-d6443cd2ca8b523e941d9c184b34a8bcccdc7cc1.tar gsoc2013-evolution-d6443cd2ca8b523e941d9c184b34a8bcccdc7cc1.tar.gz gsoc2013-evolution-d6443cd2ca8b523e941d9c184b34a8bcccdc7cc1.tar.bz2 gsoc2013-evolution-d6443cd2ca8b523e941d9c184b34a8bcccdc7cc1.tar.lz gsoc2013-evolution-d6443cd2ca8b523e941d9c184b34a8bcccdc7cc1.tar.xz gsoc2013-evolution-d6443cd2ca8b523e941d9c184b34a8bcccdc7cc1.tar.zst gsoc2013-evolution-d6443cd2ca8b523e941d9c184b34a8bcccdc7cc1.zip |
fun dun diddley un fun. Since we're writing a const buffer, we need to
2004-03-03 Not Zed <NotZed@Ximian.com>
* camel-stream-filter.c (do_write, do_write): fun dun diddley un
fun. Since we're writing a const buffer, we need to copy it
first. See #54937.
2004-02-27 Not Zed <NotZed@Ximian.com>
** See bug #54755.
* camel-vtrash-folder.c (vtrash_append_message)
(vtrash_transfer_messages_to): error/fail out if the user tries to
copy messages to the trash.
(vtrash_transfer_messages_to): use the destination bit not the
source bit for moving messages to a vtrash folder.
* camel-gpg-context.c (gpg_ctx_parse_status): ignore NODATA
response, otherwise we abort in a meaningless way. See #52939.
* providers/imap/camel-imap-utils.c: use g_ascii_str[n]casecmp
everywhere.
* providers/imap/camel-imap-utils.c (imap_body_decode): fix the
sense of the nil check for the subtype of a mutlipart. See
#53355.
2004-02-26 Not Zed <NotZed@Ximian.com>
* camel-session.c (camel_session_check_junk_for_imap)
(camel_session_set_check_junk_for_imap): removed.
* providers/imap/camel-imap-provider.c: Add filter_junk and
filter_junk_inbox options to the receive option page.
* providers/imap/camel-imap-store.c (imap_setv, imap_getv): handle
FILTER_JUNK and FILTER_JUNK_INBOX parameters.
(imap_setv): conver to switch rather than if statement.
(construct): handle url args for filter_junk and
filter_junk_inbox.
* providers/imap/camel-imap-folder.c (camel_imap_folder_new): Set
the folder's flags based on the stores junk settings.
(imap_update_summary): remove the test for
session_check_junk_for_imap, its handled per-store now.
* camel-folder.c (folder_changed): only check for FILTER_RECENT or
FILTER_JUNK to see if we need to do filtering.
* camel-folder.h (CAMEL_FOLDER_FILTER_JUNK): renamed from
CAMEL_FOLDER_SUPRESS_JUNK_TEST (and obviously inverted logic).
svn path=/trunk/; revision=24942
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 50 | ||||
-rw-r--r-- | camel/camel-filter-search.c | 5 | ||||
-rw-r--r-- | camel/camel-folder.c | 2 | ||||
-rw-r--r-- | camel/camel-folder.h | 2 | ||||
-rw-r--r-- | camel/camel-session.c | 29 | ||||
-rw-r--r-- | camel/camel-session.h | 10 | ||||
-rw-r--r-- | camel/camel-stream-filter.c | 42 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 17 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-provider.c | 4 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 39 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.h | 9 |
11 files changed, 130 insertions, 79 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 84adfa5ec4..273729d63e 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,53 @@ +2004-03-03 Not Zed <NotZed@Ximian.com> + + * camel-stream-filter.c (do_write, do_write): fun dun diddley un + fun. Since we're writing a const buffer, we need to copy it + first. See #54937. + +2004-02-27 Not Zed <NotZed@Ximian.com> + + ** See bug #54755. + + * camel-vtrash-folder.c (vtrash_append_message) + (vtrash_transfer_messages_to): error/fail out if the user tries to + copy messages to the trash. + (vtrash_transfer_messages_to): use the destination bit not the + source bit for moving messages to a vtrash folder. + + * camel-gpg-context.c (gpg_ctx_parse_status): ignore NODATA + response, otherwise we abort in a meaningless way. See #52939. + + * providers/imap/camel-imap-utils.c: use g_ascii_str[n]casecmp + everywhere. + * providers/imap/camel-imap-utils.c (imap_body_decode): fix the + sense of the nil check for the subtype of a mutlipart. See + #53355. + +2004-02-26 Not Zed <NotZed@Ximian.com> + + * camel-session.c (camel_session_check_junk_for_imap) + (camel_session_set_check_junk_for_imap): removed. + + * providers/imap/camel-imap-provider.c: Add filter_junk and + filter_junk_inbox options to the receive option page. + + * providers/imap/camel-imap-store.c (imap_setv, imap_getv): handle + FILTER_JUNK and FILTER_JUNK_INBOX parameters. + (imap_setv): conver to switch rather than if statement. + (construct): handle url args for filter_junk and + filter_junk_inbox. + + * providers/imap/camel-imap-folder.c (camel_imap_folder_new): Set + the folder's flags based on the stores junk settings. + (imap_update_summary): remove the test for + session_check_junk_for_imap, its handled per-store now. + + * camel-folder.c (folder_changed): only check for FILTER_RECENT or + FILTER_JUNK to see if we need to do filtering. + + * camel-folder.h (CAMEL_FOLDER_FILTER_JUNK): renamed from + CAMEL_FOLDER_SUPRESS_JUNK_TEST (and obviously inverted logic). + 2004-03-02 Jeffrey Stedfast <fejj@ximian.com> * providers/local/camel-mbox-summary.c diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c index c2edbe7a95..e970aa41c1 100644 --- a/camel/camel-filter-search.c +++ b/camel/camel-filter-search.c @@ -610,12 +610,13 @@ junk_test (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessage { ESExpResult *r; gboolean retval = FALSE; - + if (fms->session->junk_plugin != NULL) { retval = camel_junk_plugin_check_junk (fms->session->junk_plugin, camel_filter_search_get_message (fms, f)); - + printf("junk filter => %s\n", retval ? "*JUNK*" : "clean"); } + r = e_sexp_result_new (f, ESEXP_RES_BOOL); r->value.number = retval; diff --git a/camel/camel-folder.c b/camel/camel-folder.c index cac884e5c6..85dcb0a3d4 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -1647,7 +1647,7 @@ folder_changed (CamelObject *obj, gpointer event_data) CamelSession *session = ((CamelService *)folder->parent_store)->session; CamelFilterDriver *driver = NULL; - if (((folder->folder_flags & CAMEL_FOLDER_FILTER_RECENT) || (camel_session_check_junk (session) && !(folder->folder_flags & CAMEL_FOLDER_SUPRESS_JUNK_TEST))) + if ((folder->folder_flags & (CAMEL_FOLDER_FILTER_RECENT|CAMEL_FOLDER_FILTER_JUNK)) && changed->uid_recent->len > 0) driver = camel_session_get_filter_driver(session, (folder->folder_flags & CAMEL_FOLDER_FILTER_RECENT) ? FILTER_SOURCE_INCOMING : FILTER_SOURCE_JUNKTEST, NULL); diff --git a/camel/camel-folder.h b/camel/camel-folder.h index 74fc5aa205..7380ecb7a6 100644 --- a/camel/camel-folder.h +++ b/camel/camel-folder.h @@ -104,7 +104,7 @@ struct _CamelFolder #define CAMEL_FOLDER_HAS_BEEN_DELETED (1<<3) #define CAMEL_FOLDER_IS_TRASH (1<<4) #define CAMEL_FOLDER_IS_JUNK (1<<5) -#define CAMEL_FOLDER_SUPRESS_JUNK_TEST (1<<6) +#define CAMEL_FOLDER_FILTER_JUNK (1<<6) typedef struct { CamelObjectClass parent_class; diff --git a/camel/camel-session.c b/camel/camel-session.c index 69569aef2d..59d6be649c 100644 --- a/camel/camel-session.c +++ b/camel/camel-session.c @@ -662,32 +662,3 @@ camel_session_set_check_junk (CamelSession *session, gboolean check_junk) session->check_junk = check_junk; } - -/** - * camel_session_check_junk_for_imap - * @session: - * - * Do we have to check IMAP incoming messages to be junk? - **/ -gboolean -camel_session_check_junk_for_imap (CamelSession *session) -{ - g_assert(CAMEL_IS_SESSION(session)); - - return session->check_junk_for_imap; -} - -/** - * camel_session_set_check_junk_for_imap: - * @session: - * @check_junk_for_imap: - * - * Set check_junk_for_imap flag, if set, incoming IMAP mail will be checked for being junk. - **/ -void -camel_session_set_check_junk_for_imap (CamelSession *session, gboolean check_junk_for_imap) -{ - g_assert(CAMEL_IS_SESSION(session)); - - session->check_junk_for_imap = check_junk_for_imap; -} diff --git a/camel/camel-session.h b/camel/camel-session.h index 9548a7a5b8..f3f058568b 100644 --- a/camel/camel-session.h +++ b/camel/camel-session.h @@ -64,11 +64,10 @@ struct _CamelSession struct _CamelSessionPrivate *priv; char *storage_path; - gboolean online; - CamelJunkPlugin *junk_plugin; - gboolean check_junk; - gboolean check_junk_for_imap; + + gboolean online:1; + gboolean check_junk:1; }; #ifdef ENABLE_THREADS @@ -170,9 +169,6 @@ CamelFilterDriver *camel_session_get_filter_driver (CamelSession *session, gboolean camel_session_check_junk (CamelSession *session); void camel_session_set_check_junk (CamelSession *session, gboolean check_junk); -gboolean camel_session_check_junk_for_imap (CamelSession *session); -void camel_session_set_check_junk_for_imap (CamelSession *session, - gboolean check_junk_for_imap); #ifdef ENABLE_THREADS struct _CamelSessionThreadOps { diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c index 059a5198f1..e9c5e69f9c 100644 --- a/camel/camel-stream-filter.c +++ b/camel/camel-stream-filter.c @@ -28,7 +28,7 @@ #include <string.h> #include "camel-stream-filter.h" -#define d(x) +#define d(x) x /* use my malloc debugger? */ /*extern void g_check(void *mp);*/ @@ -287,34 +287,42 @@ do_write (CamelStream *stream, const char *buf, size_t n) CamelStreamFilter *filter = (CamelStreamFilter *)stream; struct _CamelStreamFilterPrivate *p = _PRIVATE(filter); struct _filter *f; - size_t presize; - char *buffer = (char *)buf; - size_t len = n; + size_t presize, len, left = n; + char *buffer, realbuffer[READ_SIZE+READ_PAD]; p->last_was_read = FALSE; d(printf ("\n\nWriting: Original content (%s): '", ((CamelObject *)filter->source)->klass->name)); - d(fwrite(buffer, sizeof(char), len, stdout)); + d(fwrite(buf, sizeof(char), n, stdout)); d(printf("'\n")); g_check(p->realbuffer); - f = p->filters; - presize = 0; - while (f) { - camel_mime_filter_filter(f->filter, buffer, len, presize, &buffer, &len, &presize); + while (left) { + /* Sigh, since filters expect non const args, copy the input first, we do this in handy sized chunks */ + len = MIN(READ_SIZE, left); + buffer = realbuffer + READ_PAD; + memcpy(buffer, buf, len); + buf += len; + left -= len; - g_check(p->realbuffer); + f = p->filters; + presize = READ_PAD; + while (f) { + camel_mime_filter_filter(f->filter, buffer, len, presize, &buffer, &len, &presize); - d(printf ("Filtered content (%s): '", ((CamelObject *)f->filter)->klass->name)); - d(fwrite(buffer, sizeof(char), len, stdout)); - d(printf("'\n")); + g_check(p->realbuffer); - f = f->next; - } + d(printf ("Filtered content (%s): '", ((CamelObject *)f->filter)->klass->name)); + d(fwrite(buffer, sizeof(char), len, stdout)); + d(printf("'\n")); - if (camel_stream_write(filter->source, buffer, len) != len) - return -1; + f = f->next; + } + + if (camel_stream_write(filter->source, buffer, len) != len) + return -1; + } g_check(p->realbuffer); diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 838762b304..add0078001 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -257,11 +257,14 @@ camel_imap_folder_new (CamelStore *parent, const char *folder_name, return NULL; } - if (!strcasecmp (folder_name, "INBOX")) { + if (!g_ascii_strcasecmp (folder_name, "INBOX")) { if ((imap_store->parameters & IMAP_PARAM_FILTER_INBOX)) folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT; - if (!camel_session_check_junk_for_imap (CAMEL_SERVICE (parent)->session)) - folder->folder_flags |= CAMEL_FOLDER_SUPRESS_JUNK_TEST; + if ((imap_store->parameters & IMAP_PARAM_FILTER_JUNK)) + folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK; + } else { + if ((imap_store->parameters & (IMAP_PARAM_FILTER_JUNK|IMAP_PARAM_FILTER_JUNK_INBOX)) == (IMAP_PARAM_FILTER_JUNK)) + folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK; } imap_folder->search = camel_imap_search_new(folder_dir); @@ -1234,7 +1237,7 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, CamelImapResponse *response; char *uid; int count; - + count = camel_folder_summary_count (folder->summary); response = do_append (folder, message, info, &uid, ex); if (!response) @@ -2393,12 +2396,6 @@ imap_update_summary (CamelFolder *folder, int exists, } g_ptr_array_free (fetch_data, TRUE); - /* update CAMEL_FOLDER_SUPRESS_JUNK_TEST flag, it may changed in session */ - if (camel_session_check_junk_for_imap (CAMEL_SERVICE (store)->session)) - folder->folder_flags &= ~CAMEL_FOLDER_SUPRESS_JUNK_TEST; - else - folder->folder_flags |= CAMEL_FOLDER_SUPRESS_JUNK_TEST; - /* And add the entries to the summary, etc. */ for (i = 0; i < messages->len; i++) { mi = messages->pdata[i]; diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c index fb7c69766c..62301307ac 100644 --- a/camel/providers/imap/camel-imap-provider.c +++ b/camel/providers/imap/camel-imap-provider.c @@ -62,6 +62,10 @@ CamelProviderConfEntry imap_conf_entries[] = { { CAMEL_PROVIDER_CONF_SECTION_END }, { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL, N_("Apply filters to new messages in INBOX on this server"), "0" }, + { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk", NULL, + N_("Check new messages for Junk contents"), "0" }, + { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk_inbox", "filter_junk", + N_("Only check for Junk messages in the INBOX folder"), "0" }, { CAMEL_PROVIDER_CONF_CHECKBOX, "offline_sync", NULL, N_("Automatically synchronize remote mail locally"), "0" }, { CAMEL_PROVIDER_CONF_END } diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 335b98b4a7..b40c5577be 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -322,6 +322,10 @@ construct (CamelService *service, CamelSession *session, imap_store->parameters |= IMAP_PARAM_FILTER_INBOX; store->flags |= CAMEL_STORE_FILTER_INBOX; } + if (camel_url_get_param (url, "filter_junk")) + imap_store->parameters |= IMAP_PARAM_FILTER_JUNK; + if (camel_url_get_param (url, "filter_junk_inbox")) + imap_store->parameters |= IMAP_PARAM_FILTER_JUNK_INBOX; /* setup/load the store summary */ tmp = alloca(strlen(imap_store->storage_path)+32); @@ -368,15 +372,17 @@ imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args) if ((tag & CAMEL_ARG_TAG) <= CAMEL_IMAP_STORE_ARG_FIRST || (tag & CAMEL_ARG_TAG) >= CAMEL_IMAP_STORE_ARG_FIRST + 100) continue; - - if (tag == CAMEL_IMAP_STORE_NAMESPACE) { + + switch (tag) { + case CAMEL_IMAP_STORE_NAMESPACE: if (strcmp (store->namespace, args->argv[i].ca_str) != 0) { g_free (store->namespace); store->namespace = g_strdup (args->argv[i].ca_str); /* the current imap code will need to do a reconnect for this to take effect */ /*reconnect = TRUE;*/ } - } else if (tag == CAMEL_IMAP_STORE_OVERRIDE_NAMESPACE) { + break; + case CAMEL_IMAP_STORE_OVERRIDE_NAMESPACE: flags = args->argv[i].ca_int ? IMAP_PARAM_OVERRIDE_NAMESPACE : 0; flags |= (store->parameters & ~IMAP_PARAM_OVERRIDE_NAMESPACE); @@ -385,17 +391,28 @@ imap_setv (CamelObject *object, CamelException *ex, CamelArgV *args) /* the current imap code will need to do a reconnect for this to take effect */ /*reconnect = TRUE;*/ } - } else if (tag == CAMEL_IMAP_STORE_CHECK_ALL) { + break; + case CAMEL_IMAP_STORE_CHECK_ALL: flags = args->argv[i].ca_int ? IMAP_PARAM_CHECK_ALL : 0; flags |= (store->parameters & ~IMAP_PARAM_CHECK_ALL); store->parameters = flags; /* no need to reconnect for this option to take effect... */ - } else if (tag == CAMEL_IMAP_STORE_FILTER_INBOX) { + break; + case CAMEL_IMAP_STORE_FILTER_INBOX: flags = args->argv[i].ca_int ? IMAP_PARAM_FILTER_INBOX : 0; flags |= (store->parameters & ~IMAP_PARAM_FILTER_INBOX); store->parameters = flags; /* no need to reconnect for this option to take effect... */ - } else { + break; + case CAMEL_IMAP_STORE_FILTER_JUNK: + flags = args->argv[i].ca_int ? IMAP_PARAM_FILTER_JUNK : 0; + store->parameters = flags | (store->parameters & ~IMAP_PARAM_FILTER_JUNK); + break; + case CAMEL_IMAP_STORE_FILTER_JUNK_INBOX: + flags = args->argv[i].ca_int ? IMAP_PARAM_FILTER_JUNK_INBOX : 0; + store->parameters = flags | (store->parameters & ~IMAP_PARAM_FILTER_JUNK_INBOX); + break; + default: /* error?? */ continue; } @@ -428,21 +445,23 @@ imap_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args) switch (tag) { case CAMEL_IMAP_STORE_NAMESPACE: - /* get the username */ *args->argv[i].ca_str = store->namespace; break; case CAMEL_IMAP_STORE_OVERRIDE_NAMESPACE: - /* get the auth mechanism */ *args->argv[i].ca_int = store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE ? TRUE : FALSE; break; case CAMEL_IMAP_STORE_CHECK_ALL: - /* get the hostname */ *args->argv[i].ca_int = store->parameters & IMAP_PARAM_CHECK_ALL ? TRUE : FALSE; break; case CAMEL_IMAP_STORE_FILTER_INBOX: - /* get the port */ *args->argv[i].ca_int = store->parameters & IMAP_PARAM_FILTER_INBOX ? TRUE : FALSE; break; + case CAMEL_IMAP_STORE_FILTER_JUNK: + *args->argv[i].ca_int = store->parameters & IMAP_PARAM_FILTER_JUNK ? TRUE : FALSE; + break; + case CAMEL_IMAP_STORE_FILTER_JUNK_INBOX: + *args->argv[i].ca_int = store->parameters & IMAP_PARAM_FILTER_JUNK_INBOX ? TRUE : FALSE; + break; default: /* error? */ break; diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h index 7d8a983df6..739a74bc74 100644 --- a/camel/providers/imap/camel-imap-store.h +++ b/camel/providers/imap/camel-imap-store.h @@ -63,19 +63,22 @@ enum { CAMEL_IMAP_STORE_ARG_NAMESPACE, CAMEL_IMAP_STORE_ARG_OVERRIDE_NAMESPACE, CAMEL_IMAP_STORE_ARG_CHECK_ALL, - CAMEL_IMAP_STORE_ARG_FILTER_INBOX + CAMEL_IMAP_STORE_ARG_FILTER_INBOX, + CAMEL_IMAP_STORE_ARG_FILTER_JUNK, + CAMEL_IMAP_STORE_ARG_FILTER_JUNK_INBOX, }; #define CAMEL_IMAP_STORE_NAMESPACE (CAMEL_IMAP_STORE_ARG_NAMESPACE | CAMEL_ARG_STR) #define CAMEL_IMAP_STORE_OVERRIDE_NAMESPACE (CAMEL_IMAP_STORE_ARG_OVERRIDE_NAMESPACE | CAMEL_ARG_INT) #define CAMEL_IMAP_STORE_CHECK_ALL (CAMEL_IMAP_STORE_ARG_CHECK_ALL | CAMEL_ARG_INT) #define CAMEL_IMAP_STORE_FILTER_INBOX (CAMEL_IMAP_STORE_ARG_FILTER_INBOX | CAMEL_ARG_INT) +#define CAMEL_IMAP_STORE_FILTER_JUNK (CAMEL_IMAP_STORE_ARG_FILTER_JUNK | CAMEL_ARG_BOO) +#define CAMEL_IMAP_STORE_FILTER_JUNK_INBOX (CAMEL_IMAP_STORE_ARG_FILTER_JUNK_INBOX | CAMEL_ARG_BOO) /* CamelFolderInfo flags */ #define CAMEL_IMAP_FOLDER_MARKED (1<<16) #define CAMEL_IMAP_FOLDER_UNMARKED (1<<17) - typedef enum { IMAP_LEVEL_UNKNOWN, IMAP_LEVEL_IMAP4, @@ -95,6 +98,8 @@ typedef enum { #define IMAP_PARAM_OVERRIDE_NAMESPACE (1 << 0) #define IMAP_PARAM_CHECK_ALL (1 << 1) #define IMAP_PARAM_FILTER_INBOX (1 << 2) +#define IMAP_PARAM_FILTER_JUNK (1 << 3) +#define IMAP_PARAM_FILTER_JUNK_INBOX (1 << 4) struct _CamelImapStore { CamelDiscoStore parent_object; |