summaryrefslogtreecommitdiffstats
path: root/src/rip/k3baudioripthread.h
blob: d9b0b1bbf4b082ba0f10cdd357a5c0826db4ecb7 (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
/*
 *
 * $Id: k3baudioripthread.h 619556 2007-01-03 17:38:12Z trueg $
 * Copyright (C) 2003 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.
 */


#ifndef K3B_AUDIO_RIP_THREAD_H
#define K3B_AUDIO_RIP_THREAD_H

#include <k3bthread.h>
#include <tqobject.h>
#include <tqvaluevector.h>
#include <tqpair.h>

#include <k3bcddbquery.h>


class K3bAudioEncoder;
class K3bCdparanoiaLib;
namespace K3bDevice {
  class Device;
}


class K3bAudioRipThread : public TQObject, public K3bThread
{
  Q_OBJECT
  

 public:
  K3bAudioRipThread();
  ~K3bAudioRipThread();

  TQString jobDescription() const;
  TQString jobDetails() const;

  // paranoia settings
  void setParanoiaMode( int mode );
  void setMaxRetries( int r );
  void setNeverSkip( bool b );

  void setSingleFile( bool b ) { m_singleFile = b; }

  void setUseIndex0( bool b ) { m_useIndex0 = b; }

  void setDevice( K3bDevice::Device* dev ) { m_device = dev; }

  void setCddbEntry( const K3bCddbResultEntry& e ) { m_cddbEntry = e; }

  // if 0 (default) wave files are created
  void setEncoder( K3bAudioEncoder* f );

  /**
   * Used for encoders that support multiple formats
   */
  void setFileType( const TQString& );

  /**
   * 1 is the first track
   */
  void setTracksToRip( const TQValueVector<TQPair<int, TQString> >& t ) { m_tracks = t; }

  void setWritePlaylist( bool b ) { m_writePlaylist = b; }
  void setPlaylistFilename( const TQString& s ) { m_playlistFilename = s; }
  void setUseRelativePathInPlaylist( bool b ) { m_relativePathInPlaylist = b; }
  void setWriteCueFile( bool b ) { m_writeCueFile = b; }

  void cancel();

 private slots:
  void slotCheckIfThreadStillRunning();

 private:
  /** reimplemented from TQThread. Does the work */
  void run();

  bool ripTrack( int track, const TQString& filename );
  void cleanupAfterCancellation();
  bool writePlaylist();
  bool writeCueFile();

  /**
   * Finds a relative path from baseDir to absPath
   */
  TQString findRelativePath( const TQString& absPath, const TQString& baseDir );

  K3bCddbResultEntry m_cddbEntry;
  K3bDevice::Device* m_device;

  bool m_bUsePattern;
  bool m_singleFile;
  bool m_useIndex0;

  bool m_writePlaylist;
  bool m_relativePathInPlaylist;
  TQString m_playlistFilename;

  bool m_writeCueFile;

  TQValueVector<TQPair<int, TQString> > m_tracks;

  friend class K3bAudioRipJob;

  class Private;
  Private* d;
};

#endif