Commit 8bf5d056 authored by Lukas Appelhans's avatar Lukas Appelhans

start fixing download functionality

parent 8eb7a42c
......@@ -24,7 +24,7 @@ PluginSelector::PluginSelector(QDialog * parent)
KService::List offers = KServiceTypeTrader::self()->query("KGet/Plugin");
//TODO: POrt this
//addPlugins(KPluginInfo::fromServices(offers), KPluginSelector::ReadConfigFile, i18n("Plugins"), "Service", KSharedConfig::openConfig());
addPlugins(KPluginInfo::fromServices(offers), KPluginSelector::ReadConfigFile, i18n("Plugins"), "Service", KSharedConfig::openConfig());
load();
......
......@@ -877,7 +877,7 @@ QList<TransferHandler*> KGet::createTransfers(const QList<TransferData> &dataIte
Transfer *newTransfer = 0;
foreach (TransferFactory *factory, m_transferFactories) {
kDebug(5001) << "Trying plugin n.plugins=" << m_transferFactories.size();
kDebug(5001) << "Trying plugin n.plugins=" << m_transferFactories.size() << factory->displayName();
if ((newTransfer = factory->createTransfer(data.src, data.dest, group, m_scheduler, data.e))) {
// kDebug(5001) << "KGet::createTransfer -> CREATING NEW TRANSFER ON GROUP: _" << group->name() << "_";
newTransfer->create();
......@@ -1154,6 +1154,8 @@ void KGet::loadPlugins()
//TransferFactory plugins
KService::List offers = KServiceTypeTrader::self()->query( "KGet/Plugin", str + "'TransferFactory'" );
qDebug() << "Found" << offers.size() << "KService offers";
//Here we use a QMap only to easily sort the plugins by rank
QMap<int, KService::Ptr> services;
......@@ -1172,7 +1174,7 @@ void KGet::loadPlugins()
//members of this class (why?), such as the m_transferFactories list.
QList<KGetPlugin *> pluginList;
/*const KConfigGroup plugins = KConfigGroup(KSharedConfig::openConfig(), "Plugins");
const KConfigGroup plugins = KConfigGroup(KSharedConfig::openConfig(), "Plugins");
foreach (KService::Ptr service, services)
{
......@@ -1199,7 +1201,7 @@ void KGet::loadPlugins()
kDebug(5001) << "Error loading TransferFactory plugin ("
<< service->library() << ")";
}
}*/
}
foreach (KGetPlugin *plugin, pluginList)
{
......
......@@ -78,3 +78,9 @@ QStringList TransferFactory::addsProtocols() const
{
return QStringList();
}
QString TransferFactory::displayName() const
{
return "Undefined";
}
......@@ -86,6 +86,8 @@ class KGET_EXPORT TransferFactory : public KGetPlugin
* default implementation returns 0
*/
virtual TransferDataSource * createTransferDataSource(const QUrl &srcUrl, const QDomElement &type, QObject *parent);
virtual QString displayName() const;
};
#endif
......@@ -179,13 +179,15 @@ UrlChecker::UrlError UrlChecker::checkDestination(const QUrl &destination, bool
error = Invalid;
}
if ((error == NoError) && !QFileInfo(destination.adjusted(QUrl::RemoveFilename).toString()).isWritable()) {
qDebug() << "Adjusted destination:" << destination.adjusted(QUrl::RemoveFilename).toString();
if ((error == NoError) && !QFileInfo(destination.adjusted(QUrl::RemoveFilename).toString().remove("file://")).isWritable()) {
error = NotWriteable;
}
}
kDebug(5001) << "Destination:" << destination << "has error:" << error;
if (showNotification && (error != NoError)) {
kDebug(5001) << "Destination:" << destination << "has error:" << error;
KGet::showNotification(KGet::m_mainWindow, "error", message(destination, Destination, error));
}
......
......@@ -24,17 +24,15 @@
* KGET_EXPORT_PLUGIN( CoolKgetPlugin );
* class CoolKgetPlugin : public KGetPlugin {
* ....
* }
* }u
*/
#define KGET_EXPORT_PLUGIN( classname ) \
K_PLUGIN_FACTORY( KGetFactory, registerPlugin< classname >(); )
K_PLUGIN_FACTORY(KGetFactory, \
registerPlugin<TransferKioFactory>(); \
)
/*\
K_EXPORT_PLUGIN( KGetFactory("classname") )*/
#define KGET_EXPORT_PLUGIN_CONFIG( classname ) \
K_PLUGIN_FACTORY( KGetFactory, registerPlugin< classname >(); )
/*\
K_EXPORT_PLUGIN( KGetFactory( "classname" ) )*/
K_PLUGIN_FACTORY( KGetFactory, registerPlugin< classname >(); )
#endif
......@@ -15,8 +15,12 @@
#include "transferKio.h"
#include <kdebug.h>
#include <kpluginfactory.h>
//PORT QT5 KGET_EXPORT_PLUGIN( TransferKioFactory );
K_PLUGIN_FACTORY(KGetFactory,
registerPlugin<TransferKioFactory>();
)
//KGET_EXPORT_PLUGIN( TransferKioFactory )
TransferKioFactory::TransferKioFactory(QObject *parent, const QVariantList &args)
: TransferFactory(parent, args)
......@@ -32,7 +36,7 @@ Transfer * TransferKioFactory::createTransfer( const KUrl &srcUrl, const KUrl &d
Scheduler * scheduler,
const QDomElement * e )
{
kDebug(5001) << "TransferKioFactory::createTransfer";
qDebug() << "TransferKioFactory::createTransfer";
if (isSupported(srcUrl))
{
......@@ -43,8 +47,8 @@ Transfer * TransferKioFactory::createTransfer( const KUrl &srcUrl, const KUrl &d
bool TransferKioFactory::isSupported(const KUrl &url) const
{
QString prot = url.protocol();
kDebug(5001) << "Protocol = " << prot;
QString prot = url.scheme();
qDebug() << "Protocol = " << prot;
return addsProtocols().contains(prot);
}
......
......@@ -24,13 +24,14 @@ class TransferKioFactory : public TransferFactory
TransferKioFactory(QObject *parent, const QVariantList &args);
~TransferKioFactory();
Transfer * createTransfer( const KUrl &srcUrl, const KUrl &destUrl,
public slots:
virtual Transfer * createTransfer( const KUrl &srcUrl, const KUrl &destUrl,
TransferGroup * parent, Scheduler * scheduler,
const QDomElement * e = 0 );
QString displayName(){return "HTTP(s) / FTP(s)";}
virtual QString displayName() const {return "HTTP(s) / FTP(s)";}
bool isSupported(const KUrl &url) const;
virtual bool isSupported(const KUrl &url) const;
QStringList addsProtocols() const;
};
......
......@@ -21,7 +21,7 @@
#include "mmssettings.h"
#include "kget_export.h"
KGET_EXPORT_PLUGIN_CONFIG(DlgMmsSettings)
//KGET_EXPORT_PLUGIN_CONFIG(DlgMmsSettings)
DlgMmsSettings::DlgMmsSettings(QWidget *parent, const QVariantList &args)
: KCModule(/*KGetFactory::componentData(), */parent, args)
......
......@@ -23,7 +23,7 @@
#include <kdebug.h>
KGET_EXPORT_PLUGIN( MmsTransferFactory )
//KGET_EXPORT_PLUGIN( MmsTransferFactory )
MmsTransferFactory::MmsTransferFactory(QObject *parent, const QVariantList &args)
: TransferFactory(parent, args)
......
......@@ -271,6 +271,7 @@ void NewTransferDialog::inputTimer()
void NewTransferDialog::checkInput()
{
qDebug() << "Check input";
QUrl source = QUrl(ui.urlRequester->text().trimmed());
const QUrl dest = ui.destRequester->url();
......@@ -379,7 +380,8 @@ void NewTransferDialog::checkInput()
enableButtonOk((folderValid || destinationValid) && sourceValid);
}
kDebug(5001) << source << source.fileName() << dest << dest.fileName();
kDebug(5001) << source << source.fileName() << dest << dest.fileName() << "Folder valid:" << folderValid
<< "Destination valid:" << destinationValid << "Source valid:" << sourceValid;
}
void NewTransferDialog::slotFinished(int resultCode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment