[Commits] [SCM] claws branch, master, updated. 3.9.2-83-gb562b29

claws at claws-mail.org claws at claws-mail.org
Tue Aug 27 10:45:49 CEST 2013


The branch master of project "claws" (Claws Mail) has been updated
       via  b562b295c97bd2f183d0c67089792cce3be734b0 (commit)
      from  61b80317c36e78d9f8f4ab8ef134478584aad9a7 (commit)


- Log -----------------------------------------------------------------
commit b562b295c97bd2f183d0c67089792cce3be734b0
Author: Paul <paul at headmonaut.co.uk>
Date:   Tue Aug 27 09:45:42 2013 +0100

    fix bug 2979, 'claws fails to load (empty) folderlist.xml and shows account wizard'

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2599a27..9d7a8a3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -36,6 +36,7 @@ src/expldifdlg.c
 src/export.c
 src/exporthtml.c
 src/exportldif.c
+src/file_checker.c
 src/folder.c
 src/foldersel.c
 src/folderview.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 1a173ee..08bc2b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,7 @@ old_abook_source = \
 	expldifdlg.c \
 	exporthtml.c \
 	exportldif.c \
+	file_checker.c \
 	importldif.c \
 	importmutt.c \
 	importpine.c \
@@ -102,6 +103,7 @@ abook_headers = \
 	expldifdlg.h \
 	exporthtml.h \
 	exportldif.h \
+	file_checker.h \
 	importldif.h \
 	importmutt.h \
 	importpine.h \
diff --git a/src/file_checker.c b/src/file_checker.c
new file mode 100644
index 0000000..5205070
--- /dev/null
+++ b/src/file_checker.c
@@ -0,0 +1,112 @@
+/*
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2013 Paul Mangan <paul at claws-mail.org> 
+ * and the Claws Mail team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#include "claws-features.h"
+#endif
+
+#include "defs.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "utils.h"
+#include "alertpanel.h"
+#include "folder.h"
+
+static gboolean verify_folderlist_xml();
+
+gboolean check_file_integrity() {
+	if (verify_folderlist_xml() != TRUE)
+		return FALSE;
+
+	return TRUE;
+}
+
+static gboolean verify_folderlist_xml() {
+	GNode *node;
+	static gchar *filename = NULL;
+	static gchar *bak = NULL;
+	time_t date;
+	struct tm *ts;
+	gchar buf[BUFFSIZE];
+
+	filename = folder_get_list_path();
+	bak = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ 			  FOLDER_LIST, ".bak", NULL);
+	
+ 	if (is_file_exist(bak)) {
+		date = get_file_mtime(bak);
+		ts = localtime(&date);
+		strftime(buf, sizeof(buf), "%a %d-%b-%Y %H:%M %Z", ts);
+	}
+	
+	if (!is_file_exist(filename) && is_file_exist(bak)) {
+		AlertValue aval;
+		gchar *msg;
+
+		msg = g_strdup_printf
+			(_("The file %s is missing! "
+			   "Do you want to use the backup file from %s?"), FOLDER_LIST,buf);
+		aval = alertpanel(_("Warning"), msg, GTK_STOCK_NO, GTK_STOCK_YES, NULL);
+		g_free(msg);
+		if (aval != G_ALERTALTERNATE)
+			return FALSE;
+		else {
+			if (copy_file(bak,filename,FALSE) < 0) {
+				alertpanel_warning(_("Could not copy %s to %s"),bak,filename);
+				return FALSE;
+			}
+			g_free(bak);
+			return TRUE;
+		}
+
+	}
+ 	node = xml_parse_file(filename);
+  	if (!node && is_file_exist(bak)) {
+		AlertValue aval;
+		gchar *msg;
+
+		msg = g_strdup_printf
+			(_("The file %s is empty or corrupted! "
+			   "Do you want to use the backup file from %s?"), FOLDER_LIST,buf);
+		aval = alertpanel(_("Warning"), msg, GTK_STOCK_NO, GTK_STOCK_YES, NULL);
+		g_free(msg);
+		if (aval != G_ALERTALTERNATE)
+			return FALSE;
+		else {
+			if (copy_file(bak,filename,FALSE) < 0) {
+				alertpanel_warning(_("Could not copy %s to %s"),bak,filename);
+				return FALSE;
+			}
+			g_free(bak);	
+		}
+  	}
+
+	return TRUE;	
+}
diff --git a/src/file_checker.h b/src/file_checker.h
new file mode 100644
index 0000000..e08ffe1
--- /dev/null
+++ b/src/file_checker.h
@@ -0,0 +1,31 @@
+/*
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2013 Paul Mangan <paul at claws-mail.org> 
+ * and the Claws Mail team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
+ */
+
+#ifndef __FILE_CHECKER_H__
+#define __FILE_CHECKER_H__
+
+#include <glib.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
+gboolean check_file_integrity();
+
+#endif
+ 
diff --git a/src/folder.c b/src/folder.c
index 39ba0e4..1b4ec03 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -88,7 +88,6 @@ void folder_init		(Folder		*folder,
 static gchar *folder_item_get_cache_file	(FolderItem	*item);
 static gchar *folder_item_get_mark_file	(FolderItem	*item);
 static gchar *folder_item_get_tags_file	(FolderItem	*item);
-static gchar *folder_get_list_path	(void);
 static GNode *folder_get_xml_node	(Folder 	*folder);
 static Folder *folder_get_from_xml	(GNode 		*node);
 static void folder_update_op_count_rec	(GNode		*node);
@@ -4122,7 +4121,7 @@ static Folder *folder_get_from_xml(GNode *node)
 	return folder;
 }
 
-static gchar *folder_get_list_path(void)
+gchar *folder_get_list_path(void)
 {
 	static gchar *filename = NULL;
 
diff --git a/src/folder.h b/src/folder.h
index d87eb0c..44f69bb 100644
--- a/src/folder.h
+++ b/src/folder.h
@@ -998,4 +998,5 @@ gint folder_item_search_msgs_local	(Folder			*folder,
 					 SearchProgressNotify	progress_cb,
 					 gpointer		progress_data);
 
+gchar *folder_get_list_path	(void);
 #endif /* __FOLDER_H__ */
diff --git a/src/main.c b/src/main.c
index f7a2eaa..c7d3eac 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,6 +49,7 @@
 #include <sys/file.h>
 #endif
 
+#include "file_checker.h"
 #include "wizard.h"
 #ifdef HAVE_STARTUP_NOTIFICATION
 # define SN_API_NOT_YET_FROZEN
@@ -1277,6 +1278,9 @@ int main(int argc, char *argv[])
 
 	mainwin = main_window_create();
 
+	if (!check_file_integrity())
+		exit(1);
+
 #ifdef HAVE_NETWORKMANAGER_SUPPORT
 	networkmanager_state_change_cb(nm_proxy,NULL,mainwin);
 #endif

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

Summary of changes:
 po/POTFILES.in                   |    1 +
 src/Makefile.am                  |    2 +
 src/file_checker.c               |  112 ++++++++++++++++++++++++++++++++++++++
 src/{wizard.h => file_checker.h} |   11 ++--
 src/folder.c                     |    3 +-
 src/folder.h                     |    1 +
 src/main.c                       |    4 ++
 7 files changed, 126 insertions(+), 8 deletions(-)
 create mode 100644 src/file_checker.c
 copy src/{wizard.h => file_checker.h} (81%)


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list