diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-09-13 21:18:44 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-09-13 21:26:44 (GMT) |
commit | 6efbed866f78e0bdd685817d9ed80405a2bf55d7 (patch) | |
tree | 99edb5ecd8ea715f8a52579b7b7fb6627ced1d84 /Swiften/MUC | |
parent | 30c3130def563b76c18f6bc91bd527ef1ba092be (diff) | |
download | swift-contrib-6efbed866f78e0bdd685817d9ed80405a2bf55d7.zip swift-contrib-6efbed866f78e0bdd685817d9ed80405a2bf55d7.tar.bz2 |
When joining a new room, create an instant room.
Resolves: #112
Diffstat (limited to 'Swiften/MUC')
-rw-r--r-- | Swiften/MUC/MUC.cpp | 13 | ||||
-rw-r--r-- | Swiften/MUC/MUC.h | 5 |
2 files changed, 16 insertions, 2 deletions
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp index f4512a0..bcc9e6f 100644 --- a/Swiften/MUC/MUC.cpp +++ b/Swiften/MUC/MUC.cpp @@ -13,15 +13,18 @@ #include "Swiften/Presence/PresenceSender.h" #include "Swiften/Client/StanzaChannel.h" +#include "Swiften/Queries/IQRouter.h" +#include "Swiften/Elements/Form.h" #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/MUCUserPayload.h" +#include "Swiften/Elements/MUCOwnerPayload.h" #include "Swiften/Elements/MUCPayload.h" namespace Swift { typedef std::pair<String, MUCOccupant> StringMUCOccupantPair; -MUC::MUC(StanzaChannel* stanzaChannel, PresenceSender* presenceSender, const JID &muc) : ownMUCJID(muc), stanzaChannel(stanzaChannel), presenceSender(presenceSender) { +MUC::MUC(StanzaChannel* stanzaChannel, IQRouter* iqRouter, PresenceSender* presenceSender, const JID &muc) : ownMUCJID(muc), stanzaChannel(stanzaChannel), iqRouter_(iqRouter), presenceSender(presenceSender), muc_(muc) { scopedConnection_ = stanzaChannel->onPresenceReceived.connect(boost::bind(&MUC::handleIncomingPresence, this, _1)); } @@ -134,6 +137,14 @@ void MUC::handleIncomingPresence(boost::shared_ptr<Presence> presence) { onJoinComplete(getOwnNick()); presenceSender->addDirectedPresenceReceiver(ownMUCJID); } + if (status.code == 201) { + /* Room is created and locked */ + /* Currently deal with this by making an instant room */ + boost::shared_ptr<MUCOwnerPayload> mucPayload(new MUCOwnerPayload()); + mucPayload->setPayload(boost::shared_ptr<Payload>(new Form(Form::SubmitType))); + boost::shared_ptr<IQ> iq(IQ::createRequest(IQ::Set, muc_, iqRouter_->getNewIQID(), mucPayload)); + iqRouter_->sendIQ(iq); + } } } diff --git a/Swiften/MUC/MUC.h b/Swiften/MUC/MUC.h index bccc26c..af3daa8 100644 --- a/Swiften/MUC/MUC.h +++ b/Swiften/MUC/MUC.h @@ -20,6 +20,7 @@ namespace Swift { class StanzaChannel; + class IQRouter; class PresenceSender; class MUC { @@ -28,7 +29,7 @@ namespace Swift { enum LeavingType { Part, Disconnect }; public: - MUC(StanzaChannel* stanzaChannel, PresenceSender* presenceSender, const JID &muc); + MUC(StanzaChannel* stanzaChannel, IQRouter* iqRouter, PresenceSender* presenceSender, const JID &muc); void joinAs(const String &nick); /*void queryRoomInfo(); */ @@ -66,7 +67,9 @@ namespace Swift { private: JID ownMUCJID; StanzaChannel* stanzaChannel; + IQRouter* iqRouter_; PresenceSender* presenceSender; + JID muc_; std::map<String, MUCOccupant> occupants; bool joinComplete_; boost::bsignals::scoped_connection scopedConnection_; |