diff --git a/CMakeLists.txt b/CMakeLists.txt index 00113e75c5..efd903bb5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,283 +1,283 @@ project(kdepim) cmake_minimum_required(VERSION 3.1) option(KDEPIM_SUPERBUILD "Build standalone apps (experimental not used for distro)" FALSE) if (KDEPIM_SUPERBUILD) # Remove it when splitted # This CMakeLists.txt is a "superbuild" for the frameworks. # This means it can be used to build them all standalone one-by-one. # This is useful to compile all them with one command. # use mkdir build && cd build && cmake -DKDEPIM_SUPERBUILD=TRUE ../ && make -j8 sb_all include(SuperBuild.cmake) sb_add_project(kmail) sb_add_project(grantleeeditor) sb_add_project(korganizer) sb_add_project(sieveeditor) sb_add_project(storageservicemanager) sb_add_project(akregator) sb_add_project(importwizard) sb_add_project(kaddressbook) sb_add_project(mboximporter) sb_add_project(knotes) sb_add_project(ktnef) sb_add_project(pimsettingexporter) sb_add_project(kalarm) sb_add_project(blogilo) sb_add_project(kontact) sb_add_project(akonadiconsole) sb_add_project(console) sb_add_project(accountwizard) # doc must be a subdir of kdepim or packagers will kill us # Need to move in subdirectory add_subdirectory(doc) sb_end() else() if (POLICY CMP0063) cmake_policy(SET CMP0063 NEW) endif() set(LIBRARY_NAMELINK LIBRARY NAMELINK_SKIP) # we need some parts of the ECM CMake helpers set(KF5_VERSION "5.23.0") find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${kdepim_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH}) include(ECMOptionalAddSubdirectory) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddTests) include(ECMMarkNonGuiExecutable) include(GenerateExportHeader) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(FeatureSummary) include(CheckFunctionExists) include(ECMGeneratePriFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) # KDEPIM_VERSION # Version scheme: "x.y.z build". # # x is the version number. # y is the major release number. # z is the minor release number. # # "x.y.z" follow the kdelibs version kdepim is released with. # # If "z" is 0, the version is "x.y" # # KDEPIM_DEV_VERSION is empty for final versions. # For development versions "build" is something like "pre", "alpha1", "alpha2", "beta1", "beta2", "rc1", "rc2". # # Examples in chronological order: # 3.0, 3.0.1, 3.1 alpha1, 3.1 beta1, 3.1 beta2, 3.1 rc1, 3.1, 3.1.1, 3.2 pre, 3.2 alpha1 # Do NOT add quote set(KDEPIM_DEV_VERSION beta1) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_VERSION_NUMBER "5.2.80") set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(AKONADI_MIMELIB_VERSION "5.2.80") set(AKONADI_CONTACT_VERSION "5.2.80") set(KCONTACTS_LIB_VERSION "5.2.81") set(KCALENDARCORE_LIB_VERSION "5.2.80") set(IDENTITYMANAGEMENT_LIB_VERSION "5.2.80") set(KLDAP_LIB_VERSION "5.2.80") set(KMAILTRANSPORT_LIB_VERSION "5.2.80") set(CALENDARUTILS_LIB_VERSION "5.2.80") set(KHOLIDAYS_LIB_VERSION "5.2.80") set(KTNEF_LIB_VERSION "5.2.80") set(KIMAP_LIB_VERSION "5.2.80") set(KMBOX_LIB_VERSION "5.2.80") set(AKONADICALENDAR_LIB_VERSION "5.2.80") set(SYNDICATION_LIB_VERSION "5.2.80") set(GPGMEPP_LIB_VERSION "5.2.80") set(KONTACTINTERFACE_LIB_VERSION "5.2.80") set(AKONADIKALARM_LIB_VERSION "5.2.80") set(KMIME_LIB_VERSION "5.2.80") set(XMLRPCCLIENT_LIB_VERSION "5.2.80") set(KBLOG_LIB_VERSION "5.2.80") set(KPIMTEXTEDIT_LIB_VERSION "5.2.80") set(AKONADI_VERSION "5.2.80") set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}") set(KDEPIM_LIB_SOVERSION "5") set(AKONADINOTES_LIB_VERSION "5.2.80") set(QT_REQUIRED_VERSION "5.6.0") option(KDEPIM_ENTERPRISE_BUILD "Enable features specific to the enterprise branch, which are normally disabled. Also, it disables many components not needed for Kontact such as the Kolab client." FALSE) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Sql Concurrent UiTools WebEngine WebEngineWidgets) find_package(Qt5X11Extras NO_MODULE) find_package(Grantlee5 "5.1" CONFIG REQUIRED) set(LIBGRAVATAR_VERSION_LIB "5.2.80") set(LIBMAILIMPORTER_VERSION_LIB "5.2.80") set(MAILCOMMON_LIB_VERSION_LIB "5.2.80") set(KDEPIM_APPS_LIB_VERSION_LIB "5.2.80") set(MESSAGELIB_LIB_VERSION_LIB "5.2.91") set(LIBKLEO_LIB_VERSION_LIB "5.2.80") set(LIBGRANTLEETHEME_LIB_VERSION_LIB "5.2.80") set(PIMCOMMON_LIB_VERSION_LIB "5.2.80") set(LIBKDEPIM_LIB_VERSION_LIB "5.2.80") set(LIBINCIDENCEEDITOR_LIB_VERSION_LIB "5.2.80") set(CALENDARSUPPORT_LIB_VERSION_LIB "5.2.80") set(EVENTVIEW_LIB_VERSION_LIB "5.2.80") set(KDGANTT2_LIB_VERSION_LIB "5.2.80") - set(LIBKSIEVE_LIB_VERSION_LIB "5.2.82") + set(LIBKSIEVE_LIB_VERSION_LIB "5.2.83") find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) set(WEBENGINE_TYPE "QtWebEngine") # Find KF5 package find_package(KF5KDELibs4Support ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Wallet ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5NewStuff ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5KCMUtils ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Archive ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5NotifyConfig ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Config ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Service ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DBusAddons ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Auth ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DocTools ${KF5_VERSION} REQUIRED) find_package(Phonon4Qt5 CONFIG REQUIRED) find_package(KF5DNSSD ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5TextEditor ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Sonnet ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5GlobalAccel ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Crash ${KF5_VERSION} REQUIRED) # Find KdepimLibs Package find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADI_CONTACT_VERSION} CONFIG REQUIRED) find_package(KF5IdentityManagement ${IDENTITYMANAGEMENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Ldap ${KLDAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailTransport ${KMAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADI_MIMELIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Holidays ${KHOLIDAYS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Tnef ${KTNEF_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IMAP ${KIMAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mbox ${KMBOX_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiCalendar ${AKONADICALENDAR_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Syndication ${SYNDICATION_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Gpgmepp ${GPGMEPP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5KontactInterface ${KONTACTINTERFACE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AlarmCalendar ${AKONADIKALARM_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5XmlRpcClient ${XMLRPCCLIENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Blog ${KBLOG_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiNotes ${AKONADINOTES_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Gravatar ${LIBGRAVATAR_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MailImporter ${LIBMAILIMPORTER_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MailCommon ${MAILCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5KaddressbookGrantlee ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5GrantleeTheme ${LIBGRANTLEETHEME_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5Libkdepim ${LIBKDEPIM_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5IncidenceEditor ${LIBINCIDENCEEDITOR_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageCore ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageComposer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5MessageList ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5TemplateParser ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5CalendarSupport ${CALENDARSUPPORT_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5EventViews ${EVENTVIEW_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5KDGantt2 ${KDGANTT2_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5FollowupReminder ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5SendLater ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5KdepimDBusInterfaces ${KDEPIM_APPS_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5LibKSieve ${LIBKSIEVE_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(MailTransportDBusService CONFIG REQUIRED) if (NOT APPLE) find_package(X11) endif() set(KDEPIM_HAVE_X11 ${X11_FOUND}) # Extra package find_package(KF5GAPI "5.2.80" CONFIG) include_directories(${kdepim_SOURCE_DIR} ${kdepim_BINARY_DIR}) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) find_package(KF5AkonadiSearch "5.2.80" CONFIG REQUIRED) set_package_properties(KF5AkonadiSearch PROPERTIES DESCRIPTION "The Akonadi Search libraries" URL "http://www.kde.org" TYPE REQUIRED PURPOSE "Provides search capabilities in KMail and Akonadi") if(KDEPIM_ENTERPRISE_BUILD) message(STATUS "Enterprise build is enabled.") endif() ############### Desktop vs. Mobile options ############## find_package(Boost 1.34.0) set_package_properties(Boost PROPERTIES DESCRIPTION "Boost C++ Libraries" URL "http://www.boost.org" TYPE REQUIRED PURPOSE "Boost is required for building most KDEPIM applications") add_subdirectory(kmail) add_subdirectory(grantleeeditor) add_subdirectory(korganizer) add_subdirectory(sieveeditor) add_subdirectory(storageservicemanager) add_subdirectory(akregator) add_subdirectory(importwizard) add_subdirectory(kaddressbook) add_subdirectory(mboximporter) add_subdirectory(knotes) add_subdirectory(ktnef) add_subdirectory(pimsettingexporter) add_subdirectory(kalarm) add_subdirectory(blogilo) add_subdirectory(kontact) add_subdirectory(akonadiconsole) add_subdirectory(console) add_subdirectory(accountwizard) # doc must be a subdir of kdepim or packagers will kill us add_subdirectory(doc) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES ) endif() diff --git a/sieveeditor/CMakeLists.txt b/sieveeditor/CMakeLists.txt index 85e8c42c68..a9af6db1fd 100644 --- a/sieveeditor/CMakeLists.txt +++ b/sieveeditor/CMakeLists.txt @@ -1,82 +1,82 @@ project( sieveeditor ) if(${CMAKE_SOURCE_DIR} STREQUAL ${sieveeditor_SOURCE_DIR}) cmake_minimum_required(VERSION 3.1) set(KF5_VERSION "5.23.0") find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(ECMInstallIcons) include(ECMOptionalAddSubdirectory) include(ECMSetupVersion) include(ECMAddTests) include(ECMMarkNonGuiExecutable) include(GenerateExportHeader) include(ECMGenerateHeaders) include(CMakePackageConfigHelpers) include(FeatureSummary) include(CheckFunctionExists) include(ECMGeneratePriFile) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddAppIcon) include(ECMQtDeclareLoggingCategory) # Do NOT add quote set(KDEPIM_DEV_VERSION beta1) # add an extra space if(DEFINED KDEPIM_DEV_VERSION) set(KDEPIM_DEV_VERSION " ${KDEPIM_DEV_VERSION}") endif() set(KDEPIM_VERSION_NUMBER "5.2.80") set(KDEPIM_VERSION "${KDEPIM_VERSION_NUMBER}${KDEPIM_DEV_VERSION}") set(KMAILTRANSPORT_LIB_VERSION "5.2.80") set(KPIMTEXTEDIT_LIB_VERSION "5.2.80") set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}") set(KDEPIM_LIB_SOVERSION "5") set(MESSAGELIB_LIB_VERSION_LIB "5.2.91") set(PIMCOMMON_LIB_VERSION_LIB "5.2.80") - set(LIBKSIEVE_LIB_VERSION_LIB "5.2.82") + set(LIBKSIEVE_LIB_VERSION_LIB "5.2.83") set(QT_REQUIRED_VERSION "5.6.0") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Network Test) # Find KF5 package find_package(KF5DBusAddons ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5DocTools ${KF5_VERSION} REQUIRED) find_package(KF5Crash ${KF5_VERSION} REQUIRED) # Find KdepimLibs Package find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MailTransport ${KMAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5MessageViewer ${MESSAGELIB_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5PimCommon ${PIMCOMMON_LIB_VERSION_LIB} CONFIG REQUIRED) find_package(KF5LibKSieve ${LIBKSIEVE_LIB_VERSION_LIB} CONFIG REQUIRED) include_directories(${sieveeditor_SOURCE_DIR} ${sieveeditor_BINARY_DIR}) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) endif() add_definitions(-DQT_USE_QSTRINGBUILDER) add_definitions( -DQT_NO_CAST_FROM_ASCII ) add_definitions( -DQT_NO_CAST_TO_ASCII ) add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(autotests) endif() install( FILES sieveeditor.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) endif() diff --git a/sieveeditor/src/sieveeditorpagewidget.cpp b/sieveeditor/src/sieveeditorpagewidget.cpp index 2c476723dd..a53e62ecbb 100644 --- a/sieveeditor/src/sieveeditorpagewidget.cpp +++ b/sieveeditor/src/sieveeditorpagewidget.cpp @@ -1,364 +1,371 @@ /* Copyright (C) 2014-2016 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sieveeditorpagewidget.h" #include "ksieveui/sieveeditorwidget.h" #include "sieveeditorglobalconfig.h" #include #include #include #include "sieveeditor_debug.h" #include SieveEditorPageWidget::SieveEditorPageWidget(QWidget *parent) : QWidget(parent), mWasActive(false), mIsNewScript(false) { QVBoxLayout *vbox = new QVBoxLayout; setLayout(vbox); mSieveEditorWidget = new KSieveUi::SieveEditorWidget(false); connect(mSieveEditorWidget, &KSieveUi::SieveEditorWidget::valueChanged, this, &SieveEditorPageWidget::slotValueChanged); vbox->addWidget(mSieveEditorWidget); connect(mSieveEditorWidget, &KSieveUi::SieveEditorWidget::checkSyntax, this, &SieveEditorPageWidget::slotCheckSyntaxClicked); connect(mSieveEditorWidget, &KSieveUi::SieveEditorWidget::modeEditorChanged, this, &SieveEditorPageWidget::modeEditorChanged); connect(mSieveEditorWidget, &KSieveUi::SieveEditorWidget::undoAvailable, this, &SieveEditorPageWidget::undoAvailable); connect(mSieveEditorWidget, &KSieveUi::SieveEditorWidget::redoAvailable, this, &SieveEditorPageWidget::redoAvailable); connect(mSieveEditorWidget, &KSieveUi::SieveEditorWidget::copyAvailable, this, &SieveEditorPageWidget::copyAvailable); connect(mSieveEditorWidget, &KSieveUi::SieveEditorWidget::sieveEditorTabCurrentChanged, this, &SieveEditorPageWidget::sieveEditorTabCurrentChanged); } SieveEditorPageWidget::~SieveEditorPageWidget() { } void SieveEditorPageWidget::slotCheckSyntaxClicked() { const QString script = mSieveEditorWidget->script(); if (script.isEmpty()) { return; + } + mSieveEditorWidget->addNormalMessage(i18n("Uploading script to server for checking it, please wait...")); KManageSieve::SieveJob *job = KManageSieve::SieveJob::put(mCurrentURL, script, mWasActive, mWasActive); - job->setInteractive(false); - connect(job, &KManageSieve::SieveJob::errorMessage, this, &SieveEditorPageWidget::slotPutResultDebug); + connect(job, &KManageSieve::SieveJob::result, this, &SieveEditorPageWidget::slotPutResultDebug); } -void SieveEditorPageWidget::slotPutResultDebug(KManageSieve::SieveJob *, bool success, const QString &errorMsg) +void SieveEditorPageWidget::slotPutResultDebug(KManageSieve::SieveJob *job, bool success) { if (success) { mSieveEditorWidget->addOkMessage(i18n("No errors found.")); } else { + const QString errorMsg = job->errorString(); if (errorMsg.isEmpty()) { mSieveEditorWidget->addFailedMessage(i18n("An unknown error was encountered.")); } else { mSieveEditorWidget->addFailedMessage(errorMsg); } } //Put original script after check otherwise we will put a script even if we don't click on ok - KManageSieve::SieveJob *job = KManageSieve::SieveJob::put(mCurrentURL, mSieveEditorWidget->originalScript(), mWasActive, mWasActive); - job->setInteractive(false); + KManageSieve::SieveJob *restoreJob = KManageSieve::SieveJob::put(mCurrentURL, mSieveEditorWidget->originalScript(), mWasActive, mWasActive); mSieveEditorWidget->resultDone(); } void SieveEditorPageWidget::setIsNewScript(bool isNewScript) { mIsNewScript = isNewScript; } void SieveEditorPageWidget::loadScript(const QUrl &url, const QStringList &capabilities) { mCurrentURL = url; mSieveEditorWidget->setSieveCapabilities(capabilities); mSieveEditorWidget->setReadOnly(true); mSieveEditorWidget->wordWrap(SieveEditorGlobalConfig::self()->wrapText()); KManageSieve::SieveJob *job = KManageSieve::SieveJob::get(url); connect(job, &KManageSieve::SieveJob::result, this, &SieveEditorPageWidget::slotGetResult); } QUrl SieveEditorPageWidget::currentUrl() const { return mCurrentURL; } void SieveEditorPageWidget::slotGetResult(KManageSieve::SieveJob *, bool success, const QString &script, bool isActive) { mSieveEditorWidget->setReadOnly(false); if (!success) { return; } mSieveEditorWidget->setScriptName(mCurrentURL.fileName()); mSieveEditorWidget->setScript(script); mWasActive = isActive; mSieveEditorWidget->setModified(false); } void SieveEditorPageWidget::uploadScript(bool showInformation, bool forceSave) { if (mSieveEditorWidget->isModified() || forceSave) { KManageSieve::SieveJob *job = KManageSieve::SieveJob::put(mCurrentURL, mSieveEditorWidget->script(), mWasActive, mWasActive); job->setProperty("showuploadinformation", showInformation); connect(job, &KManageSieve::SieveJob::result, this, &SieveEditorPageWidget::slotPutResult); } } void SieveEditorPageWidget::slotPutResult(KManageSieve::SieveJob *job, bool success) { if (mIsNewScript) { Q_EMIT refreshList(); } if (success) { if (job->property("showuploadinformation").toBool()) { KMessageBox::information(this, i18n("The Sieve script was successfully uploaded."), i18n("Sieve Script Upload")); } mIsNewScript = false; mSieveEditorWidget->updateOriginalScript(); mSieveEditorWidget->setModified(false); } else { - //TODO error + const QString msg = job->errorString(); + if (msg.isEmpty()) + KMessageBox::error(Q_NULLPTR, i18n("Uploading the Sieve script failed.\n" + "The server responded:\n%1", msg, i18n("Sieve Error"))); + else { + KMessageBox::error(Q_NULLPTR, msg, i18n("Sieve Error")); + } } } bool SieveEditorPageWidget::needToSaveScript() { bool result = false; if (mIsNewScript) { const int resultQuestion = KMessageBox::warningYesNoCancel(this, i18n("Script '%1' is new. Do you want to save it?", mCurrentURL.fileName())); if (resultQuestion == KMessageBox::Yes) { uploadScript(); result = true; } else if (resultQuestion == KMessageBox::Cancel) { result = true; } } else { if (mSieveEditorWidget->isModified()) { const int resultQuestion = KMessageBox::warningYesNoCancel(this, i18n("Script '%1' was changed. Do you want to save it ?", mCurrentURL.fileName())); if (resultQuestion == KMessageBox::Yes) { uploadScript(); result = true; } else if (resultQuestion == KMessageBox::Cancel) { result = true; } } } return result; } void SieveEditorPageWidget::slotValueChanged(bool b) { Q_EMIT scriptModified(b, this); } bool SieveEditorPageWidget::isModified() const { return mSieveEditorWidget->isModified(); } void SieveEditorPageWidget::goToLine() { mSieveEditorWidget->goToLine(); } void SieveEditorPageWidget::undo() { mSieveEditorWidget->undo(); } bool SieveEditorPageWidget::isUndoAvailable() const { return mSieveEditorWidget->isUndoAvailable(); } bool SieveEditorPageWidget::isRedoAvailable() const { return mSieveEditorWidget->isRedoAvailable(); } bool SieveEditorPageWidget::hasSelection() const { return mSieveEditorWidget->hasSelection(); } void SieveEditorPageWidget::redo() { mSieveEditorWidget->redo(); } void SieveEditorPageWidget::find() { mSieveEditorWidget->find(); } void SieveEditorPageWidget::replace() { mSieveEditorWidget->replace(); } void SieveEditorPageWidget::shareScript() { mSieveEditorWidget->slotShareScript(); } void SieveEditorPageWidget::import() { mSieveEditorWidget->slotImport(); } void SieveEditorPageWidget::comment() { mSieveEditorWidget->comment(); } void SieveEditorPageWidget::uncomment() { mSieveEditorWidget->uncomment(); } void SieveEditorPageWidget::checkSpelling() { mSieveEditorWidget->checkSpelling(); } void SieveEditorPageWidget::createRulesGraphically() { mSieveEditorWidget->slotCreateRulesGraphically(); } void SieveEditorPageWidget::checkSyntax() { mSieveEditorWidget->slotCheckSyntax(); } void SieveEditorPageWidget::saveAs() { mSieveEditorWidget->slotSaveAs(); } void SieveEditorPageWidget::reverseCase() { mSieveEditorWidget->reverseCase(); } void SieveEditorPageWidget::lowerCase() { mSieveEditorWidget->lowerCase(); } void SieveEditorPageWidget::debugSieveScript() { mSieveEditorWidget->debugSieveScript(); } void SieveEditorPageWidget::upperCase() { mSieveEditorWidget->upperCase(); } void SieveEditorPageWidget::sentenceCase() { mSieveEditorWidget->sentenceCase(); } KSieveUi::SieveEditorWidget::EditorMode SieveEditorPageWidget::pageMode() const { return mSieveEditorWidget->mode(); } void SieveEditorPageWidget::paste() { mSieveEditorWidget->paste(); } void SieveEditorPageWidget::cut() { mSieveEditorWidget->cut(); } void SieveEditorPageWidget::copy() { mSieveEditorWidget->copy(); } void SieveEditorPageWidget::selectAll() { mSieveEditorWidget->selectAll(); } void SieveEditorPageWidget::zoomIn() { mSieveEditorWidget->zoomIn(); } void SieveEditorPageWidget::zoomOut() { mSieveEditorWidget->zoomOut(); } void SieveEditorPageWidget::wordWrap(bool state) { mSieveEditorWidget->wordWrap(state); } bool SieveEditorPageWidget::isWordWrap() const { return mSieveEditorWidget->isWordWrap(); } void SieveEditorPageWidget::print() { mSieveEditorWidget->print(); } void SieveEditorPageWidget::printPreview() { mSieveEditorWidget->printPreview(); } bool SieveEditorPageWidget::printSupportEnabled() const { return mSieveEditorWidget->printSupportEnabled(); } bool SieveEditorPageWidget::isTextEditor() const { return mSieveEditorWidget->isTextEditor(); } void SieveEditorPageWidget::zoomReset() { mSieveEditorWidget->zoomReset(); } void SieveEditorPageWidget::openBookmarkUrl(const QUrl &url) { mSieveEditorWidget->openBookmarkUrl(url); } QString SieveEditorPageWidget::currentHelpTitle() const { return mSieveEditorWidget->currentHelpTitle(); } QUrl SieveEditorPageWidget::currentHelpUrl() const { return mSieveEditorWidget->currentHelpUrl(); } diff --git a/sieveeditor/src/sieveeditorpagewidget.h b/sieveeditor/src/sieveeditorpagewidget.h index c644bc11da..607f655b6c 100644 --- a/sieveeditor/src/sieveeditorpagewidget.h +++ b/sieveeditor/src/sieveeditorpagewidget.h @@ -1,112 +1,112 @@ /* Copyright (C) 2014-2016 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SIEVEEDITORPAGEWIDGET_H #define SIEVEEDITORPAGEWIDGET_H #include #include #include "ksieveui/sieveeditorwidget.h" namespace KManageSieve { class SieveJob; } namespace KSieveUi { class SieveEditorWidget; } class SieveEditorPageWidget : public QWidget { Q_OBJECT public: explicit SieveEditorPageWidget(QWidget *parent = Q_NULLPTR); ~SieveEditorPageWidget(); void loadScript(const QUrl &url, const QStringList &capabilities); QUrl currentUrl() const; void setIsNewScript(bool isNewScript); void uploadScript(bool showInformation = true, bool forceSave = false); bool needToSaveScript(); bool isModified() const; void goToLine(); KSieveUi::SieveEditorWidget::EditorMode pageMode() const; void find(); void replace(); void redo(); void undo(); bool isUndoAvailable() const; bool isRedoAvailable() const; void paste(); void cut(); void copy(); bool hasSelection() const; void selectAll(); void saveAs(); void checkSpelling(); void shareScript(); void import(); void createRulesGraphically(); void checkSyntax(); void comment(); void uncomment(); void lowerCase(); void upperCase(); void sentenceCase(); void reverseCase(); void zoomIn(); void zoomOut(); QString currentHelpTitle() const; QUrl currentHelpUrl() const; void openBookmarkUrl(const QUrl &url); void debugSieveScript(); void zoomReset(); void wordWrap(bool state); bool isWordWrap() const; void print(); void printPreview(); bool printSupportEnabled() const; bool isTextEditor() const; Q_SIGNALS: void refreshList(); void scriptModified(bool, SieveEditorPageWidget *); void modeEditorChanged(KSieveUi::SieveEditorWidget::EditorMode); void undoAvailable(bool); void redoAvailable(bool); void copyAvailable(bool); void sieveEditorTabCurrentChanged(); private Q_SLOTS: void slotGetResult(KManageSieve::SieveJob *, bool success, const QString &script, bool isActive); void slotCheckSyntaxClicked(); - void slotPutResultDebug(KManageSieve::SieveJob *, bool success, const QString &errorMsg); + void slotPutResultDebug(KManageSieve::SieveJob *, bool success); void slotPutResult(KManageSieve::SieveJob *, bool success); void slotValueChanged(bool b); private: void setModified(bool b); QUrl mCurrentURL; KSieveUi::SieveEditorWidget *mSieveEditorWidget; bool mWasActive; bool mIsNewScript; }; #endif // SIEVEEDITORPAGEWIDGET_H