- public:
- SqliteStorage();
- virtual ~SqliteStorage();
-
- static void init();
-
- /* General */
-
- static bool isAvailable();
- static QString displayName();
-
- // TODO: Add functions for configuring the backlog handling, i.e. defining auto-cleanup settings etc
-
- /* User handling */
-
- virtual UserId addUser(const QString &user, const QString &password);
- virtual void updateUser(UserId user, const QString &password);
- virtual void renameUser(UserId user, const QString &newName);
- virtual UserId validateUser(const QString &user, const QString &password);
- virtual void delUser(UserId user);
-
- /* Network handling */
- virtual uint getNetworkId(UserId user, const QString &network);
-
- /* Buffer handling */
- virtual BufferId getBufferId(UserId user, const QString &network, const QString &buffer = "");
- virtual QList<BufferId> requestBuffers(UserId user, QDateTime since = QDateTime());
-
- /* Message handling */
-
- virtual MsgId logMessage(Message msg);
- virtual QList<Message> requestMsgs(BufferId buffer, int lastmsgs = -1, int offset = -1);
- virtual QList<Message> requestMsgs(BufferId buffer, QDateTime since, int offset = -1);
- virtual QList<Message> requestMsgRange(BufferId buffer, int first, int last);
-
- public slots:
- //! This is just for importing the old file-based backlog */
- /** This slot needs to be implemented in the storage backends.
- * It should first prepare (delete?) the database, then call initBackLogOld(UserId id).
- * If the importing was successful, backLogEnabledOld will be true afterwards.
- */
- void importOldBacklog();
-
- signals:
- void bufferIdUpdated(BufferId);
-
- protected:
-
- private:
- void initDb();
- void createBuffer(UserId user, const QString &network, const QString &buffer);
- QSqlQuery *logMessageQuery;
- QSqlQuery *addSenderQuery;
- QSqlQuery *getLastMessageIdQuery;
- QSqlQuery *requestMsgsQuery;
- QSqlQuery *requestMsgsOffsetQuery;
- QSqlQuery *requestMsgsSinceQuery;
- QSqlQuery *requestMsgsSinceOffsetQuery;
- QSqlQuery *requestMsgRangeQuery;
- QSqlQuery *createNetworkQuery;
- QSqlQuery *createBufferQuery;
- QSqlQuery *getBufferIdQuery;
+public:
+ SqliteStorage(QObject *parent = 0);
+ virtual ~SqliteStorage();
+
+public slots:
+ /* General */
+
+ static bool isAvailable();
+ static QString displayName();
+ virtual QString engineName() ;
+ // TODO: Add functions for configuring the backlog handling, i.e. defining auto-cleanup settings etc
+
+ /* User handling */
+
+ virtual UserId addUser(const QString &user, const QString &password);
+ virtual void updateUser(UserId user, const QString &password);
+ virtual void renameUser(UserId user, const QString &newName);
+ virtual UserId validateUser(const QString &user, const QString &password);
+ virtual void delUser(UserId user);
+
+ /* Network handling */
+ virtual NetworkId getNetworkId(UserId user, const QString &network);
+
+ /* Buffer handling */
+ virtual BufferInfo getBufferInfo(UserId user, const QString &network, const QString &buffer = "");
+ virtual QList<BufferInfo> requestBuffers(UserId user, QDateTime since = QDateTime());
+
+ /* Message handling */
+
+ virtual MsgId logMessage(Message msg);
+ virtual QList<Message> requestMsgs(BufferInfo buffer, int lastmsgs = -1, int offset = -1);
+ virtual QList<Message> requestMsgs(BufferInfo buffer, QDateTime since, int offset = -1);
+ virtual QList<Message> requestMsgRange(BufferInfo buffer, int first, int last);
+
+protected:
+ inline virtual QString driverName() { return "QSQLITE"; }
+ inline virtual QString databaseName() { return backlogFile(); }
+ virtual int installedSchemaVersion();
+
+private:
+ static QString backlogFile();
+ void createBuffer(UserId user, const QString &network, const QString &buffer);