From 99e958e8c83a0d75e6a049b6cbe45a026bb816aa Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Thu, 18 Feb 2016 07:34:59 +0100 Subject: [PATCH] Libtransport: Send self presence as first one when joining from second resource --- libtransport/Conversation.cpp | 10 +++++----- tests/libtransport/user.cpp | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libtransport/Conversation.cpp b/libtransport/Conversation.cpp index c1030773..56f61018 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 6180c8d0..c925c48b 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() {