summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-10-07 14:09:27 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-10-07 14:11:23 (GMT)
commitb2f58c4f3eb93e3a32062670df5eb6682aed273a (patch)
tree737884f5e3e826407466290cf7c324c4f0069dd0 /Swift/Controllers
parent7f7b05d8d242a9b73b7d9f971779c6af19980f76 (diff)
downloadswift-contrib-b2f58c4f3eb93e3a32062670df5eb6682aed273a.zip
swift-contrib-b2f58c4f3eb93e3a32062670df5eb6682aed273a.tar.bz2
Allow affiliation editing in MUCs.
Resolves: #986 Resolves: #988
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp26
-rw-r--r--Swift/Controllers/Chat/MUCController.h3
-rw-r--r--Swift/Controllers/UIInterfaces/ChatWindow.h7
-rw-r--r--Swift/Controllers/UnitTest/MockChatWindow.h1
4 files changed, 35 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index e413d92..30e85ad 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -77,6 +77,8 @@ MUCController::MUCController (
chatWindow_->onConfigurationFormCancelled.connect(boost::bind(&MUCController::handleConfigurationCancelled, this));
chatWindow_->onDestroyRequest.connect(boost::bind(&MUCController::handleDestroyRoomRequest, this));
chatWindow_->onInvitePersonToThisMUCRequest.connect(boost::bind(&MUCController::handleInvitePersonToThisMUCRequest, this, _1, _2));
+ chatWindow_->onGetAffiliationsRequest.connect(boost::bind(&MUCController::handleGetAffiliationsRequest, this));
+ chatWindow_->onChangeAffiliationsRequest.connect(boost::bind(&MUCController::handleChangeAffiliationsRequest, this, _1));
muc_->onJoinComplete.connect(boost::bind(&MUCController::handleJoinComplete, this, _1));
muc_->onJoinFailed.connect(boost::bind(&MUCController::handleJoinFailed, this, _1));
muc_->onOccupantJoined.connect(boost::bind(&MUCController::handleOccupantJoined, this, _1));
@@ -86,6 +88,7 @@ MUCController::MUCController (
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));
+ muc_->onAffiliationListReceived.connect(boost::bind(&MUCController::handleAffiliationListReceived, this, _1, _2));
if (timerFactory) {
loginCheckTimer_ = boost::shared_ptr<Timer>(timerFactory->createTimer(MUC_JOIN_WARNING_TIMEOUT_MILLISECONDS));
loginCheckTimer_->onTick.connect(boost::bind(&MUCController::handleJoinTimeoutTick, this));
@@ -114,6 +117,7 @@ void MUCController::handleWindowOccupantSelectionChanged(ContactRosterItem* item
/* FIXME: all of these should be conditional */
if (item) {
actions.push_back(ChatWindow::Kick);
+ actions.push_back(ChatWindow::Ban);
actions.push_back(ChatWindow::MakeModerator);
actions.push_back(ChatWindow::MakeParticipant);
actions.push_back(ChatWindow::MakeVisitor);
@@ -124,6 +128,7 @@ void MUCController::handleWindowOccupantSelectionChanged(ContactRosterItem* item
void MUCController::handleActionRequestedOnOccupant(ChatWindow::OccupantAction action, ContactRosterItem* item) {
switch (action) {
case ChatWindow::Kick: muc_->kickOccupant(item->getJID());break;
+ case ChatWindow::Ban: muc_->changeAffiliation(item->getJID(), MUCOccupant::Outcast);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;
@@ -201,7 +206,7 @@ void MUCController::handleJoinFailed(boost::shared_ptr<ErrorPayload> error) {
break;
case ErrorPayload::NotAuthorized:
errorMessage += ": ";
- errorMessage += QT_TRANSLATE_NOOP("", "A password needed");
+ errorMessage += QT_TRANSLATE_NOOP("", "A password is needed");
break;
case ErrorPayload::RegistrationRequired:
errorMessage += ": ";
@@ -630,4 +635,23 @@ void MUCController::handleInvitePersonToThisMUCRequest(const JID& jid, const std
muc_->invitePerson(jid, reason);
}
+void MUCController::handleGetAffiliationsRequest() {
+ muc_->requestAffiliationList(MUCOccupant::Owner);
+ muc_->requestAffiliationList(MUCOccupant::Admin);
+ muc_->requestAffiliationList(MUCOccupant::Member);
+ muc_->requestAffiliationList(MUCOccupant::Outcast);
+}
+
+typedef std::pair<MUCOccupant::Affiliation, JID> AffiliationChangePair;
+
+void MUCController::handleChangeAffiliationsRequest(const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes) {
+ foreach (const AffiliationChangePair& change, changes) {
+ muc_->changeAffiliation(change.second, change.first);
+ }
+}
+
+void MUCController::handleAffiliationListReceived(MUCOccupant::Affiliation affiliation, const std::vector<JID>& jids) {
+ chatWindow_->setAffiliations(affiliation, jids);
+}
+
}
diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h
index 19d3f66..16dcb99 100644
--- a/Swift/Controllers/Chat/MUCController.h
+++ b/Swift/Controllers/Chat/MUCController.h
@@ -95,6 +95,9 @@ namespace Swift {
void handleInvitePersonToThisMUCRequest(const JID& jid, const std::string& reason);
void handleConfigurationCancelled();
void handleOccupantRoleChangeFailed(ErrorPayload::ref, const JID&, MUCOccupant::Role);
+ void handleGetAffiliationsRequest();
+ void handleAffiliationListReceived(MUCOccupant::Affiliation affiliation, const std::vector<JID>& jids);
+ void handleChangeAffiliationsRequest(const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes);
private:
MUC::ref muc_;
diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h
index 4a93b42..6fce7a0 100644
--- a/Swift/Controllers/UIInterfaces/ChatWindow.h
+++ b/Swift/Controllers/UIInterfaces/ChatWindow.h
@@ -17,6 +17,7 @@
#include <Swiften/Elements/SecurityLabelsCatalog.h>
#include <Swiften/Elements/ChatState.h>
#include <Swiften/Elements/Form.h>
+#include <Swiften/Elements/MUCOccupant.h>
namespace Swift {
@@ -32,7 +33,7 @@ namespace Swift {
public:
enum AckState {Pending, Received, Failed};
enum Tristate {Yes, No, Maybe};
- enum OccupantAction {Kick, MakeModerator, MakeParticipant, MakeVisitor};
+ enum OccupantAction {Kick, Ban, MakeModerator, MakeParticipant, MakeVisitor};
enum FileTransferState {WaitingForAccept, Negotiating, Transferring, Canceled, Finished, FTFailed};
ChatWindow() {}
virtual ~ChatWindow() {};
@@ -75,6 +76,7 @@ namespace Swift {
virtual void setAckState(const std::string& id, AckState state) = 0;
virtual void flash() = 0;
virtual void setSubject(const std::string& subject) = 0;
+ virtual void setAffiliations(MUCOccupant::Affiliation, const std::vector<JID>&) = 0;
/**
* Set an alert on the window.
@@ -112,6 +114,9 @@ namespace Swift {
boost::signal<void ()> onDestroyRequest;
boost::signal<void (const JID&, const std::string& /*reason*/)> onInvitePersonToThisMUCRequest;
boost::signal<void ()> onConfigurationFormCancelled;
+ boost::signal<void ()> onGetAffiliationsRequest;
+ boost::signal<void (MUCOccupant::Affiliation, const JID&)> onSetAffiliationRequest;
+ boost::signal<void (const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes)> onChangeAffiliationsRequest;
// File transfer related
boost::signal<void (std::string /* id */)> onFileTransferCancel;
diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h
index 7b90a57..7e31179 100644
--- a/Swift/Controllers/UnitTest/MockChatWindow.h
+++ b/Swift/Controllers/UnitTest/MockChatWindow.h
@@ -49,6 +49,7 @@ namespace Swift {
void setSubject(const std::string& /*subject*/) {}
virtual void showRoomConfigurationForm(Form::ref) {}
virtual void addMUCInvitation(const JID& /*jid*/, const std::string& /*reason*/, const std::string& /*password*/) {};
+ virtual void setAffiliations(MUCOccupant::Affiliation, const std::vector<JID>&) {}
std::string name_;
std::string lastMessageBody_;