[Kget] KDE/kdenetwork/kget

Manolo Valdes nolis71cu at gmail.com
Fri May 11 20:06:55 CEST 2007


SVN commit 663589 by mvaldes:

the metalink transfer has been disable, due the transfer interface dont fill the needs of metalink.so we move the metalink parser to the core stuf and handle the metalink via a global funtion in KGet class. now it works property. but some of it goods are not avialable yet like the checksum test.

please fill free to test it. feedback are very wellcome :)

CCMAIL: kget at kde.org



 M  +1 -0      CMakeLists.txt  
 M  +40 -2     core/kget.cpp  
 A             core/metalinker.cpp   [License: GPL]
 A             core/metalinker.h   [License: GPL]
 M  +0 -1      core/transfercontainer.h  
 M  +1 -1      transfer-plugins/CMakeLists.txt  
 D             transfer-plugins/metalink/metalinker.cpp  
 D             transfer-plugins/metalink/metalinker.h  


--- trunk/KDE/kdenetwork/kget/CMakeLists.txt #663588:663589
@@ -30,6 +30,7 @@
    core/plugin/plugin.cpp
    core/plugin/transferfactory.cpp
    core/transfercontainer.cpp
+   core/metalinker.cpp
 )
 
 kde4_add_kcfg_files(kgetcore_SRCS conf/settings.kcfgc)
--- trunk/KDE/kdenetwork/kget/core/kget.cpp #663588:663589
@@ -18,6 +18,7 @@
 #include "core/plugin/plugin.h"
 #include "core/plugin/transferfactory.h"
 #include "core/observer.h"
+#include "core/metalinker.h"
 #include "settings.h"
 
 #include <kio/netaccess.h>
@@ -121,9 +122,46 @@
         return;
 
     QString destDir = destInputDialog();
-    KUrl destUrl(destDir);
 
-    createTransfer(srcUrl, destUrl, QString("MetaLinks"));
+    Metalinker mlink;
+    QList<MlinkFileData> mldata = mlink.parseMetalinkFile( srcUrl );
+    if(mldata.isEmpty())
+        return;
+
+    addGroup(srcUrl.fileName());
+
+    QDomDocument doc;
+    QDomElement e;
+    QDomElement url;
+    QList<MlinkFileData>::iterator it = mldata.begin();
+    QList<MlinkFileData>::iterator itEnd = mldata.end();
+
+    for ( ; it!=itEnd ; ++it )
+    {
+        KUrl destUrl(destDir);
+        destUrl.adjustPath( KUrl::AddTrailingSlash );
+        destUrl.setFileName( (*it).fileName );
+        e = doc.createElement("Transfer");
+        e.setAttribute("Dest", destUrl.url());
+
+        if( (*it).urls.size() > 1 )
+        {
+            kDebug(5001) << "urls:  " << (*it).urls.size() << endl;
+            KUrl::List::iterator KUrlit = (*it).urls.begin();
+            KUrl::List::iterator KUrlitEnd = (*it).urls.end();
+            for ( ; KUrlit!=KUrlitEnd ; ++KUrlit )
+            {
+                url = doc.createElement("Urls");
+                e.appendChild(url);
+                url.setAttribute("Url", (*KUrlit).url()); 
+            }
+        }
+        KUrl src = (*it).urls.takeFirst();
+        e.setAttribute("Source", src.url());
+        createTransfer(src, destUrl, srcUrl.fileName(), &e);
+        url.clear();
+        e.clear();
+    }
 }
 
 void KGet::addTransfer( KUrl srcUrl, QString destDir, // krazy:exclude=passbyvalue
--- trunk/KDE/kdenetwork/kget/core/transfercontainer.h #663588:663589
@@ -38,7 +38,6 @@
 
     TransferContainer();
     ~TransferContainer();
-
 };
 
 Q_DECLARE_OPERATORS_FOR_FLAGS(TransferContainer::TransferFlags)
--- trunk/KDE/kdenetwork/kget/transfer-plugins/CMakeLists.txt #663588:663589
@@ -1,4 +1,4 @@
 add_subdirectory(kio)
 add_subdirectory(multisegmentkio)
-add_subdirectory(metalink)
+#add_subdirectory(metalink)
 #add_subdirectory(bittorrent)


More information about the Kget mailing list