Commit 40ffdf4e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move files in own directory. Remove smtp from lib. Fix api

parent db56b9d4
......@@ -4,11 +4,6 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX MAILTRANSPORT
SOVERSION 5
)
set(mailtransport_lib_smtp_srcs
smtp/smtpjob.cpp
smtp/smtpconfigwidget.cpp
)
set(mailtransport_lib_srcs
transport.cpp
transportmanager.cpp
......@@ -37,7 +32,6 @@ ecm_qt_declare_logging_category(mailtransport_lib_srcs HEADER mailtransport_debu
ki18n_wrap_ui(mailtransport_lib_srcs
ui/addtransportdialog.ui
ui/transportmanagementwidget.ui
ui/smtpsettings.ui
)
kconfig_add_kcfg_files(mailtransport_lib_srcs transportbase.kcfgc)
......@@ -45,7 +39,6 @@ kconfig_add_kcfg_files(mailtransport_lib_srcs transportbase.kcfgc)
add_library(KF5MailTransport
${mailtransport_lib_srcs}
${mailtransport_widgets_srcs}
${mailtransport_lib_smtp_srcs}
${mailtransport_plugins_srcs}
)
......@@ -96,15 +89,6 @@ ecm_generate_headers(MailTransport_CamelCase_HEADERS
REQUIRED_HEADERS MailTransport_HEADERS
)
ecm_generate_headers(MailTransport_smtp_CamelCase_HEADERS
HEADER_NAMES
SmtpJob
PREFIX MailTransport
REQUIRED_HEADERS MailTransport_smtp_HEADERS
RELATIVE smtp
)
ecm_generate_headers(MailTransport_widgets_CamelCase_HEADERS
HEADER_NAMES
TransportComboBox
......@@ -130,7 +114,6 @@ install(FILES
install(FILES
${MailTransport_CamelCase_HEADERS}
${MailTransport_widgets_CamelCase_HEADERS}
${MailTransport_smtp_CamelCase_HEADERS}
${MailTransport_plugins_CamelCase_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/MailTransport/ COMPONENT Devel )
......@@ -138,7 +121,6 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mailtransport_export.h
${MailTransport_HEADERS}
${MailTransport_widgets_HEADERS}
${MailTransport_smtp_HEADERS}
${MailTransport_plugins_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/transportbase.h
......
set(mailtransport_smtpplugin_SRCS
smtpmailtransportplugin.cpp
smtpconfigdialog.cpp
smtpjob.cpp
smtpconfigwidget.cpp
)
ki18n_wrap_ui(mailtransport_smtpplugin_SRCS
smtpsettings.ui
)
ecm_qt_declare_logging_category(mailtransport_smtpplugin_SRCS HEADER mailtransportplugin_smtp_debug.h IDENTIFIER MAILTRANSPORT_SMTP_LOG CATEGORY_NAME org.kde.pim.mailtransport.smtpplugin)
kcoreaddons_add_plugin(mailtransport_smtpplugin JSON smtpmailtransport.json SOURCES
${mailtransport_smtpplugin_SRCS} INSTALL_NAMESPACE mailtransport)
target_link_libraries(mailtransport_smtpplugin
KF5::MailTransport KF5::CoreAddons KF5::I18n Qt5::Widgets KF5::ConfigWidgets
KF5::MailTransport
KF5::CoreAddons
KF5::I18n
Qt5::Widgets
KF5::ConfigWidgets
KF5::KIOCore
KF5::Completion
)
......@@ -22,7 +22,7 @@
#include "transport.h"
#include "transportmanager.h"
#include "transporttype.h"
#include "smtp/smtpconfigwidget.h"
#include "smtpconfigwidget.h"
#include <QDialogButtonBox>
#include <QVBoxLayout>
......@@ -74,7 +74,6 @@ SmtpConfigDialog::SmtpConfigDialog(Transport *transport, QWidget *parent)
mainLayout->addWidget(d->configWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
d->okButton = buttonBox->button(QDialogButtonBox::Ok);
d->okButton->setEnabled(false);
d->okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
mainLayout->addWidget(buttonBox);
......
......@@ -32,6 +32,7 @@
#include "transportmanager.h"
#include "servertest.h"
#include "mailtransport_defs.h"
#include "mailtransportplugin_smtp_debug.h"
#include <QAbstractButton>
#include <QButtonGroup>
......@@ -328,7 +329,7 @@ void SMTPConfigWidget::ensureValidAuthSelection()
void SMTPConfigWidget::encryptionChanged(int enc)
{
Q_D(SMTPConfigWidget);
qCDebug(MAILTRANSPORT_LOG) << enc;
qCDebug(MAILTRANSPORT_SMTP_LOG) << enc;
// adjust port
if (enc == Transport::EnumEncryption::SSL) {
......
......@@ -27,7 +27,6 @@
#define MAILTRANSPORT_SMTPCONFIGWIDGET_H
#include "widgets/transportconfigwidget.h"
#include "mailtransport_export.h"
namespace MailTransport {
class Transport;
......@@ -40,7 +39,7 @@ class SMTPConfigWidgetPrivate;
@internal
Configuration widget for a SMTP transport.
*/
class MAILTRANSPORT_EXPORT SMTPConfigWidget : public TransportConfigWidget
class SMTPConfigWidget : public TransportConfigWidget
{
Q_OBJECT
......
......@@ -24,6 +24,7 @@
#include "transport.h"
#include "mailtransport_defs.h"
#include "precommandjob.h"
#include "mailtransportplugin_smtp_debug.h"
#include <QBuffer>
#include <QHash>
......@@ -51,7 +52,7 @@ public:
void removeSlave(KIO::Slave *slave, bool disconnect = false)
{
qCDebug(MAILTRANSPORT_LOG) << "Removing slave" << slave << "from pool";
qCDebug(MAILTRANSPORT_SMTP_LOG) << "Removing slave" << slave << "from pool";
const int slaveKey = slaves.key(slave);
if (slaveKey > 0) {
slaves.remove(slaveKey);
......@@ -101,7 +102,7 @@ SmtpJob::~SmtpJob()
if (!s_slavePool.isDestroyed()) {
s_slavePool->ref--;
if (s_slavePool->ref == 0) {
qCDebug(MAILTRANSPORT_LOG) << "clearing SMTP slave pool" << s_slavePool->slaves.count();
qCDebug(MAILTRANSPORT_SMTP_LOG) << "clearing SMTP slave pool" << s_slavePool->slaves.count();
foreach (KIO::Slave *slave, s_slavePool->slaves) {
if (slave) {
KIO::Scheduler::disconnectSlave(slave);
......@@ -220,10 +221,10 @@ void SmtpJob::startSmtpJob()
slaveConfig.insert(QStringLiteral("sasl"), transport()->authenticationTypeString());
}
d->slave = KIO::Scheduler::getConnectedSlave(destination, slaveConfig);
qCDebug(MAILTRANSPORT_LOG) << "Created new SMTP slave" << d->slave;
qCDebug(MAILTRANSPORT_SMTP_LOG) << "Created new SMTP slave" << d->slave;
s_slavePool->slaves.insert(transport()->id(), d->slave);
} else {
qCDebug(MAILTRANSPORT_LOG) << "Re-using existing slave" << d->slave;
qCDebug(MAILTRANSPORT_SMTP_LOG) << "Re-using existing slave" << d->slave;
}
KIO::TransferJob *job = KIO::put(destination, -1, KIO::HideProgressInfo);
......
......@@ -25,8 +25,6 @@
#include <transportjob.h>
#include <mailtransport_export.h>
namespace KIO {
class Job;
class Slave;
......@@ -45,7 +43,7 @@ namespace MailTransport {
Precommands are automatically executed, once per opening a connection to the
server (not necessarily once per message).
*/
class MAILTRANSPORT_EXPORT SmtpJob : public TransportJob
class SmtpJob : public TransportJob
{
Q_OBJECT
public:
......
......@@ -19,6 +19,7 @@
#include "smtpmailtransportplugin.h"
#include "smtpconfigdialog.h"
#include "smtpjob.h"
#include <kpluginfactory.h>
#include <KLocalizedString>
......@@ -61,4 +62,11 @@ void SMTPMailTransportPlugin::cleanUp(const QString &identifier)
//TODO FIXME
}
MailTransport::TransportJob *SMTPMailTransportPlugin::createTransportJob(MailTransport::Transport *t, const QString &identifier)
{
return new MailTransport::SmtpJob(t, this);
}
#include "smtpmailtransportplugin.moc"
......@@ -35,6 +35,7 @@ public:
QVector<MailTransport::TransportAbstractPluginInfo> names() const override;
bool configureTransport(const QString &identifier, MailTransport::Transport *transport, QWidget *parent) override;
void cleanUp(const QString &identifier) override;
MailTransport::TransportJob *createTransportJob(MailTransport::Transport *t, const QString &identifier) override;
};
#endif // SMTPMAILTRANSPORTPLUGIN_H
......@@ -18,7 +18,7 @@
*/
#include "transportabstractplugin.h"
#include "mailtransport_debug.h"
using namespace MailTransport;
TransportAbstractPlugin::TransportAbstractPlugin(QObject *parent)
......@@ -30,11 +30,6 @@ TransportAbstractPlugin::~TransportAbstractPlugin()
{
}
TransportJob *TransportAbstractPlugin::createTransportJob(const QString &identifier)
{
return nullptr;
}
void TransportAbstractPlugin::cleanUp(const QString &identifier)
{
Q_UNUSED(identifier);
......
......@@ -41,7 +41,7 @@ public:
explicit TransportAbstractPlugin(QObject *parent = nullptr);
~TransportAbstractPlugin();
virtual TransportJob *createTransportJob(const QString &identifier);
virtual TransportJob *createTransportJob(MailTransport::Transport *t, const QString &identifier) = 0;
virtual QVector<TransportAbstractPluginInfo> names() const = 0;
virtual bool configureTransport(const QString &identifier, Transport *transport, QWidget *parent) = 0;
virtual void cleanUp(const QString &identifier);
......
......@@ -98,8 +98,7 @@ void TransportMgr::editBtnClicked()
void TransportMgr::sendBtnClicked()
{
TransportJob *job;
job = TransportManager::self()->createTransportJob(mComboBox->currentTransportId());
TransportJob *job = TransportManager::self()->createTransportJob(mComboBox->currentTransportId());
if (!job) {
qDebug() << "Invalid transport!";
return;
......
......@@ -160,7 +160,8 @@ void Transport::usrRead()
{
d->transportType = TransportType();
d->transportType.d->mIdentifier = identifier();
qCDebug(MAILTRANSPORT_LOG) << "type" << identifier();
//qCDebug(MAILTRANSPORT_LOG) << "type" << identifier();
qDebug() << "set type" << identifier();
// Now we have the type and possibly agentType. Get the name, description
// etc. from TransportManager.
const TransportType::List &types = TransportManager::self()->types();
......
......@@ -19,7 +19,6 @@
#include "transportmanager.h"
#include "mailtransport_defs.h"
#include "smtp/smtpjob.h"
#include "transport.h"
#include "transport_p.h"
#include "transportjob.h"
......@@ -28,7 +27,6 @@
#include "plugins/transportpluginmanager.h"
#include "plugins/transportabstractplugin.h"
#include "widgets/addtransportdialogng.h"
#include "smtp/smtpconfigwidget.h"
#include <QApplication>
#include <QDBusConnection>
......@@ -297,7 +295,7 @@ TransportJob *TransportManager::createTransportJob(int transportId)
t->updatePasswordState();
TransportAbstractPlugin *plugin = TransportPluginManager::self()->plugin(t->identifier());
if (plugin) {
return plugin->createTransportJob(t->identifier());
return plugin->createTransportJob(t, t->identifier());
}
Q_ASSERT(false);
return nullptr;
......@@ -378,6 +376,10 @@ void TransportManager::removeTransport(int id)
if (!t) {
return;
}
auto plugin = MailTransport::TransportPluginManager::self()->plugin(t->identifier());
if (plugin) {
plugin->cleanUp(t->identifier());
}
emit transportRemoved(t->id(), t->name());
d->transports.removeAll(t);
......
......@@ -47,6 +47,7 @@ TransportType &TransportType::operator=(const TransportType &other)
bool TransportType::operator==(const TransportType &other) const
{
qDebug() << "d->mIdentifier "<<d->mIdentifier << " other.d->mIdentifier"<<other.d->mIdentifier;
return d->mIdentifier == other.d->mIdentifier;
}
......
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