X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fsqlitestorage.cpp;h=dc5b546713da8659a09e5eb878fca75568da222f;hb=00b029d3947bc751893d735a495b03ea8796e139;hp=1a75713aa5aeae66b0013fc71e43077b80b04387;hpb=6e3574a163f07c28d44276318f2d9f92e169f491;p=quassel.git diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 1a75713a..dc5b5467 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2019 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -1485,6 +1485,34 @@ bool SqliteStorage::mergeBuffersPermanently(const UserId& user, const BufferId& return !error; } +QHash SqliteStorage::bufferLastMsgIds(UserId user) +{ + QHash lastMsgHash; + + QSqlDatabase db = logDb(); + db.transaction(); + + bool error = false; + { + QSqlQuery query(db); + query.prepare(queryString("select_buffer_last_messages")); + query.bindValue(":userid", user.toInt()); + + lockForRead(); + safeExec(query); + error = !watchQuery(query); + if (!error) { + while (query.next()) { + lastMsgHash[query.value(0).toInt()] = query.value(1).toLongLong(); + } + } + } + + db.commit(); + unlock(); + return lastMsgHash; +} + void SqliteStorage::setBufferLastSeenMsg(UserId user, const BufferId& bufferId, const MsgId& msgId) { QSqlDatabase db = logDb();