mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
feat(MainDb): supports conference events insertion
This commit is contained in:
parent
0369182673
commit
e4e40d183f
16 changed files with 72 additions and 31 deletions
|
|
@ -68,6 +68,7 @@ private:
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
long insertEvent (const EventLog &eventLog);
|
||||
long insertCallEvent (const EventLog &eventLog);
|
||||
long insertMessageEvent (const EventLog &eventLog);
|
||||
long insertConferenceEvent (const EventLog &eventLog);
|
||||
long insertConferenceParticipantEvent (const EventLog &eventLog);
|
||||
|
|
|
|||
|
|
@ -244,6 +244,11 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
|
|||
return insertEvent(eventLog.getType(), Utils::getLongAsTm(eventLog.getTime()));
|
||||
}
|
||||
|
||||
long MainDbPrivate::insertCallEvent (const EventLog &eventLog) {
|
||||
// TODO.
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MainDbPrivate::insertMessageEvent (const EventLog &eventLog) {
|
||||
// TODO.
|
||||
return 0;
|
||||
|
|
@ -251,31 +256,49 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
|
|||
|
||||
long MainDbPrivate::insertConferenceEvent (const EventLog &eventLog) {
|
||||
long eventId = insertEvent(eventLog);
|
||||
long chatRoomId = insertSipAddress(
|
||||
static_cast<const ConferenceEvent &>(eventLog).getConferenceAddress().asString()
|
||||
);
|
||||
|
||||
soci::session *session = dbSession.getBackendSession<soci::session>();
|
||||
*session << "INSERT INTO conference_event (event_id, chat_room_id)"
|
||||
" VALUES (:eventId, (SELECT id FROM sip_address WHERE value = :conferenceAddress))",
|
||||
soci::use(eventId), soci::use(static_cast<const ConferenceEvent &>(eventLog).getConferenceAddress().asString());
|
||||
" VALUES (:eventId, :chatRoomId)", soci::use(eventId), soci::use(chatRoomId);
|
||||
return eventId;
|
||||
}
|
||||
|
||||
long MainDbPrivate::insertConferenceParticipantEvent (const EventLog &eventLog) {
|
||||
long eventId = insertConferenceEvent(eventLog);
|
||||
long participantAddressId = insertSipAddress(
|
||||
static_cast<const ConferenceParticipantEvent &>(eventLog).getParticipantAddress().asString()
|
||||
);
|
||||
|
||||
soci::session *session = dbSession.getBackendSession<soci::session>();
|
||||
*session << "INSERT INTO conference_participant_event (conference_event_id, chat_room_id)"
|
||||
" VALUES (:eventId, (SELECT id FROM sip_address WHERE value = :participantAddress))",
|
||||
soci::use(eventId),
|
||||
soci::use(static_cast<const ConferenceParticipantEvent &>(eventLog).getParticipantAddress().asStringUriOnly());
|
||||
*session << "INSERT INTO conference_participant_event (conference_event_id, participant_address_id)"
|
||||
" VALUES (:eventId, :participantAddressId)", soci::use(eventId), soci::use(participantAddressId);
|
||||
return eventId;
|
||||
}
|
||||
|
||||
long MainDbPrivate::insertConferenceParticipantDeviceEvent (const EventLog &eventLog) {
|
||||
// TODO.
|
||||
return 0;
|
||||
long eventId = insertConferenceParticipantEvent(eventLog);
|
||||
long gruuAddressId = insertSipAddress(
|
||||
static_cast<const ConferenceParticipantDeviceEvent &>(eventLog).getGruuAddress().asString()
|
||||
);
|
||||
|
||||
soci::session *session = dbSession.getBackendSession<soci::session>();
|
||||
*session << "INSERT INTO conference_participant_device_event (conference_participant_event_id, gruu_address_id)"
|
||||
" VALUES (:eventId, :gruuAddressId)", soci::use(eventId), soci::use(gruuAddressId);
|
||||
return eventId;
|
||||
}
|
||||
|
||||
long MainDbPrivate::insertConferenceSubjectEvent (const EventLog &eventLog) {
|
||||
// TODO.
|
||||
return 0;
|
||||
long eventId = insertConferenceEvent(eventLog);
|
||||
|
||||
soci::session *session = dbSession.getBackendSession<soci::session>();
|
||||
*session << "INSERT INTO conference_subject_event (conference_event_id, subject)"
|
||||
" VALUES (:eventId, :subject)", soci::use(eventId), soci::use(
|
||||
static_cast<const ConferenceSubjectEvent &>(eventLog).getSubject()
|
||||
);
|
||||
return eventId;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -533,7 +556,12 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO.
|
||||
bool soFarSoGood = false;
|
||||
|
||||
L_BEGIN_LOG_EXCEPTION
|
||||
|
||||
soci::transaction tr(*d->dbSession.getBackendSession<soci::session>());
|
||||
|
||||
switch (eventLog.getType()) {
|
||||
case EventLog::Type::None:
|
||||
return false;
|
||||
|
|
@ -544,7 +572,8 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
|
|||
|
||||
case EventLog::Type::CallStart:
|
||||
case EventLog::Type::CallEnd:
|
||||
return false; // TODO.
|
||||
d->insertCallEvent(eventLog);
|
||||
break;
|
||||
|
||||
case EventLog::Type::ConferenceCreated:
|
||||
case EventLog::Type::ConferenceDestroyed:
|
||||
|
|
@ -568,7 +597,13 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
|
|||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
tr.commit();
|
||||
|
||||
soFarSoGood = true;
|
||||
|
||||
L_END_LOG_EXCEPTION
|
||||
|
||||
return soFarSoGood;
|
||||
}
|
||||
|
||||
bool MainDb::deleteEvent (const EventLog &eventLog) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
CallEvent::CallEvent (Type type, const time_t &time, const shared_ptr<Call> &call) :
|
||||
CallEvent::CallEvent (Type type, time_t time, const shared_ptr<Call> &call) :
|
||||
EventLog(*new CallEventPrivate, type, time) {
|
||||
L_D();
|
||||
L_ASSERT(call);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class CallEventPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC CallEvent : public EventLog {
|
||||
public:
|
||||
CallEvent (Type type, const std::time_t &time, const std::shared_ptr<Call> &message);
|
||||
CallEvent (Type type, std::time_t time, const std::shared_ptr<Call> &message);
|
||||
CallEvent (const CallEvent &src);
|
||||
|
||||
CallEvent &operator= (const CallEvent &src);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public:
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
ChatMessageEvent::ChatMessageEvent (
|
||||
const time_t &time,
|
||||
time_t time,
|
||||
const shared_ptr<ChatMessage> &chatMessage
|
||||
) : EventLog(*new ChatMessageEventPrivate, EventLog::Type::ChatMessage, time) {
|
||||
L_D();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class ChatMessageEventPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC ChatMessageEvent : public EventLog {
|
||||
public:
|
||||
ChatMessageEvent (const std::time_t &time, const std::shared_ptr<ChatMessage> &chatMessage);
|
||||
ChatMessageEvent (std::time_t time, const std::shared_ptr<ChatMessage> &chatMessage);
|
||||
ChatMessageEvent (const ChatMessageEvent &src);
|
||||
|
||||
ChatMessageEvent &operator= (const ChatMessageEvent &src);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ using namespace std;
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
ConferenceEvent::ConferenceEvent (Type type, const time_t &time, const Address &conferenceAddress) :
|
||||
ConferenceEvent::ConferenceEvent (Type type, time_t time, const Address &conferenceAddress) :
|
||||
EventLog(*new ConferenceEventPrivate, type, time) {
|
||||
L_D();
|
||||
L_ASSERT(type == Type::ConferenceCreated || type == Type::ConferenceDestroyed);
|
||||
|
|
@ -39,7 +39,7 @@ ConferenceEvent::ConferenceEvent (const ConferenceEvent &src) :
|
|||
ConferenceEvent::ConferenceEvent (
|
||||
ConferenceEventPrivate &p,
|
||||
Type type,
|
||||
const time_t &time,
|
||||
time_t time,
|
||||
const Address &conferenceAddress
|
||||
) : EventLog(p, type, time) {
|
||||
L_D();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class ConferenceEventPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC ConferenceEvent : public EventLog {
|
||||
public:
|
||||
ConferenceEvent (Type type, const std::time_t &time, const Address &conferenceAddress);
|
||||
ConferenceEvent (Type type, 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 std::time_t &time, const Address &conferenceAddress);
|
||||
ConferenceEvent (ConferenceEventPrivate &p, Type type, std::time_t time, const Address &conferenceAddress);
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ConferenceEvent);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (
|
||||
Type type,
|
||||
const time_t &time,
|
||||
time_t time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress,
|
||||
const Address &gruuAddress
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class LINPHONE_PUBLIC ConferenceParticipantDeviceEvent : public ConferencePartic
|
|||
public:
|
||||
ConferenceParticipantDeviceEvent (
|
||||
Type type,
|
||||
const std::time_t &time,
|
||||
std::time_t time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress,
|
||||
const Address &gruuAddress
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
ConferenceParticipantEvent::ConferenceParticipantEvent (
|
||||
Type type,
|
||||
const time_t &time,
|
||||
time_t time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress
|
||||
) : ConferenceEvent(*new ConferenceParticipantEventPrivate, type, time, conferenceAddress) {
|
||||
|
|
@ -55,7 +55,7 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
|
|||
ConferenceParticipantEvent::ConferenceParticipantEvent (
|
||||
ConferenceParticipantEventPrivate &p,
|
||||
Type type,
|
||||
const time_t &time,
|
||||
time_t time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress
|
||||
) : ConferenceEvent(p, type, time, conferenceAddress) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class LINPHONE_PUBLIC ConferenceParticipantEvent : public ConferenceEvent {
|
|||
public:
|
||||
ConferenceParticipantEvent (
|
||||
Type type,
|
||||
const std::time_t &time,
|
||||
std::time_t time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress
|
||||
);
|
||||
|
|
@ -46,7 +46,7 @@ protected:
|
|||
ConferenceParticipantEvent (
|
||||
ConferenceParticipantEventPrivate &p,
|
||||
Type type,
|
||||
const std::time_t &time,
|
||||
std::time_t time,
|
||||
const Address &conferenceAddress,
|
||||
const Address &participantAddress
|
||||
);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public:
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
ConferenceSubjectEvent::ConferenceSubjectEvent (
|
||||
const time_t &time,
|
||||
time_t time,
|
||||
const Address &address,
|
||||
const string &subject
|
||||
) : ConferenceEvent(*new ConferenceSubjectEventPrivate, Type::ConferenceSubjectChanged, time, address) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ConferenceSubjectEventPrivate;
|
|||
|
||||
class LINPHONE_PUBLIC ConferenceSubjectEvent : public ConferenceEvent {
|
||||
public:
|
||||
ConferenceSubjectEvent (const std::time_t &time, const Address &conferenceAddress, const std::string &subject);
|
||||
ConferenceSubjectEvent (std::time_t time, const Address &conferenceAddress, const std::string &subject);
|
||||
ConferenceSubjectEvent (const ConferenceSubjectEvent &src);
|
||||
|
||||
ConferenceSubjectEvent &operator= (const ConferenceSubjectEvent &src);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ EventLog::EventLog () : ClonableObject(*new EventLogPrivate) {}
|
|||
|
||||
EventLog::EventLog (const EventLog &) : ClonableObject(*new EventLogPrivate) {}
|
||||
|
||||
EventLog::EventLog (EventLogPrivate &p, Type type, const time_t &time) : ClonableObject(*new EventLogPrivate) {
|
||||
EventLog::EventLog (EventLogPrivate &p, Type type, time_t time) : ClonableObject(*new EventLogPrivate) {
|
||||
L_D();
|
||||
d->type = type;
|
||||
d->time = time;
|
||||
|
|
@ -45,4 +45,9 @@ EventLog::Type EventLog::getType () const {
|
|||
return d->type;
|
||||
}
|
||||
|
||||
std::time_t EventLog::getTime () const {
|
||||
L_D();
|
||||
return d->time;
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
std::time_t getTime () const;
|
||||
|
||||
protected:
|
||||
EventLog (EventLogPrivate &p, Type type, const std::time_t &time);
|
||||
EventLog (EventLogPrivate &p, Type type, std::time_t time);
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(EventLog);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue