7
7
***************************************************************************/
10
* This program is free software; you can redistribute it and/or modify
10
* Brasero is free software; you can redistribute it and/or modify
11
11
* it under the terms of the GNU General Public License as published by
12
12
* the Free Software Foundation; either version 2 of the License, or
13
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
15
* Brasero is distributed in the hope that it will be useful,
16
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
18
* GNU Library General Public License for more details.
20
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* along with this program; if not, write to:
22
* The Free Software Foundation, Inc.,
23
* 51 Franklin Street, Fifth Floor
24
* Boston, MA 02110-1301, USA.
25
27
#ifdef HAVE_CONFIG_H
41
43
#include "burn-basics.h"
42
44
#include "burn-debug.h"
43
45
#include "burn-track.h"
44
#include "burn-medium.h"
45
#include "burn-drive.h"
46
#include "burn-medium-monitor.h"
46
#include "brasero-medium.h"
47
#include "brasero-drive.h"
48
#include "brasero-medium-monitor.h"
48
50
G_DEFINE_TYPE (BraseroBurnSession, brasero_burn_session, G_TYPE_OBJECT);
49
51
#define BRASERO_BURN_SESSION_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_BURN_SESSION, BraseroBurnSessionPrivate))
247
brasero_burn_session_clear_current_track (BraseroBurnSession *self)
249
BraseroBurnSessionPrivate *priv;
251
g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
253
priv = BRASERO_BURN_SESSION_PRIVATE (self);
255
brasero_burn_session_stop_src_drive_monitoring (self);
256
g_slist_foreach (priv->tracks, (GFunc) brasero_track_unref, NULL);
257
g_slist_free (priv->tracks);
248
261
BraseroBurnResult
249
262
brasero_burn_session_add_track (BraseroBurnSession *self,
250
263
BraseroTrack *new_track)
277
290
brasero_burn_session_stop_src_drive_monitoring (self);
279
292
/* if there is already a track, then we replace it on condition that it
280
* has the same type */
293
* has the same type and it's not AUDIO (only one allowed to have many)
281
295
if (brasero_track_get_type (new_track, NULL) != BRASERO_TRACK_TYPE_AUDIO
282
296
|| brasero_burn_session_get_input_type (self, NULL) != BRASERO_TRACK_TYPE_AUDIO) {
283
297
g_slist_foreach (priv->tracks, (GFunc) brasero_track_unref, NULL);
313
327
BraseroTrackType *type)
315
329
BraseroBurnSessionPrivate *priv;
330
BraseroTrackType input = { 0, };
317
332
g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
318
333
g_return_if_fail (type != NULL);
320
335
priv = BRASERO_BURN_SESSION_PRIVATE (self);
337
brasero_burn_session_get_input_type (self, &input);
322
338
memcpy (&priv->input, type, sizeof (BraseroTrackType));
340
if (brasero_track_type_equal (&input, type))
324
343
if (!priv->tracks)
325
344
g_signal_emit (self,
326
345
brasero_burn_session_signals [INPUT_CHANGED_SIGNAL],
473
491
return MIN (max_rate, priv->settings->rate);
477
brasero_burn_session_set_num_copies (BraseroBurnSession *self,
480
BraseroBurnSessionPrivate *priv;
482
g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
484
priv = BRASERO_BURN_SESSION_PRIVATE (self);
486
if (!BRASERO_BURN_SESSION_WRITE_TO_DISC (priv))
489
priv->settings->num_copies = copies;
493
brasero_burn_session_get_num_copies (BraseroBurnSession *self)
495
BraseroBurnSessionPrivate *priv;
497
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), 0);
499
priv = BRASERO_BURN_SESSION_PRIVATE (self);
501
if (!BRASERO_BURN_SESSION_WRITE_TO_DISC (priv))
504
return priv->settings->num_copies;
508
brasero_burn_session_get_file_complement (BraseroBurnSession *self,
509
BraseroImageFormat format,
512
gchar *retval = NULL;
513
BraseroBurnSessionPrivate *priv;
515
priv = BRASERO_BURN_SESSION_PRIVATE (self);
517
if (format == BRASERO_IMAGE_FORMAT_CLONE) {
518
if (g_str_has_suffix (path, ".toc"))
519
retval = g_strdup_printf ("%.*sraw",
523
retval = g_strdup_printf ("%s.raw", path);
525
else if (format == BRASERO_IMAGE_FORMAT_CUE) {
526
if (g_str_has_suffix (path, ".cue"))
527
retval = g_strdup_printf ("%.*sbin",
531
retval = g_strdup_printf ("%s.bin", path);
533
else if (format == BRASERO_IMAGE_FORMAT_CDRDAO) {
534
if (g_str_has_suffix (path, ".toc"))
535
retval = g_strdup_printf ("%.*sbin",
539
retval = g_strdup_printf ("%s.bin", path);
547
static BraseroBurnResult
548
brasero_burn_session_file_test (BraseroBurnSession *self,
552
BraseroBurnSessionPrivate *priv;
554
priv = BRASERO_BURN_SESSION_PRIVATE (self);
559
BRASERO_BURN_ERROR_GENERAL,
561
return BRASERO_BURN_ERR;
564
if (!g_file_test (path, G_FILE_TEST_EXISTS))
565
return BRASERO_BURN_OK;
567
if (priv->settings->flags & BRASERO_BURN_FLAG_DONT_OVERWRITE) {
570
BRASERO_BURN_ERROR_GENERAL,
571
_("%s already exists"),
573
return BRASERO_BURN_ERR;
576
return BRASERO_BURN_OK;
579
static BraseroBurnResult
580
brasero_burn_session_set_image_output_retval (BraseroBurnSession *self,
581
BraseroImageFormat format,
587
BraseroBurnSessionPrivate *priv;
589
priv = BRASERO_BURN_SESSION_PRIVATE (self);
592
case BRASERO_IMAGE_FORMAT_BIN:
593
case BRASERO_IMAGE_FORMAT_NONE:
605
case BRASERO_IMAGE_FORMAT_CLONE:
617
case BRASERO_IMAGE_FORMAT_CUE:
618
case BRASERO_IMAGE_FORMAT_CDRDAO:
631
return BRASERO_BURN_ERR;
634
return BRASERO_BURN_OK;
638
495
* This function returns a path only if we should output to a file image
657
515
return BRASERO_BURN_ERR;
660
/* output paths were set so test them and returns them if OK */
661
if (priv->settings->image) {
662
result = brasero_burn_session_file_test (self,
663
priv->settings->image,
665
if (result != BRASERO_BURN_OK) {
666
BRASERO_BURN_LOG ("Problem with image existence");
671
BRASERO_BURN_LOG ("no output specified");
518
image = g_strdup (priv->settings->image);
519
toc = g_strdup (priv->settings->toc);
675
BRASERO_BURN_ERROR_GENERAL,
676
_("no output specified"));
677
522
return BRASERO_BURN_ERR;
680
if (priv->settings->toc) {
681
result = brasero_burn_session_file_test (self,
684
if (result != BRASERO_BURN_OK) {
685
BRASERO_BURN_LOG ("Problem with toc existence");
691
*image = g_strdup (priv->settings->image);
693
*toc = g_strdup (priv->settings->toc);
525
/* output paths were set so test them and returns them if OK */
528
BraseroImageFormat format;
530
/* get the cuesheet complement */
531
format = brasero_burn_session_get_output_format (self);
532
complement = brasero_image_format_get_complement (format, toc);
534
BRASERO_BURN_LOG ("no output specified");
538
BRASERO_BURN_ERROR_OUTPUT_NONE,
539
_("No path was specified for the image output"));
542
return BRASERO_BURN_ERR;
545
*image_ret = complement;
550
BRASERO_BURN_LOG ("no output specified");
554
BRASERO_BURN_ERROR_OUTPUT_NONE,
555
_("No path was specified for the image output"));
556
return BRASERO_BURN_ERR;
695
567
return BRASERO_BURN_OK;
728
600
priv = BRASERO_BURN_SESSION_PRIVATE (self);
730
if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv)) {
731
BraseroMediumMonitor *monitor;
735
monitor = brasero_medium_monitor_get_default ();
736
list = brasero_medium_monitor_get_media (monitor, BRASERO_MEDIA_TYPE_FILE);
737
drive = brasero_medium_get_drive (list->data);
738
brasero_burn_session_set_burner (self, drive);
739
g_object_unref (monitor);
743
602
if (priv->settings->format == format
744
603
&& BRASERO_STR_EQUAL (image, priv->settings->image)
745
&& BRASERO_STR_EQUAL (toc, priv->settings->toc))
604
&& BRASERO_STR_EQUAL (toc, priv->settings->toc)) {
605
if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv)) {
606
BraseroMediumMonitor *monitor;
610
monitor = brasero_medium_monitor_get_default ();
611
list = brasero_medium_monitor_get_media (monitor, BRASERO_MEDIA_TYPE_FILE);
612
drive = brasero_medium_get_drive (list->data);
613
brasero_burn_session_set_burner (self, drive);
614
g_object_unref (monitor);
746
618
return BRASERO_BURN_OK;
748
621
if (priv->settings->image)
749
622
g_free (priv->settings->image);
764
637
priv->settings->format = format;
767
brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
639
if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv)) {
640
BraseroMediumMonitor *monitor;
644
monitor = brasero_medium_monitor_get_default ();
645
list = brasero_medium_monitor_get_media (monitor,BRASERO_MEDIA_TYPE_FILE);
646
drive = brasero_medium_get_drive (list->data);
647
brasero_burn_session_set_burner (self, drive);
648
g_object_unref (monitor);
653
brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
769
656
return BRASERO_BURN_OK;
773
brasero_burn_session_set_image_output (BraseroBurnSession *self,
774
BraseroImageFormat format,
777
BraseroBurnSessionPrivate *priv;
778
BraseroBurnResult result;
783
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
785
priv = BRASERO_BURN_SESSION_PRIVATE (self);
787
/* find the file complement */
788
complement = brasero_burn_session_get_file_complement (self,
792
brasero_burn_session_set_image_output_retval (self,
799
result = brasero_burn_session_set_image_output_full (self,
868
718
*path = mkdtemp (tmp);
869
719
if (*path == NULL) {
722
BRASERO_BURN_LOG ("Impossible to create tmp directory");
873
BRASERO_BURN_ERROR_GENERAL,
874
_("a temporary directory could not be created (%s)"),
727
BRASERO_BURN_ERROR_GENERAL,
733
BRASERO_BURN_ERROR_PERMISSION,
734
_("You do not have the required permission to write at this location"));
876
735
return BRASERO_BURN_ERR;
916
775
fd = g_mkstemp (tmp);
779
BRASERO_BURN_LOG ("Impossible to create tmp file %s", tmp);
921
BRASERO_BURN_ERROR_GENERAL,
922
_("a temporary file can't be created: %s"),
785
BRASERO_BURN_ERROR_GENERAL,
791
BRASERO_BURN_ERROR_PERMISSION,
792
_("You do not have the required permission to write at this location"));
924
794
return BRASERO_BURN_ERR;
933
803
return BRASERO_BURN_OK;
807
brasero_burn_session_get_image_complement (BraseroBurnSession *self,
808
BraseroImageFormat format,
811
gchar *retval = NULL;
812
BraseroBurnSessionPrivate *priv;
814
priv = BRASERO_BURN_SESSION_PRIVATE (self);
816
if (format == BRASERO_IMAGE_FORMAT_CLONE)
817
retval = g_strdup_printf ("%s.toc", path);
818
else if (format == BRASERO_IMAGE_FORMAT_CUE) {
819
if (g_str_has_suffix (path, ".bin"))
820
retval = g_strdup_printf ("%.*scue",
824
retval = g_strdup_printf ("%s.cue", path);
826
else if (format == BRASERO_IMAGE_FORMAT_CDRDAO) {
827
if (g_str_has_suffix (path, ".bin"))
828
retval = g_strdup_printf ("%.*stoc",
832
retval = g_strdup_printf ("%s.toc", path);
936
840
BraseroBurnResult
937
841
brasero_burn_session_get_tmp_image (BraseroBurnSession *self,
938
842
BraseroImageFormat format,
950
854
priv = BRASERO_BURN_SESSION_PRIVATE (self);
952
856
/* Image tmp file */
953
result = brasero_burn_session_get_tmp_file (self, NULL, &path, error);
857
result = brasero_burn_session_get_tmp_file (self,
858
(format == BRASERO_IMAGE_FORMAT_CLONE)? NULL:".bin",
954
861
if (result != BRASERO_BURN_OK)
957
864
if (format != BRASERO_IMAGE_FORMAT_BIN) {
958
865
/* toc tmp file */
959
complement = brasero_burn_session_get_file_complement (self, format, path);
866
complement = brasero_burn_session_get_image_complement (self, format, path);
960
867
if (complement) {
961
result = brasero_burn_session_file_test (self,
964
if (result != BRASERO_BURN_OK) {
868
/* That shouldn't happen ... */
869
if (g_file_test (complement, G_FILE_TEST_EXISTS)) {
965
870
g_free (complement);
871
return BRASERO_BURN_ERR;
1097
1005
BraseroBurnResult
1006
brasero_burn_session_tag_remove (BraseroBurnSession *self,
1009
BraseroBurnSessionPrivate *priv;
1011
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
1013
priv = BRASERO_BURN_SESSION_PRIVATE (self);
1015
return BRASERO_BURN_ERR;
1017
g_hash_table_remove (priv->tags, tag);
1018
return BRASERO_BURN_OK;
1098
1022
brasero_burn_session_tag_add (BraseroBurnSession *self,
1099
1023
const gchar *tag,
1395
brasero_burn_session_add_wrong_checksum (BraseroBurnSession *self,
1398
BraseroBurnSessionPrivate *priv;
1400
priv = BRASERO_BURN_SESSION_PRIVATE (self);
1401
priv->wrong_checksums = g_slist_prepend (priv->wrong_checksums, g_strdup (path));
1405
brasero_burn_session_get_wrong_checksums (BraseroBurnSession *self)
1407
BraseroBurnSessionPrivate *priv;
1410
g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), NULL);
1412
priv = BRASERO_BURN_SESSION_PRIVATE (self);
1414
/* reset our list so it will return only the new ones next time */
1415
retval = priv->wrong_checksums;
1416
priv->wrong_checksums = NULL;
1421
1314
/****************************** this part is for log ***************************/
1423
1316
brasero_burn_session_logv (BraseroBurnSession *self,
1577
brasero_burn_session_get_config_key (BraseroBurnSession *self,
1578
const gchar *property)
1580
BraseroMedium *medium;
1581
BraseroDrive *drive;
1582
gchar *display_name;
1586
drive = brasero_burn_session_get_burner (self);
1590
medium = brasero_drive_get_medium (drive);
1591
if (brasero_medium_get_status (medium) == BRASERO_MEDIUM_NONE)
1594
/* make sure display_name doesn't contain any forbidden characters */
1595
display_name = brasero_drive_get_display_name (drive);
1596
g_strdelimit (display_name, " +()", '_');
1598
disc_type = g_strdup (brasero_medium_get_type_string (medium));
1600
g_free (display_name);
1604
g_strdelimit (disc_type, " +()", '_');
1606
switch (brasero_burn_session_get_input_type (self, NULL)) {
1607
case BRASERO_TRACK_TYPE_NONE:
1608
key = g_strdup_printf ("%s/%s/none_%s/%s",
1609
BRASERO_DRIVE_PROPERTIES_KEY,
1614
case BRASERO_TRACK_TYPE_DISC:
1615
key = g_strdup_printf ("%s/%s/disc_%s/%s",
1616
BRASERO_DRIVE_PROPERTIES_KEY,
1622
case BRASERO_TRACK_TYPE_DATA:
1623
key = g_strdup_printf ("%s/%s/data_%s/%s",
1624
BRASERO_DRIVE_PROPERTIES_KEY,
1630
case BRASERO_TRACK_TYPE_IMAGE:
1631
key = g_strdup_printf ("%s/%s/image_%s/%s",
1632
BRASERO_DRIVE_PROPERTIES_KEY,
1638
case BRASERO_TRACK_TYPE_AUDIO:
1639
key = g_strdup_printf ("%s/%s/audio_%s/%s",
1640
BRASERO_DRIVE_PROPERTIES_KEY,
1649
g_free (display_name);
1711
if (g_file_test (path, G_FILE_TEST_IS_DIR))
1525
BRASERO_BURN_LOG ("Cleaning %s", path);
1527
/* NOTE: g_file_test follows symbolic links */
1528
if (g_file_test (path, G_FILE_TEST_IS_DIR)
1529
&& !g_file_test (path, G_FILE_TEST_IS_SYMLINK))
1712
1530
brasero_burn_session_clean_directory (path);
1714
/* NOTE : we don't follow uris as certain files are simply linked by content-data */
1532
/* NOTE : we don't follow paths as certain files are simply linked */
1715
1533
if (g_remove (path)) {
1716
BRASERO_BURN_LOG ("Cannot remove file %s", path);
1534
BRASERO_BURN_LOG ("Cannot remove file %s (%s)", path, g_strerror (errno));
1717
1535
result = FALSE;
1794
1614
priv->session_path = NULL;
1797
if (priv->wrong_checksums) {
1798
g_slist_foreach (priv->wrong_checksums, (GFunc) g_free, NULL);
1799
g_slist_free (priv->wrong_checksums);
1800
priv->wrong_checksums = NULL;
1803
1617
brasero_session_settings_clean (priv->settings);
1805
1619
G_OBJECT_CLASS (parent_class)->finalize (object);