summaryrefslogtreecommitdiffstats
path: root/libk3b/projects/k3bcdrdaowriter.h
blob: c1d145778712945784a68c649d218178b749e78d (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
/*
 *
 * $Id: k3bcdrdaowriter.h 619556 2007-01-03 17:38:12Z trueg $
 * Copyright (C) 2003 Sebastian Trueg <[email protected]>
 *                    Klaus-Dieter Krannich <[email protected]>
 *
 * This file is part of the K3b project.
 * Copyright (C) 1998-2007 Sebastian Trueg <[email protected]>
 *
 * 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.
 */


#ifndef K3B_CDRDAO_WRITER_H
#define K3B_CDRDAO_WRITER_H


#include "k3babstractwriter.h"

class K3bExternalBin;
class K3bProcess;
class TDEProcess;
class K3bDevice::Device;
class TQSocket;



class K3bCdrdaoWriter : public K3bAbstractWriter
{
  Q_OBJECT
  

 public:

  enum Command { WRITE, COPY, READ, BLANK };
  enum BlankMode { FULL, MINIMAL };
  enum SubMode { None, RW, RW_RAW };

  K3bCdrdaoWriter( K3bDevice::Device* dev, K3bJobHandler*, 
		   TQObject* parent = 0, const char* name = 0 );
  ~K3bCdrdaoWriter();

  /**
   * to be used in chain: addArgument(x)->addArgument(y)
   */
  K3bCdrdaoWriter* addArgument( const TQString& );
  K3bDevice::Device* sourceDevice() { return m_sourceDevice; };

  int fd() const;

  bool active() const;

 private:
  void reinitParser();
  void parseCdrdaoLine( const TQString& line );
  void parseCdrdaoWrote( const TQString& line );
  void parseCdrdaoError( const TQString& line ); 

 public slots:
  void start();
  void cancel();

  // options
  // ---------------------
  void setCommand( int c ) { m_command = c; }
  void setBlankMode( int b ) { m_blankMode = b; }
  void setMulti( bool b ) { m_multi = b; }
  void setForce( bool b ) { m_force = b; }
  void setOnTheFly( bool b ) { m_onTheFly = b; }
  void setDataFile( const TQString& s ) { m_dataFile = s; }
  void setTocFile( const TQString& s ) { m_tocFile = s; }

  void setSourceDevice( K3bDevice::Device* dev ) { m_sourceDevice = dev; }
  void setFastToc( bool b ) { m_fastToc = b; }
  void setReadRaw( bool b ) { m_readRaw = b; }
  void setReadSubchan(SubMode m) { m_readSubchan=m; };
  void setParanoiaMode( int i ) { m_paranoiaMode = i; }
  void setTaoSource(bool b) { m_taoSource=b; };
  void setTaoSourceAdjust(int a) { m_taoSourceAdjust=a; };
  void setSession(int s) { m_session=s; };
  void setEject(bool e) { m_eject=e; };  
// ---------------------

  /**
   * If set true the job ignores the global K3b setting
   * and does not eject the CD-RW after finishing
   */
  void setForceNoEject( bool b ) { m_forceNoEject = b; }

 private slots:
  void slotStdLine( const TQString& line );
  void slotProcessExited(TDEProcess*);
  void parseCdrdaoMessage();
  void slotThroughput( int t );

 private:
  void unknownCdrdaoLine( const TQString& );
  void prepareArgumentList();
  void setWriteArguments();
  void setReadArguments();
  void setCopyArguments();
  void setBlankArguments();
  void setCommonArguments();

  bool cueSheet();

  TQString findDriverFile( const K3bExternalBin* bin );
  bool defaultToGenericMMC( K3bDevice::Device* dev, bool writer );

  // options
  // ---------------------
  int        m_command;
  int        m_blankMode;
  K3bDevice::Device* m_sourceDevice;
  TQString    m_dataFile;
  TQString    m_tocFile;
  TQString    m_cueFileLnk;
  TQString    m_binFileLnk;
  TQString m_backupTocFile;
  bool       m_readRaw;
  bool       m_multi;
  bool       m_force;
  bool       m_onTheFly;
  bool       m_fastToc;
  SubMode    m_readSubchan;
  bool       m_taoSource;
  int        m_taoSourceAdjust;
  int        m_paranoiaMode;
  int        m_session;
  bool       m_eject;
  // ---------------------

  const K3bExternalBin* m_cdrdaoBinObject;
  K3bProcess* m_process;

  int m_cdrdaoComm[2];
  TQSocket         *m_comSock;

  bool m_canceled;

  bool m_knownError;

// parser

  int m_size;
  int m_currentTrack;

  bool m_forceNoEject;

  class Private;
  Private* d;
};

#endif