Commit 9717313f authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3963] Fix retrive uri in UriList/UriEntry

parent 5cd5922e
......@@ -20,6 +20,8 @@ static void XMLCALL startElementCallback (void *userData, const char *name, cons
const char **att;
// _debug ("InstantMessaging: StartElement Callback: %s", name);
if (strcmp (name, "entry") == 0) {
sfl::InstantMessaging::UriList *list = static_cast<sfl::InstantMessaging::UriList *> (userData);
......@@ -28,10 +30,13 @@ static void XMLCALL startElementCallback (void *userData, const char *name, cons
for (att = atts; *att; att += 2) {
const char **val = att+1;
duplicateString (attribute, *att, strlen (*att));
duplicateString (value, *val, strlen (*val));
entry->insert (std::pair<std::string, std::string> (attribute, value));
// _debug ("InstantMessaging: attribute: %s, value: %s", attribute, value);
entry->insert (std::pair<std::string, std::string> (std::string (attribute), std::string (value)));
}
list->push_back (entry);
......
......@@ -28,7 +28,7 @@
namespace sfl
{
const std::string IM_XML_URI ("IM_XML_URI");
const std::string IM_XML_URI ("uri");
const std::string BOUNDARY ("--boundary");
class InstantMessaging
......
......@@ -3481,23 +3481,26 @@ void call_on_tsx_changed (pjsip_inv_session *inv UNUSED, pjsip_transaction *tsx,
// retreive the recipient-list of this message
std::string urilist = imModule->findTextUriList (formatedMessage);
_debug ("---------------- XML -----------\n%s", urilist.c_str());
// parse the recipient list xml
InstantMessaging::UriList list = imModule->parseXmlUriList (formatedMessage);
InstantMessaging::UriList list = imModule->parseXmlUriList (urilist);
// If no item present in the list, peer is considered as the sender
if (list.empty())
if (list.empty()) {
_debug ("------------ List is empty!!!!!!!");
from = call->getPeerNumber ();
else {
} else {
_debug ("------------ List not empty!!!!!!!");
// InstaintMessaging::UriEntry *entry = static_cast<InstantMessaging::UriEntry *>(*iterItem);
// InstantMessaging::UriEntry::iterator iterAttr = entry->find(IM_XML_URI);
InstantMessaging::UriEntry *entry = list.front();
InstantMessaging::UriEntry::iterator iterAttr = entry->find (IM_XML_URI);
_debug ("------------ iterAttr->second %s", iterAttr->second.c_str());
from = iterAttr->second;
// from = call->getPeerNumber ();
}
_debug ("------------------ from: %s", from.c_str());
// Pass through the instant messaging module if needed
// Right now, it does do anything.
......
......@@ -253,14 +253,12 @@ void InstantMessagingTest::testXmlUriListParsing ()
while (iterEntry != list.end()) {
sfl::InstantMessaging::UriEntry *entry = static_cast<sfl::InstantMessaging::UriEntry *> (*iterEntry);
iterAttr = entry->find (sfl::IM_XML_URI);
/*
if((iterAttr->second == std::string("sip:alex@example.com")) ||
(iterAttr->second == std::string("sip:manu@example.com")))
CPPUNIT_ASSERT(1==1);
else
CPPUNIT_ASSERT(0==1);
*/
iterEntry++;
}
}
......@@ -311,6 +309,23 @@ void InstantMessagingTest::testGetUriListArea ()
CPPUNIT_ASSERT(urilist.compare("<?xml version=\"1.0\" encoding=\"UTF-8\"?><resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\"><list><entry uri=\"sip:alex@example.com\" cp:copyControl=\"to\" /><entry uri=\"sip:manu@example.com\" cp:copyControl=\"to\" /></list></resource-lists>") == 0);
std::cout << "urilist: " << urilist << std::endl;
sfl::InstantMessaging::UriList list = _im->parseXmlUriList(urilist);
CPPUNIT_ASSERT(list.size() == 2);
// order may be important, for example to identify message sender
sfl::InstantMessaging::UriEntry *entry = list.front();
CPPUNIT_ASSERT(entry->size() == 2);
sfl::InstantMessaging::UriEntry::iterator iterAttr = entry->find (sfl::IM_XML_URI);
if(iterAttr == entry->end()) {
std::cout << "Error, did not found attribute" << std::endl;
CPPUNIT_ASSERT(0==1);
}
std::string from = iterAttr->second;
CPPUNIT_ASSERT(from == "sip:alex@example.com");
}
......
Supports Markdown
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