From 040ecf2448fb46618f85db230959dea48c54de29 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 16 Mar 2018 17:43:02 +0100 Subject: [PATCH] start parsing of subscribe to generate notify body --- .../handlers/local-conference-event-handler.h | 2 ++ .../local-conference-list-event-handler.cpp | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/conference/handlers/local-conference-event-handler.h b/src/conference/handlers/local-conference-event-handler.h index 4912493f3..9a004ac7f 100644 --- a/src/conference/handlers/local-conference-event-handler.h +++ b/src/conference/handlers/local-conference-event-handler.h @@ -53,6 +53,8 @@ public: void setChatRoomId (const ChatRoomId &chatRoomId); ChatRoomId getChatRoomId () const; + void getNotifyForId (int notifyId) const {}; + private: L_DECLARE_PRIVATE(LocalConferenceEventHandler); L_DISABLE_COPY(LocalConferenceEventHandler); diff --git a/src/conference/handlers/local-conference-list-event-handler.cpp b/src/conference/handlers/local-conference-list-event-handler.cpp index b3b4e38ee..2500054c2 100644 --- a/src/conference/handlers/local-conference-list-event-handler.cpp +++ b/src/conference/handlers/local-conference-list-event-handler.cpp @@ -17,8 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "linphone/utils/utils.h" + +#include "address/address.h" #include "local-conference-event-handler.h" #include "local-conference-list-event-handler.h" +#include "xml/resource-lists.h" // ============================================================================= @@ -29,7 +33,25 @@ LINPHONE_BEGIN_NAMESPACE // ----------------------------------------------------------------------------- void LocalConferenceListEventHandler::subscribeReceived (const string &xmlBody) { + istringstream data(xmlBody); + unique_ptr rl(Xsd::ResourceLists::parseResourceLists( + data, + Xsd::XmlSchema::Flags::dont_validate + )); + for (const auto &l : rl->getList()) { + for (const auto &entry : l.getEntry()) { + Address addr(entry.getUri()); + string notifyIdStr = addr.getUriParamValue("Last-Notify"); + addr.removeUriParam("Last-Notify"); + int notifyId = notifyIdStr.empty() ? 0 : Utils::stoi(notifyIdStr); + ChatRoomId chatRoomId(addr, addr); + shared_ptr handler = findHandler(chatRoomId); + if (!handler) + continue; + handler->getNotifyForId(notifyId); + } + } } void LocalConferenceListEventHandler::notify () {