diff options
author | Tobias Markmann <tm@ayena.de> | 2012-03-27 23:01:17 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-04-12 14:09:34 (GMT) |
commit | 2dcdee8e9f657c7f5c5d5c507373fd328beaa568 (patch) | |
tree | f6c0516afefdcf1561e32b45a415a387bc71f9d3 /Swift/Controllers/Chat | |
parent | 0bf6afc5c01b9eb3024a8cfd04bfd743890db4f6 (diff) | |
download | swift-contrib-2dcdee8e9f657c7f5c5d5c507373fd328beaa568.zip swift-contrib-2dcdee8e9f657c7f5c5d5c507373fd328beaa568.tar.bz2 |
Refactoring incoming MUC invites UI.
Making MUC invites non-modal by moving them into the chat view.
Adding event classes for invites so they turn up in 'Notices'-tab and generate notifications.
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.cpp | 22 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.h | 4 |
2 files changed, 21 insertions, 5 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index f590ffd..8523591 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -29,6 +29,7 @@ #include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h> #include <Swiften/Queries/Requests/GetSecurityLabelsCatalogRequest.h> #include <Swiften/Avatars/AvatarManager.h> +#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> namespace Swift { @@ -91,8 +92,8 @@ void ChatControllerBase::setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> void ChatControllerBase::handleAllMessagesRead() { if (!unreadMessages_.empty()) { - foreach (boost::shared_ptr<MessageEvent> messageEvent, unreadMessages_) { - messageEvent->read(); + foreach (boost::shared_ptr<StanzaEvent> stanzaEvent, unreadMessages_) { + stanzaEvent->conclude(); } unreadMessages_.clear(); chatWindow_->setUnreadMessageCount(0); @@ -267,9 +268,20 @@ std::string ChatControllerBase::getErrorMessage(boost::shared_ptr<ErrorPayload> return defaultMessage; } +void ChatControllerBase::handleGeneralMUCInvitation(MUCInviteEvent::ref event) { + unreadMessages_.push_back(event); + chatWindow_->show(); + chatWindow_->setUnreadMessageCount(unreadMessages_.size()); + onUnreadCountChanged(); + chatWindow_->addMUCInvitation(senderDisplayNameFromMessage(event->getInviter()), event->getRoomJID(), event->getReason(), event->getPassword(), event->getDirect()); + eventController_->handleIncomingEvent(event); +} + void ChatControllerBase::handleMUCInvitation(Message::ref message) { MUCInvitationPayload::ref invite = message->getPayload<MUCInvitationPayload>(); - chatWindow_->addMUCInvitation(invite->getJID(), invite->getReason(), invite->getPassword()); + + MUCInviteEvent::ref inviteEvent = boost::make_shared<MUCInviteEvent>(toJID_, invite->getJID(), invite->getReason(), invite->getPassword(), true); + handleGeneralMUCInvitation(inviteEvent); } void ChatControllerBase::handleMediatedMUCInvitation(Message::ref message) { @@ -283,7 +295,9 @@ void ChatControllerBase::handleMediatedMUCInvitation(Message::ref message) { if (message->getPayload<MUCUserPayload>()->getPassword()) { password = *message->getPayload<MUCUserPayload>()->getPassword(); } - chatWindow_->addMUCInvitation(from, reason, password, false); + + MUCInviteEvent::ref inviteEvent = boost::make_shared<MUCInviteEvent>(invite.from, from, reason, password, false); + handleGeneralMUCInvitation(inviteEvent); } diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index e1034d6..a4d23c0 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -20,6 +20,7 @@ #include <string> #include "Swiften/Elements/DiscoInfo.h" #include "Swift/Controllers/XMPPEvents/MessageEvent.h" +#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> #include "Swiften/JID/JID.h" #include "Swiften/Elements/SecurityLabelsCatalog.h" #include "Swiften/Elements/ErrorPayload.h" @@ -84,10 +85,11 @@ namespace Swift { void handleDayChangeTick(); void handleMUCInvitation(Message::ref message); void handleMediatedMUCInvitation(Message::ref message); + void handleGeneralMUCInvitation(MUCInviteEvent::ref event); protected: JID selfJID_; - std::vector<boost::shared_ptr<MessageEvent> > unreadMessages_; + std::vector<boost::shared_ptr<StanzaEvent> > unreadMessages_; StanzaChannel* stanzaChannel_; IQRouter* iqRouter_; ChatWindowFactory* chatWindowFactory_; |