Commit 34a9666e authored by jehan's avatar jehan

add possibility to force full state conference event package

# Conflicts:
#	tester/group_chat_tester.c
parent a091a90c
...@@ -314,7 +314,11 @@ RemoteConference(core, me->getAddress(), nullptr) { ...@@ -314,7 +314,11 @@ RemoteConference(core, me->getAddress(), nullptr) {
getMe()->getPrivate()->addDevice(device->getAddress(), device->getName()); getMe()->getPrivate()->addDevice(device->getAddress(), device->getName());
dConference->eventHandler->setConferenceId(conferenceId); dConference->eventHandler->setConferenceId(conferenceId);
dConference->eventHandler->setLastNotify(lastNotifyId);
bool_t forceFullState = linphone_config_get_bool(linphone_core_get_config(getCore()->getCCore()), "misc", "conference_event_package_force_full_state",FALSE );
dConference->eventHandler->setLastNotify(forceFullState?0:lastNotifyId);
lInfo() << "Last notify set to [" << dConference->eventHandler->getLastNotify() << "] for conference [" << dConference << "]";
if (!hasBeenLeft) if (!hasBeenLeft)
getCore()->getPrivate()->remoteListEventHandler->addHandler(dConference->eventHandler.get()); getCore()->getPrivate()->remoteListEventHandler->addHandler(dConference->eventHandler.get());
} }
...@@ -725,7 +729,10 @@ void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) { ...@@ -725,7 +729,10 @@ void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) {
time(nullptr), time(nullptr),
d->conferenceId d->conferenceId
); );
d->addEvent(event);
bool_t forceFullState = linphone_config_get_bool(linphone_core_get_config(getCore()->getCCore()), "misc", "conference_event_package_force_full_state",FALSE );
if (!forceFullState) //to avoid this event to be repeated for each full state
d->addEvent(event);
LinphoneChatRoom *cr = d->getCChatRoom(); LinphoneChatRoom *cr = d->getCChatRoom();
_linphone_chat_room_notify_conference_joined(cr, L_GET_C_BACK_PTR(event)); _linphone_chat_room_notify_conference_joined(cr, L_GET_C_BACK_PTR(event));
...@@ -907,7 +914,14 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (const shared_ptr<Conferenc ...@@ -907,7 +914,14 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (const shared_ptr<Conferenc
void ClientGroupChatRoom::onParticipantsCleared () { void ClientGroupChatRoom::onParticipantsCleared () {
L_D_T(RemoteConference, dConference); L_D_T(RemoteConference, dConference);
//clear from db as well
for (const auto &participant : dConference->participants) {
getCore()->getPrivate()->mainDb->deleteChatRoomParticipant(getSharedFromThis(), participant->getAddress());
for (const auto &device : participant->getPrivate()->getDevices())
getCore()->getPrivate()->mainDb->deleteChatRoomParticipantDevice(getSharedFromThis(), device);
}
dConference->participants.clear(); dConference->participants.clear();
} }
LINPHONE_END_NAMESPACE LINPHONE_END_NAMESPACE
...@@ -371,10 +371,12 @@ ChatMessageModifier::Result LimeX3dhEncryptionEngine::processIncomingMessage ( ...@@ -371,10 +371,12 @@ ChatMessageModifier::Result LimeX3dhEncryptionEngine::processIncomingMessage (
// Discard incoming messages from unsafe peer devices // Discard incoming messages from unsafe peer devices
lime::PeerDeviceStatus peerDeviceStatus = limeManager->get_peerDeviceStatus(senderDeviceId); lime::PeerDeviceStatus peerDeviceStatus = limeManager->get_peerDeviceStatus(senderDeviceId);
if (peerDeviceStatus == lime::PeerDeviceStatus::unsafe) { if (linphone_config_get_int(linphone_core_get_config(chatRoom->getCore()->getCCore()), "lime", "allow_message_in_unsafe_chatroom", 0) == 0) {
lWarning() << "LIME X3DH discard incoming message from unsafe sender device " << senderDeviceId; if (peerDeviceStatus == lime::PeerDeviceStatus::unsafe) {
errorCode = 488; // Not Acceptable lWarning() << "LIME X3DH discard incoming message from unsafe sender device " << senderDeviceId;
return ChatMessageModifier::Result::Error; errorCode = 488; // Not Acceptable
return ChatMessageModifier::Result::Error;
}
} }
// ---------------------------------------------- HEADERS // ---------------------------------------------- HEADERS
......
...@@ -337,22 +337,22 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &cha ...@@ -337,22 +337,22 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &cha
long long chatRoomId = selectChatRoomId(peerSipAddressId, localSipAddressId); long long chatRoomId = selectChatRoomId(peerSipAddressId, localSipAddressId);
if (chatRoomId >= 0) { if (chatRoomId >= 0) {
// The chat room is already stored in DB, but still update the notify id that might have changed // The chat room is already stored in DB, but still update the notify id that might have changed
lInfo() << "Update chat room in database: " << conferenceId << ".";
*dbSession.getBackendSession() << "UPDATE chat_room SET last_notify_id = :lastNotifyId WHERE id = :chatRoomId", *dbSession.getBackendSession() << "UPDATE chat_room SET last_notify_id = :lastNotifyId WHERE id = :chatRoomId",
soci::use(notifyId), soci::use(chatRoomId); soci::use(notifyId), soci::use(chatRoomId);
return chatRoomId; } else {
}
lInfo() << "Insert new chat room in database: " << conferenceId << ".";
lInfo() << "Insert new chat room in database: " << conferenceId << ".";
const tm &creationTime = Utils::getTimeTAsTm(chatRoom->getCreationTime());
const tm &creationTime = Utils::getTimeTAsTm(chatRoom->getCreationTime()); const tm &lastUpdateTime = Utils::getTimeTAsTm(chatRoom->getLastUpdateTime());
const tm &lastUpdateTime = Utils::getTimeTAsTm(chatRoom->getLastUpdateTime());
// Remove capabilities like `Proxy`.
// Remove capabilities like `Proxy`. const int &capabilities = chatRoom->getCapabilities() & ~ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::Proxy);
const int &capabilities = chatRoom->getCapabilities() & ~ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::Proxy);
const string &subject = chatRoom->getSubject();
const string &subject = chatRoom->getSubject(); const int &flags = chatRoom->hasBeenLeft();
const int &flags = chatRoom->hasBeenLeft(); *dbSession.getBackendSession() << "INSERT INTO chat_room ("
*dbSession.getBackendSession() << "INSERT INTO chat_room ("
" peer_sip_address_id, local_sip_address_id, creation_time," " peer_sip_address_id, local_sip_address_id, creation_time,"
" last_update_time, capabilities, subject, flags, last_notify_id" " last_update_time, capabilities, subject, flags, last_notify_id"
") VALUES (" ") VALUES ("
...@@ -361,9 +361,9 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &cha ...@@ -361,9 +361,9 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &cha
")", ")",
soci::use(peerSipAddressId), soci::use(localSipAddressId), soci::use(creationTime), soci::use(peerSipAddressId), soci::use(localSipAddressId), soci::use(creationTime),
soci::use(lastUpdateTime), soci::use(capabilities), soci::use(subject), soci::use(flags), soci::use(notifyId); soci::use(lastUpdateTime), soci::use(capabilities), soci::use(subject), soci::use(flags), soci::use(notifyId);
chatRoomId = dbSession.getLastInsertId(); chatRoomId = dbSession.getLastInsertId();
}
// Do not add 'me' when creating a server-group-chat-room. // Do not add 'me' when creating a server-group-chat-room.
if (conferenceId.getLocalAddress() != conferenceId.getPeerAddress()) { if (conferenceId.getLocalAddress() != conferenceId.getPeerAddress()) {
shared_ptr<Participant> me = chatRoom->getMe(); shared_ptr<Participant> me = chatRoom->getMe();
...@@ -2851,6 +2851,27 @@ void MainDb::updateChatRoomParticipantDevice ( ...@@ -2851,6 +2851,27 @@ void MainDb::updateChatRoomParticipantDevice (
}; };
} }
void MainDb::deleteChatRoomParticipant (
const std::shared_ptr<AbstractChatRoom> &chatRoom,
const IdentityAddress &participant
){
L_D();
const long long &dbChatRoomId = d->selectChatRoomId(chatRoom->getConferenceId());
const long long &participantSipAddressId = d->selectSipAddressId(participant.asString());
d->deleteChatRoomParticipant(dbChatRoomId, participantSipAddressId);
}
void MainDb::deleteChatRoomParticipantDevice (
const shared_ptr<AbstractChatRoom> &chatRoom,
const shared_ptr<ParticipantDevice> &device
) {
L_D();
const long long &dbChatRoomId = d->selectChatRoomId(chatRoom->getConferenceId());
const long long &participantSipAddressId = d->selectSipAddressId(device->getParticipant()->getAddress().asString());
const long long &participantId = d->selectChatRoomParticipantId(dbChatRoomId, participantSipAddressId);
d->deleteChatRoomParticipantDevice(participantId, participantSipAddressId);
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool MainDb::import (Backend, const string &parameters) { bool MainDb::import (Backend, const string &parameters) {
......
...@@ -189,6 +189,16 @@ public: ...@@ -189,6 +189,16 @@ public:
const std::shared_ptr<ParticipantDevice> &device const std::shared_ptr<ParticipantDevice> &device
); );
void deleteChatRoomParticipant (
const std::shared_ptr<AbstractChatRoom> &chatRoom,
const IdentityAddress &participant
);
void deleteChatRoomParticipantDevice (
const std::shared_ptr<AbstractChatRoom> &chatRoom,
const std::shared_ptr<ParticipantDevice> &device
);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Other. // Other.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
This diff is collapsed.
...@@ -307,6 +307,7 @@ typedef struct _stats { ...@@ -307,6 +307,7 @@ typedef struct _stats {
int number_of_participants_removed; int number_of_participants_removed;
int number_of_subject_changed; int number_of_subject_changed;
int number_of_participant_devices_added; int number_of_participant_devices_added;
int number_of_participant_devices_removed;
int number_of_SecurityLevelDowngraded; int number_of_SecurityLevelDowngraded;
int number_of_ParticipantMaxDeviceCountExceeded; int number_of_ParticipantMaxDeviceCountExceeded;
......
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