From 79001f54d07b70e20e037a3b4ee0409f72479379 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Oct 2017 11:05:33 +0200 Subject: [PATCH] feat(EventLog): wrap only one C object --- include/linphone/api/c-callbacks.h | 12 +- include/linphone/api/c-event-log.h | 212 +-------------- include/linphone/api/c-types.h | 42 --- src/c-wrapper/api/c-event-log.cpp | 405 +++++++++++------------------ src/c-wrapper/c-wrapper.h | 16 +- src/core/core.h | 5 +- src/db/main-db.cpp | 2 +- 7 files changed, 185 insertions(+), 509 deletions(-) diff --git a/include/linphone/api/c-callbacks.h b/include/linphone/api/c-callbacks.h index c99e1b8aa..b45d705df 100644 --- a/include/linphone/api/c-callbacks.h +++ b/include/linphone/api/c-callbacks.h @@ -161,14 +161,14 @@ typedef void (*LinphoneChatRoomCbsMessageReceivedCb) (LinphoneChatRoom *cr, Linp * @param[in] cr #LinphoneChatRoom object * @param[in] participant The #LinphoneParticipant that has been added to the chat room */ -typedef void (*LinphoneChatRoomCbsParticipantAddedCb) (LinphoneChatRoom *cr, const LinphoneConferenceParticipantEvent *event); +typedef void (*LinphoneChatRoomCbsParticipantAddedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); /** * Callback used to notify a chat room that a participant has been removed. * @param[in] cr #LinphoneChatRoom object * @param[in] participant The #LinphoneParticipant that has been removed from the chat room */ -typedef void (*LinphoneChatRoomCbsParticipantRemovedCb) (LinphoneChatRoom *cr, const LinphoneConferenceParticipantEvent *event); +typedef void (*LinphoneChatRoomCbsParticipantRemovedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); /** * Callback used to notify a chat room that the admin status of a participant has been changed. @@ -176,7 +176,7 @@ typedef void (*LinphoneChatRoomCbsParticipantRemovedCb) (LinphoneChatRoom *cr, c * @param[in] participant The #LinphoneParticipant for which the admin status has been changed * @param[in] isAdmin The new admin status of the participant */ -typedef void (*LinphoneChatRoomCbsParticipantAdminStatusChangedCb) (LinphoneChatRoom *cr, const LinphoneConferenceParticipantEvent *event); +typedef void (*LinphoneChatRoomCbsParticipantAdminStatusChangedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); /** * Callback used to notify a chat room state has changed. @@ -190,7 +190,7 @@ typedef void (*LinphoneChatRoomCbsStateChangedCb) (LinphoneChatRoom *cr, Linphon * @param[in] cr #LinphoneChatRoom object * @param[in] subject The new subject of the chat room */ -typedef void (*LinphoneChatRoomCbsSubjectChangedCb) (LinphoneChatRoom *cr, const LinphoneConferenceSubjectEvent *event); +typedef void (*LinphoneChatRoomCbsSubjectChangedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); /** * Callback used to notify a chat room that a message has been received but we were unable to decrypt it @@ -204,14 +204,14 @@ typedef void (*LinphoneChatRoomCbsUndecryptableMessageReceivedCb) (LinphoneChatR * @param[in] cr #LinphoneChatRoom object * @param[in] participant The #LinphoneParticipant that has been added to the chat room */ -typedef void (*LinphoneChatRoomCbsParticipantDeviceAddedCb) (LinphoneChatRoom *cr, const LinphoneConferenceParticipantDeviceEvent *event); +typedef void (*LinphoneChatRoomCbsParticipantDeviceAddedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); /** * Callback used to notify a chat room that a participant has been removed. * @param[in] cr #LinphoneChatRoom object * @param[in] participant The #LinphoneParticipant that has been removed from the chat room */ -typedef void (*LinphoneChatRoomCbsParticipantDeviceRemovedCb) (LinphoneChatRoom *cr, const LinphoneConferenceParticipantDeviceEvent *event); +typedef void (*LinphoneChatRoomCbsParticipantDeviceRemovedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); /** * @} **/ diff --git a/include/linphone/api/c-event-log.h b/include/linphone/api/c-event-log.h index c701d5202..46dac0017 100644 --- a/include/linphone/api/c-event-log.h +++ b/include/linphone/api/c-event-log.h @@ -37,11 +37,6 @@ // EventLog. // ----------------------------------------------------------------------------- -/** - * Constructs a #LinphoneEventLog object. - **/ -LINPHONE_PUBLIC LinphoneEventLog *linphone_event_log_new (void); - /** * Increment reference count of #LinphoneEventLog object. **/ @@ -70,257 +65,78 @@ LINPHONE_PUBLIC time_t linphone_event_log_get_time (const LinphoneEventLog *even // ConferenceEvent. // ----------------------------------------------------------------------------- -/** - * Constructs a #LinphoneConferenceEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address -); - -/** - * Increment reference count of #LinphoneConferenceEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_ref (LinphoneConferenceEvent *conference_event); - -/** - * Decrement reference count of #LinphoneConferenceEvent object. When dropped to zero, memory is freed. - **/ -LINPHONE_PUBLIC void linphone_conference_event_unref (LinphoneConferenceEvent *conference_event); - /** * Returns the conference address of a conference event. - * @param[in] conference_event A #LinphoneConferenceEvent object. + * @param[in] event_log A #LinphoneEventLog object. * @return The conference address. */ -LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_event_get_conference_address ( - const LinphoneConferenceEvent *conference_event -); +LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_conference_address (const LinphoneEventLog *event_log); // ----------------------------------------------------------------------------- // ConferenceNotifiedEvent. // ----------------------------------------------------------------------------- -/** - * Constructs a #LinphoneConferenceNotifiedEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceNotifiedEvent *linphone_conference_notified_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address, - unsigned int notify_id -); - -/** - * Increment reference count of #LinphoneConferenceNotifiedEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceNotifiedEvent *linphone_conference_notified_event_ref ( - LinphoneConferenceNotifiedEvent *conference_notified_event -); - -/** - * Decrement reference count of #LinphoneConferenceNotifiedEvent object. When dropped to zero, memory is freed. - **/ -LINPHONE_PUBLIC void linphone_conference_notified_event_unref ( - LinphoneConferenceNotifiedEvent *conference_notified_event -); - /** * Returns the notify id of a conference notified event. - * @param[in] conference_notified_event A #LinphoneConferenceNotifiedEvent object. + * @param[in] event_log A #LinphoneEventLog object. * @return The conference notify id. */ -LINPHONE_PUBLIC unsigned int linphone_conference_notified_event_get_notify_id ( - const LinphoneConferenceNotifiedEvent *conference_notified_event -); +LINPHONE_PUBLIC unsigned int linphone_event_log_get_notify_id (const LinphoneEventLog *event_log); // ----------------------------------------------------------------------------- // ConferenceCallEvent. // ----------------------------------------------------------------------------- -/** - * Constructs a #LinphoneConferenceCallEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceCallEvent *linphone_conference_call_event_new ( - LinphoneEventLogType type, - time_t time, - LinphoneCall *call -); - -/** - * Increment reference count of #LinphoneConferenceCallEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceCallEvent *linphone_conference_call_event_ref ( - LinphoneConferenceCallEvent *conference_call_event -); - -/** - * Decrement reference count of #LinphoneConferenceCallEvent object. When dropped to zero, memory is freed. - **/ -LINPHONE_PUBLIC void linphone_conference_call_event_unref ( - LinphoneConferenceCallEvent *conference_call_event -); - /** * Returns the call of a conference call event. - * @param[in] conference_conference_call_event A #LinphoneConferenceCallEvent object. + * @param[in] event_log A #LinphoneEventLog object. * @return The conference call. */ -LINPHONE_PUBLIC LinphoneCall *linphone_conference_call_event_get_call ( - const LinphoneConferenceCallEvent *conference_call_event -); +LINPHONE_PUBLIC LinphoneCall *linphone_event_log_get_call (const LinphoneEventLog *event_log); // ----------------------------------------------------------------------------- // ConferenceChatMessageEvent. // ----------------------------------------------------------------------------- -/** - * Constructs a #LinphoneConferenceChatMessageEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceChatMessageEvent *linphone_conference_chat_message_event_new ( - time_t time, - LinphoneChatMessage *chat_message -); - -/** - * Increment reference count of #LinphoneConferenceChatMessageEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceChatMessageEvent *linphone_conference_chat_message_event_ref ( - LinphoneConferenceChatMessageEvent *conference_chat_message_event -); - -/** - * Decrement reference count of #LinphoneConferenceChatMessageEvent object. When dropped to zero, memory is freed. - **/ -LINPHONE_PUBLIC void linphone_conference_chat_message_event_unref ( - LinphoneConferenceChatMessageEvent *conference_chat_message_event -); - /** * Returns the chat message of a conference chat message event. - * @param[in] conference_chat_message_event A #LinphoneConferenceChatMessageEvent object. + * @param[in] event_log A #LinphoneEventLog object. * @return The conference chat message. */ -LINPHONE_PUBLIC LinphoneChatMessage *linphone_conference_chat_message_event_get_chat_message ( - const LinphoneConferenceChatMessageEvent *conference_chat_message_event -); +LINPHONE_PUBLIC LinphoneChatMessage *linphone_event_log_get_chat_message (const LinphoneEventLog *event_log); // ----------------------------------------------------------------------------- // ConferenceParticipantEvent. // ----------------------------------------------------------------------------- -/** - * Constructs a #LinphoneConferenceParticipantEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_participant_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address, - unsigned int notify_id, - const LinphoneAddress *participant_address -); - -/** - * Increment reference count of #LinphoneConferenceParticipantEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_participant_event_ref ( - LinphoneConferenceParticipantEvent *conference_participant_event -); - -/** - * Decrement reference count of #LinphoneConferenceParticipantEvent object. When dropped to zero, memory is freed. - **/ -LINPHONE_PUBLIC void linphone_conference_participant_event_unref ( - LinphoneConferenceParticipantEvent *conference_participant_event -); - /** * Returns the participant address of a conference participant event. - * @param[in] conference_participant_event A ConferenceParticipantEvent object. + * @param[in] event_log A ConferenceParticipantEvent object. * @return The conference participant address. */ -LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_participant_event_get_participant_address ( - const LinphoneConferenceParticipantEvent *conference_participant_event -); +LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_participant_address (const LinphoneEventLog *event_log); // ----------------------------------------------------------------------------- // ConferenceParticipantDeviceEvent. // ----------------------------------------------------------------------------- -/** - * Constructs a #LinphoneConferenceParticipantDeviceEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceParticipantDeviceEvent *linphone_conference_participant_device_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address, - unsigned int notify_id, - const LinphoneAddress *participant_address, - const LinphoneAddress *gruu_address -); - -/** - * Increment reference count of #LinphoneConferenceParticipantDeviceEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceParticipantDeviceEvent *linphone_conference_participant_device_event_ref ( - LinphoneConferenceParticipantDeviceEvent *conference_participant_device_event -); - -/** - * Decrement reference count of #LinphoneConferenceParticipantDeviceEvent object. - * When dropped to zero, memory is freed. - **/ -LINPHONE_PUBLIC void linphone_conference_participant_device_event_unref ( - LinphoneConferenceParticipantDeviceEvent *conference_participant_device_event -); - /** * Returns the gruu address of a conference participant device event. - * @param[in] conference_participant_device_event A #LinphoneConferenceParticipantDeviceEvent object. + * @param[in] event_log A #LinphoneEventLog object. * @return The conference gruu address. */ -LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_participant_device_event_get_gruu_address ( - const LinphoneConferenceParticipantDeviceEvent *conference_participant_device_event -); +LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_gruu_address (const LinphoneEventLog *event_log); // ----------------------------------------------------------------------------- // ConferenceSubjectEvent. // ----------------------------------------------------------------------------- -/** - * Constructs a #LinphoneConferenceSubjectEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceSubjectEvent *linphone_conference_subject_event_new ( - time_t time, - const LinphoneAddress *conference_address, - unsigned int notify_id, - const char *subject -); - -/** - * Increment reference count of #LinphoneConferenceSubjectEvent object. - **/ -LINPHONE_PUBLIC LinphoneConferenceSubjectEvent *linphone_conference_subject_event_ref ( - LinphoneConferenceSubjectEvent *conference_subject_event -); - -/** - * Decrement reference count of #LinphoneConferenceSubjectEvent object. - * When dropped to zero, memory is freed. - **/ -LINPHONE_PUBLIC void linphone_conference_subject_event_unref ( - LinphoneConferenceSubjectEvent *conference_subject_event -); - /** * Returns the subject of a conference subject event. - * @param[in] conference_subject_event A #LinphoneConferenceSubjectEvent object. + * @param[in] event_log A #LinphoneEventLog object. * @return The conference subject. */ -LINPHONE_PUBLIC const char *linphone_conference_subject_event_get_subject ( - const LinphoneConferenceSubjectEvent *conference_subject_event -); +LINPHONE_PUBLIC const char *linphone_event_get_subject (const LinphoneEventLog *event_log); /** * @} diff --git a/include/linphone/api/c-types.h b/include/linphone/api/c-types.h index 07ac41960..a673db45d 100644 --- a/include/linphone/api/c-types.h +++ b/include/linphone/api/c-types.h @@ -127,48 +127,6 @@ typedef struct _LinphoneChatRoomCbs LinphoneChatRoomCbs; // EventLog. // ----------------------------------------------------------------------------- -/** - * Call start/end events. - * @ingroup events - */ -typedef struct _LinphoneConferenceCallEvent LinphoneConferenceCallEvent; - -/** - * Chat message event. - * @ingroup events - */ -typedef struct _LinphoneConferenceChatMessageEvent LinphoneConferenceChatMessageEvent; - -/** - * Conference created/destroyed events. - * @ingroup events - */ -typedef struct _LinphoneConferenceEvent LinphoneConferenceEvent; - -/** - * Conference notified event. - * @ingroup events - */ -typedef struct _LinphoneConferenceNotifiedEvent LinphoneConferenceNotifiedEvent; - -/** - * Conference participant device added/removed events. - * @ingroup events - */ -typedef struct _LinphoneConferenceParticipantDeviceEvent LinphoneConferenceParticipantDeviceEvent; - -/** - * Conference participant added/removed & set/unset admin events. - * @ingroup events - */ -typedef struct _LinphoneConferenceParticipantEvent LinphoneConferenceParticipantEvent; - -/** - * Conference subject changed event. - * @ingroup events - */ -typedef struct _LinphoneConferenceSubjectEvent LinphoneConferenceSubjectEvent; - /** * Base object of events. * @ingroup events diff --git a/src/c-wrapper/api/c-event-log.cpp b/src/c-wrapper/api/c-event-log.cpp index 151f11c51..132982327 100644 --- a/src/c-wrapper/api/c-event-log.cpp +++ b/src/c-wrapper/api/c-event-log.cpp @@ -26,27 +26,126 @@ // ============================================================================= -L_DECLARE_C_OBJECT_IMPL(ConferenceCallEvent); -L_DECLARE_C_OBJECT_IMPL(ConferenceChatMessageEvent); -L_DECLARE_C_OBJECT_IMPL(ConferenceEvent); -L_DECLARE_C_OBJECT_IMPL(ConferenceNotifiedEvent); -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; // ----------------------------------------------------------------------------- -// EventLog. +// Helpers. // ----------------------------------------------------------------------------- -LinphoneEventLog *linphone_event_log_new () { - LinphoneEventLog *event_log = L_INIT(EventLog); - L_SET_CPP_PTR_FROM_C_OBJECT(event_log, make_shared()); - return event_log; +static bool isConferenceType (LinphoneEventLogType type) { + switch (type) { + case LinphoneEventLogTypeConferenceCallEnd: + case LinphoneEventLogTypeConferenceCallStart: + case LinphoneEventLogTypeConferenceChatMessage: + case LinphoneEventLogTypeConferenceCreated: + case LinphoneEventLogTypeConferenceDestroyed: + case LinphoneEventLogTypeConferenceParticipantAdded: + case LinphoneEventLogTypeConferenceParticipantDeviceAdded: + case LinphoneEventLogTypeConferenceParticipantDeviceRemoved: + case LinphoneEventLogTypeConferenceParticipantRemoved: + case LinphoneEventLogTypeConferenceParticipantSetAdmin: + case LinphoneEventLogTypeConferenceParticipantUnsetAdmin: + case LinphoneEventLogTypeConferenceSubjectChanged: + return true; + + default: + break; + } + + return false; } +static bool isConferenceCallType (LinphoneEventLogType type) { + switch (type) { + case LinphoneEventLogTypeConferenceCallEnd: + case LinphoneEventLogTypeConferenceCallStart: + return true; + + default: + break; + } + + return false; +} + +static bool isConferenceChatMessageType (LinphoneEventLogType type) { + switch (type) { + case LinphoneEventLogTypeConferenceChatMessage: + return true; + + default: + break; + } + + return false; +} + +static bool isConferenceNotifiedType (LinphoneEventLogType type) { + switch (type) { + case LinphoneEventLogTypeConferenceParticipantAdded: + case LinphoneEventLogTypeConferenceParticipantDeviceAdded: + case LinphoneEventLogTypeConferenceParticipantDeviceRemoved: + case LinphoneEventLogTypeConferenceParticipantRemoved: + case LinphoneEventLogTypeConferenceParticipantSetAdmin: + case LinphoneEventLogTypeConferenceParticipantUnsetAdmin: + case LinphoneEventLogTypeConferenceSubjectChanged: + return true; + + default: + break; + } + + return false; +} + +static bool isConferenceParticipantType (LinphoneEventLogType type) { + switch (type) { + case LinphoneEventLogTypeConferenceParticipantAdded: + case LinphoneEventLogTypeConferenceParticipantDeviceAdded: + case LinphoneEventLogTypeConferenceParticipantDeviceRemoved: + case LinphoneEventLogTypeConferenceParticipantRemoved: + case LinphoneEventLogTypeConferenceParticipantSetAdmin: + case LinphoneEventLogTypeConferenceParticipantUnsetAdmin: + return true; + + default: + break; + } + + return false; +} + +static bool isConferenceParticipantDeviceType (LinphoneEventLogType type) { + switch (type) { + case LinphoneEventLogTypeConferenceParticipantDeviceAdded: + case LinphoneEventLogTypeConferenceParticipantDeviceRemoved: + return true; + + default: + break; + } + + return false; +} + +static bool isConferenceSubjectType (LinphoneEventLogType type) { + switch (type) { + case LinphoneEventLogTypeConferenceSubjectChanged: + return true; + + default: + break; + } + + return false; +} + +// ----------------------------------------------------------------------------- +// EventLog. +// ----------------------------------------------------------------------------- + LinphoneEventLog *linphone_event_log_ref (LinphoneEventLog *event_log) { belle_sip_object_ref(event_log); return event_log; @@ -70,37 +169,14 @@ time_t linphone_event_log_get_time (const LinphoneEventLog *event_log) { // ConferenceEvent. // ----------------------------------------------------------------------------- -LinphoneConferenceEvent *linphone_conference_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address -) { - LinphoneConferenceEvent *conference_event = L_INIT(ConferenceEvent); - L_SET_CPP_PTR_FROM_C_OBJECT( - conference_event, - make_shared( - static_cast(type), - time, - *L_GET_CPP_PTR_FROM_C_OBJECT(conference_address) - ) - ); - return conference_event; -} +const LinphoneAddress *linphone_event_log_get_conference_address (const LinphoneEventLog *event_log) { + if (!isConferenceType(linphone_event_log_get_type(event_log))) + return nullptr; -LinphoneConferenceEvent *linphone_conference_event_ref (LinphoneConferenceEvent *conference_event) { - belle_sip_object_ref(conference_event); - return conference_event; -} - -void linphone_conference_event_unref (LinphoneConferenceEvent *conference_event) { - belle_sip_object_unref(conference_event); -} - -const LinphoneAddress *linphone_conference_event_get_conference_address ( - const LinphoneConferenceEvent *conference_event -) { return L_GET_C_BACK_PTR( - &L_GET_CPP_PTR_FROM_C_OBJECT(conference_event)->getConferenceAddress() + &static_pointer_cast( + L_GET_CPP_PTR_FROM_C_OBJECT(event_log) + )->getConferenceAddress() ); } @@ -108,81 +184,27 @@ const LinphoneAddress *linphone_conference_event_get_conference_address ( // ConferenceNotifiedEvent. // ----------------------------------------------------------------------------- -LinphoneConferenceNotifiedEvent *linphone_conference_notified_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address, - unsigned int notify_id -) { - LinphoneConferenceNotifiedEvent *conference_notified_event = L_INIT(ConferenceNotifiedEvent); - L_SET_CPP_PTR_FROM_C_OBJECT( - conference_notified_event, - make_shared( - static_cast(type), - time, - *L_GET_CPP_PTR_FROM_C_OBJECT(conference_address), - notify_id - ) - ); - return conference_notified_event; -} +unsigned int linphone_event_log_get_notify_id (const LinphoneEventLog *event_log) { + if (!isConferenceNotifiedType(linphone_event_log_get_type(event_log))) + return 0; -LinphoneConferenceNotifiedEvent *linphone_conference_notified_event_ref ( - LinphoneConferenceNotifiedEvent *conference_notified_event -) { - belle_sip_object_ref(conference_notified_event); - return conference_notified_event; -} - -void linphone_conference_notified_event_unref ( - LinphoneConferenceNotifiedEvent *conference_notified_event -) { - belle_sip_object_unref(conference_notified_event); -} - -unsigned int linphone_conference_notified_event_get_notify_id ( - const LinphoneConferenceNotifiedEvent *conference_notified_event -) { - return L_GET_CPP_PTR_FROM_C_OBJECT(conference_notified_event)->getNotifyId(); + return static_pointer_cast( + L_GET_CPP_PTR_FROM_C_OBJECT(event_log) + )->getNotifyId(); } // ----------------------------------------------------------------------------- // ConferenceCallEvent. // ----------------------------------------------------------------------------- -LinphoneConferenceCallEvent *linphone_conference_call_event_new ( - LinphoneEventLogType type, - time_t time, - LinphoneCall *call -) { - LinphoneConferenceCallEvent *conference_call_event = L_INIT(ConferenceCallEvent); - L_SET_CPP_PTR_FROM_C_OBJECT( - conference_call_event, - make_shared( - static_cast(type), - time, - L_GET_CPP_PTR_FROM_C_OBJECT(call) - ) - ); - return conference_call_event; -} +LinphoneCall *linphone_event_log_get_call (const LinphoneEventLog *event_log) { + if (!isConferenceCallType(linphone_event_log_get_type(event_log))) + return nullptr; -LinphoneConferenceCallEvent *linphone_conference_call_event_ref ( - LinphoneConferenceCallEvent *conference_call_event -) { - belle_sip_object_ref(conference_call_event); - return conference_call_event; -} - -void linphone_conference_call_event_unref ( - LinphoneConferenceCallEvent *conference_call_event -) { - belle_sip_object_unref(conference_call_event); -} - -LinphoneCall *linphone_conference_call_event_get_call (const LinphoneConferenceCallEvent *conference_call_event) { return L_GET_C_BACK_PTR( - L_GET_CPP_PTR_FROM_C_OBJECT(conference_call_event)->getCall() + static_pointer_cast( + L_GET_CPP_PTR_FROM_C_OBJECT(event_log) + )->getCall() ); } @@ -190,39 +212,14 @@ LinphoneCall *linphone_conference_call_event_get_call (const LinphoneConferenceC // ConferenceChatMessageEvent. // ----------------------------------------------------------------------------- -LinphoneConferenceChatMessageEvent *linphone_conference_chat_message_event_new ( - time_t time, - LinphoneChatMessage *chat_message -) { - LinphoneConferenceChatMessageEvent *conference_chat_message_event = L_INIT(ConferenceChatMessageEvent); - L_SET_CPP_PTR_FROM_C_OBJECT( - conference_chat_message_event, - make_shared( - time, - L_GET_CPP_PTR_FROM_C_OBJECT(chat_message) - ) - ); - return conference_chat_message_event; -} +LinphoneChatMessage *linphone_event_log_get_chat_message (const LinphoneEventLog *event_log) { + if (!isConferenceChatMessageType(linphone_event_log_get_type(event_log))) + return nullptr; -LinphoneConferenceChatMessageEvent *linphone_conference_chat_message_event_ref ( - LinphoneConferenceChatMessageEvent *conference_chat_message_event -) { - belle_sip_object_ref(conference_chat_message_event); - return conference_chat_message_event; -} - -void linphone_conference_chat_message_event_unref ( - LinphoneConferenceChatMessageEvent *conference_chat_message_event -) { - belle_sip_object_unref(conference_chat_message_event); -} - -LinphoneChatMessage *linphone_conference_chat_message_event_get_chat_message ( - const LinphoneConferenceChatMessageEvent *conference_chat_message_event -) { return L_GET_C_BACK_PTR( - L_GET_CPP_PTR_FROM_C_OBJECT(conference_chat_message_event)->getChatMessage() + static_pointer_cast( + L_GET_CPP_PTR_FROM_C_OBJECT(event_log) + )->getChatMessage() ); } @@ -230,45 +227,14 @@ LinphoneChatMessage *linphone_conference_chat_message_event_get_chat_message ( // ConferenceParticipantEvent. // ----------------------------------------------------------------------------- -LinphoneConferenceParticipantEvent *linphone_conference_participant_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address, - unsigned int notify_id, - const LinphoneAddress *participant_address -) { - LinphoneConferenceParticipantEvent *conference_participant_event = L_INIT(ConferenceParticipantEvent); - L_SET_CPP_PTR_FROM_C_OBJECT( - conference_participant_event, - make_shared( - static_cast(type), - time, - *L_GET_CPP_PTR_FROM_C_OBJECT(conference_address), - notify_id, - *L_GET_CPP_PTR_FROM_C_OBJECT(participant_address) - ) - ); - return conference_participant_event; -} +const LinphoneAddress *linphone_event_log_get_participant_address (const LinphoneEventLog *event_log) { + if (!isConferenceParticipantType(linphone_event_log_get_type(event_log))) + return nullptr; -LinphoneConferenceParticipantEvent *linphone_conference_participant_event_ref ( - LinphoneConferenceParticipantEvent *conference_participant_event -) { - belle_sip_object_ref(conference_participant_event); - return conference_participant_event; -} - -void linphone_conference_participant_event_unref ( - LinphoneConferenceParticipantEvent *conference_participant_event -) { - belle_sip_object_unref(conference_participant_event); -} - -const LinphoneAddress *linphone_conference_participant_event_get_participant_address ( - const LinphoneConferenceParticipantEvent *conference_participant_event -) { return L_GET_C_BACK_PTR( - &L_GET_CPP_PTR_FROM_C_OBJECT(conference_participant_event)->getParticipantAddress() + &static_pointer_cast( + L_GET_CPP_PTR_FROM_C_OBJECT(event_log) + )->getParticipantAddress() ); } @@ -276,49 +242,14 @@ const LinphoneAddress *linphone_conference_participant_event_get_participant_add // ConferenceParticipantDeviceEvent. // ----------------------------------------------------------------------------- -LinphoneConferenceParticipantDeviceEvent *linphone_conference_participant_device_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address, - unsigned int notify_id, - const LinphoneAddress *participant_address, - const LinphoneAddress *gruu_address -) { - LinphoneConferenceParticipantDeviceEvent *conference_participant_device_event = L_INIT( - ConferenceParticipantDeviceEvent - ); - L_SET_CPP_PTR_FROM_C_OBJECT( - conference_participant_device_event, - make_shared( - static_cast(type), - time, - *L_GET_CPP_PTR_FROM_C_OBJECT(conference_address), - notify_id, - *L_GET_CPP_PTR_FROM_C_OBJECT(participant_address), - *L_GET_CPP_PTR_FROM_C_OBJECT(gruu_address) - ) - ); - return conference_participant_device_event; -} +const LinphoneAddress *linphone_event_log_get_gruu_address (const LinphoneEventLog *event_log) { + if (!isConferenceParticipantDeviceType(linphone_event_log_get_type(event_log))) + return nullptr; -LinphoneConferenceParticipantDeviceEvent *linphone_conference_participant_device_event_ref ( - LinphoneConferenceParticipantDeviceEvent *conference_participant_device_event -) { - belle_sip_object_ref(conference_participant_device_event); - return conference_participant_device_event; -} - -void linphone_conference_participant_device_event_unref ( - LinphoneConferenceParticipantDeviceEvent *conference_participant_device_event -) { - belle_sip_object_unref(conference_participant_device_event); -} - -const LinphoneAddress *linphone_conference_participant_device_event_get_gruu_address ( - const LinphoneConferenceParticipantDeviceEvent *conference_participant_device_event -) { return L_GET_C_BACK_PTR( - &L_GET_CPP_PTR_FROM_C_OBJECT(conference_participant_device_event)->getGruuAddress() + &static_pointer_cast( + L_GET_CPP_PTR_FROM_C_OBJECT(event_log) + )->getGruuAddress() ); } @@ -326,43 +257,13 @@ const LinphoneAddress *linphone_conference_participant_device_event_get_gruu_add // ConferenceSubjectEvent. // ----------------------------------------------------------------------------- -LinphoneConferenceSubjectEvent *linphone_conference_subject_event_new ( - LinphoneEventLogType type, - time_t time, - const LinphoneAddress *conference_address, - unsigned int notify_id, - const char *subject -) { - LinphoneConferenceSubjectEvent *conference_subject_event = L_INIT(ConferenceSubjectEvent); - L_SET_CPP_PTR_FROM_C_OBJECT( - conference_subject_event, - make_shared( - time, - *L_GET_CPP_PTR_FROM_C_OBJECT(conference_address), - notify_id, - L_C_TO_STRING(subject) - ) - ); - return conference_subject_event; -} +LINPHONE_PUBLIC const char *linphone_event_log_get_subject (const LinphoneEventLog *event_log) { + if (!isConferenceSubjectType(linphone_event_log_get_type(event_log))) + return nullptr; -LinphoneConferenceSubjectEvent *linphone_conference_subject_event_ref ( - LinphoneConferenceSubjectEvent *conference_subject_event -) { - belle_sip_object_ref(conference_subject_event); - return conference_subject_event; -} - -void linphone_conference_subject_event_unref ( - LinphoneConferenceSubjectEvent *conference_subject_event -) { - belle_sip_object_unref(conference_subject_event); -} - -LINPHONE_PUBLIC const char *linphone_conference_subject_event_get_subject ( - const LinphoneConferenceSubjectEvent *conference_subject_event -) { return L_STRING_TO_C( - L_GET_CPP_PTR_FROM_C_OBJECT(conference_subject_event)->getSubject() + static_pointer_cast( + L_GET_CPP_PTR_FROM_C_OBJECT(event_log) + )->getSubject() ); } diff --git a/src/c-wrapper/c-wrapper.h b/src/c-wrapper/c-wrapper.h index 1cb7063a6..851385f5b 100644 --- a/src/c-wrapper/c-wrapper.h +++ b/src/c-wrapper/c-wrapper.h @@ -36,13 +36,6 @@ F(Call, Call) \ F(ChatMessage, ChatMessage) \ F(ChatRoom, ChatRoom) \ - F(ConferenceCallEvent, ConferenceCallEvent) \ - F(ConferenceChatMessageEvent, ConferenceChatMessageEvent) \ - F(ConferenceEvent, ConferenceEvent) \ - F(ConferenceNotifiedEvent, ConferenceNotifiedEvent) \ - F(ConferenceParticipantDeviceEvent, ConferenceParticipantDeviceEvent) \ - F(ConferenceParticipantEvent, ConferenceParticipantEvent) \ - F(ConferenceSubjectEvent, ConferenceSubjectEvent) \ F(DialPlan, DialPlan) \ F(EventLog, EventLog) \ F(MediaSessionParams, CallParams) \ @@ -51,7 +44,14 @@ #define L_REGISTER_SUBTYPES(F) \ F(ChatRoom, BasicChatRoom) \ F(ChatRoom, ClientGroupChatRoom) \ - F(ChatRoom, RealTimeTextChatRoom) + F(ChatRoom, RealTimeTextChatRoom) \ + F(EventLog, ConferenceCallEvent) \ + F(EventLog, ConferenceChatMessageEvent) \ + F(EventLog, ConferenceEvent) \ + F(EventLog, ConferenceNotifiedEvent) \ + F(EventLog, ConferenceParticipantDeviceEvent) \ + F(EventLog, ConferenceParticipantEvent) \ + F(EventLog, ConferenceSubjectEvent) // ============================================================================= // Register belle-sip ID. diff --git a/src/core/core.h b/src/core/core.h index 0aeff72e4..d0eb6ac4b 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -38,11 +38,12 @@ friend class ClientGroupChatRoom; public: Core (LinphoneCore *cCore); + std::string getDataPath() const; + std::string getConfigPath() const; + std::shared_ptr createClientGroupChatRoom (const std::string &subject); std::shared_ptr getOrCreateChatRoom (const std::string &peerAddress, bool isRtt = false) const; const std::list> &getChatRooms () const; - std::string getDataPath() const; - std::string getConfigPath() const; private: L_DECLARE_PRIVATE(Core); diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index df3d034c2..0dab63c1b 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -941,7 +941,7 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {} query += buildSqlEventFilter({ ConferenceCallFilter, ConferenceChatMessageFilter, ConferenceInfoFilter }, mask, "AND"); - query += " ORDER BY id DESC"; + query += " ORDER BY date DESC"; if (end >= 0) query += " LIMIT " + Utils::toString(end + 1 - begin);