summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-10-28 12:35:56 (GMT)
committerTobias Markmann <tm@ayena.de>2014-10-28 12:35:56 (GMT)
commite6ae29065d034dc23a0cc0ac4874956b931dd1c9 (patch)
treefe40164e78baefe2f23543d9b295ff4645723294
parentfa67c2b239d9c7fc508205ea17724322011194f4 (diff)
downloadswift-contrib-e6ae29065d034dc23a0cc0ac4874956b931dd1c9.zip
swift-contrib-e6ae29065d034dc23a0cc0ac4874956b931dd1c9.tar.bz2
Only handle impromptu MUC invites once.
Added missing return-statement after handling the conversion from 1-to-1 to MUC. This lead to an additional tab being opened. In addition the indentation of the relevant block was wrong and is fixed now. Test-Information: Before there was a reproducible scenario: test@A starts to chat with test2@A. toast@A is on test@A's roster, but not on test2@A's roster. test@A drops toast@A on the running chat between test@A and test2@A. test@A and test2@A end up with the chat converted into a MUC. toast@A automatically joins the MUC. test2@A additionally has a new tab. Now test2@A does not have the additional tab anymore. Only the MUC tab which previously was a 1-to-1 tab. Change-Id: I32045812952c840f0f9c6da3a9aecf5c63797b64
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index 3ff2a3d..979f87a 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -857,82 +857,83 @@ void ChatsManager::handleUserNicknameChanged(MUCController* mucController, const
/*for (std::list<ChatListWindow::Chat>::iterator i = recentChats_.begin(); i != recentChats_.end(); i++) {
if (i->jid ==
}*/
}
}
void ChatsManager::handleIncomingMessage(boost::shared_ptr<Message> message) {
JID jid = message->getFrom();
boost::shared_ptr<MessageEvent> event(new MessageEvent(message));
bool isInvite = !!message->getPayload<MUCInvitationPayload>();
bool isMediatedInvite = (message->getPayload<MUCUserPayload>() && message->getPayload<MUCUserPayload>()->getInvite());
if (isMediatedInvite) {
jid = (*message->getPayload<MUCUserPayload>()->getInvite()).from;
}
if (!event->isReadable() && !message->getPayload<ChatState>() && !message->getPayload<DeliveryReceipt>() && !message->getPayload<DeliveryReceiptRequest>() && !isInvite && !isMediatedInvite && !message->hasSubject()) {
return;
}
// Try to deliver it to a MUC
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);
return;
}
else if (message->getType() == Message::Groupchat) {
//FIXME: Error handling - groupchat messages from an unknown muc.
return;
}
}
// check for impromptu invite to potentially auto-accept
MUCInvitationPayload::ref invite = message->getPayload<MUCInvitationPayload>();
if (invite && autoAcceptMUCInviteDecider_->isAutoAcceptedInvite(message->getFrom(), invite)) {
if (invite->getIsContinuation()) {
- // check for existing chat controller for the from JID
- ChatController* controller = getChatControllerIfExists(jid);
- if (controller) {
- ChatWindow* window = controller->detachChatWindow();
- chatControllers_.erase(jid);
- delete controller;
- handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true, window);
- }
- } else {
- handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true);
+ // check for existing chat controller for the from JID
+ ChatController* controller = getChatControllerIfExists(jid);
+ if (controller) {
+ ChatWindow* window = controller->detachChatWindow();
+ chatControllers_.erase(jid);
+ delete controller;
+ handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true, window);
return;
}
+ } else {
+ handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true);
+ return;
+ }
}
//if not a mucroom
if (!event->isReadable() && !isInvite && !isMediatedInvite) {
/* Only route such messages if a window exists, don't open new windows for them.*/
ChatController* controller = getChatControllerIfExists(jid);
if (controller) {
controller->handleIncomingMessage(event);
}
} else {
getChatControllerOrCreate(jid)->handleIncomingMessage(event);
}
}
void ChatsManager::handleMUCSelectedAfterSearch(const JID& muc) {
if (joinMUCWindow_) {
joinMUCWindow_->setMUC(muc.toString());
}
}
void ChatsManager::handleMUCBookmarkActivated(const MUCBookmark& mucBookmark) {
uiEventStream_->send(boost::make_shared<JoinMUCUIEvent>(mucBookmark.getRoom(), mucBookmark.getPassword(), mucBookmark.getNick()));
}
void ChatsManager::handleNewFileTransferController(FileTransferController* ftc) {
ChatController* chatController = getChatControllerOrCreate(ftc->getOtherParty());
chatController->handleNewFileTransferController(ftc);
chatController->activateChatWindow();
}
void ChatsManager::handleWhiteboardSessionRequest(const JID& contact, bool senderIsSelf) {
ChatController* chatController = getChatControllerOrCreate(contact);
chatController->handleWhiteboardSessionRequest(senderIsSelf);
chatController->activateChatWindow();
}