diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-10-07 14:09:27 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-10-07 14:11:23 (GMT) |
commit | b2f58c4f3eb93e3a32062670df5eb6682aed273a (patch) | |
tree | 737884f5e3e826407466290cf7c324c4f0069dd0 /Swiften/MUC/MUC.cpp | |
parent | 7f7b05d8d242a9b73b7d9f971779c6af19980f76 (diff) | |
download | swift-contrib-b2f58c4f3eb93e3a32062670df5eb6682aed273a.zip swift-contrib-b2f58c4f3eb93e3a32062670df5eb6682aed273a.tar.bz2 |
Allow affiliation editing in MUCs.
Resolves: #986
Resolves: #988
Diffstat (limited to 'Swiften/MUC/MUC.cpp')
-rw-r--r-- | Swiften/MUC/MUC.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp index 204fdcc..824ced1 100644 --- a/Swiften/MUC/MUC.cpp +++ b/Swiften/MUC/MUC.cpp @@ -241,6 +241,9 @@ void MUC::kickOccupant(const JID& jid) { changeOccupantRole(jid, MUCOccupant::NoRole); } +/** + * Call with the room JID, not the real JID. + */ void MUC::changeOccupantRole(const JID& jid, MUCOccupant::Role role) { MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>(); MUCItem item; @@ -259,6 +262,51 @@ void MUC::handleOccupantRoleChangeResponse(MUCAdminPayload::ref /*unused*/, Erro } } +void MUC::requestAffiliationList(MUCOccupant::Affiliation affiliation) { + MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>(); + MUCItem item; + item.affiliation = affiliation; + mucPayload->addItem(item); + GenericRequest<MUCAdminPayload>* request = new GenericRequest<MUCAdminPayload>(IQ::Get, getJID(), mucPayload, iqRouter_); + request->onResponse.connect(boost::bind(&MUC::handleAffiliationListResponse, this, _1, _2, affiliation)); + request->send(); +} + +/** + * Must be called with the real JID, not the room JID. + */ +void MUC::changeAffiliation(const JID& jid, MUCOccupant::Affiliation affiliation) { + MUCAdminPayload::ref mucPayload = boost::make_shared<MUCAdminPayload>(); + MUCItem item; + item.affiliation = affiliation; + item.realJID = jid; + mucPayload->addItem(item); + GenericRequest<MUCAdminPayload>* request = new GenericRequest<MUCAdminPayload>(IQ::Set, getJID(), mucPayload, iqRouter_); + request->onResponse.connect(boost::bind(&MUC::handleAffiliationChangeResponse, this, _1, _2, jid, affiliation)); + request->send(); +} + +void MUC::handleAffiliationListResponse(MUCAdminPayload::ref payload, ErrorPayload::ref error, MUCOccupant::Affiliation affiliation) { + if (error) { + onAffiliationListFailed(error); + } + else { + std::vector<JID> jids; + foreach (MUCItem item, payload->getItems()) { + if (item.realJID) { + jids.push_back(*item.realJID); + } + } + onAffiliationListReceived(affiliation, jids); + } +} + +void MUC::handleAffiliationChangeResponse(MUCAdminPayload::ref /*unused*/, ErrorPayload::ref error, const JID& jid, MUCOccupant::Affiliation affiliation) { + if (error) { + onAffiliationChangeFailed(error, jid, affiliation); + } +} + void MUC::changeSubject(const std::string& subject) { Message::ref message = boost::make_shared<Message>(); message->setSubject(subject); |