Merge remote-tracking branch 'origin/master' into dev_conference_info

This commit is contained in:
Benjamin Reis 2017-08-29 15:53:05 +02:00
commit 5c230daade
23 changed files with 395 additions and 126 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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<LinphoneEventLogType>(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<LINPHONE_NAMESPACE::MessageEvent>(nullptr);
return object;
}
LinphoneMessage *linphone_message_event_get_message (const LinphoneMessageEvent *messageEvent) {
// TODO.
return nullptr;
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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_

61
src/c-wrapper/c-tools.h Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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<LINPHONE_NAMESPACE::STRUCT> 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<LINPHONE_NAMESPACE::STRUCT>(); \
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<LINPHONE_NAMESPACE::STRUCT>(); \
dest->cppPtr = make_shared<LINPHONE_NAMESPACE::STRUCT>(*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<LINPHONE_NAMESPACE::STRUCT>(); \
return object; \
}
#endif // ifndef _C_TOOLS_H_

49
src/c-wrapper/c-types.h Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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_

View file

@ -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<Event> EventsDb::getHistory (const string &remoteAddress, int nLast, FilterMask mask) const {
list<shared_ptr<EventLog>> EventsDb::getHistory (const string &remoteAddress, int nLast, FilterMask mask) const {
// TODO.
(void)remoteAddress;
(void)nLast;
(void)mask;
return list<Event>();
return list<shared_ptr<EventLog>>();
}
list<Event> EventsDb::getHistory (const string &remoteAddress, int begin, int end, FilterMask mask) const {
list<shared_ptr<EventLog>> EventsDb::getHistory (const string &remoteAddress, int begin, int end, FilterMask mask) const {
// TODO.
(void)remoteAddress;
(void)begin;
(void)end;
(void)mask;
return list<Event>();
return list<shared_ptr<EventLog>>();
}
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<Event> EventsDb::getHistory (const string &, int, FilterMask) const {
return list<Event>();
list<shared_ptr<EventLog>> EventsDb::getHistory (const string &, int, FilterMask) const {
return list<shared_ptr<EventLog>>();
}
list<Event> EventsDb::getHistory (const string &, int, int, FilterMask) const {
return list<Event>();
list<shared_ptr<EventLog>> EventsDb::getHistory (const string &, int, int, FilterMask) const {
return list<shared_ptr<EventLog>>();
}
void EventsDb::cleanHistory (const string &) {}

View file

@ -20,6 +20,7 @@
#define _EVENTS_DB_H_
#include <list>
#include <memory>
#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<Event> getHistory (const std::string &remoteAddress, int nLast, FilterMask mask = NoFilter) const;
std::list<Event> getHistory (const std::string &remoteAddress, int begin, int end, FilterMask mask = NoFilter) const;
std::list<std::shared_ptr<EventLog> > getHistory (const std::string &remoteAddress, int nLast, FilterMask mask = NoFilter) const;
std::list<std::shared_ptr<EventLog> > getHistory (const std::string &remoteAddress, int begin, int end, FilterMask mask = NoFilter) const;
void cleanHistory (const std::string &remoteAddress = "");
protected:

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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> call;
};
// -----------------------------------------------------------------------------
CallEvent::CallEvent (Type type, const shared_ptr<Call> &call) : Event(*new CallEventPrivate, type) {
CallEvent::CallEvent (Type type, const shared_ptr<Call> &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;
}

View file

@ -21,7 +21,7 @@
#include <memory>
#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<Call> &message);
CallEvent (const CallEvent &src);

View file

@ -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> address;
std::shared_ptr<const Address> address;
L_DECLARE_PUBLIC(ConferenceEvent);
};

View file

@ -26,34 +26,37 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
ConferenceEvent::ConferenceEvent (Type type, const shared_ptr<Address> &address) :
Event(*new ConferenceEventPrivate, type) {
ConferenceEvent::ConferenceEvent (Type type, const shared_ptr<const Address> &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> &address) :
Event(p, type) {
ConferenceEvent::ConferenceEvent (ConferenceEventPrivate &p, Type type, const shared_ptr<const Address> &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<Address> ConferenceEvent::getAddress () const {
shared_ptr<const Address> ConferenceEvent::getAddress () const {
// TODO.
return nullptr;
}

View file

@ -21,7 +21,7 @@
#include <memory>
#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> &address);
ConferenceEvent (Type type, const std::shared_ptr<const Address> &address);
ConferenceEvent (const ConferenceEvent &src);
virtual ~ConferenceEvent () = default;
ConferenceEvent &operator= (const ConferenceEvent &src);
std::shared_ptr<Address> getAddress () const;
std::shared_ptr<const Address> getAddress () const;
protected:
ConferenceEvent (ConferenceEventPrivate &p, Type type, const std::shared_ptr<Address> &address);
ConferenceEvent (ConferenceEventPrivate &p, Type type, const std::shared_ptr<const Address> &address);
private:
L_DECLARE_PRIVATE(ConferenceEvent);

View file

@ -28,15 +28,15 @@ LINPHONE_BEGIN_NAMESPACE
class ConferenceParticipantEventPrivate : public ConferenceEventPrivate {
public:
shared_ptr<Address> participantAddress;
shared_ptr<const Address> participantAddress;
};
// -----------------------------------------------------------------------------
ConferenceParticipantEvent::ConferenceParticipantEvent (
Type type,
const shared_ptr<Address> &conferenceAddress,
const shared_ptr<Address> &participantAddress
const shared_ptr<const Address> &conferenceAddress,
const shared_ptr<const Address> &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<Address> ConferenceParticipantEvent::getParticipantAddress () const {
shared_ptr<const Address> ConferenceParticipantEvent::getParticipantAddress () const {
// TODO.
return nullptr;
}

View file

@ -31,14 +31,14 @@ class LINPHONE_PUBLIC ConferenceParticipantEvent : public ConferenceEvent {
public:
ConferenceParticipantEvent (
Type type,
const std::shared_ptr<Address> &conferenceAddress,
const std::shared_ptr<Address> &participantAddress
const std::shared_ptr<const Address> &conferenceAddress,
const std::shared_ptr<const Address> &participantAddress
);
ConferenceParticipantEvent (const ConferenceParticipantEvent &src);
ConferenceParticipantEvent &operator= (const ConferenceParticipantEvent &src);
std::shared_ptr<Address> getParticipantAddress () const;
std::shared_ptr<const Address> getParticipantAddress () const;
private:
L_DECLARE_PRIVATE(ConferenceParticipantEvent);

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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_

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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_

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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;
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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_

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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> message;
};
// -----------------------------------------------------------------------------
MessageEvent::MessageEvent (const shared_ptr<Message> &message) : Event(*new MessageEventPrivate, Event::MessageEvent) {
MessageEvent::MessageEvent (const shared_ptr<Message> &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;
}

View file

@ -21,7 +21,7 @@
#include <memory>
#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> &message);
MessageEvent (const MessageEvent &src);

View file

@ -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_