File indexing completed on 2024-06-16 07:42:26

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef _K3B_MD5_JOB_H_
0007 #define _K3B_MD5_JOB_H_
0008 
0009 #include "k3b_export.h"
0010 #include "k3bjob.h"
0011 #include <QByteArray>
0012 
0013 class QIODevice;
0014 
0015 namespace K3b {
0016     namespace Device {
0017         class Device;
0018     }
0019 
0020     class Iso9660File;
0021 
0022     class LIBK3B_EXPORT Md5Job : public Job
0023     {
0024         Q_OBJECT
0025 
0026     public:
0027         explicit Md5Job( JobHandler* jh , QObject* parent = 0 );
0028         ~Md5Job() override;
0029 
0030         QByteArray hexDigest();
0031         QByteArray base64Digest();
0032 
0033     public Q_SLOTS:
0034         void start() override;
0035         void stop();
0036         void cancel() override;
0037 
0038         // FIXME: read from QIODevice and thus add FileSplitter support
0039 
0040         /**
0041          * read from a file.
0042          *
0043          * Be aware that the Md5Job uses FileSplitter to read split
0044          * images. In the future this will be changed with the introduction
0045          * of a setIODevice method.
0046          */
0047         void setFile( const QString& filename );
0048 
0049         /**
0050          * read from an iso9660 file
0051          */
0052         void setFile( const Iso9660File* );
0053 
0054         /**
0055          * read from a device
0056          * This should be used in combination with setMaxReadSize
0057          */
0058         void setDevice( Device::Device* dev );
0059 
0060         /**
0061          * read from the opened QIODevice.
0062          * One needs to set the max read length or call stop()
0063          * to finish calculation.
0064          */
0065         void setIODevice( QIODevice* ioDev );
0066 
0067         /**
0068          * Set the maximum bytes to read.
0069          */
0070         void setMaxReadSize( qint64 );
0071 
0072     private Q_SLOTS:
0073         void slotUpdate();
0074 
0075     private:
0076         void setupFdNotifier();
0077         void stopAll();
0078 
0079         class Private;
0080         Private* const d;
0081     };
0082 }
0083 
0084 #endif