[evolution/gnome-2-28] Bug 607234 - Open received attachments as read-only



commit 781d749e8910659540d5833a5efaba6d91d375b1
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Jan 18 13:50:33 2010 -0500

    Bug 607234 - Open received attachments as read-only

 widgets/misc/e-attachment.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index 1fec792..87fc8b2 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <config.h>
 #include <glib/gi18n.h>
+#include <glib/gstdio.h>
 #include <camel/camel-iconv.h>
 #include <camel/camel-data-wrapper.h>
 #include <camel/camel-mime-message.h>
@@ -2054,6 +2055,7 @@ attachment_open_save_finished_cb (EAttachment *attachment,
                                   OpenContext *open_context)
 {
 	GFile *file;
+	gchar *path;
 	GError *error = NULL;
 
 	file = e_attachment_save_finish (attachment, result, &error);
@@ -2061,6 +2063,22 @@ attachment_open_save_finished_cb (EAttachment *attachment,
 	if (attachment_open_check_for_error (open_context, error))
 		return;
 
+	/* Make the temporary file read-only.
+	 *
+	 * This step is non-critical, so if an error occurs just
+	 * emit a warning and move on.
+	 *
+	 * XXX I haven't figured out how to do this through GIO.
+	 *     Attempting to set the "access::can-write" attribute via
+	 *     g_file_set_attribute() returned G_IO_ERROR_NOT_SUPPORTED
+	 *     and the only other possibility I see is "unix::mode",
+	 *     which is obviously not portable.
+	 */
+	path = g_file_get_path (file);
+	if (g_chmod (path, S_IRUSR | S_IRGRP | S_IROTH) < 0)
+		g_warning ("%s", g_strerror (errno));
+	g_free (path);
+
 	attachment_open_file (file, open_context);
 	g_object_unref (file);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]