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