Correctly handle LinphoneEvent object and unsubscribe correctly for client group chat rooms that do not use list subscription.

This commit is contained in:
Ghislain MARY 2018-05-14 16:00:15 +02:00
parent a5aab47bb1
commit 575069db12
3 changed files with 10 additions and 15 deletions

View file

@ -523,7 +523,7 @@ void ClientGroupChatRoom::leave () {
L_D();
L_D_T(RemoteConference, dConference);
dConference->eventHandler->getPrivate()->lev = nullptr;
dConference->eventHandler->unsubscribe();
shared_ptr<CallSession> session = dConference->focus->getPrivate()->getSession();
if (session)
session->terminate();
@ -559,7 +559,7 @@ void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) {
L_D();
L_D_T(RemoteConference, dConference);
dConference->eventHandler->getPrivate()->lev = nullptr;
dConference->eventHandler->unsubscribe();
dConference->eventHandler->resetLastNotify();
d->setState(ChatRoom::State::Terminated);
d->addEvent(make_shared<ConferenceEvent>(

View file

@ -208,7 +208,7 @@ void RemoteConferenceEventHandlerPrivate::subscribe () {
return;
}
lev = linphone_event_ref(linphone_core_create_subscribe(conf->getCore()->getCCore(), lAddr, "conference", 600));
lev = linphone_core_create_subscribe(conf->getCore()->getCCore(), lAddr, "conference", 600);
lev->op->setFrom(chatRoomId.getLocalAddress().asString().c_str());
const string &lastNotifyStr = Utils::toString(lastNotify);
linphone_event_add_custom_header(lev, "Last-Notify-Version", lastNotifyStr.c_str());
@ -222,7 +222,6 @@ void RemoteConferenceEventHandlerPrivate::subscribe () {
void RemoteConferenceEventHandlerPrivate::unsubscribe () {
if (lev) {
linphone_event_terminate(lev);
linphone_event_unref(lev);
lev = nullptr;
}
}
@ -257,8 +256,7 @@ RemoteConferenceEventHandler::~RemoteConferenceEventHandler () {
// Unable to unregister listener here. Core is destroyed and the listener doesn't exist.
}
if (d->lev)
unsubscribe();
unsubscribe();
}
// -----------------------------------------------------------------------------

View file

@ -57,8 +57,7 @@ RemoteConferenceListEventHandler::~RemoteConferenceListEventHandler () {
// Unable to unregister listener here. Core is destroyed and the listener doesn't exist.
}
if (lev)
unsubscribe();
unsubscribe();
}
// -----------------------------------------------------------------------------
@ -105,7 +104,7 @@ void RemoteConferenceListEventHandler::subscribe () {
LinphoneAddress *rlsAddr = linphone_address_new(linphone_proxy_config_get_conference_factory_uri(cfg));
lev = linphone_event_ref(linphone_core_create_subscribe(lc, rlsAddr, "conference", 600));
lev = linphone_core_create_subscribe(lc, rlsAddr, "conference", 600);
char *from = linphone_address_as_string(linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(getCore()->getCCore())));
lev->op->setFrom(from);
bctbx_free(from);
@ -126,12 +125,10 @@ void RemoteConferenceListEventHandler::subscribe () {
}
void RemoteConferenceListEventHandler::unsubscribe () {
if (!lev)
return;
linphone_event_terminate(lev);
linphone_event_unref(lev);
lev = nullptr;
if (lev) {
linphone_event_terminate(lev);
lev = nullptr;
}
}
void RemoteConferenceListEventHandler::notifyReceived (const Content *notifyContent) {