From 28c01004d2ca5f62ba5409bdd7a469f1d73b931d Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 15 Nov 2007 14:31:48 +0000 Subject: [PATCH] * fix attachment permissions: - when opening directly, set permissions to 0444 (read-only) - when saving, set permissions to 0644 (read/write) pmo-trunk-r3744 --- src/maemo/modest-msg-view-window.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index d49fda2..799311b 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -56,6 +56,8 @@ #include #include #include +#include +#include #define DEFAULT_FOLDER "MyDocs/.documents" @@ -2230,12 +2232,18 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart gchar *filepath = NULL; const gchar *att_filename = tny_mime_part_get_filename (mime_part); TnyFsStream *temp_stream = NULL; - temp_stream = modest_maemo_utils_create_temp_stream (att_filename, attachment_uid, &filepath); + temp_stream = modest_maemo_utils_create_temp_stream (att_filename, attachment_uid, + &filepath); if (temp_stream) { const gchar *content_type; content_type = tny_mime_part_get_content_type (mime_part); tny_mime_part_decode_to_stream (mime_part, TNY_STREAM (temp_stream)); + + /* make the file read-only */ + if (g_chmod(filepath, 0444) != 0) + g_warning ("%s: failed to set file '%s' to read-only: %s", + __FUNCTION__, filepath, strerror(errno)); modest_platform_activate_file (filepath, content_type); g_object_unref (temp_stream); @@ -2349,7 +2357,7 @@ save_mime_part_to_file (SaveMimePartInfo *info) TnyStream *stream; SaveMimePartPair *pair = (SaveMimePartPair *) info->pairs->data; - result = gnome_vfs_create (&handle, pair->filename, GNOME_VFS_OPEN_WRITE, FALSE, 0444); + result = gnome_vfs_create (&handle, pair->filename, GNOME_VFS_OPEN_WRITE, FALSE, 0644); if (result == GNOME_VFS_OK) { stream = tny_vfs_stream_new (handle); tny_mime_part_decode_to_stream (pair->part, stream); -- 1.7.9.5