Commit 8fdbee66 authored by Laurent Montel's avatar Laurent Montel 😁

initialize transport

parent c2823d4e
......@@ -34,3 +34,9 @@ void TransportAbstractPlugin::cleanUp(const QString &identifier)
{
Q_UNUSED(identifier);
}
void TransportAbstractPlugin::initializeTransport(MailTransport::Transport *t, const QString &identifier)
{
Q_UNUSED(identifier);
Q_UNUSED(t);
}
......@@ -46,6 +46,7 @@ public:
virtual QVector<TransportAbstractPluginInfo> names() const = 0;
virtual bool configureTransport(const QString &identifier, Transport *transport, QWidget *parent) = 0;
virtual void cleanUp(const QString &identifier);
virtual void initializeTransport(MailTransport::Transport *t, const QString &identifier);
};
}
Q_DECLARE_TYPEINFO(MailTransport::TransportAbstractPluginInfo, Q_MOVABLE_TYPE);
......
......@@ -276,6 +276,14 @@ bool TransportManager::showTransportCreationDialog(QWidget *parent, ShowConditio
return accepted;
}
void TransportManager::initializeTransport(const QString &identifier, Transport *transport)
{
TransportAbstractPlugin *plugin = TransportPluginManager::self()->plugin(identifier);
if (plugin) {
return plugin->initializeTransport(transport, identifier);
}
}
bool TransportManager::configureTransport(const QString &identifier, Transport *transport, QWidget *parent)
{
TransportAbstractPlugin *plugin = TransportPluginManager::self()->plugin(identifier);
......
......@@ -187,6 +187,7 @@ public:
*/
bool configureTransport(const QString &identifier, Transport *transport, QWidget *parent);
void initializeTransport(const QString &identifier, Transport *transport);
public Q_SLOTS:
/**
Returns true if there are no mail transports at all.
......
......@@ -169,7 +169,9 @@ void AddTransportDialogNG::accept()
// Create a new transport and configure it.
Transport *transport = TransportManager::self()->createTransport();
transport->setName(d->ui.name->text().trimmed());
//transport->setTransportType(d->selectedType());
transport->forceUniqueName();
TransportManager::self()->initializeTransport(d->selectedType(), transport);
if (TransportManager::self()->configureTransport(d->selectedType(), transport, this)) {
// The user clicked OK and the transport settings were saved.
TransportManager::self()->addTransport(transport);
......
......@@ -22,6 +22,8 @@
#include <kpluginfactory.h>
#include <AkonadiCore/AgentManager>
#include <MailTransport/TransportAbstractPlugin>
#include <AkonadiCore/AgentInstanceCreateJob>
#include <MailTransport/Transport>
#include <QDebug>
using namespace Akonadi;
......@@ -74,4 +76,14 @@ MailTransport::TransportJob *AkonadiMailTransportPlugin::createTransportJob(Mail
return new MailTransport::ResourceSendJob(t, this);
}
void AkonadiMailTransportPlugin::initializeTransport(MailTransport::Transport *t, const QString &identifier)
{
Akonadi::AgentInstanceCreateJob *cjob = new AgentInstanceCreateJob( identifier );
if ( !cjob->exec() ) {
qWarning() << "Failed to create agent instance of type" << identifier;
return;
}
t->setHost( cjob->instance().identifier() );
}
#include "akonadimailtransportplugin.moc"
......@@ -37,6 +37,7 @@ public:
void cleanUp(const QString &identifier) override;
MailTransport::TransportJob *createTransportJob(MailTransport::Transport *t, const QString &identifier) override;
void initializeTransport(MailTransport::Transport *t, const QString &identifier) override;
};
#endif // AkonadiMAILTRANSPORTPLUGIN_H
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