return true;
}
+void AbstractSqlStorage::sync() {
+ QHash<QPair<QString, int>, QSqlQuery *>::iterator iter = _queryCache.begin();
+ while(iter != _queryCache.end()) {
+ delete *iter;
+ iter = _queryCache.erase(iter);
+ }
+
+ logDb().commit();
+}
+
QString AbstractSqlStorage::queryString(const QString &queryName, int version) {
if(version == 0)
version = schemaVersion();
protected:
bool init(const QVariantMap &settings = QVariantMap());
+ virtual void sync();
QSqlDatabase logDb();
: storage(0)
{
startTime = QDateTime::currentDateTime(); // for uptime :)
+
+ connect(&_storageSyncTimer, SIGNAL(timeout()),
+ this, SLOT(syncStorage()));
+ _storageSyncTimer.start(10 * 60 * 1000); // in msecs
}
void Core::init() {
qDeleteAll(sessions);
}
+void Core::syncStorage() {
+ QMutexLocker locker(&mutex);
+ return instance()->storage->sync();
+}
+
void Core::restoreState() {
if(instance()->sessions.count()) {
qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!"));
#include <QMutex>
#include <QString>
#include <QVariant>
+#include <QTimer>
#include <QTcpServer>
#include <QTcpSocket>
*/
static QList<BufferInfo> requestBuffers(UserId user, QDateTime since = QDateTime());
+ public slots:
+ //! Make storage data persistent
+ /** \note This method is threadsafe.
+ */
+ void syncStorage();
+
signals:
//! Sent when a BufferInfo is updated in storage.
void bufferInfoUpdated(UserId user, const BufferInfo &info);
UserId guiUser;
QHash<UserId, SessionThread *> sessions;
Storage *storage;
+ QTimer _storageSyncTimer;
QTcpServer server; // TODO: implement SSL
QHash<QTcpSocket *, quint32> blocksizes;
* \return True if and only if the storage provider was initialized successfully.
*/
virtual bool init(const QVariantMap &settings = QVariantMap()) = 0;
-
+
+ //! Makes temp data persistent
+ /** This Method is periodically called by the Quassel Core to make temporary
+ * data persistant. This reduces the data loss drastically in the
+ * unlikely case of a Core crash.
+ */
+ virtual void sync() = 0;
+
// TODO: Add functions for configuring the backlog handling, i.e. defining auto-cleanup settings etc
/* User handling */
quasselVersion = "0.2.0-pre";
quasselDate = "2008-02-02";
- quasselBuild = 437;
+ quasselBuild = 438;
//! Minimum client build number the core needs
clientBuildNeeded = 435;