Align MkColJob finish signal with the other jobs

This commit is contained in:
Hannah von Reth 2021-02-17 14:30:26 +01:00 committed by Matthieu Gallien
parent c4f4fb48a4
commit d16befd1fd
9 changed files with 38 additions and 31 deletions

View file

@ -201,21 +201,19 @@ void FolderWizardRemotePath::slotCreateRemoteFolder(const QString &folder)
auto *job = new MkColJob(_account, fullPath, this);
/* check the owncloud configuration file and query the ownCloud */
connect(job, static_cast<void (MkColJob::*)(QNetworkReply::NetworkError)>(&MkColJob::finished),
connect(job, &MkColJob::finishedWithoutError,
this, &FolderWizardRemotePath::slotCreateRemoteFolderFinished);
connect(job, &AbstractNetworkJob::networkError, this, &FolderWizardRemotePath::slotHandleMkdirNetworkError);
job->start();
}
void FolderWizardRemotePath::slotCreateRemoteFolderFinished(QNetworkReply::NetworkError error)
void FolderWizardRemotePath::slotCreateRemoteFolderFinished()
{
if (error == QNetworkReply::NoError) {
qCDebug(lcWizard) << "webdav mkdir request finished";
showWarn(tr("Folder was successfully created on %1.").arg(Theme::instance()->appNameGUI()));
slotRefreshFolders();
_ui.folderEntry->setText(static_cast<MkColJob *>(sender())->path());
slotLsColFolderEntry();
}
}
void FolderWizardRemotePath::slotHandleMkdirNetworkError(QNetworkReply *reply)

View file

@ -92,7 +92,7 @@ protected slots:
void showWarn(const QString & = QString()) const;
void slotAddRemoteFolder();
void slotCreateRemoteFolder(const QString &);
void slotCreateRemoteFolderFinished(QNetworkReply::NetworkError error);
void slotCreateRemoteFolderFinished();
void slotHandleMkdirNetworkError(QNetworkReply *);
void slotHandleLsColNetworkError(QNetworkReply *);
void slotUpdateDirectories(const QStringList &);

View file

@ -536,26 +536,28 @@ void OwncloudSetupWizard::createRemoteFolder()
_ocWizard->appendToConfigurationLog(tr("creating folder on Nextcloud: %1").arg(_remoteFolder));
auto *job = new MkColJob(_ocWizard->account(), _remoteFolder, this);
connect(job, SIGNAL(finished(QNetworkReply::NetworkError)), SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
connect(job, &MkColJob::finishedWithError, this, &OwncloudSetupWizard::slotCreateRemoteFolderFinished);
connect(job, &MkColJob::finishedWithoutError, this, [this] {
_ocWizard->appendToConfigurationLog(tr("Remote folder %1 created successfully.").arg(_remoteFolder));
finalizeSetup(true);
});
job->start();
}
void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply::NetworkError error)
void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply *reply)
{
auto error = reply->error();
qCDebug(lcWizard) << "** webdav mkdir request finished " << error;
// disconnect(ownCloudInfo::instance(), SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),
// this, SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
bool success = true;
if (error == QNetworkReply::NoError) {
_ocWizard->appendToConfigurationLog(tr("Remote folder %1 created successfully.").arg(_remoteFolder));
} else if (error == 202) {
if (error == 202) {
_ocWizard->appendToConfigurationLog(tr("The remote folder %1 already exists. Connecting it for syncing.").arg(_remoteFolder));
} else if (error > 202 && error < 300) {
_ocWizard->displayError(tr("The folder creation resulted in HTTP error code %1").arg((int)error), false);
_ocWizard->displayError(tr("The folder creation resulted in HTTP error code %1").arg(static_cast<int>(error)), false);
_ocWizard->appendToConfigurationLog(tr("The folder creation resulted in HTTP error code %1").arg((int)error));
_ocWizard->appendToConfigurationLog(tr("The folder creation resulted in HTTP error code %1").arg(static_cast<int>(error)));
} else if (error == QNetworkReply::OperationCanceledError) {
_ocWizard->displayError(tr("The remote folder creation failed because the provided credentials "
"are wrong!"

View file

@ -65,7 +65,7 @@ private slots:
void slotCreateLocalAndRemoteFolders(const QString &, const QString &);
void slotRemoteFolderExists(QNetworkReply *);
void slotCreateRemoteFolderFinished(QNetworkReply::NetworkError);
void slotCreateRemoteFolderFinished(QNetworkReply *reply);
void slotAssistantFinished(int);
void slotSkipFolderConfiguration();

View file

@ -182,7 +182,11 @@ bool MkColJob::finished()
qCInfo(lcMkColJob) << "MKCOL of" << reply()->request().url() << "FINISHED WITH STATUS"
<< replyStatusString();
emit finished(reply()->error());
if (reply()->error() != QNetworkReply::NoError) {
Q_EMIT finishedWithError(reply());
} else {
Q_EMIT finishedWithoutError();
}
return true;
}

View file

@ -273,9 +273,10 @@ public:
void start() override;
signals:
void finished(QNetworkReply::NetworkError);
void finishedWithError(QNetworkReply *reply);
void finishedWithoutError();
private slots:
private:
bool finished() override;
};

View file

@ -61,8 +61,7 @@ void PropagateRemoteMkdir::start()
_job = new DeleteJob(propagator()->account(),
propagator()->fullRemotePath(_item->_file),
this);
connect(static_cast<DeleteJob*>(_job.data()), &DeleteJob::finishedSignal,
this, &PropagateRemoteMkdir::slotMkdir);
connect(qobject_cast<DeleteJob *>(_job), &DeleteJob::finishedSignal, this, &PropagateRemoteMkdir::slotMkdir);
_job->start();
}
@ -76,7 +75,8 @@ void PropagateRemoteMkdir::slotStartMkcolJob()
_job = new MkColJob(propagator()->account(),
propagator()->fullRemotePath(_item->_file),
this);
connect(_job, SIGNAL(finished(QNetworkReply::NetworkError)), this, SLOT(slotMkcolJobFinished()));
connect(qobject_cast<MkColJob *>(_job), &MkColJob::finishedWithError, this, &PropagateRemoteMkdir::slotMkcolJobFinished);
connect(qobject_cast<MkColJob *>(_job), &MkColJob::finishedWithoutError, this, &PropagateRemoteMkdir::slotMkcolJobFinished);
_job->start();
}
@ -95,8 +95,8 @@ void PropagateRemoteMkdir::slotStartEncryptedMkcolJob(const QString &path, const
propagator()->fullRemotePath(filename),
{{"e2e-token", _uploadEncryptedHelper->folderToken() }},
this);
connect(job, qOverload<QNetworkReply::NetworkError>(&MkColJob::finished),
this, &PropagateRemoteMkdir::slotMkcolJobFinished);
connect(job, &MkColJob::finishedWithError, this, &PropagateRemoteMkdir::slotMkcolJobFinished);
connect(job, &MkColJob::finishedWithoutError, this, &PropagateRemoteMkdir::slotMkcolJobFinished);
_job = job;
_job->start();
}

View file

@ -418,7 +418,7 @@ private slots:
void slotPropfindFinishedWithError();
void slotPropfindIterate(const QString &name, const QMap<QString, QString> &properties);
void slotDeleteJobFinished();
void slotMkColFinished(QNetworkReply::NetworkError);
void slotMkColFinished();
void slotPutFinished();
void slotMoveJobFinished();
void slotUploadProgress(qint64, qint64);

View file

@ -249,13 +249,15 @@ void PropagateUploadFileNG::startNewUpload()
headers["OC-Total-Length"] = QByteArray::number(_fileToUpload._size);
auto job = new MkColJob(propagator()->account(), chunkUrl(), headers, this);
connect(job, SIGNAL(finished(QNetworkReply::NetworkError)),
this, SLOT(slotMkColFinished(QNetworkReply::NetworkError)));
connect(job, &MkColJob::finishedWithError,
this, &PropagateUploadFileNG::slotMkColFinished);
connect(job, &MkColJob::finishedWithoutError,
this, &PropagateUploadFileNG::slotMkColFinished);
connect(job, &QObject::destroyed, this, &PropagateUploadFileCommon::slotJobDestroyed);
job->start();
}
void PropagateUploadFileNG::slotMkColFinished(QNetworkReply::NetworkError)
void PropagateUploadFileNG::slotMkColFinished()
{
propagator()->_activeJobList.removeOne(this);
auto job = qobject_cast<MkColJob *>(sender());