From cd7287325944571e9d53b00b48abdba4c9257474 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 19 Jan 2016 14:26:45 +0100 Subject: Moved all commands in to the Commands namespace --- common/commands.cpp | 2 +- common/commands.h | 2 +- common/commands/commandcompletion.fbs | 2 +- common/commands/fetchentity.fbs | 2 +- common/commands/handshake.fbs | 2 +- common/commands/notification.fbs | 2 +- common/commands/revisionupdate.fbs | 2 +- common/commands/synchronize.fbs | 2 +- common/genericresource.cpp | 8 ++++---- common/listener.cpp | 28 ++++++++++++++-------------- common/resourceaccess.cpp | 20 ++++++++++---------- 11 files changed, 36 insertions(+), 36 deletions(-) (limited to 'common') diff --git a/common/commands.cpp b/common/commands.cpp index 16fd742..35dfb13 100644 --- a/common/commands.cpp +++ b/common/commands.cpp @@ -33,7 +33,7 @@ QByteArray name(int commandId) switch(commandId) { case UnknownCommand: return "Unknown"; - case CommandCompletion: + case CommandCompletionCommand: return "Completion"; case HandshakeCommand: return "Handshake"; diff --git a/common/commands.h b/common/commands.h index bce278c..33d5cd7 100644 --- a/common/commands.h +++ b/common/commands.h @@ -34,7 +34,7 @@ namespace Commands enum CommandIds { UnknownCommand = 0, - CommandCompletion, + CommandCompletionCommand, HandshakeCommand, RevisionUpdateCommand, SynchronizeCommand, diff --git a/common/commands/commandcompletion.fbs b/common/commands/commandcompletion.fbs index 5330b4f..de7ec14 100644 --- a/common/commands/commandcompletion.fbs +++ b/common/commands/commandcompletion.fbs @@ -1,4 +1,4 @@ -namespace Akonadi2; +namespace Akonadi2.Commands; table CommandCompletion { id: ulong; diff --git a/common/commands/fetchentity.fbs b/common/commands/fetchentity.fbs index ddca275..7a1d74d 100644 --- a/common/commands/fetchentity.fbs +++ b/common/commands/fetchentity.fbs @@ -1,4 +1,4 @@ -namespace Akonadi2; +namespace Akonadi2.Commands; table FetchEntity { revision: ulong; diff --git a/common/commands/handshake.fbs b/common/commands/handshake.fbs index 52a883a..e824715 100644 --- a/common/commands/handshake.fbs +++ b/common/commands/handshake.fbs @@ -1,4 +1,4 @@ -namespace Akonadi2; +namespace Akonadi2.Commands; table Handshake { name: string; diff --git a/common/commands/notification.fbs b/common/commands/notification.fbs index 5c810cf..89687cf 100644 --- a/common/commands/notification.fbs +++ b/common/commands/notification.fbs @@ -1,4 +1,4 @@ -namespace Akonadi2; +namespace Akonadi2.Commands; enum NotificationType : byte { Shutdown = 1, Status, Warning, Progress, Inspection } enum NotificationCode : byte { Success = 0, Failure = 1, UserCode } diff --git a/common/commands/revisionupdate.fbs b/common/commands/revisionupdate.fbs index 634bcd0..93fbe34 100644 --- a/common/commands/revisionupdate.fbs +++ b/common/commands/revisionupdate.fbs @@ -1,4 +1,4 @@ -namespace Akonadi2; +namespace Akonadi2.Commands; table RevisionUpdate { revision: ulong; diff --git a/common/commands/synchronize.fbs b/common/commands/synchronize.fbs index d2d0364..7c3ae9a 100644 --- a/common/commands/synchronize.fbs +++ b/common/commands/synchronize.fbs @@ -1,4 +1,4 @@ -namespace Akonadi2; +namespace Akonadi2.Commands; table Synchronize { sourceSync: bool; //Synchronize with source diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 40e3add..e9a6012 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp @@ -313,16 +313,16 @@ GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, c s >> expectedValue; inspect(inspectionType, inspectionId, domainType, entityId, property, expectedValue).then([=]() { Akonadi2::ResourceNotification n; - n.type = Akonadi2::NotificationType_Inspection; + n.type = Akonadi2::Commands::NotificationType_Inspection; n.id = inspectionId; - n.code = Akonadi2::NotificationCode_Success; + n.code = Akonadi2::Commands::NotificationCode_Success; emit notify(n); }, [=](int code, const QString &message) { Akonadi2::ResourceNotification n; - n.type = Akonadi2::NotificationType_Inspection; + n.type = Akonadi2::Commands::NotificationType_Inspection; n.message = message; n.id = inspectionId; - n.code = Akonadi2::NotificationCode_Failure; + n.code = Akonadi2::Commands::NotificationCode_Failure; emit notify(n); }).exec(); return KAsync::null(); diff --git a/common/listener.cpp b/common/listener.cpp index bb0a130..857e15f 100644 --- a/common/listener.cpp +++ b/common/listener.cpp @@ -211,8 +211,8 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c switch (commandId) { case Akonadi2::Commands::HandshakeCommand: { flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); - if (Akonadi2::VerifyHandshakeBuffer(verifier)) { - auto buffer = Akonadi2::GetHandshake(commandBuffer.constData()); + if (Akonadi2::Commands::VerifyHandshakeBuffer(verifier)) { + auto buffer = Akonadi2::Commands::GetHandshake(commandBuffer.constData()); client.name = buffer->name()->c_str(); } else { Warning() << "received invalid command"; @@ -221,8 +221,8 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c } case Akonadi2::Commands::SynchronizeCommand: { flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); - if (Akonadi2::VerifySynchronizeBuffer(verifier)) { - auto buffer = Akonadi2::GetSynchronize(commandBuffer.constData()); + if (Akonadi2::Commands::VerifySynchronizeBuffer(verifier)) { + auto buffer = Akonadi2::Commands::GetSynchronize(commandBuffer.constData()); Log() << QString("\tSynchronize request (id %1) from %2").arg(messageId).arg(client.name); auto timer = QSharedPointer::create(); timer->start(); @@ -303,8 +303,8 @@ qint64 Listener::lowerBoundRevision() void Listener::quit() { //Broadcast shutdown notifications to open clients, so they don't try to restart the resource - auto command = Akonadi2::CreateNotification(m_fbb, Akonadi2::NotificationType::NotificationType_Shutdown); - Akonadi2::FinishNotificationBuffer(m_fbb, command); + auto command = Akonadi2::Commands::CreateNotification(m_fbb, Akonadi2::Commands::NotificationType::NotificationType_Shutdown); + Akonadi2::Commands::FinishNotificationBuffer(m_fbb, command); for (Client &client : m_connections) { if (client.socket && client.socket->isOpen()) { Akonadi2::Commands::write(client.socket, ++m_messageId, Akonadi2::Commands::NotificationCommand, m_fbb); @@ -359,9 +359,9 @@ void Listener::sendCommandCompleted(QLocalSocket *socket, uint messageId, bool s return; } - auto command = Akonadi2::CreateCommandCompletion(m_fbb, messageId, success); - Akonadi2::FinishCommandCompletionBuffer(m_fbb, command); - Akonadi2::Commands::write(socket, ++m_messageId, Akonadi2::Commands::CommandCompletion, m_fbb); + auto command = Akonadi2::Commands::CreateCommandCompletion(m_fbb, messageId, success); + Akonadi2::Commands::FinishCommandCompletionBuffer(m_fbb, command); + Akonadi2::Commands::write(socket, ++m_messageId, Akonadi2::Commands::CommandCompletionCommand, m_fbb); m_fbb.Clear(); } @@ -372,8 +372,8 @@ void Listener::refreshRevision(qint64 revision) void Listener::updateClientsWithRevision(qint64 revision) { - auto command = Akonadi2::CreateRevisionUpdate(m_fbb, revision); - Akonadi2::FinishRevisionUpdateBuffer(m_fbb, command); + auto command = Akonadi2::Commands::CreateRevisionUpdate(m_fbb, revision); + Akonadi2::Commands::FinishRevisionUpdateBuffer(m_fbb, command); for (const Client &client: m_connections) { if (!client.socket || !client.socket->isValid()) { @@ -390,13 +390,13 @@ void Listener::notify(const Akonadi2::ResourceNotification ¬ification) { auto messageString = m_fbb.CreateString(notification.message.toUtf8().constData(), notification.message.toUtf8().size()); auto idString = m_fbb.CreateString(notification.id.constData(), notification.id.size()); - Akonadi2::NotificationBuilder builder(m_fbb); - builder.add_type(static_cast(notification.type)); + Akonadi2::Commands::NotificationBuilder builder(m_fbb); + builder.add_type(static_cast(notification.type)); builder.add_code(notification.code); builder.add_identifier(idString); builder.add_message(messageString); auto command = builder.Finish(); - Akonadi2::FinishNotificationBuffer(m_fbb, command); + Akonadi2::Commands::FinishNotificationBuffer(m_fbb, command); for (Client &client : m_connections) { if (client.socket && client.socket->isOpen()) { Akonadi2::Commands::write(client.socket, ++m_messageId, Akonadi2::Commands::NotificationCommand, m_fbb); diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 6540e98..e3ffe64 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp @@ -298,8 +298,8 @@ KAsync::Job ResourceAccess::synchronizeResource(bool sourceSync, bool loca { Trace() << "Sending synchronize command: " << sourceSync << localSync; flatbuffers::FlatBufferBuilder fbb; - auto command = Akonadi2::CreateSynchronize(fbb, sourceSync, localSync); - Akonadi2::FinishSynchronizeBuffer(fbb, command); + auto command = Akonadi2::Commands::CreateSynchronize(fbb, sourceSync, localSync); + Akonadi2::Commands::FinishSynchronizeBuffer(fbb, command); open(); return sendCommand(Commands::SynchronizeCommand, fbb); } @@ -457,8 +457,8 @@ void ResourceAccess::connected() { flatbuffers::FlatBufferBuilder fbb; auto name = fbb.CreateString(QString("PID: %1 ResourceAccess: %2").arg(QCoreApplication::applicationPid()).arg(reinterpret_cast(this)).toLatin1()); - auto command = Akonadi2::CreateHandshake(fbb, name); - Akonadi2::FinishHandshakeBuffer(fbb, command); + auto command = Akonadi2::Commands::CreateHandshake(fbb, name); + Akonadi2::Commands::FinishHandshakeBuffer(fbb, command); Commands::write(d->socket.data(), ++d->messageId, Commands::HandshakeCommand, fbb); } @@ -523,14 +523,14 @@ bool ResourceAccess::processMessageBuffer() switch (commandId) { case Commands::RevisionUpdateCommand: { - auto buffer = GetRevisionUpdate(d->partialMessageBuffer.constData() + headerSize); + auto buffer = Commands::GetRevisionUpdate(d->partialMessageBuffer.constData() + headerSize); log(QString("Revision updated to: %1").arg(buffer->revision())); emit revisionChanged(buffer->revision()); break; } - case Commands::CommandCompletion: { - auto buffer = GetCommandCompletion(d->partialMessageBuffer.constData() + headerSize); + case Commands::CommandCompletionCommand: { + auto buffer = Commands::GetCommandCompletion(d->partialMessageBuffer.constData() + headerSize); log(QString("Command with messageId %1 completed %2").arg(buffer->id()).arg(buffer->success() ? "sucessfully" : "unsuccessfully")); d->completeCommands << buffer->id(); @@ -541,13 +541,13 @@ bool ResourceAccess::processMessageBuffer() break; } case Commands::NotificationCommand: { - auto buffer = GetNotification(d->partialMessageBuffer.constData() + headerSize); + auto buffer = Commands::GetNotification(d->partialMessageBuffer.constData() + headerSize); switch (buffer->type()) { - case Akonadi2::NotificationType::NotificationType_Shutdown: + case Akonadi2::Commands::NotificationType::NotificationType_Shutdown: Log(d->resourceInstanceIdentifier) << "Received shutdown notification."; close(); break; - case Akonadi2::NotificationType::NotificationType_Inspection: { + case Akonadi2::Commands::NotificationType::NotificationType_Inspection: { Log(d->resourceInstanceIdentifier) << "Received inspection notification."; ResourceNotification n; if (buffer->identifier()) { -- cgit v1.2.3