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 /Swift/Controllers/Chat | |
parent | 8159071adb232b68c2ce79479145fbcd04979245 (diff) | |
download | swift-contrib-16a895e7d64b71d1aa7a971d77e8daf6591e9c56.zip swift-contrib-16a895e7d64b71d1aa7a971d77e8daf6591e9c56.tar.bz2 |
Allow role changing in MUCs.
Resolves: #987
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 17 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.h | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 2b8a8b7..e413d92 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -85,6 +85,7 @@ MUCController::MUCController ( muc_->onOccupantRoleChanged.connect(boost::bind(&MUCController::handleOccupantRoleChanged, this, _1, _2, _3)); muc_->onConfigurationFailed.connect(boost::bind(&MUCController::handleConfigurationFailed, this, _1)); muc_->onConfigurationFormReceived.connect(boost::bind(&MUCController::handleConfigurationFormReceived, this, _1)); + muc_->onRoleChangeFailed.connect(boost::bind(&MUCController::handleOccupantRoleChangeFailed, this, _1, _2, _3)); if (timerFactory) { loginCheckTimer_ = boost::shared_ptr<Timer>(timerFactory->createTimer(MUC_JOIN_WARNING_TIMEOUT_MILLISECONDS)); loginCheckTimer_->onTick.connect(boost::bind(&MUCController::handleJoinTimeoutTick, this)); @@ -110,16 +111,22 @@ MUCController::~MUCController() { void MUCController::handleWindowOccupantSelectionChanged(ContactRosterItem* item) { std::vector<ChatWindow::OccupantAction> actions; - //FIXME + /* FIXME: all of these should be conditional */ if (item) { actions.push_back(ChatWindow::Kick); + actions.push_back(ChatWindow::MakeModerator); + actions.push_back(ChatWindow::MakeParticipant); + actions.push_back(ChatWindow::MakeVisitor); } chatWindow_->setAvailableOccupantActions(actions); } void MUCController::handleActionRequestedOnOccupant(ChatWindow::OccupantAction action, ContactRosterItem* item) { switch (action) { - case ChatWindow::Kick: muc_->kickUser(item->getJID());break; + case ChatWindow::Kick: muc_->kickOccupant(item->getJID());break; + case ChatWindow::MakeModerator: muc_->changeOccupantRole(item->getJID(), MUCOccupant::Moderator);break; + case ChatWindow::MakeParticipant: muc_->changeOccupantRole(item->getJID(), MUCOccupant::Participant);break; + case ChatWindow::MakeVisitor: muc_->changeOccupantRole(item->getJID(), MUCOccupant::Visitor);break; } } @@ -601,6 +608,12 @@ void MUCController::handleConfigurationFailed(ErrorPayload::ref error) { chatWindow_->addErrorMessage(errorMessage); } +void MUCController::handleOccupantRoleChangeFailed(ErrorPayload::ref error, const JID&, MUCOccupant::Role) { + std::string errorMessage = getErrorMessage(error); + errorMessage = str(format(QT_TRANSLATE_NOOP("", "Occupant role change failed: %1%.")) % errorMessage); + chatWindow_->addErrorMessage(errorMessage); +} + void MUCController::handleConfigurationFormReceived(Form::ref form) { chatWindow_->showRoomConfigurationForm(form); } diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index d22d2ca..19d3f66 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -94,6 +94,7 @@ namespace Swift { void handleDestroyRoomRequest(); void handleInvitePersonToThisMUCRequest(const JID& jid, const std::string& reason); void handleConfigurationCancelled(); + void handleOccupantRoleChangeFailed(ErrorPayload::ref, const JID&, MUCOccupant::Role); private: MUC::ref muc_; |