mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 03:58:08 +00:00
feat(EventLog): supports time
This commit is contained in:
parent
e10297ba6d
commit
d64b2adf77
18 changed files with 81 additions and 37 deletions
|
|
@ -33,12 +33,17 @@ LINPHONE_PUBLIC LinphoneEventLog *linphone_event_log_clone (const LinphoneEventL
|
|||
LINPHONE_PUBLIC LinphoneEventLog *linphone_event_log_ref (LinphoneEventLog *event_log);
|
||||
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 LinphoneCallEvent *linphone_call_event_new (
|
||||
LinphoneEventLogType type,
|
||||
time_t time,
|
||||
LinphoneCall *call
|
||||
);
|
||||
LINPHONE_PUBLIC LinphoneCallEvent *linphone_call_event_clone (const LinphoneCallEvent *call_event);
|
||||
LINPHONE_PUBLIC LinphoneCall *linphone_call_event_get_call (const LinphoneCallEvent *call_event);
|
||||
|
||||
LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_new (
|
||||
LinphoneEventLogType type,
|
||||
time_t time,
|
||||
const LinphoneAddress *address
|
||||
);
|
||||
LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_clone (const LinphoneConferenceEvent *conference_event);
|
||||
|
|
@ -46,6 +51,7 @@ LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_event_get_address (co
|
|||
|
||||
LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_participant_event_new (
|
||||
LinphoneEventLogType type,
|
||||
time_t time,
|
||||
const LinphoneAddress *conferenceAddress,
|
||||
const LinphoneAddress *participantAddress
|
||||
);
|
||||
|
|
@ -56,7 +62,10 @@ LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_participant_event_get
|
|||
const LinphoneConferenceParticipantEvent *conference_participant_event
|
||||
);
|
||||
|
||||
LINPHONE_PUBLIC LinphoneChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage *chat_message);
|
||||
LINPHONE_PUBLIC LinphoneChatMessageEvent *linphone_chat_message_event_new (
|
||||
LinphoneChatMessage *chat_message,
|
||||
time_t time
|
||||
);
|
||||
LINPHONE_PUBLIC LinphoneChatMessageEvent *linphone_chat_message_event_clone (
|
||||
const LinphoneChatMessageEvent *chat_message_event
|
||||
);
|
||||
|
|
|
|||
|
|
@ -62,12 +62,13 @@ LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *event_
|
|||
// Call event.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
LinphoneCallEvent *linphone_call_event_new (LinphoneEventLogType type, LinphoneCall *call) {
|
||||
LinphoneCallEvent *linphone_call_event_new (LinphoneEventLogType type, time_t time, LinphoneCall *call) {
|
||||
LinphoneCallEvent *call_event = _linphone_CallEvent_init();
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(
|
||||
call_event,
|
||||
new LinphonePrivate::CallEvent(
|
||||
static_cast<LinphonePrivate::EventLog::Type>(type),
|
||||
time,
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(call)
|
||||
)
|
||||
);
|
||||
|
|
@ -86,6 +87,7 @@ LinphoneCall *linphone_call_event_get_call (const LinphoneCallEvent *call_event)
|
|||
|
||||
LinphoneConferenceEvent *linphone_conference_event_new (
|
||||
LinphoneEventLogType type,
|
||||
time_t time,
|
||||
const LinphoneAddress *address
|
||||
) {
|
||||
// TODO.
|
||||
|
|
@ -103,6 +105,7 @@ const LinphoneAddress *linphone_conference_event_get_address (const LinphoneConf
|
|||
|
||||
LinphoneConferenceParticipantEvent *linphone_conference_participant_event_new (
|
||||
LinphoneEventLogType type,
|
||||
time_t time,
|
||||
const LinphoneAddress *conferenceAddress,
|
||||
const LinphoneAddress *participantAddress
|
||||
) {
|
||||
|
|
@ -121,11 +124,12 @@ const LinphoneAddress *linphone_conference_participant_event_get_participant_add
|
|||
// Message event.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
LinphoneChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage *chat_message) {
|
||||
LinphoneChatMessageEvent *linphone_chat_message_event_new (LinphoneChatMessage *chat_message, time_t time) {
|
||||
LinphoneChatMessageEvent *chat_message_event = _linphone_ChatMessageEvent_init();
|
||||
L_SET_CPP_PTR_FROM_C_OBJECT(
|
||||
chat_message_event,
|
||||
new LinphonePrivate::ChatMessageEvent(
|
||||
time,
|
||||
L_GET_CPP_PTR_FROM_C_OBJECT(chat_message)
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -519,19 +519,19 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
|
|||
return false;
|
||||
}
|
||||
|
||||
long &id = const_cast<EventLog &>(eventLog).getPrivate()->id;
|
||||
if (id < 0)
|
||||
long &storageId = const_cast<EventLog &>(eventLog).getPrivate()->storageId;
|
||||
if (storageId < 0)
|
||||
return false;
|
||||
|
||||
L_BEGIN_LOG_EXCEPTION
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
*session << "DELETE FROM event WHERE id = :id", soci::use(id);
|
||||
id = -1;
|
||||
*session << "DELETE FROM event WHERE id = :id", soci::use(storageId);
|
||||
storageId = -1;
|
||||
|
||||
L_END_LOG_EXCEPTION
|
||||
|
||||
return id == -1;
|
||||
return storageId == -1;
|
||||
}
|
||||
|
||||
void MainDb::cleanEvents (FilterMask mask) {
|
||||
|
|
|
|||
|
|
@ -33,14 +33,15 @@ public:
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
CallEvent::CallEvent (Type type, const shared_ptr<Call> &call) : EventLog(*new CallEventPrivate, type) {
|
||||
CallEvent::CallEvent (Type type, const time_t &time, const shared_ptr<Call> &call) :
|
||||
EventLog(*new CallEventPrivate, type, time) {
|
||||
L_D();
|
||||
L_ASSERT(call);
|
||||
L_ASSERT(type == Type::CallStart || type == Type::CallEnd);
|
||||
d->call = call;
|
||||
}
|
||||
|
||||
CallEvent::CallEvent (const CallEvent &src) : CallEvent(src.getType(), src.getCall()) {}
|
||||
CallEvent::CallEvent (const CallEvent &src) : CallEvent(src.getType(), src.getTime(), src.getCall()) {}
|
||||
|
||||
CallEvent &CallEvent::operator= (const CallEvent &src) {
|
||||
L_D();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class CallEventPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC CallEvent : public EventLog {
|
||||
public:
|
||||
CallEvent (Type type, const std::shared_ptr<Call> &message);
|
||||
CallEvent (Type type, const std::time_t &time, const std::shared_ptr<Call> &message);
|
||||
CallEvent (const CallEvent &src);
|
||||
|
||||
CallEvent &operator= (const CallEvent &src);
|
||||
|
|
|
|||
|
|
@ -33,14 +33,18 @@ public:
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ChatMessageEvent::ChatMessageEvent (const shared_ptr<ChatMessage> &chatMessage) :
|
||||
EventLog(*new ChatMessageEventPrivate, EventLog::Type::ChatMessage) {
|
||||
ChatMessageEvent::ChatMessageEvent (
|
||||
const time_t &time,
|
||||
const shared_ptr<ChatMessage> &chatMessage
|
||||
) : EventLog(*new ChatMessageEventPrivate, EventLog::Type::ChatMessage, time) {
|
||||
L_D();
|
||||
L_ASSERT(chatMessage);
|
||||
d->chatMessage = chatMessage;
|
||||
}
|
||||
|
||||
ChatMessageEvent::ChatMessageEvent (const ChatMessageEvent &src) : ChatMessageEvent(src.getChatMessage()) {}
|
||||
ChatMessageEvent::ChatMessageEvent (
|
||||
const ChatMessageEvent &src
|
||||
) : ChatMessageEvent(src.getTime(), src.getChatMessage()) {}
|
||||
|
||||
ChatMessageEvent &ChatMessageEvent::operator= (const ChatMessageEvent &src) {
|
||||
L_D();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class ChatMessageEventPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC ChatMessageEvent : public EventLog {
|
||||
public:
|
||||
ChatMessageEvent (const std::shared_ptr<ChatMessage> &chatMessage);
|
||||
ChatMessageEvent (const std::time_t &time, const std::shared_ptr<ChatMessage> &chatMessage);
|
||||
ChatMessageEvent (const ChatMessageEvent &src);
|
||||
|
||||
ChatMessageEvent &operator= (const ChatMessageEvent &src);
|
||||
|
|
|
|||
|
|
@ -26,21 +26,25 @@ using namespace std;
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
ConferenceEvent::ConferenceEvent (Type type, const Address &conferenceAddress) :
|
||||
EventLog(*new ConferenceEventPrivate, type) {
|
||||
ConferenceEvent::ConferenceEvent (Type type, const time_t &time, const Address &conferenceAddress) :
|
||||
EventLog(*new ConferenceEventPrivate, type, time) {
|
||||
L_D();
|
||||
L_ASSERT(type == Type::ConferenceCreated || type == Type::ConferenceDestroyed);
|
||||
d->conferenceAddress = conferenceAddress;
|
||||
}
|
||||
|
||||
ConferenceEvent::ConferenceEvent (const ConferenceEvent &src) :
|
||||
ConferenceEvent(src.getType(), src.getConferenceAddress()) {}
|
||||
ConferenceEvent(src.getType(), src.getTime(), src.getConferenceAddress()) {}
|
||||
|
||||
ConferenceEvent::ConferenceEvent (ConferenceEventPrivate &p, Type type, const Address &conferenceAddress) :
|
||||
EventLog(p, type) {
|
||||
L_D();
|
||||
d->conferenceAddress = conferenceAddress;
|
||||
}
|
||||
ConferenceEvent::ConferenceEvent (
|
||||
ConferenceEventPrivate &p,
|
||||
Type type,
|
||||
const time_t &time,
|
||||
const Address &conferenceAddress
|
||||
) : EventLog(p, type, time) {
|
||||
L_D();
|
||||
d->conferenceAddress = conferenceAddress;
|
||||
}
|
||||
|
||||
ConferenceEvent &ConferenceEvent::operator= (const ConferenceEvent &src) {
|
||||
L_D();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class ConferenceEventPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC ConferenceEvent : public EventLog {
|
||||
public:
|
||||
ConferenceEvent (Type type, const Address &conferenceAddress);
|
||||
ConferenceEvent (Type type, const std::time_t &time, const Address &conferenceAddress);
|
||||
ConferenceEvent (const ConferenceEvent &src);
|
||||
|
||||
ConferenceEvent &operator= (const ConferenceEvent &src);
|
||||
|
|
@ -39,7 +39,7 @@ public:
|
|||
const Address &getConferenceAddress () const;
|
||||
|
||||
protected:
|
||||
ConferenceEvent (ConferenceEventPrivate &p, Type type, const Address &conferenceAddress);
|
||||
ConferenceEvent (ConferenceEventPrivate &p, Type type, const std::time_t &time, const Address &conferenceAddress);
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ConferenceEvent);
|
||||
|
|
|
|||
|
|
@ -35,12 +35,14 @@ public:
|
|||
|
||||
ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (
|
||||
Type type,
|
||||
const time_t &time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress,
|
||||
const Address &gruuAddress
|
||||
) : ConferenceParticipantEvent(
|
||||
*new ConferenceParticipantDeviceEventPrivate,
|
||||
type,
|
||||
time,
|
||||
conferenceAddress,
|
||||
participantAddress
|
||||
) {
|
||||
|
|
@ -55,6 +57,7 @@ ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (
|
|||
ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (const ConferenceParticipantDeviceEvent &src) :
|
||||
ConferenceParticipantDeviceEvent(
|
||||
src.getType(),
|
||||
src.getTime(),
|
||||
src.getConferenceAddress(),
|
||||
src.getParticipantAddress(),
|
||||
src.getGruuAddress()
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class LINPHONE_PUBLIC ConferenceParticipantDeviceEvent : public ConferencePartic
|
|||
public:
|
||||
ConferenceParticipantDeviceEvent (
|
||||
Type type,
|
||||
const std::time_t &time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress,
|
||||
const Address &gruuAddress
|
||||
|
|
|
|||
|
|
@ -29,9 +29,10 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
ConferenceParticipantEvent::ConferenceParticipantEvent (
|
||||
Type type,
|
||||
const time_t &time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress
|
||||
) : ConferenceEvent(*new ConferenceParticipantEventPrivate, type, conferenceAddress) {
|
||||
) : ConferenceEvent(*new ConferenceParticipantEventPrivate, type, time, conferenceAddress) {
|
||||
L_D();
|
||||
L_ASSERT(
|
||||
type == Type::ConferenceParticipantAdded ||
|
||||
|
|
@ -42,15 +43,22 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
|
|||
d->participantAddress = participantAddress;
|
||||
}
|
||||
|
||||
ConferenceParticipantEvent::ConferenceParticipantEvent (const ConferenceParticipantEvent &src) :
|
||||
ConferenceParticipantEvent(src.getType(), src.getConferenceAddress(), src.getParticipantAddress()) {}
|
||||
ConferenceParticipantEvent::ConferenceParticipantEvent (
|
||||
const ConferenceParticipantEvent &src
|
||||
) : ConferenceParticipantEvent(
|
||||
src.getType(),
|
||||
src.getTime(),
|
||||
src.getConferenceAddress(),
|
||||
src.getParticipantAddress()
|
||||
) {}
|
||||
|
||||
ConferenceParticipantEvent::ConferenceParticipantEvent (
|
||||
ConferenceParticipantEventPrivate &p,
|
||||
Type type,
|
||||
const time_t &time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress
|
||||
) : ConferenceEvent(p, type, conferenceAddress) {
|
||||
) : ConferenceEvent(p, type, time, conferenceAddress) {
|
||||
L_D();
|
||||
d->participantAddress = participantAddress;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class LINPHONE_PUBLIC ConferenceParticipantEvent : public ConferenceEvent {
|
|||
public:
|
||||
ConferenceParticipantEvent (
|
||||
Type type,
|
||||
const std::time_t &time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress
|
||||
);
|
||||
|
|
@ -45,6 +46,7 @@ protected:
|
|||
ConferenceParticipantEvent (
|
||||
ConferenceParticipantEventPrivate &p,
|
||||
Type type,
|
||||
const std::time_t &time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress
|
||||
);
|
||||
|
|
|
|||
|
|
@ -33,14 +33,17 @@ public:
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ConferenceSubjectEvent::ConferenceSubjectEvent (const Address &address, const string &subject) :
|
||||
ConferenceEvent(*new ConferenceSubjectEventPrivate, Type::ConferenceSubjectChanged, address) {
|
||||
ConferenceSubjectEvent::ConferenceSubjectEvent (
|
||||
const time_t &time,
|
||||
const Address &address,
|
||||
const string &subject
|
||||
) : ConferenceEvent(*new ConferenceSubjectEventPrivate, Type::ConferenceSubjectChanged, time, address) {
|
||||
L_D();
|
||||
d->subject = subject;
|
||||
}
|
||||
|
||||
ConferenceSubjectEvent::ConferenceSubjectEvent (const ConferenceSubjectEvent &src) :
|
||||
ConferenceSubjectEvent(src.getConferenceAddress(), src.getSubject()) {}
|
||||
ConferenceSubjectEvent(src.getTime(), src.getConferenceAddress(), src.getSubject()) {}
|
||||
|
||||
ConferenceSubjectEvent &ConferenceSubjectEvent::operator= (const ConferenceSubjectEvent &src) {
|
||||
L_D();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ConferenceSubjectEventPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC ConferenceSubjectEvent : public ConferenceEvent {
|
||||
public:
|
||||
ConferenceSubjectEvent (const Address &conferenceAddress, const std::string &subject);
|
||||
ConferenceSubjectEvent (const std::time_t &time, const Address &conferenceAddress, const std::string &subject);
|
||||
ConferenceSubjectEvent (const ConferenceSubjectEvent &src);
|
||||
|
||||
ConferenceSubjectEvent &operator= (const ConferenceSubjectEvent &src);
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
class EventLogPrivate : public ClonableObjectPrivate {
|
||||
public:
|
||||
long id = -1;
|
||||
long storageId = -1;
|
||||
|
||||
private:
|
||||
EventLog::Type type = EventLog::Type::None;
|
||||
std::time_t time = -1;
|
||||
|
||||
L_DECLARE_PUBLIC(EventLog);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@ EventLog::EventLog () : ClonableObject(*new EventLogPrivate) {}
|
|||
|
||||
EventLog::EventLog (const EventLog &) : ClonableObject(*new EventLogPrivate) {}
|
||||
|
||||
EventLog::EventLog (EventLogPrivate &p, Type type) : ClonableObject(*new EventLogPrivate) {
|
||||
EventLog::EventLog (EventLogPrivate &p, Type type, const time_t &time) : ClonableObject(*new EventLogPrivate) {
|
||||
L_D();
|
||||
d->type = type;
|
||||
d->time = time;
|
||||
}
|
||||
|
||||
EventLog &EventLog::operator= (const EventLog &src) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#ifndef _EVENT_LOG_H_
|
||||
#define _EVENT_LOG_H_
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "linphone/enums/event-log-enums.h"
|
||||
#include "linphone/utils/enum-generator.h"
|
||||
|
||||
|
|
@ -43,9 +45,10 @@ public:
|
|||
EventLog &operator= (const EventLog &src);
|
||||
|
||||
Type getType () const;
|
||||
std::time_t getTime () const;
|
||||
|
||||
protected:
|
||||
EventLog (EventLogPrivate &p, Type type);
|
||||
EventLog (EventLogPrivate &p, Type type, const std::time_t &time);
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(EventLog);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue