diff options
Diffstat (limited to 'common/resourceaccess.cpp')
-rw-r--r-- | common/resourceaccess.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 65e9a8c..483d83f 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -46,6 +46,16 @@ | |||
46 | #undef Log | 46 | #undef Log |
47 | #define Log(IDENTIFIER) Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess("+IDENTIFIER+")") | 47 | #define Log(IDENTIFIER) Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess("+IDENTIFIER+")") |
48 | 48 | ||
49 | static void queuedInvoke(const std::function<void()> &f) | ||
50 | { | ||
51 | QTimer *timer = new QTimer; | ||
52 | QObject::connect(timer, &QTimer::timeout, [=]() { | ||
53 | f(); | ||
54 | delete timer; | ||
55 | }); | ||
56 | timer->start(0); | ||
57 | } | ||
58 | |||
49 | namespace Akonadi2 | 59 | namespace Akonadi2 |
50 | { | 60 | { |
51 | 61 | ||
@@ -534,6 +544,23 @@ bool ResourceAccess::processMessageBuffer() | |||
534 | Log(d->resourceInstanceIdentifier) << "Received shutdown notification."; | 544 | Log(d->resourceInstanceIdentifier) << "Received shutdown notification."; |
535 | close(); | 545 | close(); |
536 | break; | 546 | break; |
547 | case Akonadi2::NotificationType::NotificationType_Inspection: { | ||
548 | Log(d->resourceInstanceIdentifier) << "Received inspection notification."; | ||
549 | ResourceNotification n; | ||
550 | if (buffer->identifier()) { | ||
551 | n.id = QByteArray::fromRawData(reinterpret_cast<char const *>(buffer->identifier()->Data()), buffer->identifier()->size()); | ||
552 | } | ||
553 | if (buffer->message()) { | ||
554 | n.message = QByteArray::fromRawData(reinterpret_cast<char const *>(buffer->message()->Data()), buffer->message()->size()); | ||
555 | } | ||
556 | n.type = buffer->type(); | ||
557 | n.code = buffer->code(); | ||
558 | //The callbacks can result in this object getting destroyed directly, so we need to ensure we finish our work first | ||
559 | queuedInvoke([=]() { | ||
560 | emit notification(n); | ||
561 | }); | ||
562 | } | ||
563 | break; | ||
537 | default: | 564 | default: |
538 | Warning() << "Received unknown notification: " << buffer->type(); | 565 | Warning() << "Received unknown notification: " << buffer->type(); |
539 | break; | 566 | break; |