mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 13:08:08 +00:00
Added multi listener for ChatRoom
This commit is contained in:
parent
fbdca469c7
commit
4ba2aa8af0
12 changed files with 188 additions and 83 deletions
|
|
@ -238,6 +238,10 @@ LinphoneCallCbs * linphone_factory_create_call_cbs(const LinphoneFactory *factor
|
|||
return _linphone_call_cbs_new();
|
||||
}
|
||||
|
||||
LinphoneChatRoomCbs * linphone_factory_create_chat_room_cbs(const LinphoneFactory *factory) {
|
||||
return linphone_chat_room_cbs_new();
|
||||
}
|
||||
|
||||
LinphoneVcard *linphone_factory_create_vcard(LinphoneFactory *factory) {
|
||||
return _linphone_vcard_new();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,23 @@ void linphone_call_notify_stats_updated(LinphoneCall *call, const LinphoneCallSt
|
|||
void linphone_call_notify_info_message_received(LinphoneCall *call, const LinphoneInfoMessage *msg);
|
||||
void linphone_call_notify_ack_processing(LinphoneCall *call, LinphoneHeaders *msg, bool_t is_received);
|
||||
|
||||
void linphone_chat_room_notify_is_composing_received(LinphoneChatRoom *cr, const LinphoneAddress *remoteAddr, bool_t isComposing);
|
||||
void linphone_chat_room_notify_message_received(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
|
||||
void linphone_chat_room_notify_participant_added(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
|
||||
void linphone_chat_room_notify_participant_removed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
|
||||
void linphone_chat_room_notify_participant_device_added(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
|
||||
void linphone_chat_room_notify_participant_device_removed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
|
||||
void linphone_chat_room_notify_participant_admin_status_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
|
||||
void linphone_chat_room_notify_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState);
|
||||
void linphone_chat_room_notify_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
|
||||
void linphone_chat_room_notify_undecryptable_message_received(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
|
||||
void linphone_chat_room_notify_chat_message_received(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
|
||||
void linphone_chat_room_notify_chat_message_sent(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
|
||||
void linphone_chat_room_notify_conference_address_generation(LinphoneChatRoom *cr);
|
||||
void linphone_chat_room_notify_participant_device_fetched(LinphoneChatRoom *cr, const LinphoneAddress *participantAddr);
|
||||
void linphone_chat_room_notify_participants_capabilities_checked(LinphoneChatRoom *cr, const LinphoneAddress *deviceAddr, const bctbx_list_t *participantsAddr);
|
||||
void linphone_chat_room_notify_chat_message_should_be_stored(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
|
||||
|
||||
LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg);
|
||||
LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, LinphonePrivate::SalCallOp *op);
|
||||
LinphoneCallLog * linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress * to);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ typedef void (*LinphoneCallCbsAckProcessingCb)(LinphoneCall *call, LinphoneHeade
|
|||
* @deprecated Use LinphoneChatMessageCbsMsgStateChangedCb instead.
|
||||
* @donotwrap
|
||||
*/
|
||||
typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud);
|
||||
typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud);
|
||||
|
||||
/**
|
||||
* Call back used to notify message delivery status
|
||||
|
|
|
|||
|
|
@ -277,10 +277,34 @@ LINPHONE_PUBLIC bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr);
|
|||
*/
|
||||
LINPHONE_PUBLIC LinphoneCall *linphone_chat_room_get_call(const LinphoneChatRoom *room);
|
||||
|
||||
/**
|
||||
* Add a listener in order to be notified of LinphoneChatRoom events. Once an event is received, registred LinphoneChatRoomCbs are
|
||||
* invoked sequencially.
|
||||
* @param[in] call LinphoneChatRoom object to monitor.
|
||||
* @param[in] cbs A LinphoneChatRoomCbs object holding the callbacks you need. A reference is taken by the LinphoneChatRoom until you invoke linphone_call_remove_callbacks().
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_chat_room_add_callbacks(LinphoneChatRoom *cr, LinphoneChatRoomCbs *cbs);
|
||||
|
||||
/**
|
||||
* Remove a listener from a LinphoneChatRoom
|
||||
* @param[in] call LinphoneChatRoom object
|
||||
* @param[in] cbs LinphoneChatRoomCbs object to remove.
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_chat_room_remove_callbacks(LinphoneChatRoom *cr, LinphoneChatRoomCbs *cbs);
|
||||
|
||||
/**
|
||||
* Gets the current LinphoneChatRoomCbs.
|
||||
* This is meant only to be called from a callback to be able to get the user_data associated with the LinphoneChatRoomCbs that is calling the callback.
|
||||
* @param[in] call LinphoneChatRoom object
|
||||
* @return The LinphoneChatRoomCbs that has called the last callback
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneChatRoomCbs *linphone_chat_room_get_current_callbacks(const LinphoneChatRoom *cr);
|
||||
|
||||
/**
|
||||
* Get the LinphoneChatRoomCbs object associated with the LinphoneChatRoom.
|
||||
* @param[in] cr LinphoneChatRoom object
|
||||
* @return The LinphoneChatRoomCbs object associated with the LinphoneChatRoom
|
||||
* @deprecated, use linphone_chat_room_add_callbacks instead
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneChatRoomCbs * linphone_chat_room_get_callbacks (const LinphoneChatRoom *cr);
|
||||
|
||||
|
|
|
|||
|
|
@ -224,6 +224,13 @@ LINPHONE_PUBLIC LinphoneAuthInfo *linphone_factory_create_auth_info(const Linpho
|
|||
*/
|
||||
LINPHONE_PUBLIC LinphoneCallCbs * linphone_factory_create_call_cbs(const LinphoneFactory *factory);
|
||||
|
||||
/**
|
||||
* Create a LinphoneChatRoomCbs object that holds callbacks for events happening on a chat room.
|
||||
* @param[in] factory LinphoneFactory singletion object
|
||||
* @return A new LinphoneChatRoomCbs object
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneChatRoomCbs * linphone_factory_create_chat_room_cbs(const LinphoneFactory *factory);
|
||||
|
||||
/**
|
||||
* Create an empty #LinphoneVcard.
|
||||
* @return a new #LinphoneVcard.
|
||||
|
|
|
|||
|
|
@ -54,6 +54,14 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_core_get_callbacks_list(const LinphoneCor
|
|||
*/
|
||||
LINPHONE_PUBLIC const bctbx_list_t *linphone_call_get_callbacks_list(const LinphoneCall *call);
|
||||
|
||||
/**
|
||||
* @brief Gets the list of listener in the chat room.
|
||||
* @param[in] call #LinphoneChatRoom object.
|
||||
* @return The list of #LinphoneChatRoomCbs.
|
||||
* @donotwrap
|
||||
*/
|
||||
LINPHONE_PUBLIC const bctbx_list_t *linphone_chat_room_get_callbacks_list(const LinphoneChatRoom *cr);
|
||||
|
||||
/**
|
||||
* Send a message to peer member of this chat room.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(
|
|||
ChatRoom,
|
||||
_linphone_chat_room_constructor, _linphone_chat_room_destructor,
|
||||
LinphoneChatRoomCbs *cbs;
|
||||
bctbx_list_t *callbacks; /* A list of LinphoneCallCbs object */
|
||||
LinphoneChatRoomCbs *currentCbs; /* The current LinphoneCallCbs object used to call a callback */
|
||||
mutable LinphoneAddress *conferenceAddressCache;
|
||||
mutable LinphoneAddress *peerAddressCache;
|
||||
mutable LinphoneAddress *localAddressCache;
|
||||
|
|
@ -69,6 +71,7 @@ static void _linphone_chat_room_destructor (LinphoneChatRoom *cr) {
|
|||
linphone_address_unref(cr->localAddressCache);
|
||||
if (cr->composingAddresses)
|
||||
bctbx_list_free_with_data(cr->composingAddresses, (bctbx_list_free_func)linphone_address_unref);
|
||||
bctbx_list_free_with_data(cr->callbacks, (bctbx_list_free_func)linphone_chat_room_cbs_unref);
|
||||
}
|
||||
|
||||
static list<LinphonePrivate::IdentityAddress> _get_identity_address_list_from_address_list(list<LinphonePrivate::Address> addressList) {
|
||||
|
|
@ -248,10 +251,6 @@ LinphoneChatMessage *linphone_chat_room_find_message (LinphoneChatRoom *cr, cons
|
|||
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findChatMessage(message_id));
|
||||
}
|
||||
|
||||
LinphoneChatRoomCbs *linphone_chat_room_get_callbacks (const LinphoneChatRoom *cr) {
|
||||
return cr->cbs;
|
||||
}
|
||||
|
||||
LinphoneChatRoomState linphone_chat_room_get_state (const LinphoneChatRoom *cr) {
|
||||
return (LinphoneChatRoomState)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getState();
|
||||
}
|
||||
|
|
@ -402,6 +401,106 @@ void linphone_chat_room_add_compatible_participants (LinphoneChatRoom *cr, const
|
|||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Callbacks
|
||||
// =============================================================================
|
||||
|
||||
LinphoneChatRoomCbs *linphone_chat_room_get_callbacks (const LinphoneChatRoom *cr) {
|
||||
return cr->cbs;
|
||||
}
|
||||
|
||||
void linphone_chat_room_add_callbacks (LinphoneChatRoom *cr, LinphoneChatRoomCbs *cbs) {
|
||||
cr->callbacks = bctbx_list_append(cr->callbacks, linphone_chat_room_cbs_ref(cbs));
|
||||
}
|
||||
|
||||
void linphone_chat_room_remove_callbacks (LinphoneChatRoom *cr, LinphoneChatRoomCbs *cbs) {
|
||||
cr->callbacks = bctbx_list_remove(cr->callbacks, cbs);
|
||||
linphone_chat_room_cbs_unref(cbs);
|
||||
}
|
||||
|
||||
LinphoneChatRoomCbs *linphone_chat_room_get_current_callbacks (const LinphoneChatRoom *cr) {
|
||||
return cr->currentCbs;
|
||||
}
|
||||
|
||||
const bctbx_list_t *linphone_chat_room_get_callbacks_list(const LinphoneChatRoom *cr) {
|
||||
return cr->callbacks;
|
||||
}
|
||||
|
||||
#define NOTIFY_IF_EXIST(cbName, functionName, ...) \
|
||||
LinphoneChatRoomCbs ## cbName ## Cb cb = linphone_chat_room_cbs_get_ ## functionName (cr->cbs); \
|
||||
if (cb) \
|
||||
cb(__VA_ARGS__); \
|
||||
for (bctbx_list_t *it = cr->callbacks; it; it = bctbx_list_next(it)) { \
|
||||
cr->currentCbs = reinterpret_cast<LinphoneChatRoomCbs *>(bctbx_list_get_data(it)); \
|
||||
cb = linphone_chat_room_cbs_get_ ## functionName (cr->currentCbs); \
|
||||
if (cb) \
|
||||
cb(__VA_ARGS__); \
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_is_composing_received(LinphoneChatRoom *cr, const LinphoneAddress *remoteAddr, bool_t isComposing) {
|
||||
NOTIFY_IF_EXIST(IsComposingReceived, is_composing_received, cr, remoteAddr, isComposing)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_message_received(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
|
||||
NOTIFY_IF_EXIST(MessageReceived, message_received, cr, msg)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_participant_added(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
NOTIFY_IF_EXIST(ParticipantAdded, participant_added, cr, event_log)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_participant_removed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
NOTIFY_IF_EXIST(ParticipantRemoved, participant_removed, cr, event_log)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_participant_device_added(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
NOTIFY_IF_EXIST(ParticipantDeviceAdded, participant_device_added, cr, event_log)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_participant_device_removed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
NOTIFY_IF_EXIST(ParticipantDeviceRemoved, participant_device_removed, cr, event_log)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_participant_admin_status_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
NOTIFY_IF_EXIST(ParticipantAdminStatusChanged, participant_admin_status_changed, cr, event_log)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) {
|
||||
NOTIFY_IF_EXIST(StateChanged, state_changed, cr, newState)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
NOTIFY_IF_EXIST(SubjectChanged, subject_changed, cr, event_log)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_undecryptable_message_received(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
|
||||
NOTIFY_IF_EXIST(UndecryptableMessageReceived, undecryptable_message_received, cr, msg)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_chat_message_received(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
NOTIFY_IF_EXIST(ChatMessageReceived, chat_message_received, cr, event_log)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_chat_message_sent(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
NOTIFY_IF_EXIST(ChatMessageSent, chat_message_sent, cr, event_log)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_conference_address_generation(LinphoneChatRoom *cr) {
|
||||
NOTIFY_IF_EXIST(ConferenceAddressGeneration, conference_address_generation, cr)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_participant_device_fetched(LinphoneChatRoom *cr, const LinphoneAddress *participantAddr) {
|
||||
NOTIFY_IF_EXIST(ParticipantDeviceFetched, participant_device_fetched, cr, participantAddr)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_participants_capabilities_checked(LinphoneChatRoom *cr, const LinphoneAddress *deviceAddr, const bctbx_list_t *participantsAddr) {
|
||||
NOTIFY_IF_EXIST(ParticipantsCapabilitiesChecked, participants_capabilities_checked, cr, deviceAddr, participantsAddr)
|
||||
}
|
||||
|
||||
void linphone_chat_room_notify_chat_message_should_be_stored(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
|
||||
NOTIFY_IF_EXIST(ShouldChatMessageBeStored, chat_message_should_be_stored, cr, msg)
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Reference and user data handling functions.
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -451,11 +451,7 @@ void ChatMessagePrivate::notifyReceiving () {
|
|||
return;
|
||||
|
||||
LinphoneChatRoom *chatRoom = L_GET_C_BACK_PTR(q->getChatRoom());
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(chatRoom);
|
||||
|
||||
LinphoneChatRoomCbsShouldChatMessageBeStoredCb shouldMessageBeStoredCb = linphone_chat_room_cbs_get_chat_message_should_be_stored(cbs);
|
||||
if (shouldMessageBeStoredCb)
|
||||
shouldMessageBeStoredCb(chatRoom, L_GET_C_BACK_PTR(q->getSharedFromThis()));
|
||||
linphone_chat_room_notify_chat_message_should_be_stored(chatRoom, L_GET_C_BACK_PTR(q->getSharedFromThis()));
|
||||
|
||||
if (toBeStored)
|
||||
storeInDb();
|
||||
|
|
@ -463,9 +459,7 @@ void ChatMessagePrivate::notifyReceiving () {
|
|||
shared_ptr<ConferenceChatMessageEvent> event = make_shared<ConferenceChatMessageEvent>(
|
||||
::time(nullptr), q->getSharedFromThis()
|
||||
);
|
||||
LinphoneChatRoomCbsChatMessageReceivedCb messageReceivedCb = linphone_chat_room_cbs_get_chat_message_received(cbs);
|
||||
if (messageReceivedCb)
|
||||
messageReceivedCb(chatRoom, L_GET_C_BACK_PTR(event));
|
||||
linphone_chat_room_notify_chat_message_received(chatRoom, L_GET_C_BACK_PTR(event));
|
||||
// Legacy
|
||||
q->getChatRoom()->getPrivate()->notifyChatMessageReceived(q->getSharedFromThis());
|
||||
|
||||
|
|
|
|||
|
|
@ -50,19 +50,16 @@ void ChatRoomPrivate::sendChatMessage (const shared_ptr<ChatMessage> &chatMessag
|
|||
dChatMessage->setTime(ms_time(0));
|
||||
dChatMessage->send();
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsChatMessageSentCb cb = linphone_chat_room_cbs_get_chat_message_sent(cbs);
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q);
|
||||
// TODO: server currently don't stock message, remove condition in the future.
|
||||
if (cb && !linphone_core_conference_server_enabled(q->getCore()->getCCore())) {
|
||||
if (!linphone_core_conference_server_enabled(q->getCore()->getCCore())) {
|
||||
shared_ptr<ConferenceChatMessageEvent> event = static_pointer_cast<ConferenceChatMessageEvent>(
|
||||
q->getCore()->getPrivate()->mainDb->getEventFromKey(dChatMessage->dbKey)
|
||||
);
|
||||
if (!event)
|
||||
event = make_shared<ConferenceChatMessageEvent>(time(nullptr), chatMessage);
|
||||
|
||||
cb(cr, L_GET_C_BACK_PTR(event));
|
||||
linphone_chat_room_notify_chat_message_sent(cr, L_GET_C_BACK_PTR(event));
|
||||
}
|
||||
|
||||
if (isComposing)
|
||||
|
|
@ -137,10 +134,7 @@ void ChatRoomPrivate::notifyChatMessageReceived (const shared_ptr<ChatMessage> &
|
|||
);
|
||||
linphone_address_unref(fromAddress);
|
||||
}
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsMessageReceivedCb cb = linphone_chat_room_cbs_get_message_received(cbs);
|
||||
if (cb)
|
||||
cb(cr, L_GET_C_BACK_PTR(chatMessage));
|
||||
linphone_chat_room_notify_message_received(cr, L_GET_C_BACK_PTR(chatMessage));
|
||||
linphone_core_notify_message_received(q->getCore()->getCCore(), cr, L_GET_C_BACK_PTR(chatMessage));
|
||||
}
|
||||
|
||||
|
|
@ -153,13 +147,9 @@ void ChatRoomPrivate::notifyIsComposingReceived (const Address &remoteAddress, b
|
|||
remoteIsComposing.remove(remoteAddress);
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsIsComposingReceivedCb cb = linphone_chat_room_cbs_get_is_composing_received(cbs);
|
||||
if (cb) {
|
||||
LinphoneAddress *lAddr = linphone_address_new(remoteAddress.asString().c_str());
|
||||
cb(cr, lAddr, !!isComposing);
|
||||
linphone_address_unref(lAddr);
|
||||
}
|
||||
LinphoneAddress *lAddr = linphone_address_new(remoteAddress.asString().c_str());
|
||||
linphone_chat_room_notify_is_composing_received(cr, lAddr, !!isComposing);
|
||||
linphone_address_unref(lAddr);
|
||||
// Legacy notification
|
||||
linphone_core_notify_is_composing_received(q->getCore()->getCCore(), cr);
|
||||
}
|
||||
|
|
@ -168,19 +158,13 @@ void ChatRoomPrivate::notifyStateChanged () {
|
|||
L_Q();
|
||||
linphone_core_notify_chat_room_state_changed(q->getCore()->getCCore(), L_GET_C_BACK_PTR(q), (LinphoneChatRoomState)state);
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsStateChangedCb cb = linphone_chat_room_cbs_get_state_changed(cbs);
|
||||
if (cb)
|
||||
cb(cr, (LinphoneChatRoomState)state);
|
||||
linphone_chat_room_notify_state_changed(cr, (LinphoneChatRoomState)state);
|
||||
}
|
||||
|
||||
void ChatRoomPrivate::notifyUndecryptableChatMessageReceived (const shared_ptr<ChatMessage> &chatMessage) {
|
||||
L_Q();
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsUndecryptableMessageReceivedCb cb = linphone_chat_room_cbs_get_undecryptable_message_received(cbs);
|
||||
if (cb)
|
||||
cb(cr, L_GET_C_BACK_PTR(chatMessage));
|
||||
linphone_chat_room_notify_undecryptable_message_received(cr, L_GET_C_BACK_PTR(chatMessage));
|
||||
linphone_core_notify_message_received_unable_decrypt(q->getCore()->getCCore(), cr, L_GET_C_BACK_PTR(chatMessage));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -513,10 +513,7 @@ void ClientGroupChatRoom::onParticipantAdded (const shared_ptr<ConferencePartici
|
|||
d->addEvent(event);
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsParticipantAddedCb cb = linphone_chat_room_cbs_get_participant_added(cbs);
|
||||
if (cb)
|
||||
cb(cr, L_GET_C_BACK_PTR(event));
|
||||
linphone_chat_room_notify_participant_added(cr, L_GET_C_BACK_PTR(event));
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantRemoved (const shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) {
|
||||
|
|
@ -536,10 +533,7 @@ void ClientGroupChatRoom::onParticipantRemoved (const shared_ptr<ConferenceParti
|
|||
d->addEvent(event);
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsParticipantRemovedCb cb = linphone_chat_room_cbs_get_participant_removed(cbs);
|
||||
if (cb)
|
||||
cb(cr, L_GET_C_BACK_PTR(event));
|
||||
linphone_chat_room_notify_participant_removed(cr, L_GET_C_BACK_PTR(event));
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantSetAdmin (const shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) {
|
||||
|
|
@ -567,10 +561,7 @@ void ClientGroupChatRoom::onParticipantSetAdmin (const shared_ptr<ConferencePart
|
|||
d->addEvent(event);
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsParticipantAdminStatusChangedCb cb = linphone_chat_room_cbs_get_participant_admin_status_changed(cbs);
|
||||
if (cb)
|
||||
cb(cr, L_GET_C_BACK_PTR(event));
|
||||
linphone_chat_room_notify_participant_admin_status_changed(cr, L_GET_C_BACK_PTR(event));
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onSubjectChanged (const shared_ptr<ConferenceSubjectEvent> &event, bool isFullState) {
|
||||
|
|
@ -586,10 +577,7 @@ void ClientGroupChatRoom::onSubjectChanged (const shared_ptr<ConferenceSubjectEv
|
|||
d->addEvent(event);
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsSubjectChangedCb cb = linphone_chat_room_cbs_get_subject_changed(cbs);
|
||||
if (cb)
|
||||
cb(cr, L_GET_C_BACK_PTR(event));
|
||||
linphone_chat_room_notify_subject_changed(cr, L_GET_C_BACK_PTR(event));
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantDeviceAdded (const shared_ptr<ConferenceParticipantDeviceEvent> &event, bool isFullState) {
|
||||
|
|
@ -613,10 +601,7 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (const shared_ptr<ConferenceP
|
|||
d->addEvent(event);
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsParticipantDeviceAddedCb cb = linphone_chat_room_cbs_get_participant_device_added(cbs);
|
||||
if (cb)
|
||||
cb(cr, L_GET_C_BACK_PTR(event));
|
||||
linphone_chat_room_notify_participant_device_added(cr, L_GET_C_BACK_PTR(event));
|
||||
}
|
||||
|
||||
void ClientGroupChatRoom::onParticipantDeviceRemoved (const shared_ptr<ConferenceParticipantDeviceEvent> &event, bool isFullState) {
|
||||
|
|
@ -638,10 +623,7 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (const shared_ptr<Conferenc
|
|||
d->addEvent(event);
|
||||
|
||||
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
|
||||
LinphoneChatRoomCbsParticipantDeviceRemovedCb cb = linphone_chat_room_cbs_get_participant_device_removed(cbs);
|
||||
if (cb)
|
||||
cb(cr, L_GET_C_BACK_PTR(event));
|
||||
linphone_chat_room_notify_participant_device_removed(cr, L_GET_C_BACK_PTR(event));
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ public:
|
|||
void teardownCallbacks ();
|
||||
|
||||
std::shared_ptr<AbstractChatRoom> chatRoom;
|
||||
LinphoneChatRoomCbs *callbacks;
|
||||
|
||||
L_DECLARE_PUBLIC(ProxyChatRoom);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,12 +29,10 @@ using namespace std;
|
|||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
#define PROXY_CALLBACK(callback, ...) \
|
||||
LinphoneChatRoomCbs *proxiedCbs = linphone_chat_room_get_callbacks(cr); \
|
||||
LinphoneChatRoomCbs *proxiedCbs = linphone_chat_room_get_current_callbacks(cr); \
|
||||
ProxyChatRoom *pcr = static_cast<ProxyChatRoom *>(linphone_chat_room_cbs_get_user_data(proxiedCbs)); \
|
||||
LinphoneChatRoom *lcr = L_GET_C_BACK_PTR(pcr->getSharedFromThis()); \
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(lcr); \
|
||||
if (linphone_chat_room_cbs_get_ ## callback(cbs)) \
|
||||
linphone_chat_room_cbs_get_ ## callback(cbs)(lcr, ##__VA_ARGS__)
|
||||
linphone_chat_room_notify_ ## callback(lcr, ##__VA_ARGS__)
|
||||
|
||||
static void chatMessageReceived (LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
PROXY_CALLBACK(chat_message_received, event_log);
|
||||
|
|
@ -99,7 +97,8 @@ static void undecryptableMessageReceived (LinphoneChatRoom *cr, LinphoneChatMess
|
|||
void ProxyChatRoomPrivate::setupCallbacks () {
|
||||
L_Q();
|
||||
LinphoneChatRoom *lcr = L_GET_C_BACK_PTR(chatRoom);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(lcr);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_cbs_new();
|
||||
callbacks = cbs;
|
||||
linphone_chat_room_cbs_set_user_data(cbs, q);
|
||||
linphone_chat_room_cbs_set_chat_message_received(cbs, chatMessageReceived);
|
||||
linphone_chat_room_cbs_set_chat_message_sent(cbs, chatMessageSent);
|
||||
|
|
@ -116,26 +115,12 @@ void ProxyChatRoomPrivate::setupCallbacks () {
|
|||
linphone_chat_room_cbs_set_state_changed(cbs, stateChanged);
|
||||
linphone_chat_room_cbs_set_subject_changed(cbs, subjectChanged);
|
||||
linphone_chat_room_cbs_set_undecryptable_message_received(cbs, undecryptableMessageReceived);
|
||||
linphone_chat_room_add_callbacks(lcr, cbs);
|
||||
}
|
||||
|
||||
void ProxyChatRoomPrivate::teardownCallbacks () {
|
||||
LinphoneChatRoom *lcr = L_GET_C_BACK_PTR(chatRoom);
|
||||
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(lcr);
|
||||
linphone_chat_room_cbs_set_chat_message_received(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_chat_message_sent(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_conference_address_generation(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_is_composing_received(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_message_received(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_participant_added(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_participant_admin_status_changed(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_participant_device_added(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_participant_device_fetched(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_participant_device_removed(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_participant_removed(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_participants_capabilities_checked(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_state_changed(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_subject_changed(cbs, nullptr);
|
||||
linphone_chat_room_cbs_set_undecryptable_message_received(cbs, nullptr);
|
||||
linphone_chat_room_remove_callbacks(lcr, callbacks);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue