summaryrefslogtreecommitdiffstats
path: root/common/listener.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-01-18 18:36:41 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-01-18 18:36:41 +0100
commit67e83aadde8db2bb1293cee61e8c6306a4ffcca0 (patch)
tree10531201cb5dca7617e17a4e4393bda20694c4ca /common/listener.cpp
parenta857d9b36f80adf045cd195653cb2f8b91452981 (diff)
downloadsink-67e83aadde8db2bb1293cee61e8c6306a4ffcca0.tar.gz
sink-67e83aadde8db2bb1293cee61e8c6306a4ffcca0.zip
Working resource inspection
Diffstat (limited to 'common/listener.cpp')
-rw-r--r--common/listener.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/common/listener.cpp b/common/listener.cpp
index 5d55202..bb0a130 100644
--- a/common/listener.cpp
+++ b/common/listener.cpp
@@ -386,6 +386,25 @@ void Listener::updateClientsWithRevision(qint64 revision)
386 m_fbb.Clear(); 386 m_fbb.Clear();
387} 387}
388 388
389void Listener::notify(const Akonadi2::ResourceNotification &notification)
390{
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());
393 Akonadi2::NotificationBuilder builder(m_fbb);
394 builder.add_type(static_cast<Akonadi2::NotificationType>(notification.type));
395 builder.add_code(notification.code);
396 builder.add_identifier(idString);
397 builder.add_message(messageString);
398 auto command = builder.Finish();
399 Akonadi2::FinishNotificationBuffer(m_fbb, command);
400 for (Client &client : m_connections) {
401 if (client.socket && client.socket->isOpen()) {
402 Akonadi2::Commands::write(client.socket, ++m_messageId, Akonadi2::Commands::NotificationCommand, m_fbb);
403 }
404 }
405 m_fbb.Clear();
406}
407
389Akonadi2::Resource *Listener::loadResource() 408Akonadi2::Resource *Listener::loadResource()
390{ 409{
391 if (!m_resource) { 410 if (!m_resource) {
@@ -395,6 +414,8 @@ Akonadi2::Resource *Listener::loadResource()
395 Trace() << QString("\tResource: %1").arg((qlonglong)m_resource); 414 Trace() << QString("\tResource: %1").arg((qlonglong)m_resource);
396 connect(m_resource, &Akonadi2::Resource::revisionUpdated, 415 connect(m_resource, &Akonadi2::Resource::revisionUpdated,
397 this, &Listener::refreshRevision); 416 this, &Listener::refreshRevision);
417 connect(m_resource, &Akonadi2::Resource::notify,
418 this, &Listener::notify);
398 } else { 419 } else {
399 ErrorMsg() << "Failed to load resource " << m_resourceName; 420 ErrorMsg() << "Failed to load resource " << m_resourceName;
400 m_resource = new Akonadi2::Resource; 421 m_resource = new Akonadi2::Resource;