diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index a89923637..bcca4c19f 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1032,6 +1032,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); } diff --git a/coreapi/private.h b/coreapi/private.h index 83d1d14c2..8d4c02c1a 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1890,7 +1890,10 @@ 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_TYPE_ID(LinphoneMessage), +BELLE_SIP_TYPE_ID(LinphoneMessageEvent) BELLE_SIP_DECLARE_TYPES_END diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 679599314..15a31caf2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,9 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES conference/conference-listener.h conference/local-conference-event-handler.h conference/remote-conference-event-handler.h + c-wrapper/api/c-event-log.h + c-wrapper/c-tools.h + c-wrapper/c-types.h content/content.h core/core.h cpim/cpim.h @@ -41,12 +44,14 @@ 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-enums.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 @@ -63,6 +68,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES set(LINPHONE_CXX_OBJECTS_SOURCE_FILES conference/local-conference-event-handler.cpp conference/remote-conference-event-handler.cpp + c-wrapper/api/c-event-log.cpp content/content.cpp core/core.cpp cpim/header/cpim-core-headers.cpp @@ -75,11 +81,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/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-tools.h b/src/c-wrapper/c-tools.h new file mode 100644 index 000000000..1a4c23db3 --- /dev/null +++ b/src/c-wrapper/c-tools.h @@ -0,0 +1,61 @@ +/* + * c-tools.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_TOOLS_H_ +#define _C_TOOLS_H_ + +// From coreapi. +#include "private.h" + +// ============================================================================= + +#define L_DECLARE_C_STRUCT_IMPL(STRUCT, C_NAME) \ + struct _Linphone ## STRUCT { \ + belle_sip_object_t base; \ + shared_ptr cppPtr; \ + }; \ + 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_ ## 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_NO_IMPLEMENTED_INTERFACES(Linphone ## STRUCT); \ + BELLE_SIP_INSTANCIATE_VPTR(Linphone ## STRUCT, belle_sip_object_t, \ + _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 = _linphone_ ## C_NAME ## _init(); \ + object->cppPtr = make_shared(); \ + return object; \ + } + +#endif // ifndef _C_TOOLS_H_ diff --git a/src/c-wrapper/c-types.h b/src/c-wrapper/c-types.h new file mode 100644 index 000000000..51ff9cfe2 --- /dev/null +++ b/src/c-wrapper/c-types.h @@ -0,0 +1,49 @@ +/* + * 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_ + +// 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; + +#include "event-log/event-log-enums.h" + +// ============================================================================= + +#ifdef __cplusplus + 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); +L_DECLARE_C_STRUCT(Message); +L_DECLARE_C_STRUCT(MessageEvent); + +// TODO: Remove me in the future. +typedef struct SalAddress LinphoneAddress; + +#ifdef __cplusplus + } +#endif + +#endif // ifndef _C_TYPES_H_ diff --git a/src/db/events-db.cpp b/src/db/events-db.cpp index d6c90fb29..284fc3509 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::NoneEvent: 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 89% rename from src/event/conference-event-p.h rename to src/event-log/conference-event-p.h index d4fcd9b65..1a44b76b8 100644 --- a/src/event/conference-event-p.h +++ b/src/event-log/conference-event-p.h @@ -21,15 +21,15 @@ #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; + std::shared_ptr address; L_DECLARE_PUBLIC(ConferenceEvent); }; diff --git a/src/event/conference-event.cpp b/src/event-log/conference-event.cpp similarity index 80% rename from src/event/conference-event.cpp rename to src/event-log/conference-event.cpp index a75d22657..169e9dfa5 100644 --- a/src/event/conference-event.cpp +++ b/src/event-log/conference-event.cpp @@ -26,34 +26,37 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -ConferenceEvent::ConferenceEvent (Type type, const shared_ptr
&address) : - Event(*new ConferenceEventPrivate, type) { +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) : - Event(p, type) { +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; } ConferenceEvent &ConferenceEvent::operator= (const ConferenceEvent &src) { L_D(ConferenceEvent); if (this != &src) { - Event::operator=(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/conference-event.h b/src/event-log/conference-event.h similarity index 83% rename from src/event/conference-event.h rename to src/event-log/conference-event.h index 5a499b215..966af2b2d 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,18 +30,18 @@ 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 (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/conference-participant-event.cpp b/src/event-log/conference-participant-event.cpp similarity index 87% rename from src/event/conference-participant-event.cpp rename to src/event-log/conference-participant-event.cpp index 5cb0a1ce7..4d3500144 100644 --- a/src/event/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/conference-participant-event.h b/src/event-log/conference-participant-event.h similarity index 88% rename from src/event/conference-participant-event.h rename to src/event-log/conference-participant-event.h index 9b65f1002..fbb6514d7 100644 --- a/src/event/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); 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/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..e9e266178 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::NoneEvent; - 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 57% rename from src/event/event.h rename to src/event-log/event-log.h index ebd530a4b..180a09e44 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,42 +25,29 @@ LINPHONE_BEGIN_NAMESPACE -class EventPrivate; +class EventLogPrivate; -class LINPHONE_PUBLIC Event : public ClonableObject { +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; - 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); }; +#include "event-log-enums.h" + 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); 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_