From 04e028c74f9c293f5e343c9c1f0643e9ab44065f Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Mon, 4 Dec 2017 16:56:27 +0100 Subject: [PATCH] create event when creating notify --- .../local-conference-event-handler-p.h | 3 + .../local-conference-event-handler.cpp | 67 +++++++++++++++++-- .../handlers/local-conference-event-handler.h | 21 ++++-- 3 files changed, 77 insertions(+), 14 deletions(-) diff --git a/src/conference/handlers/local-conference-event-handler-p.h b/src/conference/handlers/local-conference-event-handler-p.h index e5822c9a9..24f65b2cc 100644 --- a/src/conference/handlers/local-conference-event-handler-p.h +++ b/src/conference/handlers/local-conference-event-handler-p.h @@ -22,6 +22,7 @@ #include +#include "chat/chat-room/chat-room-id.h" #include "local-conference-event-handler.h" #include "object/object-p.h" #include "xml/conference-info.h" @@ -48,6 +49,8 @@ public: inline unsigned int getLastNotify () const { return lastNotify; }; private: + ChatRoomId chatRoomId; + LocalConference *conf = nullptr; unsigned int lastNotify = 0; diff --git a/src/conference/handlers/local-conference-event-handler.cpp b/src/conference/handlers/local-conference-event-handler.cpp index f705a59fe..ee391c3e9 100644 --- a/src/conference/handlers/local-conference-event-handler.cpp +++ b/src/conference/handlers/local-conference-event-handler.cpp @@ -21,7 +21,6 @@ #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" @@ -397,36 +396,85 @@ void LocalConferenceEventHandler::subscribeReceived (LinphoneEvent *lev) { device->setConferenceSubscribeEvent(nullptr); } -void LocalConferenceEventHandler::notifyParticipantAdded (const Address &addr) { +shared_ptr LocalConferenceEventHandler::notifyParticipantAdded (const Address &addr) { L_D(); shared_ptr participant = d->conf->findParticipant(addr); d->notifyAllExcept(d->createNotifyParticipantAdded(addr), participant); + shared_ptr event = make_shared( + EventLog::Type::ConferenceParticipantAdded, + time(nullptr), + d->chatRoomId, + d->lastNotify, + addr + ); + return event; } -void LocalConferenceEventHandler::notifyParticipantRemoved (const Address &addr) { +shared_ptr LocalConferenceEventHandler::notifyParticipantRemoved (const Address &addr) { L_D(); shared_ptr participant = d->conf->findParticipant(addr); d->notifyAllExcept(d->createNotifyParticipantRemoved(addr), participant); + shared_ptr event = make_shared( + EventLog::Type::ConferenceParticipantRemoved, + time(nullptr), + d->chatRoomId, + d->lastNotify, + addr + ); + return event; } -void LocalConferenceEventHandler::notifyParticipantSetAdmin (const Address &addr, bool isAdmin) { +shared_ptr LocalConferenceEventHandler::notifyParticipantSetAdmin (const Address &addr, bool isAdmin) { L_D(); d->notifyAll(d->createNotifyParticipantAdmined(addr, isAdmin)); + shared_ptr event = make_shared( + isAdmin ? EventLog::Type::ConferenceParticipantSetAdmin : EventLog::Type::ConferenceParticipantUnsetAdmin, + time(nullptr), + d->chatRoomId, + d->lastNotify, + addr + ); + return event; } -void LocalConferenceEventHandler::notifySubjectChanged () { +shared_ptr LocalConferenceEventHandler::notifySubjectChanged () { L_D(); d->notifyAll(d->createNotifySubjectChanged()); + shared_ptr event = make_shared( + time(nullptr), + d->chatRoomId, + d->lastNotify, + d->conf->getSubject() + ); + return event; } -void LocalConferenceEventHandler::notifyParticipantDeviceAdded (const Address &addr, const Address &gruu) { +shared_ptr LocalConferenceEventHandler::notifyParticipantDeviceAdded (const Address &addr, const Address &gruu) { L_D(); d->notifyAll(d->createNotifyParticipantDeviceAdded(addr, gruu)); + shared_ptr event = make_shared( + EventLog::Type::ConferenceParticipantDeviceAdded, + time(nullptr), + d->chatRoomId, + d->lastNotify, + addr, + gruu + ); + return event; } -void LocalConferenceEventHandler::notifyParticipantDeviceRemoved (const Address &addr, const Address &gruu) { +shared_ptr LocalConferenceEventHandler::notifyParticipantDeviceRemoved (const Address &addr, const Address &gruu) { L_D(); d->notifyAll(d->createNotifyParticipantDeviceRemoved(addr, gruu)); + shared_ptr event = make_shared( + EventLog::Type::ConferenceParticipantDeviceRemoved, + time(nullptr), + d->chatRoomId, + d->lastNotify, + addr, + gruu + ); + return event; } void LocalConferenceEventHandler::setLastNotify (unsigned int lastNotify) { @@ -434,4 +482,9 @@ void LocalConferenceEventHandler::setLastNotify (unsigned int lastNotify) { d->lastNotify = lastNotify; } +void LocalConferenceEventHandler::setChatRoomId (const ChatRoomId &chatRoomId) { + L_D(); + d->chatRoomId = chatRoomId; +} + LINPHONE_END_NAMESPACE diff --git a/src/conference/handlers/local-conference-event-handler.h b/src/conference/handlers/local-conference-event-handler.h index 04f45632c..3e6aef9b1 100644 --- a/src/conference/handlers/local-conference-event-handler.h +++ b/src/conference/handlers/local-conference-event-handler.h @@ -20,6 +20,8 @@ #ifndef _LOCAL_CONFERENCE_EVENT_HANDLER_H_ #define _LOCAL_CONFERENCE_EVENT_HANDLER_H_ +#include + #include "linphone/types.h" #include "address/address.h" @@ -30,6 +32,10 @@ LINPHONE_BEGIN_NAMESPACE +class ChatRoomId; +class ConferenceParticipantDeviceEvent; +class ConferenceParticipantEvent; +class ConferenceSubjectEvent; class LocalConference; class LocalConferenceEventHandlerPrivate; @@ -39,14 +45,15 @@ public: ~LocalConferenceEventHandler (); void subscribeReceived (LinphoneEvent *lev); - void notifyParticipantAdded (const Address &addr); - void notifyParticipantRemoved (const Address &addr); - void notifyParticipantSetAdmin (const Address &addr, bool isAdmin); - void notifySubjectChanged (); - void notifyParticipantDeviceAdded (const Address &addr, const Address &gruu); - void notifyParticipantDeviceRemoved (const Address &addr, const Address &gruu); - + std::shared_ptr notifyParticipantAdded (const Address &addr); + std::shared_ptr notifyParticipantRemoved (const Address &addr); + std::shared_ptr notifyParticipantSetAdmin (const Address &addr, bool isAdmin); + std::shared_ptr notifySubjectChanged (); + std::shared_ptr notifyParticipantDeviceAdded (const Address &addr, const Address &gruu); + std::shared_ptr notifyParticipantDeviceRemoved (const Address &addr, const Address &gruu); + void setLastNotify (unsigned int lastNotify); + void setChatRoomId (const ChatRoomId &chatRoomId); private: L_DECLARE_PRIVATE(LocalConferenceEventHandler);