X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fsqlitestorage.cpp;h=fcc52adf173fb96d473e100c4374b44ec17b0366;hp=056cddd03e9ddffe5969225cee38b2c0ca71f478;hb=b040ef84cdc254a0b1f083db3151f2724e45d210;hpb=b0cbbaffc64390db19614c65bf6af416dd55e41a diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 056cddd0..fcc52adf 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -120,7 +120,7 @@ UserId SqliteStorage::addUser(const QString &user, const QString &password) { return uid; } -void SqliteStorage::updateUser(UserId user, const QString &password) { +bool SqliteStorage::updateUser(UserId user, const QString &password) { QSqlDatabase db = logDb(); db.transaction(); @@ -130,8 +130,10 @@ void SqliteStorage::updateUser(UserId user, const QString &password) { query.bindValue(":password", cryptedPassword(password)); lockForWrite(); safeExec(query); + bool success = query.numRowsAffected() != 0; db.commit(); unlock(); + return success; } void SqliteStorage::renameUser(UserId user, const QString &newName) { @@ -167,6 +169,23 @@ UserId SqliteStorage::validateUser(const QString &user, const QString &password) } } +UserId SqliteStorage::getUserId(const QString &username) { + QSqlQuery query(logDb()); + query.prepare(queryString("select_userid")); + query.bindValue(":username", username); + + lockForRead(); + safeExec(query); + + if(query.first()) { + unlock(); + return query.value(0).toInt(); + } else { + unlock(); + return 0; + } +} + UserId SqliteStorage::internalUser() { QSqlQuery query(logDb()); query.prepare(queryString("select_internaluser")); @@ -519,16 +538,16 @@ void SqliteStorage::bindNetworkInfo(QSqlQuery &query, const NetworkInfo &info) { query.bindValue(":encodingcodec", QString(info.codecForEncoding)); query.bindValue(":decodingcodec", QString(info.codecForDecoding)); query.bindValue(":servercodec", QString(info.codecForServer)); - query.bindValue(":userandomserver", info.useRandomServer); + query.bindValue(":userandomserver", info.useRandomServer ? 1 : 0); query.bindValue(":perform", info.perform.join("\n")); - query.bindValue(":useautoidentify", info.useAutoIdentify); + query.bindValue(":useautoidentify", info.useAutoIdentify ? 1 : 0); query.bindValue(":autoidentifyservice", info.autoIdentifyService); query.bindValue(":autoidentifypassword", info.autoIdentifyPassword); - query.bindValue(":useautoreconnect", info.useAutoReconnect); + query.bindValue(":useautoreconnect", info.useAutoReconnect ? 1 : 0); query.bindValue(":autoreconnectinterval", info.autoReconnectInterval); query.bindValue(":autoreconnectretries", info.autoReconnectRetries); - query.bindValue(":unlimitedconnectretries", info.unlimitedReconnectRetries); - query.bindValue(":rejoinchannels", info.rejoinChannels); + query.bindValue(":unlimitedconnectretries", info.unlimitedReconnectRetries ? 1 : 0); + query.bindValue(":rejoinchannels", info.rejoinChannels ? 1 : 0); if(info.networkId.isValid()) query.bindValue(":networkid", info.networkId.toInt()); } @@ -537,9 +556,9 @@ void SqliteStorage::bindServerInfo(QSqlQuery &query, const Network::Server &serv query.bindValue(":hostname", server.host); query.bindValue(":port", server.port); query.bindValue(":password", server.password); - query.bindValue(":ssl", server.useSsl); + query.bindValue(":ssl", server.useSsl ? 1 : 0); query.bindValue(":sslversion", server.sslVersion); - query.bindValue(":useproxy", server.useProxy); + query.bindValue(":useproxy", server.useProxy ? 1 : 0); query.bindValue(":proxytype", server.proxyType); query.bindValue(":proxyhost", server.proxyHost); query.bindValue(":proxyport", server.proxyPort);