[balsa/fix-issue-53] fix composer description of forwarded messages
- From: Albrecht Dreß <albrecht src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/fix-issue-53] fix composer description of forwarded messages
- Date: Sat, 16 Jan 2021 13:39:46 +0000 (UTC)
commit 0760a99caf757ac7d997009cb7002fd81cb064c4
Author: Albrecht Dreß <albrecht dress arcor de>
Date: Sat Jan 16 14:39:37 2021 +0100
fix composer description of forwarded messages
modifies: src/sendmsg-window.c, function get_fwd_mail_headers(), treat
the passed file URI properly as such, not as file name (fixes #53).
Signed-off-by: Albrecht Dreß <albrecht dress arcor de>
src/sendmsg-window.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index efe6f2dd7..d078cb0b7 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1591,29 +1591,32 @@ sw_set_charset(BalsaSendmsg * bsmsg, const gchar * filename,
static LibBalsaMessageHeaders *
-get_fwd_mail_headers(const gchar *mailfile)
+get_fwd_mail_headers(const gchar *mailfile_uri)
{
- int fd;
+ GFile *msg_file;
GMimeStream *stream;
GMimeParser *parser;
GMimeMessage *message;
- LibBalsaMessageHeaders *headers;
+ LibBalsaMessageHeaders *headers = NULL;
- /* try to open the mail file */
- if ((fd = open(mailfile, O_RDONLY)) == -1)
- return NULL;
- if ((stream = g_mime_stream_fs_new(fd)) == NULL) {
- close(fd);
- return NULL;
+ /* create a stream from the mail file uri
+ * note: the next call will never fail, but... */
+ msg_file = g_file_new_for_uri(mailfile_uri);
+ if (!g_file_query_exists(msg_file, NULL)) {
+ g_object_unref(msg_file); /* ...we need a paranoia check for file existence */
+ return NULL;
}
+ stream = g_mime_stream_gio_new(msg_file); /* consumes the GFil */
- /* parse the file */
+ /* try to parse the file */
parser = g_mime_parser_new_with_stream(stream);
g_mime_parser_set_format(parser, GMIME_FORMAT_MESSAGE);
message = g_mime_parser_construct_message (parser, libbalsa_parser_options());
- g_object_unref (parser);
+ g_object_unref(parser);
g_object_unref(stream);
- close(fd);
+ if (message == NULL) {
+ return NULL;
+ }
/* get the headers from the gmime message */
headers = g_new0(LibBalsaMessageHeaders, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]