From 1cc45284cf59349da72e126121fe969f74ad0df6 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 28 Aug 2017 13:06:55 +0200 Subject: [PATCH 01/11] reset liblinphone_log_collection_max_file_size to default value in function linphone_core_reset_log_collection --- coreapi/linphonecore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 262082c31..343dffad6 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1031,6 +1031,7 @@ void linphone_core_reset_log_collection(void) { ms_free(filename); liblinphone_log_collection_file = NULL; liblinphone_log_collection_file_size = 0; + liblinphone_log_collection_max_file_size = LOG_COLLECTION_DEFAULT_MAX_FILE_SIZE; /*also reset size*/ ortp_mutex_unlock(&liblinphone_log_collection_mutex); } From ce37899b26345b651daf4f82a0b72daa29f58ae9 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 28 Aug 2017 14:52:49 +0200 Subject: [PATCH 02/11] feat(core): add c-wrapper tools --- coreapi/private.h | 3 +- src/CMakeLists.txt | 25 ++++---- src/c-wrapper/c-types.cpp | 63 +++++++++++++++++++ src/c-wrapper/c-types.h | 38 +++++++++++ src/db/events-db.cpp | 53 ++++++++-------- src/db/events-db.h | 11 ++-- src/{event => event-log}/call-event.cpp | 8 +-- src/{event => event-log}/call-event.h | 4 +- src/{event => event-log}/conference-event-p.h | 4 +- src/{event => event-log}/conference-event.cpp | 6 +- src/{event => event-log}/conference-event.h | 4 +- .../conference-participant-event.cpp | 0 .../conference-participant-event.h | 0 .../event-p.h => event-log/event-log-p.h} | 16 ++--- .../event.cpp => event-log/event-log.cpp} | 22 +++---- src/{event/event.h => event-log/event-log.h} | 24 +++---- src/{event => event-log}/message-event.cpp | 9 +-- src/{event => event-log}/message-event.h | 4 +- 18 files changed, 200 insertions(+), 94 deletions(-) create mode 100644 src/c-wrapper/c-types.cpp create mode 100644 src/c-wrapper/c-types.h rename src/{event => event-log}/call-event.cpp (91%) rename src/{event => event-log}/call-event.h (94%) rename src/{event => event-log}/conference-event-p.h (93%) rename src/{event => event-log}/conference-event.cpp (94%) rename src/{event => event-log}/conference-event.h (94%) rename src/{event => event-log}/conference-participant-event.cpp (100%) rename src/{event => event-log}/conference-participant-event.h (100%) rename src/{event/event-p.h => event-log/event-log-p.h} (78%) rename src/{event/event.cpp => event-log/event-log.cpp} (69%) rename src/{event/event.h => event-log/event-log.h} (78%) rename src/{event => event-log}/message-event.cpp (90%) rename src/{event => event-log}/message-event.h (94%) diff --git a/coreapi/private.h b/coreapi/private.h index 83d1d14c2..c332cedd9 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1890,7 +1890,8 @@ BELLE_SIP_TYPE_ID(LinphoneTransports), BELLE_SIP_TYPE_ID(LinphoneVideoActivationPolicy), BELLE_SIP_TYPE_ID(LinphoneCallStats), BELLE_SIP_TYPE_ID(LinphonePlayer), -BELLE_SIP_TYPE_ID(LinphonePlayerCbs) +BELLE_SIP_TYPE_ID(LinphonePlayerCbs), +BELLE_SIP_TYPE_ID(LinphoneEventLog) BELLE_SIP_DECLARE_TYPES_END diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 128049d35..a28041712 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,7 @@ ############################################################################ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES + c-wrapper/c-types.h content/content.h core/core.h cpim/cpim.h @@ -38,12 +39,13 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES db/provider/db-session-provider.h db/provider/db-session.h enums.h - event/call-event.h - event/conference-event-p.h - event/conference-event.h - event/conference-participant-event.h - event/event.h - event/message-event.h + event-log/call-event.h + event-log/conference-event-p.h + event-log/conference-event.h + event-log/conference-participant-event.h + event-log/event-log-p.h + event-log/event-log.h + event-log/message-event.h logger/logger.h message/message.h object/clonable-object-p.h @@ -56,6 +58,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES ) set(LINPHONE_CXX_OBJECTS_SOURCE_FILES + c-wrapper/c-types.cpp content/content.cpp core/core.cpp cpim/header/cpim-core-headers.cpp @@ -68,11 +71,11 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES db/events-db.cpp db/provider/db-session-provider.cpp db/provider/db-session.cpp - event/call-event.cpp - event/conference-event.cpp - event/conference-participant-event.cpp - event/event.cpp - event/message-event.cpp + event-log/call-event.cpp + event-log/conference-event.cpp + event-log/conference-participant-event.cpp + event-log/event-log.cpp + event-log/message-event.cpp logger/logger.cpp message/message.cpp object/clonable-object.cpp diff --git a/src/c-wrapper/c-types.cpp b/src/c-wrapper/c-types.cpp new file mode 100644 index 000000000..c4a9acbed --- /dev/null +++ b/src/c-wrapper/c-types.cpp @@ -0,0 +1,63 @@ +/* + * types.cpp + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +// From coreapi. +#include "private.h" + +#include "event-log/event-log.h" + +#include "c-types.h" + +// ================================================================²============= + +using namespace std; + +void toto () { + LinphonePrivate::EventLog titi; + LinphonePrivate::EventLog machin(titi); +} + +extern "C" { +#define L_DECLARE_C_STRUCT_IMPL(STRUCT) \ + struct _Linphone ## STRUCT { \ + belle_sip_object_t base; \ + shared_ptr cppPtr; \ + }; \ + static void _linphone_ ## STRUCT ## _uninit(Linphone ## STRUCT * object) { \ + object->cppPtr.reset(); \ + object->cppPtr->~STRUCT (); \ + } \ + static void _linphone_ ## STRUCT ## _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, \ + NULL, \ + FALSE \ + ); + +// ----------------------------------------------------------------------------- +L_DECLARE_C_STRUCT_IMPL(EventLog); +} diff --git a/src/c-wrapper/c-types.h b/src/c-wrapper/c-types.h new file mode 100644 index 000000000..24a73990b --- /dev/null +++ b/src/c-wrapper/c-types.h @@ -0,0 +1,38 @@ +/* + * c-types.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _C_TYPES_H_ +#define _C_TYPES_H_ + +// ============================================================================= + +#ifdef __cplusplus + extern "C" { +#endif + +#define L_DECLARE_C_STRUCT(STRUCT) typedef struct _Linphone ## STRUCT Linphone ## STRUCT; + +L_DECLARE_C_STRUCT(EventLog) + +#undef L_DECLARE_C_STRUCT + +#ifdef __cplusplus + } +#endif + +#endif // ifndef _C_TYPES_H_ diff --git a/src/db/events-db.cpp b/src/db/events-db.cpp index d6c90fb29..60a28c116 100644 --- a/src/db/events-db.cpp +++ b/src/db/events-db.cpp @@ -23,9 +23,8 @@ #endif // ifdef SOCI_ENABLED #include "abstract/abstract-db-p.h" -#include "event/call-event.h" -#include "event/event.h" -#include "event/message-event.h" +#include "event-log/call-event.h" +#include "event-log/message-event.h" #include "logger/logger.h" #include "message/message.h" @@ -250,29 +249,29 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} } } - bool EventsDb::addEvent (const Event &event) { + bool EventsDb::addEvent (const EventLog &eventLog) { // TODO. - switch (event.getType()) { - case Event::None: + switch (eventLog.getType()) { + case EventLog::None: return false; - case Event::MessageEvent: - case Event::CallStartEvent: - case Event::CallEndEvent: - case Event::ConferenceCreatedEvent: - case Event::ConferenceDestroyedEvent: - case Event::ConferenceParticipantAddedEvent: - case Event::ConferenceParticipantRemovedEvent: - case Event::ConferenceParticipantSetAdminEvent: - case Event::ConferenceParticipantUnsetAdminEvent: + case EventLog::MessageEvent: + case EventLog::CallStartEvent: + case EventLog::CallEndEvent: + case EventLog::ConferenceCreatedEvent: + case EventLog::ConferenceDestroyedEvent: + case EventLog::ConferenceParticipantAddedEvent: + case EventLog::ConferenceParticipantRemovedEvent: + case EventLog::ConferenceParticipantSetAdminEvent: + case EventLog::ConferenceParticipantUnsetAdminEvent: break; } return true; } - bool EventsDb::deleteEvent (const Event &event) { + bool EventsDb::deleteEvent (const EventLog &eventLog) { // TODO. - (void)event; + (void)eventLog; return true; } @@ -344,21 +343,21 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} return count; } - list EventsDb::getHistory (const string &remoteAddress, int nLast, FilterMask mask) const { + list> EventsDb::getHistory (const string &remoteAddress, int nLast, FilterMask mask) const { // TODO. (void)remoteAddress; (void)nLast; (void)mask; - return list(); + return list>(); } - list EventsDb::getHistory (const string &remoteAddress, int begin, int end, FilterMask mask) const { + list> EventsDb::getHistory (const string &remoteAddress, int begin, int end, FilterMask mask) const { // TODO. (void)remoteAddress; (void)begin; (void)end; (void)mask; - return list(); + return list>(); } void EventsDb::cleanHistory (const string &remoteAddress) { @@ -374,11 +373,11 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} void EventsDb::init () {} - bool EventsDb::addEvent (const Event &) { + bool EventsDb::addEvent (const EventLog &) { return false; } - bool EventsDb::deleteEvent (const Event &) { + bool EventsDb::deleteEvent (const EventLog &) { return false; } @@ -396,12 +395,12 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} return 0; } - list EventsDb::getHistory (const string &, int, FilterMask) const { - return list(); + list> EventsDb::getHistory (const string &, int, FilterMask) const { + return list>(); } - list EventsDb::getHistory (const string &, int, int, FilterMask) const { - return list(); + list> EventsDb::getHistory (const string &, int, int, FilterMask) const { + return list>(); } void EventsDb::cleanHistory (const string &) {} diff --git a/src/db/events-db.h b/src/db/events-db.h index d6013ed2e..22e187abb 100644 --- a/src/db/events-db.h +++ b/src/db/events-db.h @@ -20,6 +20,7 @@ #define _EVENTS_DB_H_ #include +#include #include "abstract/abstract-db.h" @@ -27,7 +28,7 @@ LINPHONE_BEGIN_NAMESPACE -class Event; +class EventLog; class EventsDbPrivate; class LINPHONE_PUBLIC EventsDb : public AbstractDb { @@ -44,16 +45,16 @@ public: EventsDb (); // Generic. - bool addEvent (const Event &event); - bool deleteEvent (const Event &event); + bool addEvent (const EventLog &eventLog); + bool deleteEvent (const EventLog &eventLog); void cleanEvents (FilterMask mask = NoFilter); int getEventsCount (FilterMask mask = NoFilter) const; // Messages, calls and conferences. int getMessagesCount (const std::string &remoteAddress = "") const; int getUnreadMessagesCount (const std::string &remoteAddress = "") const; - std::list getHistory (const std::string &remoteAddress, int nLast, FilterMask mask = NoFilter) const; - std::list getHistory (const std::string &remoteAddress, int begin, int end, FilterMask mask = NoFilter) const; + std::list > getHistory (const std::string &remoteAddress, int nLast, FilterMask mask = NoFilter) const; + std::list > getHistory (const std::string &remoteAddress, int begin, int end, FilterMask mask = NoFilter) const; void cleanHistory (const std::string &remoteAddress = ""); protected: diff --git a/src/event/call-event.cpp b/src/event-log/call-event.cpp similarity index 91% rename from src/event/call-event.cpp rename to src/event-log/call-event.cpp index f6eee2b1e..0dde3edc9 100644 --- a/src/event/call-event.cpp +++ b/src/event-log/call-event.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include "event-p.h" +#include "event-log-p.h" #include "call-event.h" @@ -26,14 +26,14 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -class CallEventPrivate : public EventPrivate { +class CallEventPrivate : public EventLogPrivate { public: shared_ptr call; }; // ----------------------------------------------------------------------------- -CallEvent::CallEvent (Type type, const shared_ptr &call) : Event(*new CallEventPrivate, type) { +CallEvent::CallEvent (Type type, const shared_ptr &call) : EventLog(*new CallEventPrivate, type) { L_D(CallEvent); L_ASSERT(call); L_ASSERT(type == CallStartEvent || type == CallEndEvent); @@ -45,7 +45,7 @@ CallEvent::CallEvent (const CallEvent &src) : CallEvent(src.getType(), src.getCa CallEvent &CallEvent::operator= (const CallEvent &src) { L_D(CallEvent); if (this != &src) { - Event::operator=(src); + EventLog::operator=(src); d->call = src.getPrivate()->call; } diff --git a/src/event/call-event.h b/src/event-log/call-event.h similarity index 94% rename from src/event/call-event.h rename to src/event-log/call-event.h index e56d25dfc..423f71449 100644 --- a/src/event/call-event.h +++ b/src/event-log/call-event.h @@ -21,7 +21,7 @@ #include -#include "event.h" +#include "event-log.h" // ============================================================================= @@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE class Call; class CallEventPrivate; -class LINPHONE_PUBLIC CallEvent : public Event { +class LINPHONE_PUBLIC CallEvent : public EventLog { public: CallEvent (Type type, const std::shared_ptr &message); CallEvent (const CallEvent &src); diff --git a/src/event/conference-event-p.h b/src/event-log/conference-event-p.h similarity index 93% rename from src/event/conference-event-p.h rename to src/event-log/conference-event-p.h index d4fcd9b65..654e2a932 100644 --- a/src/event/conference-event-p.h +++ b/src/event-log/conference-event-p.h @@ -21,13 +21,13 @@ #include "conference-event.h" -#include "event-p.h" +#include "event-log-p.h" // ============================================================================= LINPHONE_BEGIN_NAMESPACE -class ConferenceEventPrivate : public EventPrivate { +class ConferenceEventPrivate : public EventLogPrivate { private: std::shared_ptr
address; diff --git a/src/event/conference-event.cpp b/src/event-log/conference-event.cpp similarity index 94% rename from src/event/conference-event.cpp rename to src/event-log/conference-event.cpp index a75d22657..890a76d54 100644 --- a/src/event/conference-event.cpp +++ b/src/event-log/conference-event.cpp @@ -27,7 +27,7 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE ConferenceEvent::ConferenceEvent (Type type, const shared_ptr
&address) : - Event(*new ConferenceEventPrivate, type) { + EventLog(*new ConferenceEventPrivate, type) { L_D(ConferenceEvent); L_ASSERT(type == ConferenceCreatedEvent || type == ConferenceDestroyedEvent); L_ASSERT(address); @@ -37,7 +37,7 @@ ConferenceEvent::ConferenceEvent (Type type, const shared_ptr
&address) ConferenceEvent::ConferenceEvent (const ConferenceEvent &src) : ConferenceEvent(src.getType(), src.getAddress()) {} ConferenceEvent::ConferenceEvent (ConferenceEventPrivate &p, Type type, const shared_ptr
&address) : - Event(p, type) { + EventLog(p, type) { L_D(ConferenceEvent); L_ASSERT(address); d->address = address; @@ -46,7 +46,7 @@ ConferenceEvent::ConferenceEvent (ConferenceEventPrivate &p, Type type, const sh ConferenceEvent &ConferenceEvent::operator= (const ConferenceEvent &src) { L_D(ConferenceEvent); if (this != &src) { - Event::operator=(src); + EventLog::operator=(src); d->address = src.getPrivate()->address; } diff --git a/src/event/conference-event.h b/src/event-log/conference-event.h similarity index 94% rename from src/event/conference-event.h rename to src/event-log/conference-event.h index 5a499b215..6bdb10fa0 100644 --- a/src/event/conference-event.h +++ b/src/event-log/conference-event.h @@ -21,7 +21,7 @@ #include -#include "event.h" +#include "event-log.h" // ============================================================================= @@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE class Address; class ConferenceEventPrivate; -class LINPHONE_PUBLIC ConferenceEvent : public Event { +class LINPHONE_PUBLIC ConferenceEvent : public EventLog { public: ConferenceEvent (Type type, const std::shared_ptr
&address); ConferenceEvent (const ConferenceEvent &src); diff --git a/src/event/conference-participant-event.cpp b/src/event-log/conference-participant-event.cpp similarity index 100% rename from src/event/conference-participant-event.cpp rename to src/event-log/conference-participant-event.cpp diff --git a/src/event/conference-participant-event.h b/src/event-log/conference-participant-event.h similarity index 100% rename from src/event/conference-participant-event.h rename to src/event-log/conference-participant-event.h diff --git a/src/event/event-p.h b/src/event-log/event-log-p.h similarity index 78% rename from src/event/event-p.h rename to src/event-log/event-log-p.h index 0499716fd..ce5507a17 100644 --- a/src/event/event-p.h +++ b/src/event-log/event-log-p.h @@ -1,5 +1,5 @@ /* - * event-p.h + * event-log-p.h * Copyright (C) 2017 Belledonne Communications SARL * * This program is free software: you can redistribute it and/or modify @@ -16,23 +16,23 @@ * along with this program. If not, see . */ -#ifndef _EVENT_P_H_ -#define _EVENT_P_H_ +#ifndef _EVENT_LOG_P_H_ +#define _EVENT_LOG_P_H_ -#include "event.h" +#include "event-log.h" #include "object/clonable-object-p.h" // ============================================================================= LINPHONE_BEGIN_NAMESPACE -class EventPrivate : public ClonableObjectPrivate { +class EventLogPrivate : public ClonableObjectPrivate { private: - Event::Type type = Event::None; + EventLog::Type type = EventLog::None; - L_DECLARE_PUBLIC(Event); + L_DECLARE_PUBLIC(EventLog); }; LINPHONE_END_NAMESPACE -#endif // ifndef _EVENT_P_H_ +#endif // ifndef _EVENT_LOG_P_H_ diff --git a/src/event/event.cpp b/src/event-log/event-log.cpp similarity index 69% rename from src/event/event.cpp rename to src/event-log/event-log.cpp index 824240425..cacec4d0d 100644 --- a/src/event/event.cpp +++ b/src/event-log/event-log.cpp @@ -1,5 +1,5 @@ /* - * event.cpp + * event-log.cpp * Copyright (C) 2017 Belledonne Communications SARL * * This program is free software: you can redistribute it and/or modify @@ -16,9 +16,9 @@ * along with this program. If not, see . */ -#include "event-p.h" +#include "event-log-p.h" -#include "event.h" +#include "event-log.h" // ============================================================================= @@ -26,24 +26,24 @@ LINPHONE_BEGIN_NAMESPACE // ----------------------------------------------------------------------------- -Event::Event () : ClonableObject(*new EventPrivate) {} +EventLog::EventLog () : ClonableObject(*new EventLogPrivate) {} -Event::Event (const Event &) : ClonableObject(*new EventPrivate) {} +EventLog::EventLog (const EventLog &) : ClonableObject(*new EventLogPrivate) {} -Event::Event (EventPrivate &p, Type type) : ClonableObject(*new EventPrivate) { - L_D(Event); +EventLog::EventLog (EventLogPrivate &p, Type type) : ClonableObject(*new EventLogPrivate) { + L_D(EventLog); d->type = type; } -Event &Event::operator= (const Event &src) { - L_D(Event); +EventLog &EventLog::operator= (const EventLog &src) { + L_D(EventLog); if (this != &src) d->type = src.getPrivate()->type; return *this; } -Event::Type Event::getType () const { - L_D(const Event); +EventLog::Type EventLog::getType () const { + L_D(const EventLog); return d->type; } diff --git a/src/event/event.h b/src/event-log/event-log.h similarity index 78% rename from src/event/event.h rename to src/event-log/event-log.h index ebd530a4b..f83fa85e2 100644 --- a/src/event/event.h +++ b/src/event-log/event-log.h @@ -1,5 +1,5 @@ /* - * event.h + * event-log.h * Copyright (C) 2017 Belledonne Communications SARL * * This program is free software: you can redistribute it and/or modify @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef _EVENT_H_ -#define _EVENT_H_ +#ifndef _EVENT_LOG_H_ +#define _EVENT_LOG_H_ #include "object/clonable-object.h" @@ -25,9 +25,9 @@ LINPHONE_BEGIN_NAMESPACE -class EventPrivate; +class EventLogPrivate; -class LINPHONE_PUBLIC Event : public ClonableObject { +class LINPHONE_PUBLIC EventLog : public ClonableObject { public: enum Type { None, @@ -46,21 +46,21 @@ public: ConferenceParticipantUnsetAdminEvent }; - Event (); - Event (const Event &src); - virtual ~Event () = default; + EventLog (); + EventLog (const EventLog &src); + virtual ~EventLog () = default; - Event &operator= (const Event &src); + EventLog &operator= (const EventLog &src); Type getType () const; protected: - Event (EventPrivate &p, Type type); + EventLog (EventLogPrivate &p, Type type); private: - L_DECLARE_PRIVATE(Event); + L_DECLARE_PRIVATE(EventLog); }; LINPHONE_END_NAMESPACE -#endif // ifndef _EVENT_H_ +#endif // ifndef _EVENT_LOG_H_ diff --git a/src/event/message-event.cpp b/src/event-log/message-event.cpp similarity index 90% rename from src/event/message-event.cpp rename to src/event-log/message-event.cpp index 49e74f3b7..d46af4102 100644 --- a/src/event/message-event.cpp +++ b/src/event-log/message-event.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include "event-p.h" +#include "event-log-p.h" #include "message-event.h" @@ -26,14 +26,15 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -class MessageEventPrivate : public EventPrivate { +class MessageEventPrivate : public EventLogPrivate { public: shared_ptr message; }; // ----------------------------------------------------------------------------- -MessageEvent::MessageEvent (const shared_ptr &message) : Event(*new MessageEventPrivate, Event::MessageEvent) { +MessageEvent::MessageEvent (const shared_ptr &message) : + EventLog(*new MessageEventPrivate, EventLog::MessageEvent) { L_D(MessageEvent); L_ASSERT(message); d->message = message; @@ -44,7 +45,7 @@ MessageEvent::MessageEvent (const MessageEvent &src) : MessageEvent(src.getMessa MessageEvent &MessageEvent::operator= (const MessageEvent &src) { L_D(MessageEvent); if (this != &src) { - Event::operator=(src); + EventLog::operator=(src); d->message = src.getPrivate()->message; } diff --git a/src/event/message-event.h b/src/event-log/message-event.h similarity index 94% rename from src/event/message-event.h rename to src/event-log/message-event.h index 9edff75a9..b1c12a5fb 100644 --- a/src/event/message-event.h +++ b/src/event-log/message-event.h @@ -21,7 +21,7 @@ #include -#include "event.h" +#include "event-log.h" // ============================================================================= @@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE class Message; class MessageEventPrivate; -class LINPHONE_PUBLIC MessageEvent : public Event { +class LINPHONE_PUBLIC MessageEvent : public EventLog { public: MessageEvent (const std::shared_ptr &message); MessageEvent (const MessageEvent &src); From 3e7e4cb56ddb557a5ba3d9e1ae8bf3a351446cfd Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 28 Aug 2017 14:55:05 +0200 Subject: [PATCH 03/11] fix(c-types): remove toto code --- src/c-wrapper/c-types.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/c-wrapper/c-types.cpp b/src/c-wrapper/c-types.cpp index c4a9acbed..767d32833 100644 --- a/src/c-wrapper/c-types.cpp +++ b/src/c-wrapper/c-types.cpp @@ -30,11 +30,6 @@ using namespace std; -void toto () { - LinphonePrivate::EventLog titi; - LinphonePrivate::EventLog machin(titi); -} - extern "C" { #define L_DECLARE_C_STRUCT_IMPL(STRUCT) \ struct _Linphone ## STRUCT { \ From d7d78a515b45364ff0117d4e4a7febe49bb749c4 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 29 Aug 2017 10:46:19 +0200 Subject: [PATCH 04/11] feat(enums): supports C export --- src/CMakeLists.txt | 1 + src/c-wrapper/c-types.cpp | 56 +++++++++++++++++++-------------- src/c-wrapper/c-types.h | 16 ++++++++-- src/db/events-db.cpp | 2 +- src/event-log/event-log-enums.h | 43 +++++++++++++++++++++++++ src/event-log/event-log-p.h | 2 +- src/event-log/event-log.h | 19 ++--------- src/utils/general.h | 18 +++++++++-- 8 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 src/event-log/event-log-enums.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a28041712..7f2a446e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,6 +43,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES event-log/conference-event-p.h event-log/conference-event.h event-log/conference-participant-event.h + event-log/event-log-enums.h event-log/event-log-p.h event-log/event-log.h event-log/message-event.h diff --git a/src/c-wrapper/c-types.cpp b/src/c-wrapper/c-types.cpp index 767d32833..06f6fcb7d 100644 --- a/src/c-wrapper/c-types.cpp +++ b/src/c-wrapper/c-types.cpp @@ -22,37 +22,47 @@ // From coreapi. #include "private.h" -#include "event-log/event-log.h" - +// Must be included before cpp headers. #include "c-types.h" +#include "event-log/event-log.h" + // ================================================================²============= using namespace std; extern "C" { #define L_DECLARE_C_STRUCT_IMPL(STRUCT) \ - struct _Linphone ## STRUCT { \ - belle_sip_object_t base; \ - shared_ptr cppPtr; \ - }; \ - static void _linphone_ ## STRUCT ## _uninit(Linphone ## STRUCT * object) { \ - object->cppPtr.reset(); \ - object->cppPtr->~STRUCT (); \ - } \ - static void _linphone_ ## STRUCT ## _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, \ - NULL, \ - FALSE \ - ); + struct _Linphone ## STRUCT { \ + belle_sip_object_t base; \ + shared_ptr cppPtr; \ + }; \ + static void _linphone_ ## STRUCT ## _uninit(Linphone ## STRUCT * object) { \ + object->cppPtr.reset(); \ + object->cppPtr->~STRUCT (); \ + } \ + static void _linphone_ ## STRUCT ## _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, \ + NULL, \ + FALSE \ + ); // ----------------------------------------------------------------------------- -L_DECLARE_C_STRUCT_IMPL(EventLog); + + L_DECLARE_C_STRUCT_IMPL(EventLog); + +LinphoneEventLog *event_log_new () { + return nullptr; +} + +LinphoneEventLogType event_log_get_type (const LinphoneEventLog *eventLog) { + return LinphoneEventLogType::NoneEvent; +} } diff --git a/src/c-wrapper/c-types.h b/src/c-wrapper/c-types.h index 24a73990b..9b1dad31a 100644 --- a/src/c-wrapper/c-types.h +++ b/src/c-wrapper/c-types.h @@ -19,17 +19,27 @@ #ifndef _C_TYPES_H_ #define _C_TYPES_H_ +#define L_DECLARE_ENUM(CLASS, ENUM) enum Linphone ## CLASS ## ENUM +#define L_DECLARE_C_STRUCT(STRUCT) typedef struct _Linphone ## STRUCT Linphone ## STRUCT; + +#include "event-log/event-log-enums.h" + // ============================================================================= #ifdef __cplusplus extern "C" { #endif -#define L_DECLARE_C_STRUCT(STRUCT) typedef struct _Linphone ## STRUCT Linphone ## STRUCT; +// ----------------------------------------------------------------------------- +// Event log. +// ----------------------------------------------------------------------------- -L_DECLARE_C_STRUCT(EventLog) +L_DECLARE_C_STRUCT(EventLog); -#undef L_DECLARE_C_STRUCT +LINPHONE_PUBLIC LinphoneEventLog *event_log_new (); +LINPHONE_PUBLIC LinphoneEventLogType event_log_get_type (const LinphoneEventLog *eventLog); + +// ----------------------------------------------------------------------------- #ifdef __cplusplus } diff --git a/src/db/events-db.cpp b/src/db/events-db.cpp index 60a28c116..284fc3509 100644 --- a/src/db/events-db.cpp +++ b/src/db/events-db.cpp @@ -252,7 +252,7 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} bool EventsDb::addEvent (const EventLog &eventLog) { // TODO. switch (eventLog.getType()) { - case EventLog::None: + case EventLog::NoneEvent: return false; case EventLog::MessageEvent: case EventLog::CallStartEvent: diff --git a/src/event-log/event-log-enums.h b/src/event-log/event-log-enums.h new file mode 100644 index 000000000..1542fdf54 --- /dev/null +++ b/src/event-log/event-log-enums.h @@ -0,0 +1,43 @@ +/* + * event-log-enums.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _EVENT_LOG_ENUMS_H_ +#define _EVENT_LOG_ENUMS_H_ + +#include "utils/general.h" + +// ============================================================================= + +L_DECLARE_ENUM(EventLog, Type) { + NoneEvent, + // MessageEvent. + MessageEvent, + // CallEvent. + CallStartEvent, + CallEndEvent, + // ConferenceEvent. + ConferenceCreatedEvent, + ConferenceDestroyedEvent, + // ConferenceParticipantEvent. + ConferenceParticipantAddedEvent, + ConferenceParticipantRemovedEvent, + ConferenceParticipantSetAdminEvent, + ConferenceParticipantUnsetAdminEvent +}; + +#endif // ifndef _EVENT_LOG_ENUMS_H_ diff --git a/src/event-log/event-log-p.h b/src/event-log/event-log-p.h index ce5507a17..e9e266178 100644 --- a/src/event-log/event-log-p.h +++ b/src/event-log/event-log-p.h @@ -28,7 +28,7 @@ LINPHONE_BEGIN_NAMESPACE class EventLogPrivate : public ClonableObjectPrivate { private: - EventLog::Type type = EventLog::None; + EventLog::Type type = EventLog::NoneEvent; L_DECLARE_PUBLIC(EventLog); }; diff --git a/src/event-log/event-log.h b/src/event-log/event-log.h index f83fa85e2..180a09e44 100644 --- a/src/event-log/event-log.h +++ b/src/event-log/event-log.h @@ -29,22 +29,7 @@ class EventLogPrivate; class LINPHONE_PUBLIC EventLog : public ClonableObject { public: - enum Type { - None, - // MessageEvent. - MessageEvent, - // CallEvent. - CallStartEvent, - CallEndEvent, - // ConferenceEvent. - ConferenceCreatedEvent, - ConferenceDestroyedEvent, - // ConferenceParticipantEvent. - ConferenceParticipantAddedEvent, - ConferenceParticipantRemovedEvent, - ConferenceParticipantSetAdminEvent, - ConferenceParticipantUnsetAdminEvent - }; + enum Type : int; EventLog (); EventLog (const EventLog &src); @@ -61,6 +46,8 @@ private: L_DECLARE_PRIVATE(EventLog); }; +#include "event-log-enums.h" + LINPHONE_END_NAMESPACE #endif // ifndef _EVENT_LOG_H_ diff --git a/src/utils/general.h b/src/utils/general.h index 243c7a7ca..2291c43eb 100644 --- a/src/utils/general.h +++ b/src/utils/general.h @@ -22,8 +22,14 @@ // ============================================================================= #define LINPHONE_NAMESPACE LinphonePrivate -#define LINPHONE_BEGIN_NAMESPACE namespace LINPHONE_NAMESPACE { -#define LINPHONE_END_NAMESPACE } + +#ifdef __cplusplus + #define LINPHONE_BEGIN_NAMESPACE namespace LINPHONE_NAMESPACE { + #define LINPHONE_END_NAMESPACE } +#else + #define LINPHONE_BEGIN_NAMESPACE + #define LINPHONE_END_NAMESPACE +#endif // ----------------------------------------------------------------------------- @@ -47,6 +53,12 @@ LINPHONE_BEGIN_NAMESPACE // ----------------------------------------------------------------------------- +#ifdef __cplusplus + +#ifndef L_DECLARE_ENUM + #define L_DECLARE_ENUM(CLASS, ENUM) enum CLASS::ENUM : int +#endif + void l_assert (const char *condition, const char *file, int line); #ifdef DEBUG @@ -117,6 +129,8 @@ inline const Object *getPublicHelper (const T *object, const ObjectPrivate *) { return *this; \ } +#endif + LINPHONE_END_NAMESPACE #endif // ifndef _GENERAL_H_ From a588e18ac21225d6ecba24fede8f5ca55f046f19 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 29 Aug 2017 10:57:42 +0200 Subject: [PATCH 05/11] feat(c-types): EventLog wrapped --- src/c-wrapper/c-types.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/c-wrapper/c-types.cpp b/src/c-wrapper/c-types.cpp index 06f6fcb7d..051c73cf8 100644 --- a/src/c-wrapper/c-types.cpp +++ b/src/c-wrapper/c-types.cpp @@ -54,15 +54,22 @@ extern "C" { FALSE \ ); +#define L_DECLARE_C_STRUCT_NEW_DEFAULT(STRUCT, C_NAME) \ + Linphone ## STRUCT * CNAME ## _new() { \ + Linphone ## STRUCT * object = belle_sip_object_new(Linphone ## STRUCT); \ + return object; \ + } + +// ----------------------------------------------------------------------------- +// Event log. // ----------------------------------------------------------------------------- - L_DECLARE_C_STRUCT_IMPL(EventLog); - -LinphoneEventLog *event_log_new () { - return nullptr; -} +L_DECLARE_C_STRUCT_IMPL(EventLog); +L_DECLARE_C_STRUCT_NEW_DEFAULT(EventLog, event_log) LinphoneEventLogType event_log_get_type (const LinphoneEventLog *eventLog) { - return LinphoneEventLogType::NoneEvent; + return static_cast(eventLog->cppPtr->getType()); } + +// ----------------------------------------------------------------------------- } From c18c265587af6d1a211370fd61613859b5048714 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 29 Aug 2017 11:30:00 +0200 Subject: [PATCH 06/11] feat(c-types): provide init internal functions --- coreapi/private.h | 4 +++- src/c-wrapper/c-types.cpp | 37 +++++++++++++++++++++++++++---------- src/c-wrapper/c-types.h | 15 ++++++++++++--- 3 files changed, 42 insertions(+), 14 deletions(-) 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); // ----------------------------------------------------------------------------- From b5235a14f97bba5c3666af255002e850f01acd69 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 29 Aug 2017 11:38:28 +0200 Subject: [PATCH 07/11] feat(c-types): provide message event interface --- src/c-wrapper/c-types.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/c-wrapper/c-types.cpp b/src/c-wrapper/c-types.cpp index 70e1a41cf..15180d577 100644 --- a/src/c-wrapper/c-types.cpp +++ b/src/c-wrapper/c-types.cpp @@ -16,9 +16,6 @@ * along with this program. If not, see . */ -#include -#include - // From coreapi. #include "private.h" @@ -81,12 +78,17 @@ LinphoneEventLogType event_log_get_type (const LinphoneEventLog *eventLog) { // 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); +L_DECLARE_C_STRUCT_IMPL(MessageEvent, message_event); + +LinphoneMessageEvent *message_event_new (LinphoneMessage *message) { + LinphoneMessageEvent *object = _linphone_message_event_init(); + // TODO: call make_shared with cppPtr. + object->cppPtr = make_shared(nullptr); + return object; +} + +LinphoneMessage *message_event_get_message (const LinphoneMessageEvent *messageEvent) { + // TODO. + return nullptr; +} } From 698a0d520fc2dd41e89ca00ab2913cb95f11a21e Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 29 Aug 2017 13:30:19 +0200 Subject: [PATCH 08/11] feat(c-types): add conference participant event interface --- src/c-wrapper/c-types.h | 16 ++++++++++++++++ src/event-log/conference-event-p.h | 2 +- src/event-log/conference-event.cpp | 9 ++++++--- src/event-log/conference-event.h | 6 +++--- src/event-log/conference-participant-event.cpp | 10 ++++++---- src/event-log/conference-participant-event.h | 6 +++--- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/c-wrapper/c-types.h b/src/c-wrapper/c-types.h index a95e0c4ca..901a0d4c5 100644 --- a/src/c-wrapper/c-types.h +++ b/src/c-wrapper/c-types.h @@ -30,10 +30,26 @@ extern "C" { #endif +L_DECLARE_C_STRUCT(ConferenceParticipantEvent); L_DECLARE_C_STRUCT(EventLog); L_DECLARE_C_STRUCT(Message); L_DECLARE_C_STRUCT(MessageEvent); +// TODO: Remove me in the future. +typedef struct SalAddress LinphoneAddress; + +// ----------------------------------------------------------------------------- +// Conference Participant Event. +// ----------------------------------------------------------------------------- + +LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *conference_participant_event_new ( + LinphoneEventLogType type, + const LinphoneAddress *conferenceAddress, + const LinphoneAddress *participantAddress +); + +LINPHONE_PUBLIC const LinphoneAddress *conference_participant_event_get_participant_address (); + // ----------------------------------------------------------------------------- // Event log. // ----------------------------------------------------------------------------- diff --git a/src/event-log/conference-event-p.h b/src/event-log/conference-event-p.h index 654e2a932..1a44b76b8 100644 --- a/src/event-log/conference-event-p.h +++ b/src/event-log/conference-event-p.h @@ -29,7 +29,7 @@ LINPHONE_BEGIN_NAMESPACE class ConferenceEventPrivate : public EventLogPrivate { private: - std::shared_ptr
address; + std::shared_ptr address; L_DECLARE_PUBLIC(ConferenceEvent); }; diff --git a/src/event-log/conference-event.cpp b/src/event-log/conference-event.cpp index 890a76d54..169e9dfa5 100644 --- a/src/event-log/conference-event.cpp +++ b/src/event-log/conference-event.cpp @@ -26,20 +26,22 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -ConferenceEvent::ConferenceEvent (Type type, const shared_ptr
&address) : +ConferenceEvent::ConferenceEvent (Type type, const shared_ptr &address) : EventLog(*new ConferenceEventPrivate, type) { L_D(ConferenceEvent); L_ASSERT(type == ConferenceCreatedEvent || type == ConferenceDestroyedEvent); L_ASSERT(address); + // TODO: Duplicate address. d->address = address; } ConferenceEvent::ConferenceEvent (const ConferenceEvent &src) : ConferenceEvent(src.getType(), src.getAddress()) {} -ConferenceEvent::ConferenceEvent (ConferenceEventPrivate &p, Type type, const shared_ptr
&address) : +ConferenceEvent::ConferenceEvent (ConferenceEventPrivate &p, Type type, const shared_ptr &address) : EventLog(p, type) { L_D(ConferenceEvent); L_ASSERT(address); + // TODO: Duplicate address. d->address = address; } @@ -47,13 +49,14 @@ ConferenceEvent &ConferenceEvent::operator= (const ConferenceEvent &src) { L_D(ConferenceEvent); if (this != &src) { EventLog::operator=(src); + // TODO: Duplicate address. d->address = src.getPrivate()->address; } return *this; } -shared_ptr
ConferenceEvent::getAddress () const { +shared_ptr ConferenceEvent::getAddress () const { // TODO. return nullptr; } diff --git a/src/event-log/conference-event.h b/src/event-log/conference-event.h index 6bdb10fa0..966af2b2d 100644 --- a/src/event-log/conference-event.h +++ b/src/event-log/conference-event.h @@ -32,16 +32,16 @@ class ConferenceEventPrivate; class LINPHONE_PUBLIC ConferenceEvent : public EventLog { public: - ConferenceEvent (Type type, const std::shared_ptr
&address); + ConferenceEvent (Type type, const std::shared_ptr &address); ConferenceEvent (const ConferenceEvent &src); virtual ~ConferenceEvent () = default; ConferenceEvent &operator= (const ConferenceEvent &src); - std::shared_ptr
getAddress () const; + std::shared_ptr getAddress () const; protected: - ConferenceEvent (ConferenceEventPrivate &p, Type type, const std::shared_ptr
&address); + ConferenceEvent (ConferenceEventPrivate &p, Type type, const std::shared_ptr &address); private: L_DECLARE_PRIVATE(ConferenceEvent); diff --git a/src/event-log/conference-participant-event.cpp b/src/event-log/conference-participant-event.cpp index 5cb0a1ce7..4d3500144 100644 --- a/src/event-log/conference-participant-event.cpp +++ b/src/event-log/conference-participant-event.cpp @@ -28,15 +28,15 @@ LINPHONE_BEGIN_NAMESPACE class ConferenceParticipantEventPrivate : public ConferenceEventPrivate { public: - shared_ptr
participantAddress; + shared_ptr participantAddress; }; // ----------------------------------------------------------------------------- ConferenceParticipantEvent::ConferenceParticipantEvent ( Type type, - const shared_ptr
&conferenceAddress, - const shared_ptr
&participantAddress + const shared_ptr &conferenceAddress, + const shared_ptr &participantAddress ) : ConferenceEvent(*new ConferenceParticipantEventPrivate, type, conferenceAddress) { L_D(ConferenceParticipantEvent); L_ASSERT( @@ -46,6 +46,7 @@ ConferenceParticipantEvent::ConferenceParticipantEvent ( type == ConferenceParticipantUnsetAdminEvent ); L_ASSERT(participantAddress); + // TODO: Duplicate address. d->participantAddress = participantAddress; } @@ -56,13 +57,14 @@ ConferenceParticipantEvent &ConferenceParticipantEvent::operator= (const Confere L_D(ConferenceParticipantEvent); if (this != &src) { ConferenceEvent::operator=(src); + // TODO: Duplicate address. d->participantAddress = src.getPrivate()->participantAddress; } return *this; } -shared_ptr
ConferenceParticipantEvent::getParticipantAddress () const { +shared_ptr ConferenceParticipantEvent::getParticipantAddress () const { // TODO. return nullptr; } diff --git a/src/event-log/conference-participant-event.h b/src/event-log/conference-participant-event.h index 9b65f1002..fbb6514d7 100644 --- a/src/event-log/conference-participant-event.h +++ b/src/event-log/conference-participant-event.h @@ -31,14 +31,14 @@ class LINPHONE_PUBLIC ConferenceParticipantEvent : public ConferenceEvent { public: ConferenceParticipantEvent ( Type type, - const std::shared_ptr
&conferenceAddress, - const std::shared_ptr
&participantAddress + const std::shared_ptr &conferenceAddress, + const std::shared_ptr &participantAddress ); ConferenceParticipantEvent (const ConferenceParticipantEvent &src); ConferenceParticipantEvent &operator= (const ConferenceParticipantEvent &src); - std::shared_ptr
getParticipantAddress () const; + std::shared_ptr getParticipantAddress () const; private: L_DECLARE_PRIVATE(ConferenceParticipantEvent); From 9467d6819f76193ca4d096889a3ccc32063d528b Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 29 Aug 2017 13:35:11 +0200 Subject: [PATCH 09/11] feat(c-types): add conference event interface --- src/c-wrapper/c-types.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/c-wrapper/c-types.h b/src/c-wrapper/c-types.h index 901a0d4c5..a8dfd78f7 100644 --- a/src/c-wrapper/c-types.h +++ b/src/c-wrapper/c-types.h @@ -30,6 +30,7 @@ extern "C" { #endif +L_DECLARE_C_STRUCT(ConferenceEvent); L_DECLARE_C_STRUCT(ConferenceParticipantEvent); L_DECLARE_C_STRUCT(EventLog); L_DECLARE_C_STRUCT(Message); @@ -38,6 +39,17 @@ L_DECLARE_C_STRUCT(MessageEvent); // TODO: Remove me in the future. typedef struct SalAddress LinphoneAddress; +// ----------------------------------------------------------------------------- +// Conference Event. +// ----------------------------------------------------------------------------- + +LINPHONE_PUBLIC LinphoneConferenceEvent *conference_event_new ( + LinphoneEventLogType type, + const LinphoneAddress *address +); + +LINPHONE_PUBLIC const LinphoneAddress *conference_event_get_address (); + // ----------------------------------------------------------------------------- // Conference Participant Event. // ----------------------------------------------------------------------------- From a0f5602b1f04aeb5f67385d4f6027aa1c21607f9 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 29 Aug 2017 13:42:55 +0200 Subject: [PATCH 10/11] feat(c-types): add call event interface --- src/c-wrapper/c-types.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/c-wrapper/c-types.h b/src/c-wrapper/c-types.h index a8dfd78f7..d564aee72 100644 --- a/src/c-wrapper/c-types.h +++ b/src/c-wrapper/c-types.h @@ -19,6 +19,7 @@ #ifndef _C_TYPES_H_ #define _C_TYPES_H_ +// Do not move these defines. #define L_DECLARE_ENUM(CLASS, ENUM) enum Linphone ## CLASS ## ENUM #define L_DECLARE_C_STRUCT(STRUCT) typedef struct _Linphone ## STRUCT Linphone ## STRUCT; @@ -30,6 +31,8 @@ extern "C" { #endif +L_DECLARE_C_STRUCT(Call); +L_DECLARE_C_STRUCT(CallEvent); L_DECLARE_C_STRUCT(ConferenceEvent); L_DECLARE_C_STRUCT(ConferenceParticipantEvent); L_DECLARE_C_STRUCT(EventLog); @@ -39,6 +42,13 @@ L_DECLARE_C_STRUCT(MessageEvent); // TODO: Remove me in the future. typedef struct SalAddress LinphoneAddress; +// ----------------------------------------------------------------------------- +// Call Event. +// ----------------------------------------------------------------------------- + +LINPHONE_PUBLIC LinphoneCallEvent *call_event_new (LinphoneEventLogType type, LinphoneCall *call); +LINPHONE_PUBLIC LinphoneCall *call_event_get_call (const LinphoneCallEvent *call_event); + // ----------------------------------------------------------------------------- // Conference Event. // ----------------------------------------------------------------------------- From 78f8cfd4bfa5f7f9686d05c3999dd3fd37728d31 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 29 Aug 2017 14:24:59 +0200 Subject: [PATCH 11/11] feat(c-wrapper): refactoring --- src/CMakeLists.txt | 4 +- src/c-wrapper/api/c-event-log.cpp | 49 +++++++++++++++++++++++ src/c-wrapper/api/c-event-log.h | 50 ++++++++++++++++++++++++ src/c-wrapper/{c-types.cpp => c-tools.h} | 45 +++------------------ src/c-wrapper/c-types.h | 46 ---------------------- 5 files changed, 108 insertions(+), 86 deletions(-) create mode 100644 src/c-wrapper/api/c-event-log.cpp create mode 100644 src/c-wrapper/api/c-event-log.h rename src/c-wrapper/{c-types.cpp => c-tools.h} (63%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7f2a446e5..1d6327254 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,8 @@ ############################################################################ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES + c-wrapper/api/c-event-log.h + c-wrapper/c-tools.h c-wrapper/c-types.h content/content.h core/core.h @@ -59,7 +61,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES ) set(LINPHONE_CXX_OBJECTS_SOURCE_FILES - c-wrapper/c-types.cpp + c-wrapper/api/c-event-log.cpp content/content.cpp core/core.cpp cpim/header/cpim-core-headers.cpp diff --git a/src/c-wrapper/api/c-event-log.cpp b/src/c-wrapper/api/c-event-log.cpp new file mode 100644 index 000000000..c246aef3d --- /dev/null +++ b/src/c-wrapper/api/c-event-log.cpp @@ -0,0 +1,49 @@ +/* + * c-event-log.cpp + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "c-wrapper/c-tools.h" + +#include "c-event-log.h" + +#include "event-log/message-event.h" + +// ============================================================================= + +using namespace std; + + +L_DECLARE_C_STRUCT_IMPL(EventLog, event_log); +L_DECLARE_C_STRUCT_NEW_DEFAULT(EventLog, event_log); + +LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *eventLog) { + return static_cast(eventLog->cppPtr->getType()); +} + +L_DECLARE_C_STRUCT_IMPL(MessageEvent, message_event); + +LinphoneMessageEvent *linphone_message_event_new (LinphoneMessage *message) { + LinphoneMessageEvent *object = _linphone_message_event_init(); + // TODO: call make_shared with cppPtr. + object->cppPtr = make_shared(nullptr); + return object; +} + +LinphoneMessage *linphone_message_event_get_message (const LinphoneMessageEvent *messageEvent) { + // TODO. + return nullptr; +} diff --git a/src/c-wrapper/api/c-event-log.h b/src/c-wrapper/api/c-event-log.h new file mode 100644 index 000000000..38eea75aa --- /dev/null +++ b/src/c-wrapper/api/c-event-log.h @@ -0,0 +1,50 @@ +/* + * c-event-log.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _C_EVENT_LOG_H_ +#define _C_EVENT_LOG_H_ + +#include "c-wrapper/c-types.h" + +// ============================================================================= + +LINPHONE_PUBLIC LinphoneEventLog *linphone_event_log_new (); +LINPHONE_PUBLIC LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *event_log); + +LINPHONE_PUBLIC LinphoneCallEvent *linphone_call_event_new (LinphoneEventLogType type, LinphoneCall *call); +LINPHONE_PUBLIC LinphoneCall *linphone_call_event_get_call (const LinphoneCallEvent *call_event); + +LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_new ( + LinphoneEventLogType type, + const LinphoneAddress *address +); + +LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_event_get_address (); + +LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_participant_event_new ( + LinphoneEventLogType type, + const LinphoneAddress *conferenceAddress, + const LinphoneAddress *participantAddress +); + +LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_participant_event_get_participant_address (); + +LINPHONE_PUBLIC LinphoneMessageEvent *linphone_message_event_new (LinphoneMessage *message); +LINPHONE_PUBLIC LinphoneMessage *linphone_message_event_get_message (const LinphoneMessageEvent *message_event); + +#endif // ifndef _C_EVENT_LOG_H_ diff --git a/src/c-wrapper/c-types.cpp b/src/c-wrapper/c-tools.h similarity index 63% rename from src/c-wrapper/c-types.cpp rename to src/c-wrapper/c-tools.h index 15180d577..1a4c23db3 100644 --- a/src/c-wrapper/c-types.cpp +++ b/src/c-wrapper/c-tools.h @@ -1,5 +1,5 @@ /* - * types.cpp + * c-tools.h * Copyright (C) 2017 Belledonne Communications SARL * * This program is free software: you can redistribute it and/or modify @@ -16,19 +16,14 @@ * along with this program. If not, see . */ +#ifndef _C_TOOLS_H_ +#define _C_TOOLS_H_ + // From coreapi. #include "private.h" -// Must be included before cpp headers. -#include "c-types.h" +// ============================================================================= -#include "event-log/message-event.h" - -// ================================================================²============= - -using namespace std; - -extern "C" { #define L_DECLARE_C_STRUCT_IMPL(STRUCT, C_NAME) \ struct _Linphone ## STRUCT { \ belle_sip_object_t base; \ @@ -63,32 +58,4 @@ extern "C" { return object; \ } -// ----------------------------------------------------------------------------- -// 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 = _linphone_message_event_init(); - // TODO: call make_shared with cppPtr. - object->cppPtr = make_shared(nullptr); - return object; -} - -LinphoneMessage *message_event_get_message (const LinphoneMessageEvent *messageEvent) { - // TODO. - return nullptr; -} -} +#endif // ifndef _C_TOOLS_H_ diff --git a/src/c-wrapper/c-types.h b/src/c-wrapper/c-types.h index d564aee72..51ff9cfe2 100644 --- a/src/c-wrapper/c-types.h +++ b/src/c-wrapper/c-types.h @@ -42,52 +42,6 @@ L_DECLARE_C_STRUCT(MessageEvent); // TODO: Remove me in the future. typedef struct SalAddress LinphoneAddress; -// ----------------------------------------------------------------------------- -// Call Event. -// ----------------------------------------------------------------------------- - -LINPHONE_PUBLIC LinphoneCallEvent *call_event_new (LinphoneEventLogType type, LinphoneCall *call); -LINPHONE_PUBLIC LinphoneCall *call_event_get_call (const LinphoneCallEvent *call_event); - -// ----------------------------------------------------------------------------- -// Conference Event. -// ----------------------------------------------------------------------------- - -LINPHONE_PUBLIC LinphoneConferenceEvent *conference_event_new ( - LinphoneEventLogType type, - const LinphoneAddress *address -); - -LINPHONE_PUBLIC const LinphoneAddress *conference_event_get_address (); - -// ----------------------------------------------------------------------------- -// Conference Participant Event. -// ----------------------------------------------------------------------------- - -LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *conference_participant_event_new ( - LinphoneEventLogType type, - const LinphoneAddress *conferenceAddress, - const LinphoneAddress *participantAddress -); - -LINPHONE_PUBLIC const LinphoneAddress *conference_participant_event_get_participant_address (); - -// ----------------------------------------------------------------------------- -// Event log. -// ----------------------------------------------------------------------------- - -LINPHONE_PUBLIC LinphoneEventLog *event_log_new (); -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); - -// ----------------------------------------------------------------------------- - #ifdef __cplusplus } #endif