brasero r1459 - in trunk: . src src/plugins/checksum



Author: philippr
Date: Sun Nov  2 22:21:31 2008
New Revision: 1459
URL: http://svn.gnome.org/viewvc/brasero?rev=1459&view=rev

Log:
	Changed the way we dealt with lists of files having a wrong checksum.
	Use track tags instead which cleans up the headers a little.

	* src/brasero-sum-dialog.c (brasero_sum_dialog_corruption_warning),
	(brasero_sum_dialog_set_track_checksum_type),
	(brasero_sum_dialog_check_disc_sum):
	* src/burn-basics.h:
	* src/burn-job.c:
	* src/burn-job.h:
	* src/burn-session.c (brasero_burn_session_finalize):
	* src/burn-session.h:
	* src/burn-track.c (brasero_track_tag_add):
	* src/burn-track.h:
	* src/plugins/checksum/burn-checksum-files.c
	(brasero_checksum_files_check_files):

Modified:
   trunk/ChangeLog
   trunk/src/brasero-sum-dialog.c
   trunk/src/burn-basics.h
   trunk/src/burn-job.c
   trunk/src/burn-job.h
   trunk/src/burn-session.c
   trunk/src/burn-session.h
   trunk/src/burn-track.c
   trunk/src/burn-track.h
   trunk/src/plugins/checksum/burn-checksum-files.c

Modified: trunk/src/brasero-sum-dialog.c
==============================================================================
--- trunk/src/brasero-sum-dialog.c	(original)
+++ trunk/src/brasero-sum-dialog.c	Sun Nov  2 22:21:31 2008
@@ -178,9 +178,8 @@
 
 static gboolean
 brasero_sum_dialog_corruption_warning (BraseroSumDialog *self,
-				       GSList *wrong_sums)
+				       const gchar **wrong_sums)
 {
-	GSList *iter;
 	gchar *string;
 	GtkWidget *tree;
 	GtkWidget *scroll;
@@ -219,11 +218,11 @@
 
 	/* build a list */
 	model = GTK_TREE_MODEL (gtk_list_store_new (BRASERO_SUM_DIALOG_NB_COL, G_TYPE_STRING));
-	for (iter = wrong_sums; iter; iter = iter->next) {
-		gchar *path;
+	for (; wrong_sums && (*wrong_sums); wrong_sums ++) {
+		const gchar *path;
 		GtkTreeIter tree_iter;
 
-		path = iter->data;
+		path = (*wrong_sums);
 		gtk_list_store_append (GTK_LIST_STORE (model), &tree_iter);
 		gtk_list_store_set (GTK_LIST_STORE (model), &tree_iter,
 				    BRASERO_SUM_DIALOG_PATH, path,
@@ -542,8 +541,10 @@
 		return BRASERO_CHECKSUM_NONE;
 
 	filename = g_build_path (G_DIR_SEPARATOR_S, root, BRASERO_MD5_FILE, NULL);
+
 	if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
 		g_free (filename);
+		g_free (root);
 
 		brasero_track_set_checksum (track,
 					    BRASERO_CHECKSUM_MD5_FILE,
@@ -556,6 +557,7 @@
 	filename = g_build_path (G_DIR_SEPARATOR_S, root, BRASERO_SHA1_FILE, NULL);
 	if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
 		g_free (filename);
+		g_free (root);
 
 		brasero_track_set_checksum (track,
 					    BRASERO_CHECKSUM_SHA1_FILE,
@@ -568,6 +570,7 @@
 	filename = g_build_path (G_DIR_SEPARATOR_S, root, BRASERO_SHA256_FILE, NULL);
 	if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
 		g_free (filename);
+		g_free (root);
 
 		brasero_track_set_checksum (track,
 					    BRASERO_CHECKSUM_SHA256_FILE,
@@ -576,6 +579,7 @@
 		return BRASERO_CHECKSUM_SHA256_FILE;
 	}
 	g_free (filename);
+	g_free (root);
 
 	g_set_error (error,
 		     BRASERO_ERROR,
@@ -590,9 +594,9 @@
 				   BraseroDrive *drive)
 {
 	BraseroChecksumType checksum_type;
-	GSList *wrong_sums = NULL;
 	BraseroBurnResult result;
 	GError *error = NULL;
+	GValue *value = NULL;
 	BraseroTrack *track;
 	BraseroBurn *burn;
 	gboolean retval;
@@ -646,12 +650,11 @@
 
 	g_error_free (error);
 
-	wrong_sums = brasero_burn_session_get_wrong_checksums (self->priv->session);
-	retval = brasero_sum_dialog_corruption_warning (self, wrong_sums);
-	g_slist_foreach (wrong_sums, (GFunc) g_free, NULL);
-	g_slist_free (wrong_sums);
+	brasero_track_tag_lookup (track,
+				  BRASERO_TRACK_MEDIUM_WRONG_CHECKSUM_TAG,
+				  &value);
 
-	return retval;
+	return brasero_sum_dialog_corruption_warning (self, g_value_get_boxed (value));
 }
 
 static gboolean

Modified: trunk/src/burn-basics.h
==============================================================================
--- trunk/src/burn-basics.h	(original)
+++ trunk/src/burn-basics.h	Sun Nov  2 22:21:31 2008
@@ -193,7 +193,7 @@
 /**
  * Define the audio streams for a DVD
  */
-#define BRASERO_DVD_AUDIO_STREAMS		"DVD-audio-format"
+#define BRASERO_DVD_AUDIO_STREAMS		"session::DVD::audio::format"
 
 /**
  * Define the format: whether VCD or SVCD
@@ -204,7 +204,7 @@
 	BRASERO_VCD_V2,
 	BRASERO_SVCD
 };
-#define BRASERO_VCD_TYPE			"VCD-format"
+#define BRASERO_VCD_TYPE			"session::VCD::format"
 
 /**
  * This is the video format that should be used.
@@ -214,7 +214,7 @@
 	BRASERO_VIDEO_FRAMERATE_NTSC,
 	BRASERO_VIDEO_FRAMERATE_PAL_SECAM
 };
-#define BRASERO_VIDEO_OUTPUT_FRAMERATE		"video-framerate"
+#define BRASERO_VIDEO_OUTPUT_FRAMERATE		"session::video::framerate"
 
 /**
  * Aspect ratio
@@ -224,7 +224,7 @@
 	BRASERO_VIDEO_ASPECT_4_3,
 	BRASERO_VIDEO_ASPECT_16_9
 };
-#define BRASERO_VIDEO_OUTPUT_ASPECT		"video-aspect"
+#define BRASERO_VIDEO_OUTPUT_ASPECT		"session::video::aspect"
 
 
 G_END_DECLS

Modified: trunk/src/burn-job.c
==============================================================================
--- trunk/src/burn-job.c	(original)
+++ trunk/src/burn-job.c	Sun Nov  2 22:21:31 2008
@@ -1741,22 +1741,6 @@
  */
 
 BraseroBurnResult
-brasero_job_add_wrong_checksum (BraseroJob *self,
-				const gchar *path)
-{
-	BraseroJobPrivate *priv;
-	BraseroBurnSession *session;
-
-	BRASERO_JOB_DEBUG (self);
-
-	priv = BRASERO_JOB_PRIVATE (self);
-	session = brasero_task_ctx_get_session (priv->ctx);
-
-	brasero_burn_session_add_wrong_checksum (session, path);
-	return BRASERO_BURN_OK;
-}
-
-BraseroBurnResult
 brasero_job_set_progress (BraseroJob *self,
 			  gdouble progress)
 {

Modified: trunk/src/burn-job.h
==============================================================================
--- trunk/src/burn-job.h	(original)
+++ trunk/src/burn-job.h	Sun Nov  2 22:21:31 2008
@@ -276,10 +276,6 @@
 					       gint64 sectors,
 					       gint64 size);
 
-BraseroBurnResult
-brasero_job_add_wrong_checksum (BraseroJob *job,
-				const gchar *path);
-
 /**
  * Used to tell it's (or not) dangerous to interrupt this job
  */

Modified: trunk/src/burn-session.c
==============================================================================
--- trunk/src/burn-session.c	(original)
+++ trunk/src/burn-session.c	Sun Nov  2 22:21:31 2008
@@ -78,8 +78,6 @@
 	FILE *session;
 	gchar *session_path;
 
-	GSList *wrong_checksums;
-
 	GSList *tmpfiles;
 
 	BraseroSessionSetting settings [1];
@@ -1321,37 +1319,6 @@
 }
 
 
-/**
- *
- */
-
-void
-brasero_burn_session_add_wrong_checksum (BraseroBurnSession *self,
-					 const gchar *path)
-{
-	BraseroBurnSessionPrivate *priv;
-
-	priv = BRASERO_BURN_SESSION_PRIVATE (self);
-	priv->wrong_checksums = g_slist_prepend (priv->wrong_checksums, g_strdup (path));
-}
-
-GSList *
-brasero_burn_session_get_wrong_checksums (BraseroBurnSession *self)
-{
-	BraseroBurnSessionPrivate *priv;
-	GSList *retval;
-
-	g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), NULL);
-
-	priv = BRASERO_BURN_SESSION_PRIVATE (self);
-
-	/* reset our list so it will return only the new ones next time */
-	retval = priv->wrong_checksums;
-	priv->wrong_checksums = NULL;
-
-	return retval;
-}
-
 /****************************** this part is for log ***************************/
 void
 brasero_burn_session_logv (BraseroBurnSession *self,
@@ -1647,12 +1614,6 @@
 		priv->session_path = NULL;
 	}
 
-	if (priv->wrong_checksums) {
-		g_slist_foreach (priv->wrong_checksums, (GFunc) g_free, NULL);
-		g_slist_free (priv->wrong_checksums);
-		priv->wrong_checksums = NULL;
-	}
-
 	brasero_session_settings_clean (priv->settings);
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);

Modified: trunk/src/burn-session.h
==============================================================================
--- trunk/src/burn-session.h	(original)
+++ trunk/src/burn-session.h	Sun Nov  2 22:21:31 2008
@@ -289,18 +289,6 @@
 guint
 brasero_burn_session_get_num_copies (BraseroBurnSession *session);
 
-/**
- * Used to report wrong checksum
- */
-
-void
-brasero_burn_session_add_wrong_checksum (BraseroBurnSession *session,
-					 const gchar *path);
-
-GSList *
-brasero_burn_session_get_wrong_checksums (BraseroBurnSession *session);
-
-
 G_END_DECLS
 
 #endif /* BURN_SESSION_H */

Modified: trunk/src/burn-track.c
==============================================================================
--- trunk/src/burn-track.c	(original)
+++ trunk/src/burn-track.c	Sun Nov  2 22:21:31 2008
@@ -1147,7 +1147,10 @@
 						     g_str_equal,
 						     g_free,
 						     brasero_track_tag_value_free);
-	g_hash_table_insert (track->tags, g_strdup (tag), value);
+	g_hash_table_insert (track->tags,
+			     g_strdup (tag),
+			     value);
+
 	return BRASERO_BURN_OK;
 }
 

Modified: trunk/src/burn-track.h
==============================================================================
--- trunk/src/burn-track.h	(original)
+++ trunk/src/burn-track.h	Sun Nov  2 22:21:31 2008
@@ -331,8 +331,14 @@
  * Commonly used Tags
  */
 
-#define BRASERO_TRACK_MEDIUM_ADDRESS_START_TAG	"track::medium::address::start"
-#define BRASERO_TRACK_MEDIUM_ADDRESS_END_TAG	"track::medium::address::end"
+#define BRASERO_TRACK_MEDIUM_ADDRESS_START_TAG		"track::medium::address::start"
+#define BRASERO_TRACK_MEDIUM_ADDRESS_END_TAG		"track::medium::address::end"
+
+/**
+ * Array of filenames (on medium) which have a wrong checksum value (G_TYPE_STRV)
+ */
+
+#define BRASERO_TRACK_MEDIUM_WRONG_CHECKSUM_TAG		"track::medium::error::checksum::list"
 
 G_END_DECLS
 

Modified: trunk/src/plugins/checksum/burn-checksum-files.c
==============================================================================
--- trunk/src/plugins/checksum/burn-checksum-files.c	(original)
+++ trunk/src/plugins/checksum/burn-checksum-files.c	Sun Nov  2 22:21:31 2008
@@ -678,17 +678,16 @@
 	const gchar *name;
 	gint checksum_len;
 	BraseroTrack *track;
+	GValue *value = NULL;
 	BraseroMedium *medium;
-	gboolean has_wrongsums;
 	GChecksumType gchecksum_type;
-	BraseroChecksumFilesPrivate *priv;
+	GArray *wrong_checksums = NULL;
 	gchar filename [MAXPATHLEN + 1];
+	BraseroChecksumFilesPrivate *priv;
 	BraseroBurnResult result = BRASERO_BURN_OK;
 
 	priv = BRASERO_CHECKSUM_FILES_PRIVATE (self);
 
-	has_wrongsums = FALSE;
-
 	brasero_job_get_current_track (BRASERO_JOB (self), &track);
 	medium = brasero_track_get_medium_source (track);
 	root = brasero_volume_get_mount_point (BRASERO_VOLUME (medium), FALSE);
@@ -847,8 +846,15 @@
 				 filename, checksum_file, checksum_real);
 
 		if (strcmp (checksum_file, checksum_real)) {
-			has_wrongsums = TRUE;
-			brasero_job_add_wrong_checksum (BRASERO_JOB (self), filename);
+			gchar *string;
+			if (!wrong_checksums)
+				wrong_checksums = g_array_new (TRUE,
+							       TRUE, 
+							       sizeof (gchar *));
+
+			string = g_strdup (filename);
+			wrong_checksums = g_array_append_val (wrong_checksums,
+							      string);
 		}
 
 		g_free (checksum_real);
@@ -863,15 +869,25 @@
 	if (result != BRASERO_BURN_OK)
 		return result;
 
-	if (has_wrongsums) {
-		g_set_error (error,
-			     BRASERO_BURN_ERROR,
-			     BRASERO_BURN_ERROR_BAD_CHECKSUM,
-			     _("some files may be corrupted on the disc"));
-		return BRASERO_BURN_ERR;
-	}
+	if (!wrong_checksums)
+		return BRASERO_BURN_OK;
 
-	return BRASERO_BURN_OK;
+	/* add the tag */
+	value = g_new0 (GValue, 1);
+	g_value_init (value, G_TYPE_STRV);
+	g_value_take_boxed (value, wrong_checksums->data);
+	g_array_free (wrong_checksums, FALSE);
+
+	brasero_track_tag_add (track,
+			       BRASERO_TRACK_MEDIUM_WRONG_CHECKSUM_TAG,
+			       value);
+
+	g_set_error (error,
+		     BRASERO_BURN_ERROR,
+		     BRASERO_BURN_ERROR_BAD_CHECKSUM,
+		     _("some files may be corrupted on the disc"));
+
+	return BRASERO_BURN_ERR;
 }
 
 struct _BraseroChecksumFilesThreadCtx {



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