diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 2494d478a..01e1f72e1 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2115,10 +2115,8 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve } else if (strcmp(notified_event, "Conference") == 0) { LinphonePrivate::RemoteConferenceEventHandler *handler = reinterpret_cast(linphone_event_get_user_data(lev)); - if (handler) { - ms_message("Notify event for conference %s", handler->getConfId().c_str()); - handler->notifyReceived((char *)linphone_content_get_buffer(body)); - } + if (handler) + handler->notifyReceived(reinterpret_cast(linphone_content_get_buffer(body))); } } diff --git a/src/chat/client-group-chat-room.cpp b/src/chat/client-group-chat-room.cpp index bbfdcad87..3357fc5f1 100644 --- a/src/chat/client-group-chat-room.cpp +++ b/src/chat/client-group-chat-room.cpp @@ -108,6 +108,7 @@ void ClientGroupChatRoom::onConferenceCreated (const Address &addr) { L_D(); conferenceAddress = addr; d->setState(ChatRoom::State::Created); + eventHandler->subscribe(conferenceAddress); } void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) { @@ -116,6 +117,8 @@ void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) { } void ClientGroupChatRoom::onParticipantAdded (const Address &addr) { + if (isMe(addr)) + return; shared_ptr participant = findParticipant(addr); if (participant) { lWarning() << "Participant " << participant << " added but already in the list of participants!"; @@ -145,7 +148,11 @@ void ClientGroupChatRoom::onParticipantRemoved (const Address &addr) { } void ClientGroupChatRoom::onParticipantSetAdmin (const Address &addr, bool isAdmin) { - shared_ptr participant = findParticipant(addr); + shared_ptr participant = nullptr; + if (isMe(addr)) + participant = me; + else + participant = findParticipant(addr); if (!participant) { lWarning() << "Participant " << participant << " admin status has been changed but is not in the list of participants!"; return; @@ -163,6 +170,7 @@ void ClientGroupChatRoom::onParticipantSetAdmin (const Address &addr, bool isAdm void ClientGroupChatRoom::onCallSessionStateChanged (const CallSession &session, LinphoneCallState state, const string &message) { if (state == LinphoneCallConnected) { Address addr(session.getRemoteContact()); + addr.clean(); onConferenceCreated(addr); } } diff --git a/src/conference/local-conference-event-handler.cpp b/src/conference/local-conference-event-handler.cpp index 4065dd089..7e94fc45c 100644 --- a/src/conference/local-conference-event-handler.cpp +++ b/src/conference/local-conference-event-handler.cpp @@ -84,7 +84,7 @@ LocalConferenceEventHandler::~LocalConferenceEventHandler() { string LocalConferenceEventHandler::subscribeReceived(LinphoneEvent *lev) { L_D(); - string entity = d->conf->getMe()->getAddress().asStringUriOnly(); + string entity = d->conf->getConferenceAddress()->asStringUriOnly(); ConferenceType confInfo = ConferenceType(entity); UsersType users; confInfo.setUsers(users); @@ -103,13 +103,13 @@ string LocalConferenceEventHandler::subscribeReceived(LinphoneEvent *lev) { stringstream notify; serializeConferenceInfo(notify, confInfo, map); - //d->notifyFullState(notify.str(), lev); + d->notifyFullState(notify.str(), lev); return notify.str(); } string LocalConferenceEventHandler::notifyParticipantAdded(const Address &addr) { L_D(); - string entity = d->conf->getMe()->getAddress().asStringUriOnly(); + string entity = d->conf->getConferenceAddress()->asStringUriOnly(); ConferenceType confInfo = ConferenceType(entity); UsersType users; confInfo.setUsers(users); @@ -131,7 +131,7 @@ string LocalConferenceEventHandler::notifyParticipantAdded(const Address &addr) string LocalConferenceEventHandler::notifyParticipantRemoved(const Address &addr) { L_D(); - string entity = d->conf->getMe()->getAddress().asStringUriOnly(); + string entity = d->conf->getConferenceAddress()->asStringUriOnly(); ConferenceType confInfo = ConferenceType(entity); UsersType users; confInfo.setUsers(users); @@ -150,7 +150,7 @@ string LocalConferenceEventHandler::notifyParticipantRemoved(const Address &addr string LocalConferenceEventHandler::notifyParticipantSetAdmin(const Address &addr, bool isAdmin) { L_D(); - string entity = d->conf->getMe()->getAddress().asStringUriOnly(); + string entity = d->conf->getConferenceAddress()->asStringUriOnly(); ConferenceType confInfo = ConferenceType(entity); UsersType users; confInfo.setUsers(users); diff --git a/src/conference/local-conference.h b/src/conference/local-conference.h index 41a032765..c36bf9064 100644 --- a/src/conference/local-conference.h +++ b/src/conference/local-conference.h @@ -40,10 +40,11 @@ public: std::list
parseResourceLists (std::string xmlBody); +protected: + LocalConferenceEventHandler *eventHandler = nullptr; + private: L_DISABLE_COPY(LocalConference); - - LocalConferenceEventHandler *eventHandler = nullptr; }; LINPHONE_END_NAMESPACE diff --git a/src/conference/remote-conference-event-handler.cpp b/src/conference/remote-conference-event-handler.cpp index 6365707dc..a24a5d947 100644 --- a/src/conference/remote-conference-event-handler.cpp +++ b/src/conference/remote-conference-event-handler.cpp @@ -17,6 +17,7 @@ */ #include "remote-conference-event-handler.h" +#include "logger/logger.h" #include "object/object-p.h" #include "private.h" @@ -35,8 +36,7 @@ class RemoteConferenceEventHandlerPrivate : public ObjectPrivate { public: LinphoneCore *core = nullptr; ConferenceListener *listener = nullptr; - Address confAddr; - string confId; + Address confAddress; LinphoneEvent *lev = nullptr; }; @@ -59,16 +59,16 @@ RemoteConferenceEventHandler::~RemoteConferenceEventHandler() { // ----------------------------------------------------------------------------- -void RemoteConferenceEventHandler::subscribe(string confId) { +void RemoteConferenceEventHandler::subscribe(const Address &addr) { L_D(); - d->confId = confId; - LinphoneAddress *addr = linphone_address_new(d->confAddr.asString().c_str()); - d->lev = linphone_core_create_subscribe(d->core, addr, "Conference", 600); - linphone_address_unref(addr); + d->confAddress = addr; + LinphoneAddress *lAddr = linphone_address_new(d->confAddress.asString().c_str()); + d->lev = linphone_core_create_subscribe(d->core, lAddr, "Conference", 600); + linphone_address_unref(lAddr); linphone_event_ref(d->lev); linphone_event_set_internal(d->lev, TRUE); linphone_event_set_user_data(d->lev, this); - linphone_event_add_custom_header(d->lev, "Conf-id", d->confId.c_str()); // TODO : ??? + linphone_event_add_custom_header(d->lev, "Conf-id", d->confAddress.getUsername().c_str()); // TODO : ??? linphone_event_send_subscribe(d->lev, nullptr); } @@ -79,9 +79,12 @@ void RemoteConferenceEventHandler::unsubscribe() { void RemoteConferenceEventHandler::notifyReceived(string xmlBody) { L_D(); + lInfo() << "NOTIFY received for conference " << d->confAddress.asString(); istringstream data(xmlBody); unique_ptr confInfo = parseConferenceInfo(data, Xsd::XmlSchema::Flags::dont_validate); - if (confInfo->getEntity() == d->confAddr.asString()) { + Address cleanedConfAddress = d->confAddress; + cleanedConfAddress.setPort(0); + if (confInfo->getEntity() == cleanedConfAddress.asString()) { for (const auto &user : confInfo->getUsers()->getUser()) { LinphoneAddress *cAddr = linphone_core_interpret_url(d->core, user.getEntity()->c_str()); Address addr(linphone_address_as_string(cAddr)); @@ -108,14 +111,9 @@ void RemoteConferenceEventHandler::notifyReceived(string xmlBody) { // ----------------------------------------------------------------------------- -string RemoteConferenceEventHandler::getConfId() { +const Address &RemoteConferenceEventHandler::getConfAddress() { L_D(); - return d->confId; -} - -void RemoteConferenceEventHandler::setConferenceAddress (const Address &addr) { - L_D(); - d->confAddr = addr; + return d->confAddress; } LINPHONE_END_NAMESPACE diff --git a/src/conference/remote-conference-event-handler.h b/src/conference/remote-conference-event-handler.h index 6ea95adfd..73c16fd4f 100644 --- a/src/conference/remote-conference-event-handler.h +++ b/src/conference/remote-conference-event-handler.h @@ -35,12 +35,11 @@ class RemoteConferenceEventHandler : public Object { RemoteConferenceEventHandler(LinphoneCore *core, ConferenceListener *listener); ~RemoteConferenceEventHandler(); - void subscribe(std::string confId); + void subscribe(const Address &confAddress); void notifyReceived(std::string xmlBody); void unsubscribe(); - std::string getConfId(); - void setConferenceAddress (const Address &addr); + const Address &getConfAddress(); private: L_DECLARE_PRIVATE(RemoteConferenceEventHandler); diff --git a/src/conference/remote-conference.h b/src/conference/remote-conference.h index 8e7593320..c6eda721d 100644 --- a/src/conference/remote-conference.h +++ b/src/conference/remote-conference.h @@ -49,10 +49,11 @@ protected: void onParticipantRemoved (const Address &addr) override; void onParticipantSetAdmin (const Address &addr, bool isAdmin) override; +protected: + RemoteConferenceEventHandler *eventHandler = nullptr; + private: L_DISABLE_COPY(RemoteConference); - - RemoteConferenceEventHandler *eventHandler = nullptr; }; LINPHONE_END_NAMESPACE diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index 5aedeb447..5c428120c 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -438,7 +438,6 @@ public: ConferenceEventTester::ConferenceEventTester (LinphoneCore *core, const Address &confAddr) { handler = new RemoteConferenceEventHandler(core, this); - handler->setConferenceAddress(confAddr); } ConferenceEventTester::~ConferenceEventTester () {