-BufferId SqliteStorage::renameBuffer(const UserId &user, const NetworkId &networkId, const QString &newName, const QString &oldName) {
- // check if such a buffer exists...
- QSqlQuery existsQuery(logDb());
- existsQuery.prepare(queryString("select_bufferByName"));
- existsQuery.bindValue(":networkid", networkId.toInt());
- existsQuery.bindValue(":userid", user.toInt());
- existsQuery.bindValue(":buffercname", oldName.toLower());
- safeExec(existsQuery);
- if(!watchQuery(existsQuery))
- return false;
-
- if(!existsQuery.first())
- return false;
-
- const int bufferid = existsQuery.value(0).toInt();
-
- Q_ASSERT(!existsQuery.next());
-
- // ... and if the new name is still free.
- existsQuery.bindValue(":networkid", networkId.toInt());
- existsQuery.bindValue(":userid", user.toInt());
- existsQuery.bindValue(":buffercname", newName.toLower());
- safeExec(existsQuery);
- if(!watchQuery(existsQuery))
+bool SqliteStorage::renameBuffer(const UserId &user, const BufferId &bufferId, const QString &newName) {
+ if(!isValidBuffer(user, bufferId))