X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fsqlitestorage.cpp;h=c14d7cb7d78135b9c17dc3f2d20657d8132e5231;hb=c4b49f3777a7b841ad4701e9c03a69dd1ffadc66;hp=53601e0f36b47d536f78649a0ad902c6a4f7bace;hpb=7d30b18136eecbdf2089e5d5877c7e41c6f4bcb6;p=quassel.git diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 53601e0f..c14d7cb7 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -46,12 +46,19 @@ bool SqliteStorage::isAvailable() const } +QString SqliteStorage::backendId() const +{ + return QString("SQLite"); +} + + QString SqliteStorage::displayName() const { + // Note: Pre-0.13 clients use the displayName property for backend idenfication // We identify the backend to use for the monolithic core by its displayname. // so only change this string if you _really_ have to and make sure the core // setup for the mono client still works ;) - return QString("SQLite"); + return backendId(); } @@ -116,7 +123,7 @@ bool SqliteStorage::setupSchemaVersion(int version) } -UserId SqliteStorage::addUser(const QString &user, const QString &password) +UserId SqliteStorage::addUser(const QString &user, const QString &password, const QString &authenticator) { QSqlDatabase db = logDb(); UserId uid; @@ -131,6 +138,7 @@ UserId SqliteStorage::addUser(const QString &user, const QString &password) query.bindValue(":username", user); query.bindValue(":password", hashPassword(password)); query.bindValue(":hashversion", Storage::HashVersion::Latest); + query.bindValue(":authenticator", authenticator); lockForWrite(); safeExec(query); if (query.lastError().isValid() && query.lastError().number() == 19) { // user already exists - sadly 19 seems to be the general constraint violation error... @@ -240,6 +248,26 @@ UserId SqliteStorage::getUserId(const QString &username) return userId; } +QString SqliteStorage::getUserAuthenticator(const UserId userid) +{ + QString authenticator = QString(""); + + { + QSqlQuery query(logDb()); + query.prepare(queryString("select_authenticator")); + query.bindValue(":userid", userid.toInt()); + + lockForRead(); + safeExec(query); + + if (query.first()) { + authenticator = query.value(0).toString(); + } + } + unlock(); + + return authenticator; +} UserId SqliteStorage::internalUser() { @@ -1475,7 +1503,6 @@ QHash SqliteStorage::bufferMarkerLineMsgIds(UserId user) return markerLineHash; } - bool SqliteStorage::logMessage(Message &msg) { QSqlDatabase db = logDb(); @@ -1636,7 +1663,7 @@ QList SqliteStorage::requestMsgs(UserId user, BufferId bufferId, MsgId query.bindValue(":firstmsg", first.toInt()); } else { - query.prepare(queryString("select_messages")); + query.prepare(queryString("select_messagesRange")); query.bindValue(":lastmsg", last.toInt()); query.bindValue(":firstmsg", first.toInt()); } @@ -1821,6 +1848,7 @@ bool SqliteMigrationReader::readMo(QuasselUserMO &user) user.username = value(1).toString(); user.password = value(2).toString(); user.hashversion = value(3).toInt(); + user.authenticator = value(4).toString(); return true; } @@ -1918,10 +1946,11 @@ bool SqliteMigrationReader::readMo(BufferMO &buffer) buffer.buffername = value(4).toString(); buffer.buffercname = value(5).toString(); buffer.buffertype = value(6).toInt(); - buffer.lastseenmsgid = value(7).toInt(); - buffer.markerlinemsgid = value(8).toInt(); - buffer.key = value(9).toString(); - buffer.joined = value(10).toInt() == 1 ? true : false; + buffer.lastmsgid = value(7).toInt(); + buffer.lastseenmsgid = value(8).toInt(); + buffer.markerlinemsgid = value(9).toInt(); + buffer.key = value(10).toString(); + buffer.joined = value(11).toInt() == 1 ? true : false; return true; }