X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fsqlitestorage.h;h=0ab46825f5f3545baebd86f142b8fb5d17a5f5fe;hp=a4f5fec08ca7d18f5409cf1a9859440c714153a6;hb=f6f6f3e368543f0a4dce1dae772f161d7e357064;hpb=c7ad7451b1e899ba0de2ded9ac08359dff5cca61 diff --git a/src/core/sqlitestorage.h b/src/core/sqlitestorage.h index a4f5fec0..0ab46825 100644 --- a/src/core/sqlitestorage.h +++ b/src/core/sqlitestorage.h @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel Team * + * Copyright (C) 2005-07 by the Quassel IRC Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -23,7 +23,6 @@ #include -#include "global.h" #include "storage.h" class QSqlQuery; @@ -35,12 +34,13 @@ class SqliteStorage : public Storage { SqliteStorage(); virtual ~SqliteStorage(); - static void init(); - + public slots: /* General */ static bool isAvailable(); static QString displayName(); + virtual bool setup(const QVariantMap &settings = QVariantMap()); + virtual bool init(const QVariantMap &settings = QVariantMap()); // TODO: Add functions for configuring the backlog handling, i.e. defining auto-cleanup settings etc @@ -56,32 +56,29 @@ class SqliteStorage : public Storage { virtual uint getNetworkId(UserId user, const QString &network); /* Buffer handling */ - virtual BufferId getBufferId(UserId user, const QString &network, const QString &buffer = ""); - virtual QList requestBuffers(UserId user, QDateTime since = QDateTime()); + virtual BufferInfo getBufferInfo(UserId user, const QString &network, const QString &buffer = ""); + virtual QList requestBuffers(UserId user, QDateTime since = QDateTime()); /* Message handling */ virtual MsgId logMessage(Message msg); - virtual QList requestMsgs(BufferId buffer, int lastmsgs = -1, int offset = -1); - virtual QList requestMsgs(BufferId buffer, QDateTime since, int offset = -1); - virtual QList 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(); + virtual QList requestMsgs(BufferInfo buffer, int lastmsgs = -1, int offset = -1); + virtual QList requestMsgs(BufferInfo buffer, QDateTime since, int offset = -1); + virtual QList requestMsgRange(BufferInfo buffer, int first, int last); signals: - void bufferIdUpdated(BufferId); + void bufferInfoUpdated(BufferInfo); protected: private: - void initDb(); + static QString backlogFile(bool createPath = false); + void createBuffer(UserId user, const QString &network, const QString &buffer); + bool watchQuery(QSqlQuery *query); + + QSqlDatabase logDb; + QSqlQuery *logMessageQuery; QSqlQuery *addSenderQuery; QSqlQuery *getLastMessageIdQuery; @@ -92,8 +89,7 @@ class SqliteStorage : public Storage { QSqlQuery *requestMsgRangeQuery; QSqlQuery *createNetworkQuery; QSqlQuery *createBufferQuery; - QSqlQuery *getBufferIdQuery; + QSqlQuery *getBufferInfoQuery; }; - #endif