Commit cd6fe530 authored by Simon Morlat's avatar Simon Morlat Committed by Nicolas Michon

Fix crash because of unnecessary instanciation of migratable chatrooms. This...

Fix crash because of unnecessary instanciation of migratable chatrooms. This leaded in a crash while sending IMDNs.
Also, comment timing logs of MainDb, as they are very verbose and useless as there is no longer performance issue with it.
parent 423beca3
...@@ -26,6 +26,13 @@ ...@@ -26,6 +26,13 @@
// ============================================================================= // =============================================================================
/*
* The purpose of this class seems to be able to manipulate flag values that are declared as part of an enum.
* The C++ compiler forbids OR/AND operator on enums, however this can be easily workaround by either not using enum for mask but constexpr
* or by doing a basic cast to unsigned int.
* There are below 130 hardly readable lines of code for class doing this, but ~operator doesn't work as expected.
* (just try a &= EnumValue; to convince). TODO: question the interest of keeping this class and switch to simple const unsigned int.
*/
LINPHONE_BEGIN_NAMESPACE LINPHONE_BEGIN_NAMESPACE
template<typename T> template<typename T>
...@@ -58,7 +65,7 @@ public: ...@@ -58,7 +65,7 @@ public:
} }
inline EnumMask &unset (T value) { inline EnumMask &unset (T value) {
*this &= ~value; *this &= ~StorageType(value);
return *this; return *this;
} }
......
...@@ -82,10 +82,13 @@ public: ...@@ -82,10 +82,13 @@ public:
return; return;
} }
migrationRealTime = currentRealTime; migrationRealTime = currentRealTime;
char *tmp = linphone_address_as_string(linphone_proxy_config_get_contact(proxy)); //get the gruu address
IdentityAddress localAddress(tmp);
bctbx_free(tmp);
clientGroupChatRoom = static_pointer_cast<ClientGroupChatRoom>( clientGroupChatRoom = static_pointer_cast<ClientGroupChatRoom>(
//make sure to have a one2one chatroom //make sure to have a one2one chatroom
chatRoom->getCore()->getPrivate()->createChatRoom( chatRoom->getCore()->getPrivate()->createChatRoom(
ChatRoomParams::create(chatRoom->getCapabilities() & ChatRoom::Capabilities::Encrypted, false, ChatRoomParams::ChatRoomBackend::FlexisipChat), chatRoom->getLocalAddress(), chatRoom->getSubject(), {Address(chatRoom->getPeerAddress())} ChatRoomParams::create(chatRoom->getCapabilities() & ChatRoom::Capabilities::Encrypted, false, ChatRoomParams::ChatRoomBackend::FlexisipChat), localAddress, chatRoom->getSubject(), {Address(chatRoom->getPeerAddress())}
) )
); );
clientGroupChatRoom->getPrivate()->setCallSessionListener(this); clientGroupChatRoom->getPrivate()->setCallSessionListener(this);
......
...@@ -680,13 +680,8 @@ void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) { ...@@ -680,13 +680,8 @@ void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) {
if (chatRoom) { if (chatRoom) {
auto capabilities = chatRoom->getCapabilities(); auto capabilities = chatRoom->getCapabilities();
bool migrationEnabled = !!linphone_config_get_int(
linphone_core_get_config(getCore()->getCCore()), if (getCore()->getPrivate()->basicToFlexisipChatroomMigrationEnabled() && (capabilities & ChatRoom::Capabilities::Basic) && (capabilities & ChatRoom::Capabilities::Migratable)) {
"misc",
"enable_basic_to_client_group_chat_room_migration",
FALSE
);
if (migrationEnabled && (capabilities & ChatRoom::Capabilities::Basic) && (capabilities & ChatRoom::Capabilities::Migratable)) {
performMigration = true; performMigration = true;
} }
} }
......
...@@ -47,8 +47,13 @@ LINPHONE_BEGIN_NAMESPACE ...@@ -47,8 +47,13 @@ LINPHONE_BEGIN_NAMESPACE
// Helpers. // Helpers.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Return the better local address to talk with peer address. Result address must contain gru /*
static IdentityAddress getDefaultLocalAddress(const shared_ptr<Core> &core, const IdentityAddress *peerAddress) { * Returns the best local address to talk with peer address.
* If peerAddress is not defined, returns the local address of the default proxy config.
* If withGruu is true, returns the local address with its gruu parameter. FlexisipChat kind of chatroom (also refered as ClientGroupChatRoom)
* require a local address with gruu, unlike basic chatrooms.
*/
static IdentityAddress getDefaultLocalAddress(const shared_ptr<Core> &core, const IdentityAddress *peerAddress, bool withGruu) {
LinphoneCore *cCore = core->getCCore(); LinphoneCore *cCore = core->getCCore();
LinphoneProxyConfig *proxy = nullptr; LinphoneProxyConfig *proxy = nullptr;
...@@ -62,7 +67,8 @@ static IdentityAddress getDefaultLocalAddress(const shared_ptr<Core> &core, cons ...@@ -62,7 +67,8 @@ static IdentityAddress getDefaultLocalAddress(const shared_ptr<Core> &core, cons
IdentityAddress localAddress; IdentityAddress localAddress;
if (proxy) { if (proxy) {
char *identity = linphone_address_as_string(linphone_proxy_config_get_identity_address(proxy)); char *identity = linphone_address_as_string(
withGruu ? linphone_proxy_config_get_contact(proxy) : linphone_proxy_config_get_identity_address(proxy));
localAddress = IdentityAddress(identity); localAddress = IdentityAddress(identity);
bctbx_free(identity); bctbx_free(identity);
} else } else
...@@ -105,6 +111,10 @@ shared_ptr<AbstractChatRoom> CorePrivate::createClientGroupChatRoom ( ...@@ -105,6 +111,10 @@ shared_ptr<AbstractChatRoom> CorePrivate::createClientGroupChatRoom (
lWarning() << "Invalid chat room parameters given for client group chat room creation"; lWarning() << "Invalid chat room parameters given for client group chat room creation";
return nullptr; return nullptr;
} }
if (!conferenceId.getLocalAddress().hasGruu()){
lError() << "createClientGroupChatRoom(): local address must have a gruu.";
return nullptr;
}
shared_ptr<ClientGroupChatRoom> clientGroupChatRoom(new ClientGroupChatRoom(q->getSharedFromThis(), shared_ptr<ClientGroupChatRoom> clientGroupChatRoom(new ClientGroupChatRoom(q->getSharedFromThis(),
conferenceFactoryUri, conferenceFactoryUri,
conferenceId, conferenceId,
...@@ -158,7 +168,7 @@ shared_ptr<AbstractChatRoom> CorePrivate::createClientGroupChatRoom ( ...@@ -158,7 +168,7 @@ shared_ptr<AbstractChatRoom> CorePrivate::createClientGroupChatRoom (
shared_ptr<AbstractChatRoom> CorePrivate::createClientGroupChatRoom(const string &subject, bool fallback, bool encrypted) { shared_ptr<AbstractChatRoom> CorePrivate::createClientGroupChatRoom(const string &subject, bool fallback, bool encrypted) {
L_Q(); L_Q();
IdentityAddress defaultLocalAddress = getDefaultLocalAddress(q->getSharedFromThis(), nullptr); IdentityAddress defaultLocalAddress = getDefaultLocalAddress(q->getSharedFromThis(), nullptr, true);
IdentityAddress conferenceFactoryUri(getConferenceFactoryUri(q->getSharedFromThis(), defaultLocalAddress)); IdentityAddress conferenceFactoryUri(getConferenceFactoryUri(q->getSharedFromThis(), defaultLocalAddress));
shared_ptr<ChatRoomParams> params = ChatRoomParams::create(encrypted, !fallback, ChatRoomParams::ChatRoomBackend::FlexisipChat); shared_ptr<ChatRoomParams> params = ChatRoomParams::create(encrypted, !fallback, ChatRoomParams::ChatRoomBackend::FlexisipChat);
...@@ -178,6 +188,12 @@ shared_ptr<AbstractChatRoom> CorePrivate::createBasicChatRoom ( ...@@ -178,6 +188,12 @@ shared_ptr<AbstractChatRoom> CorePrivate::createBasicChatRoom (
else { else {
BasicChatRoom *basicChatRoom = new BasicChatRoom(q->getSharedFromThis(), conferenceId, params); BasicChatRoom *basicChatRoom = new BasicChatRoom(q->getSharedFromThis(), conferenceId, params);
string conferenceFactoryUri = getConferenceFactoryUri(q->getSharedFromThis(), conferenceId.getLocalAddress()); string conferenceFactoryUri = getConferenceFactoryUri(q->getSharedFromThis(), conferenceId.getLocalAddress());
if (basicToFlexisipChatroomMigrationEnabled()) {
capabilities.set(ChatRoom::Capabilities::Migratable);
}else{
capabilities.unset(ChatRoom::Capabilities::Migratable);
}
if ((capabilities & ChatRoom::Capabilities::Migratable) && !conferenceFactoryUri.empty()) { if ((capabilities & ChatRoom::Capabilities::Migratable) && !conferenceFactoryUri.empty()) {
chatRoom.reset(new BasicToClientGroupChatRoom(shared_ptr<BasicChatRoom>(basicChatRoom))); chatRoom.reset(new BasicToClientGroupChatRoom(shared_ptr<BasicChatRoom>(basicChatRoom)));
} }
...@@ -192,6 +208,7 @@ shared_ptr<AbstractChatRoom> CorePrivate::createBasicChatRoom ( ...@@ -192,6 +208,7 @@ shared_ptr<AbstractChatRoom> CorePrivate::createBasicChatRoom (
return chatRoom; return chatRoom;
} }
shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRoomParams> &params, const IdentityAddress &localAddr, const std::string &subject, const std::list<IdentityAddress> &participants) { shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRoomParams> &params, const IdentityAddress &localAddr, const std::string &subject, const std::list<IdentityAddress> &participants) {
L_Q(); L_Q();
...@@ -203,7 +220,7 @@ shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRo ...@@ -203,7 +220,7 @@ shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRo
lWarning() << "Trying to create chat room with invalid parameters " << params->toString(); lWarning() << "Trying to create chat room with invalid parameters " << params->toString();
return nullptr; return nullptr;
} }
shared_ptr<AbstractChatRoom> chatRoom; shared_ptr<AbstractChatRoom> chatRoom;
if (params->getChatRoomBackend() == ChatRoomParams::ChatRoomBackend::FlexisipChat) { if (params->getChatRoomBackend() == ChatRoomParams::ChatRoomBackend::FlexisipChat) {
string conferenceFactoryUri = getConferenceFactoryUri(q->getSharedFromThis(), localAddr); string conferenceFactoryUri = getConferenceFactoryUri(q->getSharedFromThis(), localAddr);
...@@ -226,9 +243,7 @@ shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRo ...@@ -226,9 +243,7 @@ shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRo
return nullptr; return nullptr;
} }
ChatRoom::CapabilitiesMask capabilities = ChatRoomParams::toCapabilities(params); ChatRoom::CapabilitiesMask capabilities = ChatRoomParams::toCapabilities(params);
if (!!linphone_config_get_bool(linphone_core_get_config(q->getCCore()), "misc", "enable_basic_to_client_group_chat_room_migration", FALSE)) {
capabilities |= ChatRoom::Capabilities::Migratable;
}
chatRoom = createBasicChatRoom(ConferenceId(IdentityAddress(participants.front()), localAddr), chatRoom = createBasicChatRoom(ConferenceId(IdentityAddress(participants.front()), localAddr),
capabilities, capabilities,
params); params);
...@@ -240,16 +255,14 @@ shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRo ...@@ -240,16 +255,14 @@ shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRo
shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRoomParams> &params, const std::string &subject, const std::list<IdentityAddress> &participants) { shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const shared_ptr<ChatRoomParams> &params, const std::string &subject, const std::list<IdentityAddress> &participants) {
L_Q(); L_Q();
IdentityAddress defaultLocalAddress = getDefaultLocalAddress(q->getSharedFromThis(), nullptr,
IdentityAddress defaultLocalAddress = getDefaultLocalAddress(q->getSharedFromThis(), nullptr); params->getChatRoomBackend() == ChatRoomParams::ChatRoomBackend::FlexisipChat);
return createChatRoom(params, defaultLocalAddress, subject, participants); return createChatRoom(params, defaultLocalAddress, subject, participants);
} }
shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const std::string &subject, const std::list<IdentityAddress> &participants) { shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const std::string &subject, const std::list<IdentityAddress> &participants) {
L_Q(); L_Q();
IdentityAddress defaultLocalAddress = getDefaultLocalAddress(q->getSharedFromThis(), nullptr);
shared_ptr<ChatRoomParams> params = ChatRoomParams::getDefaults(q->getSharedFromThis()); shared_ptr<ChatRoomParams> params = ChatRoomParams::getDefaults(q->getSharedFromThis());
if (participants.size() > 1) { if (participants.size() > 1) {
//Try to infer chat room type based on requested participants number //Try to infer chat room type based on requested participants number
...@@ -257,6 +270,8 @@ shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const std::string &subj ...@@ -257,6 +270,8 @@ shared_ptr<AbstractChatRoom> CorePrivate::createChatRoom(const std::string &subj
} else { } else {
params->setChatRoomBackend(ChatRoomParams::ChatRoomBackend::Basic); params->setChatRoomBackend(ChatRoomParams::ChatRoomBackend::Basic);
} }
IdentityAddress defaultLocalAddress = getDefaultLocalAddress(q->getSharedFromThis(), nullptr,
params->getChatRoomBackend() == ChatRoomParams::ChatRoomBackend::FlexisipChat);
return createChatRoom(params, defaultLocalAddress, subject, participants); return createChatRoom(params, defaultLocalAddress, subject, participants);
} }
...@@ -408,7 +423,7 @@ shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const ConferenceId ...@@ -408,7 +423,7 @@ shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const ConferenceId
if (isRtt) { if (isRtt) {
capabilities |= ChatRoom::Capabilities::RealTimeText; capabilities |= ChatRoom::Capabilities::RealTimeText;
} }
if (!!linphone_config_get_bool(linphone_core_get_config(getCCore()), "misc", "enable_basic_to_client_group_chat_room_migration", FALSE)) { if (d->basicToFlexisipChatroomMigrationEnabled()) {
capabilities |= ChatRoom::Capabilities::Migratable; capabilities |= ChatRoom::Capabilities::Migratable;
} }
chatRoom = d->createBasicChatRoom(conferenceId, capabilities, ChatRoomParams::fromCapabilities(capabilities)); chatRoom = d->createBasicChatRoom(conferenceId, capabilities, ChatRoomParams::fromCapabilities(capabilities));
...@@ -435,11 +450,11 @@ shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const IdentityAddre ...@@ -435,11 +450,11 @@ shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const IdentityAddre
if (isRtt) { if (isRtt) {
capabilities |= ChatRoom::Capabilities::RealTimeText; capabilities |= ChatRoom::Capabilities::RealTimeText;
} }
if (!!linphone_config_get_bool(linphone_core_get_config(getCCore()), "misc", "enable_basic_to_client_group_chat_room_migration", FALSE)) { if (d->basicToFlexisipChatroomMigrationEnabled()) {
capabilities |= ChatRoom::Capabilities::Migratable; capabilities |= ChatRoom::Capabilities::Migratable;
} }
shared_ptr<AbstractChatRoom> chatRoom = d->createBasicChatRoom( shared_ptr<AbstractChatRoom> chatRoom = d->createBasicChatRoom(
ConferenceId(peerAddress, getDefaultLocalAddress(getSharedFromThis(), &peerAddress)), ConferenceId(peerAddress, getDefaultLocalAddress(getSharedFromThis(), &peerAddress, false)),
capabilities, capabilities,
ChatRoomParams::fromCapabilities(capabilities) ChatRoomParams::fromCapabilities(capabilities)
); );
......
...@@ -103,11 +103,11 @@ public: ...@@ -103,11 +103,11 @@ public:
const std::list<IdentityAddress> &participants); const std::list<IdentityAddress> &participants);
std::shared_ptr<AbstractChatRoom> createChatRoom(const std::shared_ptr<ChatRoomParams> &params, const IdentityAddress &localAddr, const IdentityAddress &participant); std::shared_ptr<AbstractChatRoom> createChatRoom(const std::shared_ptr<ChatRoomParams> &params, const IdentityAddress &localAddr, const IdentityAddress &participant);
std::shared_ptr<AbstractChatRoom> createChatRoom(const IdentityAddress &participant); std::shared_ptr<AbstractChatRoom> createChatRoom(const IdentityAddress &participant);
void replaceChatRoom (const std::shared_ptr<AbstractChatRoom> &replacedChatRoom, const std::shared_ptr<AbstractChatRoom> &newChatRoom); void replaceChatRoom (const std::shared_ptr<AbstractChatRoom> &replacedChatRoom, const std::shared_ptr<AbstractChatRoom> &newChatRoom);
void doLater(const std::function<void ()> &something); void doLater(const std::function<void ()> &something);
belle_sip_main_loop_t *getMainLoop(); belle_sip_main_loop_t *getMainLoop();
bool basicToFlexisipChatroomMigrationEnabled()const;
std::unique_ptr<MainDb> mainDb; std::unique_ptr<MainDb> mainDb;
std::unique_ptr<RemoteConferenceListEventHandler> remoteListEventHandler; std::unique_ptr<RemoteConferenceListEventHandler> remoteListEventHandler;
std::unique_ptr<LocalConferenceListEventHandler> localListEventHandler; std::unique_ptr<LocalConferenceListEventHandler> localListEventHandler;
......
...@@ -187,6 +187,12 @@ void CorePrivate::enableFriendListsSubscription(bool enable) { ...@@ -187,6 +187,12 @@ void CorePrivate::enableFriendListsSubscription(bool enable) {
} }
} }
bool CorePrivate::basicToFlexisipChatroomMigrationEnabled()const{
L_Q();
return linphone_config_get_bool(linphone_core_get_config(q->getCCore()), "misc", "enable_basic_to_client_group_chat_room_migration", FALSE);
}
// ============================================================================= // =============================================================================
Core::Core () : Object(*new CorePrivate) { Core::Core () : Object(*new CorePrivate) {
......
...@@ -1931,7 +1931,7 @@ int MainDb::getEventCount (FilterMask mask) const { ...@@ -1931,7 +1931,7 @@ int MainDb::getEventCount (FilterMask mask) const {
mask mask
); );
DurationLogger durationLogger("Get event count with mask=" + Utils::toString(mask) + "."); //DurationLogger durationLogger("Get event count with mask=" + Utils::toString(mask) + ".");
return L_DB_TRANSACTION { return L_DB_TRANSACTION {
L_D(); L_D();
...@@ -1979,11 +1979,13 @@ list<shared_ptr<EventLog>> MainDb::getConferenceNotifiedEvents ( ...@@ -1979,11 +1979,13 @@ list<shared_ptr<EventLog>> MainDb::getConferenceNotifiedEvents (
const string query = Statements::get(Statements::SelectConferenceEvents) + const string query = Statements::get(Statements::SelectConferenceEvents) +
string(" AND notify_id > :lastNotifyId"); string(" AND notify_id > :lastNotifyId");
/*
DurationLogger durationLogger( DurationLogger durationLogger(
"Get conference notified events of: (peer=" + conferenceId.getPeerAddress().asString() + "Get conference notified events of: (peer=" + conferenceId.getPeerAddress().asString() +
", local=" + conferenceId.getLocalAddress().asString() + ", local=" + conferenceId.getLocalAddress().asString() +
", lastNotifyId=" + Utils::toString(lastNotifyId) + ")." ", lastNotifyId=" + Utils::toString(lastNotifyId) + ")."
); );
*/
return L_DB_TRANSACTION { return L_DB_TRANSACTION {
L_D(); L_D();
...@@ -2001,10 +2003,12 @@ list<shared_ptr<EventLog>> MainDb::getConferenceNotifiedEvents ( ...@@ -2001,10 +2003,12 @@ list<shared_ptr<EventLog>> MainDb::getConferenceNotifiedEvents (
} }
int MainDb::getChatMessageCount (const ConferenceId &conferenceId) const { int MainDb::getChatMessageCount (const ConferenceId &conferenceId) const {
/*
DurationLogger durationLogger( DurationLogger durationLogger(
"Get chat messages count of: (peer=" + conferenceId.getPeerAddress().asString() + "Get chat messages count of: (peer=" + conferenceId.getPeerAddress().asString() +
", local=" + conferenceId.getLocalAddress().asString() + ")." ", local=" + conferenceId.getLocalAddress().asString() + ")."
); );
*/
return L_DB_TRANSACTION { return L_DB_TRANSACTION {
L_D(); L_D();
...@@ -2045,10 +2049,12 @@ int MainDb::getUnreadChatMessageCount (const ConferenceId &conferenceId) const { ...@@ -2045,10 +2049,12 @@ int MainDb::getUnreadChatMessageCount (const ConferenceId &conferenceId) const {
query += " direction = " + Utils::toString(int(ChatMessage::Direction::Incoming)) + query += " direction = " + Utils::toString(int(ChatMessage::Direction::Incoming)) +
+ " AND state <> " + Utils::toString(int(ChatMessage::State::Displayed)); + " AND state <> " + Utils::toString(int(ChatMessage::State::Displayed));
/*
DurationLogger durationLogger( DurationLogger durationLogger(
"Get unread chat messages count of: (peer=" + conferenceId.getPeerAddress().asString() + "Get unread chat messages count of: (peer=" + conferenceId.getPeerAddress().asString() +
", local=" + conferenceId.getLocalAddress().asString() + ")." ", local=" + conferenceId.getLocalAddress().asString() + ")."
); );
*/
return L_DB_TRANSACTION { return L_DB_TRANSACTION {
int count = 0; int count = 0;
...@@ -2077,10 +2083,12 @@ void MainDb::markChatMessagesAsRead (const ConferenceId &conferenceId) const { ...@@ -2077,10 +2083,12 @@ void MainDb::markChatMessagesAsRead (const ConferenceId &conferenceId) const {
" SELECT event_id FROM conference_event WHERE chat_room_id = :chatRoomId" " SELECT event_id FROM conference_event WHERE chat_room_id = :chatRoomId"
") AND direction = " + Utils::toString(int(ChatMessage::Direction::Incoming)); ") AND direction = " + Utils::toString(int(ChatMessage::Direction::Incoming));
/*
DurationLogger durationLogger( DurationLogger durationLogger(
"Mark chat messages as read of: (peer=" + conferenceId.getPeerAddress().asString() + "Mark chat messages as read of: (peer=" + conferenceId.getPeerAddress().asString() +
", local=" + conferenceId.getLocalAddress().asString() + ")." ", local=" + conferenceId.getLocalAddress().asString() + ")."
); );
*/
L_DB_TRANSACTION { L_DB_TRANSACTION {
L_D(); L_D();
...@@ -2230,11 +2238,12 @@ list<shared_ptr<ChatMessage>> MainDb::findChatMessages ( ...@@ -2230,11 +2238,12 @@ list<shared_ptr<ChatMessage>> MainDb::findChatMessages (
static const string query = Statements::get(Statements::SelectConferenceEvents) + static const string query = Statements::get(Statements::SelectConferenceEvents) +
string(" AND imdn_message_id = :imdnMessageId"); string(" AND imdn_message_id = :imdnMessageId");
/*
DurationLogger durationLogger( DurationLogger durationLogger(
"Find chat messages: (peer=" + conferenceId.getPeerAddress().asString() + "Find chat messages: (peer=" + conferenceId.getPeerAddress().asString() +
", local=" + conferenceId.getLocalAddress().asString() + ")." ", local=" + conferenceId.getLocalAddress().asString() + ")."
); );
*/
return L_DB_TRANSACTION { return L_DB_TRANSACTION {
L_D(); L_D();
...@@ -2265,10 +2274,12 @@ list<shared_ptr<ChatMessage>> MainDb::findChatMessagesToBeNotifiedAsDelivered ( ...@@ -2265,10 +2274,12 @@ list<shared_ptr<ChatMessage>> MainDb::findChatMessagesToBeNotifiedAsDelivered (
static const string query = Statements::get(Statements::SelectConferenceEvents) + static const string query = Statements::get(Statements::SelectConferenceEvents) +
string(" AND direction = :direction AND delivery_notification_required <> 0"); string(" AND direction = :direction AND delivery_notification_required <> 0");
/*
DurationLogger durationLogger( DurationLogger durationLogger(
"Find chat messages to be notified as delivered: (peer=" + conferenceId.getPeerAddress().asString() + "Find chat messages to be notified as delivered: (peer=" + conferenceId.getPeerAddress().asString() +
", local=" + conferenceId.getLocalAddress().asString() + ")." ", local=" + conferenceId.getLocalAddress().asString() + ")."
); );
*/
return L_DB_TRANSACTION { return L_DB_TRANSACTION {
L_D(); L_D();
...@@ -2329,11 +2340,13 @@ list<shared_ptr<EventLog>> MainDb::getHistoryRange ( ...@@ -2329,11 +2340,13 @@ list<shared_ptr<EventLog>> MainDb::getHistoryRange (
if (begin > 0) if (begin > 0)
query += " OFFSET " + Utils::toString(begin); query += " OFFSET " + Utils::toString(begin);
/*
DurationLogger durationLogger( DurationLogger durationLogger(
"Get history range of: (peer=" + conferenceId.getPeerAddress().asString() + "Get history range of: (peer=" + conferenceId.getPeerAddress().asString() +
", local=" + conferenceId.getLocalAddress().asString() + ", local=" + conferenceId.getLocalAddress().asString() +
", begin=" + Utils::toString(begin) + ", end=" + Utils::toString(end) + ")." ", begin=" + Utils::toString(begin) + ", end=" + Utils::toString(end) + ")."
); );
*/
return L_DB_TRANSACTION { return L_DB_TRANSACTION {
L_D(); L_D();
...@@ -2379,11 +2392,13 @@ void MainDb::cleanHistory (const ConferenceId &conferenceId, FilterMask mask) { ...@@ -2379,11 +2392,13 @@ void MainDb::cleanHistory (const ConferenceId &conferenceId, FilterMask mask) {
ConferenceCallFilter, ConferenceChatMessageFilter, ConferenceInfoFilter, ConferenceInfoNoDeviceFilter ConferenceCallFilter, ConferenceChatMessageFilter, ConferenceInfoFilter, ConferenceInfoNoDeviceFilter
}, mask); }, mask);
/*
DurationLogger durationLogger( DurationLogger durationLogger(
"Clean history of: (peer=" + conferenceId.getPeerAddress().asString() + "Clean history of: (peer=" + conferenceId.getPeerAddress().asString() +
", local=" + conferenceId.getLocalAddress().asString() + ", local=" + conferenceId.getLocalAddress().asString() +
", mask=" + Utils::toString(mask) + ")." ", mask=" + Utils::toString(mask) + ")."
); );
*/
L_DB_TRANSACTION { L_DB_TRANSACTION {
L_D(); L_D();
......
...@@ -105,7 +105,7 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes ...@@ -105,7 +105,7 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,1000));
/*make sure marie receives first notification before terminating*/ /*make sure marie receives first notification before terminating*/
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,5000));
if (refresh_type==AutoRefresh){ if (refresh_type==AutoRefresh){
wait_for_list(lcs,NULL,0,6000); wait_for_list(lcs,NULL,0,6000);
...@@ -116,7 +116,7 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes ...@@ -116,7 +116,7 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes
}else if (refresh_type==ManualRefresh){ }else if (refresh_type==ManualRefresh){
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionExpiring,1,4000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionExpiring,1,4000));
linphone_event_update_subscribe(lev,NULL); linphone_event_update_subscribe(lev,NULL);
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,2,2000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,2,5000));
} }
if (terminated_by_subscriber){ if (terminated_by_subscriber){
...@@ -126,8 +126,8 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes ...@@ -126,8 +126,8 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes
linphone_event_terminate(pauline->lev); linphone_event_terminate(pauline->lev);
} }
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,5000));
bctbx_list_free(lcs); bctbx_list_free(lcs);
linphone_event_unref(lev); linphone_event_unref(lev);
......
...@@ -1649,17 +1649,19 @@ void sequential_forking(void) { ...@@ -1649,17 +1649,19 @@ void sequential_forking(void) {
/*marie accepts the call on its second device*/ /*marie accepts the call on its second device*/
linphone_call_accept(call); linphone_call_accept(call);
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,10000));
/*second device should have received nothing*/ /*second device should have received nothing*/
BC_ASSERT_EQUAL(marie2->stat.number_of_LinphoneCallEnd, 0, int, "%d"); BC_ASSERT_EQUAL(marie2->stat.number_of_LinphoneCallEnd, 0, int, "%d");
linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); linphone_call_terminate(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallReleased,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallReleased,1,5000));
end: end:
linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline);
...@@ -1716,17 +1718,20 @@ void sequential_forking_with_timeout_for_highest_priority(void) { ...@@ -1716,17 +1718,20 @@ void sequential_forking_with_timeout_for_highest_priority(void) {
/*marie accepts the call on her third device*/ /*marie accepts the call on her third device*/
linphone_call_accept(call); linphone_call_accept(call);
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallConnected,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallStreamsRunning,1,10000));
/*second device should stop ringing*/ /*second device should stop ringing*/
BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,10000));
linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); linphone_call_terminate(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallReleased,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallReleased,1,10000));
/*first device should have received nothing*/ /*first device should have received nothing*/
BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallEnd, 0, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallEnd, 0, int, "%d");
...@@ -1780,17 +1785,19 @@ void sequential_forking_with_no_response_for_highest_priority(void) { ...@@ -1780,17 +1785,19 @@ void sequential_forking_with_no_response_for_highest_priority(void) {
/*marie accepts the call on her second device*/ /*marie accepts the call on her second device*/
linphone_call_accept(call); linphone_call_accept(call);
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallConnected,1,10000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallStreamsRunning,1,10000));
/*the first device should finish*/ /*the first device should finish*/
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd, 1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd, 1, 3000));
linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); linphone_call_terminate(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallReleased,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallReleased,1,1000));
end: end:
linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline);
...@@ -1851,11 +1858,13 @@ void sequential_forking_with_insertion_of_higher_priority(void) { ...@@ -1851,11 +1858,13 @@ void sequential_forking_with_insertion_of_higher_priority(void) {
BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallStreamsRunning,1,1000));
/*second device should stop ringing*/ /*second device should stop ringing*/
BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,3000));
linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); linphone_call_terminate(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallReleased,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallReleased,1,5000));
/*first device should have received nothing*/ /*first device should have received nothing*/
BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallEnd, 0, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallEnd, 0, int, "%d");
...@@ -1927,8 +1936,10 @@ void sequential_forking_with_fallback_route(void) { ...@@ -1927,8 +1936,10 @@ void sequential_forking_with_fallback_route(void) {
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000));
linphone_call_terminate(linphone_core_get_current_call(marie->lc)); linphone_call_terminate(linphone_core_get_current_call(marie->lc));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallReleased,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallReleased,1,3000));
/*first device should have received nothing*/ /*first device should have received nothing*/
BC_ASSERT_EQUAL(pauline2->stat.number_of_LinphoneCallEnd, 0, int, "%d"); BC_ASSERT_EQUAL(pauline2->stat.number_of_LinphoneCallEnd, 0, int, "%d");
......
...@@ -387,6 +387,7 @@ static void lime_x3dh_message_test (bool_t with_composing, bool_t with_response, ...@@ -387,6 +387,7 @@ static void lime_x3dh_message_test (bool_t with_composing, bool_t with_response,
coresManagerList = bctbx_list_append(coresManagerList, marie); coresManagerList = bctbx_list_append(coresManagerList, marie);
coresManagerList = bctbx_list_append(coresManagerList, pauline); coresManagerList = bctbx_list_append(coresManagerList, pauline);
int dummy = 0; int dummy = 0;
LinphoneChatMessage* msg;
bctbx_list_t *coresList = init_core_for_conference(coresManagerList); bctbx_list_t *coresList = init_core_for_conference(coresManagerList);
start_core_for_conference(coresManagerList); start_core_for_conference(coresManagerList);
...@@ -417,7 +418,8 @@ static void lime_x3dh_message_test (bool_t with_composing, bool_t with_response, ...@@ -417,7 +418,8 @@ static void lime_x3dh_message_test (bool_t with_composing, bool_t with_response,
// Marie sends the message // Marie sends the message
const char *marieMessage = "Hey ! What's up ?"; const char *marieMessage = "Hey ! What's up ?";
_send_message(marieCr, marieMessage); msg = _send_message(marieCr, marieMessage);
linphone_chat_message_unref(msg);
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 1, 10000)); BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 1, 10000));
LinphoneChatMessage *paulineLastMsg = pauline->stat.last_received_chat_message; LinphoneChatMessage *paulineLastMsg = pauline->stat.last_received_chat_message;
if (!BC_ASSERT_PTR_NOT_NULL(paulineLastMsg))