Commit 82ad99b6 authored by Ghislain MARY's avatar Ghislain MARY

End conference subscription correctly server side.

parent f172c4d8
......@@ -2248,9 +2248,21 @@ static void linphone_core_internal_subscribe_received(LinphoneCore *lc, Linphone
}
}
static void _linphone_core_conference_subscription_state_changed (LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
const LinphoneAddress *resource = linphone_event_get_resource(lev);
shared_ptr<AbstractChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ConferenceId(
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource))
));
if (chatRoom)
L_GET_PRIVATE(static_pointer_cast<ServerGroupChatRoom>(chatRoom))->subscriptionStateChanged(lev, state);
}
static void linphone_core_internal_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
if (strcasecmp(linphone_event_get_name(lev), "Presence") == 0) {
linphone_friend_list_subscription_state_changed(lc, lev, state);
} else if (strcmp(linphone_event_get_name(lev), "conference") == 0) {
_linphone_core_conference_subscription_state_changed(lc, lev, state);
}
}
......
......@@ -55,6 +55,7 @@ public:
void dispatchQueuedMessages ();
void subscribeReceived (LinphoneEvent *event);
void subscriptionStateChanged (LinphoneEvent *event, LinphoneSubscriptionState state);
bool update (SalCallOp *op);
......
......@@ -336,6 +336,11 @@ void ServerGroupChatRoomPrivate::subscribeReceived (LinphoneEvent *event) {
qConference->getPrivate()->eventHandler->subscribeReceived(event, !!(capabilities & ServerGroupChatRoom::Capabilities::OneToOne));
}
void ServerGroupChatRoomPrivate::subscriptionStateChanged (LinphoneEvent *event, LinphoneSubscriptionState state) {
L_Q_T(LocalConference, qConference);
qConference->getPrivate()->eventHandler->subscriptionStateChanged(event, state);
}
bool ServerGroupChatRoomPrivate::update (SalCallOp *op) {
L_Q();
if (sal_custom_header_find(op->getRecvCustomHeaders(), "Subject")) {
......
......@@ -439,8 +439,29 @@ void LocalConferenceEventHandler::subscribeReceived (LinphoneEvent *lev, bool on
d->conf->getConferenceAddress() <<
"] should not be higher than last notify sent by server [" << d->lastNotify << "]";
}
} else if (linphone_event_get_subscription_state(lev) == LinphoneSubscriptionTerminated)
}
}
void LocalConferenceEventHandler::subscriptionStateChanged (LinphoneEvent *lev, LinphoneSubscriptionState state) {
L_D();
if (state == LinphoneSubscriptionTerminated) {
const LinphoneAddress *lAddr = linphone_event_get_from(lev);
char *addrStr = linphone_address_as_string(lAddr);
shared_ptr<Participant> participant = d->conf->findParticipant(Address(addrStr));
bctbx_free(addrStr);
if (!participant)
return;
const LinphoneAddress *lContactAddr = linphone_event_get_remote_contact(lev);
char *contactAddrStr = linphone_address_as_string(lContactAddr);
IdentityAddress contactAddr(contactAddrStr);
bctbx_free(contactAddrStr);
shared_ptr<ParticipantDevice> device = participant->getPrivate()->findDevice(contactAddr);
if (!device)
return;
lInfo() << "End of subscription for device [" << device->getAddress()
<< "] of conference [" << d->conf->getConferenceAddress() << "]";
device->setConferenceSubscribeEvent(nullptr);
}
}
shared_ptr<ConferenceParticipantEvent> LocalConferenceEventHandler::notifyParticipantAdded (const Address &addr) {
......
......@@ -43,6 +43,8 @@ public:
LocalConferenceEventHandler (LocalConference *localConference, unsigned int notify = 0);
void subscribeReceived (LinphoneEvent *lev, bool oneToOne = false);
void subscriptionStateChanged (LinphoneEvent *lev, LinphoneSubscriptionState state);
std::shared_ptr<ConferenceParticipantEvent> notifyParticipantAdded (const Address &addr);
std::shared_ptr<ConferenceParticipantEvent> notifyParticipantRemoved (const Address &addr);
std::shared_ptr<ConferenceParticipantEvent> notifyParticipantSetAdmin (const Address &addr, bool isAdmin);
......
......@@ -57,7 +57,7 @@ shared_ptr<Core> ParticipantDevice::getCore () const {
void ParticipantDevice::setConferenceSubscribeEvent (LinphoneEvent *ev) {
if (mConferenceSubscribeEvent)
linphone_event_unref(mConferenceSubscribeEvent);
mConferenceSubscribeEvent = linphone_event_ref(ev);
mConferenceSubscribeEvent = ev ? linphone_event_ref(ev) : nullptr;
}
ostream &operator<< (ostream &stream, ParticipantDevice::State state) {
......
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