summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-10-27 14:51:07 (GMT)
committerSwift Review <review@swift.im>2014-10-30 13:58:51 (GMT)
commit286ef105d813a12640d64b71101cafe53f212234 (patch)
tree39e3814048dd639b9a118a3b16f22b49235efd93 /Swiften/Presence
parent190cdcf7478950a90a5c8666d82047e4f33e0d2c (diff)
downloadswift-286ef105d813a12640d64b71101cafe53f212234.zip
swift-286ef105d813a12640d64b71101cafe53f212234.tar.bz2
Resend presence to MUC on join completion only if it changed since join.
Test-Information: Added test case to assure presence is not resend after join completion if it did not change. The other test cases are untouched and still all succeed. Change-Id: I2aace1aee8ca3deab9cd9050a25233617b3b0678
Diffstat (limited to 'Swiften/Presence')
-rw-r--r--Swiften/Presence/DirectedPresenceSender.cpp12
-rw-r--r--Swiften/Presence/DirectedPresenceSender.h8
2 files changed, 11 insertions, 9 deletions
diff --git a/Swiften/Presence/DirectedPresenceSender.cpp b/Swiften/Presence/DirectedPresenceSender.cpp
index ec0bd3f..c6cddbd 100644
--- a/Swiften/Presence/DirectedPresenceSender.cpp
+++ b/Swiften/Presence/DirectedPresenceSender.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -31,10 +31,10 @@ void DirectedPresenceSender::sendPresence(boost::shared_ptr<Presence> presence)
}
/**
- * Gets either the last broadcast presence, or an empty stanza if none has been sent.
+ * Gets the last broadcast presence, if none has been send the returned optional is not set.
*/
-boost::shared_ptr<Presence> DirectedPresenceSender::getLastSentUndirectedPresence() {
- boost::shared_ptr<Presence> presenceCopy(lastSentUndirectedPresence ? new Presence(*lastSentUndirectedPresence) : new Presence());
+boost::optional<Presence::ref> DirectedPresenceSender::getLastSentUndirectedPresence() const {
+ boost::optional<Presence::ref> presenceCopy = lastSentUndirectedPresence ? boost::optional<Presence::ref>((*lastSentUndirectedPresence)->clone()) : boost::optional<Presence::ref>();
return presenceCopy;
}
@@ -46,8 +46,8 @@ boost::shared_ptr<Presence> DirectedPresenceSender::getLastSentUndirectedPresenc
void DirectedPresenceSender::addDirectedPresenceReceiver(const JID& jid, SendPresence sendPresence) {
directedPresenceReceivers.insert(jid);
if (sendPresence == AndSendPresence && sender->isAvailable()) {
- if (lastSentUndirectedPresence && lastSentUndirectedPresence->getType() == Presence::Available) {
- boost::shared_ptr<Presence> presenceCopy(new Presence(*lastSentUndirectedPresence));
+ if (lastSentUndirectedPresence && (*lastSentUndirectedPresence)->getType() == Presence::Available) {
+ boost::shared_ptr<Presence> presenceCopy((*lastSentUndirectedPresence)->clone());
presenceCopy->setTo(jid);
sender->sendPresence(presenceCopy);
}
diff --git a/Swiften/Presence/DirectedPresenceSender.h b/Swiften/Presence/DirectedPresenceSender.h
index 0eb16a4..511e177 100644
--- a/Swiften/Presence/DirectedPresenceSender.h
+++ b/Swiften/Presence/DirectedPresenceSender.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -8,6 +8,8 @@
#include <set>
+#include <boost/optional.hpp>
+
#include <Swiften/Elements/Presence.h>
#include <Swiften/Presence/PresenceSender.h>
#include <Swiften/Base/API.h>
@@ -23,12 +25,12 @@ namespace Swift {
void sendPresence(Presence::ref);
- Presence::ref getLastSentUndirectedPresence();
+ boost::optional<Presence::ref> getLastSentUndirectedPresence() const;
bool isAvailable() const;
private:
- Presence::ref lastSentUndirectedPresence;
+ boost::optional<Presence::ref> lastSentUndirectedPresence;
PresenceSender* sender;
std::set<JID> directedPresenceReceivers;
};