File: verificationthread.h

package info (click to toggle)
kget 4%3A25.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,112 kB
  • sloc: cpp: 33,019; xml: 811; makefile: 9; sh: 6
file content (76 lines) | stat: -rw-r--r-- 2,660 bytes parent folder | download | duplicates (2)
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
/**************************************************************************
 *   Copyright (C) 2009-2011 Matthias Fuchs <mat69@gmx.net>                *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
 ***************************************************************************/

#ifndef VERIFICATION_THREAD_H
#define VERIFICATION_THREAD_H

#include <QUrl>
#include <kio/global.h>

#include <QMutex>
#include <QThread>

class VerificationThread : public QThread
{
    Q_OBJECT

public:
    VerificationThread(QObject *parent = nullptr);
    ~VerificationThread() override;

    void verify(const QString &type, const QString &checksum, const QUrl &file);

    void findBrokenPieces(const QString &type, const QList<QString> checksums, KIO::filesize_t length, const QUrl &file);

private:
    enum WorkType {
        Nothing,
        Verify,
        BrokenPieces
    };

    void doVerify();
    void doBrokenPieces();

Q_SIGNALS:
    /**
     * Emitted when the verification of a file finishes, connect to this signal
     * if you do the verification for one file only and do not want to bother with
     * file and type
     */
    void verified(bool verified);

    void verified(const QString &type, bool verified, const QUrl &file);

    void brokenPieces(const QList<KIO::fileoffset_t> &offsets, KIO::filesize_t length);

protected:
    void run() override;

private:
    QMutex m_mutex;
    bool m_abort;
    QStringList m_types;
    QStringList m_checksums;
    QList<QUrl> m_files;
    KIO::filesize_t m_length;
    WorkType m_type;
};

#endif