2007-03-30 [colin] 2.8.1cvs69
[claws.git] / src / prefs_common.c
index 359370cdc85b3481b2653b381ca48c1512de978c..f70e489fab148faf94d807f743001537fc766cce 100644 (file)
@@ -262,8 +262,13 @@ static PrefParam param[] = {
        {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL,
         NULL, NULL, NULL},
 
+#ifndef MAEMO
        {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL,
         NULL, NULL, NULL},
+#else
+       {"show_ruler", "FALSE", &prefs_common.show_ruler, P_BOOL,
+        NULL, NULL, NULL},
+#endif
 
        /* Quote */
        {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING,
@@ -942,10 +947,17 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
         NULL, NULL, NULL},
+#ifndef MAEMO
        {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
         NULL, NULL, NULL},
        {"cache_min_keep_time", "15", &prefs_common.cache_min_keep_time, P_INT,
         NULL, NULL, NULL},
+#else
+       {"cache_max_mem_usage", "4096", &prefs_common.cache_max_mem_usage, P_INT,
+        NULL, NULL, NULL},
+       {"cache_min_keep_time", "0", &prefs_common.cache_min_keep_time, P_INT,
+        NULL, NULL, NULL},
+#endif
        {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
        P_INT, NULL, NULL, NULL },
        {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
@@ -1052,6 +1064,13 @@ void prefs_common_read_config(void)
        colorlabel_update_colortable_from_prefs();
 }
 
+#define TRY(func) \
+if (!(func)) \
+{ \
+       g_warning("failed to write\n"); \
+       goto out;                       \
+} \
+
 /*
  * Save history list to the specified history file
  */
@@ -1059,25 +1078,45 @@ static void prefs_common_save_history(const gchar *history, GList *list)
 {
        GList *cur;
        FILE *fp;
-       gchar *path;
+       gchar *path, *tmp_path;
 
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, history,
                           NULL);
-       if ((fp = g_fopen(path, "wb")) == NULL) {
-               FILE_OP_ERROR(path, "fopen");
-               g_free(path);
-               return;
+       tmp_path = g_strconcat(path, ".tmp", NULL);
+
+       if ((fp = g_fopen(tmp_path, "wb")) == NULL) {
+               FILE_OP_ERROR(tmp_path, "fopen");
+               goto out;
        }
 
        for (cur = list; cur != NULL; cur = cur->next) {
-               fputs((gchar *)cur->data, fp);
-               fputc('\n', fp);
+               TRY(fputs((gchar *)cur->data, fp) != EOF &&
+                   fputc('\n', fp) != EOF);
        }
 
-       fclose(fp);
+       if (fclose(fp) == EOF) {
+               FILE_OP_ERROR(tmp_path, "fclose");
+               fp = NULL;
+               goto out;
+       }
+       fp = NULL;
+#ifdef G_OS_WIN32
+       g_unlink(path);
+#endif
+       if (g_rename(tmp_path, path) < 0) {
+               FILE_OP_ERROR(path, "rename");
+               goto out;
+       }
+
+out:
+       if (fp)
+               fclose(fp);
+       g_free(tmp_path);
        g_free(path);
 }
 
+#undef TRY
+
 void prefs_common_write_config(void)
 {
        prefs_write_config(param, "Common", COMMON_RC);