+ bool logMessage(Message &msg) override;
+ bool logMessages(MessageList &msgs) override;
+ QList<Message> requestMsgs(UserId user, BufferId bufferId, MsgId first = -1, MsgId last = -1, int limit = -1) override;
+ QList<Message> requestMsgsFiltered(UserId user, BufferId bufferId, MsgId first = -1, MsgId last = -1,
+ int limit = -1, Message::Types type = Message::Types{-1},
+ Message::Flags flags = Message::Flags{-1}) override;
+ QList<Message> requestAllMsgs(UserId user, MsgId first = -1, MsgId last = -1, int limit = -1) override;
+ QList<Message> requestAllMsgsFiltered(UserId user, MsgId first = -1, MsgId last = -1, int limit = -1,
+ Message::Types type = Message::Types{-1},
+ Message::Flags flags = Message::Flags{-1}) override;
+
+ /* Sysident handling */
+ QMap<UserId, QString> getAllAuthUserNames() override;
+ QString getAuthUserName(UserId user) override;
+
+protected:
+ void setConnectionProperties(const QVariantMap &properties,
+ const QProcessEnvironment &environment,
+ bool loadFromEnvironment) override {
+ Q_UNUSED(properties);
+ Q_UNUSED(environment);
+ Q_UNUSED(loadFromEnvironment);
+ }
+ // SQLite does not have any connection properties to set
+ QString driverName() override { return "QSQLITE"; }
+ QString databaseName() override { return backlogFile(); }
+ int installedSchemaVersion() override;
+ bool updateSchemaVersion(int newVersion) override;
+ bool setupSchemaVersion(int version) override;
+ bool safeExec(QSqlQuery &query, int retryCount = 0);
+
+private:
+ static QString backlogFile();
+ void bindNetworkInfo(QSqlQuery &query, const NetworkInfo &info);
+ void bindServerInfo(QSqlQuery &query, const Network::Server &server);
+
+ inline void lockForRead() { _dbLock.lockForRead(); }
+ inline void lockForWrite() { _dbLock.lockForWrite(); }
+ inline void unlock() { _dbLock.unlock(); }
+ QReadWriteLock _dbLock;
+ static int _maxRetryCount;
+};
+
+
+// ========================================
+// SqliteMigration
+// ========================================
+class SqliteMigrationReader : public SqliteStorage, public AbstractSqlMigrationReader
+{
+ Q_OBJECT
+
+public:
+ SqliteMigrationReader();
+
+ bool readMo(QuasselUserMO &user) override;
+ bool readMo(SenderMO &sender) override;
+ bool readMo(IdentityMO &identity) override;
+ bool readMo(IdentityNickMO &identityNick) override;
+ bool readMo(NetworkMO &network) override;
+ bool readMo(BufferMO &buffer) override;
+ bool readMo(BacklogMO &backlog) override;
+ bool readMo(IrcServerMO &ircserver) override;
+ bool readMo(UserSettingMO &userSetting) override;
+ bool readMo(CoreStateMO &coreState) override;
+
+ bool prepareQuery(MigrationObject mo) override;
+
+ qint64 stepSize() { return 50000; }
+
+protected:
+ bool transaction() override { return logDb().transaction(); }
+ void rollback() override { logDb().rollback(); }
+ bool commit() override { return logDb().commit(); }