From ecbe8b4800595b82e37ed0873f068bf93cdabefd Mon Sep 17 00:00:00 2001 From: zoff99 Date: Sat, 27 May 2023 22:53:35 +0200 Subject: [PATCH] show sqlcipher version in about screen --- src/persistence/history.cpp | 18 ++++++++++++++++++ src/persistence/history.h | 1 + src/widget/form/settings/aboutform.cpp | 11 ++++++++++- src/widget/widget.cpp | 5 +++++ src/widget/widget.h | 1 + 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/persistence/history.cpp b/src/persistence/history.cpp index e42bbed241..c4bd7b8de4 100644 --- a/src/persistence/history.cpp +++ b/src/persistence/history.cpp @@ -876,6 +876,24 @@ QString History::getPushtoken(const ToxPk& friendPk) return pushtoken; } +QString History::getSqlcipherVersion() +{ + if (!isValid()) { + return QString(""); + } + + QString sqlcipherVersion = QString(""); + db->execNow( + RawDatabase::Query("PRAGMA cipher_version;", + [&](const QVector& row) { + sqlcipherVersion = row[0].toString(); + qDebug() << "getSqlcipherVersion:" << sqlcipherVersion; + }) + ); + + return sqlcipherVersion; +} + void History::pushtokenPing(const ToxPk& sender) { if (!isValid()) { diff --git a/src/persistence/history.h b/src/persistence/history.h index b6adcf7483..c81fa63a43 100644 --- a/src/persistence/history.h +++ b/src/persistence/history.h @@ -234,6 +234,7 @@ class History : public QObject, public std::enable_shared_from_this void addPushtoken(const ToxPk& sender, const QString& pushtoken); QString getPushtoken(const ToxPk& friendPk); + QString getSqlcipherVersion(); void pushtokenPing(const ToxPk& sender); void addNewFileMessage(const ChatId& chatId, const QByteArray& fileId, diff --git a/src/widget/form/settings/aboutform.cpp b/src/widget/form/settings/aboutform.cpp index d78c0c5645..ffc7833d73 100644 --- a/src/widget/form/settings/aboutform.cpp +++ b/src/widget/form/settings/aboutform.cpp @@ -26,6 +26,7 @@ #include "src/widget/style.h" #include "src/widget/tool/recursivesignalblocker.h" #include "src/widget/translator.h" +#include "src/widget/widget.h" #include @@ -102,7 +103,15 @@ void AboutForm::replaceVersions() tr("Commit hash: %1").arg(createLink(commitLink, QString(GIT_VERSION)))); bodyUI->toxCoreVersion->setText(tr("toxcore version: %1").arg(TOXCORE_VERSION)); - bodyUI->qtVersion->setText(QString("Qt compiled: ") + QString(QT_VERSION_STR) + QString(" / runtime: ") + QString::fromUtf8(qVersion())); + bodyUI->qtVersion->setText(QString("Qt compiled: ") + + QString(QT_VERSION_STR) + + QString(" / runtime: ") + + QString::fromUtf8(qVersion()) + + QString("\nSQLCipher: ") + + Widget::sqlcipher_version + ); + + qDebug() << "sqlcipher_version:" << Widget::sqlcipher_version; QString issueBody = QString("##### Brief Description\n\n" "OS: %1\n" diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 2cef78eacc..bc15374a2f 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -106,6 +106,8 @@ const QString saveHandlerKey("save"); } // namespace +QString Widget::sqlcipher_version = ""; + bool Widget::toxActivateEventHandler(const QByteArray& data, void* userData) { std::ignore = data; @@ -176,6 +178,9 @@ Widget::Widget(Profile &profile_, IAudioControl& audio_, CameraSource& cameraSou void Widget::init() { + auto history_cur = profile.getHistory(); + Widget::sqlcipher_version = history_cur->getSqlcipherVersion(); + ui->setupUi(this); QIcon themeIcon = QIcon::fromTheme("qtox"); diff --git a/src/widget/widget.h b/src/widget/widget.h index 08ae6b42df..8c052475b1 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -167,6 +167,7 @@ class Widget final : public QMainWindow void registerIpcHandlers(); static bool toxActivateEventHandler(const QByteArray& data, void* userData); bool handleToxSave(const QString& path); + static QString sqlcipher_version; public slots: void reloadTheme();