smtpmailtransportplugin.cpp 2.54 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
    Copyright (c) 2017 Laurent Montel <montel@kde.org>

    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"
Laurent Montel's avatar
Laurent Montel committed
21
#include "smtpconfigdialog.h"
22
#include "smtpjob.h"
Laurent Montel's avatar
Laurent Montel committed
23
#include <kpluginfactory.h>
Laurent Montel's avatar
Laurent Montel committed
24
#include <KLocalizedString>
Laurent Montel's avatar
Laurent Montel committed
25

Laurent Montel's avatar
Laurent Montel committed
26 27 28 29
K_PLUGIN_FACTORY_WITH_JSON(SMTPMailTransportPluginFactory, "smtpmailtransport.json", registerPlugin<SMTPMailTransportPlugin>();
                           )

SMTPMailTransportPlugin::SMTPMailTransportPlugin(QObject *parent, const QList<QVariant> &)
Laurent Montel's avatar
Laurent Montel committed
30 31 32 33 34 35 36 37
    : MailTransport::TransportAbstractPlugin(parent)
{
}

SMTPMailTransportPlugin::~SMTPMailTransportPlugin()
{
}

Laurent Montel's avatar
Fix api  
Laurent Montel committed
38
QVector<MailTransport::TransportAbstractPluginInfo> SMTPMailTransportPlugin::names() const
Laurent Montel's avatar
Laurent Montel committed
39
{
Laurent Montel's avatar
Fix api  
Laurent Montel committed
40
    MailTransport::TransportAbstractPluginInfo info;
Laurent Montel's avatar
Laurent Montel committed
41 42 43

    info.name = i18nc("@option SMTP transport", "SMTP");
    info.description = i18n("An SMTP server on the Internet");
Laurent Montel's avatar
Laurent Montel committed
44
    info.identifier = QStringLiteral("SMTP");
45
    info.isAkonadi = false;
Laurent Montel's avatar
Fix api  
Laurent Montel committed
46
    return QVector<MailTransport::TransportAbstractPluginInfo>() << info;
Laurent Montel's avatar
Laurent Montel committed
47 48
}

Laurent Montel's avatar
Fix api  
Laurent Montel committed
49
bool SMTPMailTransportPlugin::configureTransport(const QString &identifier, MailTransport::Transport *transport, QWidget *parent)
Laurent Montel's avatar
Laurent Montel committed
50
{
Laurent Montel's avatar
Laurent Montel committed
51 52 53 54 55 56 57
    Q_UNUSED(identifier);
    QPointer<MailTransport::SmtpConfigDialog> transportConfigDialog
        = new MailTransport::SmtpConfigDialog(transport, parent);
    transportConfigDialog->setWindowTitle(i18n("Configure account"));
    bool okClicked = (transportConfigDialog->exec() == QDialog::Accepted);
    delete transportConfigDialog;
    return okClicked;
Laurent Montel's avatar
Laurent Montel committed
58 59 60 61
}

void SMTPMailTransportPlugin::cleanUp(const QString &identifier)
{
Laurent Montel's avatar
Laurent Montel committed
62
    Q_UNUSED(identifier);
Laurent Montel's avatar
Laurent Montel committed
63 64
    //TODO FIXME
}
Laurent Montel's avatar
Laurent Montel committed
65

66 67 68 69 70
MailTransport::TransportJob *SMTPMailTransportPlugin::createTransportJob(MailTransport::Transport *t, const QString &identifier)
{
    return new MailTransport::SmtpJob(t, this);
}

Laurent Montel's avatar
Laurent Montel committed
71
#include "smtpmailtransportplugin.moc"
72 73