[Kget] KDE/kdenetwork/kget

Manolo Valdes nolis71cu at gmail.com
Fri Jan 11 06:44:32 CET 2008


SVN commit 759698 by mvaldes:

Remove the speedlimiter implementation based on resume,suspend calls. this will be implemented on slavebase.
Adds a new interface for containers transfers like metalink. named TransferDataSource. 
the idea is to suply data to the container plugin through this interface .
so Multisegkio and bittorrent plugings should implements this interface.

this is the initial commint for this new approach, more will come.
while implementing it on multisegkio.
the interface may change until development, so ideas are wellcome

CCMAIL: kget at kde.org



 M  +1 -2      CMakeLists.txt  
 M  +1 -1      conf/preferencesdialog.cpp  
 M  +17 -0     core/kget.cpp  
 M  +9 -0      core/kget.h  
 M  +14 -0     core/plugin/transferfactory.h  
 D             core/speedlimiter.cpp  
 D             core/speedlimiter.h  
 M  +3 -0      transfer-plugins/bittorrent/bttransferfactory.h  
 M  +1 -0      transfer-plugins/kio/transferKioFactory.h  
 M  +1 -0      transfer-plugins/metalink/metalinkfactory.h  
 M  +1 -0      transfer-plugins/multisegmentkio/CMakeLists.txt  
 M  +15 -0     transfer-plugins/multisegmentkio/transfermultisegkiofactory.cpp  
 M  +1 -0      transfer-plugins/multisegmentkio/transfermultisegkiofactory.h  


--- trunk/KDE/kdenetwork/kget/CMakeLists.txt #759697:759698
@@ -28,7 +28,6 @@
    core/jobqueue.cpp
    core/kget.cpp
    core/scheduler.cpp
-   core/speedlimiter.cpp
    core/transfertreemodel.cpp
    core/transfertreeselectionmodel.cpp
    core/transfer.cpp
@@ -37,7 +36,7 @@
    core/transferhandler.cpp
    core/plugin/plugin.cpp
    core/plugin/transferfactory.cpp
-   core/transfercontainer.cpp
+   core/transferdatasource.cpp
    core/kuiserverjobs.cpp
    core/kgetglobaljob.cpp
 )
--- trunk/KDE/kdenetwork/kget/conf/preferencesdialog.cpp #759697:759698
@@ -39,7 +39,7 @@
     dlgAdv.setupUi(advanced);
 
     // TODO: remove the following lines as soon as these features are ready
-    dlgNet.kcfg_SpeedLimit->setVisible(false);
+//     dlgNet.kcfg_SpeedLimit->setVisible(false);
     dlgNet.groupBoxCompleted->setVisible(false);
     dlgNet.lbl_maxnum_2->setVisible(false);
     dlgNet.kcfg_MaxConnectionsServer->setVisible(false);
--- trunk/KDE/kdenetwork/kget/core/kget.cpp #759697:759698
@@ -14,6 +14,7 @@
 
 #include "mainwindow.h"
 #include "core/transfer.h"
+#include "core/transferdatasource.h"
 #include "core/transfergroup.h"
 #include "core/transfergrouphandler.h"
 #include "core/transfertreemodel.h"
@@ -622,6 +623,22 @@
     kDebug(5001) << "Warning! No plugin found to handle the given url";
 }
 
+TransferDataSource * KGet::createTransferDataSource(const KUrl &src)
+{
+    kDebug(5001);
+    QList<TransferFactory *>::iterator it = m_transferFactories.begin();
+    QList<TransferFactory *>::iterator itEnd = m_transferFactories.end();
+
+    TransferDataSource *dataSource;
+    for( ; it!=itEnd ; ++it)
+    {
+        dataSource = (*it)->createTransferDataSource(src);
+        if(dataSource)
+            return dataSource;
+    }
+    return 0;
+}
+
 void KGet::postAddedTransferGroupEvent(TransferGroup * group, ModelObserver * observer)
 {
     kDebug(5001);
--- trunk/KDE/kdenetwork/kget/core/kget.h #759697:759698
@@ -30,6 +30,7 @@
 class QAbstractItemView;
 
 class Transfer;
+class TransferDataSource;
 class TransferGroup;
 class TransferHandler;
 class TransferGroupHandler;
@@ -260,6 +261,14 @@
         static void createTransfer(const KUrl &src, const KUrl &dest, const QString& groupName = QString(), bool start = false, const QDomElement * e = 0);
 
         /**
+         * Scans for all the available plugins and creates the proper
+         * transfer DataSource object for transfers Containers
+         *
+         * @param src Source Url
+         */
+        static TransferDataSource * createTransferDataSource(const KUrl &src);
+
+        /**
          * Posts an addedTransferGroupEvent to all the observers
          *
          * @param group the group that has been added to the group
--- trunk/KDE/kdenetwork/kget/core/plugin/transferfactory.h #759697:759698
@@ -35,6 +35,7 @@
 #include "core/kget.h"
 #include "core/transfer.h"
 #include "core/transferhandler.h"
+#include "core/transferdatasource.h"
 #include "kget_export.h"
 
 class TransferGroup;
@@ -62,8 +63,15 @@
 
         virtual QWidget * createDetailsWidget( TransferHandler * transfer ) = 0;
 
+/**
+ * Returns the Transfer Settings Widget if any.
+ * otherwise returns 0
+ */
         virtual QWidget * createSettingsWidget(KDialog * parent) = 0;
 
+/**
+ * Returns the Transfer Name
+ */
         virtual QString displayName() = 0;
 
         virtual const QList<KAction *> actions(TransferHandler *handler = 0) = 0;
@@ -71,6 +79,12 @@
         virtual void settingsChanged() {}
 
         KMenu * createPopupMenu(QList<TransferHandler *> transfers);
+
+/**
+ * Returns a Data Source. needed for Transfers Containers if any.
+ * otherwise returns 0
+ */
+        virtual TransferDataSource * createTransferDataSource(const KUrl &srcUrl) = 0;
 };
 
 #endif
--- trunk/KDE/kdenetwork/kget/transfer-plugins/bittorrent/bttransferfactory.h #759697:759698
@@ -32,6 +32,9 @@
         QWidget * createSettingsWidget(KDialog * parent) { return new BTSettingsWidget(parent);}
 
         QString displayName(){return "Bittorrent";}
+
+        TransferDataSource * createTransferDataSource(const KUrl &srcUrl) {return 0;}
+
 };
 
 #endif
--- trunk/KDE/kdenetwork/kget/transfer-plugins/kio/transferKioFactory.h #759697:759698
@@ -38,6 +38,7 @@
         QString displayName(){return "HTTP(s) / FTP(s)";}
 
         const QList<KAction *> actions(TransferHandler *handler = 0);
+        TransferDataSource * createTransferDataSource(const KUrl &srcUrl) {return 0;}
 };
 
 #endif
--- trunk/KDE/kdenetwork/kget/transfer-plugins/metalink/metalinkfactory.h #759697:759698
@@ -38,6 +38,7 @@
         QString displayName(){return "MetaLink";}
 
         const QList<KAction *> actions(TransferHandler *handler = 0);
+        TransferDataSource * createTransferDataSource(const KUrl &srcUrl) {return 0;}
 };
 
 #endif
--- trunk/KDE/kdenetwork/kget/transfer-plugins/multisegmentkio/CMakeLists.txt #759697:759698
@@ -6,6 +6,7 @@
   dlgmultisegkio.cpp
   segmentfactory.cpp
   multisegkio.cpp
+  multisegkiodatasource.cpp
   mirrors.cpp
   transfermultisegkio.cpp
   transfermultisegkiofactory.cpp
--- trunk/KDE/kdenetwork/kget/transfer-plugins/multisegmentkio/transfermultisegkiofactory.cpp #759697:759698
@@ -16,6 +16,7 @@
 #include "multisegkiosettings.h"
 #include "dlgmultisegkio.h"
 #include "transfermultisegkio.h"
+#include "multisegkiodatasource.h"
 
 #include <kdebug.h>
 
@@ -70,3 +71,17 @@
     Q_UNUSED(handler);
     return QList<KAction *>();
 }
+
+ TransferDataSource * TransferMultiSegKioFactory::createTransferDataSource(const KUrl &srcUrl)
+{
+   kDebug(5001);
+
+    QString prot = srcUrl.protocol();
+    kDebug(5001) << "Protocol = " << prot;
+    if( prot == "http" || prot == "https" ||
+        prot == "ftp"  || prot == "sftp"
+      )
+    {
+        return new MultiSegKioDataSource();
+    }
+}
--- trunk/KDE/kdenetwork/kget/transfer-plugins/multisegmentkio/transfermultisegkiofactory.h #759697:759698
@@ -38,6 +38,7 @@
         QString displayName(){return "Multithreaded HTTP(s) / FTP(s)";}
 
         const QList<KAction *> actions(TransferHandler *handler = 0);
+        TransferDataSource * createTransferDataSource(const KUrl &srcUrl);
 };
 
 #endif


More information about the Kget mailing list