Commit 7383a292 authored by Ghislain MARY's avatar Ghislain MARY

Subscribe to the conference event package when a client group chat room enters the created state.

parent 9178c1a5
......@@ -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<LinphonePrivate::RemoteConferenceEventHandler *>(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<char *>(linphone_content_get_buffer(body)));
}
}
......
......@@ -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> 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> participant = findParticipant(addr);
shared_ptr<Participant> 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);
}
}
......
......@@ -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);
......
......@@ -40,10 +40,11 @@ public:
std::list<Address> parseResourceLists (std::string xmlBody);
protected:
LocalConferenceEventHandler *eventHandler = nullptr;
private:
L_DISABLE_COPY(LocalConference);
LocalConferenceEventHandler *eventHandler = nullptr;
};
LINPHONE_END_NAMESPACE
......
......@@ -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<ConferenceType> 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
......@@ -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);
......
......@@ -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
......
......@@ -438,7 +438,6 @@ public:
ConferenceEventTester::ConferenceEventTester (LinphoneCore *core, const Address &confAddr) {
handler = new RemoteConferenceEventHandler(core, this);
handler->setConferenceAddress(confAddr);
}
ConferenceEventTester::~ConferenceEventTester () {
......
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