[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kget
From:       Matthias Fuchs <mat69 () gmx ! net>
Date:       2011-03-12 12:04:54
Message-ID: 20110312120454.46821AC8C5 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1224584 by mfuchs:

Implements own mostLocalUrl function and a MostLocalUrlJob to get the most local url \
of a KUrl. Internally KIO::mostLocalUrl is used for any url whose protocol is not \
supported by a TransferFactory, i.e. one can not be sure that url is not external. \
All the other urls simply return themselve.

 M  +1 -0      CMakeLists.txt  
 M  +3 -3      core/kget.cpp  
 A             core/mostlocalurl.cpp   [License: GPL (v2+)]
 A             core/mostlocalurl.h   [License: GPL (v2+)]
 M  +5 -0      core/plugin/transferfactory.cpp  
 M  +7 -0      core/plugin/transferfactory.h  
 M  +7 -2      transfer-plugins/kio/transferKioFactory.cpp  
 M  +1 -0      transfer-plugins/kio/transferKioFactory.h  
 M  +6 -1      transfer-plugins/mms/mmsTransferFactory.cpp  
 M  +1 -0      transfer-plugins/mms/mmsTransferFactory.h  
 M  +7 -2      transfer-plugins/multisegmentkio/transfermultisegkiofactory.cpp  
 M  +1 -0      transfer-plugins/multisegmentkio/transfermultisegkiofactory.h  
 M  +5 -3      ui/newtransferdialog.cpp  


--- trunk/KDE/kdenetwork/kget/CMakeLists.txt #1224583:1224584
@@ -115,6 +115,7 @@
    core/verifier.cpp
    core/urlchecker.cpp
    core/basedialog.cpp
+   core/mostlocalurl.cpp
 )
 
 if(HAVE_NEPOMUK)
--- trunk/KDE/kdenetwork/kget/core/kget.cpp #1224583:1224584
@@ -15,6 +15,7 @@
 #include "core/kget.h"
 
 #include "mainwindow.h"
+#include "core/mostlocalurl.h"
 #include "core/transfer.h"
 #include "core/transferdatasource.h"
 #include "core/transfergroup.h"
@@ -28,7 +29,6 @@
 #include "settings.h"
 #include "core/transferhistorystore.h"
 #include <iostream>
-#include <kio/netaccess.h>
 #include <kinputdialog.h>
 #include <kfiledialog.h>
 #include <kmessagebox.h>
@@ -178,7 +178,7 @@
 TransferHandler * KGet::addTransfer(KUrl srcUrl, QString destDir, QString \
suggestedFileName, // krazy:exclude=passbyvalue  QString groupName, bool start)
 {
-    srcUrl = KIO::NetAccess::mostLocalUrl(srcUrl, m_mainWindow);
+    srcUrl = mostLocalUrl(srcUrl);
     // Note: destDir may actually be a full path to a file :-(
     kDebug(5001) << "Source:" << srcUrl.url() << ", dest: " << destDir << ", sugg \
file: " << suggestedFileName << endl;  
@@ -288,7 +288,7 @@
 
     for(; it!=itEnd ; ++it)
     {
-        *it = KIO::NetAccess::mostLocalUrl(*it, m_mainWindow);
+        *it = mostLocalUrl(*it);
         if ( isValidSource( *it ) )
             urlsToDownload.append( *it );
     }
--- trunk/KDE/kdenetwork/kget/core/plugin/transferfactory.cpp #1224583:1224584
@@ -74,3 +74,8 @@
     Q_UNUSED(url)
     return false;
 }
+
+QStringList TransferFactory::addsProtocols() const
+{
+    return QStringList();
+}
--- trunk/KDE/kdenetwork/kget/core/plugin/transferfactory.h #1224583:1224584
@@ -74,6 +74,13 @@
         virtual bool isSupported(const KUrl &url) const;
 
         /**
+         * Returns a list of protocols for which the TransferFactory adds support.
+         * An empty list simply means that the TransferFactory does not add support
+         * for the urls and might internally resort on other TransferFactories
+         */
+        virtual QStringList addsProtocols() const;
+
+        /**
          * Returns a Data Source. needed for Transfers Containers if any.
          * default implementation returns 0
          */
--- trunk/KDE/kdenetwork/kget/transfer-plugins/kio/transferKioFactory.cpp \
#1224583:1224584 @@ -45,6 +45,11 @@
 {
     QString prot = url.protocol();
     kDebug(5001) << "Protocol = " << prot;
-    return (prot == "http" || prot == "https" 
-         || prot == "ftp"  || prot == "sftp");
+    return addsProtocols().contains(prot);
 }
+
+QStringList TransferKioFactory::addsProtocols() const
+{
+    static const QStringList protocols = QStringList() << "http" << "https" << "ftp" \
<< "sftp"; +    return protocols;
+}
--- trunk/KDE/kdenetwork/kget/transfer-plugins/kio/transferKioFactory.h \
#1224583:1224584 @@ -31,6 +31,7 @@
         QString displayName(){return "HTTP(s) / FTP(s)";}
         
         bool isSupported(const KUrl &url) const;
+        QStringList addsProtocols() const;
 };
 
 #endif
--- trunk/KDE/kdenetwork/kget/transfer-plugins/mms/mmsTransferFactory.cpp \
#1224583:1224584 @@ -41,6 +41,11 @@
 
 bool MmsTransferFactory::isSupported(const KUrl &src) const
 {
-    return src.protocol() == "mms";
+    return addsProtocols().contains(src.protocol());
 }
 
+QStringList MmsTransferFactory::addsProtocols() const
+{
+    static const QStringList protocols = QStringList() << "mms";
+    return protocols;
+}
--- trunk/KDE/kdenetwork/kget/transfer-plugins/mms/mmsTransferFactory.h \
#1224583:1224584 @@ -41,6 +41,7 @@
         const QList<KAction *> actions(TransferHandler *handler = 0) {return \
QList<KAction *>();}  
         bool isSupported(const KUrl &src) const;
+        QStringList addsProtocols() const;
 };
 
 #endif
--- trunk/KDE/kdenetwork/kget/transfer-plugins/multisegmentkio/transfermultisegkiofactory.cpp \
#1224583:1224584 @@ -84,6 +84,11 @@
 {
     QString prot = url.protocol();
     kDebug(5001) << "Protocol = " << prot;
-    return (prot == "http" || prot == "https" ||
-            prot == "ftp"  || prot == "sftp");
+    return addsProtocols().contains(prot);
 }
+
+QStringList TransferMultiSegKioFactory::addsProtocols() const
+{
+    static const QStringList protocols = QStringList() << "http" << "https" << "ftp" \
<< "sftp"; +    return protocols;
+}
--- trunk/KDE/kdenetwork/kget/transfer-plugins/multisegmentkio/transfermultisegkiofactory.h \
#1224583:1224584 @@ -36,6 +36,7 @@
         const QList<KAction *> actions(TransferHandler *handler = 0);
         TransferDataSource * createTransferDataSource(const KUrl &srcUrl, const \
QDomElement &type, QObject *parent);  bool isSupported(const KUrl &url) const;
+        QStringList addsProtocols() const;
 };
 
 #endif
--- trunk/KDE/kdenetwork/kget/ui/newtransferdialog.cpp #1224583:1224584
@@ -15,6 +15,7 @@
 
 #include "core/kget.h"
 #include "mainwindow.h"
+#include "core/mostlocalurl.h"
 #include "core/transfertreemodel.h"
 #include "core/transfergrouphandler.h"
 #include "core/plugin/transferfactory.h"
@@ -330,7 +331,7 @@
 
     //check the source
     if (!m_multiple) {
-        source = KIO::NetAccess::mostLocalUrl(source, 0);
+        source = mostLocalUrl(source);
     }
     error = UrlChecker::checkSource(source);
     const bool sourceValid = (error == UrlChecker::NoError);
@@ -589,9 +590,10 @@
     newTransferDialogHandler->m_numJobs[newTransferDialogHandler->m_nextJobId] = \
urls.count();  foreach (const KUrl &url, urls) {
         //needed to avoid when protocols like the desktop protocol is used, see \
                bko:185283
-        KIO::StatJob *job = KIO::mostLocalUrl(url, KIO::HideProgressInfo);
+        KIO::Job *job = mostLocalUrlJob(url);
         job->setProperty("jobId", (newTransferDialogHandler->m_nextJobId));
         connect(job, SIGNAL(result(KJob*)), newTransferDialogHandler, \
SLOT(slotMostLocalUrlResult(KJob*))); +        job->start();
     }
 
     ++(newTransferDialogHandler->m_nextJobId);
@@ -599,7 +601,7 @@
 
 void NewTransferDialogHandler::slotMostLocalUrlResult(KJob *j)
 {
-    KIO::StatJob *job = static_cast<KIO::StatJob*>(j);
+    MostLocalUrlJob *job = static_cast<MostLocalUrlJob*>(j);//FIXME auch sonst in \
KGet mostLocalUrl ersetzen!!!  const int jobId = job->property("jobId").toInt();
 
     if (job->error()) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic