Commit 232850d2 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Rename internal KIMAP::Message to KIMAP::Response

It holds an IMAP response, which is not necessarilly a message,
but also frees the name to be used in public API later to
represent an actual message.
parent 8ff31452
......@@ -19,7 +19,7 @@
#include <qtest.h>
#include "imapstreamparser.h"
#include <message_p.h>
#include <response_p.h>
#include <QtTest>
......@@ -33,7 +33,7 @@ class StreamParserTest: public QObject
QByteArray part2;
QByteArray part3;
QByteArray part4;
QByteArray completeMessage;
QByteArray completeResponse;
QList<QByteArray> expectedList;
private Q_SLOTS:
......@@ -45,7 +45,7 @@ private Q_SLOTS:
part2 = "\nDate: Fri, 01 Nov 2013 12:31:13 +0000\n";
part3 = "body\n";
part4 = ")\n\r";
completeMessage = part1 + part2 + part3 + part4;
completeResponse = part1 + part2 + part3 + part4;
expectedList.clear();
expectedList << "FLAGS";
expectedList << "(\\Recent \\Seen)";
......@@ -68,7 +68,7 @@ private Q_SLOTS:
QByteArray buffer;
QBuffer socket(&buffer);
socket.open(QBuffer::WriteOnly);
QVERIFY(socket.write(completeMessage) != -1);
QVERIFY(socket.write(completeResponse) != -1);
QBuffer readSocket(&buffer);
readSocket.open(QBuffer::ReadOnly);
......@@ -76,17 +76,17 @@ private Q_SLOTS:
QVERIFY(parser.availableDataSize() != 0);
Message message;
QList<Message::Part> *payload = &message.content;
Response message;
QList<Response::Part> *payload = &message.content;
QVERIFY(!parser.atCommandEnd());
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //*
*payload << Response::Part(parser.readString()); //*
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //230
*payload << Response::Part(parser.readString()); //230
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //FETCH
*payload << Response::Part(parser.readString()); //FETCH
QVERIFY(parser.hasList());
*payload << Message::Part(parser.readParenthesizedList());
*payload << Response::Part(parser.readParenthesizedList());
QVERIFY(parser.atCommandEnd());
QCOMPARE(message.content.last().toList(), expectedList);
......@@ -109,23 +109,23 @@ private Q_SLOTS:
QVERIFY(parser.availableDataSize() != 0);
Message message;
QList<Message::Part> *payload = &message.content;
Response message;
QList<Response::Part> *payload = &message.content;
QVERIFY(!parser.atCommandEnd());
//We wait with writing part2 until the first part is already loaded into the buffer
QVERIFY(socket.write(part2) != -1);
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //*
*payload << Response::Part(parser.readString()); //*
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //230
*payload << Response::Part(parser.readString()); //230
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //FETCH
*payload << Response::Part(parser.readString()); //FETCH
QVERIFY(socket.write(part3) != -1);
QVERIFY(socket.write(part4) != -1);
QVERIFY(parser.hasList());
*payload << Message::Part(parser.readParenthesizedList());
*payload << Response::Part(parser.readParenthesizedList());
QVERIFY(parser.atCommandEnd());
}
......@@ -149,17 +149,17 @@ private Q_SLOTS:
QVERIFY(parser.availableDataSize() != 0);
Message message;
QList<Message::Part> *payload = &message.content;
Response message;
QList<Response::Part> *payload = &message.content;
QVERIFY(!parser.atCommandEnd());
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //*
*payload << Response::Part(parser.readString()); //*
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //33
*payload << Response::Part(parser.readString()); //33
QVERIFY(parser.hasString());
*payload << Message::Part(parser.readString()); //FETCH
*payload << Response::Part(parser.readString()); //FETCH
QVERIFY(parser.hasList());
*payload << Message::Part(parser.readParenthesizedList());
*payload << Response::Part(parser.readParenthesizedList());
QVERIFY(parser.atCommandEnd());
}
......
......@@ -19,7 +19,7 @@
#include "acljobbase.h"
#include "acljobbase_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include <KLocalizedString>
......
......@@ -29,7 +29,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class AclJobBasePrivate;
/**
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include "rfccodecs.h"
......@@ -133,11 +133,11 @@ void AppendJob::doStart()
d->tags << d->sessionInternal()->sendCommand("APPEND", parameters);
}
void AppendJob::handleResponse(const Message &response)
void AppendJob::handleResponse(const Response &response)
{
Q_D(AppendJob);
const QList<Message::Part>::ConstIterator end(response.responseCode.end());
for (QList<Message::Part>::ConstIterator it = response.responseCode.begin();
const QList<Response::Part>::ConstIterator end(response.responseCode.end());
for (QList<Response::Part>::ConstIterator it = response.responseCode.begin();
it != end; ++it) {
if (it->toString() == "APPENDUID") {
it = it + 2;
......
......@@ -29,7 +29,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class AppendJobPrivate;
/**
......@@ -126,7 +126,7 @@ public:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
}
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
namespace KIMAP
......@@ -60,7 +60,7 @@ void CapabilitiesJob::doStart()
d->tags << d->sessionInternal()->sendCommand("CAPABILITY");
}
void CapabilitiesJob::handleResponse(const Message &response)
void CapabilitiesJob::handleResponse(const Response &response)
{
Q_D(CapabilitiesJob);
if (handleErrorReplies(response) == NotHandled) {
......
......@@ -28,7 +28,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class CapabilitiesJobPrivate;
/**
......@@ -71,7 +71,7 @@ Q_SIGNALS:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
}
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
namespace KIMAP
......
......@@ -28,7 +28,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class CloseJobPrivate;
/**
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include "rfccodecs.h"
......@@ -113,12 +113,11 @@ void CopyJob::doStart()
d->tags << d->sessionInternal()->sendCommand(command, parameters);
}
void CopyJob::handleResponse(const Message &response)
void CopyJob::handleResponse(const Response &response)
{
Q_D(CopyJob);
const QList<Message::Part>::ConstIterator end(response.responseCode.end());
for (QList<Message::Part>::ConstIterator it = response.responseCode.begin();
it != end; ++it) {
for (auto it = response.responseCode.cbegin(), end = response.responseCode.cend();
it != end; ++it) {
if (it->toString() == "COPYUID") {
it = it + 3;
if (it < end) {
......
......@@ -120,7 +120,7 @@ public:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
}
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "rfccodecs.h"
#include "session_p.h"
......
......@@ -28,7 +28,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class CreateJobPrivate;
/**
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "acljobbase_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include "rfccodecs.h"
......
......@@ -28,7 +28,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class DeleteAclJobPrivate;
/**
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include "rfccodecs.h"
......
......@@ -23,7 +23,7 @@
#include "kimap_debug.h"
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
namespace KIMAP
......@@ -56,7 +56,7 @@ void ExpungeJob::doStart()
d->tags << d->sessionInternal()->sendCommand("EXPUNGE");
}
void ExpungeJob::handleResponse(const Message &response)
void ExpungeJob::handleResponse(const Response &response)
{
// Q_D(ExpungeJob);
......
......@@ -28,7 +28,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class ExpungeJobPrivate;
/**
......@@ -56,7 +56,7 @@ public:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
}
......
......@@ -24,7 +24,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
......@@ -249,7 +249,7 @@ void FetchJob::doStart()
d->tags << d->sessionInternal()->sendCommand(command, parameters);
}
void FetchJob::handleResponse(const Message &response)
void FetchJob::handleResponse(const Response &response)
{
Q_D(FetchJob);
......@@ -265,7 +265,7 @@ void FetchJob::handleResponse(const Message &response)
if (handleErrorReplies(response) == NotHandled) {
if (response.content.size() == 4 &&
response.content[2].toString() == "FETCH" &&
response.content[3].type() == Message::Part::List) {
response.content[3].type() == Response::Part::List) {
qint64 id = response.content[1].toString().toLongLong();
QList<QByteArray> content = response.content[3].toList();
......@@ -300,11 +300,11 @@ void FetchJob::handleResponse(const Message &response)
d->pendingFlags[id] << *it;
}
} else if (str == "X-GM-LABELS") {
d->pendingAttributes.insert(id, qMakePair<QByteArray, QVariant>("X-GM-LABELS", *it));
d->pendingAttributes.insert(id, { "X-GM-LABELS", *it });
} else if (str == "X-GM-THRID") {
d->pendingAttributes.insert(id, qMakePair<QByteArray, QVariant>("X-GM-THRID", *it));
d->pendingAttributes.insert(id, { "X-GM-THRID", *it });
} else if (str == "X-GM-MSGID") {
d->pendingAttributes.insert(id, qMakePair<QByteArray, QVariant>("X-GM-MSGID", *it));
d->pendingAttributes.insert(id, { "X-GM-MSGID", *it });
} else if (str == "BODYSTRUCTURE") {
int pos = 0;
d->parseBodyStructure(*it, pos, message.data());
......
......@@ -32,7 +32,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class FetchJobPrivate;
typedef QSharedPointer<KMime::Content> ContentPtr;
......@@ -397,7 +397,7 @@ Q_SIGNALS:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
private:
Q_PRIVATE_SLOT(d_func(), void emitPendings())
......
......@@ -23,7 +23,7 @@
#include "kimap_debug.h"
#include "acljobbase_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include "rfccodecs.h"
......@@ -57,7 +57,7 @@ void GetAclJob::doStart()
d->tags << d->sessionInternal()->sendCommand("GETACL", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
}
void GetAclJob::handleResponse(const Message &response)
void GetAclJob::handleResponse(const Response &response)
{
Q_D(GetAclJob);
// qCDebug(KIMAP_LOG) << response.toString();
......
......@@ -28,7 +28,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class GetAclJobPrivate;
/**
......@@ -132,7 +132,7 @@ public:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
......
......@@ -23,7 +23,7 @@
#include "kimap_debug.h"
#include "metadatajobbase_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include "rfccodecs.h"
......@@ -127,7 +127,7 @@ void GetMetaDataJob::doStart()
// qCDebug(KIMAP_LOG) << "SENT: " << command << " " << parameters;
}
void GetMetaDataJob::handleResponse(const Message &response)
void GetMetaDataJob::handleResponse(const Response &response)
{
Q_D(GetMetaDataJob);
// qCDebug(KIMAP_LOG) << "GOT: " << response.toString();
......
......@@ -28,7 +28,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class GetMetaDataJobPrivate;
/**
......@@ -255,7 +255,7 @@ public:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "quotajobbase_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
namespace KIMAP
......@@ -55,7 +55,7 @@ void GetQuotaJob::doStart()
d->tags << d->sessionInternal()->sendCommand("GETQUOTA", '\"' + d->root + '\"');
}
void GetQuotaJob::handleResponse(const Message &response)
void GetQuotaJob::handleResponse(const Response &response)
{
Q_D(GetQuotaJob);
if (handleErrorReplies(response) == NotHandled) {
......
......@@ -72,7 +72,7 @@ public:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "quotajobbase_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include "rfccodecs.h"
......@@ -57,7 +57,7 @@ void GetQuotaRootJob::doStart()
d->tags << d->sessionInternal()->sendCommand("GETQUOTAROOT", '\"' + KIMAP::encodeImapFolderName(d->mailBox.toUtf8()) + '\"');
}
void GetQuotaRootJob::handleResponse(const Message &response)
void GetQuotaRootJob::handleResponse(const Response &response)
{
Q_D(GetQuotaRootJob);
if (handleErrorReplies(response) == NotHandled) {
......
......@@ -116,7 +116,7 @@ public:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
......
......@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
namespace KIMAP
......@@ -70,7 +70,7 @@ void IdJob::doStart()
d->tags << d->sessionInternal()->sendCommand(command);
}
void IdJob::handleResponse(const Message &response)
void IdJob::handleResponse(const Response &response)
{
Q_D(IdJob);
if (handleErrorReplies(response) == NotHandled) {
......
......@@ -50,7 +50,7 @@ public:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
};
}
......
......@@ -23,7 +23,7 @@
#include <KLocalizedString>
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
namespace KIMAP
......@@ -103,7 +103,7 @@ void IdleJob::doStart()
d->tags << d->sessionInternal()->sendCommand("IDLE");
}
void IdleJob::handleResponse(const Message &response)
void IdleJob::handleResponse(const Response &response)
{
Q_D(IdleJob);
......
......@@ -32,7 +32,7 @@ namespace KIMAP
{
class Session;
struct Message;
struct Response;
class IdleJobPrivate;
/**
......@@ -130,7 +130,7 @@ Q_SIGNALS:
protected:
void doStart() override;
void handleResponse(const Message &response) override;
void handleResponse(const Response &response) override;
private:
Q_PRIVATE_SLOT(d_func(), void emitStats())
......
......@@ -19,7 +19,7 @@
#include "job.h"
#include "job_p.h"
#include "message_p.h"
#include "response_p.h"
#include "session_p.h"
#include <KLocalizedString>
......@@ -54,7 +54,7 @@ void Job::start()
d->sessionInternal()->addJob(this);
}
void Job::handleResponse(const Message &response)
void Job::handleResponse(const Response &response)
{
handleErrorReplies(response);
}
......@@ -66,7 +66,7 @@ void Job::connectionLost()
emitResult();
}
Job::HandlerResponse Job::handleErrorReplies(const Message &response)
Job::HandlerResponse Job::handleErrorReplies(const Response &response)
{
Q_D(Job);
// qCDebug(KIMAP_LOG) << response.toString();
......
......@@ -30,7 +30,7 @@ namespace KIMAP
class Session;
class SessionPrivate;
class JobPrivate;
struct Message;
struct Response;
class KIMAP_EXPORT Job : public KJob
{
......@@ -48,7 +48,7 @@ public: