Unverified Commit 6e1b0314 authored by Luca Beltrame's avatar Luca Beltrame
Browse files

Revert "Implement RFC5161 - ENABLED extension"

This reverts commit ee4e0146.
parent d532cfe1
Pipeline #37344 passed with stage
in 8 minutes and 22 seconds
......@@ -29,7 +29,6 @@ KIMAP_UNIT_TESTS(
selectjobtest
createjobtest
deletejobtest
enablejobtest
expungejobtest
fetchjobtest
renamejobtest
......
/*
SPDX-FileCopyrightText: 2020 Daniel Vrátil <dvratil@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QTest>
#include "kimaptest/fakeserver.h"
#include "kimap/session.h"
#include "kimap/enablejob.h"
#include <QTest>
#include <QSignalSpy>
#include <QDebug>
Q_DECLARE_METATYPE(QList<QList<QByteArray>>)
class EnableJobTest: public QObject
{
Q_OBJECT
private Q_SLOTS:
void testEnable_data()
{
QTest::addColumn<QList<QByteArray>>("scenario");
QTest::addColumn<QStringList>("reqCapabilities");
QTest::addColumn<QStringList>("supportedCaps");
QList<QByteArray> scenario;
scenario << FakeServer::preauth()
<< "C: A000001 ENABLE CONDSTORE X-GOOD-IDEA"
<< "S: * ENABLED X-GOOD-IDEA"
<< "S: A000001 OK Enabled";
QStringList reqCapabilities = {QStringLiteral("CONDSTORE"), QStringLiteral("X-GOOD-IDEA")};
QStringList supportedCaps = {QStringLiteral("X-GOOD-IDEA")};
QTest::newRow("one feature") << scenario << reqCapabilities << supportedCaps;
scenario.clear();
scenario << FakeServer::preauth()
<< "C: A000001 ENABLE FEATURE1 FEATURE2"
<< "S: * ENABLED FEATURE1 FEATURE2"
<< "S: A000001 OK Enabled";
reqCapabilities = QStringList{QStringLiteral("FEATURE1"), QStringLiteral("FEATURE2")};
supportedCaps = QStringList{QStringLiteral("FEATURE1"), QStringLiteral("FEATURE2")};
QTest::newRow("both features") << scenario << reqCapabilities << supportedCaps;
}
void testEnable()
{
QFETCH(QList<QByteArray>, scenario);
QFETCH(QStringList, reqCapabilities);
QFETCH(QStringList, supportedCaps);
FakeServer fakeServer;
fakeServer.setScenario(scenario);
fakeServer.startAndWait();
KIMAP::Session session(QStringLiteral("127.0.0.1"), 5989);
auto *job = new KIMAP::EnableJob(&session);
job->setCapabilities(reqCapabilities);
QVERIFY(job->exec());
QCOMPARE(job->enabledCapabilities(), supportedCaps);
fakeServer.quit();
}
};
QTEST_GUILESS_MAIN(EnableJobTest)
#include "enablejobtest.moc"
......@@ -12,7 +12,6 @@ set(kimap_SRCS
createjob.cpp
deleteacljob.cpp
deletejob.cpp
enablejob.cpp
expungejob.cpp
fetchjob.cpp
getacljob.cpp
......@@ -98,7 +97,6 @@ ecm_generate_headers(KIMAP_CamelCase_HEADERS
CreateJob
DeleteAclJob
DeleteJob
EnableJob
ExpungeJob
FetchJob
GetAclJob
......
/*
SPDX-FileCopyrightText: 2020 Daniel Vrátil <dvratil@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "enablejob.h"
#include <KLocalizedString>
#include "job_p.h"
#include "response_p.h"
#include "session_p.h"
#include "kimap_debug.h"
namespace KIMAP
{
class EnableJobPrivate : public JobPrivate
{
public:
using JobPrivate::JobPrivate;
QStringList reqCapabilities;
QStringList enabledCapabilities;
};
}
using namespace KIMAP;
EnableJob::EnableJob(Session *session)
: Job(*new EnableJobPrivate(session, i18n("Enable")))
{
}
EnableJob::~EnableJob() = default;
void EnableJob::setCapabilities(const QStringList &capabilities)
{
Q_D(EnableJob);
d->reqCapabilities = capabilities;
}
QStringList EnableJob::enabledCapabilities() const
{
Q_D(const EnableJob);
return d->enabledCapabilities;
}
void EnableJob::doStart()
{
Q_D(EnableJob);
d->tags << d->sessionInternal()->sendCommand("ENABLE", d->reqCapabilities.join(QLatin1Char{' '}).toLatin1());
}
void EnableJob::handleResponse(const Response &response)
{
Q_D(EnableJob);
if (handleErrorReplies(response) == NotHandled) {
if (response.content.size() >= 2) {
for (int i = 2; i < response.content.size(); ++i) {
d->enabledCapabilities.push_back(QString::fromLatin1(response.content[i].toString()));
}
} else {
qCDebug(KIMAP_LOG) << response.toString();
}
}
}
/*
SPDX-FileCopyrightText: 2020 Daniel Vrátil <dvratil@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KIMAP_ENABLEJOB_H
#define KIMAP_ENABLEJOB_H
#include "kimap_export.h"
#include "job.h"
#include <QStringList>
namespace KIMAP
{
class Session;
struct Response;
class EnableJobPrivate;
/**
* Job to enable additional IMAP capabilities.
*
* Requires server to implement the IMAP ENABLE Extension (RFC5161). The
* new capabilities to enable will be specified by the user. The user is
* responsible for making sure the capabilities are supported by the server.
*
* @since 5.15
*/
class KIMAP_EXPORT EnableJob : public Job
{
Q_OBJECT
Q_DECLARE_PRIVATE(EnableJob)
friend class SessionPrivate;
public:
explicit EnableJob(Session *session);
~EnableJob() override;
/**
* List of server capabilities to enable.
*/
void setCapabilities(const QStringList &capabilities);
/**
* List of capabilities that were successfully enabled on the server.
*/
Q_REQUIRED_RESULT QStringList enabledCapabilities() const;
protected:
void doStart() override;
void handleResponse(const Response &response) override;
};
}
#endif
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