Commit f63257ec authored by Laurent Montel's avatar Laurent Montel 😁

USe new class to check script

parent 48b64ee6
......@@ -45,7 +45,7 @@ set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}")
set(KDEPIM_LIB_SOVERSION "5")
set(MESSAGELIB_LIB_VERSION_LIB "5.3.47")
set(LIBKSIEVE_LIB_VERSION_LIB "5.3.44")
set(LIBKSIEVE_LIB_VERSION_LIB "5.3.45")
set(PIMCOMMON_LIB_VERSION_LIB "5.3.41")
set(QT_REQUIRED_VERSION "5.6.0")
......
......@@ -19,6 +19,7 @@
#include "sieveeditorpagewidget.h"
#include "ksieveui/sieveeditorwidget.h"
#include "ksieveui/checkscriptjob.h"
#include "sieveeditorglobalconfig.h"
#include <kmanagesieve/sievejob.h>
......@@ -28,7 +29,7 @@
#include "sieveeditor_debug.h"
#include <QVBoxLayout>
//#define USE_CHECK_SIEVE_METHOD 1
SieveEditorPageWidget::SieveEditorPageWidget(QWidget *parent)
: QWidget(parent),
mWasActive(false),
......@@ -60,31 +61,22 @@ void SieveEditorPageWidget::slotCheckSyntaxClicked()
}
mSieveEditorWidget->addNormalMessage(i18n("Uploading script to server for checking it, please wait..."));
#ifdef USE_CHECK_SIEVE_METHOD
KManageSieve::SieveJob *job = KManageSieve::SieveJob::check(mCurrentURL, script);
connect(job, &KManageSieve::SieveJob::result, this, &SieveEditorPageWidget::slotPutResultDebug);
#else
KManageSieve::SieveJob *job = KManageSieve::SieveJob::put(mCurrentURL, script, mWasActive, mWasActive);
connect(job, &KManageSieve::SieveJob::result, this, &SieveEditorPageWidget::slotPutResultDebug);
#endif
KSieveUi::CheckScriptJob *checkScriptJob = new KSieveUi::CheckScriptJob(this);
connect(checkScriptJob, &KSieveUi::CheckScriptJob::finished, this, &SieveEditorPageWidget::slotCheckScriptJobFinished);
checkScriptJob->setUrl(mCurrentURL);
checkScriptJob->setIsActive(mWasActive);
checkScriptJob->setCurrentScript(script);
checkScriptJob->setOriginalScript(mSieveEditorWidget->originalScript());
checkScriptJob->start();
}
void SieveEditorPageWidget::slotPutResultDebug(KManageSieve::SieveJob *job, bool success)
void SieveEditorPageWidget::slotCheckScriptJobFinished(const QString &errorMsg, bool success)
{
if (success) {
mSieveEditorWidget->addOkMessage(i18n("No errors found."));
mSieveEditorWidget->addOkMessage(errorMsg);
} else {
const QString errorMsg = job->errorString();
if (errorMsg.isEmpty()) {
mSieveEditorWidget->addFailedMessage(i18n("An unknown error was encountered."));
} else {
mSieveEditorWidget->addFailedMessage(errorMsg);
}
mSieveEditorWidget->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(mCurrentURL, mSieveEditorWidget->originalScript(), mWasActive, mWasActive);
#endif
mSieveEditorWidget->resultDone();
}
......
......@@ -98,9 +98,9 @@ Q_SIGNALS:
private Q_SLOTS:
void slotGetResult(KManageSieve::SieveJob *, bool success, const QString &script, bool isActive);
void slotCheckSyntaxClicked();
void slotPutResultDebug(KManageSieve::SieveJob *, bool success);
void slotPutResult(KManageSieve::SieveJob *, bool success);
void slotValueChanged(bool b);
void slotValueChanged(bool b);
void slotCheckScriptJobFinished(const QString &errorMsg, bool success);
private:
void setModified(bool b);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment