diff options
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_; |