From 1ca9d64af87fd88baa009c5fac2200c4ccb27574 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 17 Nov 2017 15:48:43 +0100 Subject: [PATCH] feat(core): avoid virtual inheritance of CoreAccessor --- src/chat/chat-room/basic-chat-room.cpp | 4 +- src/chat/chat-room/chat-room.cpp | 2 +- src/chat/chat-room/chat-room.h | 2 +- src/chat/chat-room/client-group-chat-room.cpp | 7 ++- src/chat/chat-room/client-group-chat-room.h | 2 + .../chat-room/real-time-text-chat-room.cpp | 2 +- .../chat-room/server-group-chat-room-stub.cpp | 2 +- src/conference/conference.h | 2 +- src/conference/local-conference.cpp | 2 +- src/conference/remote-conference.cpp | 2 +- tester/conference-event-tester.cpp | 58 ++++++++++--------- 11 files changed, 46 insertions(+), 39 deletions(-) diff --git a/src/chat/chat-room/basic-chat-room.cpp b/src/chat/chat-room/basic-chat-room.cpp index 985b09519..a02a58657 100644 --- a/src/chat/chat-room/basic-chat-room.cpp +++ b/src/chat/chat-room/basic-chat-room.cpp @@ -30,13 +30,13 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE BasicChatRoom::BasicChatRoom (const shared_ptr &core, const ChatRoomId &chatRoomId) : - BasicChatRoom(*new BasicChatRoomPrivate, core, chatRoomId) {} + ChatRoom(*new BasicChatRoomPrivate, core, chatRoomId) {} BasicChatRoom::BasicChatRoom ( BasicChatRoomPrivate &p, const std::shared_ptr &core, const ChatRoomId &chatRoomId -) : CoreAccessor(core), ChatRoom(p, core, chatRoomId) {} +) : ChatRoom(p, core, chatRoomId) {} BasicChatRoom::CapabilitiesMask BasicChatRoom::getCapabilities () const { return static_cast(Capabilities::Basic); diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 0e2b77c6c..cc9b2e5b7 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -449,7 +449,7 @@ void ChatRoomPrivate::onIsComposingRefreshNeeded () { // ============================================================================= ChatRoom::ChatRoom (ChatRoomPrivate &p, const shared_ptr &core, const ChatRoomId &chatRoomId) : - CoreAccessor(core), Object(p) { + Object(p), CoreAccessor(core) { L_D(); d->chatRoomId = chatRoomId; diff --git a/src/chat/chat-room/chat-room.h b/src/chat/chat-room/chat-room.h index 51f4c59cd..b11d28d93 100644 --- a/src/chat/chat-room/chat-room.h +++ b/src/chat/chat-room/chat-room.h @@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE class ChatRoomPrivate; -class LINPHONE_PUBLIC ChatRoom : public Object, virtual public CoreAccessor, public ConferenceInterface { +class LINPHONE_PUBLIC ChatRoom : public Object, public CoreAccessor, public ConferenceInterface { friend class Core; friend class CorePrivate; friend class ChatMessage; diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 5d22c36a9..9c70f7bc1 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -81,14 +81,17 @@ ClientGroupChatRoom::ClientGroupChatRoom ( const std::string &factoryUri, const IdentityAddress &me, const std::string &subject -) : CoreAccessor(core), -ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(), me)), +) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(), me)), RemoteConference(core, me, nullptr) { L_D_T(RemoteConference, dConference); dConference->focus = make_shared(Address(factoryUri)); RemoteConference::setSubject(subject); } +shared_ptr ClientGroupChatRoom::getCore () const { + return ChatRoom::getCore(); +} + ClientGroupChatRoom::CapabilitiesMask ClientGroupChatRoom::getCapabilities () const { return static_cast(Capabilities::Conference); } diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index 6d63aa704..3edaabb55 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -39,6 +39,8 @@ public: const std::string &subject ); + std::shared_ptr getCore () const; + CapabilitiesMask getCapabilities () const override; const Address &getConferenceAddress () const override; diff --git a/src/chat/chat-room/real-time-text-chat-room.cpp b/src/chat/chat-room/real-time-text-chat-room.cpp index 7a8cb8ef6..d4ed5ee45 100644 --- a/src/chat/chat-room/real-time-text-chat-room.cpp +++ b/src/chat/chat-room/real-time-text-chat-room.cpp @@ -104,7 +104,7 @@ void RealTimeTextChatRoomPrivate::sendMessage (const shared_ptr &ms // ============================================================================= RealTimeTextChatRoom::RealTimeTextChatRoom (const shared_ptr &core, const ChatRoomId &chatRoomId) : - CoreAccessor(core), BasicChatRoom(*new RealTimeTextChatRoomPrivate, core, chatRoomId) {} + BasicChatRoom(*new RealTimeTextChatRoomPrivate, core, chatRoomId) {} RealTimeTextChatRoom::CapabilitiesMask RealTimeTextChatRoom::getCapabilities () const { return BasicChatRoom::getCapabilities() | static_cast(Capabilities::RealTimeText); diff --git a/src/chat/chat-room/server-group-chat-room-stub.cpp b/src/chat/chat-room/server-group-chat-room-stub.cpp index a1fe25c89..97e694bc3 100644 --- a/src/chat/chat-room/server-group-chat-room-stub.cpp +++ b/src/chat/chat-room/server-group-chat-room-stub.cpp @@ -77,7 +77,7 @@ bool ServerGroupChatRoomPrivate::isAdminLeft () const { // ============================================================================= -ServerGroupChatRoom::ServerGroupChatRoom (const shared_ptr &core, SalCallOp *op) : CoreAccessor(core), +ServerGroupChatRoom::ServerGroupChatRoom (const shared_ptr &core, SalCallOp *op) : ChatRoom(*new ServerGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to()))), LocalConference(core, Address(op->get_to()), nullptr) {} diff --git a/src/conference/conference.h b/src/conference/conference.h index 6489a11b4..d89536343 100644 --- a/src/conference/conference.h +++ b/src/conference/conference.h @@ -37,7 +37,7 @@ class ConferencePrivate; class LINPHONE_PUBLIC Conference : public ConferenceInterface, public CallSessionListener, - virtual public CoreAccessor { + public CoreAccessor { friend class CallSessionPrivate; public: diff --git a/src/conference/local-conference.cpp b/src/conference/local-conference.cpp index 36ad2cf57..203e899cd 100644 --- a/src/conference/local-conference.cpp +++ b/src/conference/local-conference.cpp @@ -29,7 +29,7 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE LocalConference::LocalConference (const shared_ptr &core, const Address &myAddress, CallListener *listener) - : CoreAccessor(core), Conference(*new LocalConferencePrivate, core, myAddress, listener) { + : Conference(*new LocalConferencePrivate, core, myAddress, listener) { L_D(); d->eventHandler.reset(new LocalConferenceEventHandler(this)); } diff --git a/src/conference/remote-conference.cpp b/src/conference/remote-conference.cpp index 194a1235c..603939bbf 100644 --- a/src/conference/remote-conference.cpp +++ b/src/conference/remote-conference.cpp @@ -32,7 +32,7 @@ RemoteConference::RemoteConference ( const shared_ptr &core, const Address &myAddress, CallListener *listener -) : CoreAccessor(core), Conference(*new RemoteConferencePrivate, core, myAddress, listener) { +) : Conference(*new RemoteConferencePrivate, core, myAddress, listener) { L_D(); d->eventHandler.reset(new RemoteConferenceEventHandler(this)); } diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index db70d0896..ff1ae2930 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -19,12 +19,14 @@ #include #include +#include "address/identity-address.h" #include "conference/conference-listener.h" -#include "conference/local-conference-event-handler-p.h" +#include "conference/handlers/local-conference-event-handler-p.h" +#include "conference/handlers/remote-conference-event-handler-p.h" #include "conference/local-conference-p.h" #include "conference/local-conference.h" #include "conference/participant-p.h" -#include "conference/remote-conference-event-handler-p.h" +#include "conference/remote-conference.h" #include "liblinphone_tester.h" #include "linphone/core.h" #include "private.h" @@ -440,7 +442,7 @@ static const char *confUri = "sips:conf233@example.com"; L_ENABLE_ATTR_ACCESS(LocalConferencePrivate, unique_ptr, eventHandler); -class ConferenceEventTester : public ConferenceListener { +class ConferenceEventTester : public RemoteConference { public: ConferenceEventTester (LinphoneCore *core, const Address &confAddr); ~ConferenceEventTester (); @@ -463,8 +465,8 @@ public: string confSubject; }; -ConferenceEventTester::ConferenceEventTester (LinphoneCore *core, const Address &confAddr) { - handler = new RemoteConferenceEventHandler(core, this); +ConferenceEventTester::ConferenceEventTester (LinphoneCore *core, const Address &confAddr) : RemoteConference(core->cppCore, confAddr) { + handler = new RemoteConferenceEventHandler(this); } ConferenceEventTester::~ConferenceEventTester () { @@ -533,7 +535,7 @@ void first_notify_parsing() { size_t size = strlen(first_notify) + strlen(confUri); char *notify = new char[size]; - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; snprintf(notify, size, first_notify, confUri); tester.handler->notifyReceived(notify); @@ -570,7 +572,7 @@ void first_notify_parsing_wrong_conf() { size_t size = strlen(first_notify) + strlen(confUri); char *notify = new char[size]; - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; snprintf(notify, size, first_notify, confUri); tester.handler->notifyReceived(notify); @@ -601,7 +603,7 @@ void participant_added_parsing() { size_t size2 = strlen(participant_added_notify) + strlen(confUri); char *notify_added = new char[size2]; - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; snprintf(notify, size, first_notify, confUri); tester.handler->notifyReceived(notify); @@ -646,7 +648,7 @@ void participant_not_added_parsing() { size_t size2 = strlen(participant_not_added_notify) + strlen(confUri); char *notify_not_added = new char[size2]; - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; snprintf(notify, size, first_notify, confUri); tester.handler->notifyReceived(notify); @@ -688,7 +690,7 @@ void participant_deleted_parsing() { size_t size2 = strlen(participant_deleted_notify) + strlen(confUri); char *notify_deleted = new char[size2]; - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; snprintf(notify, size, first_notify, confUri); tester.handler->notifyReceived(notify); @@ -730,7 +732,7 @@ void participant_admined_parsing() { size_t size2 = strlen(participant_admined_notify) + strlen(confUri); char *notify_admined = new char[size2]; - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; snprintf(notify, size, first_notify, confUri); tester.handler->notifyReceived(notify); @@ -771,7 +773,7 @@ void participant_unadmined_parsing() { size_t size2 = strlen(participant_unadmined_notify) + strlen(confUri); char *notify_unadmined = new char[size2]; - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; snprintf(notify, size, first_notify, confUri); tester.handler->notifyReceived(notify); @@ -804,7 +806,7 @@ void send_first_notify() { Address addr(identityStr); bctbx_free(identityStr); ConferenceEventTester tester(marie->lc, addr); - LocalConference localConf(pauline->lc, addr); + LocalConference localConf(pauline->lc->cppCore, addr); LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); char *bobAddrStr = linphone_address_as_string(cBobAddr); Address bobAddr(bobAddrStr); @@ -828,7 +830,7 @@ void send_first_notify() { const_cast
(localConf.getConferenceAddress()) = addr; string notify = localHandlerPrivate->createNotifyFullState(); - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; tester.handler->notifyReceived(notify); BC_ASSERT_STRING_EQUAL(tester.confSubject.c_str(), "A random test subject"); @@ -849,7 +851,7 @@ void send_added_notify() { Address addr(identityStr); bctbx_free(identityStr); ConferenceEventTester tester(marie->lc, addr); - LocalConference localConf(pauline->lc, addr); + LocalConference localConf(pauline->lc->cppCore, addr); LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); char *bobAddrStr = linphone_address_as_string(cBobAddr); Address bobAddr(bobAddrStr); @@ -877,7 +879,7 @@ void send_added_notify() { const_cast
(localConf.getConferenceAddress()) = addr; string notify = localHandlerPrivate->createNotifyFullState(); - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; tester.handler->notifyReceived(notify); BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d"); @@ -910,7 +912,7 @@ void send_removed_notify() { Address addr(identityStr); bctbx_free(identityStr); ConferenceEventTester tester(marie->lc, addr); - LocalConference localConf(pauline->lc, addr); + LocalConference localConf(pauline->lc->cppCore, addr); LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); char *bobAddrStr = linphone_address_as_string(cBobAddr); Address bobAddr(bobAddrStr); @@ -933,7 +935,7 @@ void send_removed_notify() { const_cast
(localConf.getConferenceAddress()) = addr; string notify = localHandlerPrivate->createNotifyFullState(); - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; tester.handler->notifyReceived(notify); BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d"); @@ -963,7 +965,7 @@ void send_admined_notify() { Address addr(identityStr); bctbx_free(identityStr); ConferenceEventTester tester(marie->lc, addr); - LocalConference localConf(pauline->lc, addr); + LocalConference localConf(pauline->lc->cppCore, addr); LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); char *bobAddrStr = linphone_address_as_string(cBobAddr); Address bobAddr(bobAddrStr); @@ -986,7 +988,7 @@ void send_admined_notify() { const_cast
(localConf.getConferenceAddress()) = addr; string notify = localHandlerPrivate->createNotifyFullState(); - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; tester.handler->notifyReceived(notify); BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d"); @@ -1015,7 +1017,7 @@ void send_unadmined_notify() { Address addr(identityStr); bctbx_free(identityStr); ConferenceEventTester tester(marie->lc, addr); - LocalConference localConf(pauline->lc, addr); + LocalConference localConf(pauline->lc->cppCore, addr); LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); char *bobAddrStr = linphone_address_as_string(cBobAddr); Address bobAddr(bobAddrStr); @@ -1038,7 +1040,7 @@ void send_unadmined_notify() { const_cast
(localConf.getConferenceAddress()) = addr; string notify = localHandlerPrivate->createNotifyFullState(); - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; tester.handler->notifyReceived(notify); @@ -1068,7 +1070,7 @@ void send_subject_changed_notify () { Address addr(identityStr); bctbx_free(identityStr); ConferenceEventTester tester(marie->lc, addr); - LocalConference localConf(pauline->lc, addr); + LocalConference localConf(pauline->lc->cppCore, addr); LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); char *bobAddrStr = linphone_address_as_string(cBobAddr); Address bobAddr(bobAddrStr); @@ -1092,7 +1094,7 @@ void send_subject_changed_notify () { const_cast
(localConf.getConferenceAddress()) = addr; string notify = localHandlerPrivate->createNotifyFullState(); - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; tester.handler->notifyReceived(notify); BC_ASSERT_STRING_EQUAL(tester.confSubject.c_str(), "A random test subject"); @@ -1128,7 +1130,7 @@ void send_device_added_notify() { Address addr(identityStr); bctbx_free(identityStr); ConferenceEventTester tester(marie->lc, addr); - LocalConference localConf(pauline->lc, addr); + LocalConference localConf(pauline->lc->cppCore, addr); LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); char *bobAddrStr = linphone_address_as_string(cBobAddr); Address bobAddr(bobAddrStr); @@ -1151,7 +1153,7 @@ void send_device_added_notify() { const_cast
(localConf.getConferenceAddress()) = addr; string notify = localHandlerPrivate->createNotifyFullState(); - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; tester.handler->notifyReceived(notify); BC_ASSERT_EQUAL(tester.participantDevices.size(), 2, int, "%d"); @@ -1180,7 +1182,7 @@ void send_device_removed_notify() { Address addr(identityStr); bctbx_free(identityStr); ConferenceEventTester tester(marie->lc, addr); - LocalConference localConf(pauline->lc, addr); + LocalConference localConf(pauline->lc->cppCore, addr); LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); char *bobAddrStr = linphone_address_as_string(cBobAddr); Address bobAddr(bobAddrStr); @@ -1204,7 +1206,7 @@ void send_device_removed_notify() { const_cast
(localConf.getConferenceAddress()) = addr; string notify = localHandlerPrivate->createNotifyFullState(); - const_cast
(tester.handler->getConfAddress()) = addr; + const_cast(tester.handler->getChatRoomId().getPeerAddress()) = addr; tester.handler->notifyReceived(notify); BC_ASSERT_EQUAL(tester.participantDevices.size(), 2, int, "%d");