File indexing completed on 2024-12-01 04:33:18
0001 /*************************************************************************** 0002 * Copyright (C) 2010 Matthias Fuchs <mat69@gmx.net> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 0018 ***************************************************************************/ 0019 0020 #ifndef DBUSVERIFIERWRAPPER_H 0021 #define DBUSVERIFIERWRAPPER_H 0022 0023 #include <QDBusVariant> 0024 #include <kio/global.h> 0025 0026 class Verifier; 0027 0028 class DBusVerifierWrapper : public QObject 0029 { 0030 Q_OBJECT 0031 public: 0032 explicit DBusVerifierWrapper(Verifier *parent); 0033 ~DBusVerifierWrapper() override; 0034 0035 public Q_SLOTS: 0036 /** 0037 * @return the dest url 0038 */ 0039 QString destination() const; 0040 0041 /** 0042 * Adds a checksum to the transfer 0043 */ 0044 void addChecksum(const QString &type, const QString &hash); 0045 0046 /** 0047 * Add partial checksums that can be used as repairinformation 0048 * @note only one checksum per type can be added (one MD5, one SHA1 etc.), 0049 * the newer overwrites the older and a checksum can only be added if it is 0050 * supported by the verifier 0051 * @param type the type of the checksums 0052 * @param length the length of each piece 0053 * @param checksums the checksums, first entry is piece number 0 0054 */ 0055 void addPartialChecksums(const QString &type, qulonglong length, const QStringList &checksums); 0056 0057 bool isVerifyable() const; 0058 0059 void verify(); 0060 0061 /** 0062 * Call this method after calling verify() with a negative result, it will 0063 * Q_EMIT a list of the broken pieces, if PartialChecksums were defined, 0064 * otherwise and in case of any error an empty list will be emitted 0065 */ 0066 void brokenPieces() const; 0067 0068 Q_SIGNALS: 0069 /** 0070 * Emitted when the verification of a file finishes 0071 */ 0072 void verified(bool verified); 0073 0074 /** 0075 * Emitted when brokenPiecesThreaded finishes, the list can be empty 0076 * @param offsets of the broken pieces, they are the beginning 0077 * @param length of broken pieces 0078 */ 0079 void brokenPieces(const QStringList &offsets, qulonglong length); 0080 0081 private Q_SLOTS: 0082 void slotBrokenPieces(const QList<KIO::fileoffset_t> &offsets, KIO::filesize_t length); 0083 0084 private: 0085 Verifier *m_verifier; 0086 }; 0087 0088 #endif