1 /*
2     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
3     SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 #ifndef _K3B_GROWISOFS_HANDLER_H_
6 #define _K3B_GROWISOFS_HANDLER_H_
7 
8 #include "k3bdevice.h"
9 
10 #include <QObject>
11 
12 namespace K3b {
13     namespace Device {
14         class Device;
15         class DeviceHandler;
16     }
17 
18 
19     /**
20      * This class handles the output parsing for growisofs
21      * We put it in an extra class since we have two classes
22      * using growisofs: the writer and the imager.
23      */
24     class GrowisofsHandler : public QObject
25     {
26         Q_OBJECT
27 
28     public:
29         explicit GrowisofsHandler( QObject* parent = 0 );
30         ~GrowisofsHandler() override;
31 
32         enum ErrorType {
33             ERROR_UNKNOWN,
34             ERROR_MEDIA,
35             ERROR_OVERSIZE,
36             ERROR_SPEED_SET_FAILED,
37             ERROR_OPC,
38             ERROR_MEMLOCK,
39             ERROR_WRITE_FAILED
40         };
41 
error()42         int error() const { return m_error; }
43 
44         void setMediaType(Device::MediaType mediaType);
45 
46     public Q_SLOTS:
47         /**
48          * This will basically reset the error type
49          * @param dao was growisofs called with DAO?
50          */
51         void reset( K3b::Device::Device* = 0, bool dao = false );
52 
53         void handleStart();
54         void handleLine( const QString& );
55         void handleExit( int exitCode );
56 
57     Q_SIGNALS:
58         void infoMessage( const QString&, int );
59         void newSubTask( const QString& );
60         void buffer( int );
61         void deviceBuffer( int );
62 
63         /**
64          * We need this to know when the writing finished to update the progress
65          */
66         void flushingCache();
67 
68     private Q_SLOTS:
69         void slotCheckBufferStatus();
70         void slotCheckBufferStatusDone( Device::DeviceHandler* );
71 
72     private:
73         class Private;
74         Private* d;
75 
76         int m_error;
77         bool m_dao;
78         Device::Device* m_device;
79         Device::MediaType m_mediaType;
80     };
81 }
82 
83 #endif
84