From 91196256ce3aed92870e2291558cc796b9c7f4d4 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 12 Dec 2017 15:43:11 +0100 Subject: [PATCH] =?UTF-8?q?fix=20how=20to=20send=20multi=C3=A2rt=20notify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- coreapi/linphonecore.c | 18 +++++++++++++----- .../local-conference-event-handler-p.h | 2 +- .../local-conference-event-handler.cpp | 11 +++++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index a1f294a94..9d0c9b723 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -51,6 +51,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "chat/chat-room/client-group-chat-room-p.h" #include "chat/chat-room/server-group-chat-room-p.h" #include "conference/handlers/remote-conference-event-handler.h" +#include "content/content-manager.h" +#include "content/content-type.h" #include "core/core-p.h" // For migration purpose. @@ -2138,11 +2140,17 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve )); if (chatRoom) { - if (linphone_content_is_multipart(body)) - L_GET_PRIVATE(static_pointer_cast(chatRoom))->multipartNotifyReceived( - linphone_content_get_string_buffer(body) - ); - else + if (linphone_content_is_multipart(body)) { + // TODO : migrate to c++ 'Content'. + int i = 0; + LinphoneContent *part = NULL; + while ((part = linphone_content_get_part(body, i))) { + i++; + L_GET_PRIVATE(static_pointer_cast(chatRoom))->notifyReceived( + linphone_content_get_string_buffer(part) + ); + } + } else L_GET_PRIVATE(static_pointer_cast(chatRoom))->notifyReceived( linphone_content_get_string_buffer(body) ); diff --git a/src/conference/handlers/local-conference-event-handler-p.h b/src/conference/handlers/local-conference-event-handler-p.h index e5ffea9d9..54ee0b697 100644 --- a/src/conference/handlers/local-conference-event-handler-p.h +++ b/src/conference/handlers/local-conference-event-handler-p.h @@ -57,7 +57,7 @@ private: std::string createNotify (Xsd::ConferenceInfo::ConferenceType confInfo, int notifyId = -1, bool isFullState = false); std::string createNotifySubjectChanged (const std::string &subject, int notifyId = -1); void notifyParticipant (const std::string ¬ify, const std::shared_ptr &participant); - void notifyParticipantDevice (const std::string ¬ify, const std::shared_ptr &device); + void notifyParticipantDevice (const std::string ¬ify, const std::shared_ptr &device, bool multipart = false); L_DECLARE_PUBLIC(LocalConferenceEventHandler); }; diff --git a/src/conference/handlers/local-conference-event-handler.cpp b/src/conference/handlers/local-conference-event-handler.cpp index cdfa9e304..fe04b6022 100644 --- a/src/conference/handlers/local-conference-event-handler.cpp +++ b/src/conference/handlers/local-conference-event-handler.cpp @@ -67,11 +67,18 @@ void LocalConferenceEventHandlerPrivate::notifyParticipant (const string ¬ify notifyParticipantDevice(notify, device); } -void LocalConferenceEventHandlerPrivate::notifyParticipantDevice (const string ¬ify, const shared_ptr &device) { +void LocalConferenceEventHandlerPrivate::notifyParticipantDevice (const string ¬ify, const shared_ptr &device, bool multipart) { if (device->isSubscribedToConferenceEventPackage() && !notify.empty()) { LinphoneEvent *ev = device->getConferenceSubscribeEvent(); LinphoneContent *content = linphone_core_create_content(ev->lc); linphone_content_set_buffer(content, (const uint8_t *)notify.c_str(), strlen(notify.c_str())); + if (multipart) { + linphone_content_set_type(content, "multipart"); + linphone_content_set_subtype(content, "mixed;boundary=---------------------------14737809831466499882746641449"); + } else { + linphone_content_set_type(content, "application"); + linphone_content_set_subtype(content, "conference-info"); + } linphone_event_notify(ev, content); linphone_content_unref(content); } @@ -394,7 +401,7 @@ void LocalConferenceEventHandler::subscribeReceived (LinphoneEvent *lev) { lInfo() << "Sending all missed notify [" << lastNotify << "-" << d->lastNotify << "] for conference:" << d->conf->getConferenceAddress().asString() << " to: " << participant->getAddress().asString(); - d->notifyParticipantDevice(d->createNotifyMultipart(static_cast(lastNotify)), device); + d->notifyParticipantDevice(d->createNotifyMultipart(static_cast(lastNotify)), device, true); } else if (lastNotify > d->lastNotify) { lError() << "last notify received by client: [" << lastNotify <<"] for conference:" << d->conf->getConferenceAddress().asString() <<