X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=core%2Fbacklog.h;fp=core%2Fbacklog.h;h=709125ad7eaecb3df49d64539bdf91c61df4097d;hb=ddc5208315db8ca9ca19f6a59ee7caefe631ffc7;hp=0000000000000000000000000000000000000000;hpb=fd718b6209f1ad2bcd199c44c2dae3b0cb0f633b;p=quassel.git diff --git a/core/backlog.h b/core/backlog.h new file mode 100644 index 00000000..709125ad --- /dev/null +++ b/core/backlog.h @@ -0,0 +1,82 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _BACKLOG_H_ +#define _BACKLOG_H_ + +#include +#include + +#include "global.h" +#include "message.h" + +// TODO: is this threadsafe? should it be? +class Backlog : public QObject { + Q_OBJECT + + public: + Backlog(); + ~Backlog(); + + void init(QString user); + void setDefaultSettings(int lines = -1, QDateTime time = QDateTime()); + void setSettings(QString network, QString buffer, int lines = -1, QDateTime time = QDateTime()); + + BufferId getBufferId(QString network, QString buffer); + uint logMessage(Message msg); + + QList requestMsgs(BufferId, int lastlines = -1, int offset = -1); + QList requestMsgs(BufferId, QDateTime since, int offset = -1); + //QList requestMsgRange(BufferId, int first, int last); + + QList requestBuffers(QDateTime since = QDateTime()); + + public slots: + void importOldBacklog(); + + private: + QString user; + bool backlogEnabled; + QSqlDatabase logDb; + + uint nextMsgId, nextBufferId, nextSenderId; + + QTimer cleanupTimer; + + void cleanup(); + + // Old stuff, just for importing old file-based data + void initBackLogOld(); + void logMessageOld(QString net, Message); + + bool backLogEnabledOld; + QDir backLogDir; + QHash > backLog; + //QHash netIdx; + QHash logFiles; + QHash logStreams; + QHash logFileDates; + QHash logFileDirs; + +}; + + + +#endif