akonadimailtransportplugin.cpp 2.64 KB
Newer Older
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 "akonadimailtransportplugin.h"
21
#include "resourcesendjob_p.h"
22
#include <kpluginfactory.h>
23 24
#include <AkonadiCore/AgentManager>
#include <MailTransport/TransportAbstractPlugin>
25
#include <QDebug>
26

27
using namespace Akonadi;
28
K_PLUGIN_FACTORY_WITH_JSON(AkonadiMailTransportPluginFactory, "akonadimailtransport.json", registerPlugin<AkonadiMailTransportPlugin>();
Laurent Montel's avatar
Laurent Montel committed
29
                           )
30 31 32 33 34 35 36 37 38 39

AkonadiMailTransportPlugin::AkonadiMailTransportPlugin(QObject *parent, const QList<QVariant> &)
    : MailTransport::TransportAbstractPlugin(parent)
{
}

AkonadiMailTransportPlugin::~AkonadiMailTransportPlugin()
{
}

Laurent Montel's avatar
Fix api  
Laurent Montel committed
40
void AkonadiMailTransportPlugin::cleanUp(const QString &identifier)
41
{
Laurent Montel's avatar
Fix api  
Laurent Montel committed
42
    Q_UNUSED(identifier);
43 44 45
    //TODO FIXME
}

Laurent Montel's avatar
Fix api  
Laurent Montel committed
46
QVector<MailTransport::TransportAbstractPluginInfo> AkonadiMailTransportPlugin::names() const
47
{
48 49 50 51 52
    QVector<MailTransport::TransportAbstractPluginInfo> lst;

    for (const AgentType &atype : AgentManager::self()->types()) {
        // TODO probably the string "MailTransport" should be #defined somewhere
        // and used like that in the resources (?)
Laurent Montel's avatar
Laurent Montel committed
53
        if (atype.capabilities().contains(QStringLiteral("MailTransport"))) {
54 55 56 57
            MailTransport::TransportAbstractPluginInfo info;
            info.name = atype.name();
            info.description = atype.description();
            info.identifier = atype.identifier();
58
            info.isAkonadi = true;
59 60 61 62
            lst << info;
        }
    }
    return lst;
63 64
}

Laurent Montel's avatar
Fix api  
Laurent Montel committed
65
bool AkonadiMailTransportPlugin::configureTransport(const QString &identifier, MailTransport::Transport *transport, QWidget *parent)
66
{
67

Laurent Montel's avatar
Fix api  
Laurent Montel committed
68
    //TODO
69
    return false;
70 71
}

72 73 74 75 76
MailTransport::TransportJob *AkonadiMailTransportPlugin::createTransportJob(MailTransport::Transport *t, const QString &identifier)
{
    return new MailTransport::ResourceSendJob(t, this);
}

77
#include "akonadimailtransportplugin.moc"