Commit 8b7f6ef6 authored by Ronan's avatar Ronan

feat(MainDb): deal with conference terminated event

parent d532fb79
......@@ -25,7 +25,7 @@
#define L_ENUM_VALUES_EVENT_LOG_TYPE(F) \
F(None) \
F(ConferenceCreated) \
F(ConferenceDestroyed) \
F(ConferenceTerminated) \
F(ConferenceCallStart) \
F(ConferenceCallEnd) \
F(ConferenceChatMessage) \
......
......@@ -65,7 +65,7 @@ static bool isConferenceType (LinphoneEventLogType type) {
case LinphoneEventLogTypeConferenceCallStart:
case LinphoneEventLogTypeConferenceChatMessage:
case LinphoneEventLogTypeConferenceCreated:
case LinphoneEventLogTypeConferenceDestroyed:
case LinphoneEventLogTypeConferenceTerminated:
case LinphoneEventLogTypeConferenceParticipantAdded:
case LinphoneEventLogTypeConferenceParticipantDeviceAdded:
case LinphoneEventLogTypeConferenceParticipantDeviceRemoved:
......
......@@ -310,6 +310,11 @@ void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) {
L_D_T(RemoteConference, dConference);
dConference->eventHandler->resetLastNotify();
d->setState(ChatRoom::State::Terminated);
getCore()->getPrivate()->mainDb->addEvent(make_shared<ConferenceEvent>(
EventLog::Type::ConferenceTerminated,
time(nullptr),
d->chatRoomId
));
}
void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) {
......
......@@ -351,7 +351,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
return nullptr;
case EventLog::Type::ConferenceCreated:
case EventLog::Type::ConferenceDestroyed:
case EventLog::Type::ConferenceTerminated:
eventLog = selectConferenceEvent(eventId, type, creationTime, chatRoomId);
break;
......@@ -454,13 +454,15 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
chatRoom,
static_cast<ChatMessage::Direction>(direction)
));
chatMessage->getPrivate()->setState(static_cast<ChatMessage::State>(state), true);
chatMessage->setIsSecured(static_cast<bool>(isSecured));
chatMessage->getPrivate()->forceFromAddress(IdentityAddress(fromSipAddress));
chatMessage->getPrivate()->forceToAddress(IdentityAddress(toSipAddress));
ChatMessagePrivate *dChatMessage = chatMessage->getPrivate();
dChatMessage->setState(static_cast<ChatMessage::State>(state), true);
chatMessage->getPrivate()->setTime(Utils::getTmAsTimeT(messageTime));
dChatMessage->forceFromAddress(IdentityAddress(fromSipAddress));
dChatMessage->forceToAddress(IdentityAddress(toSipAddress));
dChatMessage->setTime(Utils::getTmAsTimeT(messageTime));
}
// 2 - Fetch contents.
......@@ -629,6 +631,9 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
*session << "UPDATE chat_room SET last_update_time = :lastUpdateTime"
" WHERE id = :chatRoomId", soci::use(lastUpdateTime),
soci::use(curChatRoomId);
if (eventLog->getType() == EventLog::Type::ConferenceTerminated)
*session << "UPDATE chat_room SET flags = 0 WHERE id = :chatRoomId", soci::use(curChatRoomId);
}
if (chatRoomId)
......@@ -1160,7 +1165,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
return false;
case EventLog::Type::ConferenceCreated:
case EventLog::Type::ConferenceDestroyed:
case EventLog::Type::ConferenceTerminated:
storageId = d->insertConferenceEvent(eventLog);
break;
......@@ -1232,7 +1237,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
break;
case EventLog::Type::ConferenceCreated:
case EventLog::Type::ConferenceDestroyed:
case EventLog::Type::ConferenceTerminated:
case EventLog::Type::ConferenceCallStart:
case EventLog::Type::ConferenceCallEnd:
case EventLog::Type::ConferenceParticipantAdded:
......
......@@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE
ConferenceEvent::ConferenceEvent (Type type, time_t creationTime, const ChatRoomId &chatRoomId) :
EventLog(*new ConferenceEventPrivate, type, creationTime) {
L_D();
L_ASSERT(type == Type::ConferenceCreated || type == Type::ConferenceDestroyed);
L_ASSERT(type == Type::ConferenceCreated || type == Type::ConferenceTerminated);
d->chatRoomId = chatRoomId;
}
......
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