Commit f8715508 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Fix some bugs in group chat handling.

parent 7099bab3
......@@ -138,7 +138,6 @@ LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc,
LinphoneChatRoom *_linphone_core_join_client_group_chat_room (LinphoneCore *lc, const LinphonePrivate::Address &addr) {
LinphoneChatRoom *cr = _linphone_client_group_chat_room_new(lc, addr.asString().c_str(), nullptr);
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->join();
_linphone_core_add_group_chat_room(lc, L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getConferenceAddress()->asStringUriOnly().c_str(), linphone_chat_room_ref(cr));
lc->chatrooms = bctbx_list_append(lc->chatrooms, cr);
return cr;
}
......
......@@ -7106,14 +7106,18 @@ bool_t _linphone_core_has_group_chat_room(const LinphoneCore *lc, const char *id
return result;
}
void _linphone_core_add_group_chat_room(LinphoneCore *lc, const char *id, LinphoneChatRoom *cr) {
bctbx_pair_t *pair = reinterpret_cast<bctbx_pair_t *>(bctbx_pair_cchar_new(id, linphone_chat_room_ref(cr)));
void _linphone_core_add_group_chat_room(LinphoneCore *lc, const LinphonePrivate::Address &addr, LinphoneChatRoom *cr) {
Address cleanedAddr = addr;
cleanedAddr.setPort(0);
bctbx_pair_t *pair = reinterpret_cast<bctbx_pair_t *>(bctbx_pair_cchar_new(cleanedAddr.asStringUriOnly().c_str(), linphone_chat_room_ref(cr)));
bctbx_map_cchar_insert_and_delete(lc->group_chat_rooms, pair);
}
LinphoneChatRoom *_linphone_core_find_group_chat_room(const LinphoneCore *lc, const char *id) {
LinphoneChatRoom *result = nullptr;
bctbx_iterator_t *it = bctbx_map_cchar_find_key(lc->group_chat_rooms, id);
Address cleanedAddr(id);
cleanedAddr.setPort(0);
bctbx_iterator_t *it = bctbx_map_cchar_find_key(lc->group_chat_rooms, cleanedAddr.asStringUriOnly().c_str());
bctbx_iterator_t *endit = bctbx_map_cchar_end(lc->group_chat_rooms);
if (!bctbx_iterator_cchar_equals(it, endit))
result = reinterpret_cast<LinphoneChatRoom *>(bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)));
......
......@@ -450,7 +450,7 @@ extern LinphonePrivate::Sal::Callbacks linphone_sal_callbacks;
LINPHONE_PUBLIC bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc);
LINPHONE_PUBLIC bool_t linphone_core_symmetric_rtp_enabled(LinphoneCore*lc);
bool_t _linphone_core_has_group_chat_room(const LinphoneCore *lc, const char *id);
void _linphone_core_add_group_chat_room(LinphoneCore *lc, const char *id, LinphoneChatRoom *cr);
void _linphone_core_add_group_chat_room(LinphoneCore *lc, const LinphonePrivate::Address &addr, LinphoneChatRoom *cr);
void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun, void *data, const char *task_description);
......
......@@ -20,6 +20,7 @@
#include "address/address-p.h"
#include "client-group-chat-room-p.h"
#include "c-wrapper/c-wrapper.h"
#include "conference/params/call-session-params-p.h"
#include "conference/session/call-session-p.h"
#include "conference/participant-p.h"
#include "content/content.h"
......@@ -174,7 +175,7 @@ void ClientGroupChatRoom::onConferenceCreated (const Address &addr) {
L_D();
conferenceAddress = addr;
d->setState(ChatRoom::State::Created);
_linphone_core_add_group_chat_room(d->core, addr.asStringUriOnly().c_str(), L_GET_C_BACK_PTR(this));
_linphone_core_add_group_chat_room(d->core, addr, L_GET_C_BACK_PTR(this));
}
void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) {
......
......@@ -174,7 +174,7 @@ shared_ptr<Participant> Conference::findParticipant (const Address &addr) const
for (const auto &participant : participants) {
Address participantAddr = participant->getAddress();
participantAddr.setPort(0);
if (testedAddr.equal(participantAddr))
if (testedAddr.weakEqual(participantAddr))
return participant;
}
return nullptr;
......
......@@ -59,9 +59,13 @@ void LocalConferenceEventHandlerPrivate::notifyFullState (const string &notify,
}
void LocalConferenceEventHandlerPrivate::notifyAllExcept (const string &notify, const Address &addr) {
Address cleanedAddr(addr);
cleanedAddr.setPort(0);
for (const auto &participant : conf->getParticipants()) {
if (participant->getPrivate()->isSubscribedToConferenceEventPackage() && (addr != participant->getAddress()))
sendNotify(notify, addr);
Address cleanedParticipantAddr(participant->getAddress());
cleanedParticipantAddr.setPort(0);
if (participant->getPrivate()->isSubscribedToConferenceEventPackage() && !(cleanedAddr.weakEqual(cleanedParticipantAddr)))
sendNotify(notify, participant->getAddress());
}
}
......@@ -157,6 +161,8 @@ string LocalConferenceEventHandlerPrivate::createNotifySubjectChanged () {
void LocalConferenceEventHandlerPrivate::sendNotify (const string &notify, const Address &addr) {
LinphoneAddress *cAddr = linphone_address_new(addr.asString().c_str());
LinphoneEvent *lev = linphone_core_create_notify(core, cAddr, "conference");
// Fix the From header to put the chat room URI
lev->op->set_from(this->conf->getConferenceAddress()->asString().c_str());
linphone_address_unref(cAddr);
doNotify(notify, lev);
}
......
......@@ -30,13 +30,12 @@
LINPHONE_BEGIN_NAMESPACE
class CallSession;
class CallSessionParamsPrivate;
class CallSessionPrivate;
class CallSessionParams : public ClonableObject {
friend class CallSession;
friend class CallSessionPrivate;
friend class ClientGroupChatRoom;
public:
CallSessionParams ();
......
......@@ -24,6 +24,8 @@
LINPHONE_BEGIN_NAMESPACE
class CallSession;
class LINPHONE_PUBLIC CallSessionListener {
public:
virtual ~CallSessionListener() = default;
......
......@@ -492,6 +492,7 @@ bool CallSessionPrivate::isUpdateAllowed (LinphoneCallState &nextState) const {
case LinphoneCallOutgoingEarlyMedia:
nextState = LinphoneCallEarlyUpdating;
break;
case LinphoneCallConnected:
case LinphoneCallStreamsRunning:
case LinphoneCallPausedByRemote:
case LinphoneCallUpdatedByRemote:
......@@ -943,8 +944,9 @@ LinphoneStatus CallSession::update (const CallSessionParams *csp, const string &
return -1;
if (d->currentParams == csp)
lWarning() << "CallSession::update() is given the current params, this is probably not what you intend to do!";
if (content)
d->op->set_local_body(*content);
if (csp)
d->params = new CallSessionParams(*csp);
d->op->set_local_body(content ? *content : Content());
LinphoneStatus result = d->startUpdate(subject);
if (result && (d->state != initialState)) {
/* Restore initial 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