- private:
- void initDb();
- void createBuffer(UserId user, QString network, 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 */
+
+ bool isAvailable() const;
+ QString displayName() const;
+ QString description() const;
+
+ // 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 createNetworkId(UserId user, const NetworkInfo &info);
+
+ /* Buffer handling */
+ virtual BufferInfo getBufferInfo(UserId user, const NetworkId &networkId, 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();
+ NetworkId getNetworkId(UserId user, const QString &network);
+ void createBuffer(UserId user, const NetworkId &networkId, const QString &buffer);