summaryrefslogtreecommitdiffstats
path: root/libk3b/projects/videocd/k3bvcdoptions.cpp
blob: e19e6227f2fc4897502b7966dcb01e7e742816a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
*
* $Id: k3bvcdoptions.cpp 619556 2007-01-03 17:38:12Z trueg $
* Copyright (C) 2003-2004 Christian Kvasny <chris@k3b.org>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See the file "COPYING" for the exact licensing terms.
*/

// Kde Includes
#include <kapplication.h>
#include <tdeconfig.h>
#include <k3bcore.h>
#include <klocale.h>
#include <kstandarddirs.h>

// TQt Includes
#include <tqstring.h>
#include <tqfile.h>

// K3b Includes
#include "k3bvcdoptions.h"
#include <k3bversion.h>

K3bVcdOptions::K3bVcdOptions()
        : m_restriction( 0 ),
        m_segment( 0 ),
        m_sequence( 0 ),
        m_pbcenabled( PbcEnabled() ),
        m_pbcnumkeysenabled( PbcNumkeysEnabled() ),
        m_volumeID( "VIDEOCD" ),
        m_albumID( "" ),
        m_volumeSetId( "" ),
        m_publisher( TQString( "K3b - Version %1" ).arg( k3bcore->version() ) ),
        m_applicationId( "CDI/CDI_VCD.APP;1" ),
        m_systemId( "CD-RTOS CD-BRIDGE" ),
        m_vcdclass( "vcd" ),
        m_vcdversion( "2.0" ),
        m_pregapleadout( 150 ),
        m_pregaptrack( 150 ),
        m_frontmargintrack( 30 ),
        m_rearmargintrack( 45 ),
        m_frontmargintrackSVCD( 0 ),
        m_rearmargintrackSVCD( 0 ),
        m_mpegversion( 1 ),
        m_volumeCount( 1 ),
        m_volumeNumber( 1 ),
        m_autodetect( true ),
        m_cdisupport( false ),
        m_brokensvcdmode( false ),
        m_VCD30interpretation( false ),
        m_sector2336( false ),
        m_updatescanoffsets( false ),
        m_relaxedaps( false ),
        m_segmentfolder( true ),
        m_usegaps( false )
{}

bool K3bVcdOptions::checkCdiFiles()
{
    m_cdisize = 0;
    if ( !TQFile::exists( locate( "data", "k3b/cdi/cdi_imag.rtf" ) ) )
        return false;
    if ( !TQFile::exists( locate( "data", "k3b/cdi/cdi_text.fnt" ) ) )
        return false;
    if ( !TQFile::exists( locate( "data", "k3b/cdi/cdi_vcd.app" ) ) )
        return false;
    if ( !TQFile::exists( locate( "data", "k3b/cdi/cdi_vcd.cfg" ) ) )
        return false;

    m_cdisize += TQFile( locate( "data", "k3b/cdi/cdi_imag.rtf" ) ).size();
    m_cdisize += TQFile( locate( "data", "k3b/cdi/cdi_text.fnt" ) ).size();
    m_cdisize += TQFile( locate( "data", "k3b/cdi/cdi_vcd.app" ) ).size();
    m_cdisize += TQFile( locate( "data", "k3b/cdi/cdi_vcd.cfg" ) ).size();

    return true;
}

void K3bVcdOptions::save( TDEConfigBase* c )
{
    c->writeEntry( "volume_id", m_volumeID );
    c->writeEntry( "album_id", m_albumID );
    c->writeEntry( "volume_set_id", m_volumeSetId );
    c->writeEntry( "preparer", m_preparer );
    c->writeEntry( "publisher", m_publisher );
    c->writeEntry( "volume_count", m_volumeCount );
    c->writeEntry( "volume_number", m_volumeNumber );
    c->writeEntry( "autodetect", m_autodetect );
    c->writeEntry( "cdi_support", m_cdisupport );
    c->writeEntry( "broken_svcd_mode", m_brokensvcdmode );
    c->writeEntry( "VCD30interpretation", m_VCD30interpretation );
    c->writeEntry( "2336_sectors", m_sector2336 );
    c->writeEntry( "UpdateScanOffsets", m_updatescanoffsets );
    c->writeEntry( "RelaxedAps", m_relaxedaps );
    c->writeEntry( "PbcEnabled", m_pbcenabled );
    c->writeEntry( "SegmentFolder", m_segmentfolder );
    c->writeEntry( "Restriction", m_restriction );
    c->writeEntry( "PreGapLeadout", m_pregapleadout );
    c->writeEntry( "PreGapTrack", m_pregaptrack );
    c->writeEntry( "FrontMarginTrack", m_frontmargintrack );
    c->writeEntry( "RearMarginTrack", m_rearmargintrack );
    c->writeEntry( "UseGaps", m_usegaps );
}


K3bVcdOptions K3bVcdOptions::load( TDEConfigBase* c )
{
    K3bVcdOptions options;

    options.setVolumeId( c->readEntry( "volume_id", options.volumeId() ) );
    options.setAlbumId( c->readEntry( "album_id", options.albumId() ) );
    options.setVolumeSetId( c->readEntry( "volume_set_id", options.volumeSetId() ) );
    options.setPreparer( c->readEntry( "preparer", options.preparer() ) );
    options.setPublisher( c->readEntry( "publisher", options.publisher() ) );
    options.setVolumeCount( c->readNumEntry( "volume_count", options.volumeCount() ) );
    options.setVolumeNumber( c->readNumEntry( "volume_number", options.volumeNumber() ) );
    options.setAutoDetect( c->readBoolEntry( "autodetect", options.AutoDetect() ) );
    options.setCdiSupport( c->readBoolEntry( "cdi_support", options.CdiSupport() ) );
    options.setNonCompliantMode( c->readBoolEntry( "broken_svcd_mode", options.NonCompliantMode() ) );
    options.setVCD30interpretation( c->readBoolEntry( "VCD30interpretation", options.VCD30interpretation() ) );
    options.setSector2336( c->readBoolEntry( "2336_sectors", options.Sector2336() ) );
    options.setUpdateScanOffsets( c->readBoolEntry( "UpdateScanOffsets", options.UpdateScanOffsets() ) );
    options.setRelaxedAps( c->readBoolEntry( "RelaxedAps", options.RelaxedAps() ) );
    options.setPbcEnabled( c->readBoolEntry( "PbcEnabled", options.PbcEnabled() ) );
    options.setSegmentFolder( c->readBoolEntry( "SegmentFolder", options.SegmentFolder() ) );
    options.setRestriction( c->readNumEntry( "Restriction", options.Restriction() ) );
    options.setPreGapLeadout( c->readNumEntry( "PreGapLeadout", options.PreGapLeadout() ) );
    options.setPreGapTrack( c->readNumEntry( "PreGapTrack", options.PreGapTrack() ) );
    options.setFrontMarginTrack( c->readNumEntry( "FrontMarginTrack", options.FrontMarginTrack() ) );
    options.setRearMarginTrack( c->readNumEntry( "RearMarginTrack", options.RearMarginTrack() ) );
    options.setUseGaps( c->readBoolEntry( "UseGaps", options.UseGaps() ) );

    return options;
}

K3bVcdOptions K3bVcdOptions::defaults()
{
    // let the constructor create defaults
    return K3bVcdOptions();
}