Commit 61560b69 authored by Karel Slaný's avatar Karel Slaný

Moved getdbStateText() into separate compilation unit.

parent 52d255be
......@@ -94,6 +94,7 @@ SOURCES += \
src/io/filesystem.cpp \
src/io/sqlite/db.cpp \
src/io/sqlite/table.cpp \
src/isds/isds_conversion.cpp \
src/locker.cpp \
src/log/log.cpp \
src/main.cpp \
......@@ -146,6 +147,7 @@ HEADERS += \
src/io/filesystem.h \
src/io/sqlite/db.h \
src/io/sqlite/table.h \
src/isds/isds_conversion.h \
src/locker.h \
src/log/log.h \
src/messages.h \
......
/*
* Copyright (C) 2014-2016 CZ.NIC
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -21,8 +21,8 @@
* the two.
*/
#ifndef COMMON_H
#define COMMON_H
#ifndef _COMMON_H_
#define _COMMON_H_
/* APPLICATION IDENTIFICATION */
#define APP_ORG_NAME "CZ.NIC, z.s.p.o."
......@@ -52,12 +52,4 @@
/* HOME PAGE */
#define DATOVKA_HOMEPAGE_URL "https://labs.nic.cz/cs/datovka.html"
/* DATABOX STATES */
#define DBSTATE_ACCESSIBLE 1
#define DBSTATE_TEMP_UNACCESSIBLE 2
#define DBSTATE_NOT_YET_ACCESSIBLE 3
#define DBSTATE_PERM_UNACCESSIBLE 4
#define DBSTATE_REMOVED 5
#define DBSTATE_TEMP_UNACCESSIBLE_LAW 6
#endif // COMMON_H
#endif /* _COMMON_H_ */
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#include "src/isds/isds_conversion.h"
/* DATABOX STATES */
#define DBSTATE_ACCESSIBLE 1
#define DBSTATE_TEMP_UNACCESSIBLE 2
#define DBSTATE_NOT_YET_ACCESSIBLE 3
#define DBSTATE_PERM_UNACCESSIBLE 4
#define DBSTATE_REMOVED 5
#define DBSTATE_TEMP_UNACCESSIBLE_LAW 6
QString IsdsConversion::dataBoxStateDescription(int state)
{
switch (state) {
case DBSTATE_ACCESSIBLE:
return tr("The data box is accessible. "
"It is possible to send messages into it. "
"It can be looked up on the Portal.");
break;
case DBSTATE_TEMP_UNACCESSIBLE:
return tr(
"The data box is temporarily inaccessible (at own request). "
"It may be made accessible again at some point in the future.");
break;
case DBSTATE_NOT_YET_ACCESSIBLE:
return tr("The data box is so far inactive. "
"The owner of the box has to log into the web interface at first in order to activate the box.");
break;
case DBSTATE_PERM_UNACCESSIBLE:
return tr("The data box is permanently inaccessible. "
"It is waiting to be deleted (but it may be made accessible again).");
break;
case DBSTATE_REMOVED:
return tr(
"The data box has been deleted (none the less it exists in ISDS).");
break;
case DBSTATE_TEMP_UNACCESSIBLE_LAW:
return tr(
"The data box is temporarily inaccessible (because of the reasons enumerated in the law at the time of access denial). "
"It may be made accessible again at some point in the future.");
break;
default:
return tr("An error occurred while checking the status.");
break;
}
}
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#ifndef _ISDS_CONVERSION_H_
#define _ISDS_CONVERSION_H_
#include <QCoreApplication> // Q_DECLARE_TR_FUNCTIONS
#include <QString>
/*!
* @brief Provides conversion functions for ISDS types.
*/
class IsdsConversion {
Q_DECLARE_TR_FUNCTIONS(IsdsConversion)
private:
/*!
* @brief Private constructor.
*/
IsdsConversion(void);
public:
/*!
* @brief Returns localised description of data box state.
*
* @param[in] state Data-box state code.
* @return Localised description.
*/
static
QString dataBoxStateDescription(int state);
};
#endif /* _ISDS_CONVERSION_H_ */
......@@ -21,7 +21,6 @@
* the two.
*/
#include <QDebug>
#include <QQmlEngine> /* qmlRegisterType */
#include <QSqlRecord>
......
......@@ -21,9 +21,10 @@
* the two.
*/
#include "src/settings.h"
#include "src/isds/isds_conversion.h"
#include "src/models/accountmodel.h"
#include "src/net/db_wrapper.h"
#include "src/settings.h"
#include "src/sqlite/account_db.h"
DbWrapper::DbWrapper(QObject *parent)
......@@ -100,7 +101,7 @@ QString DbWrapper::createAccountInfoStringForQml(
accountInfo.nationality));
}
dbInfo.append(strongInfoLine(tr("Databox state"),
getdbStateText(accountInfo.dbState)));
IsdsConversion::dataBoxStateDescription(accountInfo.dbState)));
dbInfo.append(strongInfoLine(tr("Effective OVM"),
(accountInfo.dbEffectiveOVM) ? tr("Yes") : tr("No")));
dbInfo.append(strongInfoLine(tr("Open addressing"),
......
/*
* Copyright (C) 2014-2016 CZ.NIC
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -29,13 +29,12 @@
#include <QSqlRecord>
#include <QStandardPaths>
#include "src/common.h"
#include "src/io/filesystem.h"
#include "src/isds/isds_conversion.h"
#include "src/sqlite/account_db.h"
#include "src/sqlite/db_tables.h"
#include "src/sqlite/dbs.h"
const QVector<QString> AccountDb::dsPrintedAttribs = {"dbID",
"dbType", "dbEffectiveOVM", "dbOpenAddressing", "dbState"};
......@@ -50,46 +49,6 @@ const QVector<QString> AccountDb::userPrintedAttribs = {"firmName", "ic",
"biDate", "caStreet", "caCity", "caZipCode", "caState",
"userType", "userPrivils", "_pwdExpirDate"};
/* ========================================================================= */
/*
* Convert DS state to string.
*/
QString getdbStateText(int value)
/* ========================================================================= */
{
switch (value) {
case DBSTATE_ACCESSIBLE:
return QObject::tr(
"The databox is accessible. It is possible to send messages into it. It can be looked up on the Portal.");
break;
case DBSTATE_TEMP_UNACCESSIBLE:
return QObject::tr(
"The databox is temporarily inaccessible (at own request). It may be made accessible again at some point in the future.");
break;
case DBSTATE_NOT_YET_ACCESSIBLE:
return QObject::tr(
"The databox is so far inactive. The owner of the box has to log into the web interface at first in order to activate the box.");
break;
case DBSTATE_PERM_UNACCESSIBLE:
return QObject::tr(
"The databox is permanently inaccessible. It is waiting to be deleted (but it may be made accessible again).");
break;
case DBSTATE_REMOVED:
return QObject::tr(
"The databox has been deleted (none the less it exists in ISDS).");
break;
case DBSTATE_TEMP_UNACCESSIBLE_LAW:
return QObject::tr(
"The databox is temporarily inaccessible (because of the reasons enumerated in the law at the time of access denial). It may be made accessible again at some point in the future.");
break;
default:
return QObject::tr("An error occurred while checking the status.");
break;
}
}
/* ========================================================================= */
/*
* Translates ISDS author type to text.
......@@ -666,7 +625,7 @@ QString AccountDb::getAccountDetail(const QString &userName) const
} else if (dsPrintedAttribs[i] == "dbState") {
html += strongInfoLine(
accntinfTbl.attrProps[dsPrintedAttribs[i]].desc,
getdbStateText(query.value(i).toInt()));
IsdsConversion::dataBoxStateDescription(query.value(i).toInt()));
} else {
html += strongInfoLine(
accntinfTbl.attrProps[dsPrintedAttribs[i]].desc,
......
/*
* Copyright (C) 2014-2016 CZ.NIC
* Copyright (C) 2014-2017 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -109,12 +109,9 @@ private:
QList<class SQLiteTbl *> listOfTables(void);
};
/*!
* @brief Global account database.
*/
extern AccountDb *globAccountDbPtr;
QString getdbStateText(int value);
#endif /* _ACCOUNT_DB_H_ */
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