From 5c8fa71e9d77fe44497ef05c307fdf6476888742 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 17 Oct 2017 17:13:27 +0200 Subject: [PATCH] create event object on notifed conference event --- src/chat/chat-room/client-group-chat-room.cpp | 49 +++++++++++++++++++ .../remote-conference-event-handler-p.h | 5 -- .../remote-conference-event-handler.cpp | 7 ++- .../remote-conference-event-handler.h | 5 +- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index af63cc759..b7151aa59 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -26,6 +26,7 @@ #include "conference/remote-conference-event-handler.h" #include "conference/remote-conference-p.h" #include "conference/session/call-session-p.h" +#include "event-log/events.h" #include "logger/logger.h" #include "sal/refer-op.h" @@ -274,6 +275,14 @@ void ClientGroupChatRoom::onParticipantAdded (time_t tm, const Address &addr) { 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); + ConferenceParticipantEvent event( + EventLog::Type::ConferenceParticipantAdded, + tm, + dConference->conferenceAddress, + dConference->eventHandler->getLastNotify(), + addr + ); + if (cb) cb(cr, L_GET_C_BACK_PTR(participant)); } @@ -290,6 +299,13 @@ void ClientGroupChatRoom::onParticipantRemoved (time_t tm, const Address &addr) 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); + ConferenceParticipantEvent event( + EventLog::Type::ConferenceParticipantRemoved, + tm, + dConference->conferenceAddress, + dConference->eventHandler->getLastNotify(), + addr + ); if (cb) cb(cr, L_GET_C_BACK_PTR(participant)); @@ -298,6 +314,7 @@ void ClientGroupChatRoom::onParticipantRemoved (time_t tm, const Address &addr) } void ClientGroupChatRoom::onParticipantSetAdmin (time_t tm, const Address &addr, bool isAdmin) { + L_D_T(RemoteConference, dConference); shared_ptr participant; if (isMe(addr)) participant = getMe(); @@ -312,22 +329,37 @@ void ClientGroupChatRoom::onParticipantSetAdmin (time_t tm, const Address &addr, 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); + ConferenceParticipantEvent event( + isAdmin ? EventLog::Type::ConferenceParticipantSetAdmin : EventLog::Type::ConferenceParticipantUnsetAdmin, + tm, + dConference->conferenceAddress, + dConference->eventHandler->getLastNotify(), + addr + ); if (cb) cb(cr, L_GET_C_BACK_PTR(participant), isAdmin); } void ClientGroupChatRoom::onSubjectChanged (time_t tm, const std::string &subject) { + L_D_T(RemoteConference, dConference); RemoteConference::setSubject(subject); 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); + ConferenceSubjectEvent event( + tm, + dConference->conferenceAddress, + dConference->eventHandler->getLastNotify(), + subject + ); if (cb) cb(cr, subject.c_str()); } void ClientGroupChatRoom::onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) { + L_D_T(RemoteConference, dConference); shared_ptr participant; if (isMe(addr)) participant = getMe(); @@ -338,9 +370,18 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (time_t tm, const Address &ad return; } participant->getPrivate()->addDevice(gruu); + ConferenceParticipantDeviceEvent event( + EventLog::Type::ConferenceParticipantDeviceAdded, + tm, + dConference->conferenceAddress, + dConference->eventHandler->getLastNotify(), + addr, + gruu + ); } void ClientGroupChatRoom::onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) { + L_D_T(RemoteConference, dConference); shared_ptr participant; if (isMe(addr)) participant = getMe(); @@ -351,6 +392,14 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (time_t tm, const Address & return; } participant->getPrivate()->removeDevice(gruu); + ConferenceParticipantDeviceEvent event( + EventLog::Type::ConferenceParticipantDeviceRemoved, + tm, + dConference->conferenceAddress, + dConference->eventHandler->getLastNotify(), + addr, + gruu + ); } // ----------------------------------------------------------------------------- diff --git a/src/conference/remote-conference-event-handler-p.h b/src/conference/remote-conference-event-handler-p.h index 776435e08..88eba6168 100644 --- a/src/conference/remote-conference-event-handler-p.h +++ b/src/conference/remote-conference-event-handler-p.h @@ -29,11 +29,6 @@ LINPHONE_BEGIN_NAMESPACE class RemoteConferenceEventHandlerPrivate : public ObjectPrivate { -public: - inline unsigned int getLastNotify () const { - return lastNotify; - }; - private: LinphoneCore *core = nullptr; ConferenceListener *listener = nullptr; diff --git a/src/conference/remote-conference-event-handler.cpp b/src/conference/remote-conference-event-handler.cpp index 685f2ef7d..41430353e 100644 --- a/src/conference/remote-conference-event-handler.cpp +++ b/src/conference/remote-conference-event-handler.cpp @@ -68,7 +68,7 @@ void RemoteConferenceEventHandler::unsubscribe () { } } -void RemoteConferenceEventHandler::notifyReceived (string xmlBody) { +void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) { L_D(); lInfo() << "NOTIFY received for conference " << d->confAddress.asString(); istringstream data(xmlBody); @@ -133,4 +133,9 @@ const Address &RemoteConferenceEventHandler::getConfAddress () const { return d->confAddress; } +unsigned int RemoteConferenceEventHandler::getLastNotify () const { + L_D(); + return d->lastNotify; +}; + LINPHONE_END_NAMESPACE diff --git a/src/conference/remote-conference-event-handler.h b/src/conference/remote-conference-event-handler.h index 810feb49d..993c1c9e2 100644 --- a/src/conference/remote-conference-event-handler.h +++ b/src/conference/remote-conference-event-handler.h @@ -22,8 +22,6 @@ #include -#include "linphone/types.h" - #include "object/object.h" #include "conference-listener.h" @@ -37,10 +35,11 @@ class RemoteConferenceEventHandler : public Object { ~RemoteConferenceEventHandler (); void subscribe (const Address &confAddress); - void notifyReceived (std::string xmlBody); + void notifyReceived (const std::string &xmlBody); void unsubscribe (); const Address &getConfAddress () const; + unsigned int getLastNotify () const; private: L_DECLARE_PRIVATE(RemoteConferenceEventHandler);