summaryrefslogtreecommitdiffstats
path: root/common/resourceaccess.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-01-20 19:07:07 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-01-20 19:07:07 +0100
commitbdb01c2c068df326f5a8328ed1492ab1bea388c5 (patch)
tree25c2ee1b29bc481b6914c244ed9ca194b1415d16 /common/resourceaccess.cpp
parent17e7ee40c9185c0505883853345fd6024c675b1a (diff)
downloadsink-bdb01c2c068df326f5a8328ed1492ab1bea388c5.tar.gz
sink-bdb01c2c068df326f5a8328ed1492ab1bea388c5.zip
Renamed Akonadi2 to Sink
(except for documentation).
Diffstat (limited to 'common/resourceaccess.cpp')
-rw-r--r--common/resourceaccess.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp
index 6592699..0c435c9 100644
--- a/common/resourceaccess.cpp
+++ b/common/resourceaccess.cpp
@@ -43,9 +43,9 @@
43#include <QBuffer> 43#include <QBuffer>
44 44
45#undef Trace 45#undef Trace
46#define Trace() Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Trace, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess") 46#define Trace() Sink::Log::debugStream(Sink::Log::DebugLevel::Trace, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess")
47#undef Log 47#undef Log
48#define Log(IDENTIFIER) Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess("+IDENTIFIER+")") 48#define Log(IDENTIFIER) Sink::Log::debugStream(Sink::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess("+IDENTIFIER+")")
49 49
50static void queuedInvoke(const std::function<void()> &f, QObject *context = 0) 50static void queuedInvoke(const std::function<void()> &f, QObject *context = 0)
51{ 51{
@@ -57,7 +57,7 @@ static void queuedInvoke(const std::function<void()> &f, QObject *context = 0)
57 timer->start(0); 57 timer->start(0);
58} 58}
59 59
60namespace Akonadi2 60namespace Sink
61{ 61{
62 62
63struct QueuedCommand 63struct QueuedCommand
@@ -205,7 +205,7 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket()
205 QStringList args; 205 QStringList args;
206 args << resourceInstanceIdentifier; 206 args << resourceInstanceIdentifier;
207 qint64 pid = 0; 207 qint64 pid = 0;
208 if (QProcess::startDetached("akonadi2_synchronizer", args, QDir::homePath(), &pid)) { 208 if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) {
209 Trace() << "Started resource " << pid; 209 Trace() << "Started resource " << pid;
210 tryToConnect() 210 tryToConnect()
211 .then<void>([&future]() { 211 .then<void>([&future]() {
@@ -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::Commands::CreateSynchronize(fbb, sourceSync, localSync); 301 auto command = Sink::Commands::CreateSynchronize(fbb, sourceSync, localSync);
302 Akonadi2::Commands::FinishSynchronizeBuffer(fbb, command); 302 Sink::Commands::FinishSynchronizeBuffer(fbb, command);
303 open(); 303 open();
304 return sendCommand(Commands::SynchronizeCommand, fbb); 304 return sendCommand(Commands::SynchronizeCommand, fbb);
305} 305}
@@ -309,11 +309,11 @@ KAsync::Job<void> ResourceAccess::sendCreateCommand(const QByteArray &resourceBu
309 flatbuffers::FlatBufferBuilder fbb; 309 flatbuffers::FlatBufferBuilder fbb;
310 //This is the resource buffer type and not the domain type 310 //This is the resource buffer type and not the domain type
311 auto type = fbb.CreateString(resourceBufferType.constData()); 311 auto type = fbb.CreateString(resourceBufferType.constData());
312 auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); 312 auto delta = Sink::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size());
313 auto location = Akonadi2::Commands::CreateCreateEntity(fbb, 0, type, delta); 313 auto location = Sink::Commands::CreateCreateEntity(fbb, 0, type, delta);
314 Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); 314 Sink::Commands::FinishCreateEntityBuffer(fbb, location);
315 open(); 315 open();
316 return sendCommand(Akonadi2::Commands::CreateEntityCommand, fbb); 316 return sendCommand(Sink::Commands::CreateEntityCommand, fbb);
317} 317}
318 318
319KAsync::Job<void> ResourceAccess::sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer) 319KAsync::Job<void> ResourceAccess::sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer)
@@ -324,11 +324,11 @@ KAsync::Job<void> ResourceAccess::sendModifyCommand(const QByteArray &uid, qint6
324 auto type = fbb.CreateString(resourceBufferType.constData()); 324 auto type = fbb.CreateString(resourceBufferType.constData());
325 //FIXME 325 //FIXME
326 auto deletions = 0; 326 auto deletions = 0;
327 auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); 327 auto delta = Sink::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size());
328 auto location = Akonadi2::Commands::CreateModifyEntity(fbb, revision, entityId, deletions, type, delta); 328 auto location = Sink::Commands::CreateModifyEntity(fbb, revision, entityId, deletions, type, delta);
329 Akonadi2::Commands::FinishModifyEntityBuffer(fbb, location); 329 Sink::Commands::FinishModifyEntityBuffer(fbb, location);
330 open(); 330 open();
331 return sendCommand(Akonadi2::Commands::ModifyEntityCommand, fbb); 331 return sendCommand(Sink::Commands::ModifyEntityCommand, fbb);
332} 332}
333 333
334KAsync::Job<void> ResourceAccess::sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) 334KAsync::Job<void> ResourceAccess::sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType)
@@ -337,19 +337,19 @@ KAsync::Job<void> ResourceAccess::sendDeleteCommand(const QByteArray &uid, qint6
337 auto entityId = fbb.CreateString(uid.constData()); 337 auto entityId = fbb.CreateString(uid.constData());
338 //This is the resource buffer type and not the domain type 338 //This is the resource buffer type and not the domain type
339 auto type = fbb.CreateString(resourceBufferType.constData()); 339 auto type = fbb.CreateString(resourceBufferType.constData());
340 auto location = Akonadi2::Commands::CreateDeleteEntity(fbb, revision, entityId, type); 340 auto location = Sink::Commands::CreateDeleteEntity(fbb, revision, entityId, type);
341 Akonadi2::Commands::FinishDeleteEntityBuffer(fbb, location); 341 Sink::Commands::FinishDeleteEntityBuffer(fbb, location);
342 open(); 342 open();
343 return sendCommand(Akonadi2::Commands::DeleteEntityCommand, fbb); 343 return sendCommand(Sink::Commands::DeleteEntityCommand, fbb);
344} 344}
345 345
346KAsync::Job<void> ResourceAccess::sendRevisionReplayedCommand(qint64 revision) 346KAsync::Job<void> ResourceAccess::sendRevisionReplayedCommand(qint64 revision)
347{ 347{
348 flatbuffers::FlatBufferBuilder fbb; 348 flatbuffers::FlatBufferBuilder fbb;
349 auto location = Akonadi2::Commands::CreateRevisionReplayed(fbb, revision); 349 auto location = Sink::Commands::CreateRevisionReplayed(fbb, revision);
350 Akonadi2::Commands::FinishRevisionReplayedBuffer(fbb, location); 350 Sink::Commands::FinishRevisionReplayedBuffer(fbb, location);
351 open(); 351 open();
352 return sendCommand(Akonadi2::Commands::RevisionReplayedCommand, fbb); 352 return sendCommand(Sink::Commands::RevisionReplayedCommand, fbb);
353} 353}
354 354
355KAsync::Job<void> ResourceAccess::sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) 355KAsync::Job<void> ResourceAccess::sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue)
@@ -365,10 +365,10 @@ KAsync::Job<void> ResourceAccess::sendInspectionCommand(const QByteArray &inspec
365 s << expectedValue; 365 s << expectedValue;
366 366
367 auto expected = fbb.CreateString(array.toStdString()); 367 auto expected = fbb.CreateString(array.toStdString());
368 auto location = Akonadi2::Commands::CreateInspection (fbb, id, 0, entity, domain, prop, expected); 368 auto location = Sink::Commands::CreateInspection (fbb, id, 0, entity, domain, prop, expected);
369 Akonadi2::Commands::FinishInspectionBuffer(fbb, location); 369 Sink::Commands::FinishInspectionBuffer(fbb, location);
370 open(); 370 open();
371 return sendCommand(Akonadi2::Commands::InspectionCommand, fbb); 371 return sendCommand(Sink::Commands::InspectionCommand, fbb);
372} 372}
373 373
374void ResourceAccess::open() 374void ResourceAccess::open()
@@ -412,7 +412,7 @@ void ResourceAccess::sendCommand(const QSharedPointer<QueuedCommand> &command)
412 //TODO: we should have a timeout for commands 412 //TODO: we should have a timeout for commands
413 d->messageId++; 413 d->messageId++;
414 const auto messageId = d->messageId; 414 const auto messageId = d->messageId;
415 log(QString("Sending command \"%1\" with messageId %2").arg(QString(Akonadi2::Commands::name(command->commandId))).arg(d->messageId)); 415 log(QString("Sending command \"%1\" with messageId %2").arg(QString(Sink::Commands::name(command->commandId))).arg(d->messageId));
416 Q_ASSERT(command->callback); 416 Q_ASSERT(command->callback);
417 registerCallback(d->messageId, [this, messageId, command](int errorCode, QString errorMessage) { 417 registerCallback(d->messageId, [this, messageId, command](int errorCode, QString errorMessage) {
418 Trace() << "Command complete " << messageId; 418 Trace() << "Command complete " << messageId;
@@ -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::Commands::CreateHandshake(fbb, name); 460 auto command = Sink::Commands::CreateHandshake(fbb, name);
461 Akonadi2::Commands::FinishHandshakeBuffer(fbb, command); 461 Sink::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
@@ -543,11 +543,11 @@ bool ResourceAccess::processMessageBuffer()
543 case Commands::NotificationCommand: { 543 case Commands::NotificationCommand: {
544 auto buffer = Commands::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::Commands::NotificationType::NotificationType_Shutdown: 546 case Sink::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::Commands::NotificationType::NotificationType_Inspection: { 550 case Sink::Commands::NotificationType::NotificationType_Inspection: {
551 Log(d->resourceInstanceIdentifier) << "Received inspection notification."; 551 Log(d->resourceInstanceIdentifier) << "Received inspection notification.";
552 Notification n; 552 Notification n;
553 if (buffer->identifier()) { 553 if (buffer->identifier()) {