mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-30 07:46:22 +00:00
Add API to leave a chat room.
This commit is contained in:
parent
d60b5fab06
commit
7b59cd6ee6
13 changed files with 62 additions and 13 deletions
|
|
@ -289,6 +289,12 @@ LINPHONE_PUBLIC bctbx_list_t * linphone_chat_room_get_participants (const Linpho
|
||||||
*/
|
*/
|
||||||
LINPHONE_PUBLIC const char * linphone_chat_room_get_subject (const LinphoneChatRoom *cr);
|
LINPHONE_PUBLIC const char * linphone_chat_room_get_subject (const LinphoneChatRoom *cr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leave a chat room.
|
||||||
|
* @param[in] cr A LinphoneChatRoom object
|
||||||
|
*/
|
||||||
|
LINPHONE_PUBLIC void linphone_chat_room_leave (LinphoneChatRoom *cr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a participant of a chat room.
|
* Remove a participant of a chat room.
|
||||||
* @param[in] cr A LinphoneChatRoom object
|
* @param[in] cr A LinphoneChatRoom object
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
F(Instantiated) \
|
F(Instantiated) \
|
||||||
F(CreationPending) \
|
F(CreationPending) \
|
||||||
F(Created) \
|
F(Created) \
|
||||||
|
F(TerminationPending) \
|
||||||
F(Terminated) \
|
F(Terminated) \
|
||||||
F(CreationFailed)
|
F(CreationFailed)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,10 @@ const char * linphone_chat_room_get_subject (const LinphoneChatRoom *cr) {
|
||||||
return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getSubject());
|
return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getSubject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void linphone_chat_room_leave (LinphoneChatRoom *cr) {
|
||||||
|
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->leave();
|
||||||
|
}
|
||||||
|
|
||||||
void linphone_chat_room_remove_participant (LinphoneChatRoom *cr, LinphoneParticipant *participant) {
|
void linphone_chat_room_remove_participant (LinphoneChatRoom *cr, LinphoneParticipant *participant) {
|
||||||
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->removeParticipant(L_GET_CPP_PTR_FROM_C_OBJECT(participant));
|
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->removeParticipant(L_GET_CPP_PTR_FROM_C_OBJECT(participant));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,8 @@ const string &BasicChatRoom::getSubject () const {
|
||||||
return d->subject;
|
return d->subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BasicChatRoom::leave () {}
|
||||||
|
|
||||||
void BasicChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
|
void BasicChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
|
||||||
lError() << "removeParticipant() is not allowed on a BasicChatRoom";
|
lError() << "removeParticipant() is not allowed on a BasicChatRoom";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ public:
|
||||||
int getNbParticipants () const override;
|
int getNbParticipants () const override;
|
||||||
std::list<std::shared_ptr<Participant>> getParticipants () const override;
|
std::list<std::shared_ptr<Participant>> getParticipants () const override;
|
||||||
const std::string &getSubject () const override;
|
const std::string &getSubject () const override;
|
||||||
|
void leave () override;
|
||||||
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
|
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
|
||||||
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
|
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
|
||||||
void setSubject (const std::string &subject) override;
|
void setSubject (const std::string &subject) override;
|
||||||
|
|
|
||||||
|
|
@ -59,11 +59,6 @@ ClientGroupChatRoom::ClientGroupChatRoom (LinphoneCore *core, const Address &me,
|
||||||
this->subject = subject;
|
this->subject = subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientGroupChatRoom::~ClientGroupChatRoom () {
|
|
||||||
shared_ptr<CallSession> session = focus->getPrivate()->getSession();
|
|
||||||
session->terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ClientGroupChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) {
|
void ClientGroupChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) {
|
||||||
|
|
@ -119,6 +114,19 @@ const string &ClientGroupChatRoom::getSubject () const {
|
||||||
return RemoteConference::getSubject();
|
return RemoteConference::getSubject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientGroupChatRoom::leave () {
|
||||||
|
L_D();
|
||||||
|
eventHandler->unsubscribe();
|
||||||
|
shared_ptr<CallSession> session = focus->getPrivate()->getSession();
|
||||||
|
if (session)
|
||||||
|
session->terminate();
|
||||||
|
else {
|
||||||
|
session = d->createSession();
|
||||||
|
session->startInvite(nullptr, "", nullptr);
|
||||||
|
}
|
||||||
|
d->setState(ChatRoom::State::TerminationPending);
|
||||||
|
}
|
||||||
|
|
||||||
void ClientGroupChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
|
void ClientGroupChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
@ -219,18 +227,27 @@ void ClientGroupChatRoom::onSubjectChanged (const std::string &subject) {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ClientGroupChatRoom::onCallSessionSetTerminated (const std::shared_ptr<const CallSession> session) {
|
void ClientGroupChatRoom::onCallSessionSetReleased (const std::shared_ptr<const CallSession> session) {
|
||||||
if (session == focus->getPrivate()->getSession())
|
if (session == focus->getPrivate()->getSession())
|
||||||
focus->getPrivate()->removeSession();
|
focus->getPrivate()->removeSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientGroupChatRoom::onCallSessionStateChanged (const std::shared_ptr<const CallSession> session, LinphoneCallState state, const string &message) {
|
void ClientGroupChatRoom::onCallSessionStateChanged (const std::shared_ptr<const CallSession> session, LinphoneCallState state, const string &message) {
|
||||||
|
L_D();
|
||||||
if (state == LinphoneCallConnected) {
|
if (state == LinphoneCallConnected) {
|
||||||
Address addr(session->getRemoteContact());
|
if (d->state == ChatRoom::State::CreationPending) {
|
||||||
addr.clean();
|
Address addr(session->getRemoteContact());
|
||||||
onConferenceCreated(addr);
|
addr.clean();
|
||||||
if (session->getRemoteContactAddress()->hasParam("isfocus"))
|
onConferenceCreated(addr);
|
||||||
eventHandler->subscribe(conferenceAddress);
|
if (session->getRemoteContactAddress()->hasParam("isfocus"))
|
||||||
|
eventHandler->subscribe(conferenceAddress);
|
||||||
|
} else if (d->state == ChatRoom::State::TerminationPending) {
|
||||||
|
focus->getPrivate()->getSession()->terminate();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((state == LinphoneCallReleased) && (d->state == ChatRoom::State::TerminationPending)) {
|
||||||
|
onConferenceTerminated(conferenceAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class ClientGroupChatRoomPrivate;
|
||||||
class LINPHONE_PUBLIC ClientGroupChatRoom : public ChatRoom, public RemoteConference {
|
class LINPHONE_PUBLIC ClientGroupChatRoom : public ChatRoom, public RemoteConference {
|
||||||
public:
|
public:
|
||||||
ClientGroupChatRoom (LinphoneCore *core, const Address &me, const std::string &subject);
|
ClientGroupChatRoom (LinphoneCore *core, const Address &me, const std::string &subject);
|
||||||
virtual ~ClientGroupChatRoom ();
|
virtual ~ClientGroupChatRoom () = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* ConferenceInterface */
|
/* ConferenceInterface */
|
||||||
|
|
@ -49,6 +49,7 @@ public:
|
||||||
int getNbParticipants () const override;
|
int getNbParticipants () const override;
|
||||||
std::list<std::shared_ptr<Participant>> getParticipants () const override;
|
std::list<std::shared_ptr<Participant>> getParticipants () const override;
|
||||||
const std::string &getSubject () const override;
|
const std::string &getSubject () const override;
|
||||||
|
void leave () override;
|
||||||
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
|
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
|
||||||
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
|
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
|
||||||
void setSubject (const std::string &subject) override;
|
void setSubject (const std::string &subject) override;
|
||||||
|
|
@ -64,7 +65,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* CallSessionListener */
|
/* CallSessionListener */
|
||||||
void onCallSessionSetTerminated (const std::shared_ptr<const CallSession> session) override;
|
void onCallSessionSetReleased (const std::shared_ptr<const CallSession> session) override;
|
||||||
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> session, LinphoneCallState state, const std::string &message) override;
|
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> session, LinphoneCallState state, const std::string &message) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,8 @@ const string &RealTimeTextChatRoom::getSubject () const {
|
||||||
return d->subject;
|
return d->subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RealTimeTextChatRoom::leave () {}
|
||||||
|
|
||||||
void RealTimeTextChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
|
void RealTimeTextChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
|
||||||
lError() << "removeParticipant() is not allowed on a RealTimeTextChatRoom";
|
lError() << "removeParticipant() is not allowed on a RealTimeTextChatRoom";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ public:
|
||||||
int getNbParticipants () const override;
|
int getNbParticipants () const override;
|
||||||
std::list<std::shared_ptr<Participant>> getParticipants () const override;
|
std::list<std::shared_ptr<Participant>> getParticipants () const override;
|
||||||
const std::string &getSubject () const override;
|
const std::string &getSubject () const override;
|
||||||
|
void leave () override;
|
||||||
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
|
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
|
||||||
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
|
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
|
||||||
void setSubject (const std::string &subject) override;
|
void setSubject (const std::string &subject) override;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ public:
|
||||||
virtual int getNbParticipants () const = 0;
|
virtual int getNbParticipants () const = 0;
|
||||||
virtual std::list<std::shared_ptr<Participant>> getParticipants () const = 0;
|
virtual std::list<std::shared_ptr<Participant>> getParticipants () const = 0;
|
||||||
virtual const std::string &getSubject () const = 0;
|
virtual const std::string &getSubject () const = 0;
|
||||||
|
virtual void leave () = 0;
|
||||||
virtual void removeParticipant (const std::shared_ptr<const Participant> &participant) = 0;
|
virtual void removeParticipant (const std::shared_ptr<const Participant> &participant) = 0;
|
||||||
virtual void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) = 0;
|
virtual void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) = 0;
|
||||||
virtual void setSubject (const std::string &subject) = 0;
|
virtual void setSubject (const std::string &subject) = 0;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,8 @@ const string &Conference::getSubject () const {
|
||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Conference::leave () {}
|
||||||
|
|
||||||
void Conference::removeParticipant (const shared_ptr<const Participant> &participant) {
|
void Conference::removeParticipant (const shared_ptr<const Participant> &participant) {
|
||||||
lError() << "Conference class does not handle removeParticipant() generically";
|
lError() << "Conference class does not handle removeParticipant() generically";
|
||||||
}
|
}
|
||||||
|
|
@ -171,6 +173,14 @@ shared_ptr<Participant> Conference::findParticipant (const Address &addr) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shared_ptr<Participant> Conference::findParticipant (const shared_ptr<const CallSession> session) {
|
||||||
|
for (const auto &participant : participants) {
|
||||||
|
if (participant->getPrivate()->getSession() == session)
|
||||||
|
return participant;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool Conference::isMe (const Address &addr) const {
|
bool Conference::isMe (const Address &addr) const {
|
||||||
Address cleanedAddress = me->getAddress();
|
Address cleanedAddress = me->getAddress();
|
||||||
cleanedAddress.setPort(0);
|
cleanedAddress.setPort(0);
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ public:
|
||||||
int getNbParticipants () const override;
|
int getNbParticipants () const override;
|
||||||
std::list<std::shared_ptr<Participant>> getParticipants () const override;
|
std::list<std::shared_ptr<Participant>> getParticipants () const override;
|
||||||
const std::string &getSubject () const override;
|
const std::string &getSubject () const override;
|
||||||
|
void leave () override;
|
||||||
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
|
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
|
||||||
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
|
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
|
||||||
void setSubject (const std::string &subject) override;
|
void setSubject (const std::string &subject) override;
|
||||||
|
|
@ -80,6 +81,7 @@ protected:
|
||||||
explicit Conference (LinphoneCore *core, const Address &myAddress, CallListener *listener = nullptr);
|
explicit Conference (LinphoneCore *core, const Address &myAddress, CallListener *listener = nullptr);
|
||||||
|
|
||||||
std::shared_ptr<Participant> findParticipant (const Address &addr) const;
|
std::shared_ptr<Participant> findParticipant (const Address &addr) const;
|
||||||
|
std::shared_ptr<Participant> findParticipant (const std::shared_ptr<const CallSession> session);
|
||||||
bool isMe (const Address &addr) const ;
|
bool isMe (const Address &addr) const ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ class Participant : public Object {
|
||||||
friend class CallPrivate;
|
friend class CallPrivate;
|
||||||
friend class ClientGroupChatRoom;
|
friend class ClientGroupChatRoom;
|
||||||
friend class ClientGroupChatRoomPrivate;
|
friend class ClientGroupChatRoomPrivate;
|
||||||
|
friend class Conference;
|
||||||
friend class LocalConference;
|
friend class LocalConference;
|
||||||
friend class MediaSessionPrivate;
|
friend class MediaSessionPrivate;
|
||||||
friend class RemoteConference;
|
friend class RemoteConference;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue