mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-20 04:28:10 +00:00
feat(MainDb): enable legacy history import
This commit is contained in:
parent
c89611f47a
commit
2e0dd7907f
2 changed files with 14 additions and 4 deletions
|
|
@ -6689,8 +6689,12 @@ int linphone_core_get_video_dscp(const LinphoneCore *lc){
|
|||
return lp_config_get_int(lc->config,"rtp","video_dscp",0);
|
||||
}
|
||||
|
||||
void linphone_core_set_chat_database_path (LinphoneCore *, const char *) {
|
||||
lError() << "Do not use `linphone_core_set_chat_database_path`. Not necessary.";
|
||||
void linphone_core_set_chat_database_path (LinphoneCore *lc, const char *path) {
|
||||
if (
|
||||
linphone_core_conference_server_enabled(lc) ||
|
||||
!L_GET_PRIVATE(lc->cppPtr)->mainDb->import(LinphonePrivate::MainDb::Sqlite3, path)
|
||||
)
|
||||
lError() << "Do not use `linphone_core_set_chat_database_path`. Not necessary.";
|
||||
}
|
||||
|
||||
const char *linphone_core_get_chat_database_path (const LinphoneCore *) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include "main-db-p.h"
|
||||
|
||||
#define DB_MODULE_VERSION_EVENTS L_VERSION(1, 0, 0)
|
||||
#define DB_MODULE_VERSION_LEGACY_HISTORY_IMPORT L_VERSION(1, 0, 0)
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -2242,10 +2243,15 @@ static constexpr string &blobToString (string &in) {
|
|||
|
||||
// Import messages.
|
||||
try {
|
||||
soci::transaction tr(*d->dbSession.getBackendSession<soci::session>());
|
||||
|
||||
unsigned int version = d->getModuleVersion("legacy-history-import");
|
||||
if (version >= L_VERSION(1, 0, 0))
|
||||
return false;
|
||||
d->updateModuleVersion("legacy-history-import", DB_MODULE_VERSION_LEGACY_HISTORY_IMPORT);
|
||||
|
||||
soci::rowset<soci::row> messages = (inSession->prepare << "SELECT * FROM history");
|
||||
try {
|
||||
soci::transaction tr(*d->dbSession.getBackendSession<soci::session>());
|
||||
|
||||
for (const auto &message : messages) {
|
||||
const int direction = message.get<int>(LEGACY_MESSAGE_COL_DIRECTION);
|
||||
if (direction != 0 && direction != 1) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue