File indexing completed on 2024-05-19 05:00:09
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2004 Dario Massarin <nekkar@libero.it> 0004 Copyright (C) 2006 Manolo Valdes <nolis71cu@gmail.com> 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_MULTISEGKIO_H 0013 #define TRANSFER_MULTISEGKIO_H 0014 0015 #include <KIO/Job> 0016 0017 #include "core/datasourcefactory.h" 0018 #include "core/transfer.h" 0019 0020 /** 0021 * This transfer uses multiple segments to download a file 0022 */ 0023 0024 class DataSourceFactory; 0025 class FileModel; 0026 0027 class TransferMultiSegKio : public Transfer 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 TransferMultiSegKio(TransferGroup *parent, 0033 TransferFactory *factory, 0034 Scheduler *scheduler, 0035 const QUrl &src, 0036 const QUrl &dest, 0037 const QDomElement *e = nullptr); 0038 0039 bool repair(const QUrl &file = QUrl()) override; 0040 0041 /** 0042 * Move the download to the new destination 0043 * @param newDirectory is a directory where the download should be stored 0044 * @returns true if newDestination can be used 0045 */ 0046 bool setDirectory(const QUrl &newDirectory) override; 0047 0048 void init() override; 0049 void deinit(Transfer::DeleteOptions options) override; 0050 0051 QHash<QUrl, QPair<bool, int>> availableMirrors(const QUrl &file) const override; 0052 void setAvailableMirrors(const QUrl &file, const QHash<QUrl, QPair<bool, int>> &mirrors) override; 0053 0054 /** 0055 * @param file for which to get the verifier 0056 * @return Verifier that allows you to add checksums manually verify a file etc. 0057 */ 0058 Verifier *verifier(const QUrl &file = QUrl()) override; 0059 0060 /** 0061 * @param file for which to get the signature 0062 * @return Signature that allows you to add signatures and verify them 0063 */ 0064 Signature *signature(const QUrl &file = QUrl()) override; 0065 0066 FileModel *fileModel() override; 0067 0068 public Q_SLOTS: 0069 bool setNewDestination(const QUrl &newDestination); 0070 // --- Job virtual functions --- 0071 void start() override; 0072 void stop() override; 0073 0074 void save(const QDomElement &element) override; 0075 void load(const QDomElement *e) override; 0076 void slotChecksumFound(QString type, QString checksum); 0077 0078 private: 0079 void createJob(); 0080 0081 private Q_SLOTS: 0082 void slotDataSourceFactoryChange(Transfer::ChangesFlags change); 0083 void slotUpdateCapabilities(); 0084 void slotSearchUrls(const QList<QUrl> &urls); 0085 void slotRename(const QUrl &oldUrl, const QUrl &newUrl); 0086 void slotVerified(bool isVerified); 0087 void slotStatResult(KJob *kioJob); 0088 0089 private: 0090 bool m_movingFile; 0091 bool m_searchStarted; 0092 bool m_verificationSearch; 0093 DataSourceFactory *m_dataSourceFactory; 0094 FileModel *m_fileModel; 0095 }; 0096 0097 #endif