diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-10-12 21:48:36 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-10-12 21:48:36 +0800 |
commit | 80237e0c26dd375b0269dc2099d49fc3cd50a4f2 (patch) | |
tree | 8083431b7966dc91fd725b599d1366009bbc518e /mail | |
parent | 1deca02b41aae9bf2632ea1420cc900fcf41531d (diff) | |
download | gsoc2013-evolution-80237e0c26dd375b0269dc2099d49fc3cd50a4f2.tar gsoc2013-evolution-80237e0c26dd375b0269dc2099d49fc3cd50a4f2.tar.gz gsoc2013-evolution-80237e0c26dd375b0269dc2099d49fc3cd50a4f2.tar.bz2 gsoc2013-evolution-80237e0c26dd375b0269dc2099d49fc3cd50a4f2.tar.lz gsoc2013-evolution-80237e0c26dd375b0269dc2099d49fc3cd50a4f2.tar.xz gsoc2013-evolution-80237e0c26dd375b0269dc2099d49fc3cd50a4f2.tar.zst gsoc2013-evolution-80237e0c26dd375b0269dc2099d49fc3cd50a4f2.zip |
Duh, fix the test for the folder name, strstr != strcmp is it.
2000-10-12 Not Zed <NotZed@HelixCode.com>
* message-list.c (message_list_setup_etable): Duh, fix the test
for the folder name, strstr != strcmp is it.
2000-10-10 Not Zed <NotZed@HelixCode.com>
* message-list.c (folder_to_cachename): Removed, changed callers
to use mail_config_folder_to_cachename instead.
* mail-config.c (mail_config_folder_to_cachename): New utility
function to get a cache name for a folder.
* mail-tools.c (mail_tool_do_movemail): Changed to return the path
to the mbox, rather than opening a folder of it.
* mail-ops.c (mail_incorporate_messages): Dont bother making the
pseudo messageinfo, filder_driver_filter_message will do it for
us.
(report_status): Callback to report status of filtering operation.
(do_fetch_mail): Changed significantly - for the api changes to
the filtering system. Also now incorporates a mailbox file
directly, without having to import it into a camel folder first.
(mail_incorporate_messages): Removed entirely, no longer needed.
* mail-vfolder.c (vfolder_refresh): Fix for context api changes.
(vfolder_uri_to_folder): Likewise.
* folder-browser-factory.c (create_ondemand_hooks): Changed for
api changes. Also only adds demand filters to the menu (fixed a
small logic bug).
svn path=/trunk/; revision=5883
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 33 | ||||
-rw-r--r-- | mail/folder-browser-factory.c | 2 | ||||
-rw-r--r-- | mail/mail-config.c | 16 | ||||
-rw-r--r-- | mail/mail-config.h | 3 | ||||
-rw-r--r-- | mail/mail-ops.c | 207 | ||||
-rw-r--r-- | mail/mail-tools.c | 11 | ||||
-rw-r--r-- | mail/mail-tools.h | 4 | ||||
-rw-r--r-- | mail/mail-vfolder.c | 4 | ||||
-rw-r--r-- | mail/message-list.c | 34 |
9 files changed, 229 insertions, 85 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 4803929966..2bb572baa0 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,35 @@ +2000-10-12 Not Zed <NotZed@HelixCode.com> + + * message-list.c (message_list_setup_etable): Duh, fix the test + for the folder name, strstr != strcmp is it. + +2000-10-10 Not Zed <NotZed@HelixCode.com> + + * message-list.c (folder_to_cachename): Removed, changed callers + to use mail_config_folder_to_cachename instead. + + * mail-config.c (mail_config_folder_to_cachename): New utility + function to get a cache name for a folder. + + * mail-tools.c (mail_tool_do_movemail): Changed to return the path + to the mbox, rather than opening a folder of it. + + * mail-ops.c (mail_incorporate_messages): Dont bother making the + pseudo messageinfo, filder_driver_filter_message will do it for + us. + (report_status): Callback to report status of filtering operation. + (do_fetch_mail): Changed significantly - for the api changes to + the filtering system. Also now incorporates a mailbox file + directly, without having to import it into a camel folder first. + (mail_incorporate_messages): Removed entirely, no longer needed. + + * mail-vfolder.c (vfolder_refresh): Fix for context api changes. + (vfolder_uri_to_folder): Likewise. + + * folder-browser-factory.c (create_ondemand_hooks): Changed for + api changes. Also only adds demand filters to the menu (fixed a + small logic bug). + 2000-10-11 Chris Toshok <toshok@helixcode.com> * subscribe-dialog.c (folder_etree_value_at): special case for @@ -159,6 +191,7 @@ `mail-search-dialogue.h' and `mail-search-dialogue.c' as NotZed forgot to put them into CVS. +>>>>>>> 1.631 2000-10-06 Not Zed <NotZed@HelixCode.com> * mail-search-dialogue.c: New widget, full search dialogue for diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index 1bc493b381..31f61cd786 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -71,7 +71,7 @@ create_ondemand_hooks (FolderBrowser *fb, BonoboUIComponent *uic) system = EVOLUTION_DATADIR "/evolution/filtertypes.xml"; fb->filter_context = filter_context_new(); rule_context_load ((RuleContext *) fb->filter_context, system, user); - while ( (rule = rule_context_next_rule((RuleContext *)fb->filter_context, rule)) != NULL ) { + while ( (rule = rule_context_next_rule((RuleContext *)fb->filter_context, rule, FILTER_SOURCE_DEMAND)) != NULL ) { register_ondemand((RuleContext *)fb->filter_context, rule, fb, uic); } g_free (user); diff --git a/mail/mail-config.c b/mail/mail-config.c index fc8fa7203e..b8d3058181 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -550,6 +550,22 @@ mail_config_add_news (MailConfigService *news) config->news = g_slist_append (config->news, new_news); } +char * +mail_config_folder_to_cachename(CamelFolder *folder, const char *prefix) +{ + char *url, *p, *filename; + + url = camel_url_to_string(CAMEL_SERVICE(folder->parent_store)->url, FALSE); + for (p = url; *p; p++) { + if (!isprint((unsigned char)*p) || strchr(" /'\"`&();|<>${}!", *p)) + *p = '_'; + } + + filename = g_strdup_printf("%s/config/%s%s", evolution_dir, prefix, url); + g_free(url); + return filename; +} + diff --git a/mail/mail-config.h b/mail/mail-config.h index f716373dce..f6ee59e3b0 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -83,6 +83,9 @@ MailConfigService *mail_config_get_default_news (void); GSList *mail_config_get_news (void); void mail_config_add_news (MailConfigService *source); +/* static utility functions */ +char *mail_config_folder_to_cachename(CamelFolder *folder, const char *prefix); + #endif diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 4a784d3688..d74f343134 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -98,6 +98,8 @@ mail_load_evolution_rule_context () return fc; } +#if 0 +/* to be removed */ static void mail_incorporate_messages (CamelFolder *folder, fetch_mail_input_t *input, @@ -158,7 +160,7 @@ mail_incorporate_messages (CamelFolder *folder, /* get/filter the new messages */ for (i = 0; i < uids->len; i++) { CamelMimeMessage *message; - CamelMessageInfo *info; + const CamelMessageInfo *info; gboolean free_info; gboolean last_message = (i+1 == uids->len); time_t now; @@ -176,19 +178,13 @@ mail_incorporate_messages (CamelFolder *folder, if (camel_exception_is_set (ex)) continue; - if (camel_folder_has_summary_capability (folder)) { - info = (CamelMessageInfo *) camel_folder_get_message_info (folder, uids->pdata[i]); - free_info = FALSE; - } else { - info = g_new0 (CamelMessageInfo, 1); - free_info = TRUE; - } - - filter_driver_run (filter, message, info, input->destination, - FILTER_SOURCE_INCOMING, logfile, ex); + if (camel_folder_has_summary_capability (folder)) + info = camel_folder_get_message_info (folder, uids->pdata[i]); + else + info = NULL; - if (free_info) - camel_message_info_free (info); + filter_driver_filter_message(filter, message, info, input->destination, + FILTER_SOURCE_INCOMING, logfile, ex); /* we don't care if it was filtered or not here because no matter what it's been copied to at least 1 folder - even if it's just @@ -228,14 +224,40 @@ mail_incorporate_messages (CamelFolder *folder, data->empty = FALSE; } +#endif + +static void +mail_op_report_status(FilterDriver *driver, enum filter_status_t status, const char *desc, CamelMimeMessage *msg, void *data) +{ + printf("reporting status: %s\n", desc); + + /* FIXME: make it work */ + switch(status) { + case FILTER_STATUS_START: + mail_op_set_message (_("Retrieving messages : %s"), desc); + break; + case FILTER_STATUS_END: + break; + case FILTER_STATUS_ACTION: + break; + default: + break; + } + + /* use the 'standard' logging function, data is already the fd */ + if (data) + filter_driver_status_log(driver, status, desc, msg, data); +} static void do_fetch_mail (gpointer in_data, gpointer op_data, CamelException *ex) { fetch_mail_input_t *input = (fetch_mail_input_t *) in_data; fetch_mail_data_t *data = (fetch_mail_data_t *) op_data; - CamelFolder *folder = NULL; - + FilterContext *fc; + FilterDriver *filter; + FILE *logfile = NULL; + /* If using IMAP, don't do anything... */ if (!strncmp (input->source_url, "imap:", 5)) { data->empty = FALSE; @@ -248,31 +270,82 @@ do_fetch_mail (gpointer in_data, gpointer op_data, CamelException *ex) if (input->destination == NULL) return; } - - if (!strncmp (input->source_url, "mbox:", 5)) - folder = mail_tool_do_movemail (input->source_url, ex); - else - folder = mail_tool_get_inbox (input->source_url, ex); - - if (folder == NULL) { - /* This happens with an IMAP source and on error - * and on "no new mail" - */ - camel_object_unref (CAMEL_OBJECT (input->destination)); - input->destination = NULL; - data->empty = TRUE; - return; + + /* setup filter driver */ + fc = mail_load_evolution_rule_context(); + filter = filter_driver_new(fc, mail_tool_filter_get_folder_func, 0); + filter_driver_set_default_folder(filter, input->destination); + + if (TRUE /* perform_logging */) { + char *filename = g_strdup_printf ("%s/evolution-filter-log", evolution_dir); + logfile = fopen (filename, "a+"); + g_free (filename); } - + filter_driver_set_status_func(filter, mail_op_report_status, logfile); + + /* why on earth we 'up' a lock to get it, ... */ mail_tool_camel_lock_up (); - if (camel_folder_get_message_count (folder) == 0) - data->empty = TRUE; - else - mail_incorporate_messages (folder, input, data, ex); + + camel_folder_freeze(input->destination); + + if (!strncmp (input->source_url, "mbox:", 5)) { + char *path = mail_tool_do_movemail (input->source_url, ex); + + if (path && !camel_exception_is_set(ex)) { + filter_driver_filter_mbox(filter, path, FILTER_SOURCE_INCOMING, ex); + + /* ok? zap the output file */ + if (!camel_exception_is_set(ex)) { + unlink(path); + } + } + g_free(path); + } else { + CamelFolder *folder = mail_tool_get_inbox (input->source_url, ex); + + if (folder) { + if (camel_folder_get_message_count (folder) > 0) { + GPtrArray *uids, *new_uids = NULL; + CamelUIDCache *cache = NULL; + + uids = camel_folder_get_uids(folder); + if (input->keep_on_server) { + char *cachename = mail_config_folder_to_cachename(folder, "cache-"); + + cache = camel_uid_cache_new(cachename); + if (cache) { + new_uids = camel_uid_cache_get_new_uids(cache, uids); + camel_folder_free_uids(folder, uids); + uids = new_uids; + } + } + filter_driver_filter_folder(filter, folder, FILTER_SOURCE_INCOMING, uids, !input->keep_on_server, ex); + if (new_uids) { + camel_uid_cache_free_uids(new_uids); + if (!camel_exception_is_set(ex)) + camel_uid_cache_save(cache); + camel_uid_cache_destroy(cache); + } else { + camel_folder_free_uids(folder, uids); + } + } else { + data->empty = TRUE; + } + camel_object_unref (CAMEL_OBJECT (folder)); + } else { + data->empty = TRUE; + } + } + + if (logfile) + fclose(logfile); + + camel_folder_thaw(input->destination); mail_tool_camel_lock_down (); - - camel_object_unref (CAMEL_OBJECT (folder)); + + /*camel_object_unref (CAMEL_OBJECT (input->destination));*/ + gtk_object_unref((GtkObject *)filter); } static void @@ -328,6 +401,9 @@ mail_do_fetch_mail (const gchar *source_url, gboolean keep_on_server, /* ** FILTER ON DEMAND ********************************************************** */ +/* why do we have this separate code, it is basically a copy of the code above, + should be consolidated */ + typedef struct filter_ondemand_input_s { FilterContext *context; @@ -360,20 +436,56 @@ static void do_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex) { filter_ondemand_input_t *input = (filter_ondemand_input_t *) in_data; + FilterDriver *driver; + GPtrArray *uids, *new_uids; + char *filename; + FILE *logfile = NULL; + int i; mail_tool_camel_lock_up (); - if (camel_folder_get_message_count (input->source) != 0) { - FilterDriver *driver; - GPtrArray *uids; - char *filename; - FILE *logfile; - int i; - - uids = camel_folder_get_uids (input->source); - - camel_folder_freeze (input->source); + if (camel_folder_get_message_count (input->source) == 0) { + mail_tool_camel_lock_down(); + return; + } + + /* setup filter driver */ + driver = filter_driver_new (input->context, mail_tool_filter_get_folder_func, NULL); + /* -- we want no default destination this time */ + if (TRUE /* perform_logging */) { + filename = g_strdup_printf ("%s/evolution-filter-log", evolution_dir); + logfile = fopen (filename, "a+"); + g_free (filename); + } + filter_driver_set_status_func(driver, mail_op_report_status, logfile); + /* build the uid list - all uid's not deleted already */ + uids = camel_folder_get_uids (input->source); + new_uids = g_ptr_array_new(); + for (i=0;i<uids->len;i++) { + CamelMessageInfo *info = camel_folder_get_message_info(input->source, uids->pdata[i]); + if (info && (info->flags & CAMEL_MESSAGE_DELETED) == 0) { + g_ptr_array_add(new_uids, uids->pdata[i]); + } + } + + /* run the filter */ + filter_driver_filter_folder(driver, input->source, FILTER_SOURCE_DEMAND, new_uids, TRUE, ex); + + camel_folder_free_uids (input->source, uids); + g_ptr_array_free(new_uids, TRUE); + + if (logfile) + fclose(logfile); + + gtk_object_unref((GtkObject *)driver); + mail_tool_camel_lock_down (); +} + +#if 0 +/* to be removed, old version */ +{ + { + - driver = filter_driver_new (input->context, mail_tool_filter_get_folder_func, NULL); /* FIXME: find out if we want to log or not - config option */ if (TRUE /* perform_logging */) { @@ -442,6 +554,7 @@ do_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex) } mail_tool_camel_lock_down (); } +#endif static void cleanup_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex) diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 2646a8ad41..ccbcce3d1d 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -178,7 +178,8 @@ mail_tool_get_inbox (const gchar *url, CamelException *ex) } -CamelFolder * +/* why is this function so stupidly complex when allthe work is done elsehwere? */ +char * mail_tool_do_movemail (const gchar *source_url, CamelException *ex) { gchar *dest_url; @@ -232,18 +233,14 @@ mail_tool_do_movemail (const gchar *source_url, CamelException *ex) return NULL; } - g_free (dest_path); - if (camel_exception_is_set (ex)) { g_free (dest_url); + g_free (dest_path); return NULL; } - /* Get the CamelFolder for our dest_path. */ - - ret = mail_tool_get_folder_from_urlname (dest_url, "movemail", TRUE, ex); g_free (dest_url); - return ret; + return dest_path; } void diff --git a/mail/mail-tools.h b/mail/mail-tools.h index ee2af84a5a..1178921bb7 100644 --- a/mail/mail-tools.h +++ b/mail/mail-tools.h @@ -54,8 +54,8 @@ CamelFolder *mail_tool_get_local_inbox (CamelException *ex); CamelFolder *mail_tool_get_inbox (const gchar *url, CamelException *ex); /* Does a camel_movemail into the local movemail folder - * and returns the movemail folder that was created. */ -CamelFolder * + * and returns the path to the new movemail folder that was created. which shoudl be freed later */ +char * mail_tool_do_movemail (const gchar *source_url, CamelException *ex); /* Transfers all the messages from source into dest; diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index a26c2986fc..606a5a0b64 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -74,7 +74,7 @@ vfolder_refresh(void) char *uri, *path; rule = NULL; - while ( (rule = rule_context_next_rule((RuleContext *)context, rule)) ) { + while ( (rule = rule_context_next_rule((RuleContext *)context, rule, NULL)) ) { info = vfolder_find(rule->name); g_string_truncate(expr, 0); filter_rule_build_code(rule, expr); @@ -189,7 +189,7 @@ vfolder_uri_to_folder(const char *uri, CamelException *ex) d(printf("Opening vfolder: %s\n", uri)); - rule = (VfolderRule *)rule_context_find_rule((RuleContext *)context, info->name); + rule = (VfolderRule *)rule_context_find_rule((RuleContext *)context, info->name, NULL); storeuri = g_strdup_printf("vfolder:%s/vfolder/%s", evolution_dir, info->name); foldername = g_strdup_printf("mbox?%s", info->query); diff --git a/mail/message-list.c b/mail/message-list.c index 2305a8d47a..7cfd7397d7 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -87,7 +87,6 @@ static void select_msg (MessageList *message_list, gint row); static char *filter_date (const void *data); static void nuke_uids (GtkObject *o); -static char *folder_to_cachename(CamelFolder *folder, const char *prefix); static void save_tree_state(MessageList *ml); static struct { @@ -843,7 +842,7 @@ save_header_state(MessageList *ml) || ml->etable == NULL) return; - filename = folder_to_cachename(ml->folder, "et-header-"); + filename = mail_config_folder_to_cachename(ml->folder, "et-header-"); e_table_scrolled_save_state(E_TABLE_SCROLLED(ml->etable), filename); g_free(filename); } @@ -883,17 +882,17 @@ message_list_setup_etable(MessageList *message_list) char *path; struct stat st; - path = folder_to_cachename(message_list->folder, "et-header-"); + path = mail_config_folder_to_cachename(message_list->folder, "et-header-"); if (stat(path, &st) == 0 && st.st_size > 0 && S_ISREG(st.st_mode)) { e_table_scrolled_load_state(E_TABLE_SCROLLED(message_list->etable), path); } else { /* I wonder if there's a better way to do this ...? */ name = camel_service_get_name((CAMEL_SERVICE(message_list->folder->parent_store)), TRUE); printf("folder name is '%s'\n", name); - if (strstr(name, "/Drafts") - || strstr(name, "/Outbox") - || strstr(name, "/Sent")) { - e_table_scrolled_set_state(E_TABLE_SCROLLED(message_list->etable), state); + if (strstr(name, "/Drafts") != NULL + || strstr(name, "/Outbox") != NULL + || strstr(name, "/Sent") != NULL) { + e_table_scrolled_set_specification(E_TABLE_SCROLLED(message_list->etable), spec); } g_free(name); } @@ -984,7 +983,6 @@ message_list_destroy (GtkObject *object) } gtk_object_unref (GTK_OBJECT (message_list->table_model)); - gtk_object_unref (GTK_OBJECT (message_list->etable)); if (message_list->uid_rowmap) { @@ -1126,22 +1124,6 @@ clear_tree (MessageList *ml) e_tree_model_node_set_expanded (etm, ml->tree_root, TRUE); } -static char * -folder_to_cachename(CamelFolder *folder, const char *prefix) -{ - char *url, *p, *filename; - - url = camel_url_to_string(CAMEL_SERVICE(folder->parent_store)->url, FALSE); - for (p = url; *p; p++) { - if (!isprint((unsigned char)*p) || strchr(" /'\"`&();|<>${}!", *p)) - *p = '_'; - } - - filename = g_strdup_printf("%s/config/%s%s", evolution_dir, prefix, url); - g_free(url); - return filename; -} - /* we save the node id to the file if the node should be closed when we start up. We only save nodeid's for messages with children */ static void @@ -1181,7 +1163,7 @@ load_tree_state(MessageList *ml) int len; result = g_hash_table_new(g_str_hash, g_str_equal); - filename = folder_to_cachename(ml->folder, "treestate-"); + filename = mail_config_folder_to_cachename(ml->folder, "treestate-"); in = fopen(filename, "r"); if (in) { while (fgets(linebuf, sizeof(linebuf), in) != NULL) { @@ -1205,7 +1187,7 @@ save_tree_state(MessageList *ml) ETreePath *node; FILE *out; - filename = folder_to_cachename(ml->folder, "treestate-"); + filename = mail_config_folder_to_cachename(ml->folder, "treestate-"); out = fopen(filename, "w"); if (out) { node = e_tree_model_get_root((ETreeModel *)ml->table_model); |