Changeset - 672f91a63093
[Not reviewed]
0 3 0
Jan Kaluza - 13 years ago 2012-08-16 13:18:40
hanzz.k@gmail.com
Move Conversatino deletion into User class
3 files changed with 19 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/networkpluginserver.cpp
Show inline comments
 
@@ -1181,15 +1181,6 @@ void NetworkPluginServer::handleRoomLeft(User *user, const std::string &r) {
 
		return;
 
	}
 
	send(c->connection, message);
 

	
 
	NetworkConversation *conv = (NetworkConversation *) user->getConversationManager()->getConversation(r);
 
	if (!conv) {
 
		return;
 
	}
 

	
 
	user->getConversationManager()->removeConversation(conv);
 

	
 
	delete conv;
 
}
 

	
 
void NetworkPluginServer::handleUserDestroyed(User *user) {
src/tests/user.cpp
Show inline comments
 
@@ -26,6 +26,7 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
    CPPUNIT_TEST(handlePresence);
 
	CPPUNIT_TEST(handlePresenceJoinRoom);
 
	CPPUNIT_TEST(handlePresenceLeaveRoom);
 
	CPPUNIT_TEST(leaveJoinedRoom);
 
	CPPUNIT_TEST(handleDisconnected);
 
	CPPUNIT_TEST_SUITE_END();
 

	
 
@@ -191,6 +192,18 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
		CPPUNIT_ASSERT_EQUAL(std::string(""), roomPassword);
 
	}
 

	
 
	void leaveJoinedRoom() {
 
		User *user = userManager->getUser("user@localhost");
 
		handlePresenceJoinRoom();
 

	
 
		CPPUNIT_ASSERT(user->getConversationManager()->getConversation("#room"));
 

	
 
		received.clear();
 
		handlePresenceLeaveRoom();
 

	
 
		CPPUNIT_ASSERT(!user->getConversationManager()->getConversation("#room"));
 
	}
 

	
 
	void handleDisconnected() {
 
		User *user = userManager->getUser("user@localhost");
 
		user->handleDisconnected("Connection error", Swift::SpectrumErrorPayload::CONNECTION_ERROR_AUTHENTICATION_FAILED);
src/user.cpp
Show inline comments
 
@@ -217,6 +217,12 @@ void User::handlePresence(Swift::Presence::ref presence) {
 
			std::string room = Buddy::JIDToLegacyName(presence->getTo());
 
			LOG4CXX_INFO(logger, m_jid.toString() << ": Going to left room " << room);
 
			onRoomLeft(room);
 

	
 
			Conversation *conv = m_conversationManager->getConversation(room);
 
			if (conv) {
 
				m_conversationManager->removeConversation(conv);
 
				delete conv;
 
			}
 
		}
 
		else {
 
			// force connection to legacy network to let backend to handle auto-join on connect.
0 comments (0 inline, 0 general)