From b3b0c68cf905beb1179014e3d28355e3b0b0ee77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Mon, 14 Sep 2015 12:28:45 -0400
Subject: [PATCH] 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
---
 configure.ac                 |  6 ----
 contrib/src/expat/SHA512SUMS |  1 -
 contrib/src/expat/rules.mak  | 30 -----------------
 src/Makefile.am              |  1 -
 src/im/instant_messaging.cpp | 64 ------------------------------------
 src/im/instant_messaging.h   | 24 --------------
 6 files changed, 126 deletions(-)
 delete mode 100644 contrib/src/expat/SHA512SUMS
 delete mode 100644 contrib/src/expat/rules.mak

diff --git a/configure.ac b/configure.ac
index 92f23890e0..f9d626e414 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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" )
diff --git a/contrib/src/expat/SHA512SUMS b/contrib/src/expat/SHA512SUMS
deleted file mode 100644
index 02f25a87a0..0000000000
--- a/contrib/src/expat/SHA512SUMS
+++ /dev/null
@@ -1 +0,0 @@
-2a9ad2b44b87b84087979fe4114d661838df3b03dbdcb74d590cb74096bf35ce9d5a86617b0941a2655ea441a94537bcbcd78252da92342238823be36de2d09d  expat-2.1.0.tar.gz
diff --git a/contrib/src/expat/rules.mak b/contrib/src/expat/rules.mak
deleted file mode 100644
index c5524be588..0000000000
--- a/contrib/src/expat/rules.mak
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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 $@
diff --git a/src/Makefile.am b/src/Makefile.am
index 411aed9c7e..9e16bb6470 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/im/instant_messaging.cpp b/src/im/instant_messaging.cpp
index f5d3829547..2a44a17ad4 100644
--- a/src/im/instant_messaging.cpp
+++ b/src/im/instant_messaging.cpp
@@ -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
diff --git a/src/im/instant_messaging.h b/src/im/instant_messaging.h
index 407e24d63b..2bd13fa87b 100644
--- a/src/im/instant_messaging.h
+++ b/src/im/instant_messaging.h
@@ -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
-- 
GitLab