Commit b3b0c68c authored by Adrien Béraud's avatar Adrien Béraud Committed by Stepan Salenikovich

dependencies: remove lib expat

- removes functions to create XML uri list, which are no longer used
- without these functions, lib expat is no longer required

Issue: #79618
Change-Id: I8511d09dc707f3244700f4d396c7f81a01176982
parent 1cb755ae
......@@ -412,16 +412,10 @@ AC_DEFINE_UNQUOTED([HAVE_TLS], `if test $HAVE_GNUTLS -eq 1; then echo 1; else ec
AM_CONDITIONAL(BUILD_TLS, test "$HAVE_GNUTLS" -eq 1)
# Instant Messaging
# required dependency(ies): libxpat
AC_ARG_WITH([instant_messaging],
[AS_HELP_STRING([--without-instant_messaging], [disable support for instant-messaging])],
[],
[with_instant_messaging=yes])
AS_IF([test "x$with_instant_messaging" = "xyes"], [
PKG_CHECK_MODULES([EXPAT], expat >= 2.0.0, [with_instant_messaging=yes],
dnl Fallback to older version
[with_instant_messaging=no])
]);
AC_DEFINE_UNQUOTED([HAVE_INSTANT_MESSAGING], `if test "x$with_instant_messaging" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have instant messaging support])
AM_CONDITIONAL(BUILD_INSTANT_MESSAGING, test "x$with_instant_messaging" = "xyes" )
......
2a9ad2b44b87b84087979fe4114d661838df3b03dbdcb74d590cb74096bf35ce9d5a86617b0941a2655ea441a94537bcbcd78252da92342238823be36de2d09d expat-2.1.0.tar.gz
# EXPAT
EXPAT_VERSION := 2.1.0
EXPAT_URL := $(SF)/expat/expat-$(EXPAT_VERSION).tar.gz
EXPAT_GITURL := https://github.com/coapp-packages/expat.git
EXPAT_HASH := 5ccfa1602907957bf11dc3a1a1cfd683ab3758ae
PKGS += expat
ifeq ($(call need_pkg,"expat >= 1.95.0"),)
PKGS_FOUND += expat
endif
$(TARBALLS)/expat-$(EXPAT_HASH).tar.xz:
$(call download_git,$(EXPAT_GITURL), master, $(EXPAT_HASH))
.sum-expat: expat-$(EXPAT_HASH).tar.xz
$(warning Not implemented.)
touch $@
expat: expat-$(EXPAT_HASH).tar.xz .sum-expat
rm -Rf $@ $@-$(EXPAT_HASH)
mkdir -p $@-$(EXPAT_HASH)
(cd $@-$(EXPAT_HASH) && tar xv --strip-components=1 -f ../$<)
$(UPDATE_AUTOCONFIG)
$(MOVE)
.expat: expat
cd $< && $(HOSTVARS) bash ./configure $(HOSTCONF)
cd $< && $(MAKE) install
touch $@
......@@ -26,7 +26,6 @@ endif
if BUILD_INSTANT_MESSAGING
INSTANT_MESSAGING_SUBDIR = im
IM_LIBA=./im/libim.la
IM_LIB=@EXPAT_LIBS@
endif
# Redefine the USE_IAX variable here, so that it could be used in manager
......
......@@ -35,7 +35,6 @@
#include "logger.h"
#include "sip/sip_utils.h"
#include <expat.h>
#include <pjsip_ua.h>
#include <pjsip.h>
......@@ -271,67 +270,4 @@ InstantMessaging::sendIaxMessage(iax_session* session, const std::string& /* id
}
#endif
/*
* The following functions are for creating and parsing XML URI lists which are appended to
* instant messages in order to be able to send a message to multiple recipients as defined in
* RFC 5365
*
* These functions are not currently used, but are left for now, along with the Expat library
* dependance, in case this functionality is implemented later. Note that it may be possible to
* replace the Expat XML parser library by using the pjsip xml functions.
*/
static void XMLCALL
startElementCallback(void* userData, const char* name, const char** atts)
{
if (strcmp(name, "entry"))
return;
InstantMessaging::UriEntry entry = InstantMessaging::UriEntry();
for (const char **att = atts; *att; att += 2)
entry.insert(std::pair<std::string, std::string> (*att, *(att+1)));
static_cast<InstantMessaging::UriList *>(userData)->push_back(entry);
}
static void XMLCALL
endElementCallback(void * /*userData*/, const char* /*name*/)
{}
std::string
InstantMessaging::generateXmlUriList(const UriList& list)
{
std::string xmlbuffer = "<?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>";
for (const auto& item: list) {
const auto it = item.find(IM_XML_URI);
if (it == item.cend())
continue;
xmlbuffer += "<entry uri=" + it->second + " cp:copyControl=\"to\" />";
}
return xmlbuffer + "</list></resource-lists>";
}
InstantMessaging::UriList
InstantMessaging::parseXmlUriList(const std::string& urilist)
{
InstantMessaging::UriList list;
XML_Parser parser = XML_ParserCreate(NULL);
XML_SetUserData(parser, &list);
XML_SetElementHandler(parser, startElementCallback, endElementCallback);
if (XML_Parse(parser, urilist.c_str(), urilist.size(), 1) == XML_STATUS_ERROR) {
RING_ERR("%s at line %lu\n", XML_ErrorString(XML_GetErrorCode(parser)),
XML_GetCurrentLineNumber(parser));
throw InstantMessageException("Error while parsing uri-list xml content");
}
return list;
}
} // namespace ring
......@@ -50,17 +50,12 @@ struct pjsip_msg;
namespace ring { namespace InstantMessaging {
constexpr static const char* IM_XML_URI = "uri";
struct InstantMessageException : std::runtime_error
{
InstantMessageException(const std::string& str="") :
std::runtime_error("InstantMessageException occured: " + str) {}
};
using UriEntry = std::map<std::string, std::string>;
using UriList = std::list<UriEntry>;
/**
* Constructs and sends a SIP message.
*
......@@ -96,23 +91,4 @@ void sendIaxMessage(iax_session* session, const std::string& id,
const std::vector<std::string>& chunks);
#endif
/**
* Generate Xml participant list for multi recipient based on RFC Draft 5365
*
* @param A UriList of UriEntry
*
* @return A string containing the full XML formated information to be included in the
* sip instant message.
*/
std::string generateXmlUriList(const UriList& list);
/**
* Parse the Urilist from a SIP Instant Message provided by a UriList service.
*
* @param A XML formated string as obtained from a SIP instant message.
*
* @return An UriList of UriEntry containing parsed XML information as a map.
*/
UriList parseXmlUriList(const std::string& urilist);
}} // namespace ring::InstantMessaging
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