~ubuntu-branches/debian/wheezy/brasero/wheezy

« back to all changes in this revision

Viewing changes to src/burn-session.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette, Pedro Fragoso, Luca Bruno, Josselin Mouette, Emilio Pozuelo Monfort
  • Date: 2009-06-24 18:59:46 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624185946-iyxkgf3gjptir5y3
Tags: 2.26.2-1
[ Pedro Fragoso ]
* Add myself to Maintainer field
  - Thanks Ondřej Surý
* New upstream version (Closes: #528945)
  - Split package into brasero, libbrasero-media0 and libbrasero-dev
  - Add Replaces to libbrasero-media0
  - Bump libgtk to 2.14.0
  - Remove libnotify Build-dep
  - Add Build-dep libnautilus-extension-dev (>= 2.22.2)
    and install it.
  - Add Build-dep to libsm-dev
  - Add Build-dep on intltool
* Install omf files to prevent crash on Help
* Move gstreamer0.10-plugins-bad to Suggests, and add
  dvdauthor and vcdimager
* Recommends gvfs (Closes: #491827)
* Pass --disable-scrollkeeper in DEB_CONFIGURE_EXTRA_FLAGS
* debian/patches/007-fix-gnome-doc-utils-path.patch:
  - Removed, not needed anymore
* debian/patches/008-fix-volume-identifier-crash.patch:
  - Removed, merged upstream
* debian/patches/011_nautilus_menu_move.patch:
 - Move CD/DVD Creator Menu to Acessories, taken from Ubuntu

[ Luca Bruno ]
* debian/control.in:
  - Add Build-Depend gtk-doc-tools 1.9.
* debian/patches/006-fix-libdvdcss.patch:
  - Removed as applied upstream.

[ Josselin Mouette ]
* New upstream release.
* Update build-dependencies.
* Move the translations and data to a new brasero-common package.
* Rewrite the descriptions.
* Add -dev depends to the development package.
* Remove inappropriate recommends in the library package.
* Let’s not forget dvd+rw-tools so that we can write DVDs too.
* Rework dependencies accordingly.
* Put the nautilus extension in brasero.
* Conflict against nautilus-cd-burner to avoid having two burning 
  extensions.
* Include clean-la.mk and gnome-version.mk; build-depend on 
  gnome-pkg-tools 0.7.
* Don’t run dh_makeshlibs on brasero and libbrasero-plugins.
* 011_nautilus_menu_move.patch: add NoDisplay=true, this icon is 
  duplicating existing functionality (brasero icon in sound&video 
  menu, and nautilus autorun).
* Update list of copyright holders.

[ Emilio Pozuelo Monfort ]
* debian/copyright: updated.

[ Josselin Mouette ]
* copyright: improve indentation, and point to versioned LGPL.
* 090_relibtoolize.patch: add a relibtoolization patch to avoid the 
  rpath crap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 ***************************************************************************/
8
8
 
9
9
/*
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.
14
14
 *
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.
19
19
 *
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.
23
25
 */
24
26
 
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"
47
49
 
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))
51
53
struct _BraseroSessionSetting {
52
54
        BraseroDrive *burner;
53
55
 
54
 
        guint num_copies;
55
 
 
56
56
        /**
57
57
         * Used when outputting an image instead of burning
58
58
         */
76
76
        FILE *session;
77
77
        gchar *session_path;
78
78
 
79
 
        GSList *wrong_checksums;
80
 
 
81
79
        GSList *tmpfiles;
82
80
 
83
81
        BraseroSessionSetting settings [1];
245
243
                       0);
246
244
}
247
245
 
 
246
void
 
247
brasero_burn_session_clear_current_track (BraseroBurnSession *self)
 
248
{
 
249
        BraseroBurnSessionPrivate *priv;
 
250
 
 
251
        g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
 
252
 
 
253
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
 
254
 
 
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);
 
258
        priv->tracks = NULL;
 
259
}
 
260
 
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);
278
291
 
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)
 
294
         */
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)
314
328
{
315
329
        BraseroBurnSessionPrivate *priv;
 
330
        BraseroTrackType input = { 0, };
316
331
 
317
332
        g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
318
333
        g_return_if_fail (type != NULL);
319
334
 
320
335
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
321
336
 
 
337
        brasero_burn_session_get_input_type (self, &input);
322
338
        memcpy (&priv->input, type, sizeof (BraseroTrackType));
323
339
 
 
340
        if (brasero_track_type_equal (&input, type))
 
341
                return;
 
342
 
324
343
        if (!priv->tracks)
325
344
                g_signal_emit (self,
326
345
                               brasero_burn_session_signals [INPUT_CHANGED_SIGNAL],
370
389
                                         BraseroMedium *medium,
371
390
                                         BraseroBurnSession *self)
372
391
{
373
 
        
374
392
        g_signal_emit (self,
375
393
                       brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
376
394
                       0);
473
491
                return MIN (max_rate, priv->settings->rate);
474
492
}
475
493
 
476
 
void
477
 
brasero_burn_session_set_num_copies (BraseroBurnSession *self,
478
 
                                     guint copies)
479
 
{
480
 
        BraseroBurnSessionPrivate *priv;
481
 
 
482
 
        g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
483
 
 
484
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
485
 
 
486
 
        if (!BRASERO_BURN_SESSION_WRITE_TO_DISC (priv))
487
 
                return;
488
 
 
489
 
        priv->settings->num_copies = copies;
490
 
}
491
 
 
492
 
guint
493
 
brasero_burn_session_get_num_copies (BraseroBurnSession *self)
494
 
{
495
 
        BraseroBurnSessionPrivate *priv;
496
 
 
497
 
        g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), 0);
498
 
 
499
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
500
 
 
501
 
        if (!BRASERO_BURN_SESSION_WRITE_TO_DISC (priv))
502
 
                return 1;
503
 
 
504
 
        return priv->settings->num_copies;
505
 
}
506
 
 
507
 
static gchar *
508
 
brasero_burn_session_get_file_complement (BraseroBurnSession *self,
509
 
                                          BraseroImageFormat format,
510
 
                                          const gchar *path)
511
 
{
512
 
        gchar *retval = NULL;
513
 
        BraseroBurnSessionPrivate *priv;
514
 
 
515
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
516
 
 
517
 
        if (format == BRASERO_IMAGE_FORMAT_CLONE) {
518
 
                if (g_str_has_suffix (path, ".toc"))
519
 
                        retval = g_strdup_printf ("%.*sraw",
520
 
                                                  strlen (path) - 3,
521
 
                                                  path);
522
 
                else
523
 
                        retval = g_strdup_printf ("%s.raw", path);
524
 
        }
525
 
        else if (format == BRASERO_IMAGE_FORMAT_CUE) {
526
 
                if (g_str_has_suffix (path, ".cue"))
527
 
                        retval = g_strdup_printf ("%.*sbin",
528
 
                                                  strlen (path) - 3,
529
 
                                                  path);
530
 
                else
531
 
                        retval = g_strdup_printf ("%s.bin", path);
532
 
        }
533
 
        else if (format == BRASERO_IMAGE_FORMAT_CDRDAO) {
534
 
                if (g_str_has_suffix (path, ".toc"))
535
 
                        retval = g_strdup_printf ("%.*sbin",
536
 
                                                  strlen (path) - 3,
537
 
                                                  path);
538
 
                else
539
 
                        retval = g_strdup_printf ("%s.bin", path);
540
 
        }
541
 
        else
542
 
                retval = NULL;
543
 
 
544
 
        return retval;
545
 
}
546
 
 
547
 
static BraseroBurnResult
548
 
brasero_burn_session_file_test (BraseroBurnSession *self,
549
 
                                const gchar *path,
550
 
                                GError **error)
551
 
{
552
 
        BraseroBurnSessionPrivate *priv;
553
 
 
554
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
555
 
 
556
 
        if (!path) {
557
 
                g_set_error (error,
558
 
                             BRASERO_BURN_ERROR,
559
 
                             BRASERO_BURN_ERROR_GENERAL,
560
 
                             _("no path"));
561
 
                return BRASERO_BURN_ERR;
562
 
        }
563
 
 
564
 
        if (!g_file_test (path, G_FILE_TEST_EXISTS))
565
 
                return BRASERO_BURN_OK;
566
 
        
567
 
        if (priv->settings->flags & BRASERO_BURN_FLAG_DONT_OVERWRITE) {
568
 
                g_set_error (error,
569
 
                             BRASERO_BURN_ERROR,
570
 
                             BRASERO_BURN_ERROR_GENERAL,
571
 
                             _("%s already exists"),
572
 
                             path);
573
 
                return BRASERO_BURN_ERR;
574
 
        }
575
 
 
576
 
        return BRASERO_BURN_OK;
577
 
}
578
 
 
579
 
static BraseroBurnResult
580
 
brasero_burn_session_set_image_output_retval (BraseroBurnSession *self,
581
 
                                              BraseroImageFormat format,
582
 
                                              gchar **image,
583
 
                                              gchar **toc,
584
 
                                              gchar *output,
585
 
                                              gchar *complement)
586
 
{
587
 
        BraseroBurnSessionPrivate *priv;
588
 
 
589
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
590
 
 
591
 
        switch (format) {
592
 
        case BRASERO_IMAGE_FORMAT_BIN:
593
 
        case BRASERO_IMAGE_FORMAT_NONE:
594
 
                if (image)
595
 
                        *image = output;
596
 
                else
597
 
                        g_free (output);
598
 
 
599
 
                if (toc)
600
 
                        *toc = NULL;
601
 
 
602
 
                g_free (complement);
603
 
                break;
604
 
 
605
 
        case BRASERO_IMAGE_FORMAT_CLONE:
606
 
                if (image)
607
 
                        *image = output;
608
 
                else
609
 
                        g_free (output);
610
 
 
611
 
                if (toc)
612
 
                        *toc = complement;
613
 
                else
614
 
                        g_free (complement);
615
 
                break;
616
 
 
617
 
        case BRASERO_IMAGE_FORMAT_CUE:
618
 
        case BRASERO_IMAGE_FORMAT_CDRDAO:
619
 
                if (image)
620
 
                        *image = complement;
621
 
                else
622
 
                        g_free (complement);
623
 
 
624
 
                if (toc)
625
 
                        *toc = output;
626
 
                else
627
 
                        g_free (output);
628
 
                break;
629
 
 
630
 
        default:
631
 
                return BRASERO_BURN_ERR;
632
 
        }
633
 
 
634
 
        return BRASERO_BURN_OK;
635
 
}
636
 
 
637
494
/**
638
495
 * This function returns a path only if we should output to a file image
639
496
 * and not burn.
641
498
 
642
499
BraseroBurnResult
643
500
brasero_burn_session_get_output (BraseroBurnSession *self,
644
 
                                 gchar **image,
645
 
                                 gchar **toc,
 
501
                                 gchar **image_ret,
 
502
                                 gchar **toc_ret,
646
503
                                 GError **error)
647
504
{
648
 
        BraseroBurnResult result;
 
505
        gchar *toc = NULL;
 
506
        gchar *image = NULL;
649
507
        BraseroBurnSessionPrivate *priv;
650
508
 
651
509
        g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
657
515
                return BRASERO_BURN_ERR;
658
516
        }
659
517
 
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,
664
 
                                                         error);
665
 
                if (result != BRASERO_BURN_OK) {
666
 
                        BRASERO_BURN_LOG ("Problem with image existence");
667
 
                        return result;
668
 
                }
669
 
        }
670
 
        else {
671
 
                BRASERO_BURN_LOG ("no output specified");
 
518
        image = g_strdup (priv->settings->image);
 
519
        toc = g_strdup (priv->settings->toc);
672
520
 
673
 
                g_set_error (error,
674
 
                             BRASERO_BURN_ERROR,
675
 
                             BRASERO_BURN_ERROR_GENERAL,
676
 
                             _("no output specified"));
 
521
        if (!image && !toc)
677
522
                return BRASERO_BURN_ERR;
678
 
        }
679
 
 
680
 
        if (priv->settings->toc) {
681
 
                result = brasero_burn_session_file_test (self,
682
 
                                                         priv->settings->toc,
683
 
                                                         error);
684
 
                if (result != BRASERO_BURN_OK) {
685
 
                        BRASERO_BURN_LOG ("Problem with toc existence");
686
 
                        return result;
687
 
                }
688
 
        }
689
 
 
690
 
        if (image)
691
 
                *image = g_strdup (priv->settings->image);
692
 
        if (toc)
693
 
                *toc = g_strdup (priv->settings->toc);
 
523
 
 
524
        if (image_ret) {
 
525
                /* output paths were set so test them and returns them if OK */
 
526
                if (!image && toc) {
 
527
                        gchar *complement;
 
528
                        BraseroImageFormat format;
 
529
 
 
530
                        /* get the cuesheet complement */
 
531
                        format = brasero_burn_session_get_output_format (self);
 
532
                        complement = brasero_image_format_get_complement (format, toc);
 
533
                        if (!complement) {
 
534
                                BRASERO_BURN_LOG ("no output specified");
 
535
 
 
536
                                g_set_error (error,
 
537
                                             BRASERO_BURN_ERROR,
 
538
                                             BRASERO_BURN_ERROR_OUTPUT_NONE,
 
539
                                             _("No path was specified for the image output"));
 
540
 
 
541
                                g_free (toc);
 
542
                                return BRASERO_BURN_ERR;
 
543
                        }
 
544
 
 
545
                        *image_ret = complement;
 
546
                }
 
547
                else if (image)
 
548
                        *image_ret = image;
 
549
                else {
 
550
                        BRASERO_BURN_LOG ("no output specified");
 
551
 
 
552
                        g_set_error (error,
 
553
                                     BRASERO_BURN_ERROR,
 
554
                                     BRASERO_BURN_ERROR_OUTPUT_NONE,
 
555
                                     _("No path was specified for the image output"));
 
556
                        return BRASERO_BURN_ERR;
 
557
                }
 
558
        }
 
559
        else
 
560
                g_free (image);
 
561
 
 
562
        if (toc_ret)
 
563
                *toc_ret = toc;
 
564
        else
 
565
                g_free (toc);
694
566
 
695
567
        return BRASERO_BURN_OK;
696
568
}
727
599
 
728
600
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
729
601
 
730
 
        if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv)) {
731
 
                BraseroMediumMonitor *monitor;
732
 
                BraseroDrive *drive;
733
 
                GSList *list;
734
 
 
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);
740
 
                g_slist_free (list);
741
 
        }
742
 
 
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;
 
607
                        BraseroDrive *drive;
 
608
                        GSList *list;
 
609
 
 
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);
 
615
                        g_slist_free (list);
 
616
                }
 
617
 
746
618
                return BRASERO_BURN_OK;
 
619
        }
747
620
 
748
621
        if (priv->settings->image)
749
622
                g_free (priv->settings->image);
763
636
 
764
637
        priv->settings->format = format;
765
638
 
766
 
        g_signal_emit (self,
767
 
                       brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
768
 
                       0);
 
639
        if (!BRASERO_BURN_SESSION_WRITE_TO_FILE (priv)) {
 
640
                BraseroMediumMonitor *monitor;
 
641
                BraseroDrive *drive;
 
642
                GSList *list;
 
643
 
 
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);
 
649
                g_slist_free (list);
 
650
        }
 
651
        else
 
652
                g_signal_emit (self,
 
653
                               brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
 
654
                               0);
 
655
 
769
656
        return BRASERO_BURN_OK;
770
657
}
771
658
 
772
 
BraseroBurnResult
773
 
brasero_burn_session_set_image_output (BraseroBurnSession *self,
774
 
                                       BraseroImageFormat format,
775
 
                                       const gchar *path)
776
 
{
777
 
        BraseroBurnSessionPrivate *priv;
778
 
        BraseroBurnResult result;
779
 
        gchar *complement;
780
 
        gchar *image = NULL;
781
 
        gchar *toc = NULL;
782
 
 
783
 
        g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
784
 
 
785
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
786
 
 
787
 
        /* find the file complement */
788
 
        complement = brasero_burn_session_get_file_complement (self,
789
 
                                                               format,
790
 
                                                               path);
791
 
 
792
 
        brasero_burn_session_set_image_output_retval (self,
793
 
                                                      format,
794
 
                                                      &image,
795
 
                                                      &toc,
796
 
                                                      g_strdup (path),
797
 
                                                      complement);
798
 
 
799
 
        result = brasero_burn_session_set_image_output_full (self,
800
 
                                                             format,
801
 
                                                             image,
802
 
                                                             toc);
803
 
        g_free (image);
804
 
        g_free (toc);
805
 
 
806
 
        return result;
807
 
}
808
 
 
809
659
/**
810
660
 *
811
661
 */
867
717
 
868
718
        *path = mkdtemp (tmp);
869
719
        if (*path == NULL) {
 
720
                int errsv = errno;
 
721
 
 
722
                BRASERO_BURN_LOG ("Impossible to create tmp directory");
870
723
                g_free (tmp);
871
 
                g_set_error (error,
872
 
                             BRASERO_BURN_ERROR,
873
 
                             BRASERO_BURN_ERROR_GENERAL,
874
 
                             _("a temporary directory could not be created (%s)"),
875
 
                             strerror (errno));
 
724
                if (errsv != EACCES)
 
725
                        g_set_error (error, 
 
726
                                     BRASERO_BURN_ERROR,
 
727
                                     BRASERO_BURN_ERROR_GENERAL,
 
728
                                     "%s",
 
729
                                     g_strerror (errsv));
 
730
                else
 
731
                        g_set_error (error,
 
732
                                     BRASERO_BURN_ERROR,
 
733
                                     BRASERO_BURN_ERROR_PERMISSION,
 
734
                                     _("You do not have the required permission to write at this location"));
876
735
                return BRASERO_BURN_ERR;
877
736
        }
878
737
 
915
774
 
916
775
        fd = g_mkstemp (tmp);
917
776
        if (fd == -1) {
 
777
                int errsv = errno;
 
778
 
 
779
                BRASERO_BURN_LOG ("Impossible to create tmp file %s", tmp);
 
780
 
918
781
                g_free (tmp);
919
 
                g_set_error (error, 
920
 
                             BRASERO_BURN_ERROR,
921
 
                             BRASERO_BURN_ERROR_GENERAL,
922
 
                             _("a temporary file can't be created: %s"),
923
 
                             strerror (errno));
 
782
                if (errsv != EACCES)
 
783
                        g_set_error (error, 
 
784
                                     BRASERO_BURN_ERROR,
 
785
                                     BRASERO_BURN_ERROR_GENERAL,
 
786
                                     "%s",
 
787
                                     g_strerror (errsv));
 
788
                else
 
789
                        g_set_error (error, 
 
790
                                     BRASERO_BURN_ERROR,
 
791
                                     BRASERO_BURN_ERROR_PERMISSION,
 
792
                                     _("You do not have the required permission to write at this location"));
 
793
 
924
794
                return BRASERO_BURN_ERR;
925
795
        }
926
796
 
933
803
        return BRASERO_BURN_OK;
934
804
}
935
805
 
 
806
static gchar *
 
807
brasero_burn_session_get_image_complement (BraseroBurnSession *self,
 
808
                                           BraseroImageFormat format,
 
809
                                           const gchar *path)
 
810
{
 
811
        gchar *retval = NULL;
 
812
        BraseroBurnSessionPrivate *priv;
 
813
 
 
814
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
 
815
 
 
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",
 
821
                                                  strlen (path) - 3,
 
822
                                                  path);
 
823
                else
 
824
                        retval = g_strdup_printf ("%s.cue", path);
 
825
        }
 
826
        else if (format == BRASERO_IMAGE_FORMAT_CDRDAO) {
 
827
                if (g_str_has_suffix (path, ".bin"))
 
828
                        retval = g_strdup_printf ("%.*stoc",
 
829
                                                  strlen (path) - 3,
 
830
                                                  path);
 
831
                else
 
832
                        retval = g_strdup_printf ("%s.toc", path);
 
833
        }
 
834
        else
 
835
                retval = NULL;
 
836
 
 
837
        return retval;
 
838
}
 
839
 
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);
951
855
 
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",
 
859
                                                    &path,
 
860
                                                    error);
954
861
        if (result != BRASERO_BURN_OK)
955
862
                return result;
956
863
 
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,
962
 
                                                                 complement,
963
 
                                                                 error);
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);
966
 
                                return result;
 
871
                                return BRASERO_BURN_ERR;
967
872
                        }
968
873
                }
969
874
        }
972
877
                priv->tmpfiles = g_slist_prepend (priv->tmpfiles,
973
878
                                                  g_strdup (complement));
974
879
 
975
 
        brasero_burn_session_set_image_output_retval (self,
976
 
                                                      format,
977
 
                                                      image,
978
 
                                                      toc,
979
 
                                                      path,
980
 
                                                      complement);
 
880
        if (image)
 
881
                *image = path;
 
882
        else
 
883
                g_free (path);
 
884
 
 
885
        if (toc)
 
886
                *toc = complement;
 
887
        else
 
888
                g_free (complement);
981
889
 
982
890
        return BRASERO_BURN_OK;
983
891
}
1095
1003
}
1096
1004
 
1097
1005
BraseroBurnResult
 
1006
brasero_burn_session_tag_remove (BraseroBurnSession *self,
 
1007
                                 const gchar *tag)
 
1008
{
 
1009
        BraseroBurnSessionPrivate *priv;
 
1010
 
 
1011
        g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
 
1012
 
 
1013
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
 
1014
        if (!priv->tags)
 
1015
                return BRASERO_BURN_ERR;
 
1016
 
 
1017
        g_hash_table_remove (priv->tags, tag);
 
1018
        return BRASERO_BURN_OK;
 
1019
}
 
1020
 
 
1021
BraseroBurnResult
1098
1022
brasero_burn_session_tag_add (BraseroBurnSession *self,
1099
1023
                              const gchar *tag,
1100
1024
                              GValue *value)
1387
1311
}
1388
1312
 
1389
1313
 
1390
 
/**
1391
 
 *
1392
 
 */
1393
 
 
1394
 
void
1395
 
brasero_burn_session_add_wrong_checksum (BraseroBurnSession *self,
1396
 
                                         const gchar *path)
1397
 
{
1398
 
        BraseroBurnSessionPrivate *priv;
1399
 
 
1400
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
1401
 
        priv->wrong_checksums = g_slist_prepend (priv->wrong_checksums, g_strdup (path));
1402
 
}
1403
 
 
1404
 
GSList *
1405
 
brasero_burn_session_get_wrong_checksums (BraseroBurnSession *self)
1406
 
{
1407
 
        BraseroBurnSessionPrivate *priv;
1408
 
        GSList *retval;
1409
 
 
1410
 
        g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), NULL);
1411
 
 
1412
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
1413
 
 
1414
 
        /* reset our list so it will return only the new ones next time */
1415
 
        retval = priv->wrong_checksums;
1416
 
        priv->wrong_checksums = NULL;
1417
 
 
1418
 
        return retval;
1419
 
}
1420
 
 
1421
1314
/****************************** this part is for log ***************************/
1422
1315
void
1423
1316
brasero_burn_session_logv (BraseroBurnSession *self,
1438
1331
        if (!priv->session)
1439
1332
                return;
1440
1333
 
1441
 
        if (arg_list)
1442
 
                message = g_strdup_vprintf (format, arg_list);
1443
 
        else
1444
 
                message = g_strdup (format);
 
1334
        message = g_strdup_vprintf (format, arg_list);
1445
1335
 
1446
1336
        /* we also need to validate the messages to be in UTF-8 */
1447
1337
        if (!g_utf8_validate (message, -1, (const gchar**) &offending))
1513
1403
 
1514
1404
        if (!priv->session_path) {
1515
1405
                int fd;
1516
 
 
 
1406
                const gchar *tmpdir;
 
1407
 
 
1408
                /* takes care of the output file */
 
1409
                tmpdir = priv->settings->tmpdir ?
 
1410
                         priv->settings->tmpdir :
 
1411
                         g_get_tmp_dir ();
 
1412
 
 
1413
                /* This must obey the path of the temporary directory */
1517
1414
                priv->session_path = g_build_path (G_DIR_SEPARATOR_S,
1518
 
                                                   g_get_tmp_dir (),
 
1415
                                                   tmpdir,
1519
1416
                                                   BRASERO_BURN_TMP_FILE_NAME,
1520
1417
                                                   NULL);
1521
1418
 
1544
1441
                medium = brasero_drive_get_medium (priv->settings->burner);
1545
1442
                BRASERO_BURN_LOG_DISC_TYPE (brasero_medium_get_status (medium), "media type\t=");
1546
1443
                BRASERO_BURN_LOG ("speed\t= %i", priv->settings->rate);
1547
 
                BRASERO_BURN_LOG ("number of copies\t= %i", priv->settings->num_copies);
1548
1444
        }
1549
1445
        else {
1550
1446
                type.type = BRASERO_TRACK_TYPE_IMAGE;
1570
1466
}
1571
1467
 
1572
1468
/**
1573
 
 * Misc
1574
 
 */
1575
 
 
1576
 
gchar *
1577
 
brasero_burn_session_get_config_key (BraseroBurnSession *self,
1578
 
                                     const gchar *property)
1579
 
{
1580
 
        BraseroMedium *medium;
1581
 
        BraseroDrive *drive;
1582
 
        gchar *display_name;
1583
 
        gchar *key = NULL;
1584
 
        gchar *disc_type;
1585
 
 
1586
 
        drive = brasero_burn_session_get_burner (self);
1587
 
        if (!drive)
1588
 
                return NULL;
1589
 
 
1590
 
        medium = brasero_drive_get_medium (drive);
1591
 
        if (brasero_medium_get_status (medium) == BRASERO_MEDIUM_NONE)
1592
 
                return NULL;
1593
 
        
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, " +()", '_');
1597
 
 
1598
 
        disc_type = g_strdup (brasero_medium_get_type_string (medium));
1599
 
        if (!disc_type) {
1600
 
                g_free (display_name);
1601
 
                return NULL;
1602
 
        }
1603
 
 
1604
 
        g_strdelimit (disc_type, " +()", '_');
1605
 
 
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,
1610
 
                                       display_name,
1611
 
                                       disc_type,
1612
 
                                       property);
1613
 
                break;
1614
 
        case BRASERO_TRACK_TYPE_DISC:
1615
 
                key = g_strdup_printf ("%s/%s/disc_%s/%s",
1616
 
                                       BRASERO_DRIVE_PROPERTIES_KEY,
1617
 
                                       display_name,
1618
 
                                       disc_type,
1619
 
                                       property);
1620
 
                break;
1621
 
 
1622
 
        case BRASERO_TRACK_TYPE_DATA:
1623
 
                key = g_strdup_printf ("%s/%s/data_%s/%s",
1624
 
                                       BRASERO_DRIVE_PROPERTIES_KEY,
1625
 
                                       display_name,
1626
 
                                       disc_type,
1627
 
                                       property);
1628
 
                break;
1629
 
 
1630
 
        case BRASERO_TRACK_TYPE_IMAGE:
1631
 
                key = g_strdup_printf ("%s/%s/image_%s/%s",
1632
 
                                       BRASERO_DRIVE_PROPERTIES_KEY,
1633
 
                                       display_name,
1634
 
                                       disc_type,
1635
 
                                       property);
1636
 
                break;
1637
 
 
1638
 
        case BRASERO_TRACK_TYPE_AUDIO:
1639
 
                key = g_strdup_printf ("%s/%s/audio_%s/%s",
1640
 
                                       BRASERO_DRIVE_PROPERTIES_KEY,
1641
 
                                       display_name,
1642
 
                                       disc_type,
1643
 
                                       property);
1644
 
                break;
1645
 
        default:
1646
 
                break;
1647
 
        }
1648
 
 
1649
 
        g_free (display_name);
1650
 
        g_free (disc_type);
1651
 
        return key;
1652
 
}
1653
 
 
1654
 
/**
1655
1469
 *
1656
1470
 */
1657
1471
 
1708
1522
        if (!path)
1709
1523
                return TRUE;
1710
1524
 
1711
 
        if (g_file_test (path, G_FILE_TEST_IS_DIR))
 
1525
        BRASERO_BURN_LOG ("Cleaning %s", path);
 
1526
 
 
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);
1713
1531
 
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;
1718
1536
        }
1719
1537
 
1726
1544
        BraseroBurnSessionPrivate *priv;
1727
1545
        GSList *iter;
1728
1546
 
 
1547
        BRASERO_BURN_LOG ("Cleaning session");
 
1548
 
1729
1549
        priv = BRASERO_BURN_SESSION_PRIVATE (object);
1730
1550
 
1731
1551
        if (priv->tags) {
1794
1614
                priv->session_path = NULL;
1795
1615
        }
1796
1616
 
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;
1801
 
        }
1802
 
 
1803
1617
        brasero_session_settings_clean (priv->settings);
1804
1618
 
1805
1619
        G_OBJECT_CLASS (parent_class)->finalize (object);
1823
1637
        brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL] =
1824
1638
            g_signal_new ("output_changed",
1825
1639
                          BRASERO_TYPE_BURN_SESSION,
1826
 
                          G_SIGNAL_RUN_LAST|G_SIGNAL_ACTION|G_SIGNAL_NO_RECURSE,
 
1640
                          G_SIGNAL_RUN_FIRST,
1827
1641
                          G_STRUCT_OFFSET (BraseroBurnSessionClass, output_changed),
1828
1642
                          NULL,
1829
1643
                          NULL,
1834
1648
        brasero_burn_session_signals [INPUT_CHANGED_SIGNAL] =
1835
1649
            g_signal_new ("input_changed",
1836
1650
                          BRASERO_TYPE_BURN_SESSION,
1837
 
                          G_SIGNAL_RUN_LAST|G_SIGNAL_ACTION|G_SIGNAL_NO_RECURSE,
 
1651
                          G_SIGNAL_RUN_FIRST,
1838
1652
                          G_STRUCT_OFFSET (BraseroBurnSessionClass, input_changed),
1839
1653
                          NULL,
1840
1654
                          NULL,