add parseResouceLists method to local conference

This commit is contained in:
Benjamin Reis 2017-09-22 16:45:30 +02:00
parent 8d075bbd27
commit 3bcf6e3523
3 changed files with 23 additions and 1 deletions

View file

@ -18,8 +18,10 @@
#include "local-conference.h"
#include "participant-p.h"
#include "xml/resource-lists.h"
using namespace std;
using namespace LinphonePrivate::Xsd::ResourceLists;
LINPHONE_BEGIN_NAMESPACE
@ -57,4 +59,22 @@ void LocalConference::removeParticipant (const shared_ptr<const Participant> &pa
}
}
list<shared_ptr<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()));
// TODO : set display name when possible
/*if(!entry.getDisplayName()->present()) {
addr->setDisplayName(entry.getDisplayName()->get());
}*/
addresses.push_back(addr);
}
}
return addresses;
}
LINPHONE_END_NAMESPACE

View file

@ -38,6 +38,8 @@ 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);
private:
L_DISABLE_COPY(LocalConference);

View file

@ -65,7 +65,7 @@ string RemoteConference::getResourceLists(const list<shared_ptr<const Address>>
ListType l = ListType();
for(const auto &addr : addresses) {
EntryType entry = EntryType(addr->asStringUriOnly());
if(addr->getDisplayName() != "") {
if(!addr->getDisplayName().empty()) {
entry.setDisplayName(DisplayName(addr->getDisplayName()));
}
l.getEntry().push_back(entry);