~mfisch/brasero/update-to-3.8.0

« back to all changes in this revision

Viewing changes to src/burn-session.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2008-08-10 01:16:00 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20080810011600-bfb87m1rs6n0qx16
Tags: upstream-0.8.1
ImportĀ upstreamĀ versionĀ 0.8.1

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
370
372
                                         BraseroMedium *medium,
371
373
                                         BraseroBurnSession *self)
372
374
{
373
 
        
374
375
        g_signal_emit (self,
375
376
                       brasero_burn_session_signals [OUTPUT_CHANGED_SIGNAL],
376
377
                       0);
505
506
}
506
507
 
507
508
static gchar *
508
 
brasero_burn_session_get_file_complement (BraseroBurnSession *self,
509
 
                                          BraseroImageFormat format,
510
 
                                          const gchar *path)
 
509
brasero_burn_session_get_image_complement (BraseroBurnSession *self,
 
510
                                           BraseroImageFormat format,
 
511
                                           const gchar *path)
511
512
{
512
513
        gchar *retval = NULL;
513
514
        BraseroBurnSessionPrivate *priv;
515
516
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
516
517
 
517
518
        if (format == BRASERO_IMAGE_FORMAT_CLONE) {
518
 
                if (g_str_has_suffix (path, ".toc"))
519
 
                        retval = g_strdup_printf ("%.*sraw",
 
519
                if (g_str_has_suffix (path, ".raw"))
 
520
                        retval = g_strdup_printf ("%.*stoc",
520
521
                                                  strlen (path) - 3,
521
522
                                                  path);
522
523
                else
523
 
                        retval = g_strdup_printf ("%s.raw", path);
 
524
                        retval = g_strdup_printf ("%s.toc", path);
524
525
        }
525
526
        else if (format == BRASERO_IMAGE_FORMAT_CUE) {
526
 
                if (g_str_has_suffix (path, ".cue"))
527
 
                        retval = g_strdup_printf ("%.*sbin",
 
527
                if (g_str_has_suffix (path, ".bin"))
 
528
                        retval = g_strdup_printf ("%.*scue",
528
529
                                                  strlen (path) - 3,
529
530
                                                  path);
530
531
                else
531
532
                        retval = g_strdup_printf ("%s.bin", path);
532
533
        }
533
534
        else if (format == BRASERO_IMAGE_FORMAT_CDRDAO) {
534
 
                if (g_str_has_suffix (path, ".toc"))
535
 
                        retval = g_strdup_printf ("%.*sbin",
 
535
                if (g_str_has_suffix (path, ".bin"))
 
536
                        retval = g_strdup_printf ("%.*stoc",
536
537
                                                  strlen (path) - 3,
537
538
                                                  path);
538
539
                else
539
 
                        retval = g_strdup_printf ("%s.bin", path);
 
540
                        retval = g_strdup_printf ("%s.toc", path);
540
541
        }
541
542
        else
542
543
                retval = NULL;
657
658
                return BRASERO_BURN_ERR;
658
659
        }
659
660
 
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");
672
 
 
673
 
                g_set_error (error,
674
 
                             BRASERO_BURN_ERROR,
675
 
                             BRASERO_BURN_ERROR_GENERAL,
676
 
                             _("no output specified"));
677
 
                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)
 
661
        if (image) {
 
662
                /* output paths were set so test them and returns them if OK */
 
663
                if (priv->settings->image) {
 
664
                        result = brasero_burn_session_file_test (self,
 
665
                                                                 priv->settings->image,
 
666
                                                                 error);
 
667
                        if (result != BRASERO_BURN_OK) {
 
668
                                BRASERO_BURN_LOG ("Problem with image existence");
 
669
                                return result;
 
670
                        }
 
671
 
 
672
                        *image = g_strdup (priv->settings->image);
 
673
                }
 
674
                else if (priv->settings->toc) {
 
675
                        gchar *complement;
 
676
 
 
677
                        /* get the cuesheet complement */
 
678
                        complement = brasero_image_format_get_complement (priv->settings->format,
 
679
                                                                          priv->settings->toc);
 
680
                        if (!complement) {
 
681
                                BRASERO_BURN_LOG ("no output specified");
 
682
 
 
683
                                g_set_error (error,
 
684
                                             BRASERO_BURN_ERROR,
 
685
                                             BRASERO_BURN_ERROR_GENERAL,
 
686
                                             _("no output specified"));
 
687
                                return BRASERO_BURN_ERR;
 
688
                        }
 
689
 
 
690
                        result = brasero_burn_session_file_test (self,
 
691
                                                                 complement,
 
692
                                                                 error);
 
693
                        if (result != BRASERO_BURN_OK) {
 
694
                                BRASERO_BURN_LOG ("Problem with image existence");
 
695
                                return result;
 
696
                        }
 
697
 
 
698
                        *image = complement;
 
699
                }
 
700
                else {
 
701
                        BRASERO_BURN_LOG ("no output specified");
 
702
 
 
703
                        g_set_error (error,
 
704
                                     BRASERO_BURN_ERROR,
 
705
                                     BRASERO_BURN_ERROR_GENERAL,
 
706
                                     _("no output specified"));
 
707
                        return BRASERO_BURN_ERR;
 
708
                }
 
709
        }
 
710
 
 
711
        if (toc) {
 
712
                if (priv->settings->toc) {
 
713
                        result = brasero_burn_session_file_test (self,
 
714
                                                                 priv->settings->toc,
 
715
                                                                 error);
 
716
                        if (result != BRASERO_BURN_OK) {
 
717
                                BRASERO_BURN_LOG ("Problem with toc existence");
 
718
                                return result;
 
719
                        }
 
720
                }
 
721
 
693
722
                *toc = g_strdup (priv->settings->toc);
 
723
        }
694
724
 
695
725
        return BRASERO_BURN_OK;
696
726
}
769
799
        return BRASERO_BURN_OK;
770
800
}
771
801
 
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
802
/**
810
803
 *
811
804
 */
956
949
 
957
950
        if (format != BRASERO_IMAGE_FORMAT_BIN) {
958
951
                /* toc tmp file */
959
 
                complement = brasero_burn_session_get_file_complement (self, format, path);
 
952
                complement = brasero_burn_session_get_image_complement (self, format, path);
960
953
                if (complement) {
961
954
                        result = brasero_burn_session_file_test (self,
962
955
                                                                 complement,
1095
1088
}
1096
1089
 
1097
1090
BraseroBurnResult
 
1091
brasero_burn_session_tag_remove (BraseroBurnSession *self,
 
1092
                                 const gchar *tag)
 
1093
{
 
1094
        BraseroBurnSessionPrivate *priv;
 
1095
 
 
1096
        g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
 
1097
 
 
1098
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
 
1099
        if (!priv->tags)
 
1100
                return BRASERO_BURN_ERR;
 
1101
 
 
1102
        g_hash_table_remove (priv->tags, tag);
 
1103
        return BRASERO_BURN_OK;
 
1104
}
 
1105
 
 
1106
BraseroBurnResult
1098
1107
brasero_burn_session_tag_add (BraseroBurnSession *self,
1099
1108
                              const gchar *tag,
1100
1109
                              GValue *value)
1438
1447
        if (!priv->session)
1439
1448
                return;
1440
1449
 
1441
 
        if (arg_list)
1442
 
                message = g_strdup_vprintf (format, arg_list);
1443
 
        else
1444
 
                message = g_strdup (format);
 
1450
        message = g_strdup_vprintf (format, arg_list);
1445
1451
 
1446
1452
        /* we also need to validate the messages to be in UTF-8 */
1447
1453
        if (!g_utf8_validate (message, -1, (const gchar**) &offending))
1603
1609
 
1604
1610
        g_strdelimit (disc_type, " +()", '_');
1605
1611
 
 
1612
        display_name = display_name ? display_name : "";
 
1613
        disc_type = disc_type ? disc_type : "";
 
1614
 
1606
1615
        switch (brasero_burn_session_get_input_type (self, NULL)) {
1607
1616
        case BRASERO_TRACK_TYPE_NONE:
1608
1617
                key = g_strdup_printf ("%s/%s/none_%s/%s",