aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/prefs_common.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c
index 4b5759de..238c5dd5 100644
--- a/libsylph/prefs_common.c
+++ b/libsylph/prefs_common.c
@@ -514,8 +514,6 @@ void prefs_common_read_config(void)
prefs_common.online_mode = TRUE;
- prefs_common_junk_filter_list_set();
-
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMAND_HISTORY,
NULL);
if ((fp = g_fopen(path, "rb")) == NULL) {
@@ -568,19 +566,33 @@ static FilterRule *prefs_common_junk_filter_rule_create(gboolean is_manual)
FilterCond *cond;
FilterAction *action;
GSList *cond_list = NULL, *action_list = NULL;
+ gchar *junk_id;
+
+ if (prefs_common.junk_folder)
+ junk_id = g_strdup(prefs_common.junk_folder);
+ else {
+ FolderItem *item;
+ item = folder_get_default_junk();
+ if (!item)
+ return NULL;
+ junk_id = folder_item_get_identifier(item);
+ if (!junk_id)
+ return NULL;
+ }
+
+ debug_print("prefs_common_junk_filter_rule_create: junk folder: %s\n",
+ junk_id);
cond = filter_cond_new(FLT_COND_CMD_TEST, 0, 0, NULL,
prefs_common.junk_classify_cmd);
cond_list = g_slist_append(NULL, cond);
if (prefs_common.delete_junk_on_recv && !is_manual) {
- action = filter_action_new(FLT_ACTION_COPY,
- prefs_common.junk_folder);
+ action = filter_action_new(FLT_ACTION_COPY, junk_id);
action_list = g_slist_append(NULL, action);
action = filter_action_new(FLT_ACTION_DELETE, NULL);
action_list = g_slist_append(action_list, action);
} else {
- action = filter_action_new(FLT_ACTION_MOVE,
- prefs_common.junk_folder);
+ action = filter_action_new(FLT_ACTION_MOVE, junk_id);
action_list = g_slist_append(NULL, action);
}
@@ -596,6 +608,8 @@ static FilterRule *prefs_common_junk_filter_rule_create(gboolean is_manual)
rule = filter_rule_new(_("Junk mail filter"), FLT_OR,
cond_list, action_list);
+ g_free(junk_id);
+
return rule;
}
@@ -603,6 +617,8 @@ void prefs_common_junk_filter_list_set(void)
{
FilterRule *rule;
+ debug_print("prefs_common_junk_filter_list_set\n");
+
if (prefs_common.junk_fltlist) {
filter_rule_list_free(prefs_common.junk_fltlist);
prefs_common.junk_fltlist = NULL;
@@ -612,13 +628,17 @@ void prefs_common_junk_filter_list_set(void)
prefs_common.manual_junk_fltlist = NULL;
}
- if (!prefs_common.junk_classify_cmd || !prefs_common.junk_folder)
+ if (!prefs_common.junk_classify_cmd)
return;
rule = prefs_common_junk_filter_rule_create(FALSE);
+ if (!rule)
+ return;
prefs_common.junk_fltlist = g_slist_append(NULL, rule);
rule = prefs_common_junk_filter_rule_create(TRUE);
+ if (!rule)
+ return;
prefs_common.manual_junk_fltlist = g_slist_append(NULL, rule);
}