[evolution] Bug 607234 - Open received attachments as read-only



commit f6d07f6cc622da5409a4f09db2b34d9c44f71011
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 a8cef68..5385ab0 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>
@@ -2045,6 +2046,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);
@@ -2052,6 +2054,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]