From 84df0776a61ea7d3297d2cded634a99f3dba411f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 25 Sep 2017 14:49:55 +0200 Subject: [PATCH] Fix conference participants resource-list parsing and generation. --- src/conference/local-conference.cpp | 16 +++++----- src/conference/local-conference.h | 2 +- src/conference/remote-conference.cpp | 11 ++++--- src/conference/remote-conference.h | 2 +- tester/conference-tester.cpp | 45 ++++++++++++++-------------- 5 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/conference/local-conference.cpp b/src/conference/local-conference.cpp index 8e3b53a78..1de626295 100644 --- a/src/conference/local-conference.cpp +++ b/src/conference/local-conference.cpp @@ -59,20 +59,18 @@ void LocalConference::removeParticipant (const shared_ptr &pa } } -list> LocalConference::parseResourceLists(string xmlBody) { +list
LocalConference::parseResourceLists (string xmlBody) { istringstream data(xmlBody); unique_ptr rl = LinphonePrivate::Xsd::ResourceLists::parseResourceLists(data, Xsd::XmlSchema::Flags::dont_validate); - list> addresses = list>(); - for(const auto &l : rl->getList()) { - for(const auto &entry : l.getEntry()) { - shared_ptr
addr = make_shared
(Address(entry.getUri())); - if(!entry.getDisplayName().present()) { - addr->setDisplayName(entry.getDisplayName().get()); - } + list
addresses = list
(); + for (const auto &l : rl->getList()) { + for (const auto &entry : l.getEntry()) { + Address addr(entry.getUri()); + if (entry.getDisplayName().present()) + addr.setDisplayName(entry.getDisplayName().get()); addresses.push_back(addr); } } - return addresses; } diff --git a/src/conference/local-conference.h b/src/conference/local-conference.h index 1d20f9cb8..41a032765 100644 --- a/src/conference/local-conference.h +++ b/src/conference/local-conference.h @@ -38,7 +38,7 @@ public: std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void removeParticipant (const std::shared_ptr &participant) override; - std::list> parseResourceLists(std::string xmlBody); + std::list
parseResourceLists (std::string xmlBody); private: L_DISABLE_COPY(LocalConference); diff --git a/src/conference/remote-conference.cpp b/src/conference/remote-conference.cpp index ade1aa1c4..f0d30eb98 100644 --- a/src/conference/remote-conference.cpp +++ b/src/conference/remote-conference.cpp @@ -60,14 +60,13 @@ void RemoteConference::removeParticipant (const shared_ptr &p } -string RemoteConference::getResourceLists(const list> &addresses) { +string RemoteConference::getResourceLists (const list &addresses) { ResourceLists rl = ResourceLists(); ListType l = ListType(); - for(const auto &addr : addresses) { - EntryType entry = EntryType(addr->asStringUriOnly()); - if(!addr->getDisplayName().empty()) { - entry.setDisplayName(DisplayName(addr->getDisplayName())); - } + for (const auto &addr : addresses) { + EntryType entry = EntryType(addr.asStringUriOnly()); + if (!addr.getDisplayName().empty()) + entry.setDisplayName(DisplayName(addr.getDisplayName())); l.getEntry().push_back(entry); } rl.getList().push_back(l); diff --git a/src/conference/remote-conference.h b/src/conference/remote-conference.h index 718bf6edb..801dfff8c 100644 --- a/src/conference/remote-conference.h +++ b/src/conference/remote-conference.h @@ -39,7 +39,7 @@ public: std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void removeParticipant (const std::shared_ptr &participant) override; - std::string getResourceLists(const std::list> &addresses); + std::string getResourceLists (const std::list &addresses); protected: /* ConferenceListener */ diff --git a/tester/conference-tester.cpp b/tester/conference-tester.cpp index 6a3261989..111265d84 100644 --- a/tester/conference-tester.cpp +++ b/tester/conference-tester.cpp @@ -26,50 +26,49 @@ using namespace LinphonePrivate; using namespace std; -static string first_invite = "" +static const string firstInvite = "" "" "" " " -" " +" Le Bricoleur" " " " " -" " +" Sarah" "" ""; -static string alice_addr = "sip:alice@sip.linphone.org"; -static string bob_addr = "sip:bob@sip.linphone.org"; -static string john_addr = "sip:john-doe@sip.linphone.org"; -static string anne_addr = "sip:anne-onyme@sip.linphone.org"; -static string sarah_addr = "sip:sarah-bache@sip.linphone.org"; +static const string aliceAddr = "sip:alice@sip.linphone.org"; +static const string bobAddr = "sip:bob@sip.linphone.org"; +static const string johnAddr = "sip:john-doe@sip.linphone.org"; +static const string anneAddr = "sip:anne-onyme@sip.linphone.org"; +static const string sarahAddr = "sip:sarah-bache@sip.linphone.org"; -static string bob_name = "Le Bricoleur"; -static string sarah_name = "Sarah"; +static const string bobName = "Le Bricoleur"; +static const string sarahName = "Sarah"; -void first_invite_parsing() { +void first_invite_parsing () { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - Address marie_identity(linphone_address_as_string_uri_only(marie->identity)); - LocalConference localConf(marie->lc, marie_identity); - list> addresses = localConf.parseResourceLists(first_invite); + Address marieIdentity(linphone_address_as_string_uri_only(marie->identity)); + LocalConference localConf(marie->lc, marieIdentity); + list
addresses = localConf.parseResourceLists(firstInvite); BC_ASSERT_EQUAL(addresses.size(), 5, int, "%d"); - if(addresses.size() != 5) { + if (addresses.size() != 5) goto end; - } - BC_ASSERT_TRUE(addresses.front()->asStringUriOnly() == alice_addr); + BC_ASSERT_TRUE(addresses.front().asStringUriOnly() == aliceAddr); addresses.pop_front(); - BC_ASSERT_TRUE(addresses.front()->asStringUriOnly() == bob_addr); - BC_ASSERT_TRUE(addresses.front()->getDisplayName() == bob_name); + BC_ASSERT_TRUE(addresses.front().asStringUriOnly() == bobAddr); + BC_ASSERT_TRUE(addresses.front().getDisplayName() == bobName); addresses.pop_front(); - BC_ASSERT_TRUE(addresses.front()->asStringUriOnly() == john_addr); + BC_ASSERT_TRUE(addresses.front().asStringUriOnly() == johnAddr); addresses.pop_front(); - BC_ASSERT_TRUE(addresses.front()->asStringUriOnly() == anne_addr); + BC_ASSERT_TRUE(addresses.front().asStringUriOnly() == anneAddr); addresses.pop_front(); - BC_ASSERT_TRUE(addresses.front()->asStringUriOnly() == sarah_addr); - BC_ASSERT_TRUE(addresses.front()->getDisplayName() == sarah_name); + BC_ASSERT_TRUE(addresses.front().asStringUriOnly() == sarahAddr); + BC_ASSERT_TRUE(addresses.front().getDisplayName() == sarahName); addresses.pop_front(); end: