diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-10-02 17:38:56 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-10-03 07:02:37 (GMT) |
commit | 4ea336d9d124f1c761b22943eaf6771e16a61e58 (patch) | |
tree | 7bcb7ac4366cf31a2f98654a5859de0b32fb318a /Swift/Controllers/Chat | |
parent | 123502d97dc20357ea03fd7f238f117aeb2d05c3 (diff) | |
download | swift-contrib-4ea336d9d124f1c761b22943eaf6771e16a61e58.zip swift-contrib-4ea336d9d124f1c761b22943eaf6771e16a61e58.tar.bz2 |
Simple MUC invites.
Resolves: #152
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.cpp | 30 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 7 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 5 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.h | 1 |
5 files changed, 31 insertions, 13 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index df59c2f..4bcb4c7 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -16,16 +16,17 @@ #include <Swift/Controllers/Intl.h> #include <Swiften/Base/format.h> -#include "Swiften/Base/String.h" -#include "Swiften/Client/StanzaChannel.h" -#include "Swiften/Elements/Delay.h" -#include "Swiften/Base/foreach.h" -#include "Swift/Controllers/XMPPEvents/EventController.h" -#include "Swiften/Disco/EntityCapsProvider.h" -#include "Swift/Controllers/UIInterfaces/ChatWindow.h" -#include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h" -#include "Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h" -#include "Swiften/Avatars/AvatarManager.h" +#include <Swiften/Base/String.h> +#include <Swiften/Client/StanzaChannel.h> +#include <Swiften/Elements/Delay.h> +#include <Swiften/Elements/MUCInvitationPayload.h> +#include <Swiften/Base/foreach.h> +#include <Swift/Controllers/XMPPEvents/EventController.h> +#include <Swiften/Disco/EntityCapsProvider.h> +#include <Swift/Controllers/UIInterfaces/ChatWindow.h> +#include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h> +#include <Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h> +#include <Swiften/Avatars/AvatarManager.h> namespace Swift { @@ -176,6 +177,10 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m std::string errorMessage = str(format(QT_TRANSLATE_NOOP("", "Couldn't send message: %1%")) % getErrorMessage(message->getPayload<ErrorPayload>())); chatWindow_->addErrorMessage(errorMessage); } + else if (messageEvent->getStanza()->getPayload<MUCInvitationPayload>()) { + handleMUCInvitation(messageEvent->getStanza()); + return; + } else { if (!messageEvent->isReadable()) { return; @@ -256,4 +261,9 @@ std::string ChatControllerBase::getErrorMessage(boost::shared_ptr<ErrorPayload> return defaultMessage; } +void ChatControllerBase::handleMUCInvitation(Message::ref message) { + MUCInvitationPayload::ref invite = message->getPayload<MUCInvitationPayload>(); + chatWindow_->addMUCInvitation(invite->getJID(), invite->getReason(), invite->getPassword()); +} + } diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index 67bd74f..a857f3d 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -80,6 +80,7 @@ namespace Swift { void handleAllMessagesRead(); void handleSecurityLabelsCatalogResponse(boost::shared_ptr<SecurityLabelsCatalog>, ErrorPayload::ref error); void handleDayChangeTick(); + void handleMUCInvitation(Message::ref message); protected: JID selfJID_; diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 47a65a8..c0b2a7d 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -33,6 +33,7 @@ #include <Swift/Controllers/FileTransfer/FileTransferOverview.h> #include <Swift/Controllers/ProfileSettingsProvider.h> #include <Swiften/Avatars/AvatarManager.h> +#include <Swiften/Elements/MUCInvitationPayload.h> namespace Swift { @@ -516,12 +517,13 @@ void ChatsManager::handleSearchMUCRequest() { void ChatsManager::handleIncomingMessage(boost::shared_ptr<Message> message) { JID jid = message->getFrom(); boost::shared_ptr<MessageEvent> event(new MessageEvent(message)); - if (!event->isReadable() && !message->getPayload<ChatState>() && !message->hasSubject()) { + bool isInvite = message->getPayload<MUCInvitationPayload>(); + if (!event->isReadable() && !message->getPayload<ChatState>() && !isInvite && !message->hasSubject()) { return; } // Try to deliver it to a MUC - if (message->getType() == Message::Groupchat || message->getType() == Message::Error) { + if (message->getType() == Message::Groupchat || message->getType() == Message::Error || (isInvite && message->getType() == Message::Normal)) { std::map<JID, MUCController*>::iterator i = mucControllers_.find(jid.toBare()); if (i != mucControllers_.end()) { i->second->handleIncomingMessage(event); @@ -562,5 +564,4 @@ void ChatsManager::handleRecentActivated(const ChatListWindow::Chat& chat) { } } - } diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index e1d02ae..87d5a16 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -74,6 +74,7 @@ MUCController::MUCController ( chatWindow_->onChangeSubjectRequest.connect(boost::bind(&MUCController::handleChangeSubjectRequest, this, _1)); chatWindow_->onConfigureRequest.connect(boost::bind(&MUCController::handleConfigureRequest, this, _1)); chatWindow_->onDestroyRequest.connect(boost::bind(&MUCController::handleDestroyRoomRequest, this)); + chatWindow_->onInvitePersonToThisMUCRequest.connect(boost::bind(&MUCController::handleInvitePersonToThisMUCRequest, this, _1, _2)); 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)); @@ -603,4 +604,8 @@ void MUCController::handleDestroyRoomRequest() { muc_->destroyRoom(); } +void MUCController::handleInvitePersonToThisMUCRequest(const JID& jid, const std::string& reason) { + muc_->invitePerson(jid, reason); +} + } diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index 7a7461b..f83e2af 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -92,6 +92,7 @@ namespace Swift { void handleConfigurationFailed(ErrorPayload::ref); void handleConfigurationFormReceived(Form::ref); void handleDestroyRoomRequest(); + void handleInvitePersonToThisMUCRequest(const JID& jid, const std::string& reason); private: MUC::ref muc_; |