Commit 79001f54 authored by Ronan's avatar Ronan
Browse files

feat(EventLog): wrap only one C object

parent c26031d7
......@@ -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);
/**
* @}
**/
......
......@@ -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);
/**
* @}
......
......@@ -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
......
......@@ -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<LinphonePrivate::EventLog>());
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<LinphonePrivate::ConferenceEvent>(
static_cast<LinphonePrivate::EventLog::Type>(type),
time,
*L_GET_CPP_PTR_FROM_C_OBJECT(conference_address)
)
);
return conference_event;
}
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_event_log_get_conference_address (const LinphoneEventLog *event_log) {
if (!isConferenceType(linphone_event_log_get_type(event_log)))
return nullptr;
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<const LinphonePrivate::ConferenceEvent>(
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<LinphonePrivate::ConferenceNotifiedEvent>(
static_cast<LinphonePrivate::EventLog::Type>(type),
time,
*L_GET_CPP_PTR_FROM_C_OBJECT(conference_address),
notify_id
)
);
return conference_notified_event;
}
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_event_log_get_notify_id (const LinphoneEventLog *event_log) {
if (!isConferenceNotifiedType(linphone_event_log_get_type(event_log)))
return 0;
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<const LinphonePrivate::ConferenceNotifiedEvent>(
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(