Commit 905e47d1 authored by Ghislain MARY's avatar Ghislain MARY

Improve xsd integration.

parent 6d37e56b
......@@ -61,13 +61,6 @@ if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
if(APPLE)
set(XSDCXX_DEFAULT_ROOT_PATH "/usr/local")
else ()
set(XSDCXX_DEFAULT_ROOT_PATH "/usr")
endif()
set(XSDCXX_ROOT_PATH ${XSDCXX_DEFAULT_ROOT_PATH} CACHE STRING "Path of where the bin/xsdcxx executable will be found. Comes from http://www.codesynthesis.com/products/xsd/download.xhtml. On mac use 'brew install xsd'")
set(SYSCONF_INSTALL_DIR ${CMAKE_INSTALL_FULL_SYSCONFDIR} CACHE STRING "Config directory, the place where flexisip expects its flexisip.conf file to reside" )
......@@ -94,25 +87,7 @@ endif()
find_package(BcToolbox 0.0.3 REQUIRED)
find_program(XSDCXX_PROG NAMES "xsdcxx" "xsd"
HINTS ${XSDCXX_ROOT_PATH}/bin
)
if(XSDCXX_PROG)
set(ENABLE_XSD 1)
message(STATUS "XSD found at ${XSDCXX_PROG}, enabling XSD")
# TODO: check XSD is the correct executable
find_library(XERCES_LIBS NAMES xerces-c)
if(NOT XERCES_LIBS)
message(FATAL_ERROR "Failed to find the Xerces library.")
endif()
find_path(XERCES_INCLUDE_DIRS NAMES xercesc/util/XercesDefs.hpp)
if(NOT XERCES_INCLUDE_DIRS)
message(FATAL_ERROR "Failed to find the Xerces includes.")
endif()
else()
set(ENABLE_XSD 0)
message(STATUS "Program 'xsdcxx' could not be found in ${XSDCXX_ROOT_PATH}/bin, disabling XSD features")
endif()
find_package(LibXsd)
check_function_exists(arc4random HAVE_ARC4RANDOM)
find_file(HAVE_SYS_PRCTL_H NAMES sys/prctl.h)
......
############################################################################
# FindLibXsd.cmake
# Copyright (C) 2017 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# - Find the libxsd library
#
# LIBXSD_FOUND - system has libxsd
# LIBXSD_INCLUDE_DIRS - the libxsd include directory
# LIBXSD_LIBRARIES - The libraries needed to use libxsd
find_package(XercesC)
find_path(LIBXSD_INCLUDE_DIRS
NAMES xsd/cxx/config.hxx
PATH_SUFFIXES include
)
if(LIBXSD_INCLUDE_DIRS)
list(APPEND LIBXSD_INCLUDE_DIRS ${XercesC_INCLUDE_DIRS})
endif()
set(LIBXSD_LIBRARIES ${XercesC_LIBRARIES})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibXsd
DEFAULT_MSG
LIBXSD_INCLUDE_DIRS LIBXSD_LIBRARIES
)
mark_as_advanced(LIBXSD_INCLUDE_DIRS LIBXSD_LIBRARIES)
......@@ -91,35 +91,12 @@ add_custom_target(flexisip-git-version
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/flexisip_gitversion.h"
)
function(ADD_XSD_WRAPPERS file _comment)
set(destinations ${CMAKE_CURRENT_BINARY_DIR}/xml/${file}.hxx ${CMAKE_CURRENT_BINARY_DIR}/xml/${file}.cxx)
set(source ${CMAKE_CURRENT_LIST_DIR}/xml/${file}.xsd)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/xml")
set(regex "%http://.+/(.+)%\\\$$1%")
add_custom_command(OUTPUT ${destinations}
COMMAND "${XSDCXX_PROG}" "cxx-tree" "--generate-wildcard"
"--generate-serialization" "--generate-ostream"
"--generate-detach" "--std" "c++11" "--type-naming" "java"
"--function-naming" "java" "--location-regex-trace" "--show-sloc"
"--location-regex" "\"${regex}\""
"--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/xml" "${source}"
COMMENT "${_comment}")
add_custom_target(${file} DEPENDS ${destinations} SOURCES ${source})
set_source_files_properties(${destinations} PROPERTIES GENERATED ON)
set(FLEXISIP_SOURCES ${FLEXISIP_SOURCES} ${destinations} PARENT_SCOPE)
endfunction()
list(APPEND FLEXISIP_INCLUDES ${BCTOOLBOX_INCLUDE_DIRS})
if(ENABLE_XSD)
list(APPEND FLEXISIP_LIBS ${XERCES_LIBS})
list(APPEND FLEXISIP_INCLUDES ${XERCES_INCLUDE_DIRS} ${XSDCXX_ROOT_PATH}/libxsd ${CMAKE_CURRENT_BINARY_DIR}/xml)
list(APPEND FLEXISIP_DEPENDENCIES fthttp)
ADD_XSD_WRAPPERS(fthttp "Generating XSD for FTHTTP")
if(LIBXSD_FOUND)
list(APPEND FLEXISIP_LIBS ${LIBXSD_LIBRARIES})
list(APPEND FLEXISIP_INCLUDES ${LIBXSD_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/xml)
list(APPEND FLEXISIP_SOURCES xml/fthttp.cc xml/fthttp.hh)
endif()
if(ENABLE_MSGPACK)
......@@ -176,27 +153,44 @@ if(ENABLE_PROTOBUF)
endif()
if(ENABLE_PRESENCE)
if (NOT ENABLE_XSD)
if(NOT LIBXSD_FOUND)
message(FATAL_ERROR "Presence asked but XSD not enabled! Please enable it first.")
endif()
file(GLOB PRESENCE_SRCS presence/*.cc presence/*.hh)
list(APPEND FLEXISIP_SOURCES ${PRESENCE_SRCS})
add_definitions(-DBELLE_SIP_USE_STL ${BELLE_SIP_CFLAGS})
list(APPEND FLEXISIP_LIBS ${BELLESIP_LIBRARIES} ${XERCES_LIBS})
list(APPEND FLEXISIP_INCLUDES ${BELLESIP_INCLUDE_DIRS} presence)
add_definitions(-DBELLE_SIP_USE_STL ${BELLE_SIP_CFLAGS})
ADD_XSD_WRAPPERS(xml "Presence XSD - xml.xsd")
list(APPEND FLEXISIP_SOURCES xml/xml.xsd)
ADD_XSD_WRAPPERS(pidf+xml "Presence XSD - pidf+xml.xsd")
list(APPEND FLEXISIP_SOURCES xml/pidf+xml.xsd)
ADD_XSD_WRAPPERS(rlmi+xml "Presence XSD - rlmi+xml.xsd")
list(APPEND FLEXISIP_SOURCES xml/rlmi+xml.xsd)
ADD_XSD_WRAPPERS(resource-lists "Presence XSD - resource-lists.xsd")
list(APPEND FLEXISIP_SOURCES xml/resource-lists.xsd)
ADD_XSD_WRAPPERS(rpid "RPID XSD - rpid.xsd")
list(APPEND FLEXISIP_SOURCES xml/rpid.xsd)
ADD_XSD_WRAPPERS(data-model "Data model XSD - data-model.xsd")
list(APPEND FLEXISIP_SOURCES xml/data-model.xsd)
list(APPEND FLEXISIP_DEPENDENCIES xml pidf+xml rlmi+xml resource-lists rpid data-model)
list(APPEND FLEXISIP_SOURCES
presence/bellesip-signaling-exception.cc
presence/bellesip-signaling-exception.hh
presence/etag-manager.hh
presence/file-resource-list-manager.cc
presence/file-resource-list-manager.hh
presence/list-subscription.cc
presence/list-subscription.hh
presence/presence-configmanager.cc
presence/presence-configmanager.hh
presence/presence-longterm.cc
presence/presence-longterm.hh
presence/presence-server.cc
presence/presence-server.hh
presence/presentity-manager.hh
presence/presentity-presenceinformation.cc
presence/presentity-presenceinformation.hh
presence/subscription.cc
presence/subscription.hh
xml/data-model.cc
xml/data-model.hh
xml/pidf+xml.cc
xml/pidf+xml.hh
xml/resource-lists.cc
xml/resource-lists.hh
xml/rlmi+xml.cc
xml/rlmi+xml.hh
xml/rpid.cc
xml/rpid.hh
xml/xml.cc
xml/xml.hh
)
endif()
if(ENABLE_CONFERENCE)
......@@ -207,8 +201,25 @@ if(ENABLE_CONFERENCE)
endif()
if(ENABLE_PUSHNOTIFICATION)
file(GLOB PUSHNOTIFICATION_SRCS pushnotification/*.cc pushnotification/*.hh)
list(APPEND FLEXISIP_SOURCES module-pushnotification.cc ${PUSHNOTIFICATION_SRCS})
list(APPEND FLEXISIP_SOURCES
module-pushnotification.cc
pushnotification/applepush.cc
pushnotification/applepush.hh
pushnotification/firebasepush.cc
pushnotification/firebasepush.hh
pushnotification/genericpush.cc
pushnotification/genericpush.hh
pushnotification/googlepush.cc
pushnotification/googlepush.hh
pushnotification/microsoftpush.cc
pushnotification/microsoftpush.hh
pushnotification/pushnotificationclient.cc
pushnotification/pushnotificationclient.hh
pushnotification/pushnotificationclient_wp.cc
pushnotification/pushnotificationclient_wp.hh
pushnotification/pushnotificationservice.cc
pushnotification/pushnotificationservice.hh
)
endif()
list(APPEND FLEXISIP_LIBS ${OPENSSL_LIBRARIES})
list(APPEND FLEXISIP_INCLUDES ${OPENSSL_INCLUDE_DIR})
......
......@@ -25,9 +25,8 @@
#if ENABLE_XSD
#include "xml/fthttp.hxx"
#include "xml/fthttp.h"
#include <xercesc/util/PlatformUtils.hpp>
using namespace fthttp;
#endif
......@@ -213,23 +212,23 @@ void ForkMessageContext::onNewBranch(const shared_ptr<BranchInfo> &br) {
xercesc::XMLPlatformUtils::Initialize();
if (payload) {
std::unique_ptr<fthttp::File> file_transfer_infos;
std::unique_ptr<Xsd::Fthttp::File> file_transfer_infos;
char *file_url = NULL;
try {
istringstream data(payload->pl_data);
file_transfer_infos = parseFile(data, xml_schema::Flags::dont_validate);
} catch (const xml_schema::Exception &e) {
file_transfer_infos = Xsd::Fthttp::parseFile(data, Xsd::XmlSchema::Flags::dont_validate);
} catch (const Xsd::XmlSchema::Exception &e) {
SLOGE << "Can't parse the content of the message";
}
if (file_transfer_infos) {
File::File_infoSequence &infos = file_transfer_infos->getFile_info();
Xsd::Fthttp::File::FileInfoSequence &infos = file_transfer_infos->getFileInfo();
if (infos.size() >= 1) {
for (File::File_infoConstIterator i(infos.begin()); i != infos.end(); ++i) {
const File::File_infoType &info = (*i);
const File_info::DataType &data = info.getData();
const Data::UrlType &url = data.getUrl();
for (Xsd::Fthttp::File::FileInfoConstIterator i(infos.begin()); i != infos.end(); ++i) {
const Xsd::Fthttp::File::FileInfoType &info = (*i);
const Xsd::Fthttp::FileInfo::DataType &data = info.getData();
const Xsd::Fthttp::Data::UrlType &url = data.getUrl();
file_url = (char *)url.c_str();
break;
}
......
......@@ -20,9 +20,9 @@
#include "belle-sip/belle-sip.h"
#include "bellesip-signaling-exception.hh"
#include "log/logmanager.hh"
#include "resource-lists.hxx"
#include "resource-lists.hh"
#include <chrono>
#include "rlmi+xml.hxx"
#include "rlmi+xml.hh"
#include "belle-sip/bodyhandler.h"
#include <algorithm>
......@@ -49,20 +49,20 @@ ListSubscription::ListSubscription(unsigned int expires, belle_sip_server_transa
if (!belle_sip_message_get_body(BELLE_SIP_MESSAGE(request))) {
throw BELLESIP_SIGNALING_EXCEPTION_1(400, belle_sip_header_create("Warning", "Empty body")) << "Empty body";
}
::std::unique_ptr<resource_lists::Resource_lists> resource_list_body = NULL;
::std::unique_ptr<Xsd::ResourceLists::ResourceLists> resource_list_body = NULL;
try {
istringstream data(belle_sip_message_get_body(BELLE_SIP_MESSAGE(request)));
resource_list_body = resource_lists::parseResource_lists(data, xml_schema::Flags::dont_validate);
} catch (const xml_schema::Exception &e) {
resource_list_body = Xsd::ResourceLists::parseResourceLists(data, Xsd::XmlSchema::Flags::dont_validate);
} catch (const Xsd::XmlSchema::Exception &e) {
ostringstream os;
os << "Cannot parse body caused by [" << e << "]";
// todo check error code
throw BELLESIP_SIGNALING_EXCEPTION_1(400, belle_sip_header_create("Warning", os.str().c_str())) << os.str();
}
for (::resource_lists::List::ListConstIterator listIt = resource_list_body->getList().begin();
for (Xsd::ResourceLists::List::ListConstIterator listIt = resource_list_body->getList().begin();
listIt != resource_list_body->getList().end(); listIt++) {
for (::resource_lists::List::EntryConstIterator entryIt = listIt->getEntry().begin();
for (Xsd::ResourceLists::List::EntryConstIterator entryIt = listIt->getEntry().begin();
entryIt != listIt->getEntry().end(); entryIt++) {
//fixme until we have a fast uri parser
//belle_sip_uri_t *uri = belle_sip_uri_parse(entryIt->getUri().c_str());
......@@ -106,12 +106,12 @@ ListSubscription::~ListSubscription() {
SLOGD << "List souscription ["<< this <<"] deleted";
};
void ListSubscription::addInstanceToResource(rlmi::Resource &resource, list<belle_sip_body_handler_t *> &multipartList,
void ListSubscription::addInstanceToResource(Xsd::Rlmi::Resource &resource, list<belle_sip_body_handler_t *> &multipartList,
PresentityPresenceInformation &presentityInformation, bool extended) {
// we have a resource instance
// subscription state is always active until we implement ACL
rlmi::Instance instance("1", rlmi::State::active);
Xsd::Rlmi::Instance instance("1", Xsd::Rlmi::State::active);
char cid_rand_part[8];
belle_sip_random_token(cid_rand_part, sizeof(cid_rand_part));
ostringstream cid;
......@@ -157,7 +157,7 @@ void ListSubscription::notify(bool isFullState) throw(FlexisipException) {
*/
SLOGE << "First NOTIFY sent in subscription [" << mName << "] MUST contain full state";
}
rlmi::List resourceList(string(uri), mVersion, isFullState);
Xsd::Rlmi::List resourceList(string(uri), mVersion, isFullState);
belle_sip_free(uri);
list<belle_sip_body_handler_t *> multipartList;
......@@ -165,7 +165,7 @@ void ListSubscription::notify(bool isFullState) throw(FlexisipException) {
SLOGI << "Building full state rlmi for list name [" << mName << "]";
for (shared_ptr<PresentityPresenceInformationListener> &resourceListener : mListeners) {
char *presentityUri = belle_sip_uri_to_string(resourceListener->getPresentityUri());
rlmi::Resource resource(presentityUri);
Xsd::Rlmi::Resource resource(presentityUri);
belle_sip_free(presentityUri);
PendingStateType::iterator it = mPendingStates.find(resourceListener->getPresentityUri());
if (it != mPendingStates.end() && it->second.first->isKnown()) {
......@@ -183,7 +183,7 @@ void ListSubscription::notify(bool isFullState) throw(FlexisipException) {
if (presenceInformationPair.second.first->isKnown()) { /* only notify for entity with known state*/
shared_ptr<PresentityPresenceInformation> presenceInformation = presenceInformationPair.second.first;
char *presentityUri = belle_sip_uri_to_string(presenceInformation->getEntity());
rlmi::Resource resource(presentityUri);
Xsd::Rlmi::Resource resource(presentityUri);
belle_sip_free(presentityUri);
addInstanceToResource(resource, multipartList, *presenceInformation, presenceInformationPair.second.second);
resourceList.getResource().push_back(resource);
......@@ -199,10 +199,10 @@ void ListSubscription::notify(bool isFullState) throw(FlexisipException) {
// Serialize the object model to XML.
//
xml_schema::NamespaceInfomap map;
Xsd::XmlSchema::NamespaceInfomap map;
map[""].name = "urn:ietf:params:xml:ns:rlmi";
stringstream out;
rlmi::serializeList(out, resourceList, map);
Xsd::Rlmi::serializeList(out, resourceList, map);
belle_sip_memory_body_handler_t *firstBodyPart = belle_sip_memory_body_handler_new_copy_from_buffer(
(void *)out.str().c_str(), out.str().length(), NULL, NULL);
......@@ -224,7 +224,7 @@ void ListSubscription::notify(bool isFullState) throw(FlexisipException) {
mVersion++;
mLastNotify = chrono::system_clock::now();
mPendingStates.clear();
} catch (const xml_schema::Serialization &e) {
} catch (const Xsd::XmlSchema::Serialization &e) {
throw FLEXISIP_EXCEPTION << "serialization error: " << e.diagnostics();
} catch (exception &e) {
throw FLEXISIP_EXCEPTION << "Cannot get build list notidy for [" << mName << "]error [" << e.what() << "]";
......
......@@ -19,13 +19,11 @@
#ifndef flexisip_rls_subscription_hh
#define flexisip_rls_subscription_hh
#include "subscription.hh"
#include "rlmi+xml.hh"
#include <unordered_map>
#include <chrono>
typedef struct _belle_sip_uri belle_sip_uri_t;
typedef struct belle_sip_server_transaction belle_sip_server_transaction_t;
namespace rlmi {
class Resource;
}
namespace flexisip {
class ListSubscription;
......@@ -76,7 +74,7 @@ class ListSubscription : public Subscription {
ListSubscription(const ListSubscription &);
// return true if a real notify can be sent.
bool isTimeToNotify();
void addInstanceToResource(rlmi::Resource &resource, std::list<belle_sip_body_handler_t *> &multipartList,
void addInstanceToResource(Xsd::Rlmi::Resource &resource, std::list<belle_sip_body_handler_t *> &multipartList,
PresentityPresenceInformation &presentityInformation, bool extended);
std::list<std::shared_ptr<PresentityPresenceInformationListener>> mListeners;
......
......@@ -18,8 +18,8 @@
#include "presence-server.hh"
#include "belle-sip/belle-sip.h"
#include "pidf+xml.hxx"
#include "resource-lists.hxx"
#include "pidf+xml.hh"
#include "resource-lists.hh"
#include "presentity-presenceinformation.hh"
#include "list-subscription.hh"
#include "bellesip-signaling-exception.hh"
......@@ -391,11 +391,11 @@ void PresenceServer::processPublishRequestEvent(const belle_sip_request_event_t
// At that point, we are safe
if (belle_sip_message_get_body_size(BELLE_SIP_MESSAGE(request)) > 0) {
::std::unique_ptr<pidf::Presence> presence_body = NULL;
::std::unique_ptr<Xsd::Pidf::Presence> presence_body = NULL;
try {
istringstream data(belle_sip_message_get_body(BELLE_SIP_MESSAGE(request)));
presence_body = parsePresence(data, xml_schema::Flags::dont_validate);
} catch (const xml_schema::Exception &e) {
presence_body = Xsd::Pidf::parsePresence(data, Xsd::XmlSchema::Flags::dont_validate);
} catch (const Xsd::XmlSchema::Exception &e) {
ostringstream os;
os << "Cannot parse body caused by [" << e << "]";
// todo check error code
......
......@@ -21,24 +21,21 @@
#include <ostream>
#include <functional>
#include "etag-manager.hh"
#include "pidf+xml.hxx"
#include "rpid.hxx"
#include "data-model.hxx"
#include "pidf+xml.hh"
#include "rpid.hh"
#include "data-model.hh"
#include <memory>
#include "presentity-manager.hh"
#include "log/logmanager.hh"
#define ETAG_SIZE 8
using namespace pidf;
using namespace rpid;
using namespace data_model;
using namespace std;
namespace flexisip {
static string generate_presence_id(void);
FlexisipException &operator<<(FlexisipException &e, const xml_schema::Exception &val) {
FlexisipException &operator<<(FlexisipException &e, const Xsd::XmlSchema::Exception &val) {
stringstream e_out;
e_out << val;
e << e_out.str();
......@@ -51,16 +48,16 @@ PresenceInformationElement::PresenceInformationElement(const belle_sip_uri_t *co
std::time_t t;
std::time(&t);
struct tm *now = gmtime(&t);
Status status;
status.setBasic(Basic("open"));
unique_ptr<Tuple> tup(new Tuple(status, string(generate_presence_id())));
tup->setTimestamp(::xml_schema::DateTime(now->tm_year + 1900, now->tm_mon + 1, now->tm_mday, now->tm_hour,
Xsd::Pidf::Status status;
status.setBasic(Xsd::Pidf::Basic("open"));
unique_ptr<Xsd::Pidf::Tuple> tup(new Xsd::Pidf::Tuple(status, string(generate_presence_id())));
tup->setTimestamp(Xsd::XmlSchema::DateTime(now->tm_year + 1900, now->tm_mon + 1, now->tm_mday, now->tm_hour,
now->tm_min, now->tm_sec));
tup->setContact(::pidf::Contact(contact_as_string));
tup->setContact(Xsd::Pidf::Contact(contact_as_string));
mTuples.clear(); // just in case
mTuples.push_back(std::unique_ptr<Tuple>(tup.release()));
Activities act = Activities();
act.getAway().push_back(rpid::Empty());
mTuples.push_back(std::unique_ptr<Xsd::Pidf::Tuple>(tup.release()));
Xsd::Rpid::Activities act = Xsd::Rpid::Activities();
act.getAway().push_back(Xsd::Rpid::Empty());
mPerson.setId(contact_as_string);
mPerson.getActivities().push_back(act);
belle_sip_free(contact_as_string);
......@@ -107,20 +104,20 @@ bool PresentityPresenceInformation::findPresenceInfo(std::shared_ptr<PresentityP
}
return false;
}
string PresentityPresenceInformation::putTuples(pidf::Presence::TupleSequence &tuples,
data_model::Person &person, int expires) {
string PresentityPresenceInformation::putTuples(Xsd::Pidf::Presence::TupleSequence &tuples,
Xsd::DataModel::Person &person, int expires) {
return setOrUpdate(&tuples, &person, NULL, expires);
}
string PresentityPresenceInformation::updateTuples(pidf::Presence::TupleSequence &tuples,
data_model::Person &person, string &eTag,
string PresentityPresenceInformation::updateTuples(Xsd::Pidf::Presence::TupleSequence &tuples,
Xsd::DataModel::Person &person, string &eTag,
int expires) throw(FlexisipException) {
return setOrUpdate(&tuples, &person, &eTag, expires);
}
void PresenceInformationElement::clearTuples() {
mTuples.clear();
}
string PresentityPresenceInformation::setOrUpdate(pidf::Presence::TupleSequence *tuples,
data_model::Person *person, const string *eTag,
string PresentityPresenceInformation::setOrUpdate(Xsd::Pidf::Presence::TupleSequence *tuples,
Xsd::DataModel::Person *person, const string *eTag,
int expires) throw(FlexisipException) {
PresenceInformationElement *informationElement = NULL;
......@@ -205,7 +202,7 @@ void PresentityPresenceInformation::setDefaultElement(const char *contact) {
if (contact) {
for (auto & tup : mDefaultInformationElement->getTuples()) {
tup->setContact(::pidf::Contact(contact));
tup->setContact(Xsd::Pidf::Contact(contact));
}
}
......@@ -334,14 +331,14 @@ string PresentityPresenceInformation::getPidf(bool extended) throw(FlexisipExcep
stringstream out;
try {
char *entity = belle_sip_uri_to_string(getEntity());
pidf::Presence presence((string(entity)));
Xsd::Pidf::Presence presence((string(entity)));
belle_sip_free(entity);
list<string> tupleList;
if(extended) {
for (auto element : mInformationElements) {
// copy pidf
for (const unique_ptr<pidf::Tuple> &tup : element.second->getTuples()) {
for (const unique_ptr<Xsd::Pidf::Tuple> &tup : element.second->getTuples()) {
// check for multiple tupple id, may happend with buggy presence publisher
if (find(tupleList.begin(), tupleList.end(), tup.get()->getId()) == tupleList.end()) {
presence.getTuple().push_back(*tup);
......@@ -351,10 +348,10 @@ string PresentityPresenceInformation::getPidf(bool extended) throw(FlexisipExcep
}
}
// copy extensions
Person dm_person = element.second->getPerson();
for(data_model::Person::ActivitiesIterator activity = dm_person.getActivities().begin(); activity != dm_person.getActivities().end();activity++) {
Xsd::DataModel::Person dm_person = element.second->getPerson();
for(Xsd::DataModel::Person::ActivitiesIterator activity = dm_person.getActivities().begin(); activity != dm_person.getActivities().end();activity++) {
if(!presence.getPerson()) {
Person person = Person(dm_person.getId());
Xsd::DataModel::Person person = Xsd::DataModel::Person(dm_person.getId());
presence.setPerson(person);
}
presence.getPerson()->getActivities().push_back(*activity);
......@@ -366,17 +363,17 @@ string PresentityPresenceInformation::getPidf(bool extended) throw(FlexisipExcep
presence.getTuple().push_back(*mDefaultInformationElement->getTuples().begin()->get());
// copy extensions
Person dm_person = mDefaultInformationElement->getPerson();
for(data_model::Person::ActivitiesIterator activity = dm_person.getActivities().begin(); activity != dm_person.getActivities().end();activity++) {
Xsd::DataModel::Person dm_person = mDefaultInformationElement->getPerson();
for(Xsd::DataModel::Person::ActivitiesIterator activity = dm_person.getActivities().begin(); activity != dm_person.getActivities().end();activity++) {
if(!presence.getPerson()) {
Person person = Person(dm_person.getId());
Xsd::DataModel::Person person = Xsd::DataModel::Person(dm_person.getId());
presence.setPerson(person);
}
presence.getPerson()->getActivities().push_back(*activity);
}
}
if (presence.getTuple().size() == 0) {
pidf::Note value;
Xsd::Pidf::Note value;
namespace_::Lang lang("en");
value += "No presence information available yet";
value.setLang(lang);
......@@ -386,12 +383,12 @@ string PresentityPresenceInformation::getPidf(bool extended) throw(FlexisipExcep
// Serialize the object model to XML.
//
xml_schema::NamespaceInfomap map;
Xsd::XmlSchema::NamespaceInfomap map;
map[""].name = "urn:ietf:params:xml:ns:pidf";
serializePresence(out, presence, map);
} catch (const xml_schema::Exception &e) {
} catch (const Xsd::XmlSchema::Exception &e) {
throw FLEXISIP_EXCEPTION << "error: " << e;
} catch (exception &e) {
throw FLEXISIP_EXCEPTION << "Cannot get pidf for for [" << *this << "]error [" << e.what() << "]";
......@@ -435,24 +432,24 @@ void PresentityPresenceInformationListener::setExpiresTimer(belle_sip_main_loop_
// PresenceInformationElement
PresenceInformationElement::PresenceInformationElement(pidf::Presence::TupleSequence *tuples,
data_model::Person *person,
PresenceInformationElement::PresenceInformationElement(Xsd::Pidf::Presence::TupleSequence *tuples,
Xsd::DataModel::Person *person,
belle_sip_main_loop_t *mainLoop)
: mDomDocument(::xsd::cxx::xml::dom::create_document<char>()), mBelleSipMainloop(mainLoop), mTimer(NULL) {
for (pidf::Presence::TupleSequence::iterator tupleIt = tuples->begin(); tupleIt != tuples->end();) {
for (Xsd::Pidf::Presence::TupleSequence::iterator tupleIt = tuples->begin(); tupleIt != tuples->end();) {
SLOGD << "Adding tuple id [" << tupleIt->getId() << "] to presence info element [" << this << "]";
std::unique_ptr<Tuple> r;
std::unique_ptr<Xsd::Pidf::Tuple> r;
tupleIt = tuples->detach(tupleIt, r);
mTuples.push_back(std::unique_ptr<Tuple>(r.release()));
mTuples.push_back(std::unique_ptr<Xsd::Pidf::Tuple>(r.release()));
}
if(person) {
for(data_model::Person::ActivitiesIterator activity = person->getActivities().begin(); activity != person->getActivities().end();activity++) {
for(Xsd::DataModel::Person::ActivitiesIterator activity = person->getActivities().begin(); activity != person->getActivities().end();activity++) {
mPerson.getActivities().push_back(*activity);
}
}
/*for (pidf::Presence::PersonType::iterator domElement = extensions->begin(); domElement != extensions->end();
/*for (Xsd::Pidf::Presence::PersonType::iterator domElement = extensions->begin(); domElement != extensions->end();
domElement++) {
char * transcodedString = xercesc::XMLString::transcode(domElement->getNodeName());
SLOGD << "Adding extension element [" << transcodedString
......@@ -488,17 +485,17 @@ void PresenceInformationElement::setExpiresTimer(belle_sip_source_t *timer) {
mTimer = timer;
}
const std::unique_ptr<pidf::Tuple> &PresenceInformationElement::getTuple(const string &id) const {
for (const std::unique_ptr<Tuple> &tup : mTuples) {
const std::unique_ptr<Xsd::Pidf::Tuple> &PresenceInformationElement::getTuple(const string &id) const {
for (const std::unique_ptr<Xsd::Pidf::Tuple> &tup : mTuples) {
if (tup->getId().compare(id) == 0)
return tup;
}
throw FLEXISIP_EXCEPTION << "No tuple found for id [" << id << "]";
}
const list<std::unique_ptr<pidf::Tuple>> &PresenceInformationElement::getTuples() const {
const list<std::unique_ptr<Xsd::Pidf::Tuple>> &PresenceInformationElement::getTuples() const {
return mTuples;
}
const data_model::Person PresenceInformationElement::getPerson() const {
const Xsd::DataModel::Person PresenceInformationElement::getPerson() const {
return mPerson;
}
/* void PresenceInformationElement::addTuple(pidf::Tuple* tup) {
......
......@@ -20,8 +20,8 @@
#define PRESENCETUPLE_HH_
#include <map>
#include "pidf+xml.hxx"
//#include "data-model.hxx"
#include "pidf+xml.hh"
//#include "data-model.hh"
#include <list>
#include "utils/flexisip-exception.hh"
......@@ -32,16 +32,16 @@ namespace flexisip {
class PresentityManager;
class PresenceInformationElement {
public:
PresenceInformationElement(pidf::Presence::TupleSequence *tuples, data_model::Person *person,
PresenceInformationElement(Xsd::Pidf::Presence::TupleSequence *tuples, Xsd::DataModel::Person *person,
belle_sip_main_loop_t *mainLoop);
// create an information element with a default tuple set to closed.
PresenceInformationElement(const belle_sip_uri_t *contact);
~PresenceInformationElement();
time_t getExpitationTime() const;
void setExpiresTimer(belle_sip_source_t *timer);
const std::unique_ptr<pidf::Tuple> &getTuple(const std::string &id) const;
const std::list<std::unique_ptr<pidf::Tuple>> &getTuples() const;
const data_model::Person getPerson() const;
const std::unique_ptr<Xsd::Pidf::Tuple> &getTuple(const std::string &id) const;
const std::list<std::unique_ptr<Xsd::Pidf::Tuple>> &getTuples() const;
const Xsd::DataModel::Person getPerson() const;
// void addTuple(pidf::Tuple*);
// void removeTuple(pidf::Tuple*);
void clearTuples();
......@@ -49,9 +49,9 @@ class PresenceInformationElement {
void setEtag(const std::string &eTag);
private:
std::list<std::unique_ptr<pidf::Tuple>> mTuples;
data_model::Person mPerson = data_model::Person("");
::xml_schema::dom::unique_ptr<xercesc::DOMDocument> mDomDocument; // needed to store extension nodes
std::list<std::unique_ptr<Xsd::Pidf::Tuple>> mTuples;
Xsd::DataModel::Person mPerson = Xsd::DataModel::Person("");
Xsd::XmlSchema::dom::unique_ptr<xercesc::DOMDocument> mDomDocument; // needed to store extension nodes
belle_sip_main_loop_t *mBelleSipMainloop;
belle_sip_source_t *mTimer;
std::string mEtag;
......@@ -99,7 +99,7 @@ class PresentityPresenceInformation : public std::enable_shared_from_this<Presen
* store tuples a new tupple;
* @return new eTag
* */
std::string putTuples(pidf::Presence::TupleSequence &tuples, data_model::Person &person, int expires);
std::string putTuples(Xsd::Pidf::Presence::TupleSequence &tuples, Xsd::DataModel::Person &person, int expires);
void setDefaultElement(const char* contact = NULL);
......@@ -117,7 +117,7 @@ class PresentityPresenceInformation : public std::enable_shared_from_this<Presen
*
* @return new eTag
* */
std::string updateTuples(pidf::Presence::TupleSequence &tuples, data_model::Person &person, std::string &eTag,
std::string updateTuples(Xsd::Pidf::Presence::TupleSequence &tuples, Xsd::DataModel::Person &person, std::string &eTag,
int expires) throw(FlexisipException);
/*
......@@ -188,7 +188,7 @@ class PresentityPresenceInformation : public std::enable_shared_from_this<Presen
/*
* tuples may be null
*/
std::string setOrUpdate(pidf::Presence::TupleSequence *tuples, data_model::Person *, const std::string *eTag,
std::string setOrUpdate(Xsd::Pidf::Presence::TupleSequence *tuples, Xsd::DataModel::Person *, const std::string *eTag,
int expires) throw(FlexisipException);
/*
*Notify all listener
......
This diff is collapsed.