From e1122d15f57e099a9b5f07a1e3f46d708cb50540 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Mon, 20 Nov 2017 14:52:15 +0100 Subject: [PATCH] add multipart notify support for conference events --- coreapi/linphonecore.c | 14 +- src/chat/chat-room/client-group-chat-room-p.h | 1 + src/chat/chat-room/client-group-chat-room.cpp | 5 + .../local-conference-event-handler-p.h | 2 + .../local-conference-event-handler.cpp | 102 ++++++- .../remote-conference-event-handler-p.h | 2 + .../remote-conference-event-handler.cpp | 263 ++++++++++-------- .../remote-conference-event-handler.h | 1 + src/conference/local-conference.cpp | 2 +- src/conference/local-conference.h | 2 +- src/content/content-manager.cpp | 12 +- src/content/content-manager.h | 12 +- src/core/core.h | 1 + tester/conference-event-tester.cpp | 4 +- tester/content-manager-tester.cpp | 26 +- 15 files changed, 285 insertions(+), 164 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e0a23f2d2..95dd2aed2 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2142,10 +2142,16 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(from)) )); - if (chatRoom) - L_GET_PRIVATE(static_pointer_cast(chatRoom))->notifyReceived( - linphone_content_get_string_buffer(body) - ); + if (chatRoom) { + if (linphone_content_is_multipart(body)) + L_GET_PRIVATE(static_pointer_cast(chatRoom))->multipartNotifyReceived( + linphone_content_get_string_buffer(body) + ); + else + L_GET_PRIVATE(static_pointer_cast(chatRoom))->notifyReceived( + linphone_content_get_string_buffer(body) + ); + } } } diff --git a/src/chat/chat-room/client-group-chat-room-p.h b/src/chat/chat-room/client-group-chat-room-p.h index 72ffd2206..6a8871cd5 100644 --- a/src/chat/chat-room/client-group-chat-room-p.h +++ b/src/chat/chat-room/client-group-chat-room-p.h @@ -34,6 +34,7 @@ public: std::list
cleanAddressesList (const std::list
&addresses) const; std::shared_ptr createSession (); void notifyReceived (const std::string &body); + void multipartNotifyReceived (const std::string &body); private: L_DECLARE_PUBLIC(ClientGroupChatRoom); diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 9c70f7bc1..0661a4627 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -74,6 +74,11 @@ void ClientGroupChatRoomPrivate::notifyReceived (const string &body) { qConference->getPrivate()->eventHandler->notifyReceived(body); } +void ClientGroupChatRoomPrivate::multipartNotifyReceived (const string &body) { + L_Q_T(RemoteConference, qConference); + qConference->getPrivate()->eventHandler->multipartNotifyReceived(body); +} + // ============================================================================= ClientGroupChatRoom::ClientGroupChatRoom ( diff --git a/src/conference/handlers/local-conference-event-handler-p.h b/src/conference/handlers/local-conference-event-handler-p.h index 14211f0fa..e5822c9a9 100644 --- a/src/conference/handlers/local-conference-event-handler-p.h +++ b/src/conference/handlers/local-conference-event-handler-p.h @@ -37,6 +37,7 @@ public: void notifyAllExcept (const std::string ¬ify, const std::shared_ptr &exceptParticipant); void notifyAll (const std::string ¬ify); std::string createNotifyFullState (int notifyId = -1); + std::string createNotifyMultipart (int notifyId); std::string createNotifyParticipantAdded (const Address &addr, int notifyId = -1); std::string createNotifyParticipantRemoved (const Address &addr, int notifyId = -1); std::string createNotifyParticipantAdmined (const Address &addr, bool isAdmin, int notifyId = -1); @@ -51,6 +52,7 @@ private: unsigned int lastNotify = 0; 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); diff --git a/src/conference/handlers/local-conference-event-handler.cpp b/src/conference/handlers/local-conference-event-handler.cpp index b364f4547..63a8633d2 100644 --- a/src/conference/handlers/local-conference-event-handler.cpp +++ b/src/conference/handlers/local-conference-event-handler.cpp @@ -21,8 +21,15 @@ #include "linphone/utils/utils.h" +#include "chat/chat-room/chat-room-id.h" #include "conference/local-conference.h" #include "conference/participant-p.h" +#include "content/content-manager.h" +#include "content/content-type.h" +#include "content/content.h" +#include "core/core-p.h" +#include "db/main-db.h" +#include "event-log/events.h" #include "local-conference-event-handler-p.h" #include "logger/logger.h" #include "object/object-p.h" @@ -128,6 +135,94 @@ string LocalConferenceEventHandlerPrivate::createNotifyFullState (int notifyId) return createNotify(confInfo, notifyId, true); } +string LocalConferenceEventHandlerPrivate::createNotifyMultipart (int notifyId) { + list> events = conf->getCore()->getPrivate()->mainDb->getConferenceNotifiedEvents( + ChatRoomId(conf->getConferenceAddress(), conf->getConferenceAddress()), + static_cast(notifyId) + ); + + list contents; + for (const auto &eventLog : events) { + Content content; + content.setContentType(ContentType("application","conference-info")); + string body; + shared_ptr notifiedEvent = static_pointer_cast(eventLog); + int eventNotifyId = static_cast(notifiedEvent->getNotifyId()); + switch (eventLog->getType()) { + case EventLog::Type::ConferenceParticipantAdded: { + shared_ptr addedEvent = static_pointer_cast(eventLog); + body = createNotifyParticipantAdded( + addedEvent->getParticipantAddress(), + eventNotifyId + ); + } break; + + case EventLog::Type::ConferenceParticipantRemoved: { + shared_ptr removedEvent = static_pointer_cast(eventLog); + body = createNotifyParticipantRemoved( + removedEvent->getParticipantAddress(), + eventNotifyId + ); + } break; + + case EventLog::Type::ConferenceParticipantSetAdmin: { + shared_ptr setAdminEvent = static_pointer_cast(eventLog); + body = createNotifyParticipantAdmined( + setAdminEvent->getParticipantAddress(), + true, + eventNotifyId + ); + } break; + + case EventLog::Type::ConferenceParticipantUnsetAdmin: { + shared_ptr unsetAdminEvent = static_pointer_cast(eventLog); + body = createNotifyParticipantAdmined( + unsetAdminEvent->getParticipantAddress(), + false, + eventNotifyId + ); + } break; + + case EventLog::Type::ConferenceParticipantDeviceAdded: { + shared_ptr deviceAddedEvent = static_pointer_cast(eventLog); + body = createNotifyParticipantDeviceAdded( + deviceAddedEvent->getParticipantAddress(), + deviceAddedEvent->getDeviceAddress(), + eventNotifyId + ); + } break; + + case EventLog::Type::ConferenceParticipantDeviceRemoved: { + shared_ptr deviceRemovedEvent = static_pointer_cast(eventLog); + body = createNotifyParticipantDeviceRemoved( + deviceRemovedEvent->getParticipantAddress(), + deviceRemovedEvent->getDeviceAddress(), + eventNotifyId + ); + } break; + + case EventLog::Type::ConferenceSubjectChanged: { + shared_ptr subjectEvent = static_pointer_cast(eventLog); + body = createNotifySubjectChanged( + subjectEvent->getSubject(), + eventNotifyId + ); + } break; + + default: + // We should never pass here! + L_ASSERT(false); + continue; + } + content.setBody(body); + contents.push_back(content); + } + + ContentManager contentManager; + Content multipart = contentManager.contentsListToMultipart(contents); + return multipart.getBodyAsString(); +} + string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdded (const Address &addr, int notifyId) { string entity = conf->getConferenceAddress().asStringUriOnly(); ConferenceType confInfo = ConferenceType(entity); @@ -190,8 +285,11 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdmined (const } string LocalConferenceEventHandlerPrivate::createNotifySubjectChanged (int notifyId) { + return createNotifySubjectChanged(conf->getSubject(), notifyId); +} + +string LocalConferenceEventHandlerPrivate::createNotifySubjectChanged (const string &subject, int notifyId) { string entity = conf->getConferenceAddress().asStringUriOnly(); - string subject = conf->getSubject(); ConferenceType confInfo = ConferenceType(entity); ConferenceDescriptionType confDescr = ConferenceDescriptionType(); confDescr.setSubject(subject); @@ -291,7 +389,7 @@ void LocalConferenceEventHandler::subscribeReceived (LinphoneEvent *lev) { } else if (lastNotify < d->lastNotify) { lInfo() << "Sending all missed notify for conference:" << d->conf->getConferenceAddress().asStringUriOnly() << " from: " << lastNotify << " to: " << participant->getAddress().asString(); - // TODO : send all missed notify from lastNotify to d->lastNotify + d->notifyParticipantDevice(d->createNotifyMultipart(static_cast(lastNotify)), device); } else if (lastNotify > d->lastNotify) { lError() << "last notify received by client: [" << lastNotify <<"] for conference:" << d->conf->getConferenceAddress().asStringUriOnly() << diff --git a/src/conference/handlers/remote-conference-event-handler-p.h b/src/conference/handlers/remote-conference-event-handler-p.h index fb69feab3..87992f7b5 100644 --- a/src/conference/handlers/remote-conference-event-handler-p.h +++ b/src/conference/handlers/remote-conference-event-handler-p.h @@ -32,6 +32,8 @@ LINPHONE_BEGIN_NAMESPACE class RemoteConferenceEventHandlerPrivate : public ObjectPrivate { private: + void simpleNotifyReceived (const std::string &xmlBody); + ChatRoomId chatRoomId; RemoteConference *conf = nullptr; diff --git a/src/conference/handlers/remote-conference-event-handler.cpp b/src/conference/handlers/remote-conference-event-handler.cpp index df4b8b56a..2ce85abae 100644 --- a/src/conference/handlers/remote-conference-event-handler.cpp +++ b/src/conference/handlers/remote-conference-event-handler.cpp @@ -20,6 +20,8 @@ #include "linphone/utils/utils.h" #include "conference/remote-conference.h" +#include "content/content-manager.h" +#include "content/content.h" #include "core/core.h" #include "logger/logger.h" #include "remote-conference-event-handler-p.h" @@ -38,6 +40,135 @@ using namespace Xsd::ConferenceInfo; // ----------------------------------------------------------------------------- +void RemoteConferenceEventHandlerPrivate::simpleNotifyReceived (const string &xmlBody) { + istringstream data(xmlBody); + unique_ptr confInfo = parseConferenceInfo(data, Xsd::XmlSchema::Flags::dont_validate); + time_t tm = time(nullptr); + if (confInfo->getConferenceDescription()->getFreeText().present()) + tm = static_cast(Utils::stoll(confInfo->getConferenceDescription()->getFreeText().get())); + + bool isFullState = (confInfo->getState() == StateType::full); + + ConferenceListener *confListener = static_cast(conf); + + // TODO: Temporary workaround, remove me. + const IdentityAddress &peerAddress = chatRoomId.getPeerAddress(); + IdentityAddress entityAddress(confInfo->getEntity().c_str()); + IdentityAddress peerAddressWorkaround = peerAddress; + peerAddressWorkaround.setDomain(entityAddress.getDomain()); + if ((entityAddress == peerAddress) || (entityAddress == peerAddressWorkaround)) { + if ( + confInfo->getConferenceDescription().present() && + confInfo->getConferenceDescription().get().getSubject().present() + ) + confListener->onSubjectChanged( + make_shared( + tm, + chatRoomId, + lastNotify, + confInfo->getConferenceDescription().get().getSubject().get() + ), + isFullState + ); + if (confInfo->getVersion().present()) + lastNotify = confInfo->getVersion().get(); + + if (!confInfo->getUsers().present()) + return; + + for (const auto &user : confInfo->getUsers()->getUser()) { + LinphoneAddress *cAddr = linphone_core_interpret_url(conf->getCore()->getCCore(), user.getEntity()->c_str()); + char *cAddrStr = linphone_address_as_string(cAddr); + Address addr(cAddrStr); + bctbx_free(cAddrStr); + if (user.getState() == StateType::deleted) { + confListener->onParticipantRemoved( + make_shared( + EventLog::Type::ConferenceParticipantRemoved, + tm, + chatRoomId, + lastNotify, + addr + ), + isFullState + ); + } else { + bool isAdmin = false; + if (user.getRoles()) { + for (const auto &entry : user.getRoles()->getEntry()) { + if (entry == "admin") { + isAdmin = true; + break; + } + } + } + + if (user.getState() == StateType::full) { + confListener->onParticipantAdded( + make_shared( + EventLog::Type::ConferenceParticipantAdded, + tm, + chatRoomId, + lastNotify, + addr + ), + isFullState + ); + } + + confListener->onParticipantSetAdmin( + make_shared( + isAdmin ? EventLog::Type::ConferenceParticipantSetAdmin : EventLog::Type::ConferenceParticipantUnsetAdmin, + tm, + chatRoomId, + lastNotify, + addr + ), + isFullState + ); + + for (const auto &endpoint : user.getEndpoint()) { + if (!endpoint.getEntity().present()) + break; + + Address gruu(endpoint.getEntity().get()); + if (endpoint.getState() == StateType::deleted) { + confListener->onParticipantDeviceRemoved( + make_shared( + EventLog::Type::ConferenceParticipantDeviceRemoved, + tm, + chatRoomId, + lastNotify, + addr, + gruu + ), + isFullState + ); + } else if (endpoint.getState() == StateType::full) { + confListener->onParticipantDeviceAdded( + make_shared( + EventLog::Type::ConferenceParticipantDeviceAdded, + tm, + chatRoomId, + lastNotify, + addr, + gruu + ), + isFullState + ); + } + } + } + linphone_address_unref(cAddr); + } + + if (isFullState) + confListener->onFirstNotifyReceived(chatRoomId.getPeerAddress()); + } +} + +// ----------------------------------------------------------------------------- + RemoteConferenceEventHandler::RemoteConferenceEventHandler (RemoteConference *remoteConference) : Object(*new RemoteConferenceEventHandlerPrivate) { L_D(); @@ -78,129 +209,21 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) { lInfo() << "NOTIFY received for conference: (remote=" << d->chatRoomId.getPeerAddress().asString() << ", local=" << d->chatRoomId.getLocalAddress().asString() << ")."; - istringstream data(xmlBody); - unique_ptr confInfo = parseConferenceInfo(data, Xsd::XmlSchema::Flags::dont_validate); - time_t tm = time(nullptr); - if (confInfo->getConferenceDescription()->getFreeText().present()) - tm = static_cast(Utils::stoll(confInfo->getConferenceDescription()->getFreeText().get())); + d->simpleNotifyReceived(xmlBody); +} - bool isFullState = (confInfo->getState() == StateType::full); +void RemoteConferenceEventHandler::multipartNotifyReceived (const string &xmlBody) { + L_D(); - ConferenceListener *confListener = static_cast(d->conf); + lInfo() << "multipart NOTIFY received for conference: (remote=" << d->chatRoomId.getPeerAddress().asString() << + ", local=" << d->chatRoomId.getLocalAddress().asString() << ")."; - // TODO: Temporary workaround, remove me. - const IdentityAddress &peerAddress = d->chatRoomId.getPeerAddress(); - IdentityAddress entityAddress(confInfo->getEntity().c_str()); - IdentityAddress peerAddressWorkaround = peerAddress; - peerAddressWorkaround.setDomain(entityAddress.getDomain()); - if ((entityAddress == peerAddress) || (entityAddress == peerAddressWorkaround)) { - if ( - confInfo->getConferenceDescription().present() && - confInfo->getConferenceDescription().get().getSubject().present() - ) - confListener->onSubjectChanged( - make_shared( - tm, - d->chatRoomId, - d->lastNotify, - confInfo->getConferenceDescription().get().getSubject().get() - ), - isFullState - ); - if (confInfo->getVersion().present()) - d->lastNotify = confInfo->getVersion().get(); - - if (!confInfo->getUsers().present()) - return; - - for (const auto &user : confInfo->getUsers()->getUser()) { - LinphoneAddress *cAddr = linphone_core_interpret_url(d->conf->getCore()->getCCore(), user.getEntity()->c_str()); - char *cAddrStr = linphone_address_as_string(cAddr); - Address addr(cAddrStr); - bctbx_free(cAddrStr); - if (user.getState() == StateType::deleted) { - confListener->onParticipantRemoved( - make_shared( - EventLog::Type::ConferenceParticipantRemoved, - tm, - d->chatRoomId, - d->lastNotify, - addr - ), - isFullState - ); - } else { - bool isAdmin = false; - if (user.getRoles()) { - for (const auto &entry : user.getRoles()->getEntry()) { - if (entry == "admin") { - isAdmin = true; - break; - } - } - } - - if (user.getState() == StateType::full) { - confListener->onParticipantAdded( - make_shared( - EventLog::Type::ConferenceParticipantAdded, - tm, - d->chatRoomId, - d->lastNotify, - addr - ), - isFullState - ); - } - - confListener->onParticipantSetAdmin( - make_shared( - isAdmin ? EventLog::Type::ConferenceParticipantSetAdmin : EventLog::Type::ConferenceParticipantUnsetAdmin, - tm, - d->chatRoomId, - d->lastNotify, - addr - ), - isFullState - ); - - for (const auto &endpoint : user.getEndpoint()) { - if (!endpoint.getEntity().present()) - break; - - Address gruu(endpoint.getEntity().get()); - if (endpoint.getState() == StateType::deleted) { - confListener->onParticipantDeviceRemoved( - make_shared( - EventLog::Type::ConferenceParticipantDeviceRemoved, - tm, - d->chatRoomId, - d->lastNotify, - addr, - gruu - ), - isFullState - ); - } else if (endpoint.getState() == StateType::full) { - confListener->onParticipantDeviceAdded( - make_shared( - EventLog::Type::ConferenceParticipantDeviceAdded, - tm, - d->chatRoomId, - d->lastNotify, - addr, - gruu - ), - isFullState - ); - } - } - } - linphone_address_unref(cAddr); - } - - if (isFullState) - confListener->onFirstNotifyReceived(d->chatRoomId.getPeerAddress()); + Content multipart; + multipart.setBody(xmlBody); + ContentManager manager; + list contents = manager.multipartToContentLists(multipart); + for (const auto &content : contents) { + d->simpleNotifyReceived(content.getBodyAsString()); } } diff --git a/src/conference/handlers/remote-conference-event-handler.h b/src/conference/handlers/remote-conference-event-handler.h index 7598283d2..ecd443e19 100644 --- a/src/conference/handlers/remote-conference-event-handler.h +++ b/src/conference/handlers/remote-conference-event-handler.h @@ -37,6 +37,7 @@ public: void subscribe (const ChatRoomId &chatRoomId); void notifyReceived (const std::string &xmlBody); + void multipartNotifyReceived (const std::string &xmlBody); void unsubscribe (); const ChatRoomId &getChatRoomId () const; diff --git a/src/conference/local-conference.cpp b/src/conference/local-conference.cpp index 203e899cd..f550bb59f 100644 --- a/src/conference/local-conference.cpp +++ b/src/conference/local-conference.cpp @@ -57,7 +57,7 @@ void LocalConference::removeParticipant (const shared_ptr &pa } } -list
LocalConference::parseResourceLists (string xmlBody) { +list
LocalConference::parseResourceLists (const string &xmlBody) { istringstream data(xmlBody); unique_ptr rl = LinphonePrivate::Xsd::ResourceLists::parseResourceLists( data, diff --git a/src/conference/local-conference.h b/src/conference/local-conference.h index 58198518e..079acda7e 100644 --- a/src/conference/local-conference.h +++ b/src/conference/local-conference.h @@ -38,7 +38,7 @@ public: void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void removeParticipant (const std::shared_ptr &participant) override; - std::list
parseResourceLists (std::string xmlBody); + std::list
parseResourceLists (const std::string &xmlBody); private: L_DECLARE_PRIVATE(LocalConference); diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index 285c3f998..79e515cb7 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -20,12 +20,11 @@ #include #include "belle-sip/belle-sip.h" + #include "content-manager.h" #include "content-type.h" #include "linphone/content.h" -#include "linphone/core.h" #include "logger/logger.h" -#include "private.h" // ============================================================================= @@ -35,11 +34,7 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -ContentManager::ContentManager (LinphoneCore *core) { - mCore = core; -} - -list ContentManager::multipartToContentLists (Content content) const { +list ContentManager::multipartToContentLists (const Content &content) const { belle_sip_multipart_body_handler_t *mpbh = belle_sip_multipart_body_handler_new_from_buffer((void *)content.getBodyAsString().c_str(), content.getBodyAsString().length(), MULTIPART_BOUNDARY); belle_sip_object_ref(mpbh); @@ -71,7 +66,7 @@ list ContentManager::multipartToContentLists (Content content) const { return contentsList; } -Content ContentManager::contentsListToMultipart (list contents) const { +Content ContentManager::contentsListToMultipart (const list &contents) const { char *desc; string sub; belle_sip_memory_body_handler_t *mbh = NULL; @@ -99,7 +94,6 @@ Content ContentManager::contentsListToMultipart (list contents) const { } desc = belle_sip_object_to_string(mpbh); belle_sip_object_unref(mpbh); - belle_sip_object_ref(mbh); Content retContent = Content(); ContentType type("application", sub); diff --git a/src/content/content-manager.h b/src/content/content-manager.h index 0b020616a..8b15bb6a2 100644 --- a/src/content/content-manager.h +++ b/src/content/content-manager.h @@ -22,8 +22,9 @@ #include +#include "linphone/utils/general.h" + #include "content.h" -#include "linphone/types.h" // ============================================================================= @@ -31,13 +32,10 @@ LINPHONE_BEGIN_NAMESPACE class ContentManager { public: - ContentManager (LinphoneCore *core); + ContentManager () = default; - std::list multipartToContentLists (Content content) const; - Content contentsListToMultipart (std::list contents) const; - -private: - LinphoneCore *mCore = nullptr; + std::list multipartToContentLists (const Content &content) const; + Content contentsListToMultipart (const std::list &contents) const; }; LINPHONE_END_NAMESPACE diff --git a/src/core/core.h b/src/core/core.h index 635dca487..35514f5e0 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -39,6 +39,7 @@ class IdentityAddress; class LINPHONE_PUBLIC Core : public Object { friend class ChatRoom; friend class ClientGroupChatRoom; + friend class LocalConferenceEventHandlerPrivate; friend class MainDb; friend class MainDbEventKey; diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index ff1ae2930..8b91e5661 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -438,7 +438,7 @@ static const char *participant_unadmined_notify = \ static const char *bobUri = "sip:bob@example.com"; static const char *aliceUri = "sip:alice@example.com"; static const char *frankUri = "sip:frank@example.com"; -static const char *confUri = "sips:conf233@example.com"; +static const char *confUri = "sip:conf233@example.com"; L_ENABLE_ATTR_ACCESS(LocalConferencePrivate, unique_ptr, eventHandler); @@ -561,7 +561,7 @@ void first_notify_parsing() { void first_notify_parsing_wrong_conf() { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, "sips:conf322@example.com"); + LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, "sip:conf322@example.com"); char *confAddressStr = linphone_address_as_string(confAddress); Address addr(confAddressStr); bctbx_free(confAddressStr); diff --git a/tester/content-manager-tester.cpp b/tester/content-manager-tester.cpp index 3ce12ac04..05e4eb893 100644 --- a/tester/content-manager-tester.cpp +++ b/tester/content-manager-tester.cpp @@ -160,10 +160,9 @@ static const char* part4 = \ ""; void multipart_to_list () { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - ContentManager manager(marie->lc); + ContentManager manager; - Content multipartContent = Content(); + Content multipartContent; multipartContent.setBody(multipart); multipartContent.setContentType(ContentType("multipart", "related")); @@ -240,31 +239,24 @@ void multipart_to_list () { ms_message("\n\n----- Original part 4 -----"); ms_message("%s", originalStr4.c_str()); BC_ASSERT_TRUE(originalStr4 == generatedStr4); - - linphone_core_manager_destroy(marie); } void list_to_multipart () { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - ContentManager manager(marie->lc); + ContentManager manager; - Content content1 = Content(); + Content content1; content1.setBody(part1); content1.setContentType(ContentType("application", "rlmi+xml")); - Content content2 = Content(); + Content content2; content2.setBody(part2); content2.setContentType(ContentType("application", "pidf+xml")); - Content content3 = Content(); + Content content3; content3.setBody(part3); content3.setContentType(ContentType("application", "pidf+xml")); - Content content4 = Content(); + Content content4; content4.setBody(part4); content4.setContentType(ContentType("application", "pidf+xml")); - list contents; - contents.push_back(content1); - contents.push_back(content2); - contents.push_back(content3); - contents.push_back(content4); + list contents = {content1, content2, content3, content4}; Content multipartContent = manager.contentsListToMultipart(contents); string originalStr(multipart); @@ -285,8 +277,6 @@ void list_to_multipart () { ms_message("\n\n----- Original multipart -----"); ms_message("%s", originalStr.c_str()); BC_ASSERT_TRUE(originalStr == generatedStr); - - linphone_core_manager_destroy(marie); } test_t content_manager_tests[] = {