From 99e958e8c83a0d75e6a049b6cbe45a026bb816aa 2016-02-18 07:34:59 From: Jan Kaluza Date: 2016-02-18 07:34:59 Subject: [PATCH] Libtransport: Send self presence as first one when joining from second resource --- diff --git a/libtransport/Conversation.cpp b/libtransport/Conversation.cpp index c10307737bc27e54d1e3001d94e50c840f862259..56f6101803ced23111dc8ee33a75b0b8d32f6e4c 100644 --- a/libtransport/Conversation.cpp +++ b/libtransport/Conversation.cpp @@ -251,13 +251,13 @@ void Conversation::sendParticipants(const Swift::JID &to, const std::string &nic presence->setTo(to); m_conversationManager->getComponent()->getFrontend()->sendPresence(presence); - // And send the presence from as new user - m_nickname = tmp; - presence = generatePresence(m_nickname, 0, (int) Swift::StatusShow::Online, "", "", ""); - presence->setTo(to); - m_conversationManager->getComponent()->getFrontend()->sendPresence(presence); } + // Self presence has to be sent as first. + Swift::Presence::ref presence = generatePresence(m_nickname, 0, (int) Swift::StatusShow::Online, "", "", ""); + presence->setTo(to); + m_conversationManager->getComponent()->getFrontend()->sendPresence(presence); + for (std::map::iterator it = m_participants.begin(); it != m_participants.end(); it++) { (*it).second.presence->setTo(to); m_conversationManager->getComponent()->getFrontend()->sendPresence((*it).second.presence); diff --git a/tests/libtransport/user.cpp b/tests/libtransport/user.cpp index 6180c8d03697d7ca5219fd4d5b70e11729f4e985..c925c48bb5644cad904d4ceb5cc116f1778cfba7 100644 --- a/tests/libtransport/user.cpp +++ b/tests/libtransport/user.cpp @@ -193,14 +193,14 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest { CPPUNIT_ASSERT_EQUAL(std::string(""), roomNickname); CPPUNIT_ASSERT_EQUAL(std::string(""), roomPassword); - CPPUNIT_ASSERT_EQUAL(1, (int) received2.size()); - CPPUNIT_ASSERT(dynamic_cast(getStanza(received2[0]))); - CPPUNIT_ASSERT_EQUAL(Swift::StatusShow::Away, dynamic_cast(getStanza(received2[0]))->getShow()); - CPPUNIT_ASSERT_EQUAL(std::string("user@localhost/resource2"), dynamic_cast(getStanza(received2[0]))->getTo().toString()); - CPPUNIT_ASSERT_EQUAL(std::string("room@localhost/anotheruser"), dynamic_cast(getStanza(received2[0]))->getFrom().toString()); - CPPUNIT_ASSERT(getStanza(received2[0])->getPayload()); - CPPUNIT_ASSERT_EQUAL(Swift::MUCOccupant::Member, *getStanza(received2[0])->getPayload()->getItems()[0].affiliation); - CPPUNIT_ASSERT_EQUAL(Swift::MUCOccupant::Participant, *getStanza(received2[0])->getPayload()->getItems()[0].role); + CPPUNIT_ASSERT_EQUAL(2, (int) received2.size()); + CPPUNIT_ASSERT(dynamic_cast(getStanza(received2[1]))); + CPPUNIT_ASSERT_EQUAL(Swift::StatusShow::Away, dynamic_cast(getStanza(received2[1]))->getShow()); + CPPUNIT_ASSERT_EQUAL(std::string("user@localhost/resource2"), dynamic_cast(getStanza(received2[1]))->getTo().toString()); + CPPUNIT_ASSERT_EQUAL(std::string("room@localhost/anotheruser"), dynamic_cast(getStanza(received2[1]))->getFrom().toString()); + CPPUNIT_ASSERT(getStanza(received2[1])->getPayload()); + CPPUNIT_ASSERT_EQUAL(Swift::MUCOccupant::Member, *getStanza(received2[1])->getPayload()->getItems()[0].affiliation); + CPPUNIT_ASSERT_EQUAL(Swift::MUCOccupant::Participant, *getStanza(received2[1])->getPayload()->getItems()[0].role); } void handlePresenceLeaveRoom() {