[Commits] [SCM] claws branch, master, updated. 3.15.0-163-g5a3c83b

ticho at claws-mail.org ticho at claws-mail.org
Sun Oct 29 19:37:21 CET 2017


The branch, master has been updated
       via  5a3c83b91c814db749d1a23c531a559ba5b04701 (commit)
       via  b97b0cead96edc843ddb0f9a9b8dd3ed03319271 (commit)
       via  211cb0478112f813743d1a43266f1eef946c6bd2 (commit)
       via  5407e4537cd183c0239d1424bb3e010ff57bb07f (commit)
       via  5c9937be210699188161baadba41a3a28d79be75 (commit)
      from  efd5c578268bdb7732734240e796d63c178a875f (commit)

Summary of changes:
 src/common/utils.c |   22 +++++++++++++
 src/compose.c      |   90 +++++++++++++++++++++++++++++++++++++++++++++++++---
 src/mh.c           |   37 +++++++++++++++++++--
 src/prefs_themes.c |   60 +++++++++++++++++++++++++++--------
 4 files changed, 188 insertions(+), 21 deletions(-)


- Log -----------------------------------------------------------------
commit 5a3c83b91c814db749d1a23c531a559ba5b04701
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Oct 29 19:14:26 2017 +0100

    Use GIO API instead of g_stat() in prefs_themes_file_stats() on Windows.

diff --git a/src/prefs_themes.c b/src/prefs_themes.c
index 820dff3..1454bfd 100644
--- a/src/prefs_themes.c
+++ b/src/prefs_themes.c
@@ -174,24 +174,58 @@ static void prefs_themes_file_install		(const gchar *filename, gpointer data);
 
 static void prefs_themes_file_stats(const gchar *filename, gpointer data)
 {
+#ifdef G_OS_WIN32
+	GFile *f;
+	GFileInfo *fi;
+	GError *error = NULL;
+#else
 	GStatBuf s;
+#endif
+	goffset size;
 	DirInfo *di = (DirInfo *)data;
 	gint len;
 	gint i;
 
-	if (0 == g_stat(filename, &s) && 0 != S_ISREG(s.st_mode)) {
-		di->bytes += s.st_size;
-		di->files++;
-		len = strlen(filename);
-		for (i = 0; (di->supported)[i] != NULL; ++i) {
-			gint curlen = (di->length)[i];
-			if (len <= curlen)
-				continue;
-			const gchar *extension = filename + (len - curlen);
-			if (!strcmp(extension, (di->supported)[i])) {
-				di->pixms++;
-				break;
-			}
+#ifdef G_OS_WIN32
+	f = g_file_new_for_path(filename);
+	fi = g_file_query_info(f, "standard::size,standard::type",
+			G_FILE_QUERY_INFO_NONE, NULL, &error);
+	if (error != NULL) {
+		g_warning(error->message);
+		g_error_free(error);
+		g_object_unref(f);
+		return;
+	}
+	if (g_file_info_get_file_type(fi) != G_FILE_TYPE_REGULAR) {
+		g_object_unref(fi);
+		g_object_unref(f);
+		return;
+	}
+	size = g_file_info_get_size(fi);
+	g_object_unref(fi);
+	g_object_unref(f);
+#else
+	if ((i = g_stat(filename, &s)) != 0) {
+		debug_print("g_stat on '%s' failed: %d\n", filename, i);
+		return;
+	}
+	if (!S_ISREG(s.st_mode)) {
+		return;
+	}
+	size = s.st_size;
+#endif
+
+	di->bytes += size;
+	di->files++;
+	len = strlen(filename);
+	for (i = 0; (di->supported)[i] != NULL; ++i) {
+		gint curlen = (di->length)[i];
+		if (len <= curlen)
+			continue;
+		const gchar *extension = filename + (len - curlen);
+		if (!strcmp(extension, (di->supported)[i])) {
+			di->pixms++;
+			break;
 		}
 	}
 }

commit b97b0cead96edc843ddb0f9a9b8dd3ed03319271
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Oct 29 18:40:54 2017 +0100

    Use GIO API instead of g_stat() in compose_draft() on Windows.

diff --git a/src/compose.c b/src/compose.c
index 679b546..bfa2ac8 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -10483,26 +10483,56 @@ warn_err:
 		compose_close(compose);
 		return TRUE;
 	} else {
+#ifdef G_OS_WIN32
+		GFile *f;
+		GFileInfo *fi;
+		GTimeVal tv;
+		GError *error;
+#else
 		GStatBuf s;
+#endif
 		gchar *path;
+		goffset size, mtime;
 
 		path = folder_item_fetch_msg(draft, msgnum);
 		if (path == NULL) {
 			debug_print("can't fetch %s:%d\n", draft->path, msgnum);
 			goto unlock;
 		}
+#ifdef G_OS_WIN32
+		f = g_file_new_for_path(path);
+		fi = g_file_query_info(f, "standard::size,time::modified",
+				G_FILE_QUERY_INFO_NONE, NULL, &error);
+		if (error != NULL) {
+			debug_print("couldn't query file info for '%s': %s\n",
+					path, error->message);
+			g_error_free(error);
+			g_free(path);
+			g_object_unref(f);
+			goto unlock;
+		}
+		size = g_file_info_get_size(fi);
+		g_file_info_get_modification_time(fi, &tv);
+		mtime = tv.tv_sec;
+		g_object_unref(fi);
+		g_object_unref(f);
+		g_free(path);
+#else
 		if (g_stat(path, &s) < 0) {
 			FILE_OP_ERROR(path, "stat");
 			g_free(path);
 			goto unlock;
 		}
+		size = s.st_size;
+		mtime = s.st_mtime;
+#endif
 		g_free(path);
 
 		procmsg_msginfo_free(&(compose->targetinfo));
 		compose->targetinfo = procmsg_msginfo_new();
 		compose->targetinfo->msgnum = msgnum;
-		compose->targetinfo->size = (goffset)s.st_size;
-		compose->targetinfo->mtime = s.st_mtime;
+		compose->targetinfo->size = size;
+		compose->targetinfo->mtime = mtime;
 		compose->targetinfo->folder = draft;
 		if (target_locked)
 			procmsg_msginfo_set_flags(compose->targetinfo, MSG_LOCKED, 0);

commit 211cb0478112f813743d1a43266f1eef946c6bd2
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Oct 29 18:31:18 2017 +0100

    Use GIO API instead of g_stat() on Windows in compose_add_attachments() and get_file_size().

diff --git a/src/common/utils.c b/src/common/utils.c
index 5ac09a7..941f1c7 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -2028,6 +2028,27 @@ const gchar *get_domain_name(void)
 
 off_t get_file_size(const gchar *file)
 {
+#ifdef G_OS_WIN32
+	GFile *f;
+	GFileInfo *fi;
+	GError *error = NULL;
+	goffset size;
+
+	f = g_file_new_for_path(file);
+	fi = g_file_query_info(f, "standard::size",
+			G_FILE_QUERY_INFO_NONE, NULL, &error);
+	if (error != NULL) {
+		debug_print("get_file_size error: %s\n", error->message);
+		g_error_free(error);
+		g_object_unref(f);
+		return -1;
+	}
+	size = g_file_info_get_size(fi);
+	g_object_unref(fi);
+	g_object_unref(f);
+	return size;
+
+#else
 	GStatBuf s;
 
 	if (g_stat(file, &s) < 0) {
@@ -2036,6 +2057,7 @@ off_t get_file_size(const gchar *file)
 	}
 
 	return s.st_size;
+#endif
 }
 
 time_t get_file_mtime(const gchar *file)
diff --git a/src/compose.c b/src/compose.c
index 1e5d2a2..679b546 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -6352,7 +6352,14 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
 	AttachInfo *ainfo;
 	GtkTreeView *tree_view = GTK_TREE_VIEW(compose->attach_clist);
 	MimeInfo *mimepart;
+#ifdef G_OS_WIN32
+	GFile *f;
+	GFileInfo *fi;
+	GError *error = NULL;
+#else
 	GStatBuf statbuf;
+#endif
+	goffset size;
 	gchar *type, *subtype;
 	GtkTreeModel *model;
 	GtkTreeIter iter;
@@ -6374,15 +6381,31 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
 			}
 			continue;
 		}
+#ifdef G_OS_WIN32
+		f = g_file_new_for_path(ainfo->file);
+		fi = g_file_query_info(f, "standard::size",
+				G_FILE_QUERY_INFO_NONE, NULL, &error);
+		if (error != NULL) {
+			g_warning(error->message);
+			g_error_free(error);
+			g_object_unref(f);
+			return -1;
+		}
+		size = g_file_info_get_size(fi);
+		g_object_unref(fi);
+		g_object_unref(f);
+#else
 		if (g_stat(ainfo->file, &statbuf) < 0)
 			return -1;
+		size = statbuf.st_size;
+#endif
 
 		mimepart = procmime_mimeinfo_new();
 		mimepart->content = MIMECONTENT_FILE;
 		mimepart->data.filename = g_strdup(ainfo->file);
 		mimepart->tmp = FALSE; /* or we destroy our attachment */
 		mimepart->offset = 0;
-		mimepart->length = statbuf.st_size;
+		mimepart->length = size;
 
     		type = g_strdup(ainfo->content_type);
 

commit 5407e4537cd183c0239d1424bb3e010ff57bb07f
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Oct 29 18:12:12 2017 +0100

    Use GIO API instead of g_stat() in compose_insert_file() on Windows.

diff --git a/src/compose.c b/src/compose.c
index 5aad277..1e5d2a2 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -3633,31 +3633,58 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
 	gint len;
 	FILE *fp;
 	gboolean prev_autowrap;
+#ifdef G_OS_WIN32
+	GFile *f;
+	GFileInfo *fi;
+	GError *error = NULL;
+#else
 	GStatBuf file_stat;
+#endif
 	int ret;
+	goffset size;
 	GString *file_contents = NULL;
 	ComposeInsertResult result = COMPOSE_INSERT_SUCCESS;
 
 	cm_return_val_if_fail(file != NULL, COMPOSE_INSERT_NO_FILE);
 
 	/* get the size of the file we are about to insert */
+#ifdef G_OS_WIN32
+	f = g_file_new_for_path(file);
+	fi = g_file_query_info(f, "standard::size",
+			G_FILE_QUERY_INFO_NONE, NULL, &error);
+	ret = 0;
+	if (error != NULL) {
+		g_warning(error->message);
+		ret = 1;
+		g_error_free(error);
+		g_object_unref(f);
+	}
+#else
 	ret = g_stat(file, &file_stat);
+#endif
 	if (ret != 0) {
 		gchar *shortfile = g_path_get_basename(file);
 		alertpanel_error(_("Could not get size of file '%s'."), shortfile);
 		g_free(shortfile);
 		return COMPOSE_INSERT_NO_FILE;
 	} else if (prefs_common.warn_large_insert == TRUE) {
+#ifdef G_OS_WIN32
+		size = g_file_info_get_size(fi);
+		g_object_unref(fi);
+		g_object_unref(f);
+#else
+		size = file_stat.st_size;
+#endif
 
 		/* ask user for confirmation if the file is large */
 		if (prefs_common.warn_large_insert_size < 0 ||
-		    file_stat.st_size > (prefs_common.warn_large_insert_size * 1024)) {
+		    size > (prefs_common.warn_large_insert_size * 1024)) {
 			AlertValue aval;
 			gchar *msg;
 
 			msg = g_strdup_printf(_("You are about to insert a file of %s "
 						"in the message body. Are you sure you want to do that?"),
-						to_human_readable(file_stat.st_size));
+						to_human_readable(size));
 			aval = alertpanel_full(_("Are you sure?"), msg, GTK_STOCK_CANCEL,
 					g_strconcat("+", _("_Insert"), NULL), NULL, TRUE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
 			g_free(msg);

commit 5c9937be210699188161baadba41a3a28d79be75
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Oct 28 17:57:48 2017 +0200

    Use GIO API instead of g_stat() in mh_is_msg_changed() on Windows.

diff --git a/src/mh.c b/src/mh.c
index 50999e7..0bf0783 100644
--- a/src/mh.c
+++ b/src/mh.c
@@ -730,7 +730,15 @@ static gint mh_remove_all_msg(Folder *folder, FolderItem *item)
 static gboolean mh_is_msg_changed(Folder *folder, FolderItem *item,
 				  MsgInfo *msginfo)
 {
+#ifdef G_OS_WIN32
+	GFile *f;
+	GFileInfo *fi;
+	GTimeVal tv;
+	GError *error = NULL;
+#else
 	GStatBuf s;
+	int r;
+#endif
 	gchar *path;
 	gchar *parent_path;
 
@@ -738,16 +746,39 @@ static gboolean mh_is_msg_changed(Folder *folder, FolderItem *item,
 	path = g_strdup_printf("%s%c%d", parent_path,
 			G_DIR_SEPARATOR, msginfo->msgnum);
 	g_free(parent_path);
-	if (g_stat((path), &s) < 0 ||
+
+#ifdef G_OS_WIN32
+	f = g_file_new_for_path(path);
+	g_free(path);
+	fi = g_file_query_info(f, "standard::size,time::modified",
+			G_FILE_QUERY_INFO_NONE, NULL, &error);
+	if (error != NULL) {
+		g_warning(error->message);
+		g_error_free(error);
+		g_object_unref(f);
+		return TRUE;
+	}
+
+	g_file_info_get_modification_time(fi, &tv);
+	if (msginfo->size != g_file_info_get_size(fi) || (
+			(msginfo->mtime - tv.tv_sec != 0) &&
+			abs(msginfo->mtime - tv.tv_sec) != 3600)) {
+		g_error_free(error);
+		g_object_unref(f);
+		return TRUE;
+	}
+#else
+	r = g_stat(path, &s);
+	g_free(path);
+	if (r < 0 ||
 	    msginfo->size  != s.st_size || (
 		(msginfo->mtime - s.st_mtime != 0) &&
 		(msginfo->mtime - s.st_mtime != 3600) &&
 		(msginfo->mtime - s.st_mtime != -3600))) {
-		g_free(path);
 		return TRUE;
 	}
+#endif
 
-	g_free(path);
 	return FALSE;
 }
 

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list