summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/commands.cpp2
-rw-r--r--common/commands.h2
-rw-r--r--common/commands/commandcompletion.fbs2
-rw-r--r--common/commands/fetchentity.fbs2
-rw-r--r--common/commands/handshake.fbs2
-rw-r--r--common/commands/notification.fbs2
-rw-r--r--common/commands/revisionupdate.fbs2
-rw-r--r--common/commands/synchronize.fbs2
-rw-r--r--common/genericresource.cpp8
-rw-r--r--common/listener.cpp28
-rw-r--r--common/resourceaccess.cpp20
-rw-r--r--tests/resourcecommunicationtest.cpp4
12 files changed, 38 insertions, 38 deletions
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)
33 switch(commandId) { 33 switch(commandId) {
34 case UnknownCommand: 34 case UnknownCommand:
35 return "Unknown"; 35 return "Unknown";
36 case CommandCompletion: 36 case CommandCompletionCommand:
37 return "Completion"; 37 return "Completion";
38 case HandshakeCommand: 38 case HandshakeCommand:
39 return "Handshake"; 39 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
34 34
35enum CommandIds { 35enum CommandIds {
36 UnknownCommand = 0, 36 UnknownCommand = 0,
37 CommandCompletion, 37 CommandCompletionCommand,
38 HandshakeCommand, 38 HandshakeCommand,
39 RevisionUpdateCommand, 39 RevisionUpdateCommand,
40 SynchronizeCommand, 40 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 @@
1namespace Akonadi2; 1namespace Akonadi2.Commands;
2 2
3table CommandCompletion { 3table CommandCompletion {
4 id: ulong; 4 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 @@
1namespace Akonadi2; 1namespace Akonadi2.Commands;
2 2
3table FetchEntity { 3table FetchEntity {
4 revision: ulong; 4 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 @@
1namespace Akonadi2; 1namespace Akonadi2.Commands;
2 2
3table Handshake { 3table Handshake {
4 name: string; 4 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 @@
1namespace Akonadi2; 1namespace Akonadi2.Commands;
2 2
3enum NotificationType : byte { Shutdown = 1, Status, Warning, Progress, Inspection } 3enum NotificationType : byte { Shutdown = 1, Status, Warning, Progress, Inspection }
4enum NotificationCode : byte { Success = 0, Failure = 1, UserCode } 4enum 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 @@
1namespace Akonadi2; 1namespace Akonadi2.Commands;
2 2
3table RevisionUpdate { 3table RevisionUpdate {
4 revision: ulong; 4 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 @@
1namespace Akonadi2; 1namespace Akonadi2.Commands;
2 2
3table Synchronize { 3table Synchronize {
4 sourceSync: bool; //Synchronize with source 4 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
313 s >> expectedValue; 313 s >> expectedValue;
314 inspect(inspectionType, inspectionId, domainType, entityId, property, expectedValue).then<void>([=]() { 314 inspect(inspectionType, inspectionId, domainType, entityId, property, expectedValue).then<void>([=]() {
315 Akonadi2::ResourceNotification n; 315 Akonadi2::ResourceNotification n;
316 n.type = Akonadi2::NotificationType_Inspection; 316 n.type = Akonadi2::Commands::NotificationType_Inspection;
317 n.id = inspectionId; 317 n.id = inspectionId;
318 n.code = Akonadi2::NotificationCode_Success; 318 n.code = Akonadi2::Commands::NotificationCode_Success;
319 emit notify(n); 319 emit notify(n);
320 }, [=](int code, const QString &message) { 320 }, [=](int code, const QString &message) {
321 Akonadi2::ResourceNotification n; 321 Akonadi2::ResourceNotification n;
322 n.type = Akonadi2::NotificationType_Inspection; 322 n.type = Akonadi2::Commands::NotificationType_Inspection;
323 n.message = message; 323 n.message = message;
324 n.id = inspectionId; 324 n.id = inspectionId;
325 n.code = Akonadi2::NotificationCode_Failure; 325 n.code = Akonadi2::Commands::NotificationCode_Failure;
326 emit notify(n); 326 emit notify(n);
327 }).exec(); 327 }).exec();
328 return KAsync::null<void>(); 328 return KAsync::null<void>();
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
211 switch (commandId) { 211 switch (commandId) {
212 case Akonadi2::Commands::HandshakeCommand: { 212 case Akonadi2::Commands::HandshakeCommand: {
213 flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); 213 flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size());
214 if (Akonadi2::VerifyHandshakeBuffer(verifier)) { 214 if (Akonadi2::Commands::VerifyHandshakeBuffer(verifier)) {
215 auto buffer = Akonadi2::GetHandshake(commandBuffer.constData()); 215 auto buffer = Akonadi2::Commands::GetHandshake(commandBuffer.constData());
216 client.name = buffer->name()->c_str(); 216 client.name = buffer->name()->c_str();
217 } else { 217 } else {
218 Warning() << "received invalid command"; 218 Warning() << "received invalid command";
@@ -221,8 +221,8 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c
221 } 221 }
222 case Akonadi2::Commands::SynchronizeCommand: { 222 case Akonadi2::Commands::SynchronizeCommand: {
223 flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); 223 flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size());
224 if (Akonadi2::VerifySynchronizeBuffer(verifier)) { 224 if (Akonadi2::Commands::VerifySynchronizeBuffer(verifier)) {
225 auto buffer = Akonadi2::GetSynchronize(commandBuffer.constData()); 225 auto buffer = Akonadi2::Commands::GetSynchronize(commandBuffer.constData());
226 Log() << QString("\tSynchronize request (id %1) from %2").arg(messageId).arg(client.name); 226 Log() << QString("\tSynchronize request (id %1) from %2").arg(messageId).arg(client.name);
227 auto timer = QSharedPointer<QTime>::create(); 227 auto timer = QSharedPointer<QTime>::create();
228 timer->start(); 228 timer->start();
@@ -303,8 +303,8 @@ qint64 Listener::lowerBoundRevision()
303void Listener::quit() 303void Listener::quit()
304{ 304{
305 //Broadcast shutdown notifications to open clients, so they don't try to restart the resource 305 //Broadcast shutdown notifications to open clients, so they don't try to restart the resource
306 auto command = Akonadi2::CreateNotification(m_fbb, Akonadi2::NotificationType::NotificationType_Shutdown); 306 auto command = Akonadi2::Commands::CreateNotification(m_fbb, Akonadi2::Commands::NotificationType::NotificationType_Shutdown);
307 Akonadi2::FinishNotificationBuffer(m_fbb, command); 307 Akonadi2::Commands::FinishNotificationBuffer(m_fbb, command);
308 for (Client &client : m_connections) { 308 for (Client &client : m_connections) {
309 if (client.socket && client.socket->isOpen()) { 309 if (client.socket && client.socket->isOpen()) {
310 Akonadi2::Commands::write(client.socket, ++m_messageId, Akonadi2::Commands::NotificationCommand, m_fbb); 310 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
359 return; 359 return;
360 } 360 }
361 361
362 auto command = Akonadi2::CreateCommandCompletion(m_fbb, messageId, success); 362 auto command = Akonadi2::Commands::CreateCommandCompletion(m_fbb, messageId, success);
363 Akonadi2::FinishCommandCompletionBuffer(m_fbb, command); 363 Akonadi2::Commands::FinishCommandCompletionBuffer(m_fbb, command);
364 Akonadi2::Commands::write(socket, ++m_messageId, Akonadi2::Commands::CommandCompletion, m_fbb); 364 Akonadi2::Commands::write(socket, ++m_messageId, Akonadi2::Commands::CommandCompletionCommand, m_fbb);
365 m_fbb.Clear(); 365 m_fbb.Clear();
366} 366}
367 367
@@ -372,8 +372,8 @@ void Listener::refreshRevision(qint64 revision)
372 372
373void Listener::updateClientsWithRevision(qint64 revision) 373void Listener::updateClientsWithRevision(qint64 revision)
374{ 374{
375 auto command = Akonadi2::CreateRevisionUpdate(m_fbb, revision); 375 auto command = Akonadi2::Commands::CreateRevisionUpdate(m_fbb, revision);
376 Akonadi2::FinishRevisionUpdateBuffer(m_fbb, command); 376 Akonadi2::Commands::FinishRevisionUpdateBuffer(m_fbb, command);
377 377
378 for (const Client &client: m_connections) { 378 for (const Client &client: m_connections) {
379 if (!client.socket || !client.socket->isValid()) { 379 if (!client.socket || !client.socket->isValid()) {
@@ -390,13 +390,13 @@ void Listener::notify(const Akonadi2::ResourceNotification &notification)
390{ 390{
391 auto messageString = m_fbb.CreateString(notification.message.toUtf8().constData(), notification.message.toUtf8().size()); 391 auto messageString = m_fbb.CreateString(notification.message.toUtf8().constData(), notification.message.toUtf8().size());
392 auto idString = m_fbb.CreateString(notification.id.constData(), notification.id.size()); 392 auto idString = m_fbb.CreateString(notification.id.constData(), notification.id.size());
393 Akonadi2::NotificationBuilder builder(m_fbb); 393 Akonadi2::Commands::NotificationBuilder builder(m_fbb);
394 builder.add_type(static_cast<Akonadi2::NotificationType>(notification.type)); 394 builder.add_type(static_cast<Akonadi2::Commands::NotificationType>(notification.type));
395 builder.add_code(notification.code); 395 builder.add_code(notification.code);
396 builder.add_identifier(idString); 396 builder.add_identifier(idString);
397 builder.add_message(messageString); 397 builder.add_message(messageString);
398 auto command = builder.Finish(); 398 auto command = builder.Finish();
399 Akonadi2::FinishNotificationBuffer(m_fbb, command); 399 Akonadi2::Commands::FinishNotificationBuffer(m_fbb, command);
400 for (Client &client : m_connections) { 400 for (Client &client : m_connections) {
401 if (client.socket && client.socket->isOpen()) { 401 if (client.socket && client.socket->isOpen()) {
402 Akonadi2::Commands::write(client.socket, ++m_messageId, Akonadi2::Commands::NotificationCommand, m_fbb); 402 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<void> ResourceAccess::synchronizeResource(bool sourceSync, bool loca
298{ 298{
299 Trace() << "Sending synchronize command: " << sourceSync << localSync; 299 Trace() << "Sending synchronize command: " << sourceSync << localSync;
300 flatbuffers::FlatBufferBuilder fbb; 300 flatbuffers::FlatBufferBuilder fbb;
301 auto command = Akonadi2::CreateSynchronize(fbb, sourceSync, localSync); 301 auto command = Akonadi2::Commands::CreateSynchronize(fbb, sourceSync, localSync);
302 Akonadi2::FinishSynchronizeBuffer(fbb, command); 302 Akonadi2::Commands::FinishSynchronizeBuffer(fbb, command);
303 open(); 303 open();
304 return sendCommand(Commands::SynchronizeCommand, fbb); 304 return sendCommand(Commands::SynchronizeCommand, fbb);
305} 305}
@@ -457,8 +457,8 @@ void ResourceAccess::connected()
457 { 457 {
458 flatbuffers::FlatBufferBuilder fbb; 458 flatbuffers::FlatBufferBuilder fbb;
459 auto name = fbb.CreateString(QString("PID: %1 ResourceAccess: %2").arg(QCoreApplication::applicationPid()).arg(reinterpret_cast<qlonglong>(this)).toLatin1()); 459 auto name = fbb.CreateString(QString("PID: %1 ResourceAccess: %2").arg(QCoreApplication::applicationPid()).arg(reinterpret_cast<qlonglong>(this)).toLatin1());
460 auto command = Akonadi2::CreateHandshake(fbb, name); 460 auto command = Akonadi2::Commands::CreateHandshake(fbb, name);
461 Akonadi2::FinishHandshakeBuffer(fbb, command); 461 Akonadi2::Commands::FinishHandshakeBuffer(fbb, command);
462 Commands::write(d->socket.data(), ++d->messageId, Commands::HandshakeCommand, fbb); 462 Commands::write(d->socket.data(), ++d->messageId, Commands::HandshakeCommand, fbb);
463 } 463 }
464 464
@@ -523,14 +523,14 @@ bool ResourceAccess::processMessageBuffer()
523 523
524 switch (commandId) { 524 switch (commandId) {
525 case Commands::RevisionUpdateCommand: { 525 case Commands::RevisionUpdateCommand: {
526 auto buffer = GetRevisionUpdate(d->partialMessageBuffer.constData() + headerSize); 526 auto buffer = Commands::GetRevisionUpdate(d->partialMessageBuffer.constData() + headerSize);
527 log(QString("Revision updated to: %1").arg(buffer->revision())); 527 log(QString("Revision updated to: %1").arg(buffer->revision()));
528 emit revisionChanged(buffer->revision()); 528 emit revisionChanged(buffer->revision());
529 529
530 break; 530 break;
531 } 531 }
532 case Commands::CommandCompletion: { 532 case Commands::CommandCompletionCommand: {
533 auto buffer = GetCommandCompletion(d->partialMessageBuffer.constData() + headerSize); 533 auto buffer = Commands::GetCommandCompletion(d->partialMessageBuffer.constData() + headerSize);
534 log(QString("Command with messageId %1 completed %2").arg(buffer->id()).arg(buffer->success() ? "sucessfully" : "unsuccessfully")); 534 log(QString("Command with messageId %1 completed %2").arg(buffer->id()).arg(buffer->success() ? "sucessfully" : "unsuccessfully"));
535 535
536 d->completeCommands << buffer->id(); 536 d->completeCommands << buffer->id();
@@ -541,13 +541,13 @@ bool ResourceAccess::processMessageBuffer()
541 break; 541 break;
542 } 542 }
543 case Commands::NotificationCommand: { 543 case Commands::NotificationCommand: {
544 auto buffer = GetNotification(d->partialMessageBuffer.constData() + headerSize); 544 auto buffer = Commands::GetNotification(d->partialMessageBuffer.constData() + headerSize);
545 switch (buffer->type()) { 545 switch (buffer->type()) {
546 case Akonadi2::NotificationType::NotificationType_Shutdown: 546 case Akonadi2::Commands::NotificationType::NotificationType_Shutdown:
547 Log(d->resourceInstanceIdentifier) << "Received shutdown notification."; 547 Log(d->resourceInstanceIdentifier) << "Received shutdown notification.";
548 close(); 548 close();
549 break; 549 break;
550 case Akonadi2::NotificationType::NotificationType_Inspection: { 550 case Akonadi2::Commands::NotificationType::NotificationType_Inspection: {
551 Log(d->resourceInstanceIdentifier) << "Received inspection notification."; 551 Log(d->resourceInstanceIdentifier) << "Received inspection notification.";
552 ResourceNotification n; 552 ResourceNotification n;
553 if (buffer->identifier()) { 553 if (buffer->identifier()) {
diff --git a/tests/resourcecommunicationtest.cpp b/tests/resourcecommunicationtest.cpp
index 18e9223..1b09c5f 100644
--- a/tests/resourcecommunicationtest.cpp
+++ b/tests/resourcecommunicationtest.cpp
@@ -32,8 +32,8 @@ private Q_SLOTS:
32 32
33 flatbuffers::FlatBufferBuilder fbb; 33 flatbuffers::FlatBufferBuilder fbb;
34 auto name = fbb.CreateString("test"); 34 auto name = fbb.CreateString("test");
35 auto command = Akonadi2::CreateHandshake(fbb, name); 35 auto command = Akonadi2::Commands::CreateHandshake(fbb, name);
36 Akonadi2::FinishHandshakeBuffer(fbb, command); 36 Akonadi2::Commands::FinishHandshakeBuffer(fbb, command);
37 auto result = resourceAccess.sendCommand(Akonadi2::Commands::HandshakeCommand, fbb).exec(); 37 auto result = resourceAccess.sendCommand(Akonadi2::Commands::HandshakeCommand, fbb).exec();
38 result.waitForFinished(); 38 result.waitForFinished();
39 QVERIFY(!result.errorCode()); 39 QVERIFY(!result.errorCode());