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:
parent
603b6b9ecd
commit
80d1f8f90f
3 changed files with 17 additions and 3 deletions
|
@ -98,9 +98,7 @@ class Conversation {
|
|||
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;
|
||||
|
|
|
@ -360,6 +360,10 @@ void Conversation::handleRawPresence(Swift::Presence::ref 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);
|
||||
|
||||
|
|
|
@ -103,8 +103,20 @@ void ConversationManager::resetResources() {
|
|||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue