Commit 84df0776 authored by Ghislain MARY's avatar Ghislain MARY

Fix conference participants resource-list parsing and generation.

parent f9fc3e1a
......@@ -59,20 +59,18 @@ void LocalConference::removeParticipant (const shared_ptr<const Participant> &pa
}
}
list<shared_ptr<Address>> LocalConference::parseResourceLists(string xmlBody) {
list<Address> LocalConference::parseResourceLists (string xmlBody) {
istringstream data(xmlBody);
unique_ptr<ResourceLists> rl = LinphonePrivate::Xsd::ResourceLists::parseResourceLists(data, Xsd::XmlSchema::Flags::dont_validate);
list<shared_ptr<Address>> addresses = list<shared_ptr<Address>>();
for(const auto &l : rl->getList()) {
for(const auto &entry : l.getEntry()) {
shared_ptr<Address> addr = make_shared<Address>(Address(entry.getUri()));
if(!entry.getDisplayName().present()) {
addr->setDisplayName(entry.getDisplayName().get());
}
list<Address> addresses = list<Address>();
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;
}
......
......@@ -38,7 +38,7 @@ public:
std::shared_ptr<Participant> addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
std::list<std::shared_ptr<Address>> parseResourceLists(std::string xmlBody);
std::list<Address> parseResourceLists (std::string xmlBody);
private:
L_DISABLE_COPY(LocalConference);
......
......@@ -60,14 +60,13 @@ void RemoteConference::removeParticipant (const shared_ptr<const Participant> &p
}
string RemoteConference::getResourceLists(const list<shared_ptr<const Address>> &addresses) {
string RemoteConference::getResourceLists (const list<const Address> &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);
......
......@@ -39,7 +39,7 @@ public:
std::shared_ptr<Participant> addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
std::string getResourceLists(const std::list<std::shared_ptr<const Address>> &addresses);
std::string getResourceLists (const std::list<const Address> &addresses);
protected:
/* ConferenceListener */
......
......@@ -26,50 +26,49 @@
using namespace LinphonePrivate;
using namespace std;
static string first_invite = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
static const string firstInvite = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<resource-lists xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:ietf:params:xml:ns:resource-lists\">"
"<list>"
" <entry uri=\"sip:alice@sip.linphone.org\"/>"
" <entry uri=\"sip:bob@sip.linphone.org\" display-name=\"Le Bricoleur\"/>"
" <entry uri=\"sip:bob@sip.linphone.org\"><display-name>Le Bricoleur</display-name></entry>"
" <entry uri=\"sip:john-doe@sip.linphone.org\"/>"
" <entry uri=\"sip:anne-onyme@sip.linphone.org\"/>"
" <entry uri=\"sip:sarah-bache@sip.linphone.org\" display-name=\"Sarah\"/>"
" <entry uri=\"sip:sarah-bache@sip.linphone.org\"><display-name>Sarah</display-name></entry>"
"</list>"
"</resource-lists>";
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<shared_ptr<Address>> addresses = localConf.parseResourceLists(first_invite);
Address marieIdentity(linphone_address_as_string_uri_only(marie->identity));
LocalConference localConf(marie->lc, marieIdentity);
list<Address> 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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment