1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

mysql synchronous set

This commit is contained in:
apprb 2014-11-12 21:56:24 +09:00
parent 59b26f3d33
commit 9d96110e9b
No known key found for this signature in database
GPG Key ID: B001911B5B22FB9B
5 changed files with 60 additions and 1 deletions

View File

@ -130,6 +130,8 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
updateChatsID();
updateAliases();
setSyncType(Settings::getInstance().getDbSyncType());
QSqlQuery sqlAnswer = db->exec("select seq from sqlite_sequence where name=\"history\";");
sqlAnswer.first();
messageID = sqlAnswer.value(0).toInt();
@ -315,3 +317,25 @@ void HistoryKeeper::markAsSent(int m_id)
{
db->exec(QString("UPDATE sent_status SET status = 1 WHERE id = %1;").arg(m_id));
}
void HistoryKeeper::setSyncType(Db::syncType sType)
{
QString syncCmd;
switch (sType) {
case Db::syncType::stFull:
syncCmd = "FULL";
break;
case Db::syncType::stNormal:
syncCmd = "NORMAL";
break;
case Db::syncType::stOff:
syncCmd = "OFF";
break;
default:
syncCmd = "FULL";
break;
}
db->exec(QString("PRAGMA synchronous=%1;").arg(syncCmd));
}

View File

@ -22,6 +22,7 @@
#include <QDateTime>
class GenericDdInterface;
namespace Db { enum class syncType; }
class HistoryKeeper
{
@ -51,6 +52,8 @@ public:
QList<HistMessage> getChatHistory(ChatType ct, const QString &chat, const QDateTime &time_from, const QDateTime &time_to);
void markAsSent(int m_id);
void setSyncType(Db::syncType sType);
private:
HistoryKeeper(GenericDdInterface *db_);
HistoryKeeper(HistoryKeeper &hk) = delete;

View File

@ -21,6 +21,10 @@
#include <QSqlDatabase>
namespace Db {
enum class syncType : int {stOff = 0, stNormal = 1, stFull = 2};
}
class PlainDb : public GenericDdInterface
{
public:

View File

@ -17,6 +17,7 @@
#include "settings.h"
#include "smileypack.h"
#include "src/corestructs.h"
#include "src/misc/db/plaindb.h"
#include <QFont>
#include <QApplication>
@ -121,12 +122,17 @@ void Settings::load()
proxyAddr = s.value("proxyAddr", "").toString();
proxyPort = s.value("proxyPort", 0).toInt();
currentProfile = s.value("currentProfile", "").toString();
autoAwayTime = s.value("autoAwayTime", 10).toInt();
autoAwayTime = s.value("autoAwayTime", 10).toInt();
checkUpdates = s.value("checkUpdates", false).toBool();
showInFront = s.value("showInFront", false).toBool();
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
s.endGroup();
s.beginGroup("Advanced");
int sType = s.value("dbSyncType", static_cast<int>(Db::syncType::stFull)).toInt();
setDbSyncType(sType);
s.endGroup();
s.beginGroup("Widgets");
QList<QString> objectNames = s.childKeys();
for (const QString& name : objectNames) {
@ -267,6 +273,10 @@ void Settings::save(QString path)
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
s.endGroup();
s.beginGroup("Advanced");
s.setValue("dbSyncType", static_cast<int>(dbSyncType));
s.endGroup();
s.beginGroup("Widgets");
const QList<QString> widgetNames = widgetSettings.keys();
for (const QString& name : widgetNames) {
@ -597,6 +607,19 @@ void Settings::setEncryptTox(bool newValue)
encryptTox = newValue;
}
Db::syncType Settings::getDbSyncType() const
{
return dbSyncType;
}
void Settings::setDbSyncType(int newValue)
{
if (newValue >= 0 && newValue <= 2)
dbSyncType = static_cast<Db::syncType>(newValue);
else
dbSyncType = Db::syncType::stFull;
}
int Settings::getAutoAwayTime() const
{
return autoAwayTime;

View File

@ -22,6 +22,7 @@
#include <QPixmap>
struct ToxID;
namespace Db { enum class syncType; }
class Settings : public QObject
{
@ -99,6 +100,9 @@ public:
bool getEncryptTox() const;
void setEncryptTox(bool newValue);
Db::syncType getDbSyncType() const;
void setDbSyncType(int newValue);
int getAutoAwayTime() const;
void setAutoAwayTime(int newValue);
@ -278,6 +282,7 @@ private:
// Privacy
bool typingNotification;
Db::syncType dbSyncType;
// Audio
QString inDev;