From 28944e466e62094183060c3548004764c9f0fa59 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 18 Dec 2017 11:42:13 +0100 Subject: [PATCH] feat(MainDb): add new table `db_module_version` --- coreapi/linphonecore.c | 2 -- src/conference/session/call-session.cpp | 7 +------ src/db/abstract/abstract-db.cpp | 19 ++++++++++++++++--- src/db/abstract/abstract-db.h | 1 + src/db/main-db.cpp | 6 ++++++ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 8fcbef6ac..294fa3132 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -6003,8 +6003,6 @@ void _linphone_core_uninit(LinphoneCore *lc) ms_usleep(10000); } - 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"); #ifdef VIDEO_ENABLED if (lc->previewstream!=NULL){ diff --git a/src/conference/session/call-session.cpp b/src/conference/session/call-session.cpp index 18e445d84..2f52449c9 100644 --- a/src/conference/session/call-session.cpp +++ b/src/conference/session/call-session.cpp @@ -612,12 +612,7 @@ void CallSessionPrivate::setReleased () { } referer = nullptr; transferTarget = nullptr; -#if 0 - if (call->chat_room){ - linphone_chat_room_unref(call->chat_room); - call->chat_room = NULL; - } -#endif + if (listener) listener->onCallSessionSetReleased(q->getSharedFromThis()); } diff --git a/src/db/abstract/abstract-db.cpp b/src/db/abstract/abstract-db.cpp index 30992ee76..98412571f 100644 --- a/src/db/abstract/abstract-db.cpp +++ b/src/db/abstract/abstract-db.cpp @@ -25,6 +25,8 @@ #include #endif // ifdef __APPLE__ +#include "linphone/utils/utils.h" + #include "abstract-db-p.h" #include "db/session/db-session-provider.h" #include "logger/logger.h" @@ -123,6 +125,20 @@ string AbstractDb::primaryKeyRefStr (const string &type) const { return ""; } +string AbstractDb::varcharPrimaryKeyStr (int length) const { + L_D(); + + switch (d->backend) { + case Mysql: + return " VARCHAR(" + Utils::toString(length) + ") AUTO_INCREMENT PRIMARY KEY"; + case Sqlite3: + return " VARCHAR(" + Utils::toString(length) + ") PRIMARY KEY"; + } + + L_ASSERT(false); + return ""; +} + string AbstractDb::timestampType () const { L_D(); @@ -165,9 +181,6 @@ long long AbstractDb::getLastInsertId () const { case Sqlite3: sql = "SELECT last_insert_rowid()"; break; - default: - lWarning() << "Unsupported backend."; - return -1; } soci::session *session = d->dbSession.getBackendSession(); diff --git a/src/db/abstract/abstract-db.h b/src/db/abstract/abstract-db.h index 91d08eba7..29bf9be15 100644 --- a/src/db/abstract/abstract-db.h +++ b/src/db/abstract/abstract-db.h @@ -53,6 +53,7 @@ protected: std::string primaryKeyStr (const std::string &type = "INT") const; std::string primaryKeyRefStr (const std::string &type = "INT") const; + std::string varcharPrimaryKeyStr (int length) const; std::string timestampType () const; diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 2c6bde2be..0d6973e85 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -1304,6 +1304,12 @@ static constexpr string &blobToString (string &in) { *session << participantMessageDeleter; #endif + + *session << + "CREATE TABLE IF NOT EXISTS db_module_version (" + " name" + varcharPrimaryKeyStr(16) + "," + " version INT UNSIGNED NOT NULL" + ") " + charset; } bool MainDb::addEvent (const shared_ptr &eventLog) {