Commit f99300cb authored by Erwan Croze's avatar Erwan Croze 👋🏻

Merge branch 'dev_refactor_cpp' into dev_refactor_cpp_search_bar

parents 5574b7ec 539f7b0f
......@@ -198,7 +198,11 @@ const char *linphone_call_log_get_ref_key(const LinphoneCallLog *cl){
return cl->refkey;
}
LinphoneAddress *linphone_call_log_get_remote_address(const LinphoneCallLog *cl){
const LinphoneAddress *linphone_call_log_get_local_address(const LinphoneCallLog *cl) {
return (cl->dir == LinphoneCallIncoming) ? cl->to : cl->from;
}
const LinphoneAddress *linphone_call_log_get_remote_address(const LinphoneCallLog *cl){
return (cl->dir == LinphoneCallIncoming) ? cl->from : cl->to;
}
......
......@@ -39,6 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
#include "call/call-p.h"
#include "chat/chat-message/chat-message-p.h"
#include "chat/chat-room/chat-room.h"
#include "chat/chat-room/server-group-chat-room-p.h"
#include "conference/participant.h"
......@@ -565,7 +566,7 @@ static void message_delivery_update(SalOp *op, SalMessageDeliveryStatus status)
// Check that the message does not belong to an already destroyed chat room - if so, do not invoke callbacks
if (msg->getChatRoom())
msg->updateState((LinphonePrivate::ChatMessage::State)chatStatusSal2Linphone(status));
L_GET_PRIVATE(msg)->setState((LinphonePrivate::ChatMessage::State)chatStatusSal2Linphone(status));
}
static void info_received(SalOp *op, SalBodyHandler *body_handler) {
......
......@@ -36,6 +36,7 @@
#include "linphone/wrapper_utils.h"
#include "c-wrapper/c-wrapper.h"
#include "call/call.h"
#include "chat/chat-room/basic-chat-room.h"
#include "chat/chat-room/client-group-chat-room.h"
#include "chat/chat-room/client-group-to-basic-chat-room.h"
......@@ -149,12 +150,9 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
}
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call) {
if (linphone_core_realtime_text_enabled(lc)) {
shared_ptr<LinphonePrivate::RealTimeTextChatRoom> rttcr =
static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_OBJECT(cr));
L_GET_PRIVATE(rttcr)->realtimeTextReceived(character, call);
//L_GET_PRIVATE(static_pointer_cast<LinphonePrivate::RealTimeTextChatRoom>(L_GET_CPP_PTR_FROM_C_OBJECT(cr)))->realtimeTextReceived(character, call);
}
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
return;
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->realtimeTextReceived(character, L_GET_CPP_PTR_FROM_C_OBJECT(call));
}
unsigned int linphone_chat_message_store(LinphoneChatMessage *msg) {
......
......@@ -766,7 +766,7 @@ void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *li
LinphoneFriend * linphone_friend_list_find_friend_by_address(const LinphoneFriendList *list, const LinphoneAddress *address) {
LinphoneAddress *clean_addr = linphone_address_clone(address);
LinphoneFriend *lf;
if (linphone_address_has_param(clean_addr, "gr")) {
if (linphone_address_has_uri_param(clean_addr, "gr")) {
linphone_address_remove_uri_param(clean_addr, "gr");
}
char *uri = linphone_address_as_string_uri_only(clean_addr);
......
......@@ -917,7 +917,7 @@ void linphone_core_report_call_log(LinphoneCore *lc, LinphoneCallLog *call_log){
linphone_address_unref(conference_factory_addr);
}
const char *username = linphone_address_get_username(call_log->to);
if (strstr(username, "chatroom-") == username)
if (username && (strstr(username, "chatroom-") == username))
return;
// End of workaround
......
......@@ -355,7 +355,6 @@ LinphoneChatMessageStateChangedCb linphone_chat_message_get_message_state_change
void linphone_chat_message_set_message_state_changed_cb(LinphoneChatMessage* msg, LinphoneChatMessageStateChangedCb cb);
void linphone_chat_message_set_message_state_changed_cb_user_data(LinphoneChatMessage* msg, void *user_data);
void * linphone_chat_message_get_message_state_changed_cb_user_data(LinphoneChatMessage* msg);
void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMessageState new_state);
LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call);
void linphone_core_play_named_tone(LinphoneCore *lc, LinphoneToneID id);
......
......@@ -151,11 +151,6 @@ struct _LinphoneAuthInfo
char *algorithm;
};
struct _LinphoneChatMessageCharacter {
uint32_t value;
bool_t has_been_read;
};
struct _LinphoneFriendPresence {
char *uri_or_tel;
LinphonePresenceModel *presence;
......
......@@ -27,8 +27,6 @@ typedef struct StunCandidate StunCandidate;
typedef struct _PortConfig PortConfig;
typedef struct _LinphoneChatMessageCharacter LinphoneChatMessageCharacter;
typedef struct _LinphoneFriendPresence LinphoneFriendPresence;
typedef struct _LinphoneFriendPhoneNumberSipUri LinphoneFriendPhoneNumberSipUri;
......
......@@ -249,6 +249,13 @@ typedef void (*LinphoneChatRoomCbsParticipantDeviceFetchedCb) (LinphoneChatRoom
*/
typedef void (*LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb) (LinphoneChatRoom *cr, const LinphoneAddress *deviceAddr, const bctbx_list_t *participantsAddr);
/**
* Callback used to tell the core whether or not to store the incoming message in db or not using linphone_chat_message_set_to_be_stored().
* @param[in] cr #LinphoneChatRoom object
* @param[in] msg The #LinphoneChatMessage that is being received
*/
typedef void (*LinphoneChatRoomCbsShouldChatMessageBeStoredCb) (LinphoneChatRoom *cr, LinphoneChatMessage *msg);
/**
* @}
**/
......
......@@ -271,6 +271,19 @@ LINPHONE_PUBLIC LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb linphone_ch
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_participants_capabilities_checked (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb cb);
/**
* Get the message should be stored callback.
* @param[in] cbs LinphoneChatRoomCbs object
* @return The message should be stored getting callback
*/
LINPHONE_PUBLIC LinphoneChatRoomCbsShouldChatMessageBeStoredCb linphone_chat_room_cbs_get_chat_message_should_be_stored( LinphoneChatRoomCbs *cbs);
/**
* Set the message should be stored callback.
* @param[in] cbs LinphoneChatRoomCbs object
* @param[in] cb The message should be stored callback to be used
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_chat_message_should_be_stored( LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsShouldChatMessageBeStoredCb cb);
/**
* @}
*/
......
......@@ -179,6 +179,23 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history (LinphoneChatRoom *
*/
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end);
/**
* Gets nb_events most recent chat message events from cr chat room, sorted from oldest to most recent.
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which events should be retrieved
* @param[in] nb_events Number of events to retrieve. 0 means everything.
* @return \bctbx_list{LinphoneEventLog}
*/
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_message_events (LinphoneChatRoom *cr, int nb_events);
/**
* Gets the partial list of chat message events in the given range, sorted from oldest to most recent.
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which events should be retrieved
* @param[in] begin The first event of the range to be retrieved. History most recent event has index 0.
* @param[in] end The last event of the range to be retrieved. History oldest event has index of history size - 1
* @return \bctbx_list{LinphoneEventLog}
*/
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range_message_events (LinphoneChatRoom *cr, int begin, int end);
/**
* Gets nb_events most recent events from cr chat room, sorted from oldest to most recent.
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which events should be retrieved
......@@ -281,6 +298,13 @@ LINPHONE_PUBLIC LinphoneChatRoomState linphone_chat_room_get_state (const Linpho
*/
LINPHONE_PUBLIC bool_t linphone_chat_room_has_been_left (const LinphoneChatRoom *cr);
/**
* Return the last updated time for the chat room
* @param[in] cr LinphoneChatRoom object
* @return the last updated time
*/
LINPHONE_PUBLIC time_t linphone_chat_room_get_last_update_time(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.
......
......@@ -90,12 +90,19 @@ LINPHONE_PUBLIC float linphone_call_log_get_quality(const LinphoneCallLog *cl);
**/
LINPHONE_PUBLIC const char * linphone_call_log_get_ref_key(const LinphoneCallLog *cl);
/**
* Get the local address (that is from or to depending on call direction)
* @param[in] cl LinphoneCallLog object
* @return The local address of the call
*/
LINPHONE_PUBLIC const LinphoneAddress *linphone_call_log_get_local_address(const LinphoneCallLog *cl);
/**
* Get the remote address (that is from or to depending on call direction).
* @param[in] cl LinphoneCallLog object
* @return The remote address of the call.
**/
LINPHONE_PUBLIC LinphoneAddress * linphone_call_log_get_remote_address(const LinphoneCallLog *cl);
LINPHONE_PUBLIC const LinphoneAddress * linphone_call_log_get_remote_address(const LinphoneCallLog *cl);
/**
* Get the RTP statistics computed by the remote end and sent back via RTCP.
......
......@@ -27,6 +27,10 @@
// =============================================================================
// -----------------------------------------------------------------------------
// Namespace.
// -----------------------------------------------------------------------------
#ifdef __cplusplus
#define LINPHONE_BEGIN_NAMESPACE namespace LinphonePrivate {
#define LINPHONE_END_NAMESPACE }
......@@ -75,10 +79,10 @@ LINPHONE_BEGIN_NAMESPACE
// Debug.
// -----------------------------------------------------------------------------
void l_assert (const char *condition, const char *file, int line);
void lAssert (const char *condition, const char *file, int line);
#ifdef DEBUG
#define L_ASSERT(CONDITION) ((CONDITION) ? static_cast<void>(0) : LinphonePrivate::l_assert(#CONDITION, __FILE__, __LINE__))
#define L_ASSERT(CONDITION) ((CONDITION) ? static_cast<void>(0) : LinphonePrivate::lAssert(#CONDITION, __FILE__, __LINE__))
#else
#define L_ASSERT(CONDITION) static_cast<void>(false && (CONDITION))
#endif
......@@ -100,16 +104,26 @@ void l_assert (const char *condition, const char *file, int line);
// -----------------------------------------------------------------------------
// Define an integer version like: 0xXXYYZZ, XX=MAJOR, YY=MINOR, and ZZ=PATCH.
#define L_VERSION(MAJOR, MINOR, PATCH) (((MAJOR) << 16) | ((MINOR) << 8) | (PATCH))
constexpr unsigned int makeVersion (unsigned int major, unsigned int minor, unsigned int patch) {
return ((major << 16) | (minor << 8) | patch);
}
// Not available in C++11...
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args && ...args) {
std::unique_ptr<T> makeUnique(Args && ...args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
// -----------------------------------------------------------------------------
// Data access.
// Class tools.
// -----------------------------------------------------------------------------
#define L_DISABLE_COPY(CLASS) \
CLASS (const CLASS &) = delete; \
CLASS &operator= (const CLASS &) = delete;
// -----------------------------------------------------------------------------
// PImpl tools.
// -----------------------------------------------------------------------------
class BaseObject;
......@@ -119,34 +133,68 @@ class ClonableObjectPrivate;
class Object;
class ObjectPrivate;
namespace Private {
template<typename T>
using BetterPrivateAncestor = typename std::conditional<
std::is_base_of<BaseObject, T>::value,
BaseObject,
typename std::conditional<
std::is_base_of<ClonableObject, T>::value,
ClonableObject,
T
>::type
>::type;
// Generic public helper.
template<
typename R,
typename P,
typename C
>
constexpr R *getPublicHelper (P *object, const C *) {
return static_cast<R *>(object);
}
// Generic public helper. Deal with shared data.
template<
typename R,
typename P,
typename C
>
inline R *getPublicHelper (const P &objectSet, const C *) {
auto it = objectSet.cbegin();
L_ASSERT(it != objectSet.cend());
return static_cast<R *>(*it);
}
template<typename T, typename U>
struct AddConstMirror {
typedef U type;
};
template<typename T, typename U>
struct AddConstMirror<const T, U> {
typedef typename std::add_const<U>::type type;
};
}
#define L_INTERNAL_CHECK_OBJECT_INHERITANCE(CLASS) \
static_assert( \
!(std::is_base_of<BaseObject, CLASS>::value && std::is_base_of<ClonableObject, CLASS>::value), \
"Multiple inheritance between BaseObject and ClonableObject is not allowed." \
);
#define L_INTERNAL_GET_BETTER_PRIVATE_ANCESTOR(CLASS) \
std::conditional< \
std::is_base_of<BaseObject, CLASS>::value, \
BaseObject, \
std::conditional< \
std::is_base_of<ClonableObject, CLASS>::value, \
ClonableObject, \
CLASS \
>::type \
>::type
#define L_INTERNAL_DECLARE_PRIVATE(CLASS) \
inline CLASS ## Private *getPrivate () { \
L_INTERNAL_CHECK_OBJECT_INHERITANCE(CLASS); \
return reinterpret_cast<CLASS ## Private *>( \
L_INTERNAL_GET_BETTER_PRIVATE_ANCESTOR(CLASS)::mPrivate \
LinphonePrivate::Private::BetterPrivateAncestor<CLASS>::mPrivate \
); \
} \
inline const CLASS ## Private *getPrivate () const { \
L_INTERNAL_CHECK_OBJECT_INHERITANCE(CLASS); \
return reinterpret_cast<const CLASS ## Private *>( \
L_INTERNAL_GET_BETTER_PRIVATE_ANCESTOR(CLASS)::mPrivate \
LinphonePrivate::Private::BetterPrivateAncestor<CLASS>::mPrivate \
); \
} \
friend class CLASS ## Private; \
......@@ -162,61 +210,25 @@ class ObjectPrivate;
friend class Tester;
#endif
// Generic public helper.
template<
typename R,
typename P,
typename C
>
constexpr R *getPublicHelper (P *object, const C *) {
return static_cast<R *>(object);
}
// Generic public helper. Deal with shared data.
template<
typename R,
typename P,
typename C
>
inline R *getPublicHelper (const P &objectSet, const C *) {
auto it = objectSet.cbegin();
L_ASSERT(it != objectSet.cend());
return static_cast<R *>(*it);
}
#define L_DECLARE_PUBLIC(CLASS) \
inline CLASS *getPublic () { \
return getPublicHelper<CLASS>(mPublic, this); \
CLASS *getPublic () { \
return LinphonePrivate::Private::getPublicHelper<CLASS>(mPublic, this); \
} \
inline const CLASS *getPublic () const { \
return getPublicHelper<const CLASS>(mPublic, this); \
const CLASS *getPublic () const { \
return LinphonePrivate::Private::getPublicHelper<const CLASS>(mPublic, this); \
} \
friend class CLASS;
#define L_DISABLE_COPY(CLASS) \
CLASS (const CLASS &) = delete; \
CLASS &operator= (const CLASS &) = delete;
// Get Private data.
#define L_D() decltype(getPrivate()) const d = getPrivate();
// Get Public data.
#define L_Q() decltype(getPublic()) const q = getPublic();
template<typename T, typename U>
struct AddConstMirror {
typedef U type;
};
template<typename T, typename U>
struct AddConstMirror<const T, U> {
typedef typename std::add_const<U>::type type;
};
// Get Private data of class in a multiple inheritance case.
#define L_D_T(CLASS, NAME) \
auto const NAME = static_cast< \
AddConstMirror< \
LinphonePrivate::Private::AddConstMirror< \
std::remove_reference<decltype(*this)>::type, \
CLASS ## Private \
>::type * \
......@@ -225,12 +237,16 @@ struct AddConstMirror<const T, U> {
// Get Private data of class in a multiple inheritance case.
#define L_Q_T(CLASS, NAME) \
auto const NAME = static_cast< \
AddConstMirror< \
LinphonePrivate::Private::AddConstMirror< \
std::remove_reference<decltype(*this)>::type, \
CLASS \
>::type * \
>(getPublic());
// -----------------------------------------------------------------------------
// Overload.
// -----------------------------------------------------------------------------
#define L_OVERRIDE_SHARED_FROM_THIS(CLASS) \
inline std::shared_ptr<CLASS> getSharedFromThis () { \
return std::static_pointer_cast<CLASS>(Object::getSharedFromThis()); \
......@@ -239,10 +255,6 @@ struct AddConstMirror<const T, U> {
return std::static_pointer_cast<const CLASS>(Object::getSharedFromThis()); \
}
// -----------------------------------------------------------------------------
// Overload.
// -----------------------------------------------------------------------------
namespace Private {
template<typename... Args>
struct ResolveMemberFunctionOverload {
......@@ -273,7 +285,8 @@ namespace Private {
}
// Useful to select a specific overloaded function. (Avoid usage of static_cast.)
#define L_RESOLVE_OVERLOAD(ARGS) LinphonePrivate::Private::ResolveOverload<ARGS>
template<typename... Args>
using resolveOverload = Private::ResolveOverload<Args...>;
// -----------------------------------------------------------------------------
// Wrapper public.
......
......@@ -27,6 +27,7 @@
#include "call/call.h"
#include "call/local-conference-call.h"
#include "call/remote-conference-call.h"
#include "chat/chat-room/real-time-text-chat-room.h"
#include "conference/params/media-session-params-p.h"
#include "core/core-p.h"
......@@ -246,7 +247,7 @@ const char *linphone_call_get_to_header (const LinphoneCall *call, const char *n
}
char *linphone_call_get_remote_address_as_string (const LinphoneCall *call) {
return ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getRemoteAddressAsString().c_str());
return ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getRemoteAddress().asString().c_str());
}
const LinphoneAddress *linphone_call_get_diversion_address (const LinphoneCall *call) {
......@@ -538,16 +539,10 @@ bool_t linphone_call_echo_limiter_enabled (const LinphoneCall *call) {
}
LinphoneChatRoom *linphone_call_get_chat_room (LinphoneCall *call) {
#if 0
if (!call->chat_room){
if (call->state != LinphoneCallReleased && call->state != LinphoneCallEnd){
call->chat_room = _linphone_core_create_chat_room_from_call(call);
}
}
return call->chat_room;
#else
shared_ptr<LinphonePrivate::RealTimeTextChatRoom> acr = L_GET_PRIVATE_FROM_C_OBJECT(call)->getChatRoom();
if (acr)
return L_GET_C_BACK_PTR(acr);
return nullptr;
#endif
}
float linphone_call_get_play_volume (const LinphoneCall *call) {
......
......@@ -209,10 +209,6 @@ void linphone_chat_message_resend_2(LinphoneChatMessage *msg) {
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->send();
}
void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMessageState new_state) {
L_GET_CPP_PTR_FROM_C_OBJECT(msg)->updateState((LinphonePrivate::ChatMessage::State) new_state);
}
LinphoneStatus linphone_chat_message_put_char(LinphoneChatMessage *msg, uint32_t character) {
return ((LinphoneStatus)L_GET_CPP_PTR_FROM_C_OBJECT(msg)->putCharacter(character));
}
......
......@@ -41,6 +41,7 @@ struct _LinphoneChatRoomCbs {
LinphoneChatRoomCbsConferenceAddressGenerationCb conferenceAddressGenerationCb;
LinphoneChatRoomCbsParticipantDeviceFetchedCb participantDeviceFetchedCb;
LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb participantsCapabilitiesChecked;
LinphoneChatRoomCbsShouldChatMessageBeStoredCb shouldMessageBeStoredCb;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoomCbs);
......@@ -196,3 +197,11 @@ LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb linphone_chat_room_cbs_get_
void linphone_chat_room_cbs_set_participants_capabilities_checked (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb cb) {
cbs->participantsCapabilitiesChecked = cb;
}
LinphoneChatRoomCbsShouldChatMessageBeStoredCb linphone_chat_room_cbs_get_chat_message_should_be_stored( LinphoneChatRoomCbs *cbs) {
return cbs->shouldMessageBeStoredCb;
}
void linphone_chat_room_cbs_set_chat_message_should_be_stored( LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsShouldChatMessageBeStoredCb cb) {
cbs->shouldMessageBeStoredCb = cb;
}
......@@ -27,6 +27,7 @@
#include "address/identity-address.h"
#include "c-wrapper/c-wrapper.h"
#include "call/call.h"
#include "chat/chat-message/chat-message-p.h"
#include "chat/chat-room/basic-chat-room.h"
#include "chat/chat-room/client-group-chat-room-p.h"
......@@ -156,9 +157,9 @@ void linphone_chat_room_receive_chat_message (LinphoneChatRoom *cr, LinphoneChat
}
uint32_t linphone_chat_room_get_char (const LinphoneChatRoom *cr) {
if (linphone_core_realtime_text_enabled(linphone_chat_room_get_core(cr)))
return L_GET_CPP_PTR_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->getChar();
return 0;
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
return 0;
return L_GET_CPP_PTR_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->getChar();
}
void linphone_chat_room_compose (LinphoneChatRoom *cr) {
......@@ -166,14 +167,15 @@ void linphone_chat_room_compose (LinphoneChatRoom *cr) {
}
LinphoneCall *linphone_chat_room_get_call (const LinphoneChatRoom *cr) {
if (linphone_core_realtime_text_enabled(linphone_chat_room_get_core(cr)))
return L_GET_CPP_PTR_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->getCall();
return nullptr;
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
return nullptr;
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->getCall());
}
void linphone_chat_room_set_call (LinphoneChatRoom *cr, LinphoneCall *call) {
if (linphone_core_realtime_text_enabled(linphone_chat_room_get_core(cr)))
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->call = call;
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
return;
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->call = L_GET_CPP_PTR_FROM_C_OBJECT(call);
}
void linphone_chat_room_mark_as_read (LinphoneChatRoom *cr) {
......@@ -202,9 +204,8 @@ void linphone_chat_room_delete_history (LinphoneChatRoom *cr) {
bctbx_list_t *linphone_chat_room_get_history_range (LinphoneChatRoom *cr, int startm, int endm) {
list<shared_ptr<LinphonePrivate::ChatMessage>> chatMessages;
for (auto &event : L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistoryRange(startm, endm))
if (event->getType() == LinphonePrivate::EventLog::Type::ConferenceChatMessage)
chatMessages.push_back(static_pointer_cast<LinphonePrivate::ConferenceChatMessageEvent>(event)->getChatMessage());
for (auto &event : L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMessageHistoryRange(startm, endm))
chatMessages.push_back(static_pointer_cast<LinphonePrivate::ConferenceChatMessageEvent>(event)->getChatMessage());
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(chatMessages);
}
......@@ -213,6 +214,14 @@ bctbx_list_t *linphone_chat_room_get_history (LinphoneChatRoom *cr, int nb_messa
return linphone_chat_room_get_history_range(cr, 0, nb_message);
}
bctbx_list_t *linphone_chat_room_get_history_range_message_events (LinphoneChatRoom *cr, int startm, int endm) {
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMessageHistoryRange(startm, endm));
}
bctbx_list_t *linphone_chat_room_get_history_message_events (LinphoneChatRoom *cr, int nb_events) {
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getMessageHistory(nb_events));
}
bctbx_list_t *linphone_chat_room_get_history_events (LinphoneChatRoom *cr, int nb_events) {
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getHistory(nb_events));
}
......@@ -251,6 +260,10 @@ bool_t linphone_chat_room_has_been_left (const LinphoneChatRoom *cr) {
return (bool_t)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->hasBeenLeft();
}
time_t linphone_chat_room_get_last_update_time(const LinphoneChatRoom *cr) {
return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastUpdateTime();
}
void linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr) {
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->addParticipant(
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr)), nullptr, false
......
......@@ -338,7 +338,7 @@ public:
typename = typename std::enable_if<IsDefinedBaseCppObject<CppType>::value, CppType>::type
>
static inline std::shared_ptr<const CppType> getCppPtrFromC (const CType *cObject) {
return getCppPtrFromC<CType, CppType>(const_cast<CType *>(cObject));
return getCppPtrFromC<typename std::remove_const<CType>::type, CppType>(const_cast<CType *>(cObject));
}
template<
......
......@@ -34,6 +34,7 @@
LINPHONE_BEGIN_NAMESPACE
class CallSession;
class RealTimeTextChatRoom;
class CallPrivate : public ObjectPrivate, public CallSessionListener {
public:
......@@ -50,6 +51,7 @@ public:
virtual std::shared_ptr<CallSession> getActiveSession () const { return nullptr; }
bool getAudioMuted () const;
std::shared_ptr<RealTimeTextChatRoom> getChatRoom ();
LinphoneProxyConfig *getDestProxy () const;
IceSession *getIceSession () const;
......@@ -72,43 +74,44 @@ private:
void terminateBecauseOfLostMedia ();
/* CallSessionListener */
void onAckBeingSent (const std::shared_ptr<const CallSession> &session, LinphoneHeaders *headers) override;
void onAckReceived (const std::shared_ptr<const CallSession> &session, LinphoneHeaders *headers) override;
void onBackgroundTaskToBeStarted (const std::shared_ptr<const CallSession> &session) override;
void onBackgroundTaskToBeStopped (const std::shared_ptr<const CallSession> &session) override;
bool onCallSessionAccepted (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionConferenceStreamStarting (const std::shared_ptr<const CallSession> &session, bool mute) override;
void onCallSessionConferenceStreamStopping (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionEarlyFailed (const std::shared_ptr<const CallSession> &session, LinphoneErrorInfo *ei) override;
void onCallSessionSetReleased (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionSetTerminated (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionStartReferred (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, CallSession::State state, const std::string &message) override;
void onCallSessionTransferStateChanged (const std::shared_ptr<const CallSession> &session, CallSession::State state) override;
void onCheckForAcceptation (const std::shared_ptr<const CallSession> &session) override;
void onDtmfReceived (const std::shared_ptr<const CallSession> &session, char dtmf) override;
void onIncomingCallSessionNotified (const std::shared_ptr<const CallSession> &session) override;
void onIncomingCallSessionStarted (const std::shared_ptr<const CallSession> &session) override;
void onIncomingCallSessionTimeoutCheck (const std::shared_ptr<const CallSession> &session, int elapsed, bool oneSecondElapsed) override;
void onInfoReceived (const std::shared_ptr<const CallSession> &session, const LinphoneInfoMessage *im) override;
void onNoMediaTimeoutCheck (const std::shared_ptr<const CallSession> &session, bool oneSecondElapsed) override;
void onEncryptionChanged (const std::shared_ptr<const CallSession> &session, bool activated, const std::string &authToken) override;
void onCallSessionStateChangedForReporting (const std::shared_ptr<const CallSession> &session) override;
void onRtcpUpdateForReporting (const std::shared_ptr<const CallSession> &session, SalStreamType type) override;
void onStatsUpdated (const std::shared_ptr<const CallSession> &session, const LinphoneCallStats *stats) override;
void onUpdateMediaInfoForReporting (const std::shared_ptr<const CallSession> &session, int statsType) override;
void onResetCurrentSession (const std::shared_ptr<const CallSession> &session) override;
void onSetCurrentSession (const std::shared_ptr<const CallSession> &session) override;
void onFirstVideoFrameDecoded (const std::shared_ptr<const CallSession> &session) override;
void onResetFirstVideoFrameDecoded (const std::shared_ptr<const CallSession> &session) override;
void onPlayErrorTone (const std::shared_ptr<const CallSession> &session, LinphoneReason reason) override;
void onRingbackToneRequested (const std::shared_ptr<const CallSession> &session, bool requested) override;
void onStartRinging (const std::shared_ptr<const CallSession> &session) override;
void onStopRinging (const std::shared_ptr<const CallSession> &session) override;
void onStopRingingIfInCall (const std::shared_ptr<const CallSession> &session) override;
void onStopRingingIfNeeded (const std::shared_ptr<const CallSession> &session) override;
bool areSoundResourcesAvailable (const std::shared_ptr<const CallSession> &session) override;
bool isPlayingRingbackTone (const std::shared_ptr<const CallSession> &session) override;
void onAckBeingSent (const std::shared_ptr<CallSession> &session, LinphoneHeaders *headers) override;
void onAckReceived (const std::shared_ptr<CallSession> &session, LinphoneHeaders *headers) override;
void onBackgroundTaskToBeStarted (const std::shared_ptr<CallSession> &session) override;
void onBackgroundTaskToBeStopped (const std::shared_ptr<CallSession> &session) override;
bool onCallSessionAccepted (const std::shared_ptr<CallSession> &session) override;
void onCallSessionConferenceStreamStarting (const std::shared_ptr<CallSession> &session, bool mute) override;
void onCallSessionConferenceStreamStopping (const std::shared_ptr<CallSession> &session) override;
void onCallSessionEarlyFailed (const std::shared_ptr<CallSession> &session, LinphoneErrorInfo *ei) override;
void onCallSessionSetReleased (const std::shared_ptr<CallSession> &session) override;
void onCallSessionSetTerminated (const std::shared_ptr<CallSession> &session) override;
void onCallSessionStartReferred (const std::shared_ptr<CallSession> &session) override;
void onCallSessionStateChanged (const std::shared_ptr<CallSession> &session, CallSession::State state, const std::string &message) override;
void onCallSessionTransferStateChanged (const std::shared_ptr<CallSession> &session, CallSession::State state) override;
void onCheckForAcceptation (const std::shared_ptr<CallSession> &session) override;
void onDtmfReceived (const std::shared_ptr<CallSession> &session, char dtmf) override;
void onIncomingCallSessionNotified (const std::shared_ptr<CallSession> &session) override;
void onIncomingCallSessionStarted (const std::shared_ptr<CallSession> &session) override;
void onIncomingCallSessionTimeoutCheck (const std::shared_ptr<CallSession> &session, int elapsed, bool oneSecondElapsed) override;
void onInfoReceived (const std::shared_ptr<CallSession> &session, const LinphoneInfoMessage *im) override;
void onNoMediaTimeoutCheck (const std::shared_ptr<CallSession> &session, bool oneSecondElapsed) override;
void onEncryptionChanged (const std::shared_ptr<CallSession> &session, bool activated, const std::string &authToken) override;
void onCallSessionStateChangedForReporting (const std::shared_ptr<CallSession> &session) override;
void onRtcpUpdateForReporting (const std::shared_ptr<CallSession> &session, SalStreamType type) override;
void onStatsUpdated (const std::shared_ptr<CallSession> &session, const LinphoneCallStats *stats) override;
void onUpdateMediaInfoForReporting (const std::shared_ptr<CallSession> &session, int statsType) override;
void onResetCurrentSession (const std::shared_ptr<CallSession> &session) override;
void onSetCurrentSession (const std::shared_ptr<CallSession> &session) override;
void onFirstVideoFrameDecoded (const std::shared_ptr<CallSession> &session) override;
void onResetFirstVideoFrameDecoded (const std::shared_ptr<CallSession> &session) override;
void onPlayErrorTone (const std::shared_ptr<CallSession> &session, LinphoneReason reason) override;
void onRingbackToneRequested (const std::shared_ptr<CallSession> &session, bool requested) override;
void onStartRinging (const std::shared_ptr<CallSession> &session) override;