File indexing completed on 2024-04-28 04:57:32
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2004 Dario Massarin <nekkar@libero.it> 0004 Copyright (C) 2012 Aish Raj Dahal <dahalaishraj@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 METALINKHTTP_H 0013 #define METALINKHTTP_H 0014 0015 #include <KIO/Job> 0016 #include <QMultiHash> 0017 0018 #include "core/datasourcefactory.h" 0019 #include "core/transfer.h" 0020 #include "transfer-plugins/metalink/abstractmetalink.h" 0021 0022 #include "ui/metalinkcreator/metalinker.h" 0023 0024 class MetalinkHttp : public AbstractMetalink 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 MetalinkHttp(TransferGroup *parent, 0030 TransferFactory *factory, 0031 Scheduler *scheduler, 0032 const QUrl &src, 0033 const QUrl &dest, 0034 KGetMetalink::MetalinkHttpParser *httpParser, 0035 const QDomElement *e = nullptr); 0036 ~MetalinkHttp() override; 0037 0038 public Q_SLOTS: 0039 0040 // --- Job virtual functions --- 0041 void start() override; 0042 void save(const QDomElement &element) override; 0043 void load(const QDomElement *element) override; 0044 void deinit(Transfer::DeleteOptions options) override; 0045 void slotSignatureVerified() override; 0046 0047 private Q_SLOTS: 0048 /** 0049 * @return true if initialising worked 0050 * @note false does not mean that an error happened, it could mean, that the user 0051 * decided to update the metalink 0052 */ 0053 bool metalinkHttpInit(); 0054 0055 /** 0056 * @note sets the signatures in the headers to the signature reader 0057 */ 0058 0059 void setSignature(QUrl &dest, QByteArray &data, DataSourceFactory *dataFactory); 0060 0061 /** 0062 * @note sets the Instance Digests in the headers to the vlaues as per 0063 * the Instance digest in header 0064 */ 0065 0066 void setDigests(); 0067 /** 0068 * @note sets the links in the headers to the vlaues as per 0069 * the Link in header 0070 */ 0071 void setLinks(); 0072 0073 private: 0074 QUrl m_signatureUrl; 0075 QUrl m_metalinkxmlUrl; 0076 void startMetalink() override; 0077 KGetMetalink::MetalinkHttpParser *m_httpparser; 0078 QList<KGetMetalink::HttpLinkHeader> m_linkheaderList; 0079 QMultiHash<QString, QString> m_DigestList; 0080 0081 /** 0082 * Needed to change the cases of hash type to be compatible with the Metalink XML types 0083 * @param Standard hash algorithm value in QString 0084 */ 0085 static QString adaptDigestType(const QString &); 0086 }; 0087 0088 #endif // METALINKHTTP_H