file-roller r2435 - in trunk: . src



Author: paobac
Date: Sun Aug 17 14:15:49 2008
New Revision: 2435
URL: http://svn.gnome.org/viewvc/file-roller?rev=2435&view=rev

Log:
2008-08-17  Paolo Bacchilega  <paobac svn gnome org>

	* src/fr-process.h: 
	* src/fr-process.c: 

	Use LC_MESSAGES instead of LC_ALL when use_standard_locale is TRUE.
	Try a series of charsets when input convertion fails.

	* src/typedefs.h: 
	* src/fr-window.c: 
	
	Added a bad_charset error.
	
	* src/glib-utils.h: 
	* src/fr-command-zoo.c: 
	* src/fr-command-zip.c: 
	* src/fr-command-unstuff.c: 
	* src/fr-command-tar.c: 
	* src/fr-command-rpm.c: 
	* src/fr-command-rar.c: 
	* src/fr-command-lha.c: 
	* src/fr-command-iso.c: 
	* src/fr-command-cpio.c: 
	* src/fr-command-arj.c: 
	* src/fr-command-ar.c: 
	* src/fr-command-alz.c: 
	* src/fr-command-ace.c: 
	* src/fr-command-7z.c: 
	
	Use a begin_func callback to initialize the data used in the output
	process.


Modified:
   trunk/ChangeLog
   trunk/TODO
   trunk/src/fr-command-7z.c
   trunk/src/fr-command-ace.c
   trunk/src/fr-command-alz.c
   trunk/src/fr-command-ar.c
   trunk/src/fr-command-arj.c
   trunk/src/fr-command-cpio.c
   trunk/src/fr-command-iso.c
   trunk/src/fr-command-lha.c
   trunk/src/fr-command-rar.c
   trunk/src/fr-command-rpm.c
   trunk/src/fr-command-tar.c
   trunk/src/fr-command-unstuff.c
   trunk/src/fr-command-zip.c
   trunk/src/fr-command-zoo.c
   trunk/src/fr-process.c
   trunk/src/fr-process.h
   trunk/src/fr-window.c
   trunk/src/glib-utils.h
   trunk/src/typedefs.h

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	(original)
+++ trunk/TODO	Sun Aug 17 14:15:49 2008
@@ -21,7 +21,7 @@
 
 [?] #501660 â File-roller nautilus extension creates tarbombs
 
-[ ] #547312 â file-roller fails to read all files in archive that contains utf-8 files
+[ ] #306403 â filenames in non-UTF-8 encodings are not handled correctly
 
 [ ] #547982 â Failure dialog for file extraction should be more useful
 

Modified: trunk/src/fr-command-7z.c
==============================================================================
--- trunk/src/fr-command-7z.c	(original)
+++ trunk/src/fr-command-7z.c	Sun Aug 17 14:15:49 2008
@@ -154,7 +154,7 @@
 		fdata->full_path = g_strconcat ((fdata->original_path[0] != '/') ? "/" : "",
 						fdata->original_path,
 						(fdata->dir && (fdata->original_path[strlen (fdata->original_path - 1)] != '/')) ? "/" : "",
-						NULL);
+						NULL);					
 	}
 	else if (strcmp (fields[0], "Folder") == 0) {
 		fdata->dir = (strcmp (fields[1], "+") == 0);
@@ -213,15 +213,25 @@
 
 
 static void
-fr_command_7z_list (FrCommand  *comm)
+list__begin (gpointer data)
 {
-	FrCommand7z *p7z_comm = FR_COMMAND_7Z (comm);
+	FrCommand7z *p7z_comm = data;
+	
+	if (p7z_comm->fdata != NULL) {
+		file_data_free (p7z_comm->fdata);
+		p7z_comm->fdata = NULL;
+	}
+	p7z_comm->list_started = FALSE;
+}
 
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      list__process_line,
-				      comm);
+
+static void
+fr_command_7z_list (FrCommand  *comm)
+{					   
+	fr_process_set_out_line_func (comm->process, list__process_line, comm);
 
 	fr_command_7z_begin_command (comm);
+	fr_process_set_begin_func (comm->process, list__begin, comm);
 	fr_process_add_arg (comm->process, "l");
 	fr_process_add_arg (comm->process, "-slt");
 	fr_process_add_arg (comm->process, "-bd");
@@ -231,11 +241,6 @@
 	fr_process_add_arg (comm->process, comm->filename);
 	fr_process_end_command (comm->process);
 
-	if (p7z_comm->fdata != NULL) {
-		file_data_free (p7z_comm->fdata);
-		p7z_comm->fdata = NULL;
-	}
-	p7z_comm->list_started = FALSE;
 	fr_process_start (comm->process);
 }
 

Modified: trunk/src/fr-command-ace.c
==============================================================================
--- trunk/src/fr-command-ace.c	(original)
+++ trunk/src/fr-command-ace.c	Sun Aug 17 14:15:49 2008
@@ -162,16 +162,22 @@
 
 
 static void
-fr_command_ace_list (FrCommand  *comm)
+list__begin (gpointer data)
 {
-	FR_COMMAND_ACE (comm)->list_started = FALSE;
-	FR_COMMAND_ACE (comm)->command_type = FR_ACE_COMMAND_UNKNOWN;
+	FrCommandAce *comm = data;
+	
+	comm->list_started = FALSE;
+	comm->command_type = FR_ACE_COMMAND_UNKNOWN;
+}
+
 
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      process_line,
-				      comm);
+static void
+fr_command_ace_list (FrCommand  *comm)
+{
+	fr_process_set_out_line_func (comm->process, process_line, comm);
 
 	fr_process_begin_command (comm->process, "unace");
+	fr_process_set_begin_func (comm->process, list__begin, comm);
 	fr_process_add_arg (comm->process, "v");
 	fr_process_add_arg (comm->process, "-y");
 	fr_process_add_arg (comm->process, comm->filename);

Modified: trunk/src/fr-command-alz.c
==============================================================================
--- trunk/src/fr-command-alz.c	(original)
+++ trunk/src/fr-command-alz.c	Sun Aug 17 14:15:49 2008
@@ -200,16 +200,22 @@
 
 
 static void
-fr_command_alz_list (FrCommand  *comm)
+list__begin (gpointer data)
 {
-	FR_COMMAND_ALZ (comm)->list_started = FALSE;
-	FR_COMMAND_ALZ (comm)->invalid_password = FALSE;
+	FrCommandAlz *comm = data;
+	
+	comm->list_started = FALSE;
+	comm->invalid_password = FALSE;
+}
 
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      process_line,
-				      comm);
+
+static void
+fr_command_alz_list (FrCommand  *comm)
+{
+	fr_process_set_out_line_func (FR_COMMAND (comm)->process, process_line, comm);
 
 	fr_process_begin_command (comm->process, "unalz");
+	fr_process_set_begin_func (comm->process, list__begin, comm);
 	fr_process_add_arg (comm->process, "-l");
 	add_codepage_arg(comm);
 	fr_process_add_arg (comm->process, comm->filename);

Modified: trunk/src/fr-command-ar.c
==============================================================================
--- trunk/src/fr-command-ar.c	(original)
+++ trunk/src/fr-command-ar.c	Sun Aug 17 14:15:49 2008
@@ -188,11 +188,9 @@
 
 
 static void
-fr_command_ar_list (FrCommand  *comm)
+fr_command_ar_list (FrCommand *comm)
 {
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      process_line,
-				      comm);
+	fr_process_set_out_line_func (comm->process, process_line, comm);
 
 	fr_process_begin_command (comm->process, "ar");
 	fr_process_add_arg (comm->process, "tv");

Modified: trunk/src/fr-command-arj.c
==============================================================================
--- trunk/src/fr-command-arj.c	(original)
+++ trunk/src/fr-command-arj.c	Sun Aug 17 14:15:49 2008
@@ -160,11 +160,9 @@
 
 
 static void
-fr_command_arj_list (FrCommand  *comm)
+fr_command_arj_list (FrCommand *comm)
 {
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      list__process_line,
-				      comm);
+	fr_process_set_out_line_func (comm->process, list__process_line, comm);
 
 	fr_process_begin_command (comm->process, "arj");
 	fr_process_add_arg (comm->process, "v");

Modified: trunk/src/fr-command-cpio.c
==============================================================================
--- trunk/src/fr-command-cpio.c	(original)
+++ trunk/src/fr-command-cpio.c	Sun Aug 17 14:15:49 2008
@@ -177,9 +177,7 @@
 {
 	GString *cmd;
 
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      list__process_line,
-				      comm);
+	fr_process_set_out_line_func (comm->process, list__process_line, comm);
 
 	fr_process_begin_command (comm->process, "sh");
 	fr_process_add_arg (comm->process, "-c");

Modified: trunk/src/fr-command-iso.c
==============================================================================
--- trunk/src/fr-command-iso.c	(original)
+++ trunk/src/fr-command-iso.c	Sun Aug 17 14:15:49 2008
@@ -128,18 +128,22 @@
 
 
 static void
-fr_command_iso_list (FrCommand  *comm)
+list__begin (gpointer data)
 {
-	FrCommandIso *comm_iso = FR_COMMAND_ISO (comm);
+	FrCommandIso *comm = data;
+	
+	g_free (comm->cur_path);
+	comm->cur_path = NULL;
+}
 
-	g_free (comm_iso->cur_path);
-	comm_iso->cur_path = NULL;
 
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      list__process_line,
-				      comm);
+static void
+fr_command_iso_list (FrCommand *comm)
+{
+	fr_process_set_out_line_func (comm->process, list__process_line, comm);
 
 	fr_process_begin_command (comm->process, "sh");
+	fr_process_set_begin_func (comm->process, list__begin, comm);
 	fr_process_add_arg (comm->process, PRIVEXECDIR "isoinfo.sh");
 	fr_process_add_arg (comm->process, "-i");
 	fr_process_add_arg (comm->process, comm->filename);

Modified: trunk/src/fr-command-lha.c
==============================================================================
--- trunk/src/fr-command-lha.c	(original)
+++ trunk/src/fr-command-lha.c	Sun Aug 17 14:15:49 2008
@@ -212,9 +212,7 @@
 static void
 fr_command_lha_list (FrCommand  *comm)
 {
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      process_line,
-				      comm);
+	fr_process_set_out_line_func (comm->process, process_line, comm);
 
 	fr_process_begin_command (comm->process, "lha");
 	fr_process_add_arg (comm->process, "lq");

Modified: trunk/src/fr-command-rar.c
==============================================================================
--- trunk/src/fr-command-rar.c	(original)
+++ trunk/src/fr-command-rar.c	Sun Aug 17 14:15:49 2008
@@ -315,18 +315,26 @@
 
 
 static void
+list__begin (gpointer data)
+{
+	FrCommandRar *comm = data;
+	
+	comm->list_started = FALSE;
+}
+
+
+static void
 fr_command_rar_list (FrCommand  *comm)
 {
 	check_multi_vomule (comm);
 
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      process_line,
-				      comm);
+	fr_process_set_out_line_func (comm->process, process_line, comm);
 
 	if (have_rar ())
 		fr_process_begin_command (comm->process, "rar");
 	else
 		fr_process_begin_command (comm->process, "unrar");
+	fr_process_set_begin_func (comm->process, list__begin, comm);
 	fr_process_add_arg (comm->process, "v");
 	fr_process_add_arg (comm->process, "-c-");
 	fr_process_add_arg (comm->process, "-v");
@@ -339,7 +347,6 @@
 	fr_process_add_arg (comm->process, comm->filename);
 	fr_process_end_command (comm->process);
 
-	FR_COMMAND_RAR (comm)->list_started = FALSE;
 	fr_process_start (comm->process);
 }
 

Modified: trunk/src/fr-command-rpm.c
==============================================================================
--- trunk/src/fr-command-rpm.c	(original)
+++ trunk/src/fr-command-rpm.c	Sun Aug 17 14:15:49 2008
@@ -152,11 +152,9 @@
 
 
 static void
-fr_command_rpm_list (FrCommand  *comm)
+fr_command_rpm_list (FrCommand *comm)
 {
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      list__process_line,
-				      comm);
+	fr_process_set_out_line_func (comm->process, list__process_line, comm);
 
 	fr_process_begin_command (comm->process, "sh");
 	fr_process_add_arg (comm->process, "-c");

Modified: trunk/src/fr-command-tar.c
==============================================================================
--- trunk/src/fr-command-tar.c	(original)
+++ trunk/src/fr-command-tar.c	Sun Aug 17 14:15:49 2008
@@ -241,11 +241,9 @@
 
 
 static void
-fr_command_tar_list (FrCommand  *comm)
+fr_command_tar_list (FrCommand *comm)
 {
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      process_line,
-				      comm);
+	fr_process_set_out_line_func (comm->process, process_line, comm);
 
 	begin_tar_command (comm);
 	fr_process_add_arg (comm->process, "--force-local");

Modified: trunk/src/fr-command-unstuff.c
==============================================================================
--- trunk/src/fr-command-unstuff.c	(original)
+++ trunk/src/fr-command-unstuff.c	Sun Aug 17 14:15:49 2008
@@ -180,17 +180,25 @@
 
 
 static void
-fr_command_unstuff_list (FrCommand  *comm)
+list__begin (gpointer data)
+{
+	FrCommandUnstuff *comm = data;
+	
+	comm->fdata = NULL;
+}
+
+
+static void
+fr_command_unstuff_list (FrCommand *comm)
 {
 	char *arg, *path;
 	char *filename;
 	char *path_dots;
 
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      process_line,
-				      comm);
+	fr_process_set_out_line_func (comm->process, process_line, comm);
 
 	fr_process_begin_command (comm->process, "unstuff");
+	fr_process_set_begin_func (comm->process, list__begin, comm);
 	fr_process_add_arg (comm->process, "--trace");
 
 	/* Actually unpack everything in a temporary directory */

Modified: trunk/src/fr-command-zip.c
==============================================================================
--- trunk/src/fr-command-zip.c	(original)
+++ trunk/src/fr-command-zip.c	Sun Aug 17 14:15:49 2008
@@ -173,15 +173,21 @@
 
 
 static void
-fr_command_zip_list (FrCommand  *comm)
+list__begin (gpointer data)
 {
-	FR_COMMAND_ZIP (comm)->is_empty = FALSE;
+	FrCommandZip *comm = data;
+	
+	comm->is_empty = FALSE;
+}
 
-	fr_process_set_out_line_func (FR_COMMAND (comm)->process,
-				      list__process_line,
-				      comm);
+
+static void
+fr_command_zip_list (FrCommand  *comm)
+{
+	fr_process_set_out_line_func (comm->process, list__process_line, comm);
 
 	fr_process_begin_command (comm->process, "unzip");
+	fr_process_set_begin_func (comm->process, list__begin, comm);
 	fr_process_add_arg (comm->process, "-ZTs");
 	fr_process_add_arg (comm->process, comm->filename);
 	fr_process_end_command (comm->process);

Modified: trunk/src/fr-command-zoo.c
==============================================================================
--- trunk/src/fr-command-zoo.c	(original)
+++ trunk/src/fr-command-zoo.c	Sun Aug 17 14:15:49 2008
@@ -222,9 +222,7 @@
 static void
 fr_command_zoo_list (FrCommand  *zoo_comm)
 {
-	fr_process_set_out_line_func (FR_COMMAND (zoo_comm)->process,
-				      process_zoo_line,
-				      zoo_comm);
+	fr_process_set_out_line_func (zoo_comm->process, process_zoo_line, zoo_comm);
 
 	fr_process_begin_command (zoo_comm->process, "zoo");
 	fr_process_add_arg (zoo_comm->process, "lq");

Modified: trunk/src/fr-process.c
==============================================================================
--- trunk/src/fr-process.c	(original)
+++ trunk/src/fr-process.c	Sun Aug 17 14:15:49 2008
@@ -111,6 +111,8 @@
 {
 	channel->source = NULL;
 	channel->raw = NULL;
+	channel->status = G_IO_STATUS_NORMAL;
+	channel->error = NULL;
 }
 
 
@@ -125,36 +127,42 @@
 }
 
 
-static gboolean
+static GIOStatus
 fr_channel_data_read (FrChannelData *channel)
 {
-	GIOStatus  status;
-	char      *line;
-	gsize      length;
-	gsize      terminator_pos;
-
-	while ((status = g_io_channel_read_line (channel->source,
-						 &line,
-						 &length,
-						 &terminator_pos,
-						 NULL)) == G_IO_STATUS_NORMAL)
+	char  *line;
+	gsize  length;
+	gsize  terminator_pos;
+	
+	channel->status = G_IO_STATUS_NORMAL;
+	g_clear_error (&channel->error);
+		
+	while ((channel->status = g_io_channel_read_line (channel->source,
+							  &line,
+							  &length,
+							  &terminator_pos,
+							  &channel->error)) == G_IO_STATUS_NORMAL)
 	{
 		line[terminator_pos] = 0;
 		channel->raw = g_list_prepend (channel->raw, line);
 		if (channel->line_func != NULL)
 			(*channel->line_func) (line, channel->line_data);
 	}
-
-	return (status == G_IO_STATUS_AGAIN);
+	
+	return channel->status;
 }
 
 
-static void
+static GIOStatus
 fr_channel_data_flush (FrChannelData *channel)
 {
-	while (fr_channel_data_read (channel))
+	GIOStatus status;
+	
+	while (((status = fr_channel_data_read (channel)) != G_IO_STATUS_ERROR) && (status != G_IO_STATUS_EOF))
 		/* void */;
 	fr_channel_data_close_source (channel);
+	
+	return status;
 }
 
 
@@ -180,19 +188,23 @@
 
 static void
 fr_channel_data_set_fd (FrChannelData *channel,
-			int            fd)
+			int            fd,
+			const char    *charset)
 {
-	const char *charset;
-
 	fr_channel_data_reset (channel);
+
 	channel->source = g_io_channel_unix_new (fd);
 	g_io_channel_set_flags (channel->source, G_IO_FLAG_NONBLOCK, NULL);
 	g_io_channel_set_buffer_size (channel->source, BUFFER_SIZE);
-	if (! g_get_charset (&charset))
+	if (charset != NULL)
 		g_io_channel_set_encoding (channel->source, charset, NULL);
 }
 
 
+const char *try_charsets[] = { "UTF-8", "ISO-8859-1", "WINDOW-1252" };
+int n_charsets = G_N_ELEMENTS (try_charsets);
+
+
 struct _FrProcessPrivate {
 	GPtrArray   *comm;                /* FrCommandInfo elements. */
 	gint         n_comm;              /* total number of commands */
@@ -211,6 +223,7 @@
 	gboolean     use_standard_locale;
 	gboolean     sticky_only;         /* whether to execute only sticky
 			 		   * commands. */
+	int          current_charset;
 };
 
 
@@ -303,6 +316,8 @@
 	process->priv->running = FALSE;
 	process->priv->stopping = FALSE;
 	process->restart = FALSE;
+	
+	process->priv->current_charset = -1;
 
 	process->priv->use_standard_locale = FALSE;
 }
@@ -622,7 +637,21 @@
 	FrProcess *process = user_data;
 
 	if (process->priv->use_standard_locale)
-		putenv ("LC_ALL=C");
+		putenv ("LC_MESSAGES=C");
+}
+
+
+static const char *
+fr_process_get_charset (FrProcess *process)
+{
+	const char *charset = NULL;
+	
+	if (process->priv->current_charset >= 0)
+		charset = try_charsets[process->priv->current_charset];
+	else if (g_get_charset (&charset))
+		charset = NULL;
+	
+	return charset;
 }
 
 
@@ -649,7 +678,7 @@
 		int j;
 
 		if (process->priv->use_standard_locale)
-			g_print ("\tLC_ALL=C\n");
+			g_print ("\tLC_MESSAGES=C\n");
 
 		if (info->dir != NULL)
 			g_print ("\tcd %s\n", info->dir);
@@ -688,8 +717,8 @@
 
 	g_free (argv);
 
-	fr_channel_data_set_fd (&process->out, out_fd);
-	fr_channel_data_set_fd (&process->err, err_fd);
+	fr_channel_data_set_fd (&process->out, out_fd, fr_process_get_charset (process));
+	fr_channel_data_set_fd (&process->err, err_fd, fr_process_get_charset (process));
 
 	process->priv->check_timeout = g_timeout_add (REFRESH_RATE,
 					              check_child,
@@ -730,6 +759,22 @@
 }
 
 
+static void
+fr_process_set_error (FrProcess       *process,
+		      FrProcErrorType  type,
+		      int              status,
+		      GError          *gerror)
+{
+	process->error.type = type;
+	process->error.status = status;
+	if (gerror != process->error.gerror) {
+		g_clear_error (&process->error.gerror);
+		if (gerror != NULL)
+			process->error.gerror = g_error_copy (gerror);
+	}
+}					 	
+
+
 static gint
 check_child (gpointer data)
 {
@@ -738,6 +783,7 @@
 	pid_t           pid;
 	int             status;
 	gboolean        continue_process;
+	gboolean        channel_error = FALSE;
 
 	info = g_ptr_array_index (process->priv->comm, process->priv->current_command);
 
@@ -746,23 +792,30 @@
 	g_source_remove (process->priv->check_timeout);
 	process->priv->check_timeout = 0;
 
-	fr_channel_data_read (&process->out);
-	fr_channel_data_read (&process->err);
-
-	pid = waitpid (process->priv->command_pid, &status, WNOHANG);
-	if (pid != process->priv->command_pid) {
-		/* Add check again. */
-		process->priv->check_timeout = g_timeout_add (REFRESH_RATE,
-						              check_child,
-						              process);
-		return FALSE;
+	if (fr_channel_data_read (&process->out) == G_IO_STATUS_ERROR) {
+		fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->out.error);
+		channel_error = TRUE;
+	}
+	else if (fr_channel_data_read (&process->err) == G_IO_STATUS_ERROR) {
+		fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->err.error);
+		channel_error = TRUE;
+	}
+	else {
+		pid = waitpid (process->priv->command_pid, &status, WNOHANG);
+		if (pid != process->priv->command_pid) {
+			/* Add check again. */
+			process->priv->check_timeout = g_timeout_add (REFRESH_RATE,
+							              check_child,
+							              process);
+			return FALSE;
+		}
 	}
 
 	if (info->ignore_error) {
 		process->error.type = FR_PROC_ERROR_NONE;
 		debug (DEBUG_INFO, "[ignore error]\n");
 	}
-	else if (process->error.type != FR_PROC_ERROR_STOPPED) {
+	else if (! channel_error && (process->error.type != FR_PROC_ERROR_STOPPED)) {
 		if (WIFEXITED (status)) {
 			if (WEXITSTATUS (status) == 0)
 				process->error.type = FR_PROC_ERROR_NONE;
@@ -778,14 +831,37 @@
 	}
 
 	process->priv->command_pid = 0;
-	fr_channel_data_flush (&process->out);
-	fr_channel_data_flush (&process->err);
-
-	/**/
+	
+	if (fr_channel_data_flush (&process->out) == G_IO_STATUS_ERROR) {
+		fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->out.error);
+		channel_error = TRUE;
+	}
+	else if (fr_channel_data_flush (&process->err) == G_IO_STATUS_ERROR) {
+		fr_process_set_error (process, FR_PROC_ERROR_IO_CHANNEL, 0, process->err.error);
+		channel_error = TRUE;
+	}
 
 	if (info->end_func != NULL)
 		(*info->end_func) (info->end_data);
 
+	/**/
+
+	if (channel_error 
+	    && (process->error.type == FR_PROC_ERROR_IO_CHANNEL)
+	    && g_error_matches (process->error.gerror, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
+	{	
+		if (process->priv->current_charset < n_charsets - 1) {
+			/* try with another charset */
+			process->priv->current_charset++;
+			process->priv->running = FALSE;
+			process->restart = TRUE;
+			fr_process_start (process);
+			return FALSE;
+		}		
+		/*fr_process_set_error (process, FR_PROC_ERROR_NONE, 0, NULL);*/
+		fr_process_set_error (process, FR_PROC_ERROR_BAD_CHARSET, 0, process->error.gerror);
+	}
+
 	/* Check whether to continue or stop the process */
 
 	continue_process = TRUE;
@@ -827,11 +903,10 @@
 
 	if (process->priv->sticky_only) {
 		/* Restore the first error. */
-		process->error.type = process->priv->first_error.type;
-		process->error.status = process->priv->first_error.status;
-		g_clear_error (&process->error.gerror);
-		if (process->priv->first_error.gerror != NULL)
-			process->error.gerror = g_error_copy (process->priv->first_error.gerror);
+		fr_process_set_error (process, 
+				      process->priv->first_error.type, 
+				      process->priv->first_error.status, 
+				      process->priv->first_error.gerror);
 	}
 
 	g_signal_emit (G_OBJECT (process),
@@ -864,12 +939,14 @@
 
 	process->priv->sticky_only = FALSE;
 	process->priv->current_command = 0;
-	process->error.type = FR_PROC_ERROR_NONE;
+	fr_process_set_error (process, FR_PROC_ERROR_NONE, 0, NULL);
 
-	if (! process->restart)
+	if (! process->restart) {
+		process->priv->current_charset = -1;
 		g_signal_emit (G_OBJECT (process),
 			       fr_process_signals[START],
 			       0);
+	}
 
 	process->priv->stopping = FALSE;
 

Modified: trunk/src/fr-process.h
==============================================================================
--- trunk/src/fr-process.h	(original)
+++ trunk/src/fr-process.h	Sun Aug 17 14:15:49 2008
@@ -48,6 +48,8 @@
 	GList      *raw;
 	LineFunc    line_func;
 	gpointer    line_data;
+	GIOStatus   status;
+	GError     *error;
 } FrChannelData;
 
 struct _FrProcess {

Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c	(original)
+++ trunk/src/fr-window.c	Sun Aug 17 14:15:49 2008
@@ -2828,6 +2828,13 @@
 		dlg_ask_password (window);
 		return FALSE;
 	}
+#if 0	
+	if (error->type == FR_PROC_ERROR_BAD_CHARSET) {
+		close_progress_dialog (window, TRUE);
+		/* dlg_ask_archive_charset (window); FIXME: implement after feature freeze */
+		return FALSE;
+	}
+#endif	
 	else if (error->type == FR_PROC_ERROR_STOPPED) {
 		/* nothing */
 	}
@@ -2990,9 +2997,12 @@
 
 	continue_batch = handle_errors (window, archive, action, error);
 
-	if (error->type == FR_PROC_ERROR_ASK_PASSWORD)
+	if ((error->type == FR_PROC_ERROR_ASK_PASSWORD)
+	    /*|| (error->type == FR_PROC_ERROR_BAD_CHARSET)*/)
+	{
 		return;
-
+	}
+	
 	switch (action) {
 	case FR_ACTION_CREATING_NEW_ARCHIVE:
 	case FR_ACTION_CREATING_ARCHIVE:

Modified: trunk/src/glib-utils.h
==============================================================================
--- trunk/src/glib-utils.h	(original)
+++ trunk/src/glib-utils.h	Sun Aug 17 14:15:49 2008
@@ -34,7 +34,7 @@
 char *              str_substitute               (const char *str,
 						  const char *from_str,
 						  const char *to_str);
-int                 strcmp_null_tolerant        (const char *s1, const char *s2);
+int                 strcmp_null_tolerant         (const char *s1, const char *s2);
 char*               escape_str_common            (const char *str,
 						  const char *meta_chars,
 						  const char  prefix,

Modified: trunk/src/typedefs.h
==============================================================================
--- trunk/src/typedefs.h	(original)
+++ trunk/src/typedefs.h	Sun Aug 17 14:15:49 2008
@@ -63,7 +63,9 @@
 	FR_PROC_ERROR_SPAWN,
 	FR_PROC_ERROR_STOPPED,
 	FR_PROC_ERROR_ASK_PASSWORD,
-	FR_PROC_ERROR_MISSING_VOLUME
+	FR_PROC_ERROR_MISSING_VOLUME,
+	FR_PROC_ERROR_IO_CHANNEL,
+	FR_PROC_ERROR_BAD_CHARSET
 } FrProcErrorType;
 
 typedef struct {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]