Changeset View
Changeset View
Standalone View
Standalone View
src/server/notificationsubscriber.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
42 | NotificationSubscriber::NotificationSubscriber(NotificationManager *manager) | 42 | NotificationSubscriber::NotificationSubscriber(NotificationManager *manager) | ||
43 | : QObject() | 43 | : QObject() | ||
44 | , mManager(manager) | 44 | , mManager(manager) | ||
45 | , mSocket(nullptr) | 45 | , mSocket(nullptr) | ||
46 | , mAllMonitored(false) | 46 | , mAllMonitored(false) | ||
47 | , mExclusive(false) | 47 | , mExclusive(false) | ||
48 | , mNotificationDebugging(false) | 48 | , mNotificationDebugging(false) | ||
49 | { | 49 | { | ||
50 | if (mManager) { | ||||
51 | mManager->collectionFetchScope()->addSubscriber(); | ||||
52 | mManager->tagFetchScope()->addSubscriber(); | ||||
53 | } | ||||
50 | } | 54 | } | ||
51 | 55 | | |||
52 | NotificationSubscriber::NotificationSubscriber(NotificationManager *manager, quintptr socketDescriptor) | 56 | NotificationSubscriber::NotificationSubscriber(NotificationManager *manager, quintptr socketDescriptor) | ||
53 | : NotificationSubscriber(manager) | 57 | : NotificationSubscriber(manager) | ||
54 | { | 58 | { | ||
55 | mSocket = new QLocalSocket(this); | 59 | mSocket = new QLocalSocket(this); | ||
56 | connect(mSocket, &QLocalSocket::readyRead, | 60 | connect(mSocket, &QLocalSocket::readyRead, | ||
57 | this, &NotificationSubscriber::handleIncomingData); | 61 | this, &NotificationSubscriber::handleIncomingData); | ||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 144 | { | |||
157 | } | 161 | } | ||
158 | if (mCollectionFetchScope.includeStatistics()) { | 162 | if (mCollectionFetchScope.includeStatistics()) { | ||
159 | cfs->setFetchStatistics(false); | 163 | cfs->setFetchStatistics(false); | ||
160 | } | 164 | } | ||
161 | const auto attrs = mCollectionFetchScope.attributes(); | 165 | const auto attrs = mCollectionFetchScope.attributes(); | ||
162 | for (const auto &attr : attrs) { | 166 | for (const auto &attr : attrs) { | ||
163 | cfs->removeAttribute(attr); | 167 | cfs->removeAttribute(attr); | ||
164 | } | 168 | } | ||
169 | cfs->removeSubscriber(); | ||||
170 | | ||||
171 | auto tfs = mManager->tagFetchScope(); | ||||
172 | tfs->removeSubscriber(); | ||||
165 | 173 | | |||
166 | mManager->forgetSubscriber(this); | 174 | mManager->forgetSubscriber(this); | ||
167 | deleteLater(); | 175 | deleteLater(); | ||
168 | } | 176 | } | ||
169 | 177 | | |||
170 | void NotificationSubscriber::registerSubscriber(const Protocol::CreateSubscriptionCommand &command) | 178 | void NotificationSubscriber::registerSubscriber(const Protocol::CreateSubscriptionCommand &command) | ||
171 | { | 179 | { | ||
172 | QMutexLocker locker(&mLock); | 180 | QMutexLocker locker(&mLock); | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 269 | if (modifiedParts & Protocol::ModifySubscriptionCommand::CollectionFetchScope) { | |||
262 | const auto newScope = command.collectionFetchScope(); | 270 | const auto newScope = command.collectionFetchScope(); | ||
263 | mManager->collectionFetchScope()->apply(mCollectionFetchScope, newScope); | 271 | mManager->collectionFetchScope()->apply(mCollectionFetchScope, newScope); | ||
264 | mCollectionFetchScope = newScope; | 272 | mCollectionFetchScope = newScope; | ||
265 | } | 273 | } | ||
266 | if (modifiedParts & Protocol::ModifySubscriptionCommand::TagFetchScope) { | 274 | if (modifiedParts & Protocol::ModifySubscriptionCommand::TagFetchScope) { | ||
267 | const auto newScope = command.tagFetchScope(); | 275 | const auto newScope = command.tagFetchScope(); | ||
268 | mManager->tagFetchScope()->apply(mTagFetchScope, newScope); | 276 | mManager->tagFetchScope()->apply(mTagFetchScope, newScope); | ||
269 | mTagFetchScope = newScope; | 277 | mTagFetchScope = newScope; | ||
278 | if (!newScope.fetchIdOnly()) | ||||
279 | Q_ASSERT(!mManager->tagFetchScope()->fetchIdOnly()); | ||||
270 | } | 280 | } | ||
271 | 281 | | |||
272 | if (mManager) { | 282 | if (mManager) { | ||
273 | if (modifiedParts & Protocol::ModifySubscriptionCommand::Types) { | 283 | if (modifiedParts & Protocol::ModifySubscriptionCommand::Types) { | ||
274 | // Did the caller just subscribed to subscription changes? | 284 | // Did the caller just subscribed to subscription changes? | ||
275 | if (command.startMonitoringTypes().contains(Protocol::ModifySubscriptionCommand::SubscriptionChanges)) { | 285 | if (command.startMonitoringTypes().contains(Protocol::ModifySubscriptionCommand::SubscriptionChanges)) { | ||
276 | // If yes, then send them list of all existing subscribers | 286 | // If yes, then send them list of all existing subscribers | ||
277 | Q_FOREACH (const NotificationSubscriber *subscriber, mManager->mSubscribers) { | 287 | Q_FOREACH (const NotificationSubscriber *subscriber, mManager->mSubscribers) { | ||
▲ Show 20 Lines • Show All 457 Lines • Show Last 20 Lines |