summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-12-20 09:51:03 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-12-20 11:09:05 (GMT)
commit241bbe1c1a5755972f3ec0532befa9329631934e (patch)
tree740b4d6d4e8f010260b3cf05857379072d605341 /Swiften/Presence/DirectedPresenceSender.cpp
parentee8e00ba6abb5a61ba51c0c75806b67242364dc6 (diff)
downloadswift-contrib-241bbe1c1a5755972f3ec0532befa9329631934e.zip
swift-contrib-241bbe1c1a5755972f3ec0532befa9329631934e.tar.bz2
Don't immediately send presence unneccesarily when registering directed presence senders.
Hopefully Resolves: #691 Release-Notes: We hope to have fixed the bug where a MUC room would go into loop of parting and joining continually.
Diffstat (limited to 'Swiften/Presence/DirectedPresenceSender.cpp')
-rw-r--r--Swiften/Presence/DirectedPresenceSender.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/Swiften/Presence/DirectedPresenceSender.cpp b/Swiften/Presence/DirectedPresenceSender.cpp
index aade6cf..d824554 100644
--- a/Swiften/Presence/DirectedPresenceSender.cpp
+++ b/Swiften/Presence/DirectedPresenceSender.cpp
@@ -38,9 +38,14 @@ boost::shared_ptr<Presence> DirectedPresenceSender::getLastSentUndirectedPresenc
return presenceCopy;
}
-void DirectedPresenceSender::addDirectedPresenceReceiver(const JID& jid) {
+/**
+ * Send future broadcast presence also to this JID.
+ * @param jid Non-roster JID to receive global presence updates.
+ * @param sendPresence Also send the current global presence immediately.
+ */
+void DirectedPresenceSender::addDirectedPresenceReceiver(const JID& jid, SendPresence sendPresence) {
directedPresenceReceivers.insert(jid);
- if (sender->isAvailable()) {
+ if (sendPresence == AndSendPresence && sender->isAvailable()) {
if (lastSentUndirectedPresence && lastSentUndirectedPresence->getType() == Presence::Available) {
boost::shared_ptr<Presence> presenceCopy(new Presence(*lastSentUndirectedPresence));
presenceCopy->setTo(jid);
@@ -49,9 +54,14 @@ void DirectedPresenceSender::addDirectedPresenceReceiver(const JID& jid) {
}
}
-void DirectedPresenceSender::removeDirectedPresenceReceiver(const JID& jid) {
+/**
+ * Send future broadcast presence also to this JID.
+ * @param jid Non-roster JID to stop receiving global presence updates.
+ * @param sendPresence Also send presence type=unavailable immediately to jid.
+ */
+void DirectedPresenceSender::removeDirectedPresenceReceiver(const JID& jid, SendPresence sendPresence) {
directedPresenceReceivers.erase(jid);
- if (sender->isAvailable()) {
+ if (sendPresence == AndSendPresence && sender->isAvailable()) {
boost::shared_ptr<Presence> presence(new Presence());
presence->setType(Presence::Unavailable);
presence->setTo(jid);