Commit be1d6f99 authored by Ronan's avatar Ronan
Browse files

feat(Event): events are now shared

parent 4bfbe3d9
......@@ -18,7 +18,6 @@
*/
#include "linphone/api/c-dial-plan.h"
#include "linphone/wrapper_utils.h"
#include "c-wrapper/c-wrapper.h"
#include "dial-plan/dial-plan.h"
......@@ -29,61 +28,61 @@ using namespace std;
L_DECLARE_C_OBJECT_IMPL(DialPlan);
LinphoneDialPlan *linphone_dial_plan_ref(LinphoneDialPlan *dp) {
return (LinphoneDialPlan *)belle_sip_object_ref(dp);
LinphoneDialPlan *linphone_dial_plan_ref (LinphoneDialPlan *dp) {
return reinterpret_cast<LinphoneDialPlan *>(belle_sip_object_ref(dp));
}
void linphone_dial_plan_unref(LinphoneDialPlan *dp) {
void linphone_dial_plan_unref (LinphoneDialPlan *dp) {
belle_sip_object_unref(dp);
}
const char * linphone_dial_plan_get_country(const LinphoneDialPlan *dp) {
const char *linphone_dial_plan_get_country (const LinphoneDialPlan *dp) {
return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getCountry());
}
const char * linphone_dial_plan_get_iso_country_code(const LinphoneDialPlan *dp) {
const char *linphone_dial_plan_get_iso_country_code (const LinphoneDialPlan *dp) {
return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getIsoCountryCode());
}
const char * linphone_dial_plan_get_country_calling_code(const LinphoneDialPlan *dp) {
const char *linphone_dial_plan_get_country_calling_code (const LinphoneDialPlan *dp) {
return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getCountryCallingCode());
}
int linphone_dial_plan_get_national_number_length(const LinphoneDialPlan *dp) {
int linphone_dial_plan_get_national_number_length (const LinphoneDialPlan *dp) {
return L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getNationalNumberLength();
}
const char * linphone_dial_plan_get_international_call_prefix(const LinphoneDialPlan *dp) {
const char *linphone_dial_plan_get_international_call_prefix (const LinphoneDialPlan *dp) {
return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getInternationalCallPrefix());
}
int linphone_dial_plan_lookup_ccc_from_e164(const char* e164) {
return LinphonePrivate::DialPlan::lookupCccFromE164(L_C_TO_STRING(e164));
int linphone_dial_plan_lookup_ccc_from_e164 (const char *e164) {
return LinphonePrivate::DialPlan::lookupCccFromE164(L_C_TO_STRING(e164));
}
int linphone_dial_plan_lookup_ccc_from_iso(const char* iso) {
int linphone_dial_plan_lookup_ccc_from_iso (const char *iso) {
return LinphonePrivate::DialPlan::lookupCccFromIso(L_C_TO_STRING(iso));
}
const LinphoneDialPlan* linphone_dial_plan_by_ccc_as_int(int ccc) {
const LinphonePrivate::DialPlan& dp = LinphonePrivate::DialPlan::findByCccAsInt(ccc);
const LinphoneDialPlan *linphone_dial_plan_by_ccc_as_int (int ccc) {
const LinphonePrivate::DialPlan &dp = LinphonePrivate::DialPlan::findByCccAsInt(ccc);
return L_GET_C_BACK_PTR(&dp);
}
const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc) {
const LinphonePrivate::DialPlan& dp = LinphonePrivate::DialPlan::findByCcc(L_C_TO_STRING(ccc));
const LinphoneDialPlan *linphone_dial_plan_by_ccc (const char *ccc) {
const LinphonePrivate::DialPlan &dp = LinphonePrivate::DialPlan::findByCcc(L_C_TO_STRING(ccc));
return L_GET_C_BACK_PTR(&dp);
}
const LinphoneDialPlan* linphone_dial_plan_get_all() {
return NULL;
const LinphoneDialPlan *linphone_dial_plan_get_all () {
return nullptr;
}
const bctbx_list_t * linphone_dial_plan_get_all_list() {
const list<LinphonePrivate::DialPlan>& dps = LinphonePrivate::DialPlan::getAllDialPlans();
const bctbx_list_t *linphone_dial_plan_get_all_list () {
const list<LinphonePrivate::DialPlan> &dps = LinphonePrivate::DialPlan::getAllDialPlans();
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(dps);
}
bool_t linphone_dial_plan_is_generic(const LinphoneDialPlan *ccc) {
bool_t linphone_dial_plan_is_generic (const LinphoneDialPlan *ccc) {
return L_GET_CPP_PTR_FROM_C_OBJECT(ccc)->isGeneric();
}
......@@ -27,13 +27,13 @@
// =============================================================================
L_DECLARE_C_BASE_OBJECT_IMPL(CallEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceChatMessageEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceParticipantDeviceEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceParticipantEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(ConferenceSubjectEvent);
L_DECLARE_C_BASE_OBJECT_IMPL(EventLog);
L_DECLARE_C_OBJECT_IMPL(CallEvent);
L_DECLARE_C_OBJECT_IMPL(ConferenceChatMessageEvent);
L_DECLARE_C_OBJECT_IMPL(ConferenceEvent);
L_DECLARE_C_OBJECT_IMPL(ConferenceParticipantDeviceEvent);
L_DECLARE_C_OBJECT_IMPL(ConferenceParticipantEvent);
L_DECLARE_C_OBJECT_IMPL(ConferenceSubjectEvent);
L_DECLARE_C_OBJECT_IMPL(EventLog);
using namespace std;
......@@ -43,7 +43,7 @@ using namespace std;
LinphoneEventLog *linphone_event_log_new () {
LinphoneEventLog *event_log = _linphone_EventLog_init();
L_SET_CPP_PTR_FROM_C_OBJECT(event_log, new LinphonePrivate::EventLog());
L_SET_CPP_PTR_FROM_C_OBJECT(event_log, make_shared<LinphonePrivate::EventLog>());
return event_log;
}
......@@ -66,7 +66,7 @@ LinphoneCallEvent *linphone_call_event_new (LinphoneEventLogType type, time_t ti
LinphoneCallEvent *call_event = _linphone_CallEvent_init();
L_SET_CPP_PTR_FROM_C_OBJECT(
call_event,
new LinphonePrivate::CallEvent(
make_shared<LinphonePrivate::CallEvent>(
static_cast<LinphonePrivate::EventLog::Type>(type),
time,
L_GET_CPP_PTR_FROM_C_OBJECT(call)
......@@ -128,7 +128,7 @@ LinphoneConferenceChatMessageEvent *linphone_chat_message_event_new (LinphoneCha
LinphoneConferenceChatMessageEvent *chat_message_event = _linphone_ConferenceChatMessageEvent_init();
L_SET_CPP_PTR_FROM_C_OBJECT(
chat_message_event,
new LinphonePrivate::ConferenceChatMessageEvent(
make_shared<LinphonePrivate::ConferenceChatMessageEvent>(
time,
L_GET_CPP_PTR_FROM_C_OBJECT(chat_message)
)
......
......@@ -99,16 +99,14 @@ private:
template<typename CppType>
struct IsDefinedBaseCppObject {
enum {
value = IsRegisteredCppObject<CppType>::value &&
std::is_base_of<BaseObject, CppType>::value &&
!std::is_base_of<Object, CppType>::value
value = IsRegisteredCppObject<CppType>::value && std::is_base_of<BaseObject, CppType>::value
};
};
template<typename CppType>
struct IsDefinedCppObject {
enum {
value = IsRegisteredCppObject<CppType>::value && std::is_base_of<Object, CppType>::value
value = IsDefinedBaseCppObject<CppType>::value && std::is_base_of<Object, CppType>::value
};
};
......@@ -125,12 +123,6 @@ private:
template<typename CppType>
struct WrappedBaseObject {
belle_sip_object_t base;
CppType *cppPtr;
};
template<typename CppType>
struct WrappedObject {
belle_sip_object_t base;
std::shared_ptr<CppType> cppPtr;
};
......@@ -141,23 +133,6 @@ private:
CppType *cppPtr;
};
template<typename CppType>
struct WrappedObjectResolver {
typedef typename std::conditional<
IsDefinedBaseCppObject<CppType>::value,
WrappedBaseObject<CppType>,
typename std::conditional<
IsDefinedCppObject<CppType>::value,
WrappedObject<CppType>,
typename std::conditional<
IsDefinedClonableCppObject<CppType>::value,
WrappedClonableObject<CppType>,
void
>::type
>::type
>::type type;
};
// ---------------------------------------------------------------------------
// Runtime checker.
// ---------------------------------------------------------------------------
......@@ -210,14 +185,14 @@ public:
template<
typename CType,
typename CppType = typename CTypeMetaInfo<CType>::cppType,
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
typename = typename std::enable_if<IsDefinedBaseCppObject<CppType>::value, CppType>::type
>
static L_INTERNAL_WRAPPER_CONSTEXPR std::shared_ptr<CppType> getCppPtrFromC (CType *cObject) {
#ifdef DEBUG
typedef typename CTypeMetaInfo<CType>::cppType BaseType;
typedef CppType DerivedType;
std::shared_ptr<BaseType> cppObject = reinterpret_cast<WrappedObject<BaseType> *>(cObject)->cppPtr;
std::shared_ptr<BaseType> cppObject = reinterpret_cast<WrappedBaseObject<BaseType> *>(cObject)->cppPtr;
if (!cppObject)
abort("Cpp Object is null.");
......@@ -227,36 +202,34 @@ public:
return derivedCppObject;
#else
return reinterpret_cast<WrappedObject<CppType> *>(cObject)->cppPtr;
return reinterpret_cast<WrappedBaseObject<CppType> *>(cObject)->cppPtr;
#endif
}
template<
typename CType,
typename CppType = typename CTypeMetaInfo<CType>::cppType,
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
typename = typename std::enable_if<IsDefinedBaseCppObject<CppType>::value, CppType>::type
>
static L_INTERNAL_WRAPPER_CONSTEXPR std::shared_ptr<const CppType> getCppPtrFromC (const CType *cObject) {
#ifdef DEBUG
return getCppPtrFromC<CType, CppType>(const_cast<CType *>(cObject));
#else
return reinterpret_cast<const typename WrappedObjectResolver<CppType>::type *>(cObject)->cppPtr;
return reinterpret_cast<const WrappedBaseObject<CppType> *>(cObject)->cppPtr;
#endif
}
template<
typename CType,
typename CppType = typename CTypeMetaInfo<CType>::cppType,
typename = typename std::enable_if<
IsDefinedBaseCppObject<CppType>::value || IsDefinedClonableCppObject<CppType>::value, CppType
>::type
typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type
>
static L_INTERNAL_WRAPPER_CONSTEXPR CppType *getCppPtrFromC (CType *cObject) {
#ifdef DEBUG
typedef typename CTypeMetaInfo<CType>::cppType BaseType;
typedef CppType DerivedType;
BaseType *cppObject = reinterpret_cast<typename WrappedObjectResolver<BaseType>::type *>(cObject)->cppPtr;
BaseType *cppObject = reinterpret_cast<WrappedClonableObject<BaseType> *>(cObject)->cppPtr;
if (!cppObject)
abort("Cpp Object is null.");
......@@ -266,22 +239,20 @@ public:
return derivedCppObject;
#else
return reinterpret_cast<typename WrappedObjectResolver<CppType>::type *>(cObject)->cppPtr;
return reinterpret_cast<WrappedClonableObject<CppType> *>(cObject)->cppPtr;
#endif
}
template<
typename CType,
typename CppType = typename CTypeMetaInfo<CType>::cppType,
typename = typename std::enable_if<
IsDefinedBaseCppObject<CppType>::value || IsDefinedClonableCppObject<CppType>::value, CppType
>::type
typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type
>
static L_INTERNAL_WRAPPER_CONSTEXPR const CppType *getCppPtrFromC (const CType *cObject) {
#ifdef DEBUG
return getCppPtrFromC(const_cast<CType *>(cObject));
#else
return reinterpret_cast<const typename WrappedObjectResolver<CppType>::type *>(cObject)->cppPtr;
return reinterpret_cast<const WrappedClonableObject<CppType> *>(cObject)->cppPtr;
#endif
}
......@@ -292,22 +263,20 @@ public:
template<
typename CType,
typename CppType = typename CTypeMetaInfo<CType>::cppType,
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
typename = typename std::enable_if<IsDefinedBaseCppObject<CppType>::value, CppType>::type
>
static inline void setCppPtrFromC (CType *cObject, const std::shared_ptr<CppType> &cppObject) {
reinterpret_cast<WrappedObject<CppType> *>(cObject)->cppPtr = cppObject;
reinterpret_cast<WrappedBaseObject<CppType> *>(cObject)->cppPtr = cppObject;
cppObject->setCBackPtr(cObject);
}
template<
typename CType,
typename CppType = typename CTypeMetaInfo<CType>::cppType,
typename = typename std::enable_if<
IsDefinedBaseCppObject<CppType>::value || IsDefinedClonableCppObject<CppType>::value, CppType
>::type
typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type
>
static inline void setCppPtrFromC (CType *cObject, CppType* &&cppObject) {
CppType **cppObjectAddr = &reinterpret_cast<typename WrappedObjectResolver<CppType>::type *>(cObject)->cppPtr;
CppType **cppObjectAddr = &reinterpret_cast<WrappedClonableObject<CppType> *>(cObject)->cppPtr;
if (*cppObjectAddr == cppObject)
return;
delete *cppObjectAddr;
......@@ -322,13 +291,7 @@ public:
typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type
>
static inline void setCppPtrFromC (CType *cObject, const CppType *cppObject) {
CppType **cppObjectAddr = &reinterpret_cast<WrappedClonableObject<CppType> *>(cObject)->cppPtr;
if (*cppObjectAddr == cppObject)
return;
delete *cppObjectAddr;
*cppObjectAddr = new CppType(*cppObject);
(*cppObjectAddr)->setCBackPtr(cObject);
setCppPtrFromC(cObject, new CppType(*cppObject));
}
// ---------------------------------------------------------------------------
......@@ -337,17 +300,7 @@ public:
template<
typename CppType,
typename = typename std::enable_if<IsDefinedBaseCppObject<CppType>::value>::type
>
static inline CppType * &&getResolvedCppPtr (const CppType *cppObject) {
// Exists only for `getCBackPtr` impl.
abort("Cannot get resolved cpp ptr from BaseObject.");
return std::move(const_cast<CppType *>(cppObject));
}
template<
typename CppType,
typename = typename std::enable_if<IsDefinedCppObject<CppType>::value, CppType>::type
typename = typename std::enable_if<IsDefinedBaseCppObject<CppType>::value, CppType>::type
>
static inline std::shared_ptr<CppType> getResolvedCppPtr (const CppType *cppObject) {
if (L_UNLIKELY(!cppObject))
......@@ -377,7 +330,9 @@ public:
template<
typename CppType,
typename = typename std::enable_if<IsRegisteredCppObject<CppType>::value, CppType>::type
typename = typename std::enable_if<
IsDefinedCppObject<CppType>::value || IsDefinedClonableCppObject<CppType>::value, CppType
>::type
>
static inline typename CppTypeMetaInfo<CppType>::cType *getCBackPtr (const CppType *cppObject) {
if (L_UNLIKELY(!cppObject))
......@@ -386,7 +341,7 @@ public:
typedef typename CppTypeMetaInfo<CppType>::cType RetType;
void *value = cppObject->getCBackPtr();
if (value || IsDefinedBaseCppObject<CppType>::value)
if (value)
return static_cast<RetType *>(value);
RetType *cObject = CppTypeMetaInfo<CppType>::init();
......@@ -397,6 +352,27 @@ public:
return cObject;
}
template<
typename CppType,
typename = typename std::enable_if<IsDefinedBaseCppObject<CppType>::value, CppType>::type
>
static inline typename CppTypeMetaInfo<CppType>::cType *getCBackPtr (const std::shared_ptr<CppType> &cppObject) {
if (L_UNLIKELY(!cppObject))
return nullptr;
typedef typename CppTypeMetaInfo<CppType>::cType RetType;
void *value = cppObject->getCBackPtr();
if (value)
return static_cast<RetType *>(value);
RetType *cObject = CppTypeMetaInfo<CppType>::init();
setCppPtrFromC(cObject, cppObject);
return cObject;
}
// ---------------------------------------------------------------------------
// Get/set user data.
// ---------------------------------------------------------------------------
......@@ -442,7 +418,7 @@ public:
static inline bctbx_list_t *getResolvedCListFromCppList (const std::list<std::shared_ptr<CppType>> &cppList) {
bctbx_list_t *result = nullptr;
for (const auto &value : cppList) {
result = bctbx_list_append(result, belle_sip_object_ref(getCBackPtr(value.get())));
result = bctbx_list_append(result, belle_sip_object_ref(getCBackPtr(value)));
}
return result;
}
......@@ -573,30 +549,6 @@ LINPHONE_END_NAMESPACE
// C object declaration.
// -----------------------------------------------------------------------------
// Declare base wrapped C object.
#define L_DECLARE_C_BASE_OBJECT_IMPL(C_TYPE, ...) \
static_assert(LinphonePrivate::CTypeMetaInfo<Linphone ## C_TYPE>::defined, "Type is not defined."); \
struct _Linphone ## C_TYPE { \
belle_sip_object_t base; \
L_CPP_TYPE_OF_C_TYPE(C_TYPE) *cppPtr; \
__VA_ARGS__ \
}; \
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## C_TYPE); \
Linphone ## C_TYPE *_linphone_ ## C_TYPE ## _init() { \
return belle_sip_object_new(Linphone ## C_TYPE); \
} \
static void _linphone_ ## C_TYPE ## _uninit(Linphone ## C_TYPE * object) { \
delete object->cppPtr; \
} \
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(Linphone ## C_TYPE); \
BELLE_SIP_INSTANCIATE_VPTR( \
Linphone ## C_TYPE, belle_sip_object_t, \
_linphone_ ## C_TYPE ## _uninit, \
NULL, \
NULL, \
FALSE \
);
// Declare wrapped C object with constructor/destructor.
#define L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(C_TYPE, CONSTRUCTOR, DESTRUCTOR, ...) \
struct _Linphone ## C_TYPE { \
......@@ -700,7 +652,7 @@ LINPHONE_END_NAMESPACE
// Get the wrapped C object of a C++ object.
#define L_GET_C_BACK_PTR(CPP_OBJECT) \
LinphonePrivate::Wrapper::getCBackPtr(LinphonePrivate::Utils::getPtr(CPP_OBJECT))
LinphonePrivate::Wrapper::getCBackPtr(CPP_OBJECT)
// Get/set user data on a wrapped C object.
#define L_GET_USER_DATA_FROM_C_OBJECT(C_OBJECT) \
......
......@@ -276,7 +276,7 @@ void ClientGroupChatRoom::onParticipantAdded (time_t tm, const Address &addr) {
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);
const ConferenceParticipantEvent event(
shared_ptr<ConferenceParticipantEvent> event = make_shared<ConferenceParticipantEvent>(
EventLog::Type::ConferenceParticipantAdded,
tm,
dConference->conferenceAddress,
......@@ -286,7 +286,7 @@ void ClientGroupChatRoom::onParticipantAdded (time_t tm, const Address &addr) {
Conference::getCore()->cppCore.getPrivate()->mainDb.addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(&event));
cb(cr, L_GET_C_BACK_PTR(event));
}
void ClientGroupChatRoom::onParticipantRemoved (time_t tm, const Address &addr) {
......@@ -301,7 +301,7 @@ void ClientGroupChatRoom::onParticipantRemoved (time_t tm, const Address &addr)
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);
const ConferenceParticipantEvent event(
shared_ptr<ConferenceParticipantEvent> event = make_shared<ConferenceParticipantEvent>(
EventLog::Type::ConferenceParticipantRemoved,
tm,
dConference->conferenceAddress,
......@@ -311,7 +311,7 @@ void ClientGroupChatRoom::onParticipantRemoved (time_t tm, const Address &addr)
Conference::getCore()->cppCore.getPrivate()->mainDb.addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(&event));
cb(cr, L_GET_C_BACK_PTR(event));
dConference->participants.remove(participant);
}
......@@ -332,7 +332,7 @@ void ClientGroupChatRoom::onParticipantSetAdmin (time_t tm, const Address &addr,
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);
const ConferenceParticipantEvent event(
shared_ptr<ConferenceParticipantEvent> event = make_shared<ConferenceParticipantEvent>(
isAdmin ? EventLog::Type::ConferenceParticipantSetAdmin : EventLog::Type::ConferenceParticipantUnsetAdmin,
tm,
dConference->conferenceAddress,
......@@ -342,7 +342,7 @@ void ClientGroupChatRoom::onParticipantSetAdmin (time_t tm, const Address &addr,
Conference::getCore()->cppCore.getPrivate()->mainDb.addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(&event));
cb(cr, L_GET_C_BACK_PTR(event));
}
void ClientGroupChatRoom::onSubjectChanged (time_t tm, const std::string &subject) {
......@@ -351,7 +351,7 @@ void ClientGroupChatRoom::onSubjectChanged (time_t tm, const std::string &subjec
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);
const ConferenceSubjectEvent event(
shared_ptr<ConferenceSubjectEvent> event = make_shared<ConferenceSubjectEvent>(
tm,
dConference->conferenceAddress,
dConference->eventHandler->getLastNotify(),
......@@ -360,7 +360,7 @@ void ClientGroupChatRoom::onSubjectChanged (time_t tm, const std::string &subjec
Conference::getCore()->cppCore.getPrivate()->mainDb.addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(&event));
cb(cr, L_GET_C_BACK_PTR(event));
}
void ClientGroupChatRoom::onParticipantDeviceAdded (time_t tm, const Address &addr, const Address &gruu) {
......@@ -378,7 +378,7 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (time_t tm, const Address &ad
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);
const ConferenceParticipantDeviceEvent event(
shared_ptr<ConferenceParticipantDeviceEvent> event = make_shared<ConferenceParticipantDeviceEvent>(
EventLog::Type::ConferenceParticipantDeviceAdded,
tm,
dConference->conferenceAddress,
......@@ -389,7 +389,7 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (time_t tm, const Address &ad
Conference::getCore()->cppCore.getPrivate()->mainDb.addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(&event));
cb(cr, L_GET_C_BACK_PTR(event));
}
void ClientGroupChatRoom::onParticipantDeviceRemoved (time_t tm, const Address &addr, const Address &gruu) {
......@@ -407,7 +407,7 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (time_t tm, const Address &
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);
const ConferenceParticipantDeviceEvent event(
shared_ptr<ConferenceParticipantDeviceEvent> event = make_shared<ConferenceParticipantDeviceEvent>(
EventLog::Type::ConferenceParticipantDeviceRemoved,
tm,
dConference->conferenceAddress,
......@@ -418,7 +418,7 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (time_t tm, const Address &
Conference::getCore()->cppCore.getPrivate()->mainDb.addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(&event));
cb(cr, L_GET_C_BACK_PTR(event));
}
// -----------------------------------------------------------------------------
......
......@@ -99,14 +99,14 @@ private:
const std::string &peerAddress
) const;
long long insertEvent (const EventLog &eventLog);
long long insertConferenceEvent (const EventLog &eventLog, long long *chatRoomId = nullptr);
long long insertConferenceCallEvent (const EventLog &eventLog);
long long insertConferenceChatMessageEvent (const EventLog &eventLog);
long long insertConferenceNotifiedEvent (const EventLog &eventLog);
long long insertConferenceParticipantEvent (const EventLog &eventLog);
long long insertConferenceParticipantDeviceEvent (const EventLog &eventLog);
long long insertConferenceSubjectEvent (const EventLog &eventLog);
long long insertEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceEvent (const std::shared_ptr<EventLog> &eventLog, long long *chatRoomId = nullptr);
long long insertConferenceCallEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceChatMessageEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceNotifiedEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceParticipantEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceParticipantDeviceEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceSubjectEvent (const std::shared_ptr<EventLog> &eventLog);
L_DECLARE_PUBLIC(MainDb);
};
......
......@@ -366,19 +366,19 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
// -----------------------------------------------------------------------------
long long MainDbPrivate::insertEvent (const EventLog &eventLog) {
long long MainDbPrivate::insertEvent (const shared_ptr<EventLog> &eventLog) {
L_Q();
soci::session *session = dbSession.getBackendSession<soci::session>();
*session << "INSERT INTO event (type, date) VALUES (:type, :date)",
soci::use(static_cast<int>(eventLog.getType())), soci::use(Utils::getLongAsTm(eventLog.getTime()));
soci::use(static_cast<int>(eventLog->getType())), soci::use(Utils::getLongAsTm(eventLog->getTime()));
return q->getLastInsertId();
}
long long MainDbPrivate::insertConferenceEvent (const EventLog &eventLog, long long *chatRoomId) {
long long MainDbPrivate::insertConferenceEvent (const shared_ptr<EventLog> &eventLog, long long *chatRoomId) {
long long eventId = insertEvent(eventLog);
long long curChatRoomId = insertSipAddress(
static_cast<const ConferenceEvent &>(eventLog).getConferenceAddress().asString()
static_pointer_cast<ConferenceEvent>(eventLog)->getConferenceAddress().asString()
);
soci::session *session = dbSession.getBackendSession<soci::session>();
......@@ -391,20 +391,20 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
return eventId;
}
long long MainDbPrivate::insertConferenceCallEvent (const EventLog &eventLog) {
long long MainDbPrivate::insertConferenceCallEvent (const shared_ptr<EventLog> &eventLog) {
// TODO.
return 0;
}
long long MainDbPrivate::insertConferenceChatMessageEvent (const EventLog &eventLog) {
shared_ptr<ChatMessage> chatMessage = static_cast<const ConferenceChatMessageEvent &>(eventLog).getChatMessage();
long long MainDbPrivate::insertConferenceChatMessageEvent (const shared_ptr<EventLog> &eventLog) {
shared_ptr<ChatMessage> chatMessage = static_pointer_cast<ConferenceChatMessageEvent>(eventLog)->getChatMessage();
shared_ptr<ChatRoom> chatRoom = chatMessage->getChatRoom();
if (!chatRoom) {
lError() << "Unable to get a valid chat room. It was removed from database.";
return -1;