aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-01-19 02:50:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-01-19 02:52:31 +0800
commitf6d07f6cc622da5409a4f09db2b34d9c44f71011 (patch)
tree88a1844a32f612eff5c2728262aa84902968c4d7 /widgets/misc
parente3e2f2f832be0f6931cf42b6b61b4866a2241a02 (diff)
downloadgsoc2013-evolution-f6d07f6cc622da5409a4f09db2b34d9c44f71011.tar
gsoc2013-evolution-f6d07f6cc622da5409a4f09db2b34d9c44f71011.tar.gz
gsoc2013-evolution-f6d07f6cc622da5409a4f09db2b34d9c44f71011.tar.bz2
gsoc2013-evolution-f6d07f6cc622da5409a4f09db2b34d9c44f71011.tar.lz
gsoc2013-evolution-f6d07f6cc622da5409a4f09db2b34d9c44f71011.tar.xz
gsoc2013-evolution-f6d07f6cc622da5409a4f09db2b34d9c44f71011.tar.zst
gsoc2013-evolution-f6d07f6cc622da5409a4f09db2b34d9c44f71011.zip
BugĀ 607234 - Open received attachments as read-only
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/e-attachment.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index a8cef68835..5385ab001c 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);
}