diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-10-05 13:39:47 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-10-05 13:39:47 (GMT) |
commit | 16a895e7d64b71d1aa7a971d77e8daf6591e9c56 (patch) | |
tree | 9c1c71eb1a80dd0fd813ea6ba42d1d4c7d4889ed /Swiften/MUC | |
parent | 8159071adb232b68c2ce79479145fbcd04979245 (diff) | |
download | swift-16a895e7d64b71d1aa7a971d77e8daf6591e9c56.zip swift-16a895e7d64b71d1aa7a971d77e8daf6591e9c56.tar.bz2 |
Allow role changing in MUCs.
Resolves: #987
Diffstat (limited to 'Swiften/MUC')
-rw-r--r-- | Swiften/MUC/MUC.cpp | 15 | ||||
-rw-r--r-- | Swiften/MUC/MUC.h | 7 |
2 files changed, 14 insertions, 8 deletions
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp index 15355ad..204fdcc 100644 --- a/Swiften/MUC/MUC.cpp +++ b/Swiften/MUC/MUC.cpp @@ -237,20 +237,25 @@ MUCOccupant MUC::getOccupant(const std::string& nick) { return occupants.find(nick)->second; } -void MUC::kickUser(const JID& jid) { +void MUC::kickOccupant(const JID& jid) { + changeOccupantRole(jid, MUCOccupant::NoRole); +} + +void MUC::changeOccupantRole(const JID& jid, MUCOccupant::Role role) { MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>(); MUCItem item; - item.role = MUCOccupant::NoRole; + item.role = role; item.nick = jid.getResource(); mucPayload->addItem(item); GenericRequest<MUCAdminPayload>* request = new GenericRequest<MUCAdminPayload>(IQ::Set, getJID(), mucPayload, iqRouter_); - request->onResponse.connect(boost::bind(&MUC::handleKickResponse, this, _1, _2, jid)); + request->onResponse.connect(boost::bind(&MUC::handleOccupantRoleChangeResponse, this, _1, _2, jid, role)); request->send(); + } -void MUC::handleKickResponse(MUCAdminPayload::ref /*unused*/, ErrorPayload::ref error, const JID& jid) { +void MUC::handleOccupantRoleChangeResponse(MUCAdminPayload::ref /*unused*/, ErrorPayload::ref error, const JID& jid, MUCOccupant::Role role) { if (error) { - onKickFailed(error, jid); + onRoleChangeFailed(error, jid, role); } } diff --git a/Swiften/MUC/MUC.h b/Swiften/MUC/MUC.h index a9b42b8..d855033 100644 --- a/Swiften/MUC/MUC.h +++ b/Swiften/MUC/MUC.h @@ -56,7 +56,8 @@ namespace Swift { /** Get occupant information*/ MUCOccupant getOccupant(const std::string& nick); bool hasOccupant(const std::string& nick); - void kickUser(const JID& jid); + void kickOccupant(const JID& jid); + void changeOccupantRole(const JID& jid, MUCOccupant::Role role); void changeSubject(const std::string& subject); void requestConfigurationForm(); void configureRoom(Form::ref); @@ -69,7 +70,7 @@ namespace Swift { public: boost::signal<void (const std::string& /*nick*/)> onJoinComplete; boost::signal<void (ErrorPayload::ref)> onJoinFailed; - boost::signal<void (ErrorPayload::ref, const JID&)> onKickFailed; + boost::signal<void (ErrorPayload::ref, const JID&, MUCOccupant::Role)> onRoleChangeFailed; boost::signal<void (ErrorPayload::ref)> onConfigurationFailed; boost::signal<void (Presence::ref)> onOccupantPresenceChange; boost::signal<void (const std::string&, const MUCOccupant& /*now*/, const MUCOccupant::Role& /*old*/)> onOccupantRoleChanged; @@ -94,7 +95,7 @@ namespace Swift { void handleIncomingPresence(Presence::ref presence); void internalJoin(const std::string& nick); void handleCreationConfigResponse(MUCOwnerPayload::ref, ErrorPayload::ref); - void handleKickResponse(MUCAdminPayload::ref, ErrorPayload::ref, const JID&); + void handleOccupantRoleChangeResponse(MUCAdminPayload::ref, ErrorPayload::ref, const JID&, MUCOccupant::Role); void handleConfigurationFormReceived(MUCOwnerPayload::ref, ErrorPayload::ref); void handleConfigurationResultReceived(MUCOwnerPayload::ref, ErrorPayload::ref); |