File indexing completed on 2024-04-21 04:57:08

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 #include "dbusverifierwrapper.h"
0021 #include "core/verificationmodel.h"
0022 #include "core/verifier.h"
0023 
0024 DBusVerifierWrapper::DBusVerifierWrapper(Verifier *verifier)
0025     : QObject(verifier)
0026     , m_verifier(verifier)
0027 {
0028     connect(m_verifier,
0029             SIGNAL(brokenPieces(QList<KIO::fileoffset_t>, KIO::filesize_t)),
0030             this,
0031             SLOT(slotBrokenPieces(QList<KIO::fileoffset_t>, KIO::filesize_t)));
0032     connect(m_verifier, &Verifier::verified, this, &DBusVerifierWrapper::verified);
0033 }
0034 
0035 DBusVerifierWrapper::~DBusVerifierWrapper()
0036 {
0037 }
0038 
0039 QString DBusVerifierWrapper::destination() const
0040 {
0041     return m_verifier->destination().toString();
0042 }
0043 
0044 void DBusVerifierWrapper::addChecksum(const QString &type, const QString &hash)
0045 {
0046     m_verifier->model()->addChecksum(type, hash);
0047 }
0048 
0049 void DBusVerifierWrapper::addPartialChecksums(const QString &type, qulonglong length, const QStringList &checksums)
0050 {
0051     m_verifier->addPartialChecksums(type, length, checksums);
0052 }
0053 
0054 bool DBusVerifierWrapper::isVerifyable() const
0055 {
0056     return m_verifier->isVerifyable();
0057 }
0058 
0059 void DBusVerifierWrapper::verify()
0060 {
0061     m_verifier->verify();
0062 }
0063 
0064 void DBusVerifierWrapper::brokenPieces() const
0065 {
0066     m_verifier->brokenPieces();
0067 }
0068 
0069 void DBusVerifierWrapper::slotBrokenPieces(const QList<KIO::fileoffset_t> &offsets, KIO::filesize_t length)
0070 {
0071     // FIXME seems to work correct though is not correctly received at TestTransfers or maybe wrong converted
0072     //     QList<QVariant> broken;
0073     //     for (int i = 0; i < brokenPieces.count(); ++i) {
0074     //         broken << brokenPieces[i];
0075     //     }
0076     //
0077     //     QDBusVariant dbusBroken;
0078     //     dbusBroken.setVariant(QVariant(broken));
0079     //     Q_EMIT this->brokenPieces(dbusBroken);
0080 
0081     QStringList broken;
0082     for (int i = 0; i < offsets.count(); ++i) {
0083         broken << QString::number(offsets[i]);
0084     }
0085 
0086     Q_EMIT brokenPieces(broken, length);
0087 }
0088 
0089 #include "moc_dbusverifierwrapper.cpp"