Commit a97c0484 authored by Ronan's avatar Ronan

feat(EventLog): refactoring, use IdentityAddress and rename time arg

parent 902cb501
......@@ -55,11 +55,11 @@ LINPHONE_PUBLIC void linphone_event_log_unref (LinphoneEventLog *event_log);
LINPHONE_PUBLIC LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *event_log);
/**
* Returns the time of a event log.
* Returns the creation time of a event log.
* @param[in] event_log A #LinphoneEventLog object
* @return The event time
* @return The event creation time
*/
LINPHONE_PUBLIC time_t linphone_event_log_get_time (const LinphoneEventLog *event_log);
LINPHONE_PUBLIC time_t linphone_event_log_get_creation_time (const LinphoneEventLog *event_log);
// -----------------------------------------------------------------------------
// ConferenceEvent.
......@@ -121,11 +121,11 @@ LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_participant_addres
// -----------------------------------------------------------------------------
/**
* Returns the gruu address of a conference participant device event.
* Returns the device address of a conference participant device event.
* @param[in] event_log A #LinphoneEventLog object.
* @return The conference gruu address.
* @return The conference device address.
*/
LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_gruu_address (const LinphoneEventLog *event_log);
LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_device_address (const LinphoneEventLog *event_log);
// -----------------------------------------------------------------------------
// ConferenceSubjectEvent.
......
......@@ -26,10 +26,31 @@
// =============================================================================
L_DECLARE_C_OBJECT_IMPL(EventLog);
using namespace std;
static void _linphone_event_log_constructor (LinphoneEventLog *event_log);
static void _linphone_event_log_destructor (LinphoneEventLog *event_log);
L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(
EventLog,
_linphone_event_log_constructor,
_linphone_event_log_destructor,
mutable LinphoneAddress *conferenceAddressCache;
mutable LinphoneAddress *participantAddressCache;
mutable LinphoneAddress *deviceAddressCache;
);
void _linphone_event_log_constructor (LinphoneEventLog *) {}
void _linphone_event_log_destructor (LinphoneEventLog *event_log) {
if (event_log->conferenceAddressCache)
linphone_address_unref(event_log->conferenceAddressCache);
if (event_log->participantAddressCache)
linphone_address_unref(event_log->participantAddressCache);
if (event_log->deviceAddressCache)
linphone_address_unref(event_log->deviceAddressCache);
}
// -----------------------------------------------------------------------------
// Helpers.
// -----------------------------------------------------------------------------
......@@ -161,8 +182,8 @@ LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *event_
);
}
time_t linphone_event_log_get_time (const LinphoneEventLog *event_log) {
return L_GET_CPP_PTR_FROM_C_OBJECT(event_log)->getTime();
time_t linphone_event_log_get_creation_time (const LinphoneEventLog *event_log) {
return L_GET_CPP_PTR_FROM_C_OBJECT(event_log)->getCreationTime();
}
// -----------------------------------------------------------------------------
......@@ -173,11 +194,14 @@ const LinphoneAddress *linphone_event_log_get_conference_address (const Linphone
if (!isConferenceType(linphone_event_log_get_type(event_log)))
return nullptr;
return L_GET_C_BACK_PTR(
&static_pointer_cast<const LinphonePrivate::ConferenceEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
)->getConferenceAddress()
);
if (!event_log->conferenceAddressCache)
event_log->conferenceAddressCache = linphone_address_new(
static_pointer_cast<const LinphonePrivate::ConferenceEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
)->getConferenceAddress().asString().c_str()
);
return event_log->conferenceAddressCache;
}
// -----------------------------------------------------------------------------
......@@ -231,26 +255,32 @@ const LinphoneAddress *linphone_event_log_get_participant_address (const Linphon
if (!isConferenceParticipantType(linphone_event_log_get_type(event_log)))
return nullptr;
return L_GET_C_BACK_PTR(
&static_pointer_cast<const LinphonePrivate::ConferenceParticipantEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
)->getParticipantAddress()
);
if (!event_log->participantAddressCache)
event_log->participantAddressCache = linphone_address_new(
static_pointer_cast<const LinphonePrivate::ConferenceParticipantEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
)->getParticipantAddress().asString().c_str()
);
return event_log->participantAddressCache;
}
// -----------------------------------------------------------------------------
// ConferenceParticipantDeviceEvent.
// -----------------------------------------------------------------------------
const LinphoneAddress *linphone_event_log_get_gruu_address (const LinphoneEventLog *event_log) {
const LinphoneAddress *linphone_event_log_get_device_address (const LinphoneEventLog *event_log) {
if (!isConferenceParticipantDeviceType(linphone_event_log_get_type(event_log)))
return nullptr;
return L_GET_C_BACK_PTR(
&static_pointer_cast<const LinphonePrivate::ConferenceParticipantDeviceEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
)->getGruuAddress()
);
if (!event_log->deviceAddressCache)
event_log->deviceAddressCache = linphone_address_new(
static_pointer_cast<const LinphonePrivate::ConferenceParticipantDeviceEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
)->getDeviceAddress().asString().c_str()
);
return event_log->deviceAddressCache;
}
// -----------------------------------------------------------------------------
......
......@@ -613,7 +613,7 @@ LINPHONE_END_NAMESPACE
CONSTRUCTOR(object); \
return object; \
} \
static void _linphone_ ## C_TYPE ## _uninit(Linphone ## C_TYPE * object) { \
static void _linphone_ ## C_TYPE ## _uninit(Linphone ## C_TYPE *object) { \
DESTRUCTOR(object); \
LinphonePrivate::Wrapper::uninitBaseCppObject(object); \
} \
......
......@@ -385,7 +385,7 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (const shared_ptr<ConferenceP
lWarning() << "Participant " << participant << " added a device but is not in the list of participants!";
return;
}
participant->getPrivate()->addDevice(event->getGruuAddress());
participant->getPrivate()->addDevice(event->getDeviceAddress());
if (isFullState)
return;
......@@ -412,7 +412,7 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (const shared_ptr<Conferenc
lWarning() << "Participant " << participant << " removed a device but is not in the list of participants!";
return;
}
participant->getPrivate()->removeDevice(event->getGruuAddress());
participant->getPrivate()->removeDevice(event->getDeviceAddress());
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
LinphoneChatRoomCbsParticipantDeviceRemovedCb cb = linphone_chat_room_cbs_get_participant_device_removed(cbs);
......
......@@ -26,6 +26,8 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
class ConferenceCallEventPrivate : public EventLogPrivate {
public:
shared_ptr<Call> call;
......@@ -33,8 +35,8 @@ public:
// -----------------------------------------------------------------------------
ConferenceCallEvent::ConferenceCallEvent (Type type, time_t time, const shared_ptr<Call> &call) :
EventLog(*new ConferenceCallEventPrivate, type, time) {
ConferenceCallEvent::ConferenceCallEvent (Type type, time_t creationTime, const shared_ptr<Call> &call) :
EventLog(*new ConferenceCallEventPrivate, type, creationTime) {
L_D();
L_ASSERT(call);
L_ASSERT(type == Type::ConferenceCallStart || type == Type::ConferenceCallEnd);
......
......@@ -33,7 +33,7 @@ class ConferenceCallEventPrivate;
class LINPHONE_PUBLIC ConferenceCallEvent : public EventLog {
public:
ConferenceCallEvent (Type type, time_t time, const std::shared_ptr<Call> &call);
ConferenceCallEvent (Type type, time_t creationTime, const std::shared_ptr<Call> &call);
std::shared_ptr<Call> getCall () const;
......
......@@ -27,6 +27,8 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
class ConferenceChatMessageEventPrivate : public ConferenceEventPrivate {
public:
shared_ptr<ChatMessage> chatMessage;
......@@ -35,12 +37,12 @@ public:
// -----------------------------------------------------------------------------
ConferenceChatMessageEvent::ConferenceChatMessageEvent (
time_t time,
time_t creationTime,
const shared_ptr<ChatMessage> &chatMessage
) : ConferenceEvent(
*new ConferenceChatMessageEventPrivate,
EventLog::Type::ConferenceChatMessage,
time,
creationTime,
chatMessage->getRemoteAddress()
) {
L_D();
......
......@@ -33,7 +33,7 @@ class ConferenceChatMessageEventPrivate;
class LINPHONE_PUBLIC ConferenceChatMessageEvent : public ConferenceEvent {
public:
ConferenceChatMessageEvent (time_t time, const std::shared_ptr<ChatMessage> &chatMessage);
ConferenceChatMessageEvent (time_t creationTime, const std::shared_ptr<ChatMessage> &chatMessage);
std::shared_ptr<ChatMessage> getChatMessage () const;
......
......@@ -20,7 +20,7 @@
#ifndef _CONFERENCE_EVENT_P_H_
#define _CONFERENCE_EVENT_P_H_
#include "address/address.h"
#include "address/identity-address.h"
#include "conference-event.h"
#include "event-log/event-log-p.h"
......@@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE
class ConferenceEventPrivate : public EventLogPrivate {
private:
Address conferenceAddress;
IdentityAddress conferenceAddress;
L_DECLARE_PUBLIC(ConferenceEvent);
};
......
......@@ -17,7 +17,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "address/address.h"
#include "conference-event-p.h"
// =============================================================================
......@@ -26,8 +25,10 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
ConferenceEvent::ConferenceEvent (Type type, time_t time, const Address &conferenceAddress) :
EventLog(*new ConferenceEventPrivate, type, time) {
// -----------------------------------------------------------------------------
ConferenceEvent::ConferenceEvent (Type type, time_t creationTime, const IdentityAddress &conferenceAddress) :
EventLog(*new ConferenceEventPrivate, type, creationTime) {
L_D();
L_ASSERT(type == Type::ConferenceCreated || type == Type::ConferenceDestroyed);
d->conferenceAddress = conferenceAddress;
......@@ -36,14 +37,14 @@ ConferenceEvent::ConferenceEvent (Type type, time_t time, const Address &confere
ConferenceEvent::ConferenceEvent (
ConferenceEventPrivate &p,
Type type,
time_t time,
const Address &conferenceAddress
) : EventLog(p, type, time) {
time_t creationTime,
const IdentityAddress &conferenceAddress
) : EventLog(p, type, creationTime) {
L_D();
d->conferenceAddress = conferenceAddress;
}
const Address &ConferenceEvent::getConferenceAddress () const {
const IdentityAddress &ConferenceEvent::getConferenceAddress () const {
L_D();
return d->conferenceAddress;
}
......
......@@ -26,17 +26,17 @@
LINPHONE_BEGIN_NAMESPACE
class Address;
class ConferenceEventPrivate;
class IdentityAddress;
class LINPHONE_PUBLIC ConferenceEvent : public EventLog {
public:
ConferenceEvent (Type type, time_t time, const Address &conferenceAddress);
ConferenceEvent (Type type, time_t creationTime, const IdentityAddress &conferenceAddress);
const Address &getConferenceAddress () const;
const IdentityAddress &getConferenceAddress () const;
protected:
ConferenceEvent (ConferenceEventPrivate &p, Type type, time_t time, const Address &conferenceAddress);
ConferenceEvent (ConferenceEventPrivate &p, Type type, time_t creationTime, const IdentityAddress &conferenceAddress);
private:
L_DECLARE_PRIVATE(ConferenceEvent);
......
......@@ -29,10 +29,10 @@ LINPHONE_BEGIN_NAMESPACE
ConferenceNotifiedEvent::ConferenceNotifiedEvent (
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId
) : ConferenceEvent(*new ConferenceNotifiedEventPrivate, type, time, conferenceAddress) {
) : ConferenceEvent(*new ConferenceNotifiedEventPrivate, type, creationTime, conferenceAddress) {
L_D();
d->notifyId = notifyId;
}
......@@ -40,10 +40,10 @@ ConferenceNotifiedEvent::ConferenceNotifiedEvent (
ConferenceNotifiedEvent::ConferenceNotifiedEvent (
ConferenceNotifiedEventPrivate &p,
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId
) : ConferenceEvent(p, type, time, conferenceAddress) {
) : ConferenceEvent(p, type, creationTime, conferenceAddress) {
L_D();
d->notifyId = notifyId;
}
......
......@@ -31,8 +31,8 @@ class ConferenceNotifiedEventPrivate;
class LINPHONE_PUBLIC ConferenceNotifiedEvent : public ConferenceEvent {
public:
ConferenceNotifiedEvent (
Type type, time_t time,
const Address &conferenceAddress,
Type type, time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifiyId
);
......@@ -42,8 +42,8 @@ protected:
ConferenceNotifiedEvent (
ConferenceNotifiedEventPrivate &p,
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId
);
......
......@@ -26,24 +26,26 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
class ConferenceParticipantDeviceEventPrivate : public ConferenceParticipantEventPrivate {
public:
Address gruuAddress;
IdentityAddress deviceAddress;
};
// -----------------------------------------------------------------------------
ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId,
const Address &participantAddress,
const Address &gruuAddress
const IdentityAddress &participantAddress,
const IdentityAddress &deviceAddress
) : ConferenceParticipantEvent(
*new ConferenceParticipantDeviceEventPrivate,
type,
time,
creationTime,
conferenceAddress,
notifyId,
participantAddress
......@@ -53,12 +55,12 @@ ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (
type == Type::ConferenceParticipantDeviceAdded ||
type == Type::ConferenceParticipantDeviceRemoved
);
d->gruuAddress = gruuAddress;
d->deviceAddress = deviceAddress;
}
const Address &ConferenceParticipantDeviceEvent::getGruuAddress () const {
const IdentityAddress &ConferenceParticipantDeviceEvent::getDeviceAddress () const {
L_D();
return d->gruuAddress;
return d->deviceAddress;
}
LINPHONE_END_NAMESPACE
......@@ -32,14 +32,14 @@ class LINPHONE_PUBLIC ConferenceParticipantDeviceEvent : public ConferencePartic
public:
ConferenceParticipantDeviceEvent (
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId,
const Address &participantAddress,
const Address &gruuAddress
const IdentityAddress &participantAddress,
const IdentityAddress &deviceAddress
);
const Address &getGruuAddress () const;
const IdentityAddress &getDeviceAddress () const;
private:
L_DECLARE_PRIVATE(ConferenceParticipantDeviceEvent);
......
......@@ -29,7 +29,7 @@ LINPHONE_BEGIN_NAMESPACE
class ConferenceParticipantEventPrivate : public ConferenceNotifiedEventPrivate {
private:
Address participantAddress;
IdentityAddress participantAddress;
L_DECLARE_PUBLIC(ConferenceParticipantEvent);
};
......
......@@ -29,14 +29,14 @@ LINPHONE_BEGIN_NAMESPACE
ConferenceParticipantEvent::ConferenceParticipantEvent (
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId,
const Address &participantAddress
const IdentityAddress &participantAddress
) : ConferenceNotifiedEvent(
*new ConferenceParticipantEventPrivate,
type,
time,
creationTime,
conferenceAddress,
notifyId
) {
......@@ -53,14 +53,14 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
ConferenceParticipantEvent::ConferenceParticipantEvent (
ConferenceParticipantEventPrivate &p,
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId,
const Address &participantAddress
const IdentityAddress &participantAddress
) : ConferenceNotifiedEvent(
p,
type,
time,
creationTime,
conferenceAddress,
notifyId
) {
......@@ -68,7 +68,7 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
d->participantAddress = participantAddress;
}
const Address &ConferenceParticipantEvent::getParticipantAddress () const {
const IdentityAddress &ConferenceParticipantEvent::getParticipantAddress () const {
L_D();
return d->participantAddress;
}
......
......@@ -32,22 +32,22 @@ class LINPHONE_PUBLIC ConferenceParticipantEvent : public ConferenceNotifiedEven
public:
ConferenceParticipantEvent (
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId,
const Address &participantAddress
const IdentityAddress &participantAddress
);
const Address &getParticipantAddress () const;
const IdentityAddress &getParticipantAddress () const;
protected:
ConferenceParticipantEvent (
ConferenceParticipantEventPrivate &p,
Type type,
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId,
const Address &participantAddress
const IdentityAddress &participantAddress
);
private:
......
......@@ -26,6 +26,8 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
class ConferenceSubjectEventPrivate : public ConferenceNotifiedEventPrivate {
public:
string subject;
......@@ -34,14 +36,14 @@ public:
// -----------------------------------------------------------------------------
ConferenceSubjectEvent::ConferenceSubjectEvent (
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId,
const string &subject
) : ConferenceNotifiedEvent(
*new ConferenceSubjectEventPrivate,
Type::ConferenceSubjectChanged,
time,
creationTime,
conferenceAddress,
notifyId
) {
......
......@@ -33,8 +33,8 @@ class ConferenceSubjectEventPrivate;
class LINPHONE_PUBLIC ConferenceSubjectEvent : public ConferenceNotifiedEvent {
public:
ConferenceSubjectEvent (
time_t time,
const Address &conferenceAddress,
time_t creationTime,
const IdentityAddress &conferenceAddress,
unsigned int notifyId,
const std::string &subject
);
......
......@@ -35,7 +35,7 @@ public:
private:
EventLog::Type type = EventLog::Type::None;
time_t time = -1;
time_t creationTime = -1;
L_DECLARE_PUBLIC(EventLog);
};
......
......@@ -17,7 +17,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "core/core-p.h"
#include "event-log-p.h"
// =============================================================================
......@@ -26,10 +25,10 @@ LINPHONE_BEGIN_NAMESPACE
EventLog::EventLog () : BaseObject(*new EventLogPrivate) {}
EventLog::EventLog (EventLogPrivate &p, Type type, time_t time) : BaseObject(p) {
EventLog::EventLog (EventLogPrivate &p, Type type, time_t creationTime) : BaseObject(p) {
L_D();
d->type = type;
d->time = time;
d->creationTime = creationTime;
}
EventLog::Type EventLog::getType () const {
......@@ -37,9 +36,9 @@ EventLog::Type EventLog::getType () const {
return d->type;
}
time_t EventLog::getTime () const {
time_t EventLog::getCreationTime () const {
L_D();
return d->time;
return d->creationTime;
}
LINPHONE_END_NAMESPACE
......@@ -43,10 +43,10 @@ public:
EventLog ();
Type getType () const;
time_t getTime () const;
time_t getCreationTime () const;
protected:
EventLog (EventLogPrivate &p, Type type, time_t time);
EventLog (EventLogPrivate &p, Type type, time_t creationTime);
private:
L_DECLARE_PRIVATE(EventLog);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment