Skip to content

Commit 5e70545

Browse files
committed
ews: rename subscriptions class members
Make the expression ``x->subscriptions`` for any given x unambiguous; make a distinction between ``EWSPlugin::subscriptions``, ``EWSPlugin::SubManager::subscriptions`` and ``EWSPlugin::NotificationContext::subscriptions``.
1 parent ac724ea commit 5e70545

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

exch/ews/context.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ EWSContext::EWSContext(int id, HTTP_AUTH_INFO ai, const char *data, uint64_t len
338338
EWSContext::~EWSContext()
339339
{
340340
if(m_notify)
341-
for(const tSubscriptionId& sub : m_notify->subscriptions)
341+
for (const auto &sub : m_notify->nct_subs)
342342
unsubscribe(sub);
343343
}
344344

@@ -1576,7 +1576,7 @@ BINARY EWSContext::serialize(const XID& xid) const
15761576
bool EWSContext::streamEvents(const tSubscriptionId& subscriptionId) const
15771577
{
15781578
if(m_notify)
1579-
m_notify->subscriptions.emplace_back(subscriptionId);
1579+
m_notify->nct_subs.emplace_back(subscriptionId);
15801580
return m_plugin.linkSubscription(subscriptionId, *this);
15811581
}
15821582

@@ -2141,10 +2141,10 @@ tSubscriptionId EWSContext::subscribe(const std::vector<sFolderId>& folderIds, u
21412141
detail::ExmdbSubscriptionKey key =
21422142
m_plugin.subscribe(m_auth_info.maildir, eventMask, true, rop_util_make_eid_ex(1, PRIVATE_FID_IPMSUBTREE),
21432143
subscriptionId.ID);
2144-
mgr->subscriptions.emplace_back(key);
2144+
mgr->inner_subs.emplace_back(key);
21452145
return subscriptionId;
21462146
}
2147-
mgr->subscriptions.reserve(folderIds.size());
2147+
mgr->inner_subs.reserve(folderIds.size());
21482148
std::string target;
21492149
std::string maildir;
21502150
for(const sFolderId& f : folderIds) {
@@ -2159,8 +2159,8 @@ tSubscriptionId EWSContext::subscribe(const std::vector<sFolderId>& folderIds, u
21592159
throw EWSError::InvalidSubscriptionRequest(E3200);
21602160
if(!(permissions(maildir, folderspec.folderId) & frightsReadAny))
21612161
continue; // TODO: proper error handling
2162-
mgr->subscriptions.emplace_back(m_plugin.subscribe(maildir, eventMask, all, folderspec.folderId,
2163-
subscriptionId.ID));
2162+
mgr->inner_subs.emplace_back(m_plugin.subscribe(maildir,
2163+
eventMask, all, folderspec.folderId, subscriptionId.ID));
21642164
}
21652165
return subscriptionId;
21662166
}

exch/ews/ews.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ int EWSContext::notify()
688688

689689
// S_SLEEP: Just woke up, check for new events and deliver update message
690690
bool moreAny = false;
691-
for(const tSubscriptionId& subscription : nctx.subscriptions) {
691+
for (const auto &subscription : nctx.nct_subs) {
692692
try {
693693
auto[events, more] = getEvents(subscription);
694694
moreAny = moreAny || more;
@@ -704,13 +704,14 @@ int EWSContext::notify()
704704
}
705705
}
706706
for(const tSubscriptionId& subscription : msg.ErrorSubscriptionIds)
707-
nctx.subscriptions.erase(std::remove(nctx.subscriptions.begin(), nctx.subscriptions.end(), subscription),
708-
nctx.subscriptions.end());
707+
nctx.nct_subs.erase(std::remove(nctx.nct_subs.begin(), nctx.nct_subs.end(), subscription),
708+
nctx.nct_subs.end());
709709
msg.success();
710710
// If there are no more subscriptions to monitor or the stream expired, close it
711711
// If there were more events than we could deliver in one message, proceed with the next chunk right away
712712
// Otherwise just go back to sleep
713-
nctx.state = (nctx.subscriptions.empty() || tp_now() > nctx.expire)? NS::S_CLOSING : moreAny? NS::S_SLEEP : NS::S_WRITE;
713+
nctx.state = nctx.nct_subs.empty() || tp_now() > nctx.expire ?
714+
NS::S_CLOSING : moreAny ? NS::S_SLEEP : NS::S_WRITE;
714715
if(nctx.state == NS::S_SLEEP)
715716
m_plugin.wakeContext(m_ID, m_plugin.event_stream_interval);
716717
return flush();
@@ -790,7 +791,7 @@ EWSPlugin::SubManager::SubManager(const char *uname, const EWSPlugin &plugin) :
790791
EWSPlugin::SubManager::~SubManager()
791792
{
792793
std::lock_guard ss_lock(ews.subscriptionLock);
793-
for(const auto& subKey : subscriptions)
794+
for (const auto &subKey : inner_subs)
794795
ews.unsubscribe(subKey);
795796
if(waitingContext)
796797
ews.unlinkSubscription(*waitingContext);

exch/ews/ews.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class EWSPlugin {
148148
std::string username; ///< Name of the user who created the subscription
149149
Structures::sMailboxInfo mailboxInfo; ///< Target mailbox metadata
150150
std::mutex lock; ///< I/O mutex
151-
std::vector<detail::ExmdbSubscriptionKey> subscriptions; ///< Exmdb subscription keys
151+
std::vector<detail::ExmdbSubscriptionKey> inner_subs; ///< Exmdb subscription keys
152152
std::list<Structures::sNotificationEvent> events; ///< Events that occured since last check
153153
std::optional<int> waitingContext; ///< ID of context waiting for events
154154
};
@@ -339,7 +339,7 @@ class EWSContext {
339339
inline explicit NotificationContext(gromox::time_point e) : state(S_INIT), expire(e) {}
340340

341341
State state;
342-
std::vector<Structures::tSubscriptionId> subscriptions;
342+
std::vector<Structures::tSubscriptionId> nct_subs;
343343
gromox::time_point expire;
344344
};
345345

0 commit comments

Comments
 (0)