diff --git a/src/conference/conference-info.cpp b/src/conference/conference-info.cpp index 87362e7e9185ae52c809be4f57f3c67459f748d0..331c4efb6df624452ba53f93fbf91d6eb121aef9 100644 --- a/src/conference/conference-info.cpp +++ b/src/conference/conference-info.cpp @@ -49,7 +49,13 @@ const std::shared_ptr<Address> &ConferenceInfo::getOrganizerAddress() const { } void ConferenceInfo::setOrganizer(const std::shared_ptr<const ParticipantInfo> &organizer) { - mOrganizer = organizer->clone()->toSharedPtr(); + const auto &participant = findParticipant(organizer->getAddress()); + if (participant) { + mOrganizer = participant; + mOrganizer->addParameters(organizer->getAllParameters()); + } else { + mOrganizer = organizer->clone()->toSharedPtr(); + } } void ConferenceInfo::setOrganizer(const std::shared_ptr<const Address> &organizer) { @@ -111,13 +117,15 @@ void ConferenceInfo::addParticipants(const ConferenceInfo::participant_list_t &p void ConferenceInfo::addParticipant(const std::shared_ptr<const ParticipantInfo> &participantInfo) { const auto &address = participantInfo->getAddress(); - if (!hasParticipant(address)) { + const auto &participant = findParticipant(address); + const auto &organizerAddress = mOrganizer ? mOrganizer->getAddress() : nullptr; + const auto isOrganizer = (organizerAddress && (address->weakEqual(*organizerAddress))); + if (!participant) { std::shared_ptr<ParticipantInfo> newInfo = nullptr; - // Check whetner the participant to be added is the organizer - if (mOrganizer && (participantInfo->getAddress()->weakEqual(*mOrganizer->getAddress()))) { - // Update the organizer role and parameters + // Check whether the participant to be added is the organizer + if (isOrganizer) { + // Update the organizer parameters newInfo = mOrganizer; - newInfo->setRole(participantInfo->getRole()); newInfo->addParameters(participantInfo->getAllParameters()); } else { newInfo = participantInfo->clone()->toSharedPtr(); @@ -129,6 +137,10 @@ void ConferenceInfo::addParticipant(const std::shared_ptr<const ParticipantInfo> } else { lInfo() << "Participant with address " << *address << " is already in the list of conference info " << this << " (address " << (getUri() ? getUri()->toString() : std::string("<unknown address>")) << ")"; + if (isOrganizer) { + // Update the organizer parameters + participant->addParameters(participantInfo->getAllParameters()); + } } } @@ -142,14 +154,14 @@ void ConferenceInfo::removeParticipant(const std::shared_ptr<const ParticipantIn } void ConferenceInfo::removeParticipant(const std::shared_ptr<const Address> &participant) { - auto it = findParticipantIt(participant); - if (it == mParticipants.cend()) { - lDebug() << "Unable to remove participant with address " << *participant << " in conference info " << this - << " (address " << (getUri() ? getUri()->toString() : std::string("<unknown address>")) << ")"; - } else { + if (hasParticipant(participant)) { lInfo() << "Participant with address " << *participant << " has been removed from conference info " << this << " (address " << (getUri() ? getUri()->toString() : std::string("<unknown address>")) << ")"; + auto it = findParticipantIt(participant); mParticipants.erase(it); + } else { + lDebug() << "Unable to remove participant with address " << *participant << " in conference info " << this + << " (address " << (getUri() ? getUri()->toString() : std::string("<unknown address>")) << ")"; } } @@ -184,8 +196,8 @@ ConferenceInfo::findParticipant(const std::shared_ptr<const Address> &address) c if (it != mParticipants.end()) { return *it; }; - lInfo() << "Unable to find participant with address " << *address << " in conference info " << this << " (address " - << (getUri() ? getUri()->toString() : std::string("<unknown address>")) << ")"; + lDebug() << "Unable to find participant with address " << *address << " in conference info " << this << " (address " + << (getUri() ? getUri()->toString() : std::string("<unknown address>")) << ")"; return nullptr; } diff --git a/src/db/internal/statements.cpp b/src/db/internal/statements.cpp index f58ab8d38fc903034c3088f0de13b2ab203d908f..380c93574cee20b71f34e03d3f23498d3a12be94 100644 --- a/src/db/internal/statements.cpp +++ b/src/db/internal/statements.cpp @@ -124,7 +124,7 @@ constexpr const char *select[SelectCount] = { /* SelectConferenceInfoParticipantId */ R"( SELECT id FROM conference_info_participant - WHERE conference_info_id = :1 AND participant_sip_address_id = :2 and is_organizer = :3 + WHERE conference_info_id = :1 AND participant_sip_address_id = :2 )", /* SelectConferenceInfoOrganizerId */ R"( diff --git a/src/db/main-db-p.h b/src/db/main-db-p.h index ae6f571324623fb51d1c6a3878ec05b4e355e864..5ff5bf22dbdc32f8d5459f1870f403eabce899f1 100644 --- a/src/db/main-db-p.h +++ b/src/db/main-db-p.h @@ -75,16 +75,23 @@ private: const long long participantId) const; long long insertConferenceInfo(const std::shared_ptr<ConferenceInfo> &conferenceInfo, const std::shared_ptr<ConferenceInfo> &oldConferenceInfo); + long long insertOrUpdateConferenceInfoParticipant(long long conferenceInfoId, + const std::shared_ptr<ParticipantInfo> &participantInfo, + bool deleted, + bool isOrganizer, + bool isParticipant); long long insertOrUpdateConferenceInfoParticipant(long long conferenceInfoId, long long participantSipAddressId, bool deleted, const ParticipantInfo::participant_params_t params, - bool isOrganizer); + bool isOrganizer, + bool isParticipant); long long insertOrUpdateConferenceInfoOrganizer(long long conferenceInfoId, long long organizerSipAddressId, - const ParticipantInfo::participant_params_t params); + const ParticipantInfo::participant_params_t params, + bool isParticipant); void insertOrUpdateConferenceInfoParticipantParams(long long conferenceInfoParticipantId, - const ParticipantInfo::participant_params_t params); + const ParticipantInfo::participant_params_t params) const; long long insertOrUpdateConferenceCall(const std::shared_ptr<CallLog> &callLog, const std::shared_ptr<ConferenceInfo> &conferenceInfo = nullptr); @@ -97,9 +104,7 @@ private: long long selectChatRoomParticipantId(long long chatRoomId, long long participantSipAddressId) const; long long selectOneToOneChatRoomId(long long sipAddressIdA, long long sipAddressIdB, bool encrypted) const; long long selectConferenceInfoId(long long uriSipAddressId); - long long selectConferenceInfoParticipantId(long long conferenceInfoId, - long long participantSipAddressId, - bool isOrganizer) const; + long long selectConferenceInfoParticipantId(long long conferenceInfoId, long long participantSipAddressId) const; long long selectConferenceCallId(const std::string &callId); void deleteContents(long long chatMessageId); @@ -196,7 +201,7 @@ private: // --------------------------------------------------------------------------- #ifdef HAVE_DB_STORAGE - std::shared_ptr<ConferenceInfo> selectConferenceInfo(const soci::row &row) const; + std::shared_ptr<ConferenceInfo> selectConferenceInfo(const soci::row &row); #endif // --------------------------------------------------------------------------- diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 740dc9962e22de188de2ca3fe69bd8d27a52a018..0d598c43ff6680b21fb97fa3d6650d01e82b8e78 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -71,7 +71,7 @@ LINPHONE_BEGIN_NAMESPACE #ifdef HAVE_DB_STORAGE namespace { -constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 26); +constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 27); constexpr unsigned int ModuleVersionFriends = makeVersion(1, 0, 0); constexpr unsigned int ModuleVersionLegacyFriendsImport = makeVersion(1, 0, 0); constexpr unsigned int ModuleVersionLegacyHistoryImport = makeVersion(1, 0, 0); @@ -582,7 +582,9 @@ long long MainDbPrivate::insertConferenceInfo(const std::shared_ptr<ConferenceIn lError() << "Trying to insert a Conference Info without organizer or URI!"; return -1; } - const long long &organizerSipAddressId = insertSipAddress(conferenceInfo->getOrganizerAddress()); + const auto &organizer = conferenceInfo->getOrganizer(); + const auto &organizerAddress = organizer->getAddress(); + const long long &organizerSipAddressId = insertSipAddress(organizerAddress); const long long &uriSipAddressid = insertSipAddress(conferenceUri); auto startTime = dbSession.getTimeWithSociIndicator(conferenceInfo->getDateTime()); const unsigned int duration = conferenceInfo->getDuration(); @@ -633,13 +635,18 @@ long long MainDbPrivate::insertConferenceInfo(const std::shared_ptr<ConferenceIn conferenceInfoId = dbSession.getLastInsertId(); } - insertOrUpdateConferenceInfoOrganizer(conferenceInfoId, organizerSipAddressId, - conferenceInfo->getOrganizer()->getAllParameters()); - const auto &participantList = conferenceInfo->getParticipants(); + const bool isOrganizerAParticipant = + std::find_if(participantList.cbegin(), participantList.cend(), [&organizerAddress](const auto &info) { + return organizerAddress->weakEqual(*info->getAddress()); + }) != participantList.cend(); + insertOrUpdateConferenceInfoOrganizer(conferenceInfoId, organizerSipAddressId, organizer->getAllParameters(), + isOrganizerAParticipant); + for (const auto &participantInfo : participantList) { - insertOrUpdateConferenceInfoParticipant(conferenceInfoId, insertSipAddress(participantInfo->getAddress()), - false, participantInfo->getAllParameters(), false); + const auto participantAddress = participantInfo->getAddress(); + insertOrUpdateConferenceInfoParticipant(conferenceInfoId, participantInfo, false, + participantAddress->weakEqual(*organizerAddress), true); } for (const auto &oldParticipantInfo : dbParticipantList) { @@ -648,9 +655,11 @@ long long MainDbPrivate::insertConferenceInfo(const std::shared_ptr<ConferenceIn return (p->getAddress()->weakEqual(*oldParticipantInfo->getAddress())); }) == participantList.cend()); if (deleted) { - insertOrUpdateConferenceInfoParticipant(conferenceInfoId, - insertSipAddress(oldParticipantInfo->getAddress()), true, - oldParticipantInfo->getAllParameters(), false); + const auto participantAddress = oldParticipantInfo->getAddress(); + const auto &isOrganizer = participantAddress->weakEqual(*organizerAddress); + // If the participant to be deleted is the organizer, do not change the participant information parameters + const auto &info = isOrganizer ? organizer : oldParticipantInfo; + insertOrUpdateConferenceInfoParticipant(conferenceInfoId, info, true, isOrganizer, true); } } @@ -662,8 +671,8 @@ long long MainDbPrivate::insertConferenceInfo(const std::shared_ptr<ConferenceIn #endif } -void MainDbPrivate::insertOrUpdateConferenceInfoParticipantParams(long long conferenceInfoParticipantId, - const ParticipantInfo::participant_params_t params) { +void MainDbPrivate::insertOrUpdateConferenceInfoParticipantParams( + long long conferenceInfoParticipantId, const ParticipantInfo::participant_params_t params) const { #ifdef HAVE_DB_STORAGE soci::session *session = dbSession.getBackendSession(); ParticipantInfo::participant_params_t paramsCopy = params; @@ -688,8 +697,9 @@ void MainDbPrivate::insertOrUpdateConferenceInfoParticipantParams(long long conf // Add new name values pairs for (const auto &[name, value] : paramsCopy) { - *session << "INSERT INTO conference_info_participant_params (conference_info_participant_id, name, value) " - "VALUES ( :participantId, :name, :value)", + *session << "INSERT OR REPLACE INTO conference_info_participant_params (conference_info_participant_id, name, " + "value) " + "VALUES ( :participantId, :name, :value )", soci::use(conferenceInfoParticipantId), soci::use(name), soci::use(value); } #endif @@ -697,31 +707,48 @@ void MainDbPrivate::insertOrUpdateConferenceInfoParticipantParams(long long conf long long MainDbPrivate::insertOrUpdateConferenceInfoOrganizer(long long conferenceInfoId, long long organizerSipAddressId, - const ParticipantInfo::participant_params_t params) { - return insertOrUpdateConferenceInfoParticipant(conferenceInfoId, organizerSipAddressId, false, params, true); + const ParticipantInfo::participant_params_t params, + bool isParticipant) { + return insertOrUpdateConferenceInfoParticipant(conferenceInfoId, organizerSipAddressId, false, params, true, + isParticipant); +} + +long long +MainDbPrivate::insertOrUpdateConferenceInfoParticipant(long long conferenceInfoId, + const std::shared_ptr<ParticipantInfo> &participantInfo, + bool deleted, + bool isOrganizer, + bool isParticipant) { + return insertOrUpdateConferenceInfoParticipant(conferenceInfoId, insertSipAddress(participantInfo->getAddress()), + deleted, participantInfo->getAllParameters(), isOrganizer, + isParticipant); } long long MainDbPrivate::insertOrUpdateConferenceInfoParticipant(long long conferenceInfoId, long long participantSipAddressId, bool deleted, const ParticipantInfo::participant_params_t params, - bool isOrganizer) { + bool isOrganizer, + bool isParticipant) { #ifdef HAVE_DB_STORAGE long long conferenceInfoParticipantId = - selectConferenceInfoParticipantId(conferenceInfoId, participantSipAddressId, isOrganizer); + selectConferenceInfoParticipantId(conferenceInfoId, participantSipAddressId); auto paramsStr = ParticipantInfo::memberParametersToString(params); int participantDeleted = deleted ? 1 : 0; int isOrganizerInt = isOrganizer ? 1 : 0; + int isParticipantInt = isParticipant ? 1 : 0; if (conferenceInfoParticipantId >= 0) { - *dbSession.getBackendSession() << "UPDATE conference_info_participant SET deleted = :deleted WHERE id = :id", - soci::use(participantDeleted), soci::use(conferenceInfoParticipantId); + *dbSession.getBackendSession() << "UPDATE conference_info_participant SET deleted = :deleted, is_organizer = " + ":isOrganizer, is_participant = :isParticipant WHERE id = :id", + soci::use(participantDeleted), soci::use(isOrganizerInt), soci::use(isParticipantInt), + soci::use(conferenceInfoParticipantId); } else { *dbSession.getBackendSession() << "INSERT INTO conference_info_participant (conference_info_id, participant_sip_address_id, deleted, " - "is_organizer)" - " VALUES (:conferenceInfoId, :participantSipAddressId, :deleted, :isOrganizer)", + "is_organizer, is_participant)" + " VALUES (:conferenceInfoId, :participantSipAddressId, :deleted, :isOrganizer, :isParticipant)", soci::use(conferenceInfoId), soci::use(participantSipAddressId), soci::use(participantDeleted), - soci::use(isOrganizerInt); + soci::use(isOrganizerInt), soci::use(isParticipantInt); conferenceInfoParticipantId = dbSession.getLastInsertId(); } @@ -935,15 +962,13 @@ long long MainDbPrivate::selectConferenceInfoId(long long uriSipAddressId) { } long long MainDbPrivate::selectConferenceInfoParticipantId(long long conferenceInfoId, - long long participantSipAddressId, - bool isOrganizer) const { + long long participantSipAddressId) const { #ifdef HAVE_DB_STORAGE long long conferenceInfoParticipantId; - int isOrganizerInt = isOrganizer ? 1 : 0; soci::session *session = dbSession.getBackendSession(); *session << Statements::get(Statements::SelectConferenceInfoParticipantId), soci::use(conferenceInfoId), - soci::use(participantSipAddressId), soci::use(isOrganizerInt), soci::into(conferenceInfoParticipantId); + soci::use(participantSipAddressId), soci::into(conferenceInfoParticipantId); return session->got_data() ? conferenceInfoParticipantId : -1; #else @@ -1852,7 +1877,8 @@ ParticipantInfo::participant_params_t MainDbPrivate::migrateConferenceInfoPartic } participantParams.insert(std::make_pair(name, actualValue)); - *session << "INSERT INTO conference_info_participant_params (conference_info_participant_id, name, value) " + *session << "INSERT OR REPLACE INTO conference_info_participant_params (conference_info_participant_id, name, " + "value) " "VALUES ( :participantId, :name, :value )", soci::use(participantId), soci::use(name), soci::use(actualValue); } @@ -1861,7 +1887,7 @@ ParticipantInfo::participant_params_t MainDbPrivate::migrateConferenceInfoPartic } #ifdef HAVE_DB_STORAGE -shared_ptr<ConferenceInfo> MainDbPrivate::selectConferenceInfo(const soci::row &row) const { +shared_ptr<ConferenceInfo> MainDbPrivate::selectConferenceInfo(const soci::row &row) { const long long &dbConferenceInfoId = dbSession.resolveId(row, 0); auto conferenceInfo = getConferenceInfoFromCache(dbConferenceInfoId); @@ -1908,17 +1934,16 @@ shared_ptr<ConferenceInfo> MainDbPrivate::selectConferenceInfo(const soci::row & organizerAddress = Address::create(organizerRow.get<string>(1)); const string organizerParamsStr = organizerRow.get<string>(2); const long long &organizerId = dbSession.resolveId(organizerRow, 3); - *session << "INSERT INTO conference_info_participant (conference_info_id, participant_sip_address_id, deleted, " - "is_organizer) VALUES (:conferenceInfoId, :participantSipAddressId, :deleted, :isOrganizer)", - soci::use(dbConferenceInfoId), soci::use(organizerSipAddressId), soci::use(0), soci::use(1); - const long long organizerIdInParticipantTable = dbSession.getLastInsertId(); + // The flag is_participant is set to true here as by default the organizer is also a participant + const long long organizerIdInParticipantTable = + insertOrUpdateConferenceInfoOrganizer(dbConferenceInfoId, organizerSipAddressId, organizerParams, true); const auto unprocessedOrganizerParams = ParticipantInfo::stringToMemberParameters(organizerParamsStr); organizerParams = migrateConferenceInfoParticipantParams(unprocessedOrganizerParams, organizerIdInParticipantTable); // Delete entry from conference info organizer - *session << "DELETE FROM conference_info_organizer WHERE id = :organizerId", soci::use(organizerId); + *session << "DELETE FROM conference_info_organizer WHERE id = :organizerId", soci::use(organizerId); } else { static const string organizerInParticipantTableQuery = "SELECT sip_address.value, conference_info_participant.id" @@ -1951,7 +1976,7 @@ shared_ptr<ConferenceInfo> MainDbPrivate::selectConferenceInfo(const soci::row & " WHERE conference_info.id = :conferenceInfoId" " AND sip_address.id = conference_info_participant.participant_sip_address_id" " AND conference_info_participant.conference_info_id = conference_info.id AND " - "conference_info_participant.is_organizer = 0"; + "conference_info_participant.is_participant = 1"; soci::rowset<soci::row> participantRows = (session->prepare << participantQuery, soci::use(dbConferenceInfoId)); for (const auto &participantRow : participantRows) { @@ -2553,6 +2578,15 @@ void MainDbPrivate::updateSchema() { // Sanity check *session << "SELECT name FROM conference_info_participant_params"; } + + if (version < makeVersion(1, 0, 27)) { + try { + *session << "ALTER TABLE conference_info ADD COLUMN security_level INT UNSIGNED DEFAULT 0"; + } catch (const soci::soci_error &e) { + lDebug() << "Column 'security_level' already exists in table 'conference_info'"; + } + *session << "ALTER TABLE conference_info_participant ADD COLUMN is_participant BOOLEAN NOT NULL DEFAULT 1"; + } // /!\ Warning : if varchar columns < 255 were to be indexed, their size must be set back to 191 = max indexable // (KEY or UNIQUE) varchar size for mysql < 5.7 with charset utf8mb4 (both here and in column creation) @@ -5524,7 +5558,7 @@ void MainDb::deleteChatRoomParticipantDevice(const shared_ptr<AbstractChatRoom> // ----------------------------------------------------------------------------- -std::list<std::shared_ptr<ConferenceInfo>> MainDb::getConferenceInfos(time_t afterThisTime) const { +std::list<std::shared_ptr<ConferenceInfo>> MainDb::getConferenceInfos(time_t afterThisTime) { #ifdef HAVE_DB_STORAGE string query = "SELECT conference_info.id, organizer_sip_address.value, uri_sip_address.value," " start_time, duration, subject, description, state, ics_sequence, ics_uid, security_level" @@ -5571,7 +5605,7 @@ std::list<std::shared_ptr<ConferenceInfo>> MainDb::getConferenceInfos(time_t aft } std::list<std::shared_ptr<ConferenceInfo>> -MainDb::getConferenceInfosForLocalAddress(const std::shared_ptr<Address> &localAddress) const { +MainDb::getConferenceInfosForLocalAddress(const std::shared_ptr<Address> &localAddress) { #ifdef HAVE_DB_STORAGE string query = "SELECT conference_info.id, organizer_sip_address.value, uri_sip_address.value," " start_time, duration, subject, description, state, ics_sequence, ics_uid, security_level" @@ -5611,7 +5645,7 @@ MainDb::getConferenceInfosForLocalAddress(const std::shared_ptr<Address> &localA #endif } -std::shared_ptr<ConferenceInfo> MainDb::getConferenceInfo(long long conferenceInfoId) const { +std::shared_ptr<ConferenceInfo> MainDb::getConferenceInfo(long long conferenceInfoId) { #ifdef HAVE_DB_STORAGE static const string query = "SELECT conference_info.id, organizer_sip_address.value, uri_sip_address.value," @@ -5642,7 +5676,7 @@ std::shared_ptr<ConferenceInfo> MainDb::getConferenceInfo(long long conferenceIn #endif } -std::shared_ptr<ConferenceInfo> MainDb::getConferenceInfoFromURI(const std::shared_ptr<Address> &uri) const { +std::shared_ptr<ConferenceInfo> MainDb::getConferenceInfoFromURI(const std::shared_ptr<Address> &uri) { #ifdef HAVE_DB_STORAGE if (isInitialized() && uri) { string query = "SELECT conference_info.id, organizer_sip_address.value, uri_sip_address.value," @@ -5675,7 +5709,9 @@ std::shared_ptr<ConferenceInfo> MainDb::getConferenceInfoFromURI(const std::shar long long MainDb::insertConferenceInfo(const std::shared_ptr<ConferenceInfo> &conferenceInfo) { #ifdef HAVE_DB_STORAGE if (isInitialized()) { - auto dbConfInfo = getConferenceInfoFromURI(conferenceInfo->getUri()); + auto dbConfInfo = (conferenceInfo->getState() == ConferenceInfo::State::New) + ? nullptr + : getConferenceInfoFromURI(conferenceInfo->getUri()); return L_DB_TRANSACTION { L_D(); auto id = d->insertConferenceInfo(conferenceInfo, dbConfInfo); diff --git a/src/db/main-db.h b/src/db/main-db.h index 4006a1acb6e4581f094044d244dd9ff1163aa402..e88fc8bebfa69ebfa65f06aa3a6b0a49bf6e9456 100644 --- a/src/db/main-db.h +++ b/src/db/main-db.h @@ -208,11 +208,11 @@ public: // Conference Info. // --------------------------------------------------------------------------- - std::list<std::shared_ptr<ConferenceInfo>> getConferenceInfos(time_t afterThisTime = -1) const; + std::list<std::shared_ptr<ConferenceInfo>> getConferenceInfos(time_t afterThisTime = -1); std::list<std::shared_ptr<ConferenceInfo>> - getConferenceInfosForLocalAddress(const std::shared_ptr<Address> &localAddress) const; - std::shared_ptr<ConferenceInfo> getConferenceInfo(long long conferenceInfoId) const; - std::shared_ptr<ConferenceInfo> getConferenceInfoFromURI(const std::shared_ptr<Address> &uri) const; + getConferenceInfosForLocalAddress(const std::shared_ptr<Address> &localAddress); + std::shared_ptr<ConferenceInfo> getConferenceInfo(long long conferenceInfoId); + std::shared_ptr<ConferenceInfo> getConferenceInfoFromURI(const std::shared_ptr<Address> &uri); long long insertConferenceInfo(const std::shared_ptr<ConferenceInfo> &conferenceInfo); void deleteConferenceInfo(const std::shared_ptr<ConferenceInfo> &conferenceInfo); diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 4b66c9e11cedd43947ad3b9e922c5142acb15e5e..4f999fbfa3d9908faa18c637283ad82de1eb4d12 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -129,6 +129,7 @@ set(DB_FILES db/linphone.db db/messages.db db/chatrooms.db + db/chatroom_conference.db ) set(RC_FILES diff --git a/tester/db/chatroom_conference.db b/tester/db/chatroom_conference.db new file mode 100644 index 0000000000000000000000000000000000000000..81939c746585a6983f393238cfcce1fffead0938 Binary files /dev/null and b/tester/db/chatroom_conference.db differ diff --git a/tester/local_conference_tester_functions.cpp b/tester/local_conference_tester_functions.cpp index c20a0da9ae42b9a7db533873fb5f7c8b9af02eb0..f640110a33c28f172cd4013988e5a3f46d3a35f2 100644 --- a/tester/local_conference_tester_functions.cpp +++ b/tester/local_conference_tester_functions.cpp @@ -1690,7 +1690,6 @@ void compare_conference_infos(const LinphoneConferenceInfo *info1, const int duration1_m = linphone_conference_info_get_duration(info1); const int duration2_m = linphone_conference_info_get_duration(info2); - // BC_ASSERT_EQUAL(duration_m, ((duration < 0) ? 0 : duration), int, "%d"); BC_ASSERT_EQUAL(duration1_m, duration2_m, int, "%d"); const char *subject1 = linphone_conference_info_get_subject(info1); diff --git a/tester/main-db-tester.cpp b/tester/main-db-tester.cpp index fd6c69d99f6d683bbfc67c9732f4466aef72fff9..2a253fac1f89fb62145388cfd2bc70608885e8b8 100644 --- a/tester/main-db-tester.cpp +++ b/tester/main-db-tester.cpp @@ -274,7 +274,7 @@ static void get_chat_rooms() { if (mainDb.isInitialized()) { std::string utf8Txt = "Héllo world ! Welcome to ベルドンヌ通信."; list<shared_ptr<AbstractChatRoom>> chatRooms = mainDb.getChatRooms(); - BC_ASSERT_EQUAL((int)chatRooms.size(), 86, int, "%d"); + BC_ASSERT_EQUAL(chatRooms.size(), 86, size_t, "%zu"); list<shared_ptr<AbstractChatRoom>> emptyChatRooms; shared_ptr<AbstractChatRoom> emptyMessageRoom = nullptr; @@ -354,6 +354,7 @@ static void get_chat_rooms() { BC_FAIL("Database not initialized"); } } + static void load_a_lot_of_chatrooms(void) { chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now(); MainDbProvider provider("db/chatrooms.db"); @@ -366,6 +367,20 @@ static void load_a_lot_of_chatrooms(void) { #endif } +static void load_chatroom_conference(void) { + MainDbProvider provider("db/chatroom_conference.db"); + MainDb &mainDb = provider.getMainDb(); + if (mainDb.isInitialized()) { + list<shared_ptr<AbstractChatRoom>> chatRooms = mainDb.getChatRooms(); + BC_ASSERT_EQUAL(chatRooms.size(), 1, size_t, "%zu"); + + list<shared_ptr<ConferenceInfo>> conferenceInfos = mainDb.getConferenceInfos(); + BC_ASSERT_EQUAL(conferenceInfos.size(), 1, size_t, "%zu"); + } else { + BC_FAIL("Database not initialized"); + } +} + test_t main_db_tests[] = {TEST_NO_TAG("Get events count", get_events_count), TEST_NO_TAG("Get messages count", get_messages_count), TEST_NO_TAG("Get unread messages count", get_unread_messages_count), @@ -373,7 +388,8 @@ test_t main_db_tests[] = {TEST_NO_TAG("Get events count", get_events_count), TEST_NO_TAG("Get conference events", get_conference_notified_events), TEST_NO_TAG("Get chat rooms", get_chat_rooms), TEST_NO_TAG("Set/get conference info", set_get_conference_info), - TEST_NO_TAG("Load a lot of chatrooms", load_a_lot_of_chatrooms)}; + TEST_NO_TAG("Load a lot of chatrooms", load_a_lot_of_chatrooms), + TEST_NO_TAG("Load chatroom and conference", load_chatroom_conference)}; test_suite_t main_db_test_suite = {"MainDb", NULL,