Changeset - 80d1f8f90fed
[Not reviewed]
0 3 0
Jan Kaluza - 10 years ago 2016-02-08 20:13:43
jkaluza@redhat.com
Libtransport: Disconnect from room when user is connected using multiple resources and he just disconnects one of them without sending unavailable presences to the rooms
3 files changed with 17 insertions and 3 deletions:
0 comments (0 inline, 0 general)
include/transport/Conversation.h
Show inline comments
 
@@ -95,15 +95,13 @@ class Conversation {
 
		}
 

	
 
		void clearJIDs() {
 
			m_jids.clear();
 
		}
 

	
 
		void removeJID(const Swift::JID &jid) {
 
			m_jids.remove(jid);
 
		}
 
		void removeJID(const Swift::JID &jid);
 

	
 
		const std::list<Swift::JID> &getJIDs() {
 
			return m_jids;
 
		}
 

	
 
		/// Sends message to Legacy network.
libtransport/Conversation.cpp
Show inline comments
 
@@ -357,12 +357,16 @@ void Conversation::setNickname(const std::string &nickname) {
 
void Conversation::handleRawPresence(Swift::Presence::ref presence) {
 
	// TODO: Detect nickname change.
 
	m_conversationManager->getComponent()->getFrontend()->sendPresence(presence);
 
	m_participants[presence->getFrom().getResource()].presence = presence;
 
}
 

	
 
void Conversation::removeJID(const Swift::JID &jid) {
 
	m_jids.remove(jid);
 
}
 

	
 
void Conversation::handleParticipantChanged(const std::string &nick, Conversation::ParticipantFlag flag, int status, const std::string &statusMessage, const std::string &newname, const std::string &iconhash, const std::string &alias) {
 
	Swift::Presence::ref presence = generatePresence(alias.empty() ? nick : alias, flag, status, statusMessage, newname, iconhash);
 

	
 
	if (presence->getType() == Swift::Presence::Unavailable) {
 
		m_participants.erase(nick);
 
	}
libtransport/ConversationManager.cpp
Show inline comments
 
@@ -100,14 +100,26 @@ void ConversationManager::resetResources() {
 
		}
 
		(*it).second->setJID(m_user->getJID().toBare());
 
	}
 
}
 

	
 
void ConversationManager::removeJID(const Swift::JID &jid) {
 
	std::vector<std::string> toRemove;
 
	for (std::map<std::string, Conversation *>::const_iterator it = m_convs.begin(); it != m_convs.end(); it++) {
 
		(*it).second->removeJID(jid);
 
		if (it->second->getJIDs().empty()) {
 
			toRemove.push_back(it->first);
 
		}
 
	}
 

	
 
	if (m_user->getUserSetting("stay_connected") != "1") {
 
		while(!toRemove.empty()) {
 
			LOG4CXX_INFO(logger, m_user->getJID().toString() << ": Leaving room " << toRemove.back() << ".");
 
			m_user->leaveRoom(toRemove.back());
 
			toRemove.pop_back();
 
		}
 
	}
 
}
 

	
 
void ConversationManager::clearJIDs() {
 
	for (std::map<std::string, Conversation *>::const_iterator it = m_convs.begin(); it != m_convs.end(); it++) {
 
		(*it).second->clearJIDs();
0 comments (0 inline, 0 general)