From bea9b7f3d9a823bceea7f70c39ba1d9228646a46 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Mon, 6 Nov 2017 13:36:18 +0100 Subject: [PATCH] uses event directly in internal conference callbacks --- src/chat/chat-room/client-group-chat-room.cpp | 72 ++++--------------- src/chat/chat-room/client-group-chat-room.h | 12 ++-- src/conference/conference-listener.h | 13 ++-- .../local-conference-event-handler.cpp | 22 +++--- .../remote-conference-event-handler.cpp | 71 ++++++++++++++---- .../remote-conference-event-handler.h | 2 +- src/conference/remote-conference.cpp | 12 ++-- src/conference/remote-conference.h | 12 ++-- src/db/main-db.cpp | 3 + .../conference/conference-notified-event-p.h | 1 + .../conference/conference-notified-event.cpp | 9 +++ .../conference/conference-notified-event.h | 9 ++- .../conference-participant-device-event.cpp | 2 + .../conference-participant-device-event.h | 1 + .../conference-participant-event.cpp | 20 +++++- .../conference/conference-participant-event.h | 2 + .../conference/conference-subject-event.cpp | 2 + .../conference/conference-subject-event.h | 1 + tester/CMakeLists.txt | 2 +- tester/conference-event-tester.cpp | 43 ++++++----- tester/tester.c | 2 +- 21 files changed, 182 insertions(+), 131 deletions(-) diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index d24b398ac..29b77d680 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -263,9 +263,10 @@ void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) { d->setState(ChatRoom::State::Terminated); } -void ClientGroupChatRoom::onParticipantAdded (time_t tm, bool isFullState, const Address &addr) { +void ClientGroupChatRoom::onParticipantAdded (shared_ptr event) { L_D_T(RemoteConference, dConference); + const Address &addr = event->getParticipantAddress(); if (isMe(addr)) return; @@ -280,22 +281,16 @@ void ClientGroupChatRoom::onParticipantAdded (time_t tm, bool isFullState, const LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); LinphoneChatRoomCbsParticipantAddedCb cb = linphone_chat_room_cbs_get_participant_added(cbs); - shared_ptr event = make_shared( - EventLog::Type::ConferenceParticipantAdded, - tm, - dConference->conferenceAddress, - dConference->eventHandler->getLastNotify(), - addr - ); Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event); if (cb) cb(cr, L_GET_C_BACK_PTR(event)); } -void ClientGroupChatRoom::onParticipantRemoved (time_t tm, bool isFullState, const Address &addr) { +void ClientGroupChatRoom::onParticipantRemoved (shared_ptr event) { L_D_T(RemoteConference, dConference); + const Address &addr = event->getParticipantAddress(); shared_ptr participant = findParticipant(addr); if (!participant) { lWarning() << "Participant " << addr.asString() << " removed but not in the list of participants!"; @@ -305,13 +300,6 @@ void ClientGroupChatRoom::onParticipantRemoved (time_t tm, bool isFullState, con LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); LinphoneChatRoomCbsParticipantRemovedCb cb = linphone_chat_room_cbs_get_participant_removed(cbs); - shared_ptr event = make_shared( - EventLog::Type::ConferenceParticipantRemoved, - tm, - dConference->conferenceAddress, - dConference->eventHandler->getLastNotify(), - addr - ); Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event); if (cb) @@ -320,8 +308,8 @@ void ClientGroupChatRoom::onParticipantRemoved (time_t tm, bool isFullState, con dConference->participants.remove(participant); } -void ClientGroupChatRoom::onParticipantSetAdmin (time_t tm, bool isFullState, const Address &addr, bool isAdmin) { - L_D_T(RemoteConference, dConference); +void ClientGroupChatRoom::onParticipantSetAdmin (shared_ptr event) { + const Address &addr = event->getParticipantAddress(); shared_ptr participant; if (isMe(addr)) participant = getMe(); @@ -332,43 +320,29 @@ void ClientGroupChatRoom::onParticipantSetAdmin (time_t tm, bool isFullState, co return; } - participant->getPrivate()->setAdmin(isAdmin); + participant->getPrivate()->setAdmin(event->getType() == EventLog::Type::ConferenceParticipantSetAdmin); LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); LinphoneChatRoomCbsParticipantAdminStatusChangedCb cb = linphone_chat_room_cbs_get_participant_admin_status_changed(cbs); - shared_ptr event = make_shared( - isAdmin ? EventLog::Type::ConferenceParticipantSetAdmin : EventLog::Type::ConferenceParticipantUnsetAdmin, - tm, - dConference->conferenceAddress, - dConference->eventHandler->getLastNotify(), - addr - ); Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event); if (cb) cb(cr, L_GET_C_BACK_PTR(event)); } -void ClientGroupChatRoom::onSubjectChanged (time_t tm, bool isFullState, const std::string &subject) { - L_D_T(RemoteConference, dConference); - RemoteConference::setSubject(subject); +void ClientGroupChatRoom::onSubjectChanged (shared_ptr event) { + RemoteConference::setSubject(event->getSubject()); LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); LinphoneChatRoomCbsSubjectChangedCb cb = linphone_chat_room_cbs_get_subject_changed(cbs); - shared_ptr event = make_shared( - tm, - dConference->conferenceAddress, - dConference->eventHandler->getLastNotify(), - subject - ); Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event); if (cb) cb(cr, L_GET_C_BACK_PTR(event)); } -void ClientGroupChatRoom::onParticipantDeviceAdded (time_t tm, bool isFullState, const Address &addr, const Address &gruu) { - L_D_T(RemoteConference, dConference); +void ClientGroupChatRoom::onParticipantDeviceAdded (shared_ptr event) { + const Address &addr = event->getParticipantAddress(); shared_ptr participant; if (isMe(addr)) participant = getMe(); @@ -378,26 +352,18 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (time_t tm, bool isFullState, lWarning() << "Participant " << participant << " added a device but is not in the list of participants!"; return; } - participant->getPrivate()->addDevice(gruu); + participant->getPrivate()->addDevice(event->getGruuAddress()); LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); LinphoneChatRoomCbsParticipantDeviceAddedCb cb = linphone_chat_room_cbs_get_participant_device_added(cbs); - shared_ptr event = make_shared( - EventLog::Type::ConferenceParticipantDeviceAdded, - tm, - dConference->conferenceAddress, - dConference->eventHandler->getLastNotify(), - addr, - gruu - ); Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event); if (cb) cb(cr, L_GET_C_BACK_PTR(event)); } -void ClientGroupChatRoom::onParticipantDeviceRemoved (time_t tm, bool isFullState, const Address &addr, const Address &gruu) { - L_D_T(RemoteConference, dConference); +void ClientGroupChatRoom::onParticipantDeviceRemoved (shared_ptr event) { + const Address &addr = event->getParticipantAddress(); shared_ptr participant; if (isMe(addr)) participant = getMe(); @@ -407,18 +373,10 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (time_t tm, bool isFullStat lWarning() << "Participant " << participant << " removed a device but is not in the list of participants!"; return; } - participant->getPrivate()->removeDevice(gruu); + participant->getPrivate()->removeDevice(event->getGruuAddress()); LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this); LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr); LinphoneChatRoomCbsParticipantDeviceRemovedCb cb = linphone_chat_room_cbs_get_participant_device_removed(cbs); - shared_ptr event = make_shared( - EventLog::Type::ConferenceParticipantDeviceRemoved, - tm, - dConference->conferenceAddress, - dConference->eventHandler->getLastNotify(), - addr, - gruu - ); Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event); if (cb) diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index e938fcfd5..9d96aac54 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -64,12 +64,12 @@ private: /* ConferenceListener */ void onConferenceCreated (const Address &addr) override; void onConferenceTerminated (const Address &addr) override; - void onParticipantAdded (time_t tm, bool isFullState, const Address &addr) override; - void onParticipantRemoved (time_t tm, bool isFullState, const Address &addr) override; - void onParticipantSetAdmin (time_t tm, bool isFullState, const Address &addr, bool isAdmin) override; - void onSubjectChanged (time_t tm, bool isFullState, const std::string &subject) override; - void onParticipantDeviceAdded (time_t tm, bool isFullState, const Address &addr, const Address &gruu) override; - void onParticipantDeviceRemoved (time_t tm, bool isFullState, const Address &addr, const Address &gruu) override; + void onParticipantAdded (std::shared_ptr event) override; + void onParticipantRemoved (std::shared_ptr event) override; + void onParticipantSetAdmin (std::shared_ptr event) override; + void onSubjectChanged (std::shared_ptr event) override; + void onParticipantDeviceAdded (std::shared_ptr event) override; + void onParticipantDeviceRemoved (std::shared_ptr event) override; private: /* CallSessionListener */ diff --git a/src/conference/conference-listener.h b/src/conference/conference-listener.h index 4bad04c11..fe0dbc90d 100644 --- a/src/conference/conference-listener.h +++ b/src/conference/conference-listener.h @@ -23,6 +23,7 @@ #include #include +#include "event-log/events.h" #include "linphone/utils/general.h" // ============================================================================= @@ -35,12 +36,12 @@ class ConferenceListener { public: virtual void onConferenceCreated (const Address &addr) = 0; virtual void onConferenceTerminated (const Address &addr) = 0; - virtual void onParticipantAdded (time_t tm, bool isFullState, const Address &addr) = 0; - virtual void onParticipantRemoved (time_t tm, bool isFullState, const Address &addr) = 0; - virtual void onParticipantSetAdmin (time_t tm, bool isFullState, const Address &addr, bool isAdmin) = 0; - virtual void onSubjectChanged (time_t tm, bool isFullState, const std::string &subject) = 0; - virtual void onParticipantDeviceAdded (time_t tm, bool isFullState, const Address &addr, const Address &gruu) = 0; - virtual void onParticipantDeviceRemoved (time_t tm, bool isFullState, const Address &addr, const Address &gruu) = 0; + virtual void onParticipantAdded (std::shared_ptr event) = 0; + virtual void onParticipantRemoved (std::shared_ptr event) = 0; + virtual void onParticipantSetAdmin (std::shared_ptr event) = 0; + virtual void onSubjectChanged (std::shared_ptr event) = 0; + virtual void onParticipantDeviceAdded (std::shared_ptr event) = 0; + virtual void onParticipantDeviceRemoved (std::shared_ptr event) = 0; }; LINPHONE_END_NAMESPACE diff --git a/src/conference/local-conference-event-handler.cpp b/src/conference/local-conference-event-handler.cpp index 6ff0222f2..b731aba69 100644 --- a/src/conference/local-conference-event-handler.cpp +++ b/src/conference/local-conference-event-handler.cpp @@ -83,7 +83,7 @@ string LocalConferenceEventHandlerPrivate::createNotify (ConferenceType confInfo } else { confInfo.setVersion(static_cast(notifyId)); } - confInfo.setState(isFullState ? "full" : "optional"); + confInfo.setState(isFullState ? StateType::full : StateType::partial); if (!confInfo.getConferenceDescription()) { ConferenceDescriptionType description = ConferenceDescriptionType(); confInfo.setConferenceDescription(description); @@ -117,13 +117,13 @@ string LocalConferenceEventHandlerPrivate::createNotifyFullState (int notifyId) user.setEndpoint(endpoints); user.setEntity(participant->getAddress().asStringUriOnly()); user.getRoles()->getEntry().push_back(participant->isAdmin() ? "admin" : "participant"); - user.setState("full"); + user.setState(StateType::full); for (const auto &device : participant->getPrivate()->getDevices()) { const string &gruu = device.getGruu().asStringUriOnly(); EndpointType endpoint = EndpointType(); endpoint.setEntity(gruu); - endpoint.setState("full"); + endpoint.setState(StateType::full); user.getEndpoint().push_back(endpoint); } @@ -148,7 +148,7 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdded (const A const string &gruu = device.getGruu().asStringUriOnly(); EndpointType endpoint = EndpointType(); endpoint.setEntity(gruu); - endpoint.setState("full"); + endpoint.setState(StateType::full); user.getEndpoint().push_back(endpoint); } } @@ -156,7 +156,7 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdded (const A user.setRoles(roles); user.setEntity(addr.asStringUriOnly()); user.getRoles()->getEntry().push_back("participant"); - user.setState("full"); + user.setState(StateType::full); confInfo.getUsers()->getUser().push_back(user); @@ -171,7 +171,7 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantRemoved (const UserType user = UserType(); user.setEntity(addr.asStringUriOnly()); - user.setState("deleted"); + user.setState(StateType::deleted); confInfo.getUsers()->getUser().push_back(user); return createNotify(confInfo, notifyId); @@ -188,7 +188,7 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdmined (const user.setRoles(roles); user.setEntity(addr.asStringUriOnly()); user.getRoles()->getEntry().push_back(isAdmin ? "admin" : "participant"); - user.setState("partial"); + user.setState(StateType::partial); confInfo.getUsers()->getUser().push_back(user); return createNotify(confInfo, notifyId); @@ -217,11 +217,11 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantDeviceAdded (c user.setRoles(roles); user.setEntity(addr.asStringUriOnly()); user.getRoles()->getEntry().push_back("participant"); - user.setState("partial"); + user.setState(StateType::partial); EndpointType endpoint = EndpointType(); endpoint.setEntity(gruu.asStringUriOnly()); - endpoint.setState("full"); + endpoint.setState(StateType::full); user.getEndpoint().push_back(endpoint); confInfo.getUsers()->getUser().push_back(user); @@ -241,11 +241,11 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantDeviceRemoved user.setRoles(roles); user.setEntity(addr.asStringUriOnly()); user.getRoles()->getEntry().push_back("participant"); - user.setState("partial"); + user.setState(StateType::partial); EndpointType endpoint = EndpointType(); endpoint.setEntity(gruu.asStringUriOnly()); - endpoint.setState("deleted"); + endpoint.setState(StateType::deleted); user.getEndpoint().push_back(endpoint); confInfo.getUsers()->getUser().push_back(user); diff --git a/src/conference/remote-conference-event-handler.cpp b/src/conference/remote-conference-event-handler.cpp index 21c2f5a7b..180d7e27b 100644 --- a/src/conference/remote-conference-event-handler.cpp +++ b/src/conference/remote-conference-event-handler.cpp @@ -77,7 +77,7 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) { if (confInfo->getConferenceDescription()->getFreeText().present()) tm = static_cast(Utils::stoll(confInfo->getConferenceDescription()->getFreeText().get())); - bool isFullState = (confInfo->getState() == "full"); + bool isFullState = (confInfo->getState() == StateType::full); Address cleanedConfAddress = d->confAddress; cleanedConfAddress.clean(); cleanedConfAddress.setPort(0); @@ -93,8 +93,13 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) { confInfo->getConferenceDescription().present() && confInfo->getConferenceDescription().get().getSubject().present() ) - d->listener->onSubjectChanged(tm, isFullState, confInfo->getConferenceDescription().get().getSubject().get()); - + d->listener->onSubjectChanged(make_shared( + tm, + isFullState, + d->confAddress, + d->lastNotify, + confInfo->getConferenceDescription().get().getSubject().get() + )); if (confInfo->getVersion().present()) d->lastNotify = confInfo->getVersion().get(); @@ -106,9 +111,16 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) { char *cAddrStr = linphone_address_as_string(cAddr); Address addr(cAddrStr); bctbx_free(cAddrStr); - if (user.getState() == "deleted") - d->listener->onParticipantRemoved(tm, isFullState, addr); - else { + if (user.getState() == StateType::deleted) { + d->listener->onParticipantRemoved(make_shared( + EventLog::Type::ConferenceParticipantRemoved, + tm, + isFullState, + d->confAddress, + d->lastNotify, + addr + )); + } else { bool isAdmin = false; if (user.getRoles()) { for (const auto &entry : user.getRoles()->getEntry()) { @@ -118,19 +130,50 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) { } } } - if (user.getState() == "full") - d->listener->onParticipantAdded(tm, isFullState, addr); - d->listener->onParticipantSetAdmin(tm, isFullState, addr, isAdmin); + if (user.getState() == StateType::full) { + d->listener->onParticipantAdded(make_shared( + EventLog::Type::ConferenceParticipantAdded, + tm, + isFullState, + d->confAddress, + d->lastNotify, + addr + )); + } + d->listener->onParticipantSetAdmin(make_shared( + isAdmin ? EventLog::Type::ConferenceParticipantSetAdmin : EventLog::Type::ConferenceParticipantUnsetAdmin, + tm, + isFullState, + d->confAddress, + d->lastNotify, + addr + )); for (const auto &endpoint : user.getEndpoint()) { if (!endpoint.getEntity().present()) break; Address gruu(endpoint.getEntity().get()); - if (endpoint.getState() == "deleted") - d->listener->onParticipantDeviceRemoved(tm, isFullState, addr, gruu); - else if (endpoint.getState() == "full") - d->listener->onParticipantDeviceAdded(tm, isFullState, addr, gruu); - + if (endpoint.getState() == StateType::deleted) { + d->listener->onParticipantDeviceRemoved(make_shared( + EventLog::Type::ConferenceParticipantDeviceRemoved, + tm, + isFullState, + d->confAddress, + d->lastNotify, + addr, + gruu + )); + } else if (endpoint.getState() == StateType::full) { + d->listener->onParticipantDeviceAdded(make_shared( + EventLog::Type::ConferenceParticipantDeviceAdded, + tm, + isFullState, + d->confAddress, + d->lastNotify, + addr, + gruu + )); + } } } linphone_address_unref(cAddr); diff --git a/src/conference/remote-conference-event-handler.h b/src/conference/remote-conference-event-handler.h index 993c1c9e2..b6cb6949f 100644 --- a/src/conference/remote-conference-event-handler.h +++ b/src/conference/remote-conference-event-handler.h @@ -22,8 +22,8 @@ #include -#include "object/object.h" #include "conference-listener.h" +#include "object/object.h" LINPHONE_BEGIN_NAMESPACE diff --git a/src/conference/remote-conference.cpp b/src/conference/remote-conference.cpp index ff27f5f00..68b6b990f 100644 --- a/src/conference/remote-conference.cpp +++ b/src/conference/remote-conference.cpp @@ -89,16 +89,16 @@ void RemoteConference::onConferenceTerminated (const Address &addr) { d->eventHandler->unsubscribe(); } -void RemoteConference::onParticipantAdded (time_t tm, bool isFullState, const Address &addr) {} +void RemoteConference::onParticipantAdded (std::shared_ptr event) {} -void RemoteConference::onParticipantRemoved (time_t tm, bool isFullState, const Address &addr) {} +void RemoteConference::onParticipantRemoved (std::shared_ptr event) {} -void RemoteConference::onParticipantSetAdmin (time_t tm, bool isFullState, const Address &addr, bool isAdmin) {} +void RemoteConference::onParticipantSetAdmin (std::shared_ptr event) {} -void RemoteConference::onSubjectChanged (time_t tm, bool isFullState, const std::string &subject) {} +void RemoteConference::onSubjectChanged (std::shared_ptr event) {} -void RemoteConference::onParticipantDeviceAdded (time_t tm, bool isFullState, const Address &addr, const Address &gruu) {} +void RemoteConference::onParticipantDeviceAdded (std::shared_ptr event) {} -void RemoteConference::onParticipantDeviceRemoved (time_t tm, bool isFullState, const Address &addr, const Address &gruu) {} +void RemoteConference::onParticipantDeviceRemoved (std::shared_ptr event) {} LINPHONE_END_NAMESPACE diff --git a/src/conference/remote-conference.h b/src/conference/remote-conference.h index 5487170f3..9b4e40c8d 100644 --- a/src/conference/remote-conference.h +++ b/src/conference/remote-conference.h @@ -46,12 +46,12 @@ protected: /* ConferenceListener */ void onConferenceCreated (const Address &addr) override; void onConferenceTerminated (const Address &addr) override; - void onParticipantAdded (time_t tm, bool isFullState, const Address &addr) override; - void onParticipantRemoved (time_t tm, bool isFullState, const Address &addr) override; - void onParticipantSetAdmin (time_t tm, bool isFullState, const Address &addr, bool isAdmin) override; - void onSubjectChanged (time_t tm, bool isFullState, const std::string &subject) override; - void onParticipantDeviceAdded (time_t tm, bool isFullState, const Address &addr, const Address &gruu) override; - void onParticipantDeviceRemoved (time_t tm, bool isFullState, const Address &addr, const Address &gruu) override; + void onParticipantAdded (std::shared_ptr event) override; + void onParticipantRemoved (std::shared_ptr event) override; + void onParticipantSetAdmin (std::shared_ptr event) override; + void onSubjectChanged (std::shared_ptr event) override; + void onParticipantDeviceAdded (std::shared_ptr event) override; + void onParticipantDeviceRemoved (std::shared_ptr event) override; private: L_DECLARE_PRIVATE(RemoteConference); diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 5fddd7267..244c45188 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -355,6 +355,7 @@ MainDb::MainDb (const shared_ptr &core) : CoreAccessor(core), AbstractDb(* return make_shared( type, date, + false, Address(peerAddress), notifyId, Address(participantAddress) @@ -386,6 +387,7 @@ MainDb::MainDb (const shared_ptr &core) : CoreAccessor(core), AbstractDb(* return make_shared( type, date, + false, Address(peerAddress), notifyId, Address(participantAddress), @@ -412,6 +414,7 @@ MainDb::MainDb (const shared_ptr &core) : CoreAccessor(core), AbstractDb(* // TODO: Use cache. return make_shared( date, + false, Address(peerAddress), notifyId, subject diff --git a/src/event-log/conference/conference-notified-event-p.h b/src/event-log/conference/conference-notified-event-p.h index af5855334..20f55c352 100644 --- a/src/event-log/conference/conference-notified-event-p.h +++ b/src/event-log/conference/conference-notified-event-p.h @@ -30,6 +30,7 @@ LINPHONE_BEGIN_NAMESPACE class ConferenceNotifiedEventPrivate : public ConferenceEventPrivate { private: unsigned int notifyId = 0; + bool isFullState = false; L_DECLARE_PUBLIC(ConferenceNotifiedEvent); }; diff --git a/src/event-log/conference/conference-notified-event.cpp b/src/event-log/conference/conference-notified-event.cpp index 5a0e4f857..3eba64c71 100644 --- a/src/event-log/conference/conference-notified-event.cpp +++ b/src/event-log/conference/conference-notified-event.cpp @@ -30,22 +30,26 @@ LINPHONE_BEGIN_NAMESPACE ConferenceNotifiedEvent::ConferenceNotifiedEvent ( Type type, time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId ) : ConferenceEvent(*new ConferenceNotifiedEventPrivate, type, time, conferenceAddress) { L_D(); d->notifyId = notifyId; + d->isFullState = isFullState; } ConferenceNotifiedEvent::ConferenceNotifiedEvent ( ConferenceNotifiedEventPrivate &p, Type type, time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId ) : ConferenceEvent(p, type, time, conferenceAddress) { L_D(); d->notifyId = notifyId; + d->isFullState = isFullState; } unsigned int ConferenceNotifiedEvent::getNotifyId () const { @@ -53,4 +57,9 @@ unsigned int ConferenceNotifiedEvent::getNotifyId () const { return d->notifyId; } +bool ConferenceNotifiedEvent::isFullState () const { + L_D(); + return d->isFullState; +} + LINPHONE_END_NAMESPACE diff --git a/src/event-log/conference/conference-notified-event.h b/src/event-log/conference/conference-notified-event.h index 4f238e857..bbb765e1d 100644 --- a/src/event-log/conference/conference-notified-event.h +++ b/src/event-log/conference/conference-notified-event.h @@ -30,15 +30,22 @@ class ConferenceNotifiedEventPrivate; class LINPHONE_PUBLIC ConferenceNotifiedEvent : public ConferenceEvent { public: - ConferenceNotifiedEvent (Type type, std::time_t time, const Address &conferenceAddress, unsigned int notifiyId); + ConferenceNotifiedEvent ( + Type type, std::time_t time, + bool isFullState, + const Address &conferenceAddress, + unsigned int notifiyId + ); unsigned int getNotifyId () const; + bool isFullState() const; protected: ConferenceNotifiedEvent ( ConferenceNotifiedEventPrivate &p, Type type, std::time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId ); diff --git a/src/event-log/conference/conference-participant-device-event.cpp b/src/event-log/conference/conference-participant-device-event.cpp index fbfbcceda..30850259d 100644 --- a/src/event-log/conference/conference-participant-device-event.cpp +++ b/src/event-log/conference/conference-participant-device-event.cpp @@ -36,6 +36,7 @@ public: ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent ( Type type, time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId, const Address &participantAddress, @@ -44,6 +45,7 @@ ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent ( *new ConferenceParticipantDeviceEventPrivate, type, time, + isFullState, conferenceAddress, notifyId, participantAddress diff --git a/src/event-log/conference/conference-participant-device-event.h b/src/event-log/conference/conference-participant-device-event.h index d57834dd7..27b315121 100644 --- a/src/event-log/conference/conference-participant-device-event.h +++ b/src/event-log/conference/conference-participant-device-event.h @@ -33,6 +33,7 @@ public: ConferenceParticipantDeviceEvent ( Type type, std::time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId, const Address &participantAddress, diff --git a/src/event-log/conference/conference-participant-event.cpp b/src/event-log/conference/conference-participant-event.cpp index b5e8406b6..c5ece237a 100644 --- a/src/event-log/conference/conference-participant-event.cpp +++ b/src/event-log/conference/conference-participant-event.cpp @@ -30,10 +30,18 @@ LINPHONE_BEGIN_NAMESPACE ConferenceParticipantEvent::ConferenceParticipantEvent ( Type type, time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId, const Address &participantAddress -) : ConferenceNotifiedEvent(*new ConferenceParticipantEventPrivate, type, time, conferenceAddress, notifyId) { +) : ConferenceNotifiedEvent( + *new ConferenceParticipantEventPrivate, + type, + time, + isFullState, + conferenceAddress, + notifyId +) { L_D(); L_ASSERT( type == Type::ConferenceParticipantAdded || @@ -48,10 +56,18 @@ ConferenceParticipantEvent::ConferenceParticipantEvent ( ConferenceParticipantEventPrivate &p, Type type, time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId, const Address &participantAddress -) : ConferenceNotifiedEvent(p, type, time, conferenceAddress, notifyId) { +) : ConferenceNotifiedEvent( + p, + type, + time, + isFullState, + conferenceAddress, + notifyId +) { L_D(); d->participantAddress = participantAddress; } diff --git a/src/event-log/conference/conference-participant-event.h b/src/event-log/conference/conference-participant-event.h index 792583dcf..ce96da04c 100644 --- a/src/event-log/conference/conference-participant-event.h +++ b/src/event-log/conference/conference-participant-event.h @@ -33,6 +33,7 @@ public: ConferenceParticipantEvent ( Type type, std::time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId, const Address &participantAddress @@ -45,6 +46,7 @@ protected: ConferenceParticipantEventPrivate &p, Type type, std::time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId, const Address &participantAddress diff --git a/src/event-log/conference/conference-subject-event.cpp b/src/event-log/conference/conference-subject-event.cpp index e07061dc2..817cb6157 100644 --- a/src/event-log/conference/conference-subject-event.cpp +++ b/src/event-log/conference/conference-subject-event.cpp @@ -35,6 +35,7 @@ public: ConferenceSubjectEvent::ConferenceSubjectEvent ( time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId, const string &subject @@ -42,6 +43,7 @@ ConferenceSubjectEvent::ConferenceSubjectEvent ( *new ConferenceSubjectEventPrivate, Type::ConferenceSubjectChanged, time, + isFullState, conferenceAddress, notifyId ) { diff --git a/src/event-log/conference/conference-subject-event.h b/src/event-log/conference/conference-subject-event.h index 8ea9a039f..aced99de5 100644 --- a/src/event-log/conference/conference-subject-event.h +++ b/src/event-log/conference/conference-subject-event.h @@ -34,6 +34,7 @@ class LINPHONE_PUBLIC ConferenceSubjectEvent : public ConferenceNotifiedEvent { public: ConferenceSubjectEvent ( std::time_t time, + bool isFullState, const Address &conferenceAddress, unsigned int notifyId, const std::string &subject diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 7f280fd10..3e58928c1 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -196,7 +196,7 @@ set(SOURCE_FILES_C set(SOURCE_FILES_CXX clonable-object-tester.cpp - #conference-event-tester.cpp + conference-event-tester.cpp conference-tester.cpp content-manager-tester.cpp cpim-tester.cpp diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index 2d003586a..82d797c3a 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -145,7 +145,7 @@ static const char *participant_added_notify = \ " "\ +" state=\"partial\" version=\"1\">"\ " "\ @@ -202,7 +202,7 @@ static const char *participant_not_added_notify = \ " "\ +" state=\"partial\" version=\"1\">"\ " "\ @@ -259,7 +259,7 @@ static const char *participant_deleted_notify = \ " "\ +" state=\"partial\" version=\"1\">"\ " "\ @@ -316,7 +316,7 @@ static const char *participant_admined_notify = \ " "\ +" state=\"partial\" version=\"1\">"\ " "\ @@ -377,7 +377,7 @@ static const char *participant_unadmined_notify = \ " "\ +" state=\"partial\" version=\"1\">"\ " "\ @@ -447,12 +447,12 @@ public: private: void onConferenceCreated (const Address &addr) override; void onConferenceTerminated (const Address &addr) override; - void onParticipantAdded (time_t tm, bool isFullState, const Address &addr) override; - void onParticipantRemoved (time_t tm, bool isFullState, const Address &addr) override; - void onParticipantSetAdmin (time_t tm, bool isFullState, const Address &addr, bool isAdmin) override; - void onSubjectChanged (time_t tm, bool isFullState, const string &subject) override; - void onParticipantDeviceAdded (time_t tm, bool isFullState, const Address &addr, const Address &gruu) override; - void onParticipantDeviceRemoved (time_t tm, bool isFullState, const Address &addr, const Address &gruu) override; + void onParticipantAdded (shared_ptr event) override; + void onParticipantRemoved (shared_ptr event) override; + void onParticipantSetAdmin (shared_ptr event) override; + void onSubjectChanged (shared_ptr event) override; + void onParticipantDeviceAdded (shared_ptr event) override; + void onParticipantDeviceRemoved (shared_ptr event) override; public: RemoteConferenceEventHandler *handler; @@ -473,33 +473,38 @@ void ConferenceEventTester::onConferenceCreated (const Address &addr) {} void ConferenceEventTester::onConferenceTerminated (const Address &addr) {} -void ConferenceEventTester::onParticipantAdded (time_t tm, bool isFullState, const Address &addr) { +void ConferenceEventTester::onParticipantAdded (shared_ptr event) { + const Address addr = event->getParticipantAddress(); participants.insert(pair(addr.asString(), FALSE)); participantDevices.insert(pair(addr.asString(), 0)); } -void ConferenceEventTester::onParticipantRemoved (time_t tm, bool isFullState, const Address &addr) { +void ConferenceEventTester::onParticipantRemoved (shared_ptr event) { + const Address addr = event->getParticipantAddress(); participants.erase(addr.asString()); participantDevices.erase(addr.asString()); } -void ConferenceEventTester::onParticipantSetAdmin (time_t tm, bool isFullState, const Address &addr, bool isAdmin) { +void ConferenceEventTester::onParticipantSetAdmin (shared_ptr event) { + const Address addr = event->getParticipantAddress(); auto it = participants.find(addr.asString()); if (it != participants.end()) - it->second = isAdmin; + it->second = (event->getType() == EventLog::Type::ConferenceParticipantSetAdmin); } -void ConferenceEventTester::onSubjectChanged(time_t tm, bool isFullState, const string &subject) { - confSubject = subject; +void ConferenceEventTester::onSubjectChanged(shared_ptr event) { + confSubject = event->getSubject(); } -void ConferenceEventTester::onParticipantDeviceAdded (time_t tm, bool isFullState, const Address &addr, const Address &gruu) { +void ConferenceEventTester::onParticipantDeviceAdded (shared_ptr event) { + const Address addr = event->getParticipantAddress(); auto it = participantDevices.find(addr.asString()); if (it != participantDevices.end()) it->second++; } -void ConferenceEventTester::onParticipantDeviceRemoved (time_t tm, bool isFullState, const Address &addr, const Address &gruu) { +void ConferenceEventTester::onParticipantDeviceRemoved (shared_ptr event) { + const Address addr = event->getParticipantAddress(); auto it = participantDevices.find(addr.asString()); if (it != participantDevices.end() && it->second > 0) it->second--; diff --git a/tester/tester.c b/tester/tester.c index ca41f129a..48708461e 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -563,7 +563,7 @@ void liblinphone_tester_add_suites() { bc_tester_add_suite(&account_creator_test_suite); bc_tester_add_suite(&stun_test_suite); bc_tester_add_suite(&event_test_suite); - //bc_tester_add_suite(&conference_event_test_suite); + bc_tester_add_suite(&conference_event_test_suite); bc_tester_add_suite(&conference_test_suite); bc_tester_add_suite(&content_manager_test_suite); bc_tester_add_suite(&flexisip_test_suite);