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) 2007 Manolo Valdes <nolis71cu@gmail.com> 0005 Copyright (C) 2012 Aish Raj Dahal <dahalaishraj@gmail.com> 0006 0007 This program is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 */ 0012 0013 #include "metalinkfactory.h" 0014 0015 #include "core/scheduler.h" 0016 #include "core/transfergroup.h" 0017 #include "metalinkhttp.h" 0018 #include "metalinkxml.h" 0019 0020 #include "kget_debug.h" 0021 #include <QDebug> 0022 0023 K_PLUGIN_CLASS_WITH_JSON(MetalinkFactory, "kget_metalinkfactory.json") 0024 0025 MetalinkFactory::MetalinkFactory(QObject *parent, const QVariantList &args) 0026 : TransferFactory(parent, args) 0027 { 0028 } 0029 0030 MetalinkFactory::~MetalinkFactory() 0031 { 0032 } 0033 0034 Transfer *MetalinkFactory::createTransfer(const QUrl &srcUrl, const QUrl &destUrl, TransferGroup *parent, Scheduler *scheduler, const QDomElement *e) 0035 { 0036 qCDebug(KGET_DEBUG) << "metalinkFactory::createTransfer"; 0037 auto *metalinkHttpChecker = new KGetMetalink::MetalinkHttpParser(srcUrl); 0038 0039 if (metalinkHttpChecker->isMetalinkHttp()) { 0040 qCDebug(KGET_DEBUG) << "Create MetalinkHTTP"; 0041 return new MetalinkHttp(parent, this, scheduler, srcUrl, destUrl, metalinkHttpChecker, e); 0042 } 0043 // No one takes ownership of this checker 0044 metalinkHttpChecker->deleteLater(); 0045 0046 if (isSupported(srcUrl)) { 0047 return new MetalinkXml(parent, this, scheduler, srcUrl, destUrl, e); 0048 } 0049 0050 return nullptr; 0051 } 0052 0053 bool MetalinkFactory::isSupported(const QUrl &url) const 0054 { 0055 return (url.fileName().endsWith(QLatin1String(".metalink")) || url.fileName().endsWith(QLatin1String(".meta4"))); 0056 } 0057 0058 #include "metalinkfactory.moc" 0059 #include "moc_metalinkfactory.cpp"