[Commits] [SCM] claws branch, master, updated. 3.17.3-108-g4e9e7d7

ticho at claws-mail.org ticho at claws-mail.org
Fri Mar 1 14:52:19 CET 2019


The branch, master has been updated
       via  4e9e7d734f3dc03ff9c64d8dc4c448bea58225bb (commit)
      from  699087a794cd22621e21c5f5f1c8d200157fa15b (commit)

Summary of changes:
 src/plugins/pgpcore/pgp_utils.c     |   60 -----------------------------------
 src/plugins/pgpcore/pgp_utils.h     |    1 -
 src/plugins/pgpcore/plugin.def      |    1 -
 src/plugins/pgpinline/claws.def     |    1 +
 src/plugins/pgpinline/mypgpcore.def |    1 -
 src/plugins/pgpinline/pgpinline.c   |    8 ++---
 src/plugins/pgpmime/claws.def       |    1 +
 src/plugins/pgpmime/mypgpcore.def   |    1 -
 src/plugins/pgpmime/pgpmime.c       |    2 +-
 src/procmime.c                      |   59 ++++++++++++++++++++++++++++++++++
 src/procmime.h                      |    2 ++
 11 files changed, 68 insertions(+), 69 deletions(-)


- Log -----------------------------------------------------------------
commit 4e9e7d734f3dc03ff9c64d8dc4c448bea58225bb
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Mar 1 14:51:58 2019 +0100

    Move pgpcore's get_part_as_string() to procmime.c

diff --git a/src/plugins/pgpcore/pgp_utils.c b/src/plugins/pgpcore/pgp_utils.c
index 41c5d47..31f2d34 100644
--- a/src/plugins/pgpcore/pgp_utils.c
+++ b/src/plugins/pgpcore/pgp_utils.c
@@ -31,66 +31,6 @@
 #include "codeconv.h"
 #include "file-utils.h"
 
-gchar *get_part_as_string(MimeInfo *mimeinfo)
-{
-	gchar *textdata = NULL;
-	gchar *filename = NULL;
-	FILE *fp;
-
-	cm_return_val_if_fail(mimeinfo != NULL, 0);
-	procmime_decode_content(mimeinfo);
-	
-	if (mimeinfo->content == MIMECONTENT_MEM)
-		textdata = g_strdup(mimeinfo->data.mem);
-	else {
-		filename = procmime_get_tmp_file_name(mimeinfo);
-		if (procmime_get_part(filename, mimeinfo) < 0) {
-			g_warning("error dumping temporary file '%s'", filename);
-			g_free(filename);
-			return NULL;
-		}
-		fp = claws_fopen(filename,"rb");
-		if (!fp) {
-			g_warning("error opening temporary file '%s'", filename);
-
-			g_free(filename);
-			return NULL;
-		}
-		textdata = file_read_stream_to_str_no_recode(fp);
-
-		claws_fclose(fp);
-		g_unlink(filename);
-		g_free(filename);
-	}
-
-	if (!g_utf8_validate(textdata, -1, NULL)) {
-		gchar *tmp = NULL;
-		codeconv_set_strict(TRUE);
-		if (procmime_mimeinfo_get_parameter(mimeinfo, "charset")) {
-			tmp = conv_codeset_strdup(textdata,
-				procmime_mimeinfo_get_parameter(mimeinfo, "charset"),
-				CS_UTF_8);
-		}
-		if (!tmp) {
-			tmp = conv_codeset_strdup(textdata,
-				conv_get_locale_charset_str_no_utf8(), 
-				CS_UTF_8);
-		}
-		codeconv_set_strict(FALSE);
-		if (!tmp) {
-			tmp = conv_codeset_strdup(textdata,
-				conv_get_locale_charset_str_no_utf8(), 
-				CS_UTF_8);
-		}
-		if (tmp) {
-			g_free(textdata);
-			textdata = tmp;
-		}
-	}
-
-	return textdata;	
-}
-
 gchar *pgp_locate_armor_header(gchar *textdata, const gchar *armor_header)
 {
 	gchar *pos;
diff --git a/src/plugins/pgpcore/pgp_utils.h b/src/plugins/pgpcore/pgp_utils.h
index 0299dae..aa296b8 100644
--- a/src/plugins/pgpcore/pgp_utils.h
+++ b/src/plugins/pgpcore/pgp_utils.h
@@ -27,7 +27,6 @@
 
 #include "procmime.h"
 
-gchar *get_part_as_string(MimeInfo *mimeinfo);
 gchar *pgp_locate_armor_header(gchar *textdata, const gchar *armor_header);
 
 #endif /* __PGP_UTILS_H__ */
diff --git a/src/plugins/pgpcore/plugin.def b/src/plugins/pgpcore/plugin.def
index 5c48ea9..1f156d9 100644
--- a/src/plugins/pgpcore/plugin.def
+++ b/src/plugins/pgpcore/plugin.def
@@ -27,6 +27,5 @@ EXPORTS
 
 	cm_gpgme_data_rewind
 
-	get_part_as_string
 	pgp_locate_armor_header
 	prefs_gpg_auto_check_signatures
diff --git a/src/plugins/pgpinline/claws.def b/src/plugins/pgpinline/claws.def
index 4162a99..30f963e 100644
--- a/src/plugins/pgpinline/claws.def
+++ b/src/plugins/pgpinline/claws.def
@@ -25,4 +25,5 @@ procmime_mimeinfo_parent
 procmime_scan_file
 procmime_write_mimeinfo
 procmime_get_part
+procmime_get_part_as_string
 procmime_get_tmp_file_name
diff --git a/src/plugins/pgpinline/mypgpcore.def b/src/plugins/pgpinline/mypgpcore.def
index 1e17672..dbebe9b 100644
--- a/src/plugins/pgpinline/mypgpcore.def
+++ b/src/plugins/pgpinline/mypgpcore.def
@@ -14,6 +14,5 @@ sgpgme_sigstat_gpgme_to_privacy
 sgpgme_sigstat_info_full
 sgpgme_sigstat_info_short
 sgpgme_verify_signature
-get_part_as_string
 pgp_locate_armor_header
 prefs_gpg_auto_check_signatures
diff --git a/src/plugins/pgpinline/pgpinline.c b/src/plugins/pgpinline/pgpinline.c
index 4c7c98b..f0801c4 100644
--- a/src/plugins/pgpinline/pgpinline.c
+++ b/src/plugins/pgpinline/pgpinline.c
@@ -115,7 +115,7 @@ static gboolean pgpinline_is_signed(MimeInfo *mimeinfo)
 			return data->is_signed;
 	}
 	
-	textdata = get_part_as_string(mimeinfo);
+	textdata = procmime_get_part_as_string(mimeinfo);
 	if (!textdata)
 		return FALSE;
 	
@@ -164,7 +164,7 @@ static gint pgpinline_check_signature(MimeInfo *mimeinfo)
 	cm_return_val_if_fail(mimeinfo->privacy != NULL, 0);
 	data = (PrivacyDataPGP *) mimeinfo->privacy;
 
-	textdata = get_part_as_string(mimeinfo);
+	textdata = procmime_get_part_as_string(mimeinfo);
 
 	if (!textdata) {
 		g_free(textdata);
@@ -265,7 +265,7 @@ static gboolean pgpinline_is_encrypted(MimeInfo *mimeinfo)
 		mimeinfo->subtype = g_strdup("plain");
 	}
 
-	textdata = get_part_as_string(mimeinfo);
+	textdata = procmime_get_part_as_string(mimeinfo);
 	if (!textdata)
 		return FALSE;
 
@@ -317,7 +317,7 @@ static MimeInfo *pgpinline_decrypt(MimeInfo *mimeinfo)
 		return NULL;
 	}
 
-	textdata = get_part_as_string(mimeinfo);
+	textdata = procmime_get_part_as_string(mimeinfo);
 	if (!textdata) {
 		gpgme_release(ctx);
 		privacy_set_error(_("Couldn't get text data."));
diff --git a/src/plugins/pgpmime/claws.def b/src/plugins/pgpmime/claws.def
index 3855a69..7f8f700 100644
--- a/src/plugins/pgpmime/claws.def
+++ b/src/plugins/pgpmime/claws.def
@@ -16,6 +16,7 @@ privacy_register_system
 privacy_reset_error
 privacy_set_error
 privacy_unregister_system
+procmime_get_part_as_string
 procmime_mimeinfo_free_all
 procmime_mimeinfo_get_parameter
 procmime_mimeinfo_new
diff --git a/src/plugins/pgpmime/mypgpcore.def b/src/plugins/pgpmime/mypgpcore.def
index cad93cb..ef81580 100644
--- a/src/plugins/pgpmime/mypgpcore.def
+++ b/src/plugins/pgpmime/mypgpcore.def
@@ -16,6 +16,5 @@ sgpgme_sigstat_info_full
 sgpgme_sigstat_info_short
 sgpgme_verify_signature
 cm_gpgme_data_rewind
-get_part_as_string
 pgp_locate_armor_header
 prefs_gpg_auto_check_signatures
diff --git a/src/plugins/pgpmime/pgpmime.c b/src/plugins/pgpmime/pgpmime.c
index 4ee1898..5633e0f 100644
--- a/src/plugins/pgpmime/pgpmime.c
+++ b/src/plugins/pgpmime/pgpmime.c
@@ -293,7 +293,7 @@ static gboolean pgpmime_is_encrypted(MimeInfo *mimeinfo)
 	if (g_ascii_strcasecmp(tmpinfo->subtype, "octet-stream"))
 		return FALSE;
 	
-	textdata = get_part_as_string(tmpinfo);
+	textdata = procmime_get_part_as_string(tmpinfo);
 	if (!textdata)
 		return FALSE;
 	
diff --git a/src/procmime.c b/src/procmime.c
index e259adb..004f57f 100644
--- a/src/procmime.c
+++ b/src/procmime.c
@@ -2662,3 +2662,62 @@ gchar *procmime_get_part_file_name(MimeInfo *mimeinfo)
 	return base;
 }
 
+gchar *procmime_get_part_as_string(MimeInfo *mimeinfo)
+{
+	gchar *textdata = NULL;
+	gchar *filename = NULL;
+	FILE *fp;
+
+	cm_return_val_if_fail(mimeinfo != NULL, 0);
+	procmime_decode_content(mimeinfo);
+
+	if (mimeinfo->content == MIMECONTENT_MEM)
+		textdata = g_strdup(mimeinfo->data.mem);
+	else {
+		filename = procmime_get_tmp_file_name(mimeinfo);
+		if (procmime_get_part(filename, mimeinfo) < 0) {
+			g_warning("error dumping temporary file '%s'", filename);
+			g_free(filename);
+			return NULL;
+		}
+		fp = claws_fopen(filename,"rb");
+		if (!fp) {
+			g_warning("error opening temporary file '%s'", filename);
+
+			g_free(filename);
+			return NULL;
+		}
+		textdata = file_read_stream_to_str_no_recode(fp);
+
+		claws_fclose(fp);
+		g_unlink(filename);
+		g_free(filename);
+	}
+
+	if (!g_utf8_validate(textdata, -1, NULL)) {
+		gchar *tmp = NULL;
+		codeconv_set_strict(TRUE);
+		if (procmime_mimeinfo_get_parameter(mimeinfo, "charset")) {
+			tmp = conv_codeset_strdup(textdata,
+				procmime_mimeinfo_get_parameter(mimeinfo, "charset"),
+				CS_UTF_8);
+		}
+		if (!tmp) {
+			tmp = conv_codeset_strdup(textdata,
+				conv_get_locale_charset_str_no_utf8(),
+				CS_UTF_8);
+		}
+		codeconv_set_strict(FALSE);
+		if (!tmp) {
+			tmp = conv_codeset_strdup(textdata,
+				conv_get_locale_charset_str_no_utf8(),
+				CS_UTF_8);
+		}
+		if (tmp) {
+			g_free(textdata);
+			textdata = tmp;
+		}
+	}
+
+	return textdata;
+}
diff --git a/src/procmime.h b/src/procmime.h
index 5fae87a..ae8b0e6 100644
--- a/src/procmime.h
+++ b/src/procmime.h
@@ -238,6 +238,8 @@ FILE *procmime_get_binary_content(MimeInfo *mimeinfo);
 gboolean procmime_scan_text_content(MimeInfo *mimeinfo,
 		gboolean (*scan_callback)(const gchar *str, gpointer cb_data),
 		gpointer cb_data);
+gchar *procmime_get_part_as_string(MimeInfo *mimeinfo);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list