Changeset - 6ac59201016e
[Not reviewed]
0 1 0
HanzZ - 14 years ago 2011-05-21 09:56:47
hanzz.k@gmail.com
Destroy all conversations when user logout
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/conversationmanager.cpp
Show inline comments
 
@@ -15,48 +15,51 @@
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#include "transport/conversationmanager.h"
 
#include "transport/conversation.h"
 
#include "transport/usermanager.h"
 
#include "transport/buddy.h"
 
#include "transport/factory.h"
 
#include "transport/user.h"
 
#include "Swiften/Roster/SetRosterRequest.h"
 
#include "Swiften/Elements/RosterPayload.h"
 
#include "Swiften/Elements/RosterItemPayload.h"
 

	
 
namespace Transport {
 

	
 
ConversationManager::ConversationManager(User *user, Component *component){
 
	m_user = user;
 
	m_component = component;
 
}
 

	
 
ConversationManager::~ConversationManager() {
 
	while(!m_convs.empty()) {
 
		delete (*m_convs.begin()).second;
 
	}
 
}
 

	
 
void ConversationManager::setConversation(Conversation *conv) {
 
	m_convs[conv->getLegacyName()] = conv;
 
}
 

	
 
void ConversationManager::unsetConversation(Conversation *conv) {
 
	for (std::map<std::string, Conversation *>::const_iterator it = m_convs.begin(); it != m_convs.end(); it++) {
 
		if ((*it).second->getRoom() == conv->getLegacyName()) {
 
			(*it).second->setRoom("");
 
		}
 
	}
 
	m_convs.erase(conv->getLegacyName());
 
}
 

	
 
void ConversationManager::handleMessageReceived(Swift::Message::ref message) {
 
	std::string name = message->getTo().getUnescapedNode();
 
	if (name.find_last_of("%") != std::string::npos) {
 
		name.replace(name.find_last_of("%"), 1, "@");
 
	}
 

	
 
	if (!m_convs[name]) {
 
		m_convs[name] = m_component->getFactory()->createConversation(this, name);
 
	}
0 comments (0 inline, 0 general)