[Marble-commits] KDE/kdeedu/marble/src/lib

Jens-Michael Hoffmann jensmh at gmx.de
Sat Jan 16 13:47:08 CET 2010


SVN commit 1075641 by jmhoffmann:

Add default download policy for bulk downloads.

 M  +21 -6     HttpDownloadManager.cpp  
 M  +1 -0      HttpDownloadManager.h  


--- trunk/KDE/kdeedu/marble/src/lib/HttpDownloadManager.cpp #1075640:1075641
@@ -47,7 +47,7 @@
      * - a queue containing currently being downloaded
      * - a queue for retries of failed downloads */
     QList<QPair<DownloadPolicyKey, DownloadQueueSet *> > m_queueSets;
-    DownloadQueueSet m_defaultQueues;
+    QMap<DownloadUsage, DownloadQueueSet *> m_defaultQueueSets;
     int m_jobQueueLimit;
     StoragePolicy *m_storagePolicy;
     NetworkPlugin *m_networkPlugin;
@@ -62,13 +62,20 @@
       m_networkPlugin( 0 )
 {
     // setup default download policy and associated queue set
-    DownloadPolicy defaultDownloadPolicy;
-    defaultDownloadPolicy.setMaximumConnections( 20 );
-    m_defaultQueues.setDownloadPolicy( defaultDownloadPolicy );
+    DownloadPolicy defaultBrowsePolicy;
+    defaultBrowsePolicy.setMaximumConnections( 20 );
+    m_defaultQueueSets[ DownloadBrowse ] = new DownloadQueueSet( defaultBrowsePolicy );
+    DownloadPolicy defaultBulkDownloadPolicy;
+    defaultBulkDownloadPolicy.setMaximumConnections( 2 );
+    m_defaultQueueSets[ DownloadBulk ] = new DownloadQueueSet( defaultBulkDownloadPolicy );
 }
 
 HttpDownloadManager::Private::~Private()
 {
+    QMap<DownloadUsage, DownloadQueueSet *>::iterator pos = m_defaultQueueSets.begin();
+    QMap<DownloadUsage, DownloadQueueSet *>::iterator const end = m_defaultQueueSets.end();
+    for (; pos != end; ++pos )
+        delete pos.value();
     delete m_storagePolicy;
     delete m_networkPlugin;
 }
@@ -110,7 +117,7 @@
     if ( !result ) {
         mDebug() << "No download policy found for" << hostName << usage
                  << ", using default policy.";
-        result = &m_defaultQueues;
+        result = m_defaultQueueSets[ usage ];
     }
     return result;
 }
@@ -122,7 +129,7 @@
     d->m_requeueTimer = new QTimer( this );
     d->m_requeueTimer->setInterval( requeueTime );
     connect( d->m_requeueTimer, SIGNAL( timeout() ), this, SLOT( requeue() ) );
-    connectQueueSet( &d->m_defaultQueues );
+    connectDefaultQueueSets();
 }
 
 HttpDownloadManager::~HttpDownloadManager()
@@ -210,6 +217,14 @@
         d->m_requeueTimer->start();
 }
 
+void HttpDownloadManager::connectDefaultQueueSets()
+{
+    QMap<DownloadUsage, DownloadQueueSet *>::iterator pos = d->m_defaultQueueSets.begin();
+    QMap<DownloadUsage, DownloadQueueSet *>::iterator const end = d->m_defaultQueueSets.end();
+    for (; pos != end; ++pos )
+        connectQueueSet( pos.value() );
+}
+
 void HttpDownloadManager::connectQueueSet( DownloadQueueSet * queueSet )
 {
     connect( queueSet, SIGNAL( jobFinished( QByteArray, QString, QString )),
--- trunk/KDE/kdeedu/marble/src/lib/HttpDownloadManager.h #1075640:1075641
@@ -119,6 +119,7 @@
  private:
     Q_DISABLE_COPY( HttpDownloadManager )
 
+    void connectDefaultQueueSets();
     void connectQueueSet( DownloadQueueSet * );
     bool hasDownloadPolicy( const DownloadPolicy& policy ) const;
     class Private;


More information about the Marble-commits mailing list