diff --git a/CMakeLists.txt b/CMakeLists.txt index 4837f59..ee80051 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,59 +1,59 @@ cmake_minimum_required(VERSION 3.0) set(PIM_VERSION "5.7.80") project(MailTransport VERSION ${PIM_VERSION}) # ECM setup -set(KF5_VERSION "5.43.0") +set(KF5_VERSION "5.44.0") find_package(ECM ${KF5_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(GenerateExportHeader) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(CMakePackageConfigHelpers) include(ECMSetupVersion) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMQtDeclareLoggingCategory) include(ECMCoverageOption) add_definitions(-DTRANSLATION_DOMAIN=\"libmailtransport5\") set(KMAILTRANSPORT_LIB_VERSION ${PIM_VERSION}) set(KMIME_LIB_VERSION "5.7.80") set(AKONADI_LIB_VERSION "5.7.80") set(AKONADIMIME_LIB_VERSION "5.7.80") set(KSMTP_LIB_VERSION "5.7.80") set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5MailTransport") ########### Find packages ########### find_package(KF5KCMUtils ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Wallet ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5I18n ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_VERSION} CONFIG REQUIRED) find_package(KF5Mime ${KMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiMime ${AKONADIMIME_LIB_VERSION} CONFIG REQUIRED) find_package(KPimSMTP ${KSMTP_LIB_VERSION} CONFIG REQUIRED) add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII") add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) if(BUILD_TESTING) add_definitions(-DBUILD_TESTING) endif(BUILD_TESTING) ########### Targets ########### add_subdirectory(src) install( FILES kmailtransport.renamecategories kmailtransport.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/kmailtransport/plugins/smtp/smtpmailtransportplugin.cpp b/src/kmailtransport/plugins/smtp/smtpmailtransportplugin.cpp index 5948af5..3c80a83 100644 --- a/src/kmailtransport/plugins/smtp/smtpmailtransportplugin.cpp +++ b/src/kmailtransport/plugins/smtp/smtpmailtransportplugin.cpp @@ -1,70 +1,66 @@ /* Copyright (C) 2017-2018 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "smtpmailtransportplugin.h" #include "smtpconfigdialog.h" #include "smtpjob.h" #include #include #include -#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 44, 0) -#define K_PLUGIN_CLASS_WITH_JSON(classname, json) K_PLUGIN_FACTORY_WITH_JSON(classname ## Factory, json, registerPlugin();) -#endif - K_PLUGIN_CLASS_WITH_JSON(SMTPMailTransportPlugin, "smtpmailtransport.json") SMTPMailTransportPlugin::SMTPMailTransportPlugin(QObject *parent, const QList &) : MailTransport::TransportAbstractPlugin(parent) { } SMTPMailTransportPlugin::~SMTPMailTransportPlugin() { } QVector SMTPMailTransportPlugin::names() const { MailTransport::TransportAbstractPluginInfo info; info.name = i18nc("@option SMTP transport", "SMTP"); info.description = i18n("An SMTP server on the Internet"); info.identifier = QStringLiteral("SMTP"); info.isAkonadi = false; return QVector() << info; } bool SMTPMailTransportPlugin::configureTransport(const QString &identifier, MailTransport::Transport *transport, QWidget *parent) { Q_UNUSED(identifier); QPointer transportConfigDialog = new MailTransport::SmtpConfigDialog(transport, parent); transportConfigDialog->setWindowTitle(i18n("Configure account")); bool okClicked = (transportConfigDialog->exec() == QDialog::Accepted); delete transportConfigDialog; return okClicked; } MailTransport::TransportJob *SMTPMailTransportPlugin::createTransportJob(MailTransport::Transport *t, const QString &identifier) { Q_UNUSED(identifier); return new MailTransport::SmtpJob(t, this); } #include "smtpmailtransportplugin.moc" diff --git a/src/kmailtransportakonadi/plugins/akonadimailtransportplugin.cpp b/src/kmailtransportakonadi/plugins/akonadimailtransportplugin.cpp index dfc6ac4..ebf42aa 100644 --- a/src/kmailtransportakonadi/plugins/akonadimailtransportplugin.cpp +++ b/src/kmailtransportakonadi/plugins/akonadimailtransportplugin.cpp @@ -1,112 +1,108 @@ /* Copyright (C) 2017-2018 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "akonadimailtransportplugin.h" #include "resourcesendjob_p.h" #include "mailtransportplugin_akonadi_debug.h" #include #include #include #include #include using namespace Akonadi; -#include -#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 44, 0) -#define K_PLUGIN_CLASS_WITH_JSON(classname, json) K_PLUGIN_FACTORY_WITH_JSON(classname ## Factory, json, registerPlugin();) -#endif K_PLUGIN_CLASS_WITH_JSON(AkonadiMailTransportPlugin, "akonadimailtransport.json") AkonadiMailTransportPlugin::AkonadiMailTransportPlugin(QObject *parent, const QList &) : MailTransport::TransportAbstractPlugin(parent) { // Watch for appearing and disappearing types. connect(AgentManager::self(), &AgentManager::typeAdded, this, &AkonadiMailTransportPlugin::slotUpdatePluginList); connect(AgentManager::self(), &AgentManager::typeRemoved, this, &AkonadiMailTransportPlugin::slotUpdatePluginList); } AkonadiMailTransportPlugin::~AkonadiMailTransportPlugin() { } void AkonadiMailTransportPlugin::slotUpdatePluginList(const Akonadi::AgentType &type) { if (type.capabilities().contains(QLatin1String("MailTransport"))) { Q_EMIT updatePluginList(); } } void AkonadiMailTransportPlugin::cleanUp(MailTransport::Transport *t) { const AgentInstance instance = AgentManager::self()->instance(t->host()); if (!instance.isValid()) { qCWarning(MAILTRANSPORT_AKONADI_LOG) << "Could not find resource instance for name:" << t->host(); } AgentManager::self()->removeInstance(instance); } QVector AkonadiMailTransportPlugin::names() const { QVector lst; for (const AgentType &atype : AgentManager::self()->types()) { // TODO probably the string "MailTransport" should be #defined somewhere // and used like that in the resources (?) if (atype.capabilities().contains(QLatin1String("MailTransport"))) { MailTransport::TransportAbstractPluginInfo info; info.name = atype.name(); info.description = atype.description(); info.identifier = atype.identifier(); info.isAkonadi = true; lst << info; } } return lst; } bool AkonadiMailTransportPlugin::configureTransport(const QString &identifier, MailTransport::Transport *transport, QWidget *parent) { Q_UNUSED(identifier); AgentInstance instance = AgentManager::self()->instance(transport->host()); if (!instance.isValid()) { qCWarning(MAILTRANSPORT_AKONADI_LOG) << "Invalid resource instance" << transport->host(); } instance.configure(parent); // Async... transport->save(); return true; // No way to know here if the user cancelled or not. } MailTransport::TransportJob *AkonadiMailTransportPlugin::createTransportJob(MailTransport::Transport *t, const QString &identifier) { Q_UNUSED(identifier); return new MailTransport::ResourceSendJob(t, this); } void AkonadiMailTransportPlugin::initializeTransport(MailTransport::Transport *t, const QString &identifier) { AgentInstanceCreateJob *cjob = new AgentInstanceCreateJob(identifier); if (!cjob->exec()) { qCWarning(MAILTRANSPORT_AKONADI_LOG) << "Failed to create agent instance of type" << identifier; return; } t->setHost(cjob->instance().identifier()); } #include "akonadimailtransportplugin.moc"