From 219b1e5e4684323e0dbd0f1ad7de7beaf4d75f50 Mon Sep 17 00:00:00 2001 From: Kevin Smith <git@kismith.co.uk> Date: Mon, 4 Oct 2010 09:47:47 +0100 Subject: Join MUCs with the last broadcast presence. Resolves: #590 Release-Notes: Joining rooms when you are not plain 'available' now correctly sends your status to the room. diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp index 3446849..8f04308 100644 --- a/Swiften/MUC/MUC.cpp +++ b/Swiften/MUC/MUC.cpp @@ -35,7 +35,7 @@ void MUC::joinAs(const String &nick) { ownMUCJID = JID(ownMUCJID.getNode(), ownMUCJID.getDomain(), nick); - boost::shared_ptr<Presence> joinPresence(new Presence()); + boost::shared_ptr<Presence> joinPresence(presenceSender->getLastSentUndirectedPresence()); joinPresence->setTo(ownMUCJID); joinPresence->addPayload(boost::shared_ptr<Payload>(new MUCPayload())); presenceSender->sendPresence(joinPresence); diff --git a/Swiften/Presence/PresenceSender.cpp b/Swiften/Presence/PresenceSender.cpp index 082c841..6df02b8 100644 --- a/Swiften/Presence/PresenceSender.cpp +++ b/Swiften/Presence/PresenceSender.cpp @@ -31,6 +31,14 @@ void PresenceSender::sendPresence(boost::shared_ptr<Presence> presence) { } } +/** + * Gets either the last broadcast presence, or an empty stanza if none has been sent. + */ +boost::shared_ptr<Presence> PresenceSender::getLastSentUndirectedPresence() { + boost::shared_ptr<Presence> presenceCopy(lastSentUndirectedPresence ? new Presence(*lastSentUndirectedPresence) : new Presence()); + return presenceCopy; +} + void PresenceSender::addDirectedPresenceReceiver(const JID& jid) { directedPresenceReceivers.insert(jid); if (channel->isAvailable()) { diff --git a/Swiften/Presence/PresenceSender.h b/Swiften/Presence/PresenceSender.h index 87be753..3336523 100644 --- a/Swiften/Presence/PresenceSender.h +++ b/Swiften/Presence/PresenceSender.h @@ -26,6 +26,8 @@ namespace Swift { void confirmSubscription(const JID& jid); void requestSubscription(const JID& jid); + boost::shared_ptr<Presence> getLastSentUndirectedPresence(); + private: boost::shared_ptr<Presence> lastSentUndirectedPresence; StanzaChannel* channel; -- cgit v0.10.2-6-g49f6