feat(c-chat-room): add a method to get local address

This commit is contained in:
Ronan Abhamon 2017-11-23 11:46:32 +01:00
parent 5c7fe8a92b
commit a947f8bd6c
2 changed files with 24 additions and 8 deletions

View file

@ -99,6 +99,14 @@ LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_room_create_file_transfer_mes
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_room_get_peer_address(LinphoneChatRoom *cr);
/**
* get local address \link linphone_core_get_chat_room() associated to \endlink this #LinphoneChatRoom
* @param cr #LinphoneChatRoom object
* @return #LinphoneAddress local address
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_room_get_local_address(LinphoneChatRoom *cr);
/**
* Send a message to peer member of this chat room.
* @deprecated Use linphone_chat_message_send() instead.

View file

@ -45,7 +45,8 @@ L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(
_linphone_chat_room_constructor, _linphone_chat_room_destructor,
LinphoneChatRoomCbs *cbs;
mutable LinphoneAddress *conferenceAddressCache;
LinphoneAddress *peerAddressCache;
mutable LinphoneAddress *peerAddressCache;
mutable LinphoneAddress *localAddressCache;
)
static void _linphone_chat_room_constructor (LinphoneChatRoom *cr) {
@ -54,15 +55,12 @@ static void _linphone_chat_room_constructor (LinphoneChatRoom *cr) {
static void _linphone_chat_room_destructor (LinphoneChatRoom *cr) {
linphone_chat_room_cbs_unref(cr->cbs);
cr->cbs = nullptr;
if (cr->conferenceAddressCache) {
if (cr->conferenceAddressCache)
linphone_address_unref(cr->conferenceAddressCache);
cr->conferenceAddressCache = nullptr;
}
if (cr->peerAddressCache) {
if (cr->peerAddressCache)
linphone_address_unref(cr->peerAddressCache);
cr->peerAddressCache = nullptr;
}
if (cr->localAddressCache)
linphone_address_unref(cr->localAddressCache);
}
// =============================================================================
@ -97,10 +95,20 @@ const LinphoneAddress *linphone_chat_room_get_peer_address (LinphoneChatRoom *cr
if (cr->peerAddressCache) {
linphone_address_unref(cr->peerAddressCache);
}
cr->peerAddressCache = linphone_address_new(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getPeerAddress().asString().c_str());
return cr->peerAddressCache;
}
const LinphoneAddress *linphone_chat_room_get_local_address (LinphoneChatRoom *cr) {
if (cr->localAddressCache) {
linphone_address_unref(cr->localAddressCache);
}
cr->localAddressCache = linphone_address_new(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLocalAddress().asString().c_str());
return cr->localAddressCache;
}
LinphoneChatMessage *linphone_chat_room_create_message (LinphoneChatRoom *cr, const char *message) {
shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(L_C_TO_STRING(message));
LinphoneChatMessage *object = L_INIT(ChatMessage);