Add linphone_chat_room_get_me() API.

This commit is contained in:
Ghislain MARY 2017-11-08 17:12:00 +01:00
parent ad896ab4f8
commit cc5ebffda4
11 changed files with 36 additions and 6 deletions

View file

@ -284,6 +284,7 @@ LINPHONE_PUBLIC bool_t linphone_chat_room_can_handle_participants (const Linphon
* Find a participant of a chat room from its address.
* @param[in] cr A LinphoneChatRoom object
* @param[in] addr The address to search in the list of participants of the chat room
* @return The participant if found, NULL otherwise.
*/
LINPHONE_PUBLIC LinphoneParticipant *linphone_chat_room_find_participant (const LinphoneChatRoom *cr, const LinphoneAddress *addr);
@ -294,6 +295,13 @@ LINPHONE_PUBLIC LinphoneParticipant *linphone_chat_room_find_participant (const
*/
LINPHONE_PUBLIC const LinphoneAddress *linphone_chat_room_get_conference_address (const LinphoneChatRoom *cr);
/**
* Get the participant representing myself in the chat room.
* @param[in] cr A LinphoneChatRoom object
* @return The participant representing myself in the conference.
*/
LINPHONE_PUBLIC LinphoneParticipant *linphone_chat_room_get_me (const LinphoneChatRoom *cr);
/**
* Get the number of participants in the chat room (that is without ourselves).
* @param[in] cr A LinphoneChatRoom object

View file

@ -266,6 +266,10 @@ const LinphoneAddress *linphone_chat_room_get_conference_address (const Linphone
return cr->conferenceAddressCache;
}
LinphoneParticipant *linphone_chat_room_get_me (const LinphoneChatRoom *cr) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMe());
}
int linphone_chat_room_get_nb_participants (const LinphoneChatRoom *cr) {
return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getNbParticipants();
}

View file

@ -64,6 +64,11 @@ const Address &BasicChatRoom::getConferenceAddress () const {
return Utils::getEmptyConstRefObject<Address>();
}
shared_ptr<Participant> BasicChatRoom::getMe () const {
lError() << "a BasicChatRoom does not handle participants";
return nullptr;
}
int BasicChatRoom::getNbParticipants () const {
return 1;
}

View file

@ -41,6 +41,7 @@ public:
bool canHandleParticipants () const override;
std::shared_ptr<Participant> findParticipant (const Address &addr) const override;
const Address &getConferenceAddress () const override;
std::shared_ptr<Participant> getMe () const override;
int getNbParticipants () const override;
std::list<std::shared_ptr<Participant>> getParticipants () const override;
const std::string &getSubject () const override;

View file

@ -145,6 +145,10 @@ const Address &ClientGroupChatRoom::getConferenceAddress () const {
return RemoteConference::getConferenceAddress();
}
shared_ptr<Participant> ClientGroupChatRoom::getMe () const {
return RemoteConference::getMe();
}
int ClientGroupChatRoom::getNbParticipants () const {
return RemoteConference::getNbParticipants();
}

View file

@ -47,6 +47,7 @@ public:
bool canHandleParticipants () const override;
std::shared_ptr<Participant> findParticipant (const Address &addr) const override;
const Address &getConferenceAddress () const override;
std::shared_ptr<Participant> getMe () const override;
int getNbParticipants () const override;
std::list<std::shared_ptr<Participant>> getParticipants () const override;
const std::string &getSubject () const override;

View file

@ -164,6 +164,11 @@ const Address &RealTimeTextChatRoom::getConferenceAddress () const {
return Utils::getEmptyConstRefObject<Address>();
}
shared_ptr<Participant> RealTimeTextChatRoom::getMe () const {
lError() << "a RealTimeTextChatRoom does not handle participants";
return nullptr;
}
int RealTimeTextChatRoom::getNbParticipants () const {
return 1;
}

View file

@ -47,6 +47,7 @@ public:
bool canHandleParticipants () const override;
std::shared_ptr<Participant> findParticipant (const Address &addr) const override;
const Address &getConferenceAddress () const override;
std::shared_ptr<Participant> getMe () const override;
int getNbParticipants () const override;
std::list<std::shared_ptr<Participant>> getParticipants () const override;
const std::string &getSubject () const override;

View file

@ -42,6 +42,7 @@ public:
virtual bool canHandleParticipants () const = 0;
virtual std::shared_ptr<Participant> findParticipant (const Address &addr) const = 0;
virtual const Address &getConferenceAddress () const = 0;
virtual std::shared_ptr<Participant> getMe () const = 0;
virtual int getNbParticipants () const = 0;
virtual std::list<std::shared_ptr<Participant>> getParticipants () const = 0;
virtual const std::string &getSubject () const = 0;

View file

@ -48,11 +48,6 @@ shared_ptr<Participant> Conference::getActiveParticipant () const {
return d->activeParticipant;
}
shared_ptr<Participant> Conference::getMe () const {
L_D();
return d->me;
}
LinphoneCore *Conference::getCore () const {
L_D();
return d->core;
@ -84,6 +79,11 @@ const Address &Conference::getConferenceAddress () const {
return d->conferenceAddress;
}
shared_ptr<Participant> Conference::getMe () const {
L_D();
return d->me;
}
int Conference::getNbParticipants () const {
L_D();
return static_cast<int>(d->participants.size());

View file

@ -40,7 +40,6 @@ public:
virtual ~Conference();
std::shared_ptr<Participant> getActiveParticipant () const;
std::shared_ptr<Participant> getMe () const;
LinphoneCore * getCore () const;
@ -52,6 +51,7 @@ public:
bool canHandleParticipants () const override;
std::shared_ptr<Participant> findParticipant (const Address &addr) const override;
const Address &getConferenceAddress () const override;
std::shared_ptr<Participant> getMe () const override;
int getNbParticipants () const override;
std::list<std::shared_ptr<Participant>> getParticipants () const override;
const std::string &getSubject () const override;