From 477e5f698cb05a6fa660ed415690e85de2b7a577 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 16 Mar 2018 20:38:26 +0100 Subject: [PATCH] better generation of the notify body --- .../handlers/local-conference-event-handler.cpp | 3 ++- .../handlers/local-conference-list-event-handler.cpp | 4 ++-- src/content/content-manager.cpp | 10 +++------- src/content/content-manager.h | 5 ++++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/conference/handlers/local-conference-event-handler.cpp b/src/conference/handlers/local-conference-event-handler.cpp index 903fa0e1c..a77350a0d 100644 --- a/src/conference/handlers/local-conference-event-handler.cpp +++ b/src/conference/handlers/local-conference-event-handler.cpp @@ -184,7 +184,8 @@ string LocalConferenceEventHandlerPrivate::createNotifyMultipart (int notifyId) } if (contents.empty()) - return ""; + return Utils::getEmptyConstRefObject(); + return ContentManager::contentListToMultipart(contents).getBodyAsString(); } diff --git a/src/conference/handlers/local-conference-list-event-handler.cpp b/src/conference/handlers/local-conference-list-event-handler.cpp index 96e47470f..d244733a0 100644 --- a/src/conference/handlers/local-conference-list-event-handler.cpp +++ b/src/conference/handlers/local-conference-list-event-handler.cpp @@ -35,7 +35,7 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE namespace { - constexpr const char MultipartBoundary[] = "---------------------------14737809831412343453453"; + constexpr const char MultipartBoundaryListEventHandler[] = "---------------------------14737809831412343453453"; } // ----------------------------------------------------------------------------- @@ -82,7 +82,7 @@ void LocalConferenceListEventHandler::subscribeReceived (const string &xmlBody) } contents.push_front(rlmiContent); - Content multipart = ContentManager::contentListToMultipart(contents); + Content multipart = ContentManager::contentListToMultipart(contents, MultipartBoundaryListEventHandler); (void) multipart; } diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index 94ee69ce9..30799a484 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -29,10 +29,6 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -namespace { - constexpr const char MultipartBoundary[] = "---------------------------14737809831466499882746641449"; -} - // ----------------------------------------------------------------------------- list ContentManager::multipartToContentList (const Content &content) { @@ -69,9 +65,9 @@ list ContentManager::multipartToContentList (const Content &content) { return contents; } -Content ContentManager::contentListToMultipart (const list &contents) { +Content ContentManager::contentListToMultipart (const list &contents, const string &boundary) { belle_sip_multipart_body_handler_t *mpbh = belle_sip_multipart_body_handler_new( - nullptr, nullptr, nullptr, MultipartBoundary + nullptr, nullptr, nullptr, boundary.c_str() ); belle_sip_object_ref(mpbh); @@ -110,7 +106,7 @@ Content ContentManager::contentListToMultipart (const list &contents) { belle_sip_object_unref(mpbh); ContentType contentType = ContentType::Multipart; - contentType.setParameter("boundary=" + string(MultipartBoundary)); + contentType.setParameter("boundary=" + boundary); content.setContentType(contentType); return content; diff --git a/src/content/content-manager.h b/src/content/content-manager.h index 8251d3c3b..5b1d26365 100644 --- a/src/content/content-manager.h +++ b/src/content/content-manager.h @@ -30,9 +30,12 @@ LINPHONE_BEGIN_NAMESPACE class Content; +namespace { + constexpr const char MultipartBoundary[] = "---------------------------14737809831466499882746641449"; +} namespace ContentManager { std::list multipartToContentList (const Content &content); - Content contentListToMultipart (const std::list &contents); + Content contentListToMultipart (const std::list &contents, const std::string &boundary = MultipartBoundary); } LINPHONE_END_NAMESPACE