Commit 517c6039 authored by Karel Slaný's avatar Karel Slaný
Browse files

Removed AccountDb::isOvm().

parent 46d82bf1
......@@ -58,8 +58,8 @@ const QVector<QString> AccountDb::userPrintedAttribs = {"firmName", "ic",
"biDate", "caStreet", "caCity", "caZipCode", "caState",
"userType", "userPrivils", "_pwdExpirDate"};
QString AccountDb::dbType(const QString &userName,
const QString &defaultValue) const
enum Isds::Type::DbType AccountDb::dbType(const QString &userName,
enum Isds::Type::DbType defaultValue) const
{
QMutexLocker locker(&m_lock);
QSqlQuery query(m_db);
......@@ -78,7 +78,7 @@ QString AccountDb::dbType(const QString &userName,
query.bindValue(":key", userName);
if (query.exec() && query.isActive() &&
query.first() && query.isValid()) {
return query.value(0).toString();
return Isds::strVariant2DbType(query.value(0));
} else {
logErrorNL("Cannot execute SQL query and/or read SQL data: %s",
query.lastError().text().toUtf8().constData());
......@@ -88,7 +88,6 @@ fail:
return defaultValue;
}
QString AccountDb::dbId(const QString &userName,
const QString &defaultValue) const
{
......@@ -119,37 +118,6 @@ fail:
return defaultValue;
}
bool AccountDb::isOvm(const QString &userName) const
{
QMutexLocker locker(&m_lock);
QSqlQuery query(m_db);
QString queryStr;
if (Q_UNLIKELY(!m_db.isOpen())) {
logErrorNL("%s", "Account database seems not to be open.");
goto fail;
}
queryStr = "SELECT dbType FROM account_info WHERE key = :key";
if (Q_UNLIKELY(!query.prepare(queryStr))) {
logErrorNL("Cannot prepare SQL query: %s",
query.lastError().text().toUtf8().constData());
goto fail;
}
query.bindValue(":key", userName);
if (query.exec() && query.isActive() &&
query.first() && query.isValid()) {
Isds::Type::DbType dbType =
Isds::strVariant2DbType(query.value(0));
return (dbType < Isds::Type::BT_PO);
} else {
logErrorNL("Cannot execute SQL query and/or read SQL data: %s",
query.lastError().text().toUtf8().constData());
}
fail:
return false;
}
bool AccountDb::updatePwdExpirInDb(const QString &userName, const QDateTime &date)
{
QMutexLocker locker(&m_lock);
......
......@@ -46,14 +46,14 @@ public:
using SQLiteDbSingle::closeDb;
/*!
* @brief Return data box tyoe.
* @brief Return data-box type.
*
* @param[in] userName Account user name.
* @param[in] defaultValue Default value.
* @return Databox type string.
* @return Databox type.
*/
QString dbType(const QString &userName,
const QString &defaultValue = QString()) const;
enum Isds::Type::DbType dbType(const QString &userName,
enum Isds::Type::DbType defaultValue = Isds::Type::BT_NULL) const;
/*!
* @brief Return data box identifier.
......@@ -65,14 +65,6 @@ public:
QString dbId(const QString &userName,
const QString &defaultValue = QString()) const;
/*!
* @brief Check if databox is OVM.
*
* @param[in] userName User name identifying account.
* @return True if databox is OVM.
*/
bool isOvm(const QString &userName) const;
/*!
* @brief Delete account info from db.
*
......
......@@ -26,6 +26,7 @@
#include <QUrl>
#include "src/datovka_shared/isds/box_interface.h"
#include "src/datovka_shared/isds/type_conversion.h" /* Isds::dbType2Str */
#include "src/datovka_shared/log/log.h"
#include "src/dialogues/dialogues.h"
#include "src/global.h"
......@@ -48,7 +49,8 @@ Accounts::Accounts(QObject *parent)
QString Accounts::dbType(const QmlAcntId *qAcntId)
{
if ((GlobInstcs::accountDbPtr != Q_NULLPTR) && (qAcntId != Q_NULLPTR)) {
return GlobInstcs::accountDbPtr->dbType(qAcntId->username());
return Isds::dbType2Str(
GlobInstcs::accountDbPtr->dbType(qAcntId->username()));
} else {
Q_ASSERT(0);
return QString();
......@@ -68,7 +70,9 @@ QString Accounts::dbId(const QmlAcntId *qAcntId)
bool Accounts::isOvm(const QmlAcntId *qAcntId)
{
if ((GlobInstcs::accountDbPtr != Q_NULLPTR) && (qAcntId != Q_NULLPTR)) {
return GlobInstcs::accountDbPtr->isOvm(qAcntId->username());
enum Isds::Type::DbType dbType =
GlobInstcs::accountDbPtr->dbType(qAcntId->username());
return (Isds::Type::BT_NULL < dbType) && (dbType < Isds::Type::BT_PO);
} else {
Q_ASSERT(0);
return false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment