diff options
Diffstat (limited to 'Swiften/MUC/MUC.cpp')
-rw-r--r-- | Swiften/MUC/MUC.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp index a52f552..ff26c86 100644 --- a/Swiften/MUC/MUC.cpp +++ b/Swiften/MUC/MUC.cpp @@ -30,5 +30,5 @@ namespace Swift { typedef std::pair<std::string, MUCOccupant> StringMUCOccupantPair; -MUC::MUC(StanzaChannel* stanzaChannel, IQRouter* iqRouter, DirectedPresenceSender* presenceSender, const JID &muc, MUCRegistry* mucRegistry) : ownMUCJID(muc), stanzaChannel(stanzaChannel), iqRouter_(iqRouter), presenceSender(presenceSender), mucRegistry(mucRegistry), createAsReservedIfNew(false), unlocking(false) { +MUC::MUC(StanzaChannel* stanzaChannel, IQRouter* iqRouter, DirectedPresenceSender* presenceSender, const JID &muc, MUCRegistry* mucRegistry) : ownMUCJID(muc), stanzaChannel(stanzaChannel), iqRouter_(iqRouter), presenceSender(presenceSender), mucRegistry(mucRegistry), createAsReservedIfNew(false), unlocking(false), isUnlocked_(false) { scopedConnection_ = stanzaChannel->onPresenceReceived.connect(boost::bind(&MUC::handleIncomingPresence, this, _1)); } @@ -59,4 +59,8 @@ void MUC::joinWithContextSince(const std::string &nick, const boost::posix_time: } +std::map<std::string, MUCOccupant> MUC::getOccupants() const { + return occupants; +} + void MUC::internalJoin(const std::string &nick) { //TODO: history request @@ -98,4 +102,5 @@ void MUC::handleUserLeft(LeavingType type) { joinComplete_ = false; joinSucceeded_ = false; + isUnlocked_ = false; presenceSender->removeDirectedPresenceReceiver(ownMUCJID, DirectedPresenceSender::DontSendPresence); } @@ -171,6 +176,7 @@ void MUC::handleIncomingPresence(Presence::ref presence) { if (i != occupants.end()) { //TODO: part type - onOccupantLeft(i->second, type, ""); occupants.erase(i); + MUCOccupant occupant = i->second; + onOccupantLeft(occupant, type, ""); } } @@ -201,4 +207,5 @@ void MUC::handleIncomingPresence(Presence::ref presence) { } if (mucPayload && !joinComplete_) { + bool isLocked = false; foreach (MUCUserPayload::StatusCode status, mucPayload->getStatusCodes()) { if (status.code == 110) { @@ -213,4 +220,5 @@ void MUC::handleIncomingPresence(Presence::ref presence) { } if (status.code == 201) { + isLocked = true; /* Room is created and locked */ /* Currently deal with this by making an instant room */ @@ -234,4 +242,8 @@ void MUC::handleIncomingPresence(Presence::ref presence) { } } + if (!isLocked && !isUnlocked_ && (presence->getFrom() == ownMUCJID)) { + isUnlocked_ = true; + onUnlocked(); + } } } @@ -244,4 +256,6 @@ void MUC::handleCreationConfigResponse(MUCOwnerPayload::ref /*unused*/, ErrorPay } else { onJoinComplete(getOwnNick()); /* Previously, this wasn't needed here, as the presence duplication bug caused an emit elsewhere. */ + isUnlocked_ = true; + onUnlocked(); } } @@ -387,5 +401,5 @@ void MUC::destroyRoom() { } -void MUC::invitePerson(const JID& person, const std::string& reason) { +void MUC::invitePerson(const JID& person, const std::string& reason, bool isImpromptu, bool isReuseChat) { Message::ref message = boost::make_shared<Message>(); message->setTo(person); @@ -394,4 +408,6 @@ void MUC::invitePerson(const JID& person, const std::string& reason) { invite->setReason(reason); invite->setJID(ownMUCJID.toBare()); + invite->setIsImpromptu(isImpromptu); + invite->setIsContinuation(isReuseChat); message->addPayload(invite); stanzaChannel->sendMessage(message); |