Commit f983662d authored by Benjamin REIS's avatar Benjamin REIS

set device event of a server chat room when receiving a list subscription

parent 0c333d79
......@@ -26,6 +26,7 @@
#include "conference/handlers/remote-conference-event-handler-p.h"
#include "conference/handlers/remote-conference-list-event-handler.h"
#include "conference/participant-p.h"
#include "conference/participant-device.h"
#include "conference/remote-conference-p.h"
#include "conference/session/call-session-p.h"
#include "core/core-p.h"
......
......@@ -18,6 +18,7 @@
*/
#include "conference-p.h"
#include "conference/participant-device.h"
#include "conference/session/call-session-p.h"
#include "logger/logger.h"
#include "participant-p.h"
......
......@@ -22,6 +22,7 @@
#include "linphone/utils/utils.h"
#include "conference/local-conference.h"
#include "conference/participant-device.h"
#include "conference/participant-p.h"
#include "content/content-manager.h"
#include "content/content-type.h"
......
......@@ -19,13 +19,20 @@
#include "belle-sip/utils.h"
#include "linphone/utils/utils.h"
#include "linphone/api/c-address.h"
#include "address/address.h"
#include "c-wrapper/c-wrapper.h"
#include "chat/chat-room/abstract-chat-room.h"
#include "conference/participant-p.h"
#include "conference/participant-device.h"
#include "content/content.h"
#include "content/content-manager.h"
#include "content/content-type.h"
#include "core/core.h"
#include "local-conference-event-handler.h"
#include "local-conference-list-event-handler.h"
#include "logger/logger.h"
#include "xml/resource-lists.h"
#include "xml/rlmi.h"
......@@ -41,7 +48,42 @@ namespace {
// -----------------------------------------------------------------------------
void LocalConferenceListEventHandler::subscribeReceived (const string &xmlBody) {
void LocalConferenceListEventHandler::subscribeReceived (LinphoneEvent *lev) {
const LinphoneAddress *lAddr = linphone_event_get_from(lev);
char *addrStr = linphone_address_as_string(lAddr);
IdentityAddress participantAddr(addrStr);
bctbx_free(addrStr);
const LinphoneAddress *lDeviceAddr = linphone_event_get_remote_contact(lev);
char *deviceAddrStr = linphone_address_as_string(lDeviceAddr);
IdentityAddress deviceAddr(deviceAddrStr);
bctbx_free(deviceAddrStr);
for (const auto &handler : handlers) {
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(linphone_event_get_core(lev))->findChatRoom(handler->getChatRoomId());
if (!chatRoom) {
lError() << "Received subscribe for unknown chat room: " << handler->getChatRoomId();
continue;
}
shared_ptr<Participant> participant = chatRoom->findParticipant(participantAddr);
if (!participant) {
lError() << "Received subscribe for unknown participant: " << participantAddr << " for chat room: " << handler->getChatRoomId();
continue;
}
shared_ptr<ParticipantDevice> device = participant->getPrivate()->findDevice(deviceAddr);
if (!device) {
lError() << "Received subscribe for unknown device: " << deviceAddr << " for participant: "
<< participantAddr << " for chat room: " << handler->getChatRoomId();
return;
}
device->setConferenceSubscribeEvent((linphone_event_get_subscription_state(lev) == LinphoneSubscriptionActive) ? lev : nullptr);
}
}
void LocalConferenceListEventHandler::parseBody (const string &xmlBody) {
list<Content> contents;
Content rlmiContent;
rlmiContent.setContentType(ContentType::Rlmi);
......
......@@ -23,6 +23,8 @@
#include <memory>
#include <list>
#include "linphone/event.h"
#include "chat/chat-room/chat-room-id.h"
#include "linphone/utils/general.h"
......@@ -34,7 +36,8 @@ class LocalConferenceEventHandler;
class LocalConferenceListEventHandler {
public:
void subscribeReceived (const std::string &xmlBody);
void subscribeReceived (LinphoneEvent *lev);
void parseBody (const std::string &xmlBody);
void notify ();
void addHandler (std::shared_ptr<LocalConferenceEventHandler> handler);
std::shared_ptr<LocalConferenceEventHandler> findHandler (const ChatRoomId &chatRoomId) const;
......
......@@ -20,6 +20,7 @@
#include <algorithm>
#include "object/object-p.h"
#include "participant-device.h"
#include "participant-p.h"
#include "participant.h"
......
......@@ -25,7 +25,6 @@
#include "address/identity-address.h"
#include "object/object.h"
#include "conference/params/call-session-params.h"
#include "conference/participant-device.h"
// =============================================================================
......@@ -45,6 +44,7 @@ class Participant : public Object {
friend class LocalConferenceCallPrivate;
friend class LocalConferenceEventHandler;
friend class LocalConferenceEventHandlerPrivate;
friend class LocalConferenceListEventHandler;
friend class MainDb;
friend class MainDbPrivate;
friend class MediaSessionPrivate;
......
......@@ -26,6 +26,7 @@
#include "chat/chat-room/chat-room-p.h"
#include "chat/chat-room/client-group-chat-room.h"
#include "chat/chat-room/server-group-chat-room.h"
#include "conference/participant-device.h"
#include "conference/participant-p.h"
#include "core/core-p.h"
#include "event-log/event-log-p.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment