2008-09-12 [colin] 3.5.0cvs103
[claws.git] / src / folder_item_prefs.c
index 0c030ce21aa7bbef56dd1d3921ee510083d8880d..1d5e4e7feb3907ef2aefb862343d1d3c2ef6e99a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * 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
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
-/* alfons - all folder item specific settings should migrate into 
- * folderlist.xml!!! the old folderitemrc file will only serve for a few 
- * versions (for compatibility) */
-
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
 FolderItemPrefs tmp_prefs;
 
 static PrefParam param[] = {
-       {"sort_by_number", "FALSE", &tmp_prefs.sort_by_number, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_size", "FALSE", &tmp_prefs.sort_by_size, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_date", "FALSE", &tmp_prefs.sort_by_date, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_from", "FALSE", &tmp_prefs.sort_by_from, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_subject", "FALSE", &tmp_prefs.sort_by_subject, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_by_score", "FALSE", &tmp_prefs.sort_by_score, P_BOOL,
-        NULL, NULL, NULL},
-       {"sort_descending", "FALSE", &tmp_prefs.sort_descending, P_BOOL,
-        NULL, NULL, NULL},
-       /* MIGRATION */  
-       {"request_return_receipt", "", &tmp_prefs.request_return_receipt, P_BOOL,
-        NULL, NULL, NULL},
        {"enable_default_to", "", &tmp_prefs.enable_default_to, P_BOOL,
         NULL, NULL, NULL},
        {"default_to", "", &tmp_prefs.default_to, P_STRING,
@@ -75,7 +54,7 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"default_account", NULL, &tmp_prefs.default_account, P_INT,
         NULL, NULL, NULL},
-#if USE_ASPELL
+#if USE_ENCHANT
        {"enable_default_dictionary", "", &tmp_prefs.enable_default_dictionary, P_BOOL,
         NULL, NULL, NULL},
        {"default_dictionary", NULL, &tmp_prefs.default_dictionary, P_STRING,
@@ -91,25 +70,37 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"enable_processing", "FALSE", &tmp_prefs.enable_processing, P_BOOL,
         NULL, NULL, NULL},
+       {"enable_processing_when_opening", "TRUE", &tmp_prefs.enable_processing_when_opening, P_BOOL,
+        NULL, NULL, NULL},
        {"newmailcheck", "TRUE", &tmp_prefs.newmailcheck, P_BOOL,
         NULL, NULL, NULL},
        {"offlinesync", "FALSE", &tmp_prefs.offlinesync, P_BOOL,
         NULL, NULL, NULL},
+       {"offlinesync_days", "0", &tmp_prefs.offlinesync_days, P_INT,
+        NULL, NULL, NULL},
+       {"remove_old_bodies", "FALSE", &tmp_prefs.remove_old_bodies, P_BOOL,
+        NULL, NULL, NULL},
 
        {"compose_with_format", "FALSE", &tmp_prefs.compose_with_format, P_BOOL,
         NULL, NULL, NULL},
+       {"compose_override_from_format", NULL, &tmp_prefs.compose_override_from_format, P_STRING,
+        NULL, NULL, NULL},
        {"compose_subject_format", NULL, &tmp_prefs.compose_subject_format, P_STRING,
         NULL, NULL, NULL},
        {"compose_body_format", NULL, &tmp_prefs.compose_body_format, P_STRING,
         NULL, NULL, NULL},
        {"reply_with_format", "FALSE", &tmp_prefs.reply_with_format, P_BOOL,
         NULL, NULL, NULL},
+       {"reply_override_from_format", NULL, &tmp_prefs.reply_override_from_format, P_STRING,
+        NULL, NULL, NULL},
        {"reply_quotemark", NULL, &tmp_prefs.reply_quotemark, P_STRING,
         NULL, NULL, NULL},
        {"reply_body_format", NULL, &tmp_prefs.reply_body_format, P_STRING,
         NULL, NULL, NULL},
        {"forward_with_format", "FALSE", &tmp_prefs.forward_with_format, P_BOOL,
         NULL, NULL, NULL},
+       {"forward_override_from_format", NULL, &tmp_prefs.forward_override_from_format, P_STRING,
+        NULL, NULL, NULL},
        {"forward_quotemark", NULL, &tmp_prefs.forward_quotemark, P_STRING,
         NULL, NULL, NULL},
        {"forward_body_format", NULL, &tmp_prefs.forward_body_format, P_STRING,
@@ -132,28 +123,6 @@ void folder_item_prefs_read_config(FolderItem * item)
        g_free(rcpath);
 
        *item->prefs = tmp_prefs;
-
-       /*
-        * MIGRATION: next lines are migration code. the idea is that
-        *            if used regularly, claws folder config ends up
-        *            in the same file as sylpheed-main
-        */
-
-       item->ret_rcpt = tmp_prefs.request_return_receipt ? TRUE : FALSE;
-
-       /* MIGRATION: 0.7.8main+ has persistent sort order. claws had the sort
-        *            order in different members, which is ofcourse a little
-        *            bit phoney. */
-       if (item->sort_key == SORT_BY_NONE) {
-               item->sort_key  = (tmp_prefs.sort_by_number  ? SORT_BY_NUMBER  :
-                                  tmp_prefs.sort_by_size    ? SORT_BY_SIZE    :
-                                  tmp_prefs.sort_by_date    ? SORT_BY_DATE    :
-                                  tmp_prefs.sort_by_from    ? SORT_BY_FROM    :
-                                  tmp_prefs.sort_by_subject ? SORT_BY_SUBJECT :
-                                  tmp_prefs.sort_by_score   ? SORT_BY_SCORE   :
-                                                                SORT_BY_NONE);
-               item->sort_type = tmp_prefs.sort_descending ? SORT_DESCENDING : SORT_ASCENDING;
-       }                                                               
 }
 
 void folder_item_prefs_save_config(FolderItem * item)
@@ -163,25 +132,26 @@ void folder_item_prefs_save_config(FolderItem * item)
        tmp_prefs = * item->prefs;
 
        id = folder_item_get_identifier(item);
-
+       debug_print("saving prefs for %s\n", id?id:"(null)");
        prefs_write_config(param, id, FOLDERITEM_RC);
        g_free(id);
+}
 
-       /* MIGRATION: make sure migrated items are not saved
-        */
+static gboolean folder_item_prefs_save_config_func(GNode *node, gpointer data)
+{
+       FolderItem *item = (FolderItem *) node->data;
+       folder_item_prefs_save_config(item);
+       return FALSE;
+}
+
+void folder_item_prefs_save_config_recursive(FolderItem * item)
+{      
+       g_node_traverse(item->node, G_PRE_ORDER, G_TRAVERSE_ALL,
+                       -1, folder_item_prefs_save_config_func, NULL);
 }
 
 static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
 {
-       prefs->sort_by_number = FALSE;
-       prefs->sort_by_size = FALSE;
-       prefs->sort_by_date = FALSE;
-       prefs->sort_by_from = FALSE;
-       prefs->sort_by_subject = FALSE;
-       prefs->sort_by_score = FALSE;
-       prefs->sort_descending = FALSE;
-
-       prefs->request_return_receipt = FALSE;
        prefs->enable_default_to = FALSE;
        prefs->default_to = NULL;
        prefs->enable_default_reply_to = FALSE;
@@ -192,7 +162,7 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
        prefs->folder_chmod = 0;
        prefs->enable_default_account = FALSE;
        prefs->default_account = 0;
-#if USE_ASPELL
+#if USE_ENCHANT
        prefs->enable_default_dictionary = FALSE;
        prefs->default_dictionary = NULL;
        prefs->enable_default_alt_dictionary = FALSE;
@@ -202,21 +172,26 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
        prefs->color = 0;
 
         prefs->enable_processing = TRUE;
+        prefs->enable_processing_when_opening = TRUE;
        prefs->processing = NULL;
 
        prefs->newmailcheck = TRUE;
        prefs->offlinesync = FALSE;
+       prefs->offlinesync_days = 0;
+       prefs->remove_old_bodies = FALSE;
 
        prefs->compose_with_format = FALSE;
        prefs->compose_subject_format = NULL;
        prefs->compose_body_format = NULL;
+       prefs->compose_override_from_format = NULL;
        prefs->reply_with_format = FALSE;
        prefs->reply_quotemark = NULL;
        prefs->reply_body_format = NULL;
+       prefs->reply_override_from_format = NULL;
        prefs->forward_with_format = FALSE;
        prefs->forward_quotemark = NULL;
        prefs->forward_body_format = NULL;
-
+       prefs->forward_override_from_format = NULL;
        return prefs;
 }
 
@@ -235,10 +210,13 @@ void folder_item_prefs_free(FolderItemPrefs * prefs)
        g_free(prefs->default_reply_to);
        g_free(prefs->compose_subject_format);
        g_free(prefs->compose_body_format);
+       g_free(prefs->compose_override_from_format);
        g_free(prefs->reply_quotemark);
        g_free(prefs->reply_body_format);
+       g_free(prefs->reply_override_from_format);
        g_free(prefs->forward_quotemark);
        g_free(prefs->forward_body_format);
+       g_free(prefs->forward_override_from_format);
        g_free(prefs);
 }
 
@@ -251,17 +229,12 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        folder_item_prefs_read_config(src);
 
        tmp_prefs.directory                     = g_strdup(src->prefs->directory);
-       tmp_prefs.sort_by_number                = src->prefs->sort_by_number;
-       tmp_prefs.sort_by_size                  = src->prefs->sort_by_size;
-       tmp_prefs.sort_by_date                  = src->prefs->sort_by_date;
-       tmp_prefs.sort_by_from                  = src->prefs->sort_by_from;
-       tmp_prefs.sort_by_subject               = src->prefs->sort_by_subject;
-       tmp_prefs.sort_by_score                 = src->prefs->sort_by_score;
-       tmp_prefs.sort_descending               = src->prefs->sort_descending;
-       tmp_prefs.enable_thread                 = src->prefs->enable_thread;
         tmp_prefs.enable_processing             = src->prefs->enable_processing;
+        tmp_prefs.enable_processing_when_opening = src->prefs->enable_processing_when_opening;
        tmp_prefs.newmailcheck                  = src->prefs->newmailcheck;
-       tmp_prefs.offlinesync                  = src->prefs->offlinesync;
+       tmp_prefs.offlinesync                   = src->prefs->offlinesync;
+       tmp_prefs.offlinesync_days              = src->prefs->offlinesync_days;
+       tmp_prefs.remove_old_bodies             = src->prefs->remove_old_bodies;
 
        prefs_matcher_read_config();
 
@@ -285,7 +258,7 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        tmp_prefs.folder_chmod                  = src->prefs->folder_chmod;
        tmp_prefs.enable_default_account        = src->prefs->enable_default_account;
        tmp_prefs.default_account               = src->prefs->default_account;
-#if USE_ASPELL
+#if USE_ENCHANT
        tmp_prefs.enable_default_dictionary     = src->prefs->enable_default_dictionary;
        tmp_prefs.default_dictionary            = g_strdup(src->prefs->default_dictionary);
        tmp_prefs.enable_default_alt_dictionary = src->prefs->enable_default_alt_dictionary;
@@ -297,12 +270,15 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        tmp_prefs.compose_with_format = src->prefs->compose_with_format;
        tmp_prefs.compose_subject_format = g_strdup(src->prefs->compose_subject_format);
        tmp_prefs.compose_body_format = g_strdup(src->prefs->compose_body_format);
+       tmp_prefs.compose_override_from_format = g_strdup(src->prefs->compose_override_from_format);
        tmp_prefs.reply_with_format = src->prefs->reply_with_format;
        tmp_prefs.reply_quotemark = g_strdup(src->prefs->reply_quotemark);
        tmp_prefs.reply_body_format = g_strdup(src->prefs->reply_body_format);
+       tmp_prefs.reply_override_from_format = g_strdup(src->prefs->reply_override_from_format);
        tmp_prefs.forward_with_format = src->prefs->forward_with_format;
        tmp_prefs.forward_quotemark = g_strdup(src->prefs->forward_quotemark);
        tmp_prefs.forward_body_format = g_strdup(src->prefs->forward_body_format);
+       tmp_prefs.forward_override_from_format = g_strdup(src->prefs->forward_override_from_format);
 
        *dest->prefs = tmp_prefs;
        folder_item_prefs_save_config(dest);