summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-02 12:27:09 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-02 12:27:09 (GMT)
commitf906bc46bf744fbb479a165b9b0f82f4897d708a (patch)
treeaa1385156cf2e384f235ae3eb477773309afc65f
parent79d81ab74493ec7c3eea4b7fd5b1cb9d40587abe (diff)
USe new class
-rw-r--r--src/ksieveui/managesievescriptsdialog.cpp31
-rw-r--r--src/ksieveui/managesievescriptsdialog.h5
2 files changed, 13 insertions, 23 deletions
diff --git a/src/ksieveui/managesievescriptsdialog.cpp b/src/ksieveui/managesievescriptsdialog.cpp
index b2536d9..9502de4 100644
--- a/src/ksieveui/managesievescriptsdialog.cpp
+++ b/src/ksieveui/managesievescriptsdialog.cpp
@@ -21,6 +21,7 @@
#include "editor/sievetextedit.h"
#include "editor/sieveeditor.h"
#include "widgets/sievetreewidgetitem.h"
+#include "managescriptsjob/checkscriptjob.h"
#include <KLocalizedString>
#include <kiconloader.h>
@@ -42,7 +43,6 @@
#include <KStandardGuiItem>
using namespace KSieveUi;
-//#define USE_CHECK_SIEVE_METHOD 0
class KSieveUi::ManageSieveScriptsDialogPrivate
{
@@ -212,13 +212,13 @@ void ManageSieveScriptsDialog::slotSieveEditorCheckSyntaxClicked()
return;
}
d->mSieveEditor->addNormalMessage(i18n("Uploading script to server for checking it, please wait..."));
-#ifdef USE_CHECK_SIEVE_METHOD
- KManageSieve::SieveJob *job = KManageSieve::SieveJob::check(d->mCurrentURL, script);
- connect(job, &KManageSieve::SieveJob::result, this, &ManageSieveScriptsDialog::slotPutCheckSyntaxResultDebug);
-#else
- KManageSieve::SieveJob *job = KManageSieve::SieveJob::put(d->mCurrentURL, script, d->mWasActive, d->mWasActive);
- connect(job, &KManageSieve::SieveJob::result, this, &ManageSieveScriptsDialog::slotPutCheckSyntaxResultDebug);
-#endif
+ KSieveUi::CheckScriptJob *checkScriptJob = new KSieveUi::CheckScriptJob(this);
+ connect(checkScriptJob, &CheckScriptJob::finished, this, &ManageSieveScriptsDialog::slotCheckScriptFinished);
+ checkScriptJob->setIsActive(d->mWasActive);
+ checkScriptJob->setOriginalScript(d->mSieveEditor->originalScript());
+ checkScriptJob->setCurrentScript(script);
+ checkScriptJob->setUrl(d->mCurrentURL);
+ checkScriptJob->start();
}
void ManageSieveScriptsDialog::slotSieveEditorOkClicked()
@@ -244,22 +244,13 @@ void ManageSieveScriptsDialog::slotSieveEditorCancelClicked()
}
}
-void ManageSieveScriptsDialog::slotPutCheckSyntaxResultDebug(KManageSieve::SieveJob *job, bool success)
+void ManageSieveScriptsDialog::slotCheckScriptFinished(const QString &errorMsg, bool success)
{
if (success) {
- d->mSieveEditor->addOkMessage(i18n("No errors found."));
+ d->mSieveEditor->addOkMessage(errorMsg);
} else {
- const QString errorMsg = job->errorString();
- if (errorMsg.isEmpty()) {
- d->mSieveEditor->addFailedMessage(i18n("An unknown error was encountered."));
- } else {
- d->mSieveEditor->addFailedMessage(errorMsg);
- }
+ d->mSieveEditor->addFailedMessage(errorMsg);
}
-#ifndef USE_CHECK_SIEVE_METHOD
- //Put original script after check otherwise we will put a script even if we don't click on ok
- KManageSieve::SieveJob *restoreJob = KManageSieve::SieveJob::put(d->mCurrentURL, d->mSieveEditor->originalScript(), d->mWasActive, d->mWasActive);
-#endif
d->mSieveEditor->resultDone();
}
diff --git a/src/ksieveui/managesievescriptsdialog.h b/src/ksieveui/managesievescriptsdialog.h
index 5fc1347..a77fd30 100644
--- a/src/ksieveui/managesievescriptsdialog.h
+++ b/src/ksieveui/managesievescriptsdialog.h
@@ -49,15 +49,14 @@ Q_SIGNALS:
private Q_SLOTS:
void slotGetResult(KManageSieve::SieveJob *, bool, const QString &, bool);
void slotPutResult(KManageSieve::SieveJob *job, bool);
- void slotPutCheckSyntaxResultDebug(KManageSieve::SieveJob *job, bool success);
void slotSieveEditorOkClicked();
void slotSieveEditorCancelClicked();
void slotSieveEditorCheckSyntaxClicked();
void slotUpdateButtons(QTreeWidgetItem *item);
void slotEditScript(const QUrl &u, const QStringList &capabilities);
- void slotNewScript(const QUrl &u, const QStringList &capabilities);
-
+ void slotNewScript(const QUrl &u, const QStringList &capabilities);
+ void slotCheckScriptFinished(const QString &errorMsg, bool success);
protected:
void hideEvent(QHideEvent *) Q_DECL_OVERRIDE;