Commit 0a15a02f authored by Ghislain MARY's avatar Ghislain MARY

Add callbacks to the LinphoneChatRoom object.

parent 902d6c1d
......@@ -425,6 +425,14 @@ void linphone_core_cbs_set_version_update_check_result_received(LinphoneCoreCbs
cbs->vtable->version_update_check_result_received = cb;
}
LinphoneCoreCbsChatRoomInstantiatedCb linphone_core_cbs_get_chat_room_instantiated (LinphoneCoreCbs *cbs) {
return cbs->vtable->chat_room_instantiated;
}
void linphone_core_cbs_set_chat_room_instantiated (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomInstantiatedCb cb) {
cbs->vtable->chat_room_instantiated = cb;
}
typedef belle_sip_object_t_vptr_t LinphoneCore_vptr_t;
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneCore);
......
......@@ -508,6 +508,7 @@ LinphoneChatRoom * linphone_client_group_chat_room_new(LinphoneCore *lc, const b
void linphone_chat_room_release(LinphoneChatRoom *cr);
void linphone_chat_room_set_call(LinphoneChatRoom *cr, LinphoneCall *call);
bctbx_list_t * linphone_chat_room_get_transient_messages(const LinphoneChatRoom *cr);
LinphoneChatRoomCbs * linphone_chat_room_cbs_new (void);
void linphone_chat_message_destroy(LinphoneChatMessage* msg);
void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMessageState new_state);
void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessageState state);
......@@ -1681,6 +1682,7 @@ BELLE_SIP_TYPE_ID(LinphoneCallParams),
BELLE_SIP_TYPE_ID(LinphoneChatMessage),
BELLE_SIP_TYPE_ID(LinphoneChatMessageCbs),
BELLE_SIP_TYPE_ID(LinphoneChatRoom),
BELLE_SIP_TYPE_ID(LinphoneChatRoomCbs),
BELLE_SIP_TYPE_ID(LinphoneContent),
BELLE_SIP_TYPE_ID(LinphoneImEncryptionEngine),
BELLE_SIP_TYPE_ID(LinphoneImEncryptionEngineCbs),
......@@ -1770,6 +1772,7 @@ void linphone_core_notify_friend_list_created(LinphoneCore *lc, LinphoneFriendLi
void linphone_core_notify_friend_list_removed(LinphoneCore *lc, LinphoneFriendList *list);
void linphone_core_notify_call_created(LinphoneCore *lc, LinphoneCall *call);
void linphone_core_notify_version_update_check_result_received(LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url);
void linphone_core_notify_chat_room_instantiated (LinphoneCore *lc, LinphoneChatRoom *cr);
void set_playback_gain_db(AudioStream *st, float gain);
......
......@@ -321,6 +321,11 @@ void linphone_core_notify_version_update_check_result_received(LinphoneCore *lc,
cleanup_dead_vtable_refs(lc);
}
void linphone_core_notify_chat_room_instantiated (LinphoneCore *lc, LinphoneChatRoom *cr) {
NOTIFY_IF_EXIST(chat_room_instantiated, lc, cr);
cleanup_dead_vtable_refs(lc);
}
static VTableReference * v_table_reference_new(LinphoneCoreCbs *cbs, bool_t internal){
VTableReference *ref=ms_new0(VTableReference,1);
ref->valid=TRUE;
......
......@@ -76,7 +76,9 @@ set(ROOT_HEADER_FILES
set(C_API_HEADER_FILES
c-address.h
c-api.h
c-callbacks.h
c-chat-room.h
c-chat-room-cbs.h
c-event-log.h
c-participant.h
c-types.h
......
/*
* c-callbacks.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _C_CALLBACKS_H_
#define _C_CALLBACKS_H_
// TODO: Remove me in the future.
#include "linphone/callbacks.h"
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
/**
* @addtogroup chatroom
* @{
*/
/**
* Is composing notification callback prototype.
* @param[in] cr #LinphoneChatRoom involved in the conversation
* @param[in] participant The #LinphoneParticipant that has sent the is-composing notification
*/
typedef void (*LinphoneChatRoomCbsIsComposingReceivedCb) (LinphoneChatRoom *cr, const LinphoneParticipant *participant);
/**
* Callback used to notify a chat room that a message has been received.
* @param[in] cr #LinphoneChatRoom object
* @param[in] msg The #LinphoneChatMessage that has been received
*/
typedef void (*LinphoneChatRoomCbsMessageReceivedCb) (LinphoneChatRoom *cr, LinphoneChatMessage *msg);
/**
* Callback used to notify a chat room that a message has been received but we were unable to decrypt it
* @param cr #LinphoneChatRoom involved in this conversation
* @param msg The #LinphoneChatMessage that has been received
*/
typedef void (*LinphoneChatRoomCbsUndecryptableMessageReceivedCb) (LinphoneChatRoom *cr, LinphoneChatMessage *msg);
/**
* @}
**/
#ifdef __cplusplus
}
#endif // ifdef __cplusplus
#endif // ifndef _C_CALLBACKS_H_
/*
* c-chat-room-cbs.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _C_CHAT_ROOM_CBS_H_
#define _C_CHAT_ROOM_CBS_H_
#include "linphone/api/c-callbacks.h"
#include "linphone/api/c-types.h"
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
/**
* @addtogroup chatroom
* @{
*/
/**
* Acquire a reference to the chat room callbacks object.
* @param[in] cbs The chat room callbacks object
* @return The same chat room callbacks object
**/
LINPHONE_PUBLIC LinphoneChatRoomCbs * linphone_chat_room_cbs_ref (LinphoneChatRoomCbs *cbs);
/**
* Release reference to the chat room callbacks object.
* @param[in] cr The chat room callbacks object
**/
LINPHONE_PUBLIC void linphone_chat_room_cbs_unref (LinphoneChatRoomCbs *cbs);
/**
* Retrieve the user pointer associated with the chat room callbacks object.
* @param[in] cr The chat room callbacks object
* @return The user pointer associated with the chat room callbacks object
**/
LINPHONE_PUBLIC void * linphone_chat_room_cbs_get_user_data (const LinphoneChatRoomCbs *cbs);
/**
* Assign a user pointer to the chat room callbacks object.
* @param[in] cr The chat room callbacks object
* @param[in] ud The user pointer to associate with the chat room callbacks object
**/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_user_data (LinphoneChatRoomCbs *cbs, void *ud);
/**
* Get the is-composing received callback.
* @param[in] cbs LinphoneChatRoomCbs object.
* @return The current is-composing received callback.
*/
LINPHONE_PUBLIC LinphoneChatRoomCbsIsComposingReceivedCb linphone_chat_room_cbs_get_is_composing_received (const LinphoneChatRoomCbs *cbs);
/**
* Set the is-composing received callback.
* @param[in] cbs LinphoneChatRoomCbs object.
* @param[in] cb The is-composing received callback to be used.
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_is_composing_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsIsComposingReceivedCb cb);
/**
* Get the message received callback.
* @param[in] cbs LinphoneChatRoomCbs object.
* @return The current message received callback.
*/
LINPHONE_PUBLIC LinphoneChatRoomCbsMessageReceivedCb linphone_chat_room_cbs_get_message_received (const LinphoneChatRoomCbs *cbs);
/**
* Set the message received callback.
* @param[in] cbs LinphoneChatRoomCbs object.
* @param[in] cb The message received callback to be used.
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_message_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsMessageReceivedCb cb);
/**
* Get the undecryptable message received callback.
* @param[in] cbs LinphoneChatRoomCbs object.
* @return The current undecryptable message received callback.
*/
LINPHONE_PUBLIC LinphoneChatRoomCbsUndecryptableMessageReceivedCb linphone_chat_room_cbs_get_undecryptable_message_received (const LinphoneChatRoomCbs *cbs);
/**
* Set the undecryptable message received callback.
* @param[in] cbs LinphoneChatRoomCbs object.
* @param[in] cb The undecryptable message received callback to be used.
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_undecryptable_message_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsUndecryptableMessageReceivedCb cb);
/**
* @}
*/
#ifdef __cplusplus
}
#endif // ifdef __cplusplus
#endif // ifndef _C_CHAT_ROOM_H_
......@@ -223,6 +223,13 @@ LINPHONE_PUBLIC bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr);
*/
LINPHONE_PUBLIC LinphoneCall *linphone_chat_room_get_call(const LinphoneChatRoom *room);
/**
* Get the LinphoneChatRoomCbs object associated with the LinphoneChatRoom.
* @param[in] cr LinphoneChatRoom object
* @return The LinphoneChatRoomCbs object associated with the LinphoneChatRoom
*/
LINPHONE_PUBLIC LinphoneChatRoomCbs * linphone_chat_room_get_callbacks (const LinphoneChatRoom *cr);
/**
* Add a participant to a chat room. This may fail if this type of chat room does not handle participants.
* Use linphone_chat_room_can_handle_participants() to know if this chat room handles participants.
......
......@@ -75,7 +75,20 @@ typedef struct _LinphoneAddress LinphoneAddress;
typedef struct _LinphoneCall LinphoneCall;
typedef struct _LinphoneCallEvent LinphoneCallEvent;
/**
* A chat room is the place where text messages are exchanged.
* Can be created by linphone_core_create_chat_room().
* @ingroup chatroom
*/
typedef struct _LinphoneChatRoom LinphoneChatRoom;
/**
* An object to handle the callbacks for the handling a LinphoneChatRoom objects.
* @ingroup chatroom
*/
typedef struct _LinphoneChatRoomCbs LinphoneChatRoomCbs;
typedef struct _LinphoneConferenceEvent LinphoneConferenceEvent;
typedef struct _LinphoneConferenceParticipantEvent LinphoneConferenceParticipantEvent;
typedef struct _LinphoneEventLog LinphoneEventLog;
......
......@@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/types.h"
#include "linphone/api/c-callbacks.h"
/**
......@@ -502,6 +503,13 @@ typedef LinphoneCoreCbsFriendListRemovedCb LinphoneCoreFriendListRemovedCb;
*/
typedef void (*LinphoneCoreCbsVersionUpdateCheckResultReceivedCb) (LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url);
/**
* Callback prototype telling that a LinphoneChatRoom object has been instantiated. This is useful to set the callbacks on the LinphoneChatRoom object.
* @param[in] lc LinphoneCore object
* @param[in] cr The LinphoneChatRoom object that has been instantiated
*/
typedef void (*LinphoneCoreCbsChatRoomInstantiatedCb) (LinphoneCore *lc, LinphoneChatRoom *cr);
/**
* @}
**/
......
......@@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/types.h"
#include "linphone/api/c-types.h"
#include "linphone/api/c-chat-room.h"
#include "linphone/api/c-chat-room-cbs.h"
#ifdef __cplusplus
......
......@@ -218,6 +218,7 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreFriendListRemovedCb friend_list_removed;
LinphoneCoreCbsCallCreatedCb call_created;
LinphoneCoreCbsVersionUpdateCheckResultReceivedCb version_update_check_result_received;
LinphoneCoreCbsChatRoomInstantiatedCb chat_room_instantiated;
void *user_data; /**<User data associated with the above callbacks */
} LinphoneCoreVTable;
......@@ -676,6 +677,20 @@ LINPHONE_PUBLIC void linphone_core_cbs_set_version_update_check_result_received(
*/
LINPHONE_PUBLIC LinphoneCoreCbsVersionUpdateCheckResultReceivedCb linphone_core_cbs_get_version_update_check_result_received(LinphoneCoreCbs *cbs);
/**
* Get the chat room instantiated callback.
* @param[in] cbs LinphoneCoreCbs object
* @return The current callback
*/
LINPHONE_PUBLIC LinphoneCoreCbsChatRoomInstantiatedCb linphone_core_cbs_get_chat_room_instantiated (LinphoneCoreCbs *cbs);
/**
* Set the chat room instantiated callback.
* @param[in] cbs LinphoneCoreCbs object
* @param[in] cb The callback to use
*/
LINPHONE_PUBLIC void linphone_core_cbs_set_chat_room_instantiated (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomInstantiatedCb cb);
/**
* @}
**/
......
......@@ -365,13 +365,6 @@ typedef enum _LinphoneChatMessageState {
LinphoneChatMessageStateDisplayed /**< Message displayed to the remote user */
} LinphoneChatMessageState;
/**
* A chat room is the place where text messages are exchanged.
* Can be created by linphone_core_create_chat_room().
* @ingroup chatroom
*/
typedef struct _LinphoneChatRoom LinphoneChatRoom;
/**
* LinphoneConference class
* The _LinphoneConference struct does not exists, it's the Conference C++ class that is used behind
......
......@@ -100,6 +100,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
c-wrapper/api/c-address.cpp
c-wrapper/api/c-call-params.cpp
c-wrapper/api/c-chat-room.cpp
c-wrapper/api/c-chat-room-cbs.cpp
c-wrapper/api/c-event-log.cpp
c-wrapper/api/c-participant.cpp
call/call.cpp
......
/*
* c-chat-room-cbs.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "linphone/api/c-chat-room-cbs.h"
#include "private.h"
struct _LinphoneChatRoomCbs {
belle_sip_object_t base;
void *userData;
LinphoneChatRoomCbsIsComposingReceivedCb isComposingReceivedCb;
LinphoneChatRoomCbsMessageReceivedCb messageReceivedCb;
LinphoneChatRoomCbsUndecryptableMessageReceivedCb undecryptableMessageReceivedCb;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoomCbs);
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneChatRoomCbs);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneChatRoomCbs, belle_sip_object_t,
NULL, // destroy
NULL, // clone
NULL, // marshal
FALSE
);
LinphoneChatRoomCbs * linphone_chat_room_cbs_new (void) {
return belle_sip_object_new(LinphoneChatRoomCbs);
}
LinphoneChatRoomCbs * linphone_chat_room_cbs_ref (LinphoneChatRoomCbs *cbs) {
belle_sip_object_ref(cbs);
return cbs;
}
void linphone_chat_room_cbs_unref (LinphoneChatRoomCbs *cbs) {
belle_sip_object_unref(cbs);
}
void * linphone_chat_room_cbs_get_user_data (const LinphoneChatRoomCbs *cbs) {
return cbs->userData;
}
void linphone_chat_room_cbs_set_user_data (LinphoneChatRoomCbs *cbs, void *ud) {
cbs->userData = ud;
}
LinphoneChatRoomCbsIsComposingReceivedCb linphone_chat_room_cbs_get_is_composing_received (const LinphoneChatRoomCbs *cbs) {
return cbs->isComposingReceivedCb;
}
void linphone_chat_room_cbs_set_is_composing_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsIsComposingReceivedCb cb) {
cbs->isComposingReceivedCb = cb;
}
LinphoneChatRoomCbsMessageReceivedCb linphone_chat_room_cbs_get_message_received (const LinphoneChatRoomCbs *cbs) {
return cbs->messageReceivedCb;
}
void linphone_chat_room_cbs_set_message_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsMessageReceivedCb cb) {
cbs->messageReceivedCb = cb;
}
LinphoneChatRoomCbsUndecryptableMessageReceivedCb linphone_chat_room_cbs_get_undecryptable_message_received (const LinphoneChatRoomCbs *cbs) {
return cbs->undecryptableMessageReceivedCb;
}
void linphone_chat_room_cbs_set_undecryptable_message_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsUndecryptableMessageReceivedCb cb) {
cbs->undecryptableMessageReceivedCb = cb;
}
......@@ -42,12 +42,17 @@ static void _linphone_chat_room_destructor(LinphoneChatRoom *cr);
L_DECLARE_C_STRUCT_IMPL_WITH_XTORS(ChatRoom, ChatRoom, chat_room,
_linphone_chat_room_constructor, _linphone_chat_room_destructor,
LinphoneChatRoomCbs *cbs;
LinphoneAddress *peerAddressCache;
)
static void _linphone_chat_room_constructor(LinphoneChatRoom *cr) {}
static void _linphone_chat_room_constructor(LinphoneChatRoom *cr) {
cr->cbs = linphone_chat_room_cbs_new();
}
static void _linphone_chat_room_destructor(LinphoneChatRoom *cr) {
linphone_chat_room_cbs_unref(cr->cbs);
cr->cbs = nullptr;
if (cr->peerAddressCache) {
linphone_address_unref(cr->peerAddressCache);
cr->peerAddressCache = nullptr;
......@@ -189,6 +194,10 @@ LinphoneChatMessage * linphone_chat_room_find_message(LinphoneChatRoom *cr, cons
return GET_CPP_PTR(cr)->findMessage(message_id);
}
LinphoneChatRoomCbs * linphone_chat_room_get_callbacks (const LinphoneChatRoom *cr) {
return cr->cbs;
}
LinphoneParticipant * linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr) {
return L_GET_C_BACK_PTR(GET_CPP_PTR(cr)->addParticipant(
*L_GET_CPP_PTR_FROM_C_STRUCT(addr, Address, Address), nullptr, false),
......@@ -257,25 +266,27 @@ LinphoneChatRoom * linphone_chat_room_new(LinphoneCore *core, const LinphoneAddr
L_SET_CPP_PTR_FROM_C_STRUCT(cr, std::make_shared<LinphonePrivate::RealTimeTextChatRoom>(core, *L_GET_CPP_PTR_FROM_C_STRUCT(addr, Address, Address)));
else
L_SET_CPP_PTR_FROM_C_STRUCT(cr, std::make_shared<LinphonePrivate::BasicChatRoom>(core, *L_GET_CPP_PTR_FROM_C_STRUCT(addr, Address, Address)));
linphone_core_notify_chat_room_instantiated(core, cr);
return cr;
}
LinphoneChatRoom * linphone_client_group_chat_room_new(LinphoneCore *lc, const bctbx_list_t *addresses) {
const char *factoryUri = linphone_core_get_chat_conference_factory_uri(lc);
LinphoneChatRoom * linphone_client_group_chat_room_new(LinphoneCore *core, const bctbx_list_t *addresses) {
const char *factoryUri = linphone_core_get_chat_conference_factory_uri(core);
if (!factoryUri)
return nullptr;
LinphoneAddress *factoryAddr = linphone_address_new(factoryUri);
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(lc, factoryAddr);
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(core, factoryAddr);
linphone_address_unref(factoryAddr);
std::string from;
if (proxy)
from = L_GET_CPP_PTR_FROM_C_STRUCT(linphone_proxy_config_get_identity_address(proxy), Address, Address)->asString();
if (from.empty())
from = linphone_core_get_primary_contact(lc);
from = linphone_core_get_primary_contact(core);
LinphonePrivate::Address me(from);
std::list<LinphonePrivate::Address> l = L_GET_CPP_LIST_OF_CPP_OBJ_FROM_C_LIST_OF_STRUCT_PTR(addresses, Address, Address);
LinphoneChatRoom *cr = _linphone_chat_room_init();
L_SET_CPP_PTR_FROM_C_STRUCT(cr, make_shared<LinphonePrivate::ClientGroupChatRoom>(lc, me, l));
L_SET_CPP_PTR_FROM_C_STRUCT(cr, make_shared<LinphonePrivate::ClientGroupChatRoom>(core, me, l));
linphone_core_notify_chat_room_instantiated(core, cr);
return cr;
}
......
......@@ -76,6 +76,10 @@ protected:
void imdnReceived (const std::string &text);
void isComposingReceived (const std::string &text);
private:
void notifyChatMessageReceived (LinphoneChatMessage *msg);
void notifyUndecryptableMessageReceived (LinphoneChatMessage *msg);
private:
/* IsComposingListener */
void onIsComposingStateChanged (bool isComposing);
......
......@@ -425,7 +425,7 @@ LinphoneReason ChatRoomPrivate::messageReceived (SalOp *op, const SalMessage *sa
msg->is_secured = TRUE;
} else if (retval > 0) {
/* Unable to decrypt message */
linphone_core_notify_message_received_unable_decrypt(core, GET_BACK_PTR(q), msg);
notifyUndecryptableMessageReceived(msg);
reason = linphone_error_code_to_reason(retval);
linphone_chat_message_send_delivery_notification(msg, reason);
/* Return LinphoneReasonNone to avoid flexisip resending us a message we can't decrypt */
......@@ -472,9 +472,9 @@ LinphoneReason ChatRoomPrivate::messageReceived (SalOp *op, const SalMessage *sa
unreadCount = 1;
else
unreadCount++;
/* Mark the message as pending so that if linphone_core_chat_room_mark_as_read() is called
in the linphone_chat_room_message_received() callback, it will effectively be marked as
being read before being stored. */
/* Mark the message as pending so that if ChatRoom::markAsRead() is called in the
* ChatRoomPrivate::chatMessageReceived() callback, it will effectively be marked as
* being read before being stored. */
pendingMessage = msg;
}
......@@ -496,12 +496,8 @@ end:
void ChatRoomPrivate::chatMessageReceived (LinphoneChatMessage *msg) {
L_Q(ChatRoom);
if (msg->message) {
/* Legacy API */
linphone_core_notify_text_message_received(core, GET_BACK_PTR(q), msg->from, msg->message);
}
linphone_core_notify_message_received(core, GET_BACK_PTR(q), msg);
if (!ContentType::isImdn(msg->content_type) && !ContentType::isImIsComposing(msg->content_type)) {
notifyChatMessageReceived(msg);
remoteIsComposing = false;
linphone_core_notify_is_composing_received(core, GET_BACK_PTR(q));
linphone_chat_message_send_delivery_notification(msg, LinphoneReasonNone);
......@@ -519,6 +515,32 @@ void ChatRoomPrivate::isComposingReceived (const string &text) {
// -----------------------------------------------------------------------------
void ChatRoomPrivate::notifyChatMessageReceived (LinphoneChatMessage *msg) {
L_Q(ChatRoom);
LinphoneChatRoom *cr = GET_BACK_PTR(q);
if (msg->message) {
/* Legacy API */
linphone_core_notify_text_message_received(core, cr, msg->from, msg->message);
}
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
LinphoneChatRoomCbsMessageReceivedCb cb = linphone_chat_room_cbs_get_message_received(cbs);
if (cb)
cb(cr, msg);
linphone_core_notify_message_received(core, cr, msg);
}
void ChatRoomPrivate::notifyUndecryptableMessageReceived (LinphoneChatMessage *msg) {
L_Q(ChatRoom);
LinphoneChatRoom *cr = GET_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, msg);
linphone_core_notify_message_received_unable_decrypt(core, cr, msg);
}
// -----------------------------------------------------------------------------
void ChatRoomPrivate::onIsComposingStateChanged (bool isComposing) {
this->isComposing = isComposing;
sendIsComposingNotification();
......
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