[Marble-commits] KDE/kdeedu/marble/src/lib
Jens-Michael Hoffmann
jensmh at gmx.de
Mon Oct 12 02:22:18 CEST 2009
SVN commit 1034113 by jmhoffmann:
- Private methods moved to private class Private,
- unused method removed.
M +48 -64 HttpDownloadManager.cpp
M +0 -5 HttpDownloadManager.h
--- trunk/KDE/kdeedu/marble/src/lib/HttpDownloadManager.cpp #1034112:1034113
@@ -35,6 +35,10 @@
explicit Private( StoragePolicy *policy );
~Private();
+ HttpJob *createJob( const QUrl& sourceUrl, const QString& destFileName,
+ const QString &id );
+ DownloadQueueSet *findQueues( const QString& hostName );
+
bool m_downloadEnabled;
QTimer *m_requeueTimer;
/**
@@ -46,6 +50,7 @@
int m_jobQueueLimit;
StoragePolicy *m_storagePolicy;
NetworkPlugin *m_networkPlugin;
+
};
HttpDownloadManager::Private::Private( StoragePolicy *policy )
@@ -63,7 +68,48 @@
delete m_networkPlugin;
}
+HttpJob *HttpDownloadManager::Private::createJob( const QUrl& sourceUrl,
+ const QString& destFileName,
+ const QString &id )
+{
+ if ( !m_networkPlugin ) {
+ PluginManager pluginManager;
+ QList<NetworkPlugin *> networkPlugins = pluginManager.createNetworkPlugins();
+ if ( !networkPlugins.isEmpty() ) {
+ // FIXME: not just take the first plugin, but use some configuration setting
+ // take the first plugin and delete the rest
+ m_networkPlugin = networkPlugins.takeFirst();
+ qDeleteAll( networkPlugins );
+ }
+ else {
+ m_downloadEnabled = false;
+ return 0;
+ }
+ }
+ Q_ASSERT( m_networkPlugin );
+ return m_networkPlugin->createJob( sourceUrl, destFileName, id );
+}
+DownloadQueueSet *HttpDownloadManager::Private::findQueues( const QString& hostName )
+{
+ DownloadQueueSet * result = 0;
+ QMap<DownloadPolicyKey, DownloadQueueSet*>::iterator pos = m_queueSets.begin();
+ QMap<DownloadPolicyKey, DownloadQueueSet*>::iterator const end = m_queueSets.end();
+ for (; pos != end; ++pos ) {
+ if ( pos.key().matches( hostName )) {
+ result = pos.value();
+ break;
+ }
+ }
+ // FIXME:
+ if ( !result ) {
+ Q_ASSERT( !m_queueSets.isEmpty() );
+ result = m_queueSets.begin().value();
+ }
+ return result;
+}
+
+
HttpDownloadManager::HttpDownloadManager( StoragePolicy *policy )
: d( new Private( policy ))
{
@@ -77,7 +123,6 @@
addDownloadPolicy( defaultDownloadPolicy );
}
-
HttpDownloadManager::~HttpDownloadManager()
{
d->m_downloadEnabled = false;
@@ -124,9 +169,9 @@
if ( !d->m_downloadEnabled )
return;
- DownloadQueueSet * const queueSet = findQueues( sourceUrl.host() );
+ DownloadQueueSet * const queueSet = d->findQueues( sourceUrl.host() );
if ( queueSet->canAcceptJob( sourceUrl, destFileName )) {
- HttpJob * const job = createJob( sourceUrl, destFileName, id );
+ HttpJob * const job = d->createJob( sourceUrl, destFileName, id );
if ( job ) {
queueSet->addJob( job );
}
@@ -166,65 +211,4 @@
d->m_requeueTimer->start();
}
-HttpJob *HttpDownloadManager::createJob( const QUrl& sourceUrl, const QString& destFileName,
- const QString &id )
-{
- if ( !d->m_networkPlugin ) {
- PluginManager pluginManager;
- QList<NetworkPlugin *> networkPlugins = pluginManager.createNetworkPlugins();
- if ( !networkPlugins.isEmpty() ) {
- // FIXME: not just take the first plugin, but use some configuration setting
- // take the first plugin and delete the rest
- d->m_networkPlugin = networkPlugins.takeFirst();
- qDeleteAll( networkPlugins );
- d->m_networkPlugin->setParent( this );
- }
- else {
- d->m_downloadEnabled = false;
- return 0;
- }
- }
- Q_ASSERT( d->m_networkPlugin );
- return d->m_networkPlugin->createJob( sourceUrl, destFileName, id );
-}
-
-DownloadQueueSet const * HttpDownloadManager::findQueues( const QString& hostName ) const
-{
- DownloadQueueSet const * result = 0;
- QMap<DownloadPolicyKey, DownloadQueueSet*>::const_iterator pos = d->m_queueSets.constBegin();
- QMap<DownloadPolicyKey, DownloadQueueSet*>::const_iterator const end = d->m_queueSets.constEnd();
- for (; pos != end; ++pos ) {
- if ( pos.key().matches( hostName )) {
- result = pos.value();
- break;
- }
- }
- // FIXME:
- if ( !result ) {
- Q_ASSERT( !d->m_queueSets.isEmpty() );
- result = d->m_queueSets.constBegin().value();
- }
- return result;
-}
-
-DownloadQueueSet *HttpDownloadManager::findQueues( const QString& hostName )
-{
- DownloadQueueSet * result = 0;
- QMap<DownloadPolicyKey, DownloadQueueSet*>::iterator pos = d->m_queueSets.begin();
- QMap<DownloadPolicyKey, DownloadQueueSet*>::iterator const end = d->m_queueSets.end();
- for (; pos != end; ++pos ) {
- if ( pos.key().matches( hostName )) {
- result = pos.value();
- break;
- }
- }
- // FIXME:
- if ( !result ) {
- Q_ASSERT( !d->m_queueSets.isEmpty() );
- result = d->m_queueSets.begin().value();
- }
- return result;
-}
-
-
#include "HttpDownloadManager.moc"
--- trunk/KDE/kdeedu/marble/src/lib/HttpDownloadManager.h #1034112:1034113
@@ -116,11 +116,6 @@
private:
Q_DISABLE_COPY( HttpDownloadManager )
- HttpJob *createJob( const QUrl& sourceUrl, const QString& destFileName,
- const QString &id );
- DownloadQueueSet *findQueues( const QString& hostName );
- DownloadQueueSet const *findQueues( const QString& hostName ) const;
-
class Private;
Private * const d;
};
More information about the Marble-commits
mailing list