summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-09-27 16:13:56 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-09-27 16:38:45 (GMT)
commit41854ebf8c3376d6ee430efe3a9fdd25610bb2f5 (patch)
tree81e918793afb16accb29af46ccd99eefa204930c /Swift/Controllers
parent24e53876500f0f5497a84b239d9350676e95751a (diff)
downloadswift-contrib-41854ebf8c3376d6ee430efe3a9fdd25610bb2f5.zip
swift-contrib-41854ebf8c3376d6ee430efe3a9fdd25610bb2f5.tar.bz2
Allow room configuration.
Resolves: #989
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.h2
-rw-r--r--Swift/Controllers/Chat/MUCController.cpp23
-rw-r--r--Swift/Controllers/Chat/MUCController.h4
-rw-r--r--Swift/Controllers/UIInterfaces/ChatWindow.h10
-rw-r--r--Swift/Controllers/UnitTest/MockChatWindow.h1
5 files changed, 32 insertions, 8 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h
index 79d376c..67bd74f 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.h
+++ b/Swift/Controllers/Chat/ChatControllerBase.h
@@ -70,6 +70,7 @@ namespace Swift {
virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message>) const = 0;
virtual void dayTicked() {};
virtual void handleBareJIDCapsChanged(const JID& jid) = 0;
+ std::string getErrorMessage(boost::shared_ptr<ErrorPayload>);
private:
IDGenerator idGenerator_;
@@ -78,7 +79,6 @@ namespace Swift {
void handleSendMessageRequest(const std::string &body, bool isCorrectionMessage);
void handleAllMessagesRead();
void handleSecurityLabelsCatalogResponse(boost::shared_ptr<SecurityLabelsCatalog>, ErrorPayload::ref error);
- std::string getErrorMessage(boost::shared_ptr<ErrorPayload>);
void handleDayChangeTick();
protected:
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index 178f4b6..56cc639 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -72,13 +72,15 @@ MUCController::MUCController (
chatWindow_->onOccupantSelectionChanged.connect(boost::bind(&MUCController::handleWindowOccupantSelectionChanged, this, _1));
chatWindow_->onOccupantActionSelected.connect(boost::bind(&MUCController::handleActionRequestedOnOccupant, this, _1, _2));
chatWindow_->onChangeSubjectRequest.connect(boost::bind(&MUCController::handleChangeSubjectRequest, this, _1));
- chatWindow_->onConfigureRequest.connect(boost::bind(&MUCController::handleConfigureRequest, this));
+ chatWindow_->onConfigureRequest.connect(boost::bind(&MUCController::handleConfigureRequest, 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));
muc_->onOccupantPresenceChange.connect(boost::bind(&MUCController::handleOccupantPresenceChange, this, _1));
muc_->onOccupantLeft.connect(boost::bind(&MUCController::handleOccupantLeft, this, _1, _2, _3));
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));
if (timerFactory) {
loginCheckTimer_ = boost::shared_ptr<Timer>(timerFactory->createTimer(MUC_JOIN_WARNING_TIMEOUT_MILLISECONDS));
loginCheckTimer_->onTick.connect(boost::bind(&MUCController::handleJoinTimeoutTick, this));
@@ -577,8 +579,23 @@ void MUCController::handleChangeSubjectRequest(const std::string& subject) {
muc_->changeSubject(subject);
}
-void MUCController::handleConfigureRequest() {
- muc_->requestConfigurationForm();
+void MUCController::handleConfigureRequest(Form::ref form) {
+ if (form) {
+ muc_->configureRoom(form);
+ }
+ else {
+ muc_->requestConfigurationForm();
+ }
+}
+
+void MUCController::handleConfigurationFailed(ErrorPayload::ref error) {
+ std::string errorMessage = getErrorMessage(error);
+ errorMessage = str(format(QT_TRANSLATE_NOOP("", "Room configuration 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 08a3fc3..4be1488 100644
--- a/Swift/Controllers/Chat/MUCController.h
+++ b/Swift/Controllers/Chat/MUCController.h
@@ -88,7 +88,9 @@ namespace Swift {
void dayTicked() {lastWasPresence_ = false;}
void processUserPart();
void handleBareJIDCapsChanged(const JID& jid);
- void handleConfigureRequest();
+ void handleConfigureRequest(Form::ref);
+ void handleConfigurationFailed(ErrorPayload::ref);
+ void handleConfigurationFormReceived(Form::ref);
private:
MUC::ref muc_;
diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h
index 7004324..75c92d3 100644
--- a/Swift/Controllers/UIInterfaces/ChatWindow.h
+++ b/Swift/Controllers/UIInterfaces/ChatWindow.h
@@ -14,8 +14,10 @@
#include <vector>
#include <string>
-#include "Swiften/Elements/SecurityLabelsCatalog.h"
-#include "Swiften/Elements/ChatState.h"
+#include <Swiften/Elements/SecurityLabelsCatalog.h>
+#include <Swiften/Elements/ChatState.h>
+#include <Swiften/Elements/Form.h>
+
namespace Swift {
class AvatarManager;
@@ -87,6 +89,8 @@ namespace Swift {
* Actions that can be performed on the selected occupant.
*/
virtual void setAvailableOccupantActions(const std::vector<OccupantAction>& actions) = 0;
+
+ virtual void showRoomConfigurationForm(Form::ref) = 0;
boost::signal<void ()> onClosed;
boost::signal<void ()> onAllMessagesRead;
boost::signal<void (const std::string&, bool isCorrection)> onSendMessageRequest;
@@ -97,7 +101,7 @@ namespace Swift {
boost::signal<void (ContactRosterItem*)> onOccupantSelectionChanged;
boost::signal<void (ChatWindow::OccupantAction, ContactRosterItem*)> onOccupantActionSelected;
boost::signal<void (const std::string&)> onChangeSubjectRequest;
- boost::signal<void ()> onConfigureRequest;
+ boost::signal<void (Form::ref)> onConfigureRequest;
// 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 143e281..ad8856b 100644
--- a/Swift/Controllers/UnitTest/MockChatWindow.h
+++ b/Swift/Controllers/UnitTest/MockChatWindow.h
@@ -47,6 +47,7 @@ namespace Swift {
virtual void setCorrectionEnabled(Tristate /*enabled*/) {}
void setAvailableOccupantActions(const std::vector<OccupantAction>&/* actions*/) {}
void setSubject(const std::string& /*subject*/) {}
+ virtual void showRoomConfigurationForm(Form::ref) {}
boost::signal<void ()> onClosed;
boost::signal<void ()> onAllMessagesRead;