X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fpostgresqlstorage.cpp;h=b64592d735f4b865835bce551ec157462ffc57af;hp=48ee466d444d7ea1d429094b99879d52f0bedfe5;hb=c382e0c11f80fb37307ecc42c487aa433c97ad8c;hpb=f932e5c8a0ec3ff689686a71c32ee61a428c4340 diff --git a/src/core/postgresqlstorage.cpp b/src/core/postgresqlstorage.cpp index 48ee466d..b64592d7 100644 --- a/src/core/postgresqlstorage.cpp +++ b/src/core/postgresqlstorage.cpp @@ -1440,6 +1440,44 @@ Message::Types PostgreSqlStorage::bufferActivity(BufferId bufferId, MsgId lastSe return result; } +QHash PostgreSqlStorage::bufferCiphers(UserId user, const NetworkId &networkId) +{ + QHash bufferCiphers; + + QSqlDatabase db = logDb(); + if (!beginReadOnlyTransaction(db)) { + qWarning() << "PostgreSqlStorage::persistentChannels(): cannot start read only transaction!"; + qWarning() << " -" << qPrintable(db.lastError().text()); + return bufferCiphers; + } + + QSqlQuery query(db); + query.prepare(queryString("select_buffer_ciphers")); + query.bindValue(":userid", user.toInt()); + query.bindValue(":networkid", networkId.toInt()); + safeExec(query); + watchQuery(query); + + while (query.next()) { + bufferCiphers[query.value(0).toString()] = QByteArray::fromHex(query.value(1).toString().toUtf8()); + } + + db.commit(); + return bufferCiphers; +} + +void PostgreSqlStorage::setBufferCipher(UserId user, const NetworkId &networkId, const QString &bufferName, const QByteArray &cipher) +{ + QSqlQuery query(logDb()); + query.prepare(queryString("update_buffer_cipher")); + query.bindValue(":userid", user.toInt()); + query.bindValue(":networkid", networkId.toInt()); + query.bindValue(":buffercname", bufferName.toLower()); + query.bindValue(":cipher", QString(cipher.toHex())); + safeExec(query); + watchQuery(query); +} + bool PostgreSqlStorage::logMessage(Message &msg) { QSqlDatabase db = logDb(); @@ -1702,7 +1740,24 @@ QList PostgreSqlStorage::requestAllMsgs(UserId user, MsgId first, MsgId return messagelist; } -const QString PostgreSqlStorage::getAuthusername(UserId user) { + +QMap PostgreSqlStorage::getAllAuthUserNames() +{ + QMap authusernames; + QSqlQuery query(logDb()); + query.prepare(queryString("select_all_authusernames")); + safeExec(query); + watchQuery(query); + + while (query.next()) { + authusernames[query.value(0).toInt()] = query.value(1).toString(); + } + return authusernames; +} + + +QString PostgreSqlStorage::getAuthUserName(UserId user) +{ QString authusername; QSqlQuery query(logDb()); query.prepare(queryString("select_authusername")); @@ -2049,6 +2104,7 @@ bool PostgreSqlMigrationWriter::writeMo(const BufferMO &buffer) bindValue(10, buffer.bufferactivity); bindValue(11, buffer.key); bindValue(12, buffer.joined); + bindValue(13, buffer.cipher); return exec(); }