diff --git a/coreapi/private.h b/coreapi/private.h index c332cedd9..8d4c02c1a 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1891,7 +1891,9 @@ BELLE_SIP_TYPE_ID(LinphoneVideoActivationPolicy), BELLE_SIP_TYPE_ID(LinphoneCallStats), BELLE_SIP_TYPE_ID(LinphonePlayer), BELLE_SIP_TYPE_ID(LinphonePlayerCbs), -BELLE_SIP_TYPE_ID(LinphoneEventLog) +BELLE_SIP_TYPE_ID(LinphoneEventLog), +BELLE_SIP_TYPE_ID(LinphoneMessage), +BELLE_SIP_TYPE_ID(LinphoneMessageEvent) BELLE_SIP_DECLARE_TYPES_END diff --git a/src/c-wrapper/c-types.cpp b/src/c-wrapper/c-types.cpp index 051c73cf8..70e1a41cf 100644 --- a/src/c-wrapper/c-types.cpp +++ b/src/c-wrapper/c-types.cpp @@ -25,38 +25,44 @@ // Must be included before cpp headers. #include "c-types.h" -#include "event-log/event-log.h" +#include "event-log/message-event.h" // ================================================================²============= using namespace std; extern "C" { -#define L_DECLARE_C_STRUCT_IMPL(STRUCT) \ +#define L_DECLARE_C_STRUCT_IMPL(STRUCT, C_NAME) \ struct _Linphone ## STRUCT { \ belle_sip_object_t base; \ shared_ptr cppPtr; \ }; \ - static void _linphone_ ## STRUCT ## _uninit(Linphone ## STRUCT * object) { \ + BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## STRUCT); \ + static Linphone ## STRUCT *_linphone_ ## C_NAME ## _init() { \ + Linphone ## STRUCT * object = belle_sip_object_new(Linphone ## STRUCT); \ + new(&object->cppPtr) shared_ptr(); \ + return object; \ + } \ + static void _linphone_ ## C_NAME ## _uninit(Linphone ## STRUCT * object) { \ object->cppPtr.reset(); \ object->cppPtr->~STRUCT (); \ } \ - static void _linphone_ ## STRUCT ## _clone(Linphone ## STRUCT * dest, const Linphone ## STRUCT * src) { \ + static void _linphone_ ## C_NAME ## _clone(Linphone ## STRUCT * dest, const Linphone ## STRUCT * src) { \ new(&dest->cppPtr) shared_ptr(); \ dest->cppPtr = make_shared(*src->cppPtr.get()); \ } \ - BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## STRUCT); \ BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(Linphone ## STRUCT); \ BELLE_SIP_INSTANCIATE_VPTR(Linphone ## STRUCT, belle_sip_object_t, \ - _linphone_ ## STRUCT ## _uninit, \ - _linphone_ ## STRUCT ## _clone, \ + _linphone_ ## C_NAME ## _uninit, \ + _linphone_ ## C_NAME ## _clone, \ NULL, \ FALSE \ ); #define L_DECLARE_C_STRUCT_NEW_DEFAULT(STRUCT, C_NAME) \ Linphone ## STRUCT * CNAME ## _new() { \ - Linphone ## STRUCT * object = belle_sip_object_new(Linphone ## STRUCT); \ + Linphone ## STRUCT * object = _linphone_ ## C_NAME ## _init(); \ + object->cppPtr = make_shared(); \ return object; \ } @@ -64,12 +70,23 @@ extern "C" { // Event log. // ----------------------------------------------------------------------------- -L_DECLARE_C_STRUCT_IMPL(EventLog); -L_DECLARE_C_STRUCT_NEW_DEFAULT(EventLog, event_log) +L_DECLARE_C_STRUCT_IMPL(EventLog, event_log); +L_DECLARE_C_STRUCT_NEW_DEFAULT(EventLog, event_log); LinphoneEventLogType event_log_get_type (const LinphoneEventLog *eventLog) { return static_cast(eventLog->cppPtr->getType()); } // ----------------------------------------------------------------------------- +// Message Event. +// ----------------------------------------------------------------------------- + +// L_DECLARE_C_STRUCT_IMPL(MessageEvent, message_event); +// +// LinphoneMessageEvent *message_event_new (LinphoneMessage *message) { +// LinphoneMessageEvent *object = object->cppPtr = make_shared(); +// return object; +// } +// +// LinphoneMessage *message_event_get_message (const LinphoneMessageEvent *messageEvent); } diff --git a/src/c-wrapper/c-types.h b/src/c-wrapper/c-types.h index 9b1dad31a..a95e0c4ca 100644 --- a/src/c-wrapper/c-types.h +++ b/src/c-wrapper/c-types.h @@ -30,14 +30,23 @@ extern "C" { #endif +L_DECLARE_C_STRUCT(EventLog); +L_DECLARE_C_STRUCT(Message); +L_DECLARE_C_STRUCT(MessageEvent); + // ----------------------------------------------------------------------------- // Event log. // ----------------------------------------------------------------------------- -L_DECLARE_C_STRUCT(EventLog); - LINPHONE_PUBLIC LinphoneEventLog *event_log_new (); -LINPHONE_PUBLIC LinphoneEventLogType event_log_get_type (const LinphoneEventLog *eventLog); +LINPHONE_PUBLIC LinphoneEventLogType event_log_get_type (const LinphoneEventLog *event_log); + +// ----------------------------------------------------------------------------- +// Message Event. +// ----------------------------------------------------------------------------- + +LINPHONE_PUBLIC LinphoneMessageEvent *message_event_new (LinphoneMessage *message); +LINPHONE_PUBLIC LinphoneMessage *message_event_get_message (const LinphoneMessageEvent *message_event); // -----------------------------------------------------------------------------