diff options
| author | Remko Tronçon <git@el-tramo.be> | 2009-11-25 21:34:08 (GMT) |
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2009-11-25 21:34:08 (GMT) |
| commit | 5498152b4c9537742019dd45db72c88d7e3dc70c (patch) | |
| tree | 94e7df9db7bd731eb342f05e200731b73319a176 /Swift/Controllers | |
| parent | db00adc9810377500e6ab27900b29496a0d05afe (diff) | |
| download | swift-5498152b4c9537742019dd45db72c88d7e3dc70c.zip swift-5498152b4c9537742019dd45db72c88d7e3dc70c.tar.bz2 | |
Avoid having unreadable events added to queue.
Diffstat (limited to 'Swift/Controllers')
| -rw-r--r-- | Swift/Controllers/MainController.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index d94cadc..e030a31 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -335,98 +335,97 @@ void MainController::logout() { setManagersEnabled(false); } void MainController::setManagersEnabled(bool enabled) { foreach (JIDChatControllerPair controllerPair, chatControllers_) { //printf("Setting enabled on %d to %d\n", controllerPair.second, enabled); controllerPair.second->setEnabled(enabled); } foreach (JIDMUCControllerPair controllerPair, mucControllers_) { controllerPair.second->setEnabled(enabled); } if (rosterController_) { rosterController_->setEnabled(enabled); } } void MainController::handleChatRequest(const String &contact) { ChatController* controller = getChatController(JID(contact)); controller->showChatWindow(); controller->activateChatWindow(); } ChatController* MainController::getChatController(const JID &contact) { JID lookupContact(contact); if (chatControllers_.find(lookupContact) == chatControllers_.end()) { lookupContact = JID(contact.toBare()); } if (chatControllers_.find(lookupContact) == chatControllers_.end()) { chatControllers_[contact] = new ChatController(jid_, client_, client_, chatWindowFactory_, contact, nickResolver_, presenceOracle_, avatarManager_); chatControllers_[contact]->setAvailableServerFeatures(serverDiscoInfo_); lookupContact = contact; } return chatControllers_[lookupContact]; } void MainController::handleChatControllerJIDChanged(const JID& from, const JID& to) { chatControllers_[to] = chatControllers_[from]; chatControllers_.erase(from); } void MainController::handleJoinMUCRequest(const JID &muc, const String &nick) { mucControllers_[muc] = new MUCController(jid_, muc, nick, client_, presenceSender_, client_, chatWindowFactory_, treeWidgetFactory_, presenceOracle_, avatarManager_); mucControllers_[muc]->setAvailableServerFeatures(serverDiscoInfo_); } void MainController::handleIncomingMessage(boost::shared_ptr<Message> message) { JID jid = message->getFrom(); boost::shared_ptr<MessageEvent> event(new MessageEvent(message)); + if (!event->isReadable()) { + return; + } // Try to deliver it to a MUC if (message->getType() == Message::Groupchat || message->getType() == Message::Error) { std::map<JID, MUCController*>::iterator i = mucControllers_.find(jid.toBare()); if (i != mucControllers_.end()) { i->second->handleIncomingMessage(event); return; } else if (message->getType() == Message::Groupchat) { //FIXME: Error handling - groupchat messages from an unknown muc. return; } } //if not a mucroom eventController_->handleIncomingEvent(event); - - // FIXME: This logic should go into a chat manager - if (event->isReadable()) { - getChatController(jid)->handleIncomingMessage(event); - } + getChatController(jid)->handleIncomingMessage(event); } void MainController::handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> info, const boost::optional<ErrorPayload>& error) { if (!error) { serverDiscoInfo_ = info; foreach (JIDChatControllerPair pair, chatControllers_) { pair.second->setAvailableServerFeatures(info); } foreach (JIDMUCControllerPair pair, mucControllers_) { pair.second->setAvailableServerFeatures(info); } } } bool MainController::isMUC(const JID& jid) const { return mucControllers_.find(jid.toBare()) != mucControllers_.end(); } void MainController::handleOwnVCardReceived(boost::shared_ptr<VCard> vCard, const boost::optional<ErrorPayload>& error) { if (!error && !vCard->getPhoto().isEmpty()) { vCardPhotoHash_ = SHA1::getHexHash(vCard->getPhoto()); if (lastSentPresence_) { sendPresence(lastSentPresence_); } avatarManager_->setAvatar(jid_, vCard->getPhoto()); } } } |
Swift