summaryrefslogtreecommitdiffstats
path: root/libk3b/projects/datacd/k3bisooptions.cpp
blob: 5adca1a4d10d367b8f9bdc70b501faf55692890f (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/* 
 *
 * $Id: k3bisooptions.cpp 639665 2007-03-05 16:29:52Z trueg $
 * Copyright (C) 2003-2007 Sebastian Trueg <trueg@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.
 */

#include "k3bisooptions.h"
#include <k3bcore.h>
#include <k3bversion.h>
#include <k3bglobals.h>

#include <kconfig.h>
#include <klocale.h>
#include <tqstring.h>


K3bIsoOptions::K3bIsoOptions()
  : m_volumeID( "K3b data project" ),
    m_applicationID( TQString("K3B THE CD KREATOR (C) 1998-2006 SEBASTIAN TRUEG AND THE K3B TEAM") ),
    m_systemId( K3b::systemName().upper() ),
    m_inputCharset( "iso8859-1" ),
    m_whiteSpaceTreatmentReplaceString( "_" )
{
  m_bForceInputCharset = false;

  m_createRockRidge = true;
  m_createJoliet = true;
  m_createUdf = false;
  m_ISOallowLowercase = false;
  m_ISOallowPeriodAtBegin = false;
  m_ISOallow31charFilenames = true;
  m_ISOomitVersionNumbers = false;
  m_ISOomitTrailingPeriod = false;
  m_ISOmaxFilenameLength = false;
  m_ISOrelaxedFilenames = false;
  m_ISOnoIsoTranslate = false;
  m_ISOallowMultiDot = false;
  m_ISOuntranslatedFilenames = false;
  m_followSymbolicLinks = false;
  m_createTRANS_TBL = false;
  m_hideTRANS_TBL = false;
  m_jolietLong = true;

  m_doNotCacheInodes = true;

  m_isoLevel = 2;

  m_discardSymlinks = false;
  m_discardBrokenSymlinks = false;

  m_preserveFilePermissions = false;

  m_whiteSpaceTreatment = noChange;

  m_volumeSetSize = 1;
  m_volumeSetNumber = 1;
}


void K3bIsoOptions::save( KConfigBase* c, bool saveVolumeDesc )
{
  if( saveVolumeDesc ) {
    c->writeEntry( "volume id", m_volumeID );
    c->writeEntry( "application id", m_applicationID );
    c->writeEntry( "preparer", m_preparer );
    c->writeEntry( "publisher", m_publisher );
    c->writeEntry( "system id", m_systemId );
    c->writeEntry( "volume set id", m_volumeSetId );
    c->writeEntry( "volume set size", m_volumeSetSize );
    c->writeEntry( "volume set number", m_volumeSetNumber );
    c->writeEntry( "abstract file", m_abstractFile );
    c->writeEntry( "copyright file", m_copyrightFile );
    c->writeEntry( "bibliograph file", m_bibliographFile );
  }

  c->writeEntry( "rock_ridge", m_createRockRidge );
  c->writeEntry( "joliet", m_createJoliet );
  c->writeEntry( "udf", m_createUdf );

  // save iso-level
  c->writeEntry( "iso_level", m_isoLevel );

  c->writeEntry( "create TRANS_TBL", m_createTRANS_TBL );
  c->writeEntry( "hide TRANS_TBL", m_hideTRANS_TBL );
  c->writeEntry( "untranslated filenames", m_ISOuntranslatedFilenames );
  c->writeEntry( "allow 31 character filenames", m_ISOallow31charFilenames );
  c->writeEntry( "max ISO filenames", m_ISOmaxFilenameLength );
  c->writeEntry( "allow beginning period", m_ISOallowPeriodAtBegin );
  c->writeEntry( "relaxed filenames", m_ISOrelaxedFilenames );
  c->writeEntry( "omit version numbers", m_ISOomitVersionNumbers );
  c->writeEntry( "omit trailing period", m_ISOomitTrailingPeriod );
  c->writeEntry( "no iSO translation", m_ISOnoIsoTranslate );
  c->writeEntry( "allow multiple dots", m_ISOallowMultiDot );
  c->writeEntry( "allow lowercase filenames", m_ISOallowLowercase );
  //  c->writeEntry( "follow symbolic links", m_followSymbolicLinks );

  c->writeEntry( "joliet long", m_jolietLong );

  c->writeEntry( "force input charset", m_bForceInputCharset );
  c->writeEntry( "input charset", m_inputCharset );

  c->writeEntry( "do not cache inodes", m_doNotCacheInodes );

  // save whitespace-treatment
  switch( m_whiteSpaceTreatment ) {
  case strip:
    c->writeEntry( "white_space_treatment", "strip" );
    break;
  case extended:
    c->writeEntry( "white_space_treatment", "extended" );
    break;
  case tqreplace:
    c->writeEntry( "white_space_treatment", "tqreplace" );
    break;
  default:
    c->writeEntry( "white_space_treatment", "noChange" );
  }

  c->writeEntry( "whitespace replace string", m_whiteSpaceTreatmentReplaceString );

  c->writeEntry( "discard symlinks", discardSymlinks() );
  c->writeEntry( "discard broken symlinks", discardBrokenSymlinks() );

  c->writeEntry( "preserve file permissions", m_preserveFilePermissions );
}


K3bIsoOptions K3bIsoOptions::load( KConfigBase* c, bool loadVolumeDesc )
{
  K3bIsoOptions options;

  if( loadVolumeDesc ) {
    options.setVolumeID( c->readEntry( "volume id", options.volumeID() ) );
    options.setApplicationID( c->readEntry( "application id", options.applicationID() ) );
    options.setPreparer( c->readEntry( "preparer", options.preparer() ) );
    options.setPublisher( c->readEntry( "publisher", options.publisher() ) );
    options.setSystemId( c->readEntry( "system id", options.systemId() ) );
    options.setVolumeSetId( c->readEntry( "volume set id", options.volumeSetId() ) );
    options.setVolumeSetSize( c->readNumEntry( "volume set size", options.volumeSetSize() ) );
    options.setVolumeSetNumber( c->readNumEntry( "volume set number", options.volumeSetNumber() ) );
    options.setAbstractFile( c->readEntry( "abstract file", options.abstractFile() ) );
    options.setCoprightFile( c->readEntry( "copyright file", options.copyrightFile() ) );
    options.setBibliographFile( c->readEntry( "bibliograph file", options.bibliographFile() ) );
  }

  options.setForceInputCharset( c->readBoolEntry( "force input charset", options.forceInputCharset() ) );
  if( options.forceInputCharset() )
    options.setInputCharset( c->readEntry( "input charset", options.inputCharset() ) );

  options.setCreateRockRidge( c->readBoolEntry( "rock_ridge", options.createRockRidge() ) );
  options.setCreateJoliet( c->readBoolEntry( "joliet", options.createJoliet() ) );
  options.setCreateUdf( c->readBoolEntry( "udf", options.createUdf() ) );

  options.setISOLevel( c->readNumEntry( "iso_level", options.ISOLevel() ) );

  options.setCreateTRANS_TBL( c->readBoolEntry( "create TRANS_TBL", options.createTRANS_TBL() ) );
  options.setHideTRANS_TBL( c->readBoolEntry( "hide TRANS_TBL", options.hideTRANS_TBL() ) );

  //
  // We need to use the memeber variables here instead of the access methods
  // which do not return the actual value of the member variables but the value
  // representing the use in mkisofs (i.e. ISOomitVersionNumbers is also enabled
  // if ISOmaxFilenameLength is enabled.
  //
  options.setISOuntranslatedFilenames( c->readBoolEntry( "untranslated filenames", options.m_ISOuntranslatedFilenames ) );
  options.setISOallow31charFilenames( c->readBoolEntry( "allow 31 character filenames", options.m_ISOallow31charFilenames ) );
  options.setISOmaxFilenameLength( c->readBoolEntry( "max ISO filenames", options.m_ISOmaxFilenameLength ) );
  options.setISOallowPeriodAtBegin( c->readBoolEntry( "allow beginning period", options.m_ISOallowPeriodAtBegin ) );
  options.setISOrelaxedFilenames( c->readBoolEntry( "relaxed filenames", options.m_ISOrelaxedFilenames ) );
  options.setISOomitVersionNumbers( c->readBoolEntry( "omit version numbers", options.m_ISOomitVersionNumbers ) );
  options.setISOnoIsoTranslate( c->readBoolEntry( "no iSO translation", options.m_ISOnoIsoTranslate ) );
  options.setISOallowMultiDot( c->readBoolEntry( "allow multiple dots", options.m_ISOallowMultiDot ) );
  options.setISOallowLowercase( c->readBoolEntry( "allow lowercase filenames", options.m_ISOallowLowercase ) );
  options.setISOomitTrailingPeriod( c->readBoolEntry( "omit trailing period", options.m_ISOomitTrailingPeriod ) );

  //  options.setFollowSymbolicLinks( c->readBoolEntry( "follow symbolic links", options.m_followSymbolicLinks ) );

  options.setJolietLong( c->readBoolEntry( "joliet long", options.jolietLong() ) );

  options.setDoNotCacheInodes( c->readBoolEntry( "do not cache inodes", options.doNotCacheInodes() ) );

  TQString w = c->readEntry( "white_space_treatment", "noChange" );
  if( w == "tqreplace" )
    options.setWhiteSpaceTreatment( tqreplace );
  else if( w == "strip" )
    options.setWhiteSpaceTreatment( strip );
  else if( w == "extended" )
    options.setWhiteSpaceTreatment( extended );
  else
    options.setWhiteSpaceTreatment( noChange );

  options.setWhiteSpaceTreatmentReplaceString( c->readEntry( "whitespace replace string", options.whiteSpaceTreatmentReplaceString() ) );

  options.setDiscardSymlinks( c->readBoolEntry("discard symlinks", options.discardSymlinks() ) );
  options.setDiscardBrokenSymlinks( c->readBoolEntry("discard broken symlinks", options.discardBrokenSymlinks() ) );

  options.setPreserveFilePermissions( c->readBoolEntry( "preserve file permissions", options.preserveFilePermissions() ) );

  return options;
}


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