summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/clientapi.cpp13
-rw-r--r--common/clientapi.h4
2 files changed, 15 insertions, 2 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
356Notifier::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 &notification) {
362 for (const auto &handler : d->handler) {
363 handler(notification);
364 }
365 });
366 d->resourceAccess << resourceAccess;
367}
368
356void Notifier::registerHandler(std::function<void(const Notification &)> handler) 369void Notifier::registerHandler(std::function<void(const Notification &)> handler)
357{ 370{
358 d->handler << handler; 371 d->handler << handler;
diff --git a/common/clientapi.h b/common/clientapi.h
index 8697003..d0910df 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -128,13 +128,13 @@ namespace Resources {
128class SINKCOMMON_EXPORT Notifier { 128class SINKCOMMON_EXPORT Notifier {
129public: 129public:
130 Notifier(const QSharedPointer<ResourceAccess> &resourceAccess); 130 Notifier(const QSharedPointer<ResourceAccess> &resourceAccess);
131 // Notifier(const QByteArray &resource); 131 Notifier(const QByteArray &resourceInstanceIdentifier);
132 // Notifier(const QByteArrayList &resource); 132 // Notifier(const QByteArrayList &resource);
133 void registerHandler(std::function<void(const Notification &)>); 133 void registerHandler(std::function<void(const Notification &)>);
134 134
135private: 135private:
136 class Private; 136 class Private;
137 QScopedPointer<Private> d; 137 QSharedPointer<Private> d;
138}; 138};
139 139
140} 140}