Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit c37a236b authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Rename Handlers to match the entity, operation and command names

Historically, the protocol command handlers were called after the IMAP
commands from old ASAP. Most of the names do not map to names of
commands in the new protocol, some of them are even quite confusing
(like Remove and Delete handlers). This change renames all handlers
to match their purpose and map more nicely to names of the protocol
commands as well as the client-side jobs.
parent 876ae1e4
......@@ -90,12 +90,12 @@ add_server_test(collectionstatisticstest.cpp)
if (SQLITE_FOUND) # tests using the fake server need the QSQLITE3 plugin
add_server_test(partstreamertest.cpp)
add_server_test(akappendhandlertest.cpp)
add_server_test(linkhandlertest.cpp)
add_server_test(listhandlertest.cpp)
add_server_test(modifyhandlertest.cpp)
add_server_test(movehandlertest.cpp)
add_server_test(createhandlertest.cpp)
add_server_test(itemcreatehandlertest.cpp)
add_server_test(itemlinkhandlertest.cpp)
add_server_test(itemmovehandlertest.cpp)
add_server_test(collectioncreatehandlertest.cpp)
add_server_test(collectionfetchhandlertest.cpp)
add_server_test(collectionmodifyhandlertest.cpp)
add_server_test(collectionreferencetest.cpp)
add_server_test(searchtest.cpp akonadiprivate)
add_server_test(relationhandlertest.cpp akonadiprivate)
......
......@@ -17,7 +17,6 @@
02110-1301, USA.
*/
#include <QObject>
#include <handler/create.h>
#include <storage/entity.h>
......@@ -33,12 +32,12 @@
using namespace Akonadi;
using namespace Akonadi::Server;
class CreateHandlerTest : public QObject
class CollectionCreateHandlerTest : public QObject
{
Q_OBJECT
public:
CreateHandlerTest()
CollectionCreateHandlerTest()
{
try {
FakeAkonadiServer::instance()->init();
......@@ -48,7 +47,7 @@ public:
}
}
~CreateHandlerTest()
~CollectionCreateHandlerTest()
{
FakeAkonadiServer::instance()->quit();
}
......@@ -189,6 +188,6 @@ private Q_SLOTS:
};
AKTEST_FAKESERVER_MAIN(CreateHandlerTest)
AKTEST_FAKESERVER_MAIN(CollectionCreateHandlerTest)
#include "createhandlertest.moc"
#include "collectioncreatehandlertest.moc"
......@@ -19,9 +19,6 @@
#include <QObject>
#include <handler/list.h>
#include <private/scope_p.h>
#include "fakeakonadiserver.h"
......@@ -35,12 +32,12 @@
using namespace Akonadi;
using namespace Akonadi::Server;
class ListHandlerTest : public QObject
class CollectionFetchHandlerTest : public QObject
{
Q_OBJECT
public:
ListHandlerTest()
CollectionFetchHandlerTest()
: QObject()
{
try {
......@@ -68,7 +65,7 @@ public:
}
}
~ListHandlerTest()
~CollectionFetchHandlerTest()
{
FakeAkonadiServer::instance()->quit();
}
......@@ -586,6 +583,6 @@ private Q_SLOTS:
};
AKTEST_FAKESERVER_MAIN(ListHandlerTest)
AKTEST_FAKESERVER_MAIN(CollectionFetchHandlerTest)
#include "listhandlertest.moc"
#include "collectionfetchhandlertest.moc"
......@@ -17,7 +17,6 @@
02110-1301, USA.
*/
#include <QObject>
#include <handler/modify.h>
#include <storage/entity.h>
......@@ -33,12 +32,12 @@
using namespace Akonadi;
using namespace Akonadi::Server;
class ModifyHandlerTest : public QObject
class CollectionModifyHandlerTest : public QObject
{
Q_OBJECT
public:
ModifyHandlerTest()
CollectionModifyHandlerTest()
{
try {
FakeAkonadiServer::instance()->init();
......@@ -48,7 +47,7 @@ public:
}
}
~ModifyHandlerTest()
~CollectionModifyHandlerTest()
{
FakeAkonadiServer::instance()->quit();
}
......@@ -201,6 +200,6 @@ private Q_SLOTS:
};
AKTEST_FAKESERVER_MAIN(ModifyHandlerTest)
AKTEST_FAKESERVER_MAIN(CollectionModifyHandlerTest)
#include "modifyhandlertest.moc"
#include "collectionmodifyhandlertest.moc"
......@@ -17,7 +17,6 @@
02110-1301, USA.
*/
#include <QObject>
#include <handler/modify.h>
#include <storage/entity.h>
......
......@@ -26,26 +26,27 @@
#include <typeinfo>
#include "handler.h"
#include "handler/create.h"
#include "handler/list.h"
#include "handler/searchpersistent.h"
#include "handler/search.h"
#include "handler/fetch.h"
#include "handler/store.h"
#include "handler/status.h"
#include "handler/delete.h"
#include "handler/modify.h"
#include "handler/transaction.h"
#include "handler/akappend.h"
#include "handler/copy.h"
#include "handler/colcopy.h"
#include "handler/link.h"
#include "handler/resourceselect.h"
#include "handler/remove.h"
#include "handler/move.h"
#include "handler/colmove.h"
#include "handler/login.h"
#include "handler/logout.h"
#include "handler/collectioncreatehandler.h"
#include "handler/collectionfetchhandler.h"
#include "handler/collectionstatsfetchhandler.h"
#include "handler/collectiondeletehandler.h"
#include "handler/collectionmodifyhandler.h"
#include "handler/collectioncopyhandler.h"
#include "handler/collectiondeletehandler.h"
#include "handler/collectionmovehandler.h"
#include "handler/searchcreatehandler.h"
#include "handler/searchhandler.h"
#include "handler/itemfetchhandler.h"
#include "handler/itemdeletehandler.h"
#include "handler/itemmodifyhandler.h"
#include "handler/itemcreatehandler.h"
#include "handler/itemcopyhandler.h"
#include "handler/itemlinkhandler.h"
#include "handler/itemmovehandler.h"
#include "handler/resourceselecthandler.h"
#include "handler/transactionhandler.h"
#include "handler/loginhandler.h"
#include "handler/logouthandler.h"
using namespace Akonadi;
using namespace Akonadi::Server;
......@@ -64,34 +65,34 @@ private:
void addAuthCommands()
{
MAKE_CMD_ROW(Protocol::Command::CreateCollection, Create)
MAKE_CMD_ROW(Protocol::Command::FetchCollections, List)
MAKE_CMD_ROW(Protocol::Command::StoreSearch, SearchPersistent)
MAKE_CMD_ROW(Protocol::Command::Search, Search)
MAKE_CMD_ROW(Protocol::Command::FetchItems, Fetch)
MAKE_CMD_ROW(Protocol::Command::ModifyItems, Store)
MAKE_CMD_ROW(Protocol::Command::FetchCollectionStats, Status)
MAKE_CMD_ROW(Protocol::Command::DeleteCollection, Delete)
MAKE_CMD_ROW(Protocol::Command::ModifyCollection, Modify)
MAKE_CMD_ROW(Protocol::Command::CreateCollection, CollectionCreateHandler)
MAKE_CMD_ROW(Protocol::Command::FetchCollections, CollectionFetchHandler)
MAKE_CMD_ROW(Protocol::Command::StoreSearch, SearchCreateHandler)
MAKE_CMD_ROW(Protocol::Command::Search, SearchHandler)
MAKE_CMD_ROW(Protocol::Command::FetchItems, ItemFetchHandler)
MAKE_CMD_ROW(Protocol::Command::ModifyItems, ItemModifyHandler)
MAKE_CMD_ROW(Protocol::Command::FetchCollectionStats, CollectionStatsFetchHandler)
MAKE_CMD_ROW(Protocol::Command::DeleteCollection, CollectionDeleteHandler)
MAKE_CMD_ROW(Protocol::Command::ModifyCollection, CollectionModifyHandler)
MAKE_CMD_ROW(Protocol::Command::Transaction, TransactionHandler)
MAKE_CMD_ROW(Protocol::Command::CreateItem, AkAppend)
MAKE_CMD_ROW(Protocol::Command::CopyItems, Copy)
MAKE_CMD_ROW(Protocol::Command::CopyCollection, ColCopy)
MAKE_CMD_ROW(Protocol::Command::LinkItems, Link)
MAKE_CMD_ROW(Protocol::Command::SelectResource, ResourceSelect)
MAKE_CMD_ROW(Protocol::Command::DeleteItems, Remove)
MAKE_CMD_ROW(Protocol::Command::MoveItems, Move)
MAKE_CMD_ROW(Protocol::Command::MoveCollection, ColMove)
MAKE_CMD_ROW(Protocol::Command::CreateItem, ItemCreateHandler)
MAKE_CMD_ROW(Protocol::Command::CopyItems, ItemCopyHandler)
MAKE_CMD_ROW(Protocol::Command::CopyCollection, CollectionCopyHandler)
MAKE_CMD_ROW(Protocol::Command::LinkItems, ItemLinkHandler)
MAKE_CMD_ROW(Protocol::Command::SelectResource, ResourceSelectHandler)
MAKE_CMD_ROW(Protocol::Command::DeleteItems, ItemDeleteHandler)
MAKE_CMD_ROW(Protocol::Command::MoveItems, ItemMoveHandler)
MAKE_CMD_ROW(Protocol::Command::MoveCollection, CollectionMoveHandler)
}
void addNonAuthCommands()
{
MAKE_CMD_ROW(Protocol::Command::Login, Login)
MAKE_CMD_ROW(Protocol::Command::Login, LoginHandler)
}
void addAlwaysCommands()
{
MAKE_CMD_ROW(Protocol::Command::Logout, Logout)
MAKE_CMD_ROW(Protocol::Command::Logout, LogoutHandler)
}
void addInvalidCommands()
......
......@@ -20,7 +20,6 @@
#include <QObject>
#include <QSettings>
#include <handler/akappend.h>
#include <storage/selectquerybuilder.h>
#include <private/scope_p.h>
......@@ -41,12 +40,12 @@ Q_DECLARE_METATYPE(QVector<Flag>)
Q_DECLARE_METATYPE(QVector<FakePart>)
Q_DECLARE_METATYPE(QVector<FakeTag>)
class AkAppendHandlerTest : public QObject
class ItemCreateHandlerTest : public QObject
{
Q_OBJECT
public:
AkAppendHandlerTest()
ItemCreateHandlerTest()
{
// Effectively disable external payload parts, we have a dedicated unit-test
// for that
......@@ -62,7 +61,7 @@ public:
}
}
~AkAppendHandlerTest()
~ItemCreateHandlerTest()
{
FakeAkonadiServer::instance()->quit();
}
......@@ -206,7 +205,7 @@ public:
}
private Q_SLOTS:
void testAkAppend_data()
void testItemCreate_data()
{
using Notifications = QVector<Protocol::ItemChangeNotificationPtr>;
......@@ -806,7 +805,7 @@ private Q_SLOTS:
<< flags << tags << uidnext << datetime << false;
}
void testAkAppend()
void testItemCreate()
{
QFETCH(TestScenario::List, scenarios);
QFETCH(QVector<Protocol::ItemChangeNotificationPtr>, notifications);
......@@ -901,7 +900,7 @@ private Q_SLOTS:
}
};
AKTEST_FAKESERVER_MAIN(AkAppendHandlerTest)
AKTEST_FAKESERVER_MAIN(ItemCreateHandlerTest)
#include "akappendhandlertest.moc"
#include "itemcreatehandlertest.moc"
......@@ -19,8 +19,6 @@
#include <QObject>
#include <handler/link.h>
#include "fakeakonadiserver.h"
#include <shared/aktest.h>
#include "entities.h"
......@@ -33,12 +31,12 @@
using namespace Akonadi;
using namespace Akonadi::Server;
class LinkHandlerTest : public QObject
class ItemLinkHandlerTest : public QObject
{
Q_OBJECT
public:
LinkHandlerTest()
ItemLinkHandlerTest()
{
qRegisterMetaType<Akonadi::Protocol::ChangeNotificationList>();
......@@ -50,7 +48,7 @@ public:
}
}
~LinkHandlerTest()
~ItemLinkHandlerTest()
{
FakeAkonadiServer::instance()->quit();
}
......@@ -286,6 +284,6 @@ private Q_SLOTS:
};
AKTEST_FAKESERVER_MAIN(LinkHandlerTest)
AKTEST_FAKESERVER_MAIN(ItemLinkHandlerTest)
#include "linkhandlertest.moc"
#include "itemlinkhandlertest.moc"
......@@ -17,7 +17,6 @@
02110-1301, USA.
*/
#include <QObject>
#include <handler/move.h>
#include <storage/entity.h>
......@@ -33,12 +32,12 @@
using namespace Akonadi;
using namespace Akonadi::Server;
class MoveHandlerTest : public QObject
class ItemMoveHandlerTest : public QObject
{
Q_OBJECT
public:
MoveHandlerTest()
ItemMoveHandlerTest()
{
try {
FakeAkonadiServer::instance()->init();
......@@ -48,7 +47,7 @@ public:
}
}
~MoveHandlerTest()
~ItemMoveHandlerTest()
{
FakeAkonadiServer::instance()->quit();
}
......@@ -149,7 +148,7 @@ private Q_SLOTS:
}
};
AKTEST_FAKESERVER_MAIN(MoveHandlerTest)
AKTEST_FAKESERVER_MAIN(ItemMoveHandlerTest)
#include "movehandlertest.moc"
#include "itemmovehandlertest.moc"
......@@ -49,37 +49,37 @@ set(libakonadiserver_SRCS
handlerhelper.cpp
intervalcheck.cpp
collectionreferencemanager.cpp
handler/akappend.cpp
handler/copy.cpp
handler/colcopy.cpp
handler/colmove.cpp
handler/create.cpp
handler/delete.cpp
handler/fetch.cpp
handler/fetchhelper.cpp
handler/link.cpp
handler/list.cpp
handler/login.cpp
handler/logout.cpp
handler/modify.cpp
handler/move.cpp
handler/remove.cpp
handler/resourceselect.cpp
handler/relationstore.cpp
handler/relationremove.cpp
handler/relationfetch.cpp
handler/search.cpp
handler/collectioncopyhandler.cpp
handler/collectioncreatehandler.cpp
handler/collectiondeletehandler.cpp
handler/collectionfetchhandler.cpp
handler/collectionmodifyhandler.cpp
handler/collectionmovehandler.cpp
handler/collectionstatsfetchhandler.cpp
handler/itemcopyhandler.cpp
handler/itemcreatehandler.cpp
handler/itemdeletehandler.cpp
handler/itemfetchhandler.cpp
handler/itemfetchhelper.cpp
handler/itemlinkhandler.cpp
handler/itemmodifyhandler.cpp
handler/itemmovehandler.cpp
handler/loginhandler.cpp
handler/logouthandler.cpp
handler/relationfetchhandler.cpp
handler/relationmodifyhandler.cpp
handler/relationremovehandler.cpp
handler/resourceselecthandler.cpp
handler/searchhandler.cpp
handler/searchhelper.cpp
handler/searchpersistent.cpp
handler/searchresult.cpp
handler/status.cpp
handler/store.cpp
handler/tagappend.cpp
handler/tagfetch.cpp
handler/searchcreatehandler.cpp
handler/searchresulthandler.cpp
handler/tagcreatehandler.cpp
handler/tagdeletehandler.cpp
handler/tagfetchhandler.cpp
handler/tagfetchhelper.cpp
handler/tagremove.cpp
handler/tagstore.cpp
handler/transaction.cpp
handler/tagmodifyhandler.cpp
handler/transactionhandler.cpp
search/agentsearchengine.cpp
search/agentsearchinstance.cpp
search/searchtaskmanager.cpp
......
......@@ -23,35 +23,34 @@
#include "connection.h"
#include "handler/akappend.h"
#include "handler/copy.h"
#include "handler/colcopy.h"
#include "handler/colmove.h"
#include "handler/create.h"
#include "handler/delete.h"
#include "handler/fetch.h"
#include "handler/link.h"
#include "handler/list.h"
#include "handler/login.h"
#include "handler/logout.h"
#include "handler/modify.h"
#include "handler/move.h"
#include "handler/remove.h"
#include "handler/resourceselect.h"
#include "handler/search.h"
#include "handler/searchpersistent.h"
#include "handler/searchresult.h"
#include "handler/status.h"
#include "handler/store.h"
#include "handler/transaction.h"
#include "handler/tagappend.h"
#include "handler/tagfetch.h"
#include "handler/tagremove.h"
#include "handler/tagstore.h"
#include "handler/relationstore.h"
#include "handler/relationremove.h"
#include "handler/relationfetch.h"
#include "handler/collectioncopyhandler.h"
#include "handler/collectioncreatehandler.h"
#include "handler/collectiondeletehandler.h"
#include "handler/collectionfetchhandler.h"
#include "handler/collectionmodifyhandler.h"
#include "handler/collectionmovehandler.h"
#include "handler/collectionstatsfetchhandler.h"
#include "handler/itemcopyhandler.h"
#include "handler/itemcreatehandler.h"
#include "handler/itemdeletehandler.h"
#include "handler/itemfetchhandler.h"
#include "handler/itemlinkhandler.h"
#include "handler/itemmodifyhandler.h"
#include "handler/itemmovehandler.h"
#include "handler/loginhandler.h"
#include "handler/logouthandler.h"
#include "handler/relationfetchhandler.h"
#include "handler/relationremovehandler.h"
#include "handler/relationmodifyhandler.h"
#include "handler/resourceselecthandler.h"
#include "handler/searchcreatehandler.h"
#include "handler/searchhandler.h"
#include "handler/searchresulthandler.h"
#include "handler/tagcreatehandler.h"
#include "handler/tagdeletehandler.h"
#include "handler/tagfetchhandler.h"
#include "handler/tagmodifyhandler.h"
#include "handler/transactionhandler.h"
#include "storage/querybuilder.h"
using namespace Akonadi;
......@@ -61,7 +60,7 @@ Handler *Handler::findHandlerForCommandNonAuthenticated(Protocol::Command::Type
{
// allowed are LOGIN
if (cmd == Protocol::Command::Login) {
return new Login();
return new LoginHandler();
}
return nullptr;
......@@ -71,7 +70,7 @@ Handler *Handler::findHandlerForCommandAlwaysAllowed(Protocol::Command::Type cmd
{
// allowed is LOGOUT
if (cmd == Protocol::Command::Logout) {
return new Logout();
return new LogoutHandler();
}
return nullptr;
}
......@@ -100,60 +99,60 @@ Handler *Handler::findHandlerForCommandAuthenticated(Protocol::Command::Type cmd
return new TransactionHandler();
case Protocol::Command::CreateItem:
return new AkAppend();
return new ItemCreateHandler();
case Protocol::Command::CopyItems:
return new Copy();
return new ItemCopyHandler();
case Protocol::Command::DeleteItems:
return new Remove();
return new ItemDeleteHandler();
case Protocol::Command::FetchItems:
return new Fetch();
return new ItemFetchHandler();
case Protocol::Command::LinkItems:
return new Link();
return new ItemLinkHandler();
case Protocol::Command::ModifyItems:
return new Store();
return new ItemModifyHandler();
case Protocol::Command::MoveItems:
return new Move();
return new ItemMoveHandler();
case Protocol::Command::CreateCollection:
return new Create();
return new CollectionCreateHandler();
case Protocol::Command::CopyCollection:
return new ColCopy();
return new CollectionCopyHandler();
case Protocol::Command::DeleteCollection:
return new Delete();
return new CollectionDeleteHandler();
case Protocol::Command::FetchCollections:
return new List();
return new CollectionFetchHandler();
case Protocol::Command::FetchCollectionStats:
return new Status();
return new CollectionStatsFetchHandler();
case Protocol::Command::ModifyCollection:
return new Modify();
return new CollectionModifyHandler();
case Protocol::Command::MoveCollection:
return new ColMove();
return new CollectionMoveHandler();
case Protocol::Command::Search:
return new Search();
return new SearchHandler();
case Protocol::Command::SearchResult:
return new SearchResult();
return new SearchResultHandler();
case Protocol::Command::StoreSearch:
return new SearchPersistent();
return new SearchCreateHandler();
case Protocol::Command::CreateTag:
return new TagAppend();
return new TagCreateHandler();
case Protocol::Command::DeleteTag:
return new TagRemove();
return new TagDeleteHandler();
case Protocol::Command::FetchTags:
return new TagFetch();
return new TagFetchHandler();
case Protocol::Command::ModifyTag:
return new TagStore();
return new TagModifyHandler();
case Protocol::Command::FetchRelations:
return new RelationFetch();
return new RelationFetchHandler();
case Protocol::Command::ModifyRelation:
return new RelationStore();
return new RelationModifyHandler();
case Protocol::Command::RemoveRelations:
return new RelationRemove();
return new RelationRemoveHandler();
case Protocol::Command::SelectResource:
return new ResourceSelect();
return new ResourceSelectHandler();
case Protocol::Command::StreamPayload:
Q_ASSERT_X(cmd != Protocol::Command::StreamPayload, __FUNCTION__,
......
......@@ -17,7 +17,7 @@
02110-1301, USA.
*/
#include "colcopy.h"
#include "collectioncopyhandler.h"
#include "connection.h"
#include "handlerhelper.h"
......@@ -30,7 +30,7 @@
using namespace Akonadi;
using namespace Akonadi::Server;
bool ColCopy::copyCollection(const Collection &source, const Collection &target)
bool CollectionCopyHandler::copyCollection(const Collection &source, const Collection &target)
{
if (!CollectionQueryHelper::canBeMovedTo(source, target)) {
// We don't accept source==target, or source being an ancestor of target.
......@@ -82,7 +82,7 @@ bool ColCopy::copyCollection(const Collection &source, const Collection &target)
return true;
}
bool ColCopy::parseStream()
bool CollectionCopyHandler::parseStream()
{
const auto &cmd = Protocol::cmdCast<Protocol::CopyCollectionCommand>(m_command);
......@@ -106,7 +106,7 @@ bool ColCopy::parseStream()
return failureResponse(retriever.lastError());
}
Transaction transaction(storageBackend(), QStringLiteral("COLCOPY"));
Transaction transaction(storageBackend(), QStringLiteral("CollectionCopyHandler"));
if (!copyCollection(source, target)) {
return failureResponse(QStringLiteral("Failed to copy collection"));
......
......@@ -17,10 +17,10 @@
02110-1301, USA.
*/
#ifndef AKONADI_COLCOPY_H
#define AKONADI_COLCOPY_H
#ifndef AKONADI_COLLECTIONCOPYHANDLER_H_
#define AKONADI_COLLECTIONCOPYHANDLER_H_
#include "handler/copy.h"
#include "handler/itemcopyhandler.h"