Commit 3a729f03 authored by jehan's avatar jehan

Merge branch 'feature/backward_compatibility_with_limev2_early_access'

parents cc1f38ef 9f14911c
......@@ -6288,8 +6288,7 @@ void _linphone_core_uninit(LinphoneCore *lc)
lc->chat_rooms = bctbx_list_free_with_data(lc->chat_rooms, (bctbx_list_free_func)linphone_chat_room_unref);
linphone_core_set_state(lc,LinphoneGlobalShutdown,"Shutting down");
//no longer call LinphoneGlobalShutdown because it cause LinphoneCore revival in case of managed languages like Java
getPlatformHelpers(lc)->onLinphoneCoreStop();
#ifdef VIDEO_ENABLED
......@@ -6361,7 +6360,7 @@ void _linphone_core_uninit(LinphoneCore *lc)
linphone_core_friends_storage_close(lc);
linphone_core_zrtp_cache_close(lc);
linphone_core_set_state(lc,LinphoneGlobalOff,"Off");
//linphone_core_set_state(NULL,LinphoneGlobalOff,"Off");
linphone_core_deactivate_log_serialization_if_needed();
bctbx_list_free_with_data(lc->vtable_refs,(void (*)(void *))v_table_reference_destroy);
ms_bandwidth_controller_destroy(lc->bw_controller);
......
......@@ -314,7 +314,11 @@ RemoteConference(core, me->getAddress(), nullptr) {
getMe()->getPrivate()->addDevice(device->getAddress(), device->getName());
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)
getCore()->getPrivate()->remoteListEventHandler->addHandler(dConference->eventHandler.get());
}
......@@ -665,6 +669,10 @@ void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) {
dConference->eventHandler->unsubscribe();
dConference->eventHandler->resetLastNotify();
//remove event handler from list event handler if present
if (getCore()->getPrivate()->remoteListEventHandler)
getCore()->getPrivate()->remoteListEventHandler->removeHandler(dConference->eventHandler.get());
d->setState(ChatRoom::State::Terminated);
auto event = make_shared<ConferenceEvent>(
......@@ -721,7 +729,10 @@ void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) {
time(nullptr),
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();
_linphone_chat_room_notify_conference_joined(cr, L_GET_C_BACK_PTR(event));
......@@ -903,7 +914,14 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (const shared_ptr<Conferenc
void ClientGroupChatRoom::onParticipantsCleared () {
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();
}
LINPHONE_END_NAMESPACE
......@@ -293,7 +293,9 @@ ChatMessageModifier::Result LimeX3dhEncryptionEngine::processOutgoingMessage (
// Insert protocol param before boundary for flexisip
ContentType contentType(finalContent.getContentType());
contentType.removeParameter("boundary");
contentType.addParameter("protocol", "\"application/lime\"");
if (!linphone_config_get_bool(linphone_core_get_config(message->getCore()->getCCore()), "lime", "preserve_backward_compatibility",FALSE)) {
contentType.addParameter("protocol", "\"application/lime\"");
}
contentType.addParameter("boundary", MultipartBoundary);
finalContent.setContentType(contentType);
......@@ -338,8 +340,10 @@ ChatMessageModifier::Result LimeX3dhEncryptionEngine::processIncomingMessage (
ContentType expectedContentType = ContentType::Encrypted;
expectedContentType.addParameter("protocol", "\"application/lime\"");
expectedContentType.addParameter("boundary", MultipartBoundary);
ContentType legacyContentType = ContentType::Encrypted; //for backward compatibility with limev2 early access
legacyContentType.addParameter("boundary", MultipartBoundary);
if (incomingContentType != expectedContentType) {
if (incomingContentType != expectedContentType && incomingContentType != legacyContentType) {
lError() << "LIME X3DH unexpected content-type: " << incomingContentType;
// Set unencrypted content warning flag because incoming message type is unexpected
message->getPrivate()->setUnencryptedContentWarning(true);
......@@ -367,10 +371,12 @@ ChatMessageModifier::Result LimeX3dhEncryptionEngine::processIncomingMessage (
// Discard incoming messages from unsafe peer devices
lime::PeerDeviceStatus peerDeviceStatus = limeManager->get_peerDeviceStatus(senderDeviceId);
if (peerDeviceStatus == lime::PeerDeviceStatus::unsafe) {
lWarning() << "LIME X3DH discard incoming message from unsafe sender device " << senderDeviceId;
errorCode = 488; // Not Acceptable
return ChatMessageModifier::Result::Error;
if (linphone_config_get_int(linphone_core_get_config(chatRoom->getCore()->getCCore()), "lime", "allow_message_in_unsafe_chatroom", 0) == 0) {
if (peerDeviceStatus == lime::PeerDeviceStatus::unsafe) {
lWarning() << "LIME X3DH discard incoming message from unsafe sender device " << senderDeviceId;
errorCode = 488; // Not Acceptable
return ChatMessageModifier::Result::Error;
}
}
// ---------------------------------------------- HEADERS
......
......@@ -42,7 +42,9 @@ Imdn::Imdn (ChatRoom *chatRoom) : chatRoom(chatRoom) {
Imdn::~Imdn () {
stopTimer();
chatRoom->getCore()->getPrivate()->unregisterListener(this);
try {
chatRoom->getCore()->getPrivate()->unregisterListener(this);
} catch (const bad_weak_ptr &) {}
}
// -----------------------------------------------------------------------------
......
......@@ -337,22 +337,22 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &cha
long long chatRoomId = selectChatRoomId(peerSipAddressId, localSipAddressId);
if (chatRoomId >= 0) {
// 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",
soci::use(notifyId), soci::use(chatRoomId);
return chatRoomId;
}
lInfo() << "Insert new chat room in database: " << conferenceId << ".";
const tm &creationTime = Utils::getTimeTAsTm(chatRoom->getCreationTime());
const tm &lastUpdateTime = Utils::getTimeTAsTm(chatRoom->getLastUpdateTime());
// Remove capabilities like `Proxy`.
const int &capabilities = chatRoom->getCapabilities() & ~ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::Proxy);
const string &subject = chatRoom->getSubject();
const int &flags = chatRoom->hasBeenLeft();
*dbSession.getBackendSession() << "INSERT INTO chat_room ("
} else {
lInfo() << "Insert new chat room in database: " << conferenceId << ".";
const tm &creationTime = Utils::getTimeTAsTm(chatRoom->getCreationTime());
const tm &lastUpdateTime = Utils::getTimeTAsTm(chatRoom->getLastUpdateTime());
// Remove capabilities like `Proxy`.
const int &capabilities = chatRoom->getCapabilities() & ~ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::Proxy);
const string &subject = chatRoom->getSubject();
const int &flags = chatRoom->hasBeenLeft();
*dbSession.getBackendSession() << "INSERT INTO chat_room ("
" peer_sip_address_id, local_sip_address_id, creation_time,"
" last_update_time, capabilities, subject, flags, last_notify_id"
") VALUES ("
......@@ -361,9 +361,9 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &cha
")",
soci::use(peerSipAddressId), soci::use(localSipAddressId), soci::use(creationTime),
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.
if (conferenceId.getLocalAddress() != conferenceId.getPeerAddress()) {
shared_ptr<Participant> me = chatRoom->getMe();
......@@ -1162,6 +1162,12 @@ void MainDbPrivate::updateSchema () {
" LEFT JOIN conference_subject_event ON conference_subject_event.event_id = event.id"
" LEFT JOIN conference_security_event ON conference_security_event.event_id = event.id";
}
if (version < makeVersion(1, 0, 6)
&& linphone_config_get_bool(linphone_core_get_config(q->getCore()->getCCore()), "lime", "migrate_to_secured_room",FALSE)) {
*session << "UPDATE chat_room "
"SET capabilities = capabilities | " + Utils::toString(int(ChatRoom::Capabilities::Encrypted));
}
if (version < makeVersion(1, 0, 7)) {
*session << "ALTER TABLE chat_room_participant_device ADD COLUMN name VARCHAR(255)";
}
......@@ -2845,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) {
......
......@@ -189,6 +189,16 @@ public:
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.
// ---------------------------------------------------------------------------
......
This diff is collapsed.
......@@ -307,6 +307,7 @@ typedef struct _stats {
int number_of_participants_removed;
int number_of_subject_changed;
int number_of_participant_devices_added;
int number_of_participant_devices_removed;
int number_of_SecurityLevelDowngraded;
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