Changeset - d0699848cf1c
[Not reviewed]
0 2 0
Jan Kaluza - 13 years ago 2012-08-16 12:52:53
hanzz.k@gmail.com
Join room just once
2 files changed with 26 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/tests/user.cpp
Show inline comments
 
@@ -132,6 +132,8 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
	}
 

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

	
 
		Swift::Presence::ref response = Swift::Presence::create();
 
		response->setTo("#room@localhost/hanzz");
 
		response->setFrom("user@localhost/resource");
 
@@ -149,6 +151,25 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
		CPPUNIT_ASSERT_EQUAL(std::string("#room"), room);
 
		CPPUNIT_ASSERT_EQUAL(std::string("hanzz"), roomNickname);
 
		CPPUNIT_ASSERT_EQUAL(std::string("password"), roomPassword);
 

	
 
		room = "";
 
		roomNickname = "";
 
		roomPassword = "";
 

	
 
		// simulate that backend joined the room
 
		TestingConversation *conv = new TestingConversation(user->getConversationManager(), "#room", true);
 

	
 
		received.clear();
 
		injectPresence(response);
 
		loop->processEvents();
 

	
 
		// no presence received in server mode, just disco#info
 
		CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
 
		CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::DiscoInfo>());
 

	
 
		CPPUNIT_ASSERT_EQUAL(std::string(""), room);
 
		CPPUNIT_ASSERT_EQUAL(std::string(""), roomNickname);
 
		CPPUNIT_ASSERT_EQUAL(std::string(""), roomPassword);
 
	}
 

	
 
	void handlePresenceLeaveRoom() {
src/user.cpp
Show inline comments
 
@@ -226,6 +226,11 @@ void User::handlePresence(Swift::Presence::ref presence) {
 
				onReadyToConnect();
 
			}
 
			std::string room = Buddy::JIDToLegacyName(presence->getTo());
 
			if (m_conversationManager->getConversation(room) != NULL) {
 
				LOG4CXX_INFO(logger, m_jid.toString() << ": User has already tried to join room " << room << " as " << presence->getTo().getResource());
 
				return;
 
			}
 

	
 
			LOG4CXX_INFO(logger, m_jid.toString() << ": Going to join room " << room << " as " << presence->getTo().getResource());
 
			std::string password = "";
 
			if (presence->getPayload<Swift::MUCPayload>() != NULL) {
0 comments (0 inline, 0 general)