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

This commit is contained in:
Jan Kaluza 2016-02-08 20:13:43 +01:00
parent 603b6b9ecd
commit 80d1f8f90f
3 changed files with 17 additions and 3 deletions

View file

@ -98,9 +98,7 @@ class Conversation {
m_jids.clear(); m_jids.clear();
} }
void removeJID(const Swift::JID &jid) { void removeJID(const Swift::JID &jid);
m_jids.remove(jid);
}
const std::list<Swift::JID> &getJIDs() { const std::list<Swift::JID> &getJIDs() {
return m_jids; return m_jids;

View file

@ -360,6 +360,10 @@ void Conversation::handleRawPresence(Swift::Presence::ref presence) {
m_participants[presence->getFrom().getResource()].presence = 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) { 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); Swift::Presence::ref presence = generatePresence(alias.empty() ? nick : alias, flag, status, statusMessage, newname, iconhash);

View file

@ -103,8 +103,20 @@ void ConversationManager::resetResources() {
} }
void ConversationManager::removeJID(const Swift::JID &jid) { 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++) { for (std::map<std::string, Conversation *>::const_iterator it = m_convs.begin(); it != m_convs.end(); it++) {
(*it).second->removeJID(jid); (*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();
}
} }
} }