2008-11-27 [colin] 3.6.1cvs47
[claws.git] / src / filtering.c
index 732d2f95194e9d0d75b1e94d53dc246b9df2699c..c8ffe7f855e864c9505001b244b1069445d98e1d 100644 (file)
@@ -39,8 +39,6 @@
 #include "tags.h"
 #include "log.h"
 
-#define PREFSBUFSIZE           1024
-
 GSList * pre_global_processing = NULL;
 GSList * post_global_processing = NULL;
 GSList * filtering_rules = NULL;
@@ -176,6 +174,7 @@ void filteringprop_free(FilteringProp * prop)
         for (tmp = prop->action_list ; tmp != NULL ; tmp = tmp->next) {
                 filteringaction_free(tmp->data);
         }
+       g_slist_free(prop->action_list);
        g_free(prop->name);
        g_free(prop);
 }
@@ -468,7 +467,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
                        gint errors = 0;
 
                        if (!addressbook_peek_folder_exists(action->destination, &book, &folder)) {
-                               g_warning("addressbook folder not found '%s'\n", action->destination);
+                               g_warning("addressbook folder not found '%s'\n", action->destination?action->destination:"(null)");
                                return FALSE;
                        }
                        if (!book) {
@@ -518,7 +517,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info)
                                g_slist_free(address_list);
                                end_address_completion();
                        } else {
-                               g_warning("header '%s' not set or empty\n", action->header);
+                               g_warning("header '%s' not set or empty\n", action->header?action->header:"(null)");
                        }
                        return (errors == 0);
                }
@@ -587,7 +586,7 @@ static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *inf
                                                log_status_ok(LOG_DEBUG_FILTERING,
                                                                _("rule is account-based [id=%d, name='%s'], "
                                                                "matching the account currently used to retrieve messages\n"),
-                                                               ac_prefs->account_id, ac_prefs->account_name);
+                                                               ac_prefs->account_id, ac_prefs?ac_prefs->account_name:_("NON_EXISTENT"));
                                        }
                                }
                        }
@@ -604,8 +603,8 @@ static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *inf
                                                log_status_skip(LOG_DEBUG_FILTERING,
                                                                _("rule is account-based [id=%d, name='%s'], "
                                                                "not matching the account currently used to retrieve messages [id=%d, name='%s']\n"),
-                                                               filtering->account_id, account->account_name,
-                                                               ac_prefs->account_id, ac_prefs->account_name);
+                                                               filtering->account_id, account?account->account_name:_("NON_EXISTENT"),
+                                                               ac_prefs->account_id, ac_prefs?ac_prefs->account_name:_("NON_EXISTENT"));
                                        }
                                }
                        }
@@ -629,7 +628,7 @@ static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *inf
                                                log_status_ok(LOG_DEBUG_FILTERING,
                                                                _("rule is account-based [id=%d, name='%s'], "
                                                                "but all rules are applied on user request\n"),
-                                                               filtering->account_id, account->account_name);
+                                                               filtering->account_id, account?account->account_name:_("NON_EXISTENT"));
                                        }
                                }
                        }
@@ -647,7 +646,7 @@ static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *inf
                                                log_status_skip(LOG_DEBUG_FILTERING,
                                                                _("rule is account-based [id=%d, name='%s'], "
                                                                "skipped on user request\n"),
-                                                               filtering->account_id, account->account_name);
+                                                               filtering->account_id, account?account->account_name:_("NON_EXISTENT"));
                                        } else {
                                                log_status_skip(LOG_DEBUG_FILTERING,
                                                                _("rule is account-based, "
@@ -674,8 +673,8 @@ static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *inf
                                                log_status_skip(LOG_DEBUG_FILTERING,
                                                                _("rule is account-based [id=%d, name='%s'], "
                                                                "not matching current account [id=%d, name='%s']\n"),
-                                                               filtering->account_id, account->account_name,
-                                                               cur_account->account_id, cur_account->account_name);
+                                                               filtering->account_id, account?account->account_name:_("NON_EXISTENT"),
+                                                               cur_account->account_id, cur_account?cur_account->account_name:_("NON_EXISTENT"));
                                        } else {
                                                log_status_skip(LOG_DEBUG_FILTERING,
                                                                _("rule is account-based, "
@@ -692,8 +691,8 @@ static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *inf
                                                        log_status_ok(LOG_DEBUG_FILTERING,
                                                                        _("rule is account-based [id=%d, name='%s'], "
                                                                        "current account [id=%d, name='%s']\n"),
-                                                                       account->account_id, account->account_name,
-                                                                       cur_account->account_id, cur_account->account_name);
+                                                                       account->account_id, account?account->account_name:_("NON_EXISTENT"),
+                                                                       cur_account->account_id, cur_account?cur_account->account_name:_("NON_EXISTENT"));
                                                }
                                        }
                                }
@@ -794,6 +793,7 @@ static gboolean filter_msginfo(GSList * filtering_list, MsgInfo * info, PrefsAcc
                                                _("processing rule <unnamed> [ %s ]\n"),
                                                buf);
                                }
+                               g_free(buf);
                        }
 
                        if (filtering_match_condition(filtering, info, ac_prefs)) {
@@ -850,7 +850,7 @@ gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount* a
 
        if (prefs_common.enable_filtering_debug) {
                gchar *tmp = _("undetermined");
-
+#ifndef G_OS_WIN32
                switch (context) {
                case FILTERING_INCORPORATION:
                        tmp = _("incorporation");
@@ -876,6 +876,9 @@ gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount* a
                        debug_filtering_session = FALSE;
                        break;
                }
+#else
+               debug_filtering_session = FALSE;
+#endif
                if (debug_filtering_session) {
                        gchar *file = procmsg_get_message_file_path(info);
                        gchar *spc = g_strnfill(LOG_TIME_LEN + 1, ' ');