File indexing completed on 2024-04-28 04:57:31
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2004 Dario Massarin <nekkar@libero.it> 0004 Copyright (C) 2009 Matthias Fuchs <mat69@gmx.net> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 */ 0011 0012 #ifndef TRANSFER_KIO_H 0013 #define TRANSFER_KIO_H 0014 0015 #include <KIO/FileCopyJob> 0016 0017 #include "core/transfer.h" 0018 0019 /** 0020 * This transfer uses the KIO class to download files 0021 */ 0022 0023 class Verifier; 0024 0025 class TransferKio : public Transfer 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 TransferKio(TransferGroup *parent, TransferFactory *factory, Scheduler *scheduler, const QUrl &src, const QUrl &dest, const QDomElement *e = nullptr); 0031 0032 /** 0033 * Move the download to the new destination 0034 * @param newDirectory is a directory where the download should be stored 0035 * @returns true if newDestination can be used 0036 */ 0037 bool setDirectory(const QUrl &newDirectory) override; 0038 0039 bool repair(const QUrl &file = QUrl()) override; 0040 0041 Verifier *verifier(const QUrl &file = QUrl()) override; 0042 Signature *signature(const QUrl &file = QUrl()) override; 0043 0044 public Q_SLOTS: 0045 bool setNewDestination(const QUrl &newDestination); 0046 0047 // --- Job virtual functions --- 0048 void start() override; 0049 void stop() override; 0050 0051 void deinit(Transfer::DeleteOptions options) override; 0052 0053 private: 0054 void createJob(); 0055 0056 KIO::FileCopyJob *m_copyjob; 0057 bool m_stopped; 0058 bool m_movingFile; 0059 0060 private Q_SLOTS: 0061 void slotResult(KJob *kioJob); 0062 void slotInfoMessage(KJob *kioJob, const QString &msg); 0063 void slotPercent(KJob *kioJob, unsigned long percent); 0064 void slotTotalSize(KJob *kioJob, qulonglong size); 0065 void slotProcessedSize(KJob *kioJob, qulonglong size); 0066 void slotSpeed(KJob *kioJob, unsigned long bytes_per_second); 0067 void newDestResult(KJob *result); 0068 void slotVerified(bool isVerified); 0069 void slotStatResult(KJob *kioJob); 0070 0071 private: 0072 Verifier *m_verifier; 0073 Signature *m_signature; 0074 }; 0075 0076 #endif