diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-08 19:29:58 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-08 19:29:58 +0100 |
commit | 6f43bb64e180083aff726a5be2c5122e97e54819 (patch) | |
tree | ab6427486e26ccbeb190200cb0ade54a99ec6604 /common/clientapi.cpp | |
parent | ed9f2ce38e11c907c8b801736bebc6923e9dbb2b (diff) | |
download | sink-6f43bb64e180083aff726a5be2c5122e97e54819.tar.gz sink-6f43bb64e180083aff726a5be2c5122e97e54819.zip |
Listen for notifications from specific resources.
Diffstat (limited to 'common/clientapi.cpp')
-rw-r--r-- | common/clientapi.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 413abd3..5eb4b55 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp | |||
@@ -353,6 +353,19 @@ Notifier::Notifier(const QSharedPointer<ResourceAccess> &resourceAccess) | |||
353 | d->resourceAccess << resourceAccess; | 353 | d->resourceAccess << resourceAccess; |
354 | } | 354 | } |
355 | 355 | ||
356 | Notifier::Notifier(const QByteArray &instanceIdentifier) | ||
357 | : d(new Sink::Notifier::Private) | ||
358 | { | ||
359 | auto resourceAccess = Sink::ResourceAccess::Ptr::create(instanceIdentifier); | ||
360 | resourceAccess->open(); | ||
361 | QObject::connect(resourceAccess.data(), &ResourceAccess::notification, d->context.data(), [this](const Notification ¬ification) { | ||
362 | for (const auto &handler : d->handler) { | ||
363 | handler(notification); | ||
364 | } | ||
365 | }); | ||
366 | d->resourceAccess << resourceAccess; | ||
367 | } | ||
368 | |||
356 | void Notifier::registerHandler(std::function<void(const Notification &)> handler) | 369 | void Notifier::registerHandler(std::function<void(const Notification &)> handler) |
357 | { | 370 | { |
358 | d->handler << handler; | 371 | d->handler << handler; |