Shared folders support with a GUI.
[claws.git] / src / summaryview.c
index a43e010d869fad60565e67b65b8671d31a7f710e..a737b477a16611a52e25bab0a3b3185e06c167d0 100644 (file)
@@ -45,6 +45,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <unistd.h>
+#include <sys/stat.h>
 
 #include "intl.h"
 #include "main.h"
@@ -1943,6 +1944,8 @@ gint summary_write_cache(SummaryView *summaryview)
        gchar *buf;
        gchar *cachefile, *markfile;
        GSList * cur;
+       gint filemode = 0;
+       PrefsFolderItem *prefs;
 
        if (!summaryview->folder_item || !summaryview->folder_item->path)
                return -1;
@@ -1959,6 +1962,20 @@ gint summary_write_cache(SummaryView *summaryview)
        }
        if (change_file_mode_rw(fps.cache_fp, cachefile) < 0)
                FILE_OP_ERROR(cachefile, "chmod");
+
+       prefs = summaryview->folder_item->prefs;
+        if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
+               /* for cache file */
+               filemode = prefs->folder_chmod;
+               if (filemode & S_IRGRP) filemode |= S_IWGRP;
+               if (filemode & S_IROTH) filemode |= S_IWOTH;
+#if HAVE_FCHMOD
+               fchmod(fileno(fps.cache_fp), filemode);
+#else
+               chmod(cachefile, filemode);
+#endif
+        }
+
        g_free(cachefile);
 
        markfile = folder_item_get_mark_file(summaryview->folder_item);
@@ -1970,6 +1987,14 @@ gint summary_write_cache(SummaryView *summaryview)
        }
        if (change_file_mode_rw(fps.mark_fp, markfile) < 0)
                FILE_OP_ERROR(markfile, "chmod");
+        if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
+#if HAVE_FCHMOD
+               fchmod(fileno(fps.mark_fp), filemode);
+#else
+               chmod(markfile, filemode);
+#endif
+        }
+
        g_free(markfile);
 
        buf = g_strdup_printf(_("Writing summary cache (%s)..."),
@@ -2051,7 +2076,7 @@ static void summary_set_header(gchar *text[], MsgInfo *msginfo)
                Xalloca(from, strlen(msginfo->from) + 1, return);
                strcpy(from, msginfo->from);
                extract_address(from);
-               if (account_find_mail_from_address(from)) {
+               if (account_find_from_address(from)) {
                        g_free(to);
                        to = g_strconcat("-->", msginfo->to, NULL);
                        text[S_COL_FROM] = to;
@@ -3282,7 +3307,7 @@ static void summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                compose_new_with_recipient
                                        (ac, summaryview->folder_item->path);
                        else
-                               compose_new(ac);
+                               compose_new_with_folderitem(ac, summaryview->folder_item);
                } else
                        compose_new(NULL);
                return;