diff --git a/src/mirall/folderwizard.cpp b/src/mirall/folderwizard.cpp index cee523a14..feef2d5ae 100644 --- a/src/mirall/folderwizard.cpp +++ b/src/mirall/folderwizard.cpp @@ -191,9 +191,9 @@ void FolderWizardTargetPage::slotFolderTextChanged( const QString& t) void FolderWizardTargetPage::slotTimerFires() { - const QString folder = _ui.OCFolderLineEdit->text(); - qDebug() << "Querying folder " << folder; - _ownCloudDirCheck->getWebDAVPath( folder ); + const QString folder = _ui.OCFolderLineEdit->text(); + qDebug() << "Querying folder " << folder; + _ownCloudDirCheck->getWebDAVPath( folder ); } void FolderWizardTargetPage::slotDirCheckReply(const QString &url, bool exists ) diff --git a/src/mirall/owncloudinfo.cpp b/src/mirall/owncloudinfo.cpp index 47fafa079..c94cdfc32 100644 --- a/src/mirall/owncloudinfo.cpp +++ b/src/mirall/owncloudinfo.cpp @@ -25,12 +25,22 @@ namespace Mirall { ownCloudInfo::ownCloudInfo( const QString& connectionName, QObject *parent ) : - QObject(parent) + QObject(parent), + _reply(0) { if( connectionName.isEmpty() ) _connection = QString::fromLocal8Bit( "ownCloud"); else _connection = connectionName; + + _manager = new QNetworkAccessManager; + connect(_manager, SIGNAL(finished(QNetworkReply*)), + this, SLOT(slotReplyFinished(QNetworkReply*))); +} + +ownCloudInfo::~ownCloudInfo() +{ + delete _manager; } bool ownCloudInfo::isConfigured() @@ -51,10 +61,15 @@ void ownCloudInfo::getWebDAVPath( const QString& path ) void ownCloudInfo::getRequest( const QString& path, bool webdav ) { - QNetworkAccessManager *manager = new QNetworkAccessManager(this); - connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(slotReplyFinished(QNetworkReply*))); - + qDebug() << "Get Request to " << path; + if( _reply ) { + if(_reply->isRunning() ) { + qDebug() << "info request already running, not starting a second one."; + return; + } else { + delete _reply; + } + } // this is not a status call. if( !webdav && path == "status.php") { _versionInfoCall = true; @@ -70,8 +85,7 @@ void ownCloudInfo::getRequest( const QString& path, bool webdav ) request.setUrl( QUrl( url ) ); request.setRawHeader( "User-Agent", QString("mirall-%1").arg(MIRALL_STRINGIFY(MIRALL_VERSION)).toAscii()); request.setRawHeader( "Authorization", cfgFile.basicAuthHeader() ); - - _reply = manager->get( request ); + _reply = _manager->get( request ); _readBuffer.clear(); connect( _reply, SIGNAL( error(QNetworkReply::NetworkError )), diff --git a/src/mirall/owncloudinfo.h b/src/mirall/owncloudinfo.h index ba2ea27d3..ac0086142 100644 --- a/src/mirall/owncloudinfo.h +++ b/src/mirall/owncloudinfo.h @@ -18,6 +18,8 @@ #include #include +class QNetworkAccessManager; + namespace Mirall { @@ -26,6 +28,7 @@ class ownCloudInfo : public QObject Q_OBJECT public: explicit ownCloudInfo( const QString& = QString(), QObject *parent = 0); + ~ownCloudInfo(); bool isConfigured(); @@ -58,8 +61,9 @@ protected slots: void slotReadyRead(); void slotError( QNetworkReply::NetworkError ); void slotAuthentication( QNetworkReply*, QAuthenticator *); -private: +private: + QNetworkAccessManager *_manager; QNetworkReply *_reply; QByteArray _readBuffer; QString _connection;