From ccf6e0d8487bf16bd0bbaa1f21bc97663d85f1a4 Mon Sep 17 00:00:00 2001 From: EndrII Date: Mon, 21 Nov 2022 23:17:13 +0300 Subject: [PATCH 01/19] begin separate nodes and parsers --- .gitmodules | 3 + CMakeLists.txt | 1 + Heart/AbstractSpace/Private/apiversion.cpp | 57 ++++++++++++++ Heart/AbstractSpace/Private/apiversion.h | 75 +++++++++++++++++++ Heart/AbstractSpace/Private/versionparser.cpp | 62 +++++++++++++++ Heart/AbstractSpace/Private/versionparser.h | 34 +++++++++ Heart/AbstractSpace/abstractnode.h | 2 +- Heart/AbstractSpace/apiversionparser.cpp | 16 ++++ Heart/AbstractSpace/apiversionparser.h | 35 +++++++++ Heart/AbstractSpace/iparser.h | 6 ++ Heart/AbstractSpace/packages/abstractdata.h | 5 ++ Heart/CMakeLists.txt | 2 +- plug.pro | 5 -- submodules/crc | 1 + 14 files changed, 297 insertions(+), 7 deletions(-) create mode 100644 Heart/AbstractSpace/Private/apiversion.cpp create mode 100644 Heart/AbstractSpace/Private/apiversion.h create mode 100644 Heart/AbstractSpace/Private/versionparser.cpp create mode 100644 Heart/AbstractSpace/Private/versionparser.h create mode 100644 Heart/AbstractSpace/apiversionparser.cpp create mode 100644 Heart/AbstractSpace/apiversionparser.h delete mode 100644 plug.pro create mode 160000 submodules/crc diff --git a/.gitmodules b/.gitmodules index 39d96f81..5d41ae3c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,6 @@ path = QuasarAppLib url = https://github.com/QuasarApp/QuasarAppLib.git +[submodule "submodules/crc"] + path = submodules/crc + url = https://github.com/QuasarApp/crc.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 10f7b1ac..77172b5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Network Sql Concurrent REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network Sql Concurrent REQUIRED) add_subdirectory(QuasarAppLib) +add_subdirectory(submodules/crc) add_subdirectory(Heart) if (HEART_TESTS) diff --git a/Heart/AbstractSpace/Private/apiversion.cpp b/Heart/AbstractSpace/Private/apiversion.cpp new file mode 100644 index 00000000..fe9c2976 --- /dev/null +++ b/Heart/AbstractSpace/Private/apiversion.cpp @@ -0,0 +1,57 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "apiversion.h" + +namespace RC { + +APIVersion::APIVersion() { + +} + +QDataStream &APIVersion::fromStream(QDataStream &stream) { + + stream >> _minimum; + stream >> _maximum; + stream >> _APINameKey; + + return stream; +} + +QDataStream &APIVersion::toStream(QDataStream &stream) const { + stream << _minimum; + stream << _maximum; + stream << _APINameKey; + + return stream; +} + +unsigned int APIVersion::APINameKey() const { + return _APINameKey; +} + +void APIVersion::setAPINameKey(unsigned int newAPINameKey) { + _APINameKey = newAPINameKey; +} + +unsigned short APIVersion::maximum() const { + return _maximum; +} + +void APIVersion::setMaximum(unsigned short newMaximum) { + _maximum = newMaximum; +} + +unsigned short APIVersion::minimum() const { + return _minimum; +} + +void APIVersion::setMinimum(unsigned short newMinimum) { + _minimum = newMinimum; +} + +} diff --git a/Heart/AbstractSpace/Private/apiversion.h b/Heart/AbstractSpace/Private/apiversion.h new file mode 100644 index 00000000..ed96faad --- /dev/null +++ b/Heart/AbstractSpace/Private/apiversion.h @@ -0,0 +1,75 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#ifndef APPVERSION_H +#define APPVERSION_H + +#include + + +namespace RC { + +/** + * @brief The APIVersion class This is base pacakge class that send information about supported api version on the paired node + */ +class APIVersion: public QH::PKG::AbstractData +{ + +public: + APIVersion(); + + /** + * @brief minimum This is minimum supported api version + * @return minimum supported api version + */ + unsigned short minimum() const; + + /** + * @brief setMinimum This mehod sets new value for the minimum supported api version. + * @param newMinimum This is new value of the minimum supported api version. + */ + void setMinimum(unsigned short newMinimum); + + /** + * @brief maximum This is maximum supported api version + * @return maximum supported api version + */ + unsigned short maximum() const; + + /** + * @brief setMaximum This mehod sets new value for the maximum supported api version. + * @param newMaximum This is new value of the maximum supported api version. + */ + void setMaximum(unsigned short newMaximum); + + /** + * @brief APINameKey This is api + * @return + */ + unsigned int APINameKey() const; + void setAPINameKey(unsigned int newAPINameKey); + + static unsigned short command(){return PROTOCKOL_VERSION_COMMAND;} + static QString commandText(){return "PROTOCKOL_VERSION_COMMAND";} + unsigned short cmd() const override {return APIVersion::command();} + QString cmdString() const override {return APIVersion::commandText();} + +protected: + unsigned int localCode() const override {return typeid(APIVersion).hash_code();} + QDataStream &fromStream(QDataStream &stream) override; + QDataStream &toStream(QDataStream &stream) const override; + +private: + unsigned int _APINameKey = 0; + unsigned short _minimum = 0; + unsigned short _maximum = 0; + +}; + +} + +#endif // APPVERSION_H diff --git a/Heart/AbstractSpace/Private/versionparser.cpp b/Heart/AbstractSpace/Private/versionparser.cpp new file mode 100644 index 00000000..b7a91f2d --- /dev/null +++ b/Heart/AbstractSpace/Private/versionparser.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2018-2022 QuasarApp. + * Distributed under the lgplv3 software license, see the accompanying + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. +*/ + +#include "versionparser.h" +namespace QH { + +VersionParser::VersionParser() { + +} + +ParserResult VersionParser::parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + const AbstractNodeInfo *sender) { + +// auto parentResult = AbstractNode::parsePackage(pkg, pkgHeader, sender); +// if (parentResult != QH::ParserResult::NotProcessed) { +// return parentResult; +// } + + // here node must be receive version of connected application. + // if not use the default version (0)ApplicationVersion + parentResult = commandHandler(this, &BaseNode::processAppVersion, + pkg, sender, pkgHeader); + if (parentResult != QH::ParserResult::NotProcessed) { + return parentResult; + } + + // here node must be receive responce that version is delivered. + // when node receive this message then node status are confirmed + parentResult = commandHandler(this, &BaseNode::versionDeliveredSuccessful, + pkg, sender, pkgHeader); + if (parentResult != QH::ParserResult::NotProcessed) { + return parentResult; + } + + auto distVersion = static_cast(sender)->version(); + auto parser = selectParser(distVersion); + + if (!parser) { + QuasarAppUtils::Params::log(QString("Can't found requeried parser for versions: %0-%1"). + arg(distVersion.minimum()). + arg(distVersion.maximum()), + QuasarAppUtils::Warning); + + return QH::ParserResult::NotProcessed; + } + + return parser->parsePackage(pkg, pkgHeader, sender); +} + +int VersionParser::version() const { + return 0; +} + +QString VersionParser::parserId() const { + return "QHNodeVersionParser"; +} +} diff --git a/Heart/AbstractSpace/Private/versionparser.h b/Heart/AbstractSpace/Private/versionparser.h new file mode 100644 index 00000000..f5a0caaa --- /dev/null +++ b/Heart/AbstractSpace/Private/versionparser.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2018-2022 QuasarApp. + * Distributed under the lgplv3 software license, see the accompanying + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. +*/ + + +#ifndef VERSIONPARSER_H +#define VERSIONPARSER_H + +#include + +namespace QH { + +/** + * @brief The VersionParser class This is base parser. This parser have only one version is 0 because node du not has any version information in this step. + */ +class VersionParser: public QH::iParser +{ +public: + VersionParser(); + + // iParser interface +public: + ParserResult parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + const AbstractNodeInfo *sender) override; + int version() const override; + + QString parserId() const override; +}; +} +#endif // VERSIONPARSER_H diff --git a/Heart/AbstractSpace/abstractnode.h b/Heart/AbstractSpace/abstractnode.h index 54229e45..20a10d48 100644 --- a/Heart/AbstractSpace/abstractnode.h +++ b/Heart/AbstractSpace/abstractnode.h @@ -111,7 +111,7 @@ class Abstract; * @see AbstractNode::registerPackageType * @see AbstractNode::parsePackage */ -class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete, public iParser +class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete { Q_OBJECT diff --git a/Heart/AbstractSpace/apiversionparser.cpp b/Heart/AbstractSpace/apiversionparser.cpp new file mode 100644 index 00000000..e72825af --- /dev/null +++ b/Heart/AbstractSpace/apiversionparser.cpp @@ -0,0 +1,16 @@ +//# +//# Copyright (C) 2022-2022 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "apiversionparser.h" +namespace QH { + +APIVersionParser::APIVersionParser() +{ + +} + +} diff --git a/Heart/AbstractSpace/apiversionparser.h b/Heart/AbstractSpace/apiversionparser.h new file mode 100644 index 00000000..7a02cd6d --- /dev/null +++ b/Heart/AbstractSpace/apiversionparser.h @@ -0,0 +1,35 @@ +//# +//# Copyright (C) 2022-2022 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef APIVERSIONPARSER_H +#define APIVERSIONPARSER_H + +#include "iparser.h" + +namespace QH { + + +/** + * @brief The APIVersionParser class This is main parser forthe main command. + * This parsers work only with the APIVersion packge; + */ +class APIVersionParser: public iParser +{ +public: + APIVersionParser(); + + // iParser interface +public: + ParserResult parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + const AbstractNodeInfo *sender) override; + int version() const override; + QString parserId() const override; +}; +} +#endif // APIVERSIONPARSER_H diff --git a/Heart/AbstractSpace/iparser.h b/Heart/AbstractSpace/iparser.h index aee015d8..b807b41c 100644 --- a/Heart/AbstractSpace/iparser.h +++ b/Heart/AbstractSpace/iparser.h @@ -188,6 +188,12 @@ class HEARTSHARED_EXPORT iParser */ bool checkCommand(unsigned short cmd) const; + /** + * @brief parserId This is id of the parsers. All parser will be synced betwin nodes by ids. + * @return parser id. + */ + virtual QString parserId() const = 0; + private: QHash> _registeredTypes; diff --git a/Heart/AbstractSpace/packages/abstractdata.h b/Heart/AbstractSpace/packages/abstractdata.h index 88c16c75..b8baaebe 100644 --- a/Heart/AbstractSpace/packages/abstractdata.h +++ b/Heart/AbstractSpace/packages/abstractdata.h @@ -12,6 +12,11 @@ #include +/** + * @brief PROTOCKOL_VERSION_COMMAND is command for exchange versions number betwin nodes. + */ +#define PROTOCKOL_VERSION_COMMAND 0xFFFF + /** * @brief QH_PACKAGE This macross prepare data to send and create a global id for package. For get global id use the cmd method. * For get quick access for global command use the ClassName::command() method. This method is static. diff --git a/Heart/CMakeLists.txt b/Heart/CMakeLists.txt index 62a6b7a7..89d34e2b 100644 --- a/Heart/CMakeLists.txt +++ b/Heart/CMakeLists.txt @@ -83,7 +83,7 @@ set(SOURCE_CPP ${SOURCE_CPP_LVL_0} ${SOURCE_CPP_LVL_1} ${SOURCE_CPP_LVL_2}) add_library(${PROJECT_NAME} ${SOURCE_CPP}) -target_link_libraries(${PROJECT_NAME} PUBLIC Qt::Core Qt::Network Qt::Sql Qt::Concurrent QuasarApp) +target_link_libraries(${PROJECT_NAME} PUBLIC Qt::Core Qt::Network Qt::Sql Qt::Concurrent QuasarApp crc) if (HEART_SSL) if (HEART_STATIC_SSL) diff --git a/plug.pro b/plug.pro deleted file mode 100644 index be046039..00000000 --- a/plug.pro +++ /dev/null @@ -1,5 +0,0 @@ - -TEMPLATE = subdirs - -QMAKE_EXTRA_TARGETS += \ - test diff --git a/submodules/crc b/submodules/crc new file mode 160000 index 00000000..735b9216 --- /dev/null +++ b/submodules/crc @@ -0,0 +1 @@ +Subproject commit 735b92168b4c6ca91fc5598d536859adf86c949c From 4afb43509c5758e6e9c9bfbbe1b12e2b36e8483d Mon Sep 17 00:00:00 2001 From: EndrII Date: Tue, 22 Nov 2022 22:17:34 +0300 Subject: [PATCH 02/19] work on the APIVersionParser --- Heart/AbstractSpace/Private/apiversion.cpp | 36 +---- Heart/AbstractSpace/Private/apiversion.h | 41 +---- .../Private/versionisreceived.cpp | 23 +++ .../AbstractSpace/Private/versionisreceived.h | 33 ++++ Heart/AbstractSpace/abstractnodeinfo.cpp | 26 +++- Heart/AbstractSpace/abstractnodeinfo.h | 59 ++++++- Heart/AbstractSpace/apiversionparser.cpp | 146 +++++++++++++++++- Heart/AbstractSpace/apiversionparser.h | 75 ++++++++- Heart/AbstractSpace/iparser.h | 2 +- 9 files changed, 368 insertions(+), 73 deletions(-) create mode 100644 Heart/AbstractSpace/Private/versionisreceived.cpp create mode 100644 Heart/AbstractSpace/Private/versionisreceived.h diff --git a/Heart/AbstractSpace/Private/apiversion.cpp b/Heart/AbstractSpace/Private/apiversion.cpp index fe9c2976..baf8ebdc 100644 --- a/Heart/AbstractSpace/Private/apiversion.cpp +++ b/Heart/AbstractSpace/Private/apiversion.cpp @@ -7,7 +7,7 @@ #include "apiversion.h" -namespace RC { +namespace QH { APIVersion::APIVersion() { @@ -15,43 +15,21 @@ APIVersion::APIVersion() { QDataStream &APIVersion::fromStream(QDataStream &stream) { - stream >> _minimum; - stream >> _maximum; - stream >> _APINameKey; - + stream >> _version; return stream; } QDataStream &APIVersion::toStream(QDataStream &stream) const { - stream << _minimum; - stream << _maximum; - stream << _APINameKey; - + stream << _version; return stream; } -unsigned int APIVersion::APINameKey() const { - return _APINameKey; -} - -void APIVersion::setAPINameKey(unsigned int newAPINameKey) { - _APINameKey = newAPINameKey; -} - -unsigned short APIVersion::maximum() const { - return _maximum; -} - -void APIVersion::setMaximum(unsigned short newMaximum) { - _maximum = newMaximum; -} - -unsigned short APIVersion::minimum() const { - return _minimum; +const VersionData &APIVersion::version() const { + return _version; } -void APIVersion::setMinimum(unsigned short newMinimum) { - _minimum = newMinimum; +void APIVersion::setVersion(const VersionData &newVersion) { + _version = newVersion; } } diff --git a/Heart/AbstractSpace/Private/apiversion.h b/Heart/AbstractSpace/Private/apiversion.h index ed96faad..bb5c1869 100644 --- a/Heart/AbstractSpace/Private/apiversion.h +++ b/Heart/AbstractSpace/Private/apiversion.h @@ -9,9 +9,10 @@ #define APPVERSION_H #include +#include "abstractnodeinfo.h" -namespace RC { +namespace QH { /** * @brief The APIVersion class This is base pacakge class that send information about supported api version on the paired node @@ -22,51 +23,21 @@ class APIVersion: public QH::PKG::AbstractData public: APIVersion(); - /** - * @brief minimum This is minimum supported api version - * @return minimum supported api version - */ - unsigned short minimum() const; - - /** - * @brief setMinimum This mehod sets new value for the minimum supported api version. - * @param newMinimum This is new value of the minimum supported api version. - */ - void setMinimum(unsigned short newMinimum); - - /** - * @brief maximum This is maximum supported api version - * @return maximum supported api version - */ - unsigned short maximum() const; - - /** - * @brief setMaximum This mehod sets new value for the maximum supported api version. - * @param newMaximum This is new value of the maximum supported api version. - */ - void setMaximum(unsigned short newMaximum); - - /** - * @brief APINameKey This is api - * @return - */ - unsigned int APINameKey() const; - void setAPINameKey(unsigned int newAPINameKey); - static unsigned short command(){return PROTOCKOL_VERSION_COMMAND;} static QString commandText(){return "PROTOCKOL_VERSION_COMMAND";} unsigned short cmd() const override {return APIVersion::command();} QString cmdString() const override {return APIVersion::commandText();} + const VersionData &version() const; + void setVersion(const VersionData &newVersion); + protected: unsigned int localCode() const override {return typeid(APIVersion).hash_code();} QDataStream &fromStream(QDataStream &stream) override; QDataStream &toStream(QDataStream &stream) const override; private: - unsigned int _APINameKey = 0; - unsigned short _minimum = 0; - unsigned short _maximum = 0; + VersionData _version; }; diff --git a/Heart/AbstractSpace/Private/versionisreceived.cpp b/Heart/AbstractSpace/Private/versionisreceived.cpp new file mode 100644 index 00000000..1718775c --- /dev/null +++ b/Heart/AbstractSpace/Private/versionisreceived.cpp @@ -0,0 +1,23 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "versionisreceived.h" +namespace QH { + +VersionIsReceived::VersionIsReceived() +{ + +} + +QDataStream &VersionIsReceived::fromStream(QDataStream &stream) { + return stream; +} + +QDataStream &VersionIsReceived::toStream(QDataStream &stream) const { + return stream; +} +} diff --git a/Heart/AbstractSpace/Private/versionisreceived.h b/Heart/AbstractSpace/Private/versionisreceived.h new file mode 100644 index 00000000..e6758cbb --- /dev/null +++ b/Heart/AbstractSpace/Private/versionisreceived.h @@ -0,0 +1,33 @@ +//# +//# Copyright (C) 2020-2022 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef VERSIONISRECEIVED_H +#define VERSIONISRECEIVED_H + +#include + +namespace QH { + +/** + * @brief The VersionIsReceived class + */ +class VersionIsReceived: public QH::PKG::AbstractData +{ + QH_PACKAGE(VersionIsReceived, "VersionIsReceived") + +public: + VersionIsReceived(); + + // StreamBase interface +protected: + QDataStream &fromStream(QDataStream &stream) override; + QDataStream &toStream(QDataStream &stream) const override; +}; + +} +#endif // VERSIONISRECEIVED_H diff --git a/Heart/AbstractSpace/abstractnodeinfo.cpp b/Heart/AbstractSpace/abstractnodeinfo.cpp index 3c479fb4..b5d2cc6d 100644 --- a/Heart/AbstractSpace/abstractnodeinfo.cpp +++ b/Heart/AbstractSpace/abstractnodeinfo.cpp @@ -127,7 +127,31 @@ void AbstractNodeInfo::setStatus(const NodeCoonectionStatus &status) { } bool AbstractNodeInfo::confirmData() const { - return _status != NodeCoonectionStatus::NotConnected; + return _status != NodeCoonectionStatus::NotConnected && fVersionDelivered() && fVersionReceived(); +} + +bool AbstractNodeInfo::fVersionDelivered() const { + return _fVersionDelivered; +} + +void AbstractNodeInfo::setFVersionDelivered(bool newFVersionDelivered) { + _fVersionDelivered = newFVersionDelivered; +} + +bool AbstractNodeInfo::fVersionReceived() const { + return _fVersionReceived; +} + +void AbstractNodeInfo::setFVersionReceived(bool newFVersionReceived) { + _fVersionReceived = newFVersionReceived; +} + +const VersionData &AbstractNodeInfo::version() const { + return _version; +} + +void AbstractNodeInfo::setVersion(const VersionData &newVersion) { + _version = newVersion; } void AbstractNodeInfo::updateConfirmStatus() { diff --git a/Heart/AbstractSpace/abstractnodeinfo.h b/Heart/AbstractSpace/abstractnodeinfo.h index 3b1b2508..8194c5a1 100644 --- a/Heart/AbstractSpace/abstractnodeinfo.h +++ b/Heart/AbstractSpace/abstractnodeinfo.h @@ -7,9 +7,9 @@ #ifndef ABSTRACTNODEINFO_H #define ABSTRACTNODEINFO_H + #include "hostaddress.h" #include "heart_global.h" - #include @@ -18,6 +18,23 @@ class QHostInfo; namespace QH { +/** + * @brief The DistVersion class This is infirmation of supported versions of the distanation api. + */ +struct DistVersion { + + /// This is monimum supported version. + unsigned short min = 0; + + /// This is maximum supported version. + unsigned short max = 0; +}; + +/** + * @brief VersionData This is array of all avalable apis and supported its versions. + */ +typedef QHash VersionData; + /** * @brief The TrustNode enum contains cases for trust of the client or nodes. */ @@ -191,6 +208,42 @@ class HEARTSHARED_EXPORT AbstractNodeInfo: public QObject */ void setSct(QAbstractSocket *sct); + /** + * @brief version This method return version data structure; + * @return version data structure; + */ + const VersionData &version() const; + + /** + * @brief setVersion This method sets new version data structure. + * @param newVersion This is new values of the version. + */ + void setVersion(const VersionData &newVersion); + + /** + * @brief fVersionReceived This method return true if this node receive version information. + * @return true if this node receive version information. + */ + bool fVersionReceived() const; + + /** + * @brief setFVersionReceived This method change the fVersionReceived flag. + * @param newFVersionReceived this is new value of the fVersionReceived flag. + */ + void setFVersionReceived(bool newFVersionReceived); + + /** + * @brief fVersionDelivered This method return true if this node delivere own version to the distanation node. + * @return true if this node delivere own version to the distanation node. + */ + bool fVersionDelivered() const; + + /** + * @brief setFVersionDelivered This method change the fVersionDelivered flag. + * @param newFVersionDelivered this is new value of the fVersionDelivered flag. + */ + void setFVersionDelivered(bool newFVersionDelivered); + public slots: /** * @brief removeSocket This method use for remove socket. @@ -263,6 +316,10 @@ public slots: NodeCoonectionStatus _status = NodeCoonectionStatus::NotConnected; bool _isLocal = false; + VersionData _version; + bool _fVersionReceived = false; + bool _fVersionDelivered = false; + }; } diff --git a/Heart/AbstractSpace/apiversionparser.cpp b/Heart/AbstractSpace/apiversionparser.cpp index e72825af..0d0a04e7 100644 --- a/Heart/AbstractSpace/apiversionparser.cpp +++ b/Heart/AbstractSpace/apiversionparser.cpp @@ -6,11 +6,153 @@ //# #include "apiversionparser.h" +#include "abstractnodeinfo.h" + +#include +#include +#include +#include + namespace QH { -APIVersionParser::APIVersionParser() -{ +APIVersionParser::APIVersionParser() { + +} + +ParserResult APIVersionParser::parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + AbstractNodeInfo *sender) { + + // here node must be receive version of connected application. + // if not use the default version (0)APIVersion + auto parentResult = commandHandler(this, &APIVersionParser::processAppVersion, + pkg, sender, pkgHeader); + if (parentResult != QH::ParserResult::NotProcessed) { + return parentResult; + } + + // here node must be receive responce that version is delivered. + // when node receive this message then node status are confirmed + parentResult = commandHandler(this, &APIVersionParser::versionDeliveredSuccessful, + pkg, sender, pkgHeader); + if (parentResult != QH::ParserResult::NotProcessed) { + return parentResult; + } + + auto distVersion = sender->version(); + const auto parsers = selectParser(distVersion); + + if (parsers.isEmpty()) { + QuasarAppUtils::Params::log(QString("Can't found requeried parser for versions"), + QuasarAppUtils::Warning); + return ParserResult::NotProcessed; + } + + for (const auto& parser: parsers) { + if (!parser) { + QuasarAppUtils::Params::log(QString("Internal Error with selection parasers."), + QuasarAppUtils::Error); + continue; + } + + auto perserResult = parser->parsePackage(pkg, pkgHeader, sender); + if (perserResult != QH::ParserResult::NotProcessed) { + return perserResult; + } + } + + return ParserResult::NotProcessed; +} + +int APIVersionParser::version() const { + return 0; +} + +QString APIVersionParser::parserId() const { + return "APIVersionParser"; +} + +QSharedPointer +APIVersionParser::getSelectedApiParser(const QString &apiKey, + AbstractNodeInfo *node) const { + return selectParser(node->version()).value(apiKey, nullptr); +} + +void APIVersionParser::addApiParser(const QSharedPointer &parserObject) { + _apiParsers[parserObject->parserId()][parserObject->version()] = parserObject; +} + +QHash> +APIVersionParser::selectParser(const VersionData &distVersion) const { + QHash> result; + + for (auto it = distVersion.begin(); it != distVersion.end(); ++it) { + for (int version = it->max; version >= it->min; --version) { + auto parser = _apiParsers[it.key()].value(version, nullptr); + if (parser) + result[it.key()] = parser; + } + } + + return result; +} + +unsigned short APIVersionParser::maximumApiVersion(const QString &apiKey) const { + + auto availableVersion = _apiParsers.value(apiKey, {}); + if (availableVersion.size()) { + return availableVersion.lastKey(); + } + + return 0; +} + +unsigned short APIVersionParser::minimumApiVersion(const QString &apiKey) const { + auto availableVersion = _apiParsers.value(apiKey, {}); + if (availableVersion.size()) { + return availableVersion.firstKey(); + } + + return 0; +} + +bool APIVersionParser::processAppVersion(const QSharedPointer &message, + QH::AbstractNodeInfo *sender, + const QH::Header &) { + + auto distVersion = message->version(); + sender->setVersion(distVersion); + auto parser = selectParser(distVersion); + + for (const auto &parserKey: message->version().keys()) { + if (!parser.contains(parserKey)) { + auto requiredApi = distVersion.value(parserKey); + + QuasarAppUtils::Params::log(QString("Can't found %0 parser for versions: %1-%2"). + arg(parserKey). + arg(requiredApi.min). + arg(requiredApi.max), + QuasarAppUtils::Error); + + unsigned short distMinVersion = sender->version().value(parserKey).min; + + if (distMinVersion > maximumApiVersion(parserKey)) { + emit sigNoLongerSupport(parserKey, distMinVersion); + } + + return false; + } + } + + VersionIsReceived result; + return node().send(&result, sender); +} +bool APIVersionParser::versionDeliveredSuccessful(const QSharedPointer &, + AbstractNodeInfo *sender, + const QH::Header &) { + sender->setFVersionDelivered(true); + return true; } } diff --git a/Heart/AbstractSpace/apiversionparser.h b/Heart/AbstractSpace/apiversionparser.h index 7a02cd6d..538d6332 100644 --- a/Heart/AbstractSpace/apiversionparser.h +++ b/Heart/AbstractSpace/apiversionparser.h @@ -9,27 +9,94 @@ #ifndef APIVERSIONPARSER_H #define APIVERSIONPARSER_H +#include "abstractnodeinfo.h" #include "iparser.h" namespace QH { +class APIVersion; +class VersionIsReceived; /** * @brief The APIVersionParser class This is main parser forthe main command. * This parsers work only with the APIVersion packge; */ -class APIVersionParser: public iParser +class APIVersionParser: public QObject, public iParser { + Q_OBJECT public: APIVersionParser(); - // iParser interface -public: ParserResult parsePackage(const QSharedPointer &pkg, const Header &pkgHeader, - const AbstractNodeInfo *sender) override; + AbstractNodeInfo *sender) override; int version() const override; QString parserId() const override; + + /** + * @brief getSelectedApiParser This method return apiParser for selected node + * @param apiKey This is key of needed api. + * @param node This is distanation node. + * @return needed parser of the distanation node. + */ + QSharedPointer getSelectedApiParser(const QString& apiKey, + QH::AbstractNodeInfo *node) const; + + /** + * @brief addApiParser This method add new Api parser for this node. + * @param parserObject This is bew api parser. + */ + void addApiParser(const QSharedPointer& parserObject); + + /** + * @brief addApiParser This is template metod that add sipport of new apiparser @a ApiType + * @tparam ApiType This is type of new apiParser that will be added to the main parser. + */ + template + void addApiParser() { + addApiParser(QSharedPointer::create(this)); + } + + /** + * @brief selectParser This method select api parser betwin nodes. + * @param distVersion This is information about distanation node version. + * @return hash map of needed parsers of the distanation node. + */ + QHash> + selectParser(const VersionData& distVersion) const; + + /** + * @brief maximumApiVersion This method return maximum supported api version of this node. + * @param apiKey This is api key. + * @return maximum supported api version of this node. + */ + unsigned short maximumApiVersion(const QString& apiKey) const; + + /** + * @brief minimumApiVersion This method return minimum supported api version of this node. + * @param apiKey This is api key. + * @return minimum supported api version of this node. + */ + unsigned short minimumApiVersion(const QString& apiKey) const; + +signals: + + /** + * @brief sigNoLongerSupport This signal will be emit when node receive incomplite versions. + * @param ApiKey This is key of not supported version. + * @param version This is version + */ + void sigNoLongerSupport(const QString& ApiKey, unsigned short version); + +private: + bool processAppVersion(const QSharedPointer &message, + AbstractNodeInfo *sender, + const QH::Header &); + bool versionDeliveredSuccessful(const QSharedPointer &, + QH::AbstractNodeInfo *sender, + const QH::Header &); + + QHash>> _apiParsers; }; } #endif // APIVERSIONPARSER_H diff --git a/Heart/AbstractSpace/iparser.h b/Heart/AbstractSpace/iparser.h index b807b41c..f34403c8 100644 --- a/Heart/AbstractSpace/iparser.h +++ b/Heart/AbstractSpace/iparser.h @@ -100,7 +100,7 @@ class HEARTSHARED_EXPORT iParser */ virtual ParserResult parsePackage(const QSharedPointer &pkg, - const Header& pkgHeader, const AbstractNodeInfo* sender) = 0; + const Header& pkgHeader, AbstractNodeInfo* sender) = 0; /** * @brief pareseResultToString This method convert ParserResult value to string. From 102aae32d6439bccc3cf5c3aa649e4fae58f903b Mon Sep 17 00:00:00 2001 From: EndrII Date: Wed, 23 Nov 2022 23:57:54 +0300 Subject: [PATCH 03/19] i do not known what i do .... this commit is refactoring of the Heart. i try to separate parser to another objects --- .../Private/abstractnodeparser.cpp | 86 ++++++++++++++++++ .../Private/abstractnodeparser.h | 32 +++++++ .../{bigdatamanager.cpp => bigdataparser.cpp} | 91 +++++++++++++------ .../{bigdatamanager.h => bigdataparser.h} | 51 ++++++----- Heart/AbstractSpace/abstractnode.cpp | 83 +++-------------- Heart/AbstractSpace/abstractnode.h | 74 ++++----------- Heart/AbstractSpace/apiversionparser.cpp | 28 +++++- Heart/AbstractSpace/apiversionparser.h | 4 +- Heart/AbstractSpace/iparser.cpp | 21 ++++- Heart/AbstractSpace/iparser.h | 20 +++- 10 files changed, 302 insertions(+), 188 deletions(-) create mode 100644 Heart/AbstractSpace/Private/abstractnodeparser.cpp create mode 100644 Heart/AbstractSpace/Private/abstractnodeparser.h rename Heart/AbstractSpace/Private/{bigdatamanager.cpp => bigdataparser.cpp} (58%) rename Heart/AbstractSpace/Private/{bigdatamanager.h => bigdataparser.h} (75%) diff --git a/Heart/AbstractSpace/Private/abstractnodeparser.cpp b/Heart/AbstractSpace/Private/abstractnodeparser.cpp new file mode 100644 index 00000000..9506a131 --- /dev/null +++ b/Heart/AbstractSpace/Private/abstractnodeparser.cpp @@ -0,0 +1,86 @@ +//# +//# Copyright (C) 2022-2022 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "abstractnodeparser.h" +#include "params.h" +#include "abstractnode.h" +#include "qaglobalutils.h" + +#include +#include +#include +#include + +namespace QH { + +AbstractNodeParser::AbstractNodeParser(AbstractNode* parentNode): iParser(parentNode) { + debug_assert(parentNode, "Node object can't be null!"); + + registerPackageType(); + registerPackageType(); + registerPackageType(); +} + +AbstractNodeParser::~AbstractNodeParser() { +} + +ParserResult AbstractNodeParser::parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + AbstractNodeInfo *sender) { + auto nodePtr = node(); + if (!nodePtr) { + return ParserResult::NotProcessed; + } + + if (!(sender)) { + QuasarAppUtils::Params::log("sender socket is not valid!", + QuasarAppUtils::Error); + return ParserResult::Error; + } + + if (!pkg->isValid()) { + QuasarAppUtils::Params::log("incomming package is not valid!", + QuasarAppUtils::Error); + nodePtr->changeTrust(sender->networkAddress(), CRITICAL_ERROOR); + return ParserResult::Error; + } + + nodePtr->incomingData(pkg.data(), sender); + + if (PKG::Ping::command() == pkg->cmd()) { + auto cmd = static_cast(pkg.data()); + if (!cmd->ansver()) { + cmd->setAnsver(true); + nodePtr->sendData(cmd, sender, &pkgHeader); + } + + return ParserResult::Processed; + } else if (PKG::BadRequest::command() == pkg->cmd()) { + auto cmd = static_cast(pkg.data()); + + emit nodePtr->requestError(cmd->errCode(), cmd->err()); + + return ParserResult::Processed; + + } else if (PKG::CloseConnection::command() == pkg->cmd()) { + if (sender->isLocal()) { + nodePtr->removeNode(sender->networkAddress()); + } + return ParserResult::Processed; + } + + return ParserResult::NotProcessed; +} + +int AbstractNodeParser::version() const { + return 0; +} + +QString AbstractNodeParser::parserId() const { + return "HeartLibAbstractAPI"; +} +} diff --git a/Heart/AbstractSpace/Private/abstractnodeparser.h b/Heart/AbstractSpace/Private/abstractnodeparser.h new file mode 100644 index 00000000..6ff4c112 --- /dev/null +++ b/Heart/AbstractSpace/Private/abstractnodeparser.h @@ -0,0 +1,32 @@ +//# +//# Copyright (C) 2022-2022 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef ABSTRACTNODEPARSER_H +#define ABSTRACTNODEPARSER_H + +#include + +namespace QH { + +/** + * @brief The AbstractNodeParser class is main parser of the abstract level of the hear lib. + */ +class AbstractNodeParser: public iParser +{ +public: + AbstractNodeParser(AbstractNode *parentNode); + ~AbstractNodeParser() override; + ParserResult parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + AbstractNodeInfo *sender) override; + int version() const override; + QString parserId() const override; + +}; +} +#endif // ABSTRACTNODEPARSER_H diff --git a/Heart/AbstractSpace/Private/bigdatamanager.cpp b/Heart/AbstractSpace/Private/bigdataparser.cpp similarity index 58% rename from Heart/AbstractSpace/Private/bigdatamanager.cpp rename to Heart/AbstractSpace/Private/bigdataparser.cpp index 69890960..86e8505b 100644 --- a/Heart/AbstractSpace/Private/bigdatamanager.cpp +++ b/Heart/AbstractSpace/Private/bigdataparser.cpp @@ -1,31 +1,68 @@ /* - * Copyright (C) 2021-2022 QuasarApp. + * Copyright (C) 2022-2022 QuasarApp. * Distributed under the lgplv3 software license, see the accompanying * Everyone is permitted to copy and distribute verbatim copies * of this license document, but changing it is not allowed. */ -#include "bigdatamanager.h" -#include "quasarapp.h" -#include -#include -#include -#include +#include "bigdataparser.h" +#include "bigdataheader.h" +#include "bigdatapart.h" + #include +#include #include -#include +#include #define TIMEOUT_INTERVAL 30000 namespace QH { -BigDataManager::BigDataManager(AbstractNode *node) -{ - debug_assert(node, "BigDataManager requer node object"); - _node = node; +BigDataParser::BigDataParser(AbstractNode* parentNode): iParser(parentNode) { + + registerPackageType(); + registerPackageType(); + registerPackageType(); +} + +ParserResult BigDataParser::parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + AbstractNodeInfo *sender) { + + + auto result = commandHandler(this, + &BigDataParser::processRequest, + pkg, sender, pkgHeader); + if (result != QH::ParserResult::NotProcessed) { + return result; + } + + result = commandHandler(this, + &BigDataParser::newPackage, + pkg, sender, pkgHeader); + if (result != QH::ParserResult::NotProcessed) { + return result; + } + + result = commandHandler(this, + &BigDataParser::processPart, + pkg, sender, pkgHeader); + if (result != QH::ParserResult::NotProcessed) { + return result; + } + + return ParserResult::NotProcessed; +} + +int BigDataParser::version() const { + return 0; +} + +QString BigDataParser::parserId() const { + return "HeartBigDataAPI"; } -void QH::BigDataManager::insertNewBigData(const QSharedPointer &header) { +void QH::BigDataParser::insertNewBigData(const QSharedPointer &header) { if (!_pool.contains(header->packageId())) { QVector> _array; _array.resize(header->getPackagesCount()); @@ -35,8 +72,8 @@ void QH::BigDataManager::insertNewBigData(const QSharedPointerpackageId()); } -bool BigDataManager::newPackage(const QSharedPointer &header, - const AbstractNodeInfo *sender, +bool BigDataParser::newPackage(const QSharedPointer &header, + AbstractNodeInfo *sender, const Header & hdr) { if (!header->isValid()) @@ -48,11 +85,11 @@ bool BigDataManager::newPackage(const QSharedPointer &header request.setCurrentPart(0); request.setPackageId(header->packageId()); - return _node->sendData(&request, sender, &hdr); + return node()->sendData(&request, sender, &hdr); } -bool BigDataManager::processPart(const QSharedPointer &part, - const AbstractNodeInfo *sender, +bool BigDataParser::processPart(const QSharedPointer &part, + AbstractNodeInfo *sender, const Header & hdr) { if (!_pool.contains(part->packageId())) { @@ -71,7 +108,7 @@ bool BigDataManager::processPart(const QSharedPointer &part, request.setCurrentPart(part); request.setPackageId(id); - return _node->sendData(&request, sender, &hdr); + return node()->sendData(&request, sender, &hdr); }; if (part->getPakckageNumber() + 1 < localPool.chaindata.size()) { @@ -80,7 +117,7 @@ bool BigDataManager::processPart(const QSharedPointer &part, } - auto package = _node->genPackage(localPool.header->getCommand()); + auto package = node()->genPackage(localPool.header->getCommand()); if (!package) return false; @@ -95,7 +132,7 @@ bool BigDataManager::processPart(const QSharedPointer &part, package->fromBytes(packageRawData); - if (_node->parsePackage(package, hdr, sender) == ParserResult::Error) { + if (node()->parsePackage(package, hdr, sender) == ParserResult::Error) { return false; } @@ -104,8 +141,8 @@ bool BigDataManager::processPart(const QSharedPointer &part, return true; } -bool BigDataManager::processRequest(const QSharedPointer &request, - const AbstractNodeInfo *sender, +bool BigDataParser::processRequest(const QSharedPointer &request, + AbstractNodeInfo *sender, const Header &pkgHeader) { @@ -126,7 +163,7 @@ bool BigDataManager::processRequest(const QSharedPointer &r bool fLast = localPool.chaindata.size() - 1 == request->currentPart(); const auto &data = localPool.chaindata[request->currentPart()]; - if (!_node->sendData(data.data(), sender, &pkgHeader)) { + if (!node()->sendData(data.data(), sender, &pkgHeader)) { return false; } @@ -137,7 +174,7 @@ bool BigDataManager::processRequest(const QSharedPointer &r return true; } -bool BigDataManager::sendBigDataPackage(const PKG::AbstractData *data, +bool BigDataParser::sendBigDataPackage(const PKG::AbstractData *data, const AbstractNodeInfo *sender, const QH::Header *pkgHeader) { @@ -161,14 +198,14 @@ bool BigDataManager::sendBigDataPackage(const PKG::AbstractData *data, } - if (!_node->sendData(hdr.data(), sender, pkgHeader)) { + if (!node()->sendData(hdr.data(), sender, pkgHeader)) { return false; } return true; } -void BigDataManager::checkOutDatedPacakges(unsigned int currentProcessedId) { +void BigDataParser::checkOutDatedPacakges(unsigned int currentProcessedId) { int utx = time(0); if (_pool.contains(currentProcessedId)) { diff --git a/Heart/AbstractSpace/Private/bigdatamanager.h b/Heart/AbstractSpace/Private/bigdataparser.h similarity index 75% rename from Heart/AbstractSpace/Private/bigdatamanager.h rename to Heart/AbstractSpace/Private/bigdataparser.h index eba4b935..137a5a3b 100644 --- a/Heart/AbstractSpace/Private/bigdatamanager.h +++ b/Heart/AbstractSpace/Private/bigdataparser.h @@ -6,21 +6,23 @@ */ -#ifndef BIGDATAMANAGER_H -#define BIGDATAMANAGER_H +#ifndef BIGDATAPARSER_H +#define BIGDATAPARSER_H -#include -#include -#include -#include +#include namespace QH { +namespace PKG { +class BigDataHeader; +class BigDataPart; +class BigDataRequest; +} + class AbstractNode; class AbstractNodeInfo; - struct PoolData { QSharedPointer header; QVector> chaindata; @@ -28,18 +30,20 @@ struct PoolData { }; /** - * @brief The BigDataManager class is module for control od big data delovering. - * **How to is work** - * 1. All big pacakges separate to 64kb parts. - * 2. Sender send big package header. - * 3. receiver send request to next paart (0) - * 4. Sender sent reqested part to receiver - **/ -class BigDataManager + * @brief The BigDataParser class is main manager for control big data packages. + */ +class BigDataParser: public iParser { - public: - BigDataManager(AbstractNode *); + BigDataParser(AbstractNode* parentNode); + + ParserResult parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + AbstractNodeInfo *sender) override; + int version() const override; + QString parserId() const override; + +protected: /** * @brief newPackage This method process first header packge of the big data. @@ -49,7 +53,7 @@ class BigDataManager * @return true if packge processed successful else false */ bool newPackage(const QSharedPointer &header, - const AbstractNodeInfo * sender, + AbstractNodeInfo * sender, const Header & pkgHeader); /** @@ -60,7 +64,7 @@ class BigDataManager * @return true if packge processed successful else false */ bool processPart(const QSharedPointer& part, - const QH::AbstractNodeInfo *sender, + AbstractNodeInfo *sender, const QH::Header &pkgHeader); /** @@ -71,8 +75,8 @@ class BigDataManager * @return true if pacakge parsed successful else false. */ bool processRequest(const QSharedPointer& request, - const QH::AbstractNodeInfo *sender, - const QH::Header &pkgHeader); + QH::AbstractNodeInfo *sender, + const QH::Header &pkgHeader); /** * @brief sendBigDataPackage This method separate big pacakge and sent only heder ot serve. @@ -85,13 +89,14 @@ class BigDataManager const QH::AbstractNodeInfo *sender, const Header *pkgHeader); + private: void insertNewBigData(const QSharedPointer &header); void checkOutDatedPacakges(unsigned int currentProcessedId); - AbstractNode *_node = nullptr; QHash _pool; + }; } -#endif // BIGDATAMANAGER_H +#endif // BIGDATAPARSER_H diff --git a/Heart/AbstractSpace/abstractnode.cpp b/Heart/AbstractSpace/abstractnode.cpp index 1414a52b..c7b85e87 100644 --- a/Heart/AbstractSpace/abstractnode.cpp +++ b/Heart/AbstractSpace/abstractnode.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #endif @@ -39,7 +40,8 @@ #include "receivedata.h" #include "abstracttask.h" -#include +#include +#include #include namespace QH { @@ -59,8 +61,8 @@ AbstractNode::AbstractNode( QObject *ptr): // This object moving to _senderThread. _dataSender = new DataSender(_senderThread); _socketWorker = new AsyncLauncher(_senderThread); - _bigdatamanager = new BigDataManager(this); _tasksheduller = new TaskScheduler(); + _apiVersionParser = new APIVersionParser(this); qRegisterMetaType>(); #ifdef USE_HEART_SSL @@ -70,13 +72,6 @@ AbstractNode::AbstractNode( QObject *ptr): connect(_tasksheduller, &TaskScheduler::sigPushWork, this, &AbstractNode::handleBeginWork); - registerPackageType(); - registerPackageType(); - registerPackageType(); - - registerPackageType(); - registerPackageType(); - registerPackageType(); initThreadPool(); @@ -97,12 +92,17 @@ AbstractNode::~AbstractNode() { delete _senderThread; delete _socketWorker; delete _tasksheduller; + delete _apiVersionParser; } int AbstractNode::version() const { return 0; } +QString AbstractNode::parserId() const { + return ""; +} + bool AbstractNode::run(const QString &addres, unsigned short port) { if (!port) @@ -665,68 +665,13 @@ bool AbstractNode::registerSocket(QAbstractSocket *socket, const HostAddress* cl ParserResult AbstractNode::parsePackage(const QSharedPointer &pkg, const Header &pkgHeader, - const AbstractNodeInfo *sender) { - - if (!(sender)) { - QuasarAppUtils::Params::log("sender socket is not valid!", - QuasarAppUtils::Error); - return ParserResult::Error; - } - - if (!pkg->isValid()) { - QuasarAppUtils::Params::log("incomming package is not valid!", - QuasarAppUtils::Error); - changeTrust(sender->networkAddress(), CRITICAL_ERROOR); - return ParserResult::Error; - } - - incomingData(pkg.data(), sender); - - if (Ping::command() == pkg->cmd()) { - auto cmd = static_cast(pkg.data()); - if (!cmd->ansver()) { - cmd->setAnsver(true); - sendData(cmd, sender, &pkgHeader); - } - - return ParserResult::Processed; - } else if (BadRequest::command() == pkg->cmd()) { - auto cmd = static_cast(pkg.data()); - - emit requestError(cmd->errCode(), cmd->err()); - - return ParserResult::Processed; - - } else if (CloseConnection::command() == pkg->cmd()) { - - if (sender->isLocal()) { - removeNode(sender->networkAddress()); - } - return ParserResult::Processed; - } - - auto result = commandHandler(_bigdatamanager, - &BigDataManager::processRequest, - pkg, sender, pkgHeader); - if (result != QH::ParserResult::NotProcessed) { - return result; - } - - result = commandHandler(_bigdatamanager, - &BigDataManager::newPackage, - pkg, sender, pkgHeader); - if (result != QH::ParserResult::NotProcessed) { - return result; - } + AbstractNodeInfo *sender) { + return _apiVersionParser->parsePackage(pkg, pkgHeader, sender); +} - result = commandHandler(_bigdatamanager, - &BigDataManager::processPart, - pkg, sender, pkgHeader); - if (result != QH::ParserResult::NotProcessed) { - return result; - } +QSharedPointer +AbstractNode::genPackage(unsigned short cmd) const { - return ParserResult::NotProcessed; } bool AbstractNode::sendPackage(const Package &pkg, QAbstractSocket *target) const { diff --git a/Heart/AbstractSpace/abstractnode.h b/Heart/AbstractSpace/abstractnode.h index 20a10d48..706656ad 100644 --- a/Heart/AbstractSpace/abstractnode.h +++ b/Heart/AbstractSpace/abstractnode.h @@ -38,10 +38,10 @@ class DataSender; class ReceiveData; class SocketFactory; class AsyncLauncher; -class BigDataManager; class TaskScheduler; class AbstractTask; class SslSocket; +class APIVersionParser; namespace PKG { class ErrorData; @@ -111,7 +111,7 @@ class Abstract; * @see AbstractNode::registerPackageType * @see AbstractNode::parsePackage */ -class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete +class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete, private iParser { Q_OBJECT @@ -125,8 +125,6 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete AbstractNode(QObject * ptr = nullptr); ~AbstractNode() override; - int version() const override; - /** * @brief run This method implement deployment a network node (server) on selected address. * @param addres This is network address of work node or server. @@ -407,58 +405,6 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete */ virtual bool registerSocket(QAbstractSocket *socket, const HostAddress* address = nullptr); - /** - * @brief parsePackage This is main method of all childs classes of an AbstractNode class. - * This method work on own thread. - * If you ovveride this method you need to create this than an example: - * \code{cpp} - ParserResult DataBaseNode::parsePackage(PKG::AbstractData *pkg, - const Header& pkgHeader, - const AbstractNodeInfo* sender) { - auto parentResult = AbstractNode::parsePackage(pkg, sender); - if (parentResult != ParserResult::NotProcessed) { - return parentResult; - } - - // you can use parsing without the commandHandler method - if (MyCommand::command() == pkg->cmd()) { - - BaseId requesterId = getSender(sender, &obj); - - ... - - if (FailCondition) { - return ParserResult::Error; - } - - ... - - return ParserResult::Processed; - - } - - // Or with the commandHandler method - - auto result = commandHandler(this, &MyClass::processMyPackage, pkg, sender, pkgHeader); - if (result != QH::ParserResult::NotProcessed) { - return result; - } - - return ParserResult::NotProcessed; - } - * \endcode - * @param pkg This is package with incomming data. - * @param sender This is sender this pacakge. - * @param pkgHeader This is header of the incoming packet is used to create a response. - * @return item of ParserResult. For more information see The ParserResult enum. - * @see AbstractNode::commandHandler - * @see AbstractNode::sendData - * @see AbstractNode::badRequest - - */ - ParserResult parsePackage(const QSharedPointer &pkg, - const Header& pkgHeader, const AbstractNodeInfo* sender) override; - /** * @brief sendPackage This method prepare and send to target address a package. * @param pkg This is sendet pakcage to target node. @@ -705,6 +651,17 @@ private slots: private: + // iParser interface + ParserResult parsePackage(const QSharedPointer &pkg, + const Header &pkgHeader, + AbstractNodeInfo *sender) override; + + QSharedPointer + genPackage(unsigned short cmd) const override; + + int version() const override; + QString parserId() const override; + /** @note just disaable listen method in the node objects. */ @@ -752,8 +709,8 @@ private slots: DataSender * _dataSender = nullptr; AsyncLauncher * _socketWorker = nullptr; QThread *_senderThread = nullptr; - BigDataManager *_bigdatamanager = nullptr; TaskScheduler *_tasksheduller = nullptr; + APIVersionParser *_apiVersionParser = nullptr; QHash>> _connectActions; @@ -768,7 +725,8 @@ private slots: friend class WebSocketController; friend class SocketFactory; - friend class BigDataManager; + friend class BigDataParser; + friend class AbstractNodeParser; }; diff --git a/Heart/AbstractSpace/apiversionparser.cpp b/Heart/AbstractSpace/apiversionparser.cpp index 0d0a04e7..1f9db3c5 100644 --- a/Heart/AbstractSpace/apiversionparser.cpp +++ b/Heart/AbstractSpace/apiversionparser.cpp @@ -12,10 +12,11 @@ #include #include #include +#include namespace QH { -APIVersionParser::APIVersionParser() { +APIVersionParser::APIVersionParser(AbstractNode *node): iParser(node) { } @@ -72,6 +73,29 @@ QString APIVersionParser::parserId() const { return "APIVersionParser"; } +I shold be create method that can create package by commnad with needed version. +QSharedPointer APIVersionParser::genPackage(unsigned short cmd) const { + auto distVersion = sender->version(); + const auto parsers = selectParser(distVersion); + + if (parsers.isEmpty()) { + return nullptr; + } + + for (const auto& parser: parsers) { + if (!parser) { + QuasarAppUtils::Params::log(QString("Internal Error with selection parasers."), + QuasarAppUtils::Error); + continue; + } + + auto perserResult = parser->parsePackage(pkg, pkgHeader, sender); + if (perserResult != QH::ParserResult::NotProcessed) { + return perserResult; + } + } +} + QSharedPointer APIVersionParser::getSelectedApiParser(const QString &apiKey, AbstractNodeInfo *node) const { @@ -145,7 +169,7 @@ bool APIVersionParser::processAppVersion(const QSharedPointer &messa } VersionIsReceived result; - return node().send(&result, sender); + return node()->sendData(&result, sender); } bool APIVersionParser::versionDeliveredSuccessful(const QSharedPointer &, diff --git a/Heart/AbstractSpace/apiversionparser.h b/Heart/AbstractSpace/apiversionparser.h index 538d6332..00d94219 100644 --- a/Heart/AbstractSpace/apiversionparser.h +++ b/Heart/AbstractSpace/apiversionparser.h @@ -25,13 +25,14 @@ class APIVersionParser: public QObject, public iParser { Q_OBJECT public: - APIVersionParser(); + APIVersionParser(AbstractNode* node); ParserResult parsePackage(const QSharedPointer &pkg, const Header &pkgHeader, AbstractNodeInfo *sender) override; int version() const override; QString parserId() const override; + QSharedPointer genPackage(unsigned short cmd) const override; /** * @brief getSelectedApiParser This method return apiParser for selected node @@ -97,6 +98,7 @@ class APIVersionParser: public QObject, public iParser const QH::Header &); QHash>> _apiParsers; + }; } #endif // APIVERSIONPARSER_H diff --git a/Heart/AbstractSpace/iparser.cpp b/Heart/AbstractSpace/iparser.cpp index 329bc41c..574a102a 100644 --- a/Heart/AbstractSpace/iparser.cpp +++ b/Heart/AbstractSpace/iparser.cpp @@ -1,14 +1,22 @@ +/* + * Copyright (C) 2022-2022 QuasarApp. + * Distributed under the lgplv3 software license, see the accompanying + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. +*/ + + #include "iparser.h" #include - +#include namespace QH { -iParser::iParser() { - +iParser::iParser(AbstractNode *parentNode) { + _node = parentNode; + debug_assert(_node, "All parsers shold be initialized with parent node"); } - QString iParser::pareseResultToString(const ParserResult &parseResult) const { switch (parseResult) { @@ -33,4 +41,9 @@ QSharedPointer iParser::genPackage(unsigned short cmd) const bool iParser::checkCommand(unsigned short cmd) const { return _registeredTypes.contains(cmd); } + +AbstractNode *iParser::node() const { + return _node; +} + } diff --git a/Heart/AbstractSpace/iparser.h b/Heart/AbstractSpace/iparser.h index f34403c8..fe594d3d 100644 --- a/Heart/AbstractSpace/iparser.h +++ b/Heart/AbstractSpace/iparser.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2022-2022 QuasarApp. + * Distributed under the lgplv3 software license, see the accompanying + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. +*/ + + #ifndef IPARSER_H #define IPARSER_H @@ -7,6 +15,7 @@ namespace QH { class AbstractNodeInfo; +class AbstractNode; namespace PKG { class AbstractData; @@ -37,8 +46,8 @@ enum class ParserResult { class HEARTSHARED_EXPORT iParser { public: - iParser(); - + iParser(AbstractNode* parentNode); + virtual ~iParser() = default; template /** * @brief registerPackageType This method register package type T. @@ -179,7 +188,7 @@ class HEARTSHARED_EXPORT iParser * @see AbstractNode::registerPackageType * @see Header::command */ - QSharedPointer genPackage(unsigned short cmd) const ; + virtual QSharedPointer genPackage(unsigned short cmd) const ; /** * @brief checkCommand This method check command are if registered type or not. @@ -194,9 +203,12 @@ class HEARTSHARED_EXPORT iParser */ virtual QString parserId() const = 0; +protected: + AbstractNode *node() const; + private: QHash> _registeredTypes; - + AbstractNode *_node; }; From 7d5aa6070e17d9e6bc19d2fce5650a6cc2c12841 Mon Sep 17 00:00:00 2001 From: EndrII Date: Fri, 25 Nov 2022 00:07:51 +0300 Subject: [PATCH 04/19] remove rudiment code --- Heart/AbstractSpace/Private/bigdataparser.cpp | 16 + Heart/AbstractSpace/Private/bigdataparser.h | 18 +- Heart/AbstractSpace/Private/versionparser.cpp | 62 -- Heart/AbstractSpace/Private/versionparser.h | 34 - Heart/AbstractSpace/abstractnode.cpp | 80 ++- Heart/AbstractSpace/abstractnode.h | 7 +- Heart/AbstractSpace/abstractnodeinfo.cpp | 10 + Heart/AbstractSpace/abstractnodeinfo.h | 22 +- Heart/AbstractSpace/apiversionparser.cpp | 59 +- Heart/AbstractSpace/apiversionparser.h | 24 +- Heart/AbstractSpace/iparser.h | 2 +- .../AbstractSpace/packages/bigdatawraper.cpp | 37 ++ Heart/AbstractSpace/packages/bigdatawraper.h | 52 ++ .../DataBaseSpace/Private/singleserverdb.cpp | 18 - Heart/DataBaseSpace/Private/singleserverdb.h | 26 - Heart/DataBaseSpace/basedefines.h | 27 - Heart/DataBaseSpace/basenodeinfo.cpp | 51 -- Heart/DataBaseSpace/basenodeinfo.h | 75 --- Heart/DataBaseSpace/database.cpp | 276 +------- Heart/DataBaseSpace/database.h | 159 +---- Heart/DataBaseSpace/databasenode.cpp | 414 ------------ Heart/DataBaseSpace/databasenode.h | 332 ---------- Heart/DataBaseSpace/dbaddress.h | 1 - Heart/DataBaseSpace/dbcachekey.cpp | 30 - Heart/DataBaseSpace/dbcachekey.h | 95 --- Heart/DataBaseSpace/dberrorcodes.h | 63 -- .../{isqldbcache.cpp => isqldb.cpp} | 56 +- .../DataBaseSpace/{isqldbcache.h => isqldb.h} | 18 +- .../packages/abstractnetworkmember.cpp | 128 ---- .../packages/abstractnetworkmember.h | 100 --- Heart/DataBaseSpace/packages/authrequest.cpp | 46 -- Heart/DataBaseSpace/packages/authrequest.h | 62 -- Heart/DataBaseSpace/packages/dbobject.cpp | 9 - Heart/DataBaseSpace/packages/dbobject.h | 13 +- .../packages/defaultpermision.cpp | 56 -- .../DataBaseSpace/packages/defaultpermision.h | 42 -- .../packages/isubscribabledata.cpp | 16 - .../packages/isubscribabledata.h | 37 -- .../packages/memberpermisionobject.cpp | 138 ---- .../packages/memberpermisionobject.h | 86 --- .../DataBaseSpace/packages/networkmember.cpp | 26 - Heart/DataBaseSpace/packages/networkmember.h | 35 - Heart/DataBaseSpace/packages/usermember.cpp | 82 --- Heart/DataBaseSpace/packages/usermember.h | 51 -- Heart/DataBaseSpace/packages/websocket.cpp | 61 -- Heart/DataBaseSpace/packages/websocket.h | 80 --- .../packages/websocketsubscriptions.cpp | 48 -- .../packages/websocketsubscriptions.h | 54 -- Heart/DataBaseSpace/permisiondata.cpp | 91 --- Heart/DataBaseSpace/permisiondata.h | 79 --- Heart/DataBaseSpace/permission.h | 29 - Heart/DataBaseSpace/singlebase.cpp | 20 - Heart/DataBaseSpace/singlebase.h | 37 -- Heart/DataBaseSpace/singleclient.cpp | 521 --------------- Heart/DataBaseSpace/singleclient.h | 409 ------------ Heart/DataBaseSpace/singleserver.cpp | 298 --------- Heart/DataBaseSpace/singleserver.h | 124 ---- Heart/DataBaseSpace/sqldb.cpp | 2 +- Heart/DataBaseSpace/sqldb.h | 4 +- Heart/DataBaseSpace/sqldbcache.cpp | 112 ---- Heart/DataBaseSpace/sqldbcache.h | 55 -- Heart/DataBaseSpace/websocketcontroller.cpp | 112 ---- Heart/DataBaseSpace/websocketcontroller.h | 90 --- Heart/NetworkSpace/Res/NetworkDB.sql | 17 - Heart/NetworkSpace/consensus.cpp | 19 - Heart/NetworkSpace/consensus.h | 34 - Heart/NetworkSpace/networkerrorcodes.h | 21 - Heart/NetworkSpace/networknode.cpp | 610 ------------------ Heart/NetworkSpace/networknode.h | 300 --------- Heart/NetworkSpace/networknodeinfo.cpp | 47 -- Heart/NetworkSpace/networknodeinfo.h | 79 --- Heart/NetworkSpace/nodeid.cpp | 94 --- Heart/NetworkSpace/nodeid.h | 122 ---- .../NetworkSpace/packages/badnoderequest.cpp | 57 -- Heart/NetworkSpace/packages/badnoderequest.h | 39 -- Heart/NetworkSpace/packages/knowaddresses.cpp | 65 -- Heart/NetworkSpace/packages/knowaddresses.h | 46 -- Heart/NetworkSpace/packages/longping.cpp | 51 -- Heart/NetworkSpace/packages/longping.h | 39 -- .../NetworkSpace/packages/networkrequest.cpp | 98 --- Heart/NetworkSpace/packages/networkrequest.h | 108 ---- Heart/NetworkSpace/packages/nodeobject.cpp | 74 --- Heart/NetworkSpace/packages/nodeobject.h | 37 -- Heart/NetworkSpace/packages/transportdata.cpp | 159 ----- Heart/NetworkSpace/packages/transportdata.h | 97 --- Heart/NetworkSpace/qsecretrsa2048.cpp | 81 --- Heart/NetworkSpace/qsecretrsa2048.h | 48 -- Heart/NetworkSpace/router.cpp | 64 -- Heart/NetworkSpace/router.h | 72 --- Heart/NetworkSpace/senderdata.cpp | 22 - Heart/NetworkSpace/senderdata.h | 29 - Heart/NetworkSpace/sign.cpp | 24 - Heart/NetworkSpace/sign.h | 41 -- HeartTests/DataBaseSpace/databasetestnode.h | 4 +- .../DataBaseSpace/upgradedatabasetest.cpp | 2 +- 95 files changed, 316 insertions(+), 7501 deletions(-) delete mode 100644 Heart/AbstractSpace/Private/versionparser.cpp delete mode 100644 Heart/AbstractSpace/Private/versionparser.h create mode 100644 Heart/AbstractSpace/packages/bigdatawraper.cpp create mode 100644 Heart/AbstractSpace/packages/bigdatawraper.h delete mode 100644 Heart/DataBaseSpace/Private/singleserverdb.cpp delete mode 100644 Heart/DataBaseSpace/Private/singleserverdb.h delete mode 100644 Heart/DataBaseSpace/basedefines.h delete mode 100644 Heart/DataBaseSpace/basenodeinfo.cpp delete mode 100644 Heart/DataBaseSpace/basenodeinfo.h delete mode 100644 Heart/DataBaseSpace/databasenode.cpp delete mode 100644 Heart/DataBaseSpace/databasenode.h delete mode 100644 Heart/DataBaseSpace/dbcachekey.cpp delete mode 100644 Heart/DataBaseSpace/dbcachekey.h delete mode 100644 Heart/DataBaseSpace/dberrorcodes.h rename Heart/DataBaseSpace/{isqldbcache.cpp => isqldb.cpp} (82%) rename Heart/DataBaseSpace/{isqldbcache.h => isqldb.h} (95%) delete mode 100644 Heart/DataBaseSpace/packages/abstractnetworkmember.cpp delete mode 100644 Heart/DataBaseSpace/packages/abstractnetworkmember.h delete mode 100644 Heart/DataBaseSpace/packages/authrequest.cpp delete mode 100644 Heart/DataBaseSpace/packages/authrequest.h delete mode 100644 Heart/DataBaseSpace/packages/defaultpermision.cpp delete mode 100644 Heart/DataBaseSpace/packages/defaultpermision.h delete mode 100644 Heart/DataBaseSpace/packages/isubscribabledata.cpp delete mode 100644 Heart/DataBaseSpace/packages/isubscribabledata.h delete mode 100644 Heart/DataBaseSpace/packages/memberpermisionobject.cpp delete mode 100644 Heart/DataBaseSpace/packages/memberpermisionobject.h delete mode 100644 Heart/DataBaseSpace/packages/networkmember.cpp delete mode 100644 Heart/DataBaseSpace/packages/networkmember.h delete mode 100644 Heart/DataBaseSpace/packages/usermember.cpp delete mode 100644 Heart/DataBaseSpace/packages/usermember.h delete mode 100644 Heart/DataBaseSpace/packages/websocket.cpp delete mode 100644 Heart/DataBaseSpace/packages/websocket.h delete mode 100644 Heart/DataBaseSpace/packages/websocketsubscriptions.cpp delete mode 100644 Heart/DataBaseSpace/packages/websocketsubscriptions.h delete mode 100644 Heart/DataBaseSpace/permisiondata.cpp delete mode 100644 Heart/DataBaseSpace/permisiondata.h delete mode 100644 Heart/DataBaseSpace/permission.h delete mode 100644 Heart/DataBaseSpace/singlebase.cpp delete mode 100644 Heart/DataBaseSpace/singlebase.h delete mode 100644 Heart/DataBaseSpace/singleclient.cpp delete mode 100644 Heart/DataBaseSpace/singleclient.h delete mode 100644 Heart/DataBaseSpace/singleserver.cpp delete mode 100644 Heart/DataBaseSpace/singleserver.h delete mode 100644 Heart/DataBaseSpace/sqldbcache.cpp delete mode 100644 Heart/DataBaseSpace/sqldbcache.h delete mode 100644 Heart/DataBaseSpace/websocketcontroller.cpp delete mode 100644 Heart/DataBaseSpace/websocketcontroller.h delete mode 100644 Heart/NetworkSpace/Res/NetworkDB.sql delete mode 100644 Heart/NetworkSpace/consensus.cpp delete mode 100644 Heart/NetworkSpace/consensus.h delete mode 100644 Heart/NetworkSpace/networkerrorcodes.h delete mode 100644 Heart/NetworkSpace/networknode.cpp delete mode 100644 Heart/NetworkSpace/networknode.h delete mode 100644 Heart/NetworkSpace/networknodeinfo.cpp delete mode 100644 Heart/NetworkSpace/networknodeinfo.h delete mode 100644 Heart/NetworkSpace/nodeid.cpp delete mode 100644 Heart/NetworkSpace/nodeid.h delete mode 100644 Heart/NetworkSpace/packages/badnoderequest.cpp delete mode 100644 Heart/NetworkSpace/packages/badnoderequest.h delete mode 100644 Heart/NetworkSpace/packages/knowaddresses.cpp delete mode 100644 Heart/NetworkSpace/packages/knowaddresses.h delete mode 100644 Heart/NetworkSpace/packages/longping.cpp delete mode 100644 Heart/NetworkSpace/packages/longping.h delete mode 100644 Heart/NetworkSpace/packages/networkrequest.cpp delete mode 100644 Heart/NetworkSpace/packages/networkrequest.h delete mode 100644 Heart/NetworkSpace/packages/nodeobject.cpp delete mode 100644 Heart/NetworkSpace/packages/nodeobject.h delete mode 100644 Heart/NetworkSpace/packages/transportdata.cpp delete mode 100644 Heart/NetworkSpace/packages/transportdata.h delete mode 100644 Heart/NetworkSpace/qsecretrsa2048.cpp delete mode 100644 Heart/NetworkSpace/qsecretrsa2048.h delete mode 100644 Heart/NetworkSpace/router.cpp delete mode 100644 Heart/NetworkSpace/router.h delete mode 100644 Heart/NetworkSpace/senderdata.cpp delete mode 100644 Heart/NetworkSpace/senderdata.h delete mode 100644 Heart/NetworkSpace/sign.cpp delete mode 100644 Heart/NetworkSpace/sign.h diff --git a/Heart/AbstractSpace/Private/bigdataparser.cpp b/Heart/AbstractSpace/Private/bigdataparser.cpp index 86e8505b..ef3d8c5d 100644 --- a/Heart/AbstractSpace/Private/bigdataparser.cpp +++ b/Heart/AbstractSpace/Private/bigdataparser.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #define TIMEOUT_INTERVAL 30000 @@ -20,9 +21,11 @@ namespace QH { BigDataParser::BigDataParser(AbstractNode* parentNode): iParser(parentNode) { + registerPackageType(); registerPackageType(); registerPackageType(); registerPackageType(); + } ParserResult BigDataParser::parsePackage(const QSharedPointer &pkg, @@ -37,6 +40,13 @@ ParserResult BigDataParser::parsePackage(const QSharedPointer return result; } + result = commandHandler(this, + &BigDataParser::processBigDataWraper, + pkg, sender, pkgHeader); + if (result != QH::ParserResult::NotProcessed) { + return result; + } + result = commandHandler(this, &BigDataParser::newPackage, pkg, sender, pkgHeader); @@ -174,6 +184,12 @@ bool BigDataParser::processRequest(const QSharedPointer &re return true; } +bool BigDataParser::processBigDataWraper(const QSharedPointer &request, + AbstractNodeInfo *sender, + const Header &pkgHeader) { + return sendBigDataPackage(request->data(), sender, &pkgHeader); +} + bool BigDataParser::sendBigDataPackage(const PKG::AbstractData *data, const AbstractNodeInfo *sender, const QH::Header *pkgHeader) { diff --git a/Heart/AbstractSpace/Private/bigdataparser.h b/Heart/AbstractSpace/Private/bigdataparser.h index 137a5a3b..3956249b 100644 --- a/Heart/AbstractSpace/Private/bigdataparser.h +++ b/Heart/AbstractSpace/Private/bigdataparser.h @@ -18,6 +18,7 @@ namespace PKG { class BigDataHeader; class BigDataPart; class BigDataRequest; +class BigDataWraper; } class AbstractNode; @@ -85,13 +86,24 @@ class BigDataParser: public iParser * @param pkgHeader requested header. * @return true if package sent successful */ - bool sendBigDataPackage(const PKG::AbstractData *data, - const QH::AbstractNodeInfo *sender, - const Header *pkgHeader); + bool processBigDataWraper(const QSharedPointer &request, + AbstractNodeInfo *sender, + const Header &pkgHeader); private: + /** + * @brief sendBigDataPackage This method separate big pacakge and sent only heder ot serve. + * @param data This is package that will be sent to remote node. + * @param sender This is request object. + * @param pkgHeader requested header. + * @return true if package sent successful + */ + bool sendBigDataPackage(const PKG::AbstractData *data, + const QH::AbstractNodeInfo *sender, + const Header *pkgHeader); + void insertNewBigData(const QSharedPointer &header); void checkOutDatedPacakges(unsigned int currentProcessedId); diff --git a/Heart/AbstractSpace/Private/versionparser.cpp b/Heart/AbstractSpace/Private/versionparser.cpp deleted file mode 100644 index b7a91f2d..00000000 --- a/Heart/AbstractSpace/Private/versionparser.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "versionparser.h" -namespace QH { - -VersionParser::VersionParser() { - -} - -ParserResult VersionParser::parsePackage(const QSharedPointer &pkg, - const Header &pkgHeader, - const AbstractNodeInfo *sender) { - -// auto parentResult = AbstractNode::parsePackage(pkg, pkgHeader, sender); -// if (parentResult != QH::ParserResult::NotProcessed) { -// return parentResult; -// } - - // here node must be receive version of connected application. - // if not use the default version (0)ApplicationVersion - parentResult = commandHandler(this, &BaseNode::processAppVersion, - pkg, sender, pkgHeader); - if (parentResult != QH::ParserResult::NotProcessed) { - return parentResult; - } - - // here node must be receive responce that version is delivered. - // when node receive this message then node status are confirmed - parentResult = commandHandler(this, &BaseNode::versionDeliveredSuccessful, - pkg, sender, pkgHeader); - if (parentResult != QH::ParserResult::NotProcessed) { - return parentResult; - } - - auto distVersion = static_cast(sender)->version(); - auto parser = selectParser(distVersion); - - if (!parser) { - QuasarAppUtils::Params::log(QString("Can't found requeried parser for versions: %0-%1"). - arg(distVersion.minimum()). - arg(distVersion.maximum()), - QuasarAppUtils::Warning); - - return QH::ParserResult::NotProcessed; - } - - return parser->parsePackage(pkg, pkgHeader, sender); -} - -int VersionParser::version() const { - return 0; -} - -QString VersionParser::parserId() const { - return "QHNodeVersionParser"; -} -} diff --git a/Heart/AbstractSpace/Private/versionparser.h b/Heart/AbstractSpace/Private/versionparser.h deleted file mode 100644 index f5a0caaa..00000000 --- a/Heart/AbstractSpace/Private/versionparser.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef VERSIONPARSER_H -#define VERSIONPARSER_H - -#include - -namespace QH { - -/** - * @brief The VersionParser class This is base parser. This parser have only one version is 0 because node du not has any version information in this step. - */ -class VersionParser: public QH::iParser -{ -public: - VersionParser(); - - // iParser interface -public: - ParserResult parsePackage(const QSharedPointer &pkg, - const Header &pkgHeader, - const AbstractNodeInfo *sender) override; - int version() const override; - - QString parserId() const override; -}; -} -#endif // VERSIONPARSER_H diff --git a/Heart/AbstractSpace/abstractnode.cpp b/Heart/AbstractSpace/abstractnode.cpp index c7b85e87..57d280ce 100644 --- a/Heart/AbstractSpace/abstractnode.cpp +++ b/Heart/AbstractSpace/abstractnode.cpp @@ -43,13 +43,18 @@ #include #include #include +#include +#include +#include +#include namespace QH { using namespace PKG; AbstractNode::AbstractNode( QObject *ptr): - QTcpServer(ptr) { + QTcpServer(ptr), + iParser(this) { initThreadId(); @@ -64,6 +69,9 @@ AbstractNode::AbstractNode( QObject *ptr): _tasksheduller = new TaskScheduler(); _apiVersionParser = new APIVersionParser(this); + _apiVersionParser->addApiParser(); + _apiVersionParser->addApiParser(); + qRegisterMetaType>(); #ifdef USE_HEART_SSL qRegisterMetaType>(); @@ -241,7 +249,7 @@ bool AbstractNode::addNode(const QString &domain, unsigned short port, if (info.error() != QHostInfo::NoError) { QuasarAppUtils::Params::log("The domain name :" + domain + - " has error: " + info.errorString(), + " has error: " + info.errorString(), QuasarAppUtils::Error); addNodeFailed(AddNodeError::HostNotFound); return; @@ -251,7 +259,7 @@ bool AbstractNode::addNode(const QString &domain, unsigned short port, if (addresses.size() > 1) { QuasarAppUtils::Params::log("The domain name :" + domain + - " has more 1 ip addresses.", + " has more 1 ip addresses.", QuasarAppUtils::Warning); } @@ -316,29 +324,29 @@ bool AbstractNode::generateRSAforSSL(EVP_PKEY *pkey) const { return false; } -//#if OPENSSL_VERSION_MAJOR >= 3 + //#if OPENSSL_VERSION_MAJOR >= 3 -// EVP_PKEY_CTX *pctx = -// EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL); + // EVP_PKEY_CTX *pctx = + // EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL); -// unsigned int primes = 3; -// unsigned int bits = 4096; -// OSSL_PARAM params[3]; + // unsigned int primes = 3; + // unsigned int bits = 4096; + // OSSL_PARAM params[3]; -// pkey = EVP_RSA_gen(4096); + // pkey = EVP_RSA_gen(4096); -// EVP_PKEY_keygen_init(pctx); + // EVP_PKEY_keygen_init(pctx); -// params[0] = OSSL_PARAM_construct_uint("bits", &bits); -// params[1] = OSSL_PARAM_construct_uint("primes", &primes); -// params[2] = OSSL_PARAM_construct_end(); -// EVP_PKEY_CTX_set_params(pctx, params); + // params[0] = OSSL_PARAM_construct_uint("bits", &bits); + // params[1] = OSSL_PARAM_construct_uint("primes", &primes); + // params[2] = OSSL_PARAM_construct_end(); + // EVP_PKEY_CTX_set_params(pctx, params); -// EVP_PKEY_generate(pctx, &pkey); -// EVP_PKEY_CTX_free(pctx); + // EVP_PKEY_generate(pctx, &pkey); + // EVP_PKEY_CTX_free(pctx); -//#else + //#else BIGNUM * bn = BN_new(); int rc = BN_set_word(bn, RSA_F4); @@ -357,7 +365,7 @@ bool AbstractNode::generateRSAforSSL(EVP_PKEY *pkey) const { q_check_ptr(rsa); if (EVP_PKEY_assign_RSA(pkey, rsa) <= 0) return false; -//#endif + //#endif return true; } @@ -531,7 +539,7 @@ bool AbstractNode::useSelfSignedSslConfiguration(const SslSrtData &crtData) { _ignoreSslErrors.push_back(QSslError{QSslError::SelfSignedCertificate}); if(!_ignoreSslErrors.contains(QSslError{QSslError::SelfSignedCertificateInChain})) - _ignoreSslErrors.push_back(QSslError{QSslError::SelfSignedCertificateInChain}); + _ignoreSslErrors.push_back(QSslError{QSslError::SelfSignedCertificateInChain}); return !_ssl.isNull(); } @@ -669,9 +677,9 @@ ParserResult AbstractNode::parsePackage(const QSharedPointer &pkg, return _apiVersionParser->parsePackage(pkg, pkgHeader, sender); } -QSharedPointer -AbstractNode::genPackage(unsigned short cmd) const { - +QSharedPointer AbstractNode::genPackage(unsigned short ) const { + debug_assert(false, "the AbstractNode::genPackage is disabled. use the searchPackage"); + return nullptr; } bool AbstractNode::sendPackage(const Package &pkg, QAbstractSocket *target) const { @@ -715,7 +723,7 @@ unsigned int AbstractNode::sendData(const PKG::AbstractData *resp, Package pkg; bool convert = false; - if (req) { + if (req && req->isValid()) { convert = resp->toPackage(pkg, req->hash); } else { convert = resp->toPackage(pkg); @@ -726,9 +734,9 @@ unsigned int AbstractNode::sendData(const PKG::AbstractData *resp, if (static_cast(pkg.data.size()) > Package::maximumSize()) { // big data - if (!_bigdatamanager->sendBigDataPackage(resp, - node, - req)) { + auto wrap = QSharedPointer::create(); + wrap->setData(resp); + if ( parsePackage(wrap, {}, getInfoPtr(node->networkAddress())) != ParserResult::Processed) { return 0; } @@ -759,7 +767,7 @@ void AbstractNode::badRequest(const HostAddress &address, const Header &req, QuasarAppUtils::Error); QuasarAppUtils::Params::log("SECURITY LOG: Force block the " + address.toString() + - " because trust defined", + " because trust defined", QuasarAppUtils::Error); ban(address); @@ -773,7 +781,7 @@ void AbstractNode::badRequest(const HostAddress &address, const Header &req, } QuasarAppUtils::Params::log("Bad request sendet to adderess: " + - address.toString(), + address.toString(), QuasarAppUtils::Info); } @@ -1066,9 +1074,11 @@ bool AbstractNode::listen(const HostAddress &address) { return QTcpServer::listen(address, address.port()); } -QSharedPointer AbstractNode::prepareData(const Package &pkg) const { +QSharedPointer +AbstractNode::prepareData(const Package &pkg, + AbstractNodeInfo *sender) const { - auto value = genPackage (pkg.hdr.command); + auto value = _apiVersionParser->searchPackage(pkg.hdr.command, sender); if (!value) { QuasarAppUtils::Params::log("You try parse not registered package type." " Plese use the registerPackageType method befor parsing." @@ -1149,7 +1159,7 @@ void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender, auto executeObject = [pkg, sender, id, this]() { - auto data = prepareData(pkg); + auto data = prepareData(pkg, sender); if (!data) return false; @@ -1158,7 +1168,7 @@ void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender, if (parseResult != ParserResult::Processed) { auto message = QString("Package not parsed! %0 \nresult: %1. \n%2"). - arg(pkg.toString(), pareseResultToString(parseResult), data->toString()); + arg(pkg.toString(), pareseResultToString(parseResult), data->toString()); QuasarAppUtils::Params::log(message, QuasarAppUtils::Warning); @@ -1277,8 +1287,8 @@ void AbstractNode::nodeErrorOccured(AbstractNodeInfo *nodeInfo, QString message("Network error occured on the %0 node. Message: %1"); QuasarAppUtils::Params::log( - message.arg(nodeInfo->networkAddress().toString(), errorString), - QuasarAppUtils::Error); + message.arg(nodeInfo->networkAddress().toString(), errorString), + QuasarAppUtils::Error); auto &actions = _connectActions[NodeCoonectionStatus::Connected]; actions.remove(nodeInfo->networkAddress()); diff --git a/Heart/AbstractSpace/abstractnode.h b/Heart/AbstractSpace/abstractnode.h index 706656ad..cbc8606f 100644 --- a/Heart/AbstractSpace/abstractnode.h +++ b/Heart/AbstractSpace/abstractnode.h @@ -28,8 +28,6 @@ #include "workstate.h" #include "package.h" #include "heart_global.h" -#include "packagemanager.h" -#include "abstracterrorcodes.h" #include namespace QH { @@ -544,10 +542,11 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete, pr /** * @brief prepareData This is private method for preparing package from the byteArray. * @param pkg This is a raw package value. + * @param sender This is sender of the @a pkg. * @return pointer into prepared data. * @warning The return value do not clear automatically. */ - QSharedPointer prepareData(const Package& pkg) const; + QSharedPointer prepareData(const Package& pkg, AbstractNodeInfo *sender) const; /** * @brief connectionsList This method return list of all node connections @@ -657,7 +656,7 @@ private slots: AbstractNodeInfo *sender) override; QSharedPointer - genPackage(unsigned short cmd) const override; + genPackage(unsigned short cmd) const override final; int version() const override; QString parserId() const override; diff --git a/Heart/AbstractSpace/abstractnodeinfo.cpp b/Heart/AbstractSpace/abstractnodeinfo.cpp index b5d2cc6d..68094d65 100644 --- a/Heart/AbstractSpace/abstractnodeinfo.cpp +++ b/Heart/AbstractSpace/abstractnodeinfo.cpp @@ -220,9 +220,19 @@ void AbstractNodeInfo::reset() { setTrust(static_cast(TrustNode::Default)); setStatus(NodeCoonectionStatus::NotConnected); setIsLocal(false); + _parsersMap.clear(); } +QSharedPointer AbstractNodeInfo::getParser(unsigned short cmd) { + return _parsersMap.value(cmd, nullptr); +} + +void QH::AbstractNodeInfo::addParser(unsigned short cmd, + QSharedPointer parser) { + _parsersMap[cmd] = parser; +} + uint qHash(NodeCoonectionStatus status) { return static_cast(status); } diff --git a/Heart/AbstractSpace/abstractnodeinfo.h b/Heart/AbstractSpace/abstractnodeinfo.h index 8194c5a1..a1a43762 100644 --- a/Heart/AbstractSpace/abstractnodeinfo.h +++ b/Heart/AbstractSpace/abstractnodeinfo.h @@ -18,6 +18,8 @@ class QHostInfo; namespace QH { +class iParser; + /** * @brief The DistVersion class This is infirmation of supported versions of the distanation api. */ @@ -33,7 +35,7 @@ struct DistVersion { /** * @brief VersionData This is array of all avalable apis and supported its versions. */ -typedef QHash VersionData; +typedef QHash VersionData; /** * @brief The TrustNode enum contains cases for trust of the client or nodes. @@ -296,6 +298,22 @@ public slots: */ void statusChaned(QH::AbstractNodeInfo* thisNode, QH::NodeCoonectionStatus status); + /** + * @brief getParser This method return parser of choosed command. + * @param cmd This is command that need to parse. + * @return parser of the @a cmd comand. + */ + QSharedPointer getParser(unsigned short cmd); + + /** + * @brief addParser This method add to cache new parser for command . + * @param cmd + * @param parser + * @note All parsers will be removed after reconnect of this node. + */ + void addParser(unsigned short cmd, QSharedPointer parser); + + protected: /** @@ -316,6 +334,8 @@ public slots: NodeCoonectionStatus _status = NodeCoonectionStatus::NotConnected; bool _isLocal = false; + QHash> _parsersMap; + VersionData _version; bool _fVersionReceived = false; bool _fVersionDelivered = false; diff --git a/Heart/AbstractSpace/apiversionparser.cpp b/Heart/AbstractSpace/apiversionparser.cpp index 1f9db3c5..e7ba21eb 100644 --- a/Heart/AbstractSpace/apiversionparser.cpp +++ b/Heart/AbstractSpace/apiversionparser.cpp @@ -41,25 +41,17 @@ ParserResult APIVersionParser::parsePackage(const QSharedPointerversion(); - const auto parsers = selectParser(distVersion); + const auto parser = selectParser(pkg->cmd(), sender); - if (parsers.isEmpty()) { + if (!parser) { QuasarAppUtils::Params::log(QString("Can't found requeried parser for versions"), QuasarAppUtils::Warning); return ParserResult::NotProcessed; } - for (const auto& parser: parsers) { - if (!parser) { - QuasarAppUtils::Params::log(QString("Internal Error with selection parasers."), - QuasarAppUtils::Error); - continue; - } - - auto perserResult = parser->parsePackage(pkg, pkgHeader, sender); - if (perserResult != QH::ParserResult::NotProcessed) { - return perserResult; - } + auto perserResult = parser->parsePackage(pkg, pkgHeader, sender); + if (perserResult != QH::ParserResult::NotProcessed) { + return perserResult; } return ParserResult::NotProcessed; @@ -73,8 +65,12 @@ QString APIVersionParser::parserId() const { return "APIVersionParser"; } -I shold be create method that can create package by commnad with needed version. -QSharedPointer APIVersionParser::genPackage(unsigned short cmd) const { +QSharedPointer +APIVersionParser::searchPackage(unsigned short cmd, + AbstractNodeInfo *sender) const { + if (!sender) + return nullptr; + auto distVersion = sender->version(); const auto parsers = selectParser(distVersion); @@ -89,11 +85,11 @@ QSharedPointer APIVersionParser::genPackage(unsigned short cm continue; } - auto perserResult = parser->parsePackage(pkg, pkgHeader, sender); - if (perserResult != QH::ParserResult::NotProcessed) { - return perserResult; - } + if (auto package = parser->genPackage(cmd)) + return package; } + + return nullptr; } QSharedPointer @@ -121,6 +117,31 @@ APIVersionParser::selectParser(const VersionData &distVersion) const { return result; } +QSharedPointer APIVersionParser::selectParser(unsigned short cmd, + AbstractNodeInfo *sender) { + auto parser = sender->getParser(cmd); + if (!parser) { + parser = selectParserImpl(cmd, sender); + } + + return parser; +} + +QSharedPointer APIVersionParser::selectParserImpl(unsigned short cmd, + AbstractNodeInfo *sender) { + auto version = sender->version(); + const auto availableParser = selectParser(version); + for (const auto& parser: availableParser) { + if (parser->checkCommand(cmd)) { + sender->addParser(cmd, parser); + return parser; + } + } + + return nullptr; +} + + unsigned short APIVersionParser::maximumApiVersion(const QString &apiKey) const { auto availableVersion = _apiParsers.value(apiKey, {}); diff --git a/Heart/AbstractSpace/apiversionparser.h b/Heart/AbstractSpace/apiversionparser.h index 00d94219..5b20995f 100644 --- a/Heart/AbstractSpace/apiversionparser.h +++ b/Heart/AbstractSpace/apiversionparser.h @@ -32,7 +32,16 @@ class APIVersionParser: public QObject, public iParser AbstractNodeInfo *sender) override; int version() const override; QString parserId() const override; - QSharedPointer genPackage(unsigned short cmd) const override; + + /** + * @brief searchPackage This method search package recursive in all registered pararsers. Searching will be in compatibility versions. + * Before search methd choose compatibly verson. + * @param cmd This is command for that shold be create pacakge object. + * @param sender This is node that sent @a the cmd. + * @return Package generated from cmd. + */ + QSharedPointer + searchPackage(unsigned short cmd, AbstractNodeInfo *sender) const; /** * @brief getSelectedApiParser This method return apiParser for selected node @@ -66,6 +75,15 @@ class APIVersionParser: public QObject, public iParser QHash> selectParser(const VersionData& distVersion) const; + /** + * @brief selectParser This method select parser by command and sender. + * @param cmd this is command that need to parse. + * @param sender this is node that sent this command. + * @return parser for the @a cmd command + */ + QSharedPointer + selectParser(unsigned short cmd, AbstractNodeInfo *sender); + /** * @brief maximumApiVersion This method return maximum supported api version of this node. * @param apiKey This is api key. @@ -90,6 +108,10 @@ class APIVersionParser: public QObject, public iParser void sigNoLongerSupport(const QString& ApiKey, unsigned short version); private: + + QSharedPointer + selectParserImpl(unsigned short cmd, AbstractNodeInfo *sender); + bool processAppVersion(const QSharedPointer &message, AbstractNodeInfo *sender, const QH::Header &); diff --git a/Heart/AbstractSpace/iparser.h b/Heart/AbstractSpace/iparser.h index fe594d3d..3209e334 100644 --- a/Heart/AbstractSpace/iparser.h +++ b/Heart/AbstractSpace/iparser.h @@ -153,7 +153,7 @@ class HEARTSHARED_EXPORT iParser inline ParserResult commandHandler(HandlerType handlerObject, HandlerMethod method, const QSharedPointer &pkg, - const QH::AbstractNodeInfo *sender, + QH::AbstractNodeInfo *sender, const QH::Header &pkgHeader) { if (PackageClass::command() == pkg->cmd()) { diff --git a/Heart/AbstractSpace/packages/bigdatawraper.cpp b/Heart/AbstractSpace/packages/bigdatawraper.cpp new file mode 100644 index 00000000..1c39f74a --- /dev/null +++ b/Heart/AbstractSpace/packages/bigdatawraper.cpp @@ -0,0 +1,37 @@ + +//# +//# Copyright (C) 2022-2022 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#include "bigdatawraper.h" + +namespace QH { +namespace PKG { +const AbstractData *BigDataWraper::data() const { + return _data; +} + +void BigDataWraper::setData(const AbstractData *newData) { + _data = newData; +} + +QString BigDataWraper::toString() const { + if (_data) + return QString("Wrapper of : %0").arg(_data->toString()); + return QString("Wrapper of : null"); +} + +QDataStream &BigDataWraper::fromStream(QDataStream &stream) { + return stream; +} + +QDataStream &BigDataWraper::toStream(QDataStream &stream) const { + return stream; +} + +} +} diff --git a/Heart/AbstractSpace/packages/bigdatawraper.h b/Heart/AbstractSpace/packages/bigdatawraper.h new file mode 100644 index 00000000..a2291c48 --- /dev/null +++ b/Heart/AbstractSpace/packages/bigdatawraper.h @@ -0,0 +1,52 @@ + +//# +//# Copyright (C) 2022-2022 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef BIGDATAWRAPER_H +#define BIGDATAWRAPER_H +#include "abstractdata.h" + +namespace QH { +namespace PKG { + +/** + * @brief The BigDataWraper class is wrapper of any big data commands. + */ +class BigDataWraper: public AbstractData +{ + QH_PACKAGE(BigDataWraper, "BigDataWraper") + +public: + BigDataWraper(); + + /** + * @brief data This method sets data that shold be sent as big data. + * @return + */ + const AbstractData *data() const; + + /** + * @brief setData This method sets new data for this wrapper. + * @param newData this is new data object. + */ + void setData(const AbstractData *newData); + QString toString() const override; + // StreamBase interface +protected: + QDataStream &fromStream(QDataStream &stream) override; + QDataStream &toStream(QDataStream &stream) const override; + +private: + const AbstractData *_data = nullptr; + + + +}; +} +} +#endif // BIGDATAWRAPER_H diff --git a/Heart/DataBaseSpace/Private/singleserverdb.cpp b/Heart/DataBaseSpace/Private/singleserverdb.cpp deleted file mode 100644 index 3132019d..00000000 --- a/Heart/DataBaseSpace/Private/singleserverdb.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "singleserverdb.h" - -namespace QH { - -SingleServerDB::SingleServerDB() -{ - -} - -ISqlDBCache *QH::SingleServerDB::rawDb() const { - return DataBase::db(); -} - -QStringList SingleServerDB::SQLSources() const { - return {":/sql/DataBaseSpace/Res/UserDB.sql"}; -} - -} diff --git a/Heart/DataBaseSpace/Private/singleserverdb.h b/Heart/DataBaseSpace/Private/singleserverdb.h deleted file mode 100644 index f103e552..00000000 --- a/Heart/DataBaseSpace/Private/singleserverdb.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef SINGLESERVERDB_H -#define SINGLESERVERDB_H - -#include - -namespace QH { - - -class SingleServerDB: public DataBase -{ - Q_OBJECT -public: - SingleServerDB(); - /** - * @brief rawDb This node return pointer to database object. - * @return The pointer to data base. - */ - ISqlDBCache* rawDb() const; - - QStringList SQLSources() const override; - - friend class SingleServer; -}; - -} -#endif // SINGLESERVERDB_H diff --git a/Heart/DataBaseSpace/basedefines.h b/Heart/DataBaseSpace/basedefines.h deleted file mode 100644 index 0c517d71..00000000 --- a/Heart/DataBaseSpace/basedefines.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef BASEDEFINES_H -#define BASEDEFINES_H - -namespace QH { - -/** - * @brief The DBOperationResult enum contains the statuses of database operations. - */ -enum class DBOperationResult { - /// The Node don't know about a permission of operation. - Unknown, - /// The Node allow this operation and execute it. - Allowed, - /// The Node forbid this operation. - Forbidden, -}; - -} -#endif // BASEDEFINES_H diff --git a/Heart/DataBaseSpace/basenodeinfo.cpp b/Heart/DataBaseSpace/basenodeinfo.cpp deleted file mode 100644 index 88bf463e..00000000 --- a/Heart/DataBaseSpace/basenodeinfo.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "basenodeinfo.h" -#include "dbaddress.h" -#include -#include - -namespace QH { - - -BaseNodeInfo::BaseNodeInfo(QAbstractSocket *tcp, const HostAddress* address): - AbstractNodeInfo(tcp, address){} - -BaseNodeInfo::~BaseNodeInfo() = default; - -bool BaseNodeInfo::isValid() const { - return AbstractNodeInfo::isValid(); -} - -const AccessToken &BaseNodeInfo::token() const { - return _token; -} - -void BaseNodeInfo::setToken(const AccessToken &token) { - _token = token; -} - -void BaseNodeInfo::reset() { - AbstractNodeInfo::reset(); - setToken(AccessToken{}); - setId({}); -} - -bool BaseNodeInfo::confirmData() const { - return AbstractNodeInfo::confirmData(); -} - -const QString& BaseNodeInfo::id() const { - return _id; -} - -void BaseNodeInfo::setId(const QString &id) { - _id = id; -} - -} diff --git a/Heart/DataBaseSpace/basenodeinfo.h b/Heart/DataBaseSpace/basenodeinfo.h deleted file mode 100644 index 1d4993bc..00000000 --- a/Heart/DataBaseSpace/basenodeinfo.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef CONNECTIONINFO_H -#define CONNECTIONINFO_H - -#include "abstractnodeinfo.h" -#include "accesstoken.h" -#include "heart_global.h" -#include - -class QAbstractSocket; -namespace QH { - -class DbAddress; - -/** - * @brief The BaseNodeInfo class contains the unique node id. - * This object created in the DataBaseNode::createNodeInfo method. - */ -class HEARTSHARED_EXPORT BaseNodeInfo: public AbstractNodeInfo { - -public: - - /** - * @brief BaseNodeInfo This constructor initialize the node info object from the tcp descriptor - * @param tcp This is tcp socket descriptor. - * @param clientAddress This is network address of socket. - */ - explicit BaseNodeInfo(QAbstractSocket * tcp = nullptr, - const HostAddress* clientAddress = nullptr); - ~BaseNodeInfo() override; - - bool isValid() const override; - - /** - * @brief token This method return id of peer node or client. - * @return The id of peer node or client. - */ - const AccessToken& token() const; - - /** - * @brief setToken This method set an token for the peer node or the client. - * @param token New value of token of the peer node. - */ - void setToken(const AccessToken &token); - - void reset() override; - bool confirmData() const override; - - /** - * @brief id This method return id of the connected user. - * @return User id. - */ - const QString &id() const; - - /** - * @brief setId This method set userId for connected object. - * @param id This is new value of user id. - */ - void setId(const QString &id); - -protected: - AccessToken _token; - QString _id; - -}; - -} - -#endif // CONNECTIONINFO_H diff --git a/Heart/DataBaseSpace/database.cpp b/Heart/DataBaseSpace/database.cpp index b93ad350..cd11535e 100644 --- a/Heart/DataBaseSpace/database.cpp +++ b/Heart/DataBaseSpace/database.cpp @@ -5,7 +5,6 @@ * of this license document, but changing it is not allowed. */ -#include "accesstoken.h" #include "database.h" #include "sqldbcache.h" #include "sqldbwriter.h" @@ -13,13 +12,10 @@ #include #include -#include #include -#include #include #include #include -#include #include #include #include @@ -35,7 +31,7 @@ DataBase::DataBase(QObject *ptr): QObject(ptr) { } bool DataBase::initSqlDb(QString DBparamsFile, - ISqlDBCache *cache, + ISqlDB *cache, SqlDBWriter *writer) { initDefaultDbObjects(cache, writer); @@ -67,11 +63,11 @@ bool DataBase::initSqlDb(QString DBparamsFile, QuasarAppUtils::Params::log(QString("Database loaded from: %0").arg(dbLocation()), QuasarAppUtils::Debug); - connect(_db, &ISqlDBCache::sigItemChanged, + connect(_db, &ISqlDB::sigItemChanged, this, &DataBase::sigObjectChanged, Qt::DirectConnection); - connect(_db, &ISqlDBCache::sigItemDeleted, + connect(_db, &ISqlDB::sigItemDeleted, this, &DataBase::sigObjectDeleted, Qt::DirectConnection); @@ -117,7 +113,7 @@ DataBase::~DataBase() { stop(); } -void DataBase::initDefaultDbObjects(ISqlDBCache *cache, +void DataBase::initDefaultDbObjects(ISqlDB *cache, SqlDBWriter *writer) { if (!writer) { writer = new AsyncSqlDBWriter(); @@ -182,14 +178,6 @@ void DataBase::addDBPatch(const DBPatch &patch) { _targetDBVersion = std::max(_targetDBVersion, patch.versionTo); } -void DataBase::memberSubsribed(const QVariant &, unsigned int ) { - return; -} - -void DataBase::memberUnsubsribed(const QVariant &, unsigned int ) { - return; -} - QString DataBase::dbLocation() const { if (db() && db()->writer()) { return db()->writer()->databaseLocation(); @@ -216,7 +204,7 @@ bool DataBase::changeTrust(const QString &id, int diff) { return _db->changeObjects(NetworkMember{id}, action); } -ISqlDBCache *DataBase::db() const { +ISqlDB *DataBase::db() const { return _db; } @@ -314,259 +302,5 @@ QVariantMap DataBase::defaultDbParams() const { {"DBFilePath", DEFAULT_DB_PATH + "/" + localNodeName() + "/" + localNodeName() + "_" + DEFAULT_DB_NAME}, }; } - -DBOperationResult -QH::DataBase::getObject(const QString &requester, - const QH::DBObject &templateObj, - QSharedPointer &result) const { - - if (!(_db && result)) { - return DBOperationResult::Unknown; - } - - DBOperationResult permisionResult = checkPermission(requester, templateObj.dbAddress(), - Permission::Read); - if (permisionResult != DBOperationResult::Allowed) { - return permisionResult; - } - - auto obj = _db->getObject(templateObj); - if (!obj || (obj->dbAddress() != templateObj.dbAddress())) { - return DBOperationResult::Unknown; - } - - result = obj; - return DBOperationResult::Allowed; -} - -DBOperationResult -DataBase::getObjects(const QString &requester, - const DBObject &templateObj, - QList> &result) const { - if (!_db) { - return DBOperationResult::Unknown; - } - - if (!_db->getAllObjects(templateObj, result)) { - return DBOperationResult::Unknown; - } - - for (const auto& obj: qAsConst(result)) { - if (!obj) - return DBOperationResult::Unknown; - - auto permisionResult = checkPermission(requester, obj->dbAddress(), - Permission::Read); - if (permisionResult != DBOperationResult::Allowed) { - return permisionResult; - } - } - - return DBOperationResult::Allowed; -} - -DBOperationResult -DataBase::updateObject(const QString &requester, - const QSharedPointer &saveObject) { - - if (!_db) { - return DBOperationResult::Unknown; - } - - auto permisionResult = checkPermission(requester, - saveObject->dbAddress(), - Permission::Write); - if (permisionResult != DBOperationResult::Allowed) { - return permisionResult; - } - - if (!_db->updateObject(saveObject)) { - return DBOperationResult::Unknown; - } - - return DBOperationResult::Allowed; -} - -DBOperationResult -DataBase::createObject(const QString &requester, - const QSharedPointer &obj) { - - if (!_db) { - return DBOperationResult::Unknown; - } - - if (isForbidenTable(obj->table())) { - return DBOperationResult::Forbidden; - } - - if (!_db->insertObject(obj)) { - return DBOperationResult::Unknown; - } - - if (!addUpdatePermission(requester, obj->dbAddress(), Permission::Write)) { - - _db->deleteObject(obj); - - return DBOperationResult::Forbidden; - } - - return DBOperationResult::Allowed; - -} - -DBOperationResult -DataBase::updateIfNotExistsCreateObject(const QString &requester, - const QSharedPointer &obj) { - - auto opResult = updateObject(requester, obj); - if (opResult != QH::DBOperationResult::Unknown) { - return opResult; - } - - return createObject(requester, obj); -} - -DBOperationResult -DataBase::changeObjects(const QString &requester, - const DBObject &templateObj, - const std::function &)> &changeAction) { - - DBOperationResult result = DBOperationResult::Unknown; - - if (!_db) { - return result; - } - - auto execWithCheck = [this, requester, &result, &changeAction] - (const QSharedPointer & obj) { - - result = checkPermission(requester, obj->dbAddress(), Permission::Update); - if (result != DBOperationResult::Allowed) { - return false; - } - - return changeAction(obj); - }; - - if (!db()->changeObjects(templateObj, execWithCheck)) { - return result; - } - - return result; -} - -QVariant DataBase::getSender(const AbstractNodeInfo *connectInfo, - const AbstractData *) const { - - auto info = dynamic_cast(connectInfo); - if (!info) - return {}; - - return info->id(); -} - -DBOperationResult -DataBase::checkPermission(const QString &requester, - const DbAddress &objectAddress, - const Permission& requarimentPermision) const { - - if (!requester.isEmpty()) - return DBOperationResult::Unknown; - - if (!_db) { - return DBOperationResult::Unknown; - } - - auto member = _db->getObjectRaw(NetworkMember{requester}); - if (!member) { - return DBOperationResult::Unknown; - } - - auto permision = - _db->getObject(MemberPermisionObject({requester, objectAddress})); - - if (!permision) { - - permision = _db->getObject(DefaultPermision({requester, objectAddress})); - if (!permision) - return DBOperationResult::Unknown; - } - - if (permision->permisions() < requarimentPermision) { - return DBOperationResult::Forbidden; - } - - return DBOperationResult::Allowed; -} - -bool DataBase::addUpdatePermission(const QVariant &member, - const DbAddress &objectAddress, - const Permission &permision, - const Permission &defaultPermision) const { - - if (!_db) { - return false; - } - - auto object = QSharedPointer::create(); - object->setKey(PermisionData(member, objectAddress)); - object->setPermisions(permision); - - if (!_db->insertObject(object) && !_db->updateObject(object)) { - return false; - } - - auto defaultPermisionObject = QSharedPointer::create(); - defaultPermisionObject->setKey(PermisionData({}, objectAddress)); - defaultPermisionObject->setPermisions(defaultPermision); - - if (!_db->insertObject(defaultPermisionObject) && - !_db->updateObject(defaultPermisionObject)) { - return false; - } - - return true; -} - -bool DataBase::removePermission(const QVariant &member, - const DbAddress &objectAddress) const { - - if (!_db) { - return false; - } - - auto object = QSharedPointer::create(); - object->setKey(PermisionData(member, objectAddress)); - - if (!_db->deleteObject(object)) { - return false; - } - - return true; -} - -DBOperationResult -DataBase::deleteObject(const QString &requester, - const QSharedPointer &dbObject) { - - if (!_db) { - return DBOperationResult::Unknown; - } - - auto permisionResult = checkPermission(requester, - dbObject->dbAddress(), - Permission::Write); - if (permisionResult != DBOperationResult::Allowed) { - return permisionResult; - } - - auto address = dbObject->dbAddress(); - if (!_db->deleteObject(dbObject)) { - return DBOperationResult::Unknown; - } - - return DBOperationResult::Allowed; -} - } diff --git a/Heart/DataBaseSpace/database.h b/Heart/DataBaseSpace/database.h index 5cd17453..e100a53f 100644 --- a/Heart/DataBaseSpace/database.h +++ b/Heart/DataBaseSpace/database.h @@ -11,7 +11,6 @@ #include "dbpatch.h" #include #include -#include namespace QH { @@ -22,7 +21,7 @@ class ISubscribableData; } -class ISqlDBCache; +class ISqlDB; class SqlDBWriter; class DbAddress; class NodeId; @@ -55,7 +54,7 @@ class HEARTSHARED_EXPORT DataBase: public QObject * @return True if the database initialized successful. */ virtual bool initSqlDb( QString DBparamsFile = "", - ISqlDBCache * cache = nullptr, + ISqlDB * cache = nullptr, SqlDBWriter* writer = nullptr); /** @@ -90,92 +89,6 @@ class HEARTSHARED_EXPORT DataBase: public QObject */ virtual QVariantMap defaultDbParams() const; - /** - * @brief deleteObject This method delete object by database address. - * @note If you want to delete any object use only this method because this method check permission of requester to execute this action. - * @param requester This is pointer to network member that send this request. - * @param dbObject This is pointer to object of database to remove. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult deleteObject(const QString &requester, - const QSharedPointer &dbObject); - - /** - * @brief getObject This method try get an object by database address. - * @note If you want to get any object use only this method because this method check permission of requester to execute this action - * @param requester This is pointer to network member that send this request. - * @param templateObj This is pointer to object of database with data for generation the sql select request. - * @param result This is a shared pointer for save result of request. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult getObject(const QString &requester, - const PKG::DBObject &templateObj, - QSharedPointer &result) const; - - /** - * @brief getObjects This method try get objects by template object. - * @note If you want to get any objects use only this method because this method check permission of requester to execute this action - * @param requester This is pointer to network member that send this request. - * @param templateObj This is pointer to object of database with data for generation the sql select request. - * @param result This is reference to the list of result objects. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult getObjects(const QString &requester, - const PKG::DBObject &templateObj, - QList> &result) const; - - /** - * @brief updateObject This method try save or update database object. - * @note If you want to save or update any objects use only this method because this method check permission of requester to execute this action - * @param requester This is network mebmer that send this request. - * @param saveObject This is pointer to object of database for save or update. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult updateObject(const QString &requester, - const QSharedPointer &saveObject); - - /** - * @brief createObject This method create a new object in the database and add all permissions for the objects creator. - * @note If you want to create any objects use only this method because this method check permission of requester to execute this action - * @param requester This is network member that send this request. - * @param obj This is pointer to object of database for save or update. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult createObject(const QString &requester, - const QSharedPointer &obj); - - /** - * @brief updateIfNotExistsCreateObject This is wraper of the updateObject and createObjects methods. - * 1. Try update object - * 2. If object not exists Try create new object. - * 3. Return operation result - * @param requester This is network member that send this request. - * @param obj This is initializing object. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult updateIfNotExistsCreateObject(const QString &requester, - const QSharedPointer &obj); - - /** - * @brief changeObjects This is wrapper of the "ISqlDBCache::changeObjects" method. - * Key difference between a base method is checking of the permision for needed action. - * @note If you want to change any objects use only this method because this method check permission of requester to execute this action - * @param requester This is network member that send this request. - * @param templateObj This is pointer to object of database with data for generation the sql select request. - * @param changeAction This is action function for change all selected objects. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult changeObjects(const QString &requester, - const PKG::DBObject &templateObj, - const std::function&)> &changeAction); - /** * @brief isBanned This method check trust of node, if node trust is lover of 0 return true. * @param member This is member of network (node, client or server). @@ -242,75 +155,13 @@ class HEARTSHARED_EXPORT DataBase: public QObject * @param cache This is Cache database object. * @param writer This is Database writerObject. */ - virtual void initDefaultDbObjects(ISqlDBCache *cache, SqlDBWriter *writer); - - /** - * @brief memberSubsribed This method invoked when client with @a clientId subscribed on object with @a subscribeId. - * @param clientId This is id of the client member. - * @param subscribeId This is id of the subscribeObject. - */ - virtual void memberSubsribed(const QVariant &clientId, unsigned int subscribeId); - - /** - * @brief memberUnSubsribed This method invoked when client with @a clientId unsubsribed on object with @a subscribeId - * @param clientId This is id of the client member. - * @param subscribeId This is id of the subscribeObject. - */ - virtual void memberUnsubsribed(const QVariant &clientId, unsigned int subscribeId); + virtual void initDefaultDbObjects(ISqlDB *cache, SqlDBWriter *writer); /** * @brief db This node return pointer to database object. * @return The pointer to data base. */ - ISqlDBCache* db() const; - - /** - * @brief getSender This method return id of requester. - * By Default base implementation get id from BaseNdoeInfo. - * override this method for correctly work of the DataBaseNode::ParsePacakge method. - * @param connectInfo This is info about connection. - * @param requestData This is data of request. - * @return id of requester member. - */ - virtual QVariant getSender(const AbstractNodeInfo *connectInfo, const PKG::AbstractData *requestData) const; - - /** - * @brief checkPermision This method check a permision of requester, to database object with objectAddress. - * Override this method if you have a custom database structure. - * @param requester This is user, node or another object of network - * @param objectAddress This is address to database object - * @param requarimentPermision This is needed permission for requester - * @return DBOperationResult::Alowed if permission granted. - * For more information about result see the DBOperationResult enum. - */ - virtual DBOperationResult checkPermission(const QString &requester, - const DbAddress& objectAddress, - const Permission& requarimentPermision) const; - - - /** - * @brief addUpdatePermission This method added or update permission for member. - * @warning This method do not have a validation. It is just change a NetworkMembers table, so use this carefully. - * @param member This is member id (user of node). - * @param objectAddress This is database object for which the permissions will be set. - * @param permision This is permission level. - * @param defaultPermision This is default permision for all of rest objects. By default This is Permission::Read - * @return true if method finished successful. - */ - virtual bool addUpdatePermission(const QVariant &member, - const DbAddress& objectAddress, - const Permission& permision, - const Permission& defaultPermision = Permission::Read) const; - - /** - * @brief removePermission This method use to removed permission for member. - * @warning This method do not have a validation. It is just change a NetworkMembers table, so use this carefully. - * @param member This is member id (user of node) - * @param objectAddress This is database object for which the permissions will be removed - * @return true if method finished successful. - */ - virtual bool removePermission(const QVariant &member, - const DbAddress& objectAddress) const; + ISqlDB* db() const; /** * @brief welcomeAddress This method send to the node information about self. @@ -462,7 +313,7 @@ class HEARTSHARED_EXPORT DataBase: public QObject bool isForbidenTable(const QString& table); - ISqlDBCache *_db = nullptr; + ISqlDB *_db = nullptr; unsigned short _targetDBVersion = 0; DBPatchMap _dbPatches; QString _localNodeName; diff --git a/Heart/DataBaseSpace/databasenode.cpp b/Heart/DataBaseSpace/databasenode.cpp deleted file mode 100644 index d6682537..00000000 --- a/Heart/DataBaseSpace/databasenode.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "accesstoken.h" -#include "databasenode.h" -#include "abstractnodeinfo.h" -#include "sqldbcache.h" -#include "sqldbwriter.h" -#include "websocketcontroller.h" -#include "asyncsqldbwriter.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dberrorcodes.h" -#include -#include -#include -#include -#include -#include -#include -#include "getsinglevalue.h" -#include "setsinglevalue.h" -#include "database.h" - -#define THIS_NODE "this_node_key" -namespace QH { -using namespace PKG; - -DataBaseNode::DataBaseNode(QObject *ptr): - AbstractNode(ptr) { - - _webSocketWorker = new WebSocketController(this); - - qRegisterMetaType>(); - - registerPackageType(); - registerPackageType(); - registerPackageType(); - -} - -bool DataBaseNode::initDatabase() { - setDb(new DataBase()); - return true; -} - -void DataBaseNode::setDb(DataBase *newDb) { - if (_db) { - disconnect(_db, &DataBase::sigObjectChanged, - this, &DataBaseNode::handleObjectChanged); - - disconnect(_db, &DataBase::sigObjectDeleted, - this, &DataBaseNode::handleObjectDeleted); - - delete _db; - } - - _db = newDb; - - if (_db) { - connect(_db, &DataBase::sigObjectChanged, - this, &DataBaseNode::handleObjectChanged, - Qt::DirectConnection); - - connect(_db, &DataBase::sigObjectDeleted, - this, &DataBaseNode::handleObjectDeleted, - Qt::DirectConnection); - } -} - - -bool DataBaseNode::isSqlInited() const { - return _db && _db->isSqlInited(); -} - -DBOperationResult DataBaseNode::checkPermission(const QString &requester, - const DbAddress &objectAddress, - const Permission &requarimentPermision) const { - if (!_db) { - return DBOperationResult::Unknown; - } - - return _db->checkPermission(requester, objectAddress, requarimentPermision); -} - -bool DataBaseNode::run(const QString &addres, unsigned short port) { - return initDatabase() && _db->run() &&AbstractNode::run(addres, port); -} - -bool DataBaseNode::run(const QString &addres, - unsigned short port, - const QString &localNodeName) { - return initDatabase() && _db->run(localNodeName) && AbstractNode::run(addres, port); -} - -void DataBaseNode::stop() { - - AbstractNode::stop(); - - if (_db) - _db->stop(); -} - -DataBaseNode::~DataBaseNode() { - if (_db) - delete _db; -} - -bool DataBaseNode::welcomeAddress(AbstractNodeInfo *) { - return true; -} - -bool DataBaseNode::isBanned(const QString &node) const { - return db()->isBanned(node); -} - -bool DataBaseNode::isBanned(const AbstractNodeInfo *node) const { - return AbstractNode::isBanned(node); -} - -bool DataBaseNode::notifyObjectChanged(const QSharedPointer &item) { - - if (!item.dynamicCast()) { - return false; - } - - _webSocketWorker->handleItemChanged(item); - - return true; -} - -void DataBaseNode::objectRemoved(const DbAddress &) { - -} - -void DataBaseNode::objectChanged(const QSharedPointer &) { - -} - -void DataBaseNode::handleObjectChanged(const QSharedPointer &item) { - notifyObjectChanged(item.staticCast()); - objectChanged(item); - -} - -void DataBaseNode::handleObjectDeleted(const DbAddress &item) { - objectRemoved(item); -} - -void DataBaseNode::nodeConnected(AbstractNodeInfo *node) { - AbstractNode::nodeConnected(node); - welcomeAddress(node); -} - -void DataBaseNode::nodeDisconnected(AbstractNodeInfo *node) { - AbstractNode::nodeDisconnected(node); - - auto baseInfo = dynamic_cast(node); - - if (baseInfo) { - baseInfo->reset(); - } -} - -void DataBaseNode::memberSubsribed(const QVariant &, unsigned int ) { - return; -} - -void DataBaseNode::memberUnsubsribed(const QVariant &, unsigned int ) { - return; -} - -QString DataBaseNode::dbLocation() const { - if (!db()) { - return ""; - } - - return db()->dbLocation(); -} - -AbstractNodeInfo *DataBaseNode::createNodeInfo(QAbstractSocket *socket, const HostAddress *clientAddress) const { - return new BaseNodeInfo(socket, clientAddress); -} - -bool DataBaseNode::changeTrust(const HostAddress &id, int diff) { - auto info = dynamic_cast(getInfoPtr(id)); - if (!info) - return false; - - if (info->id().size()) - return changeTrust(info->id(), diff); - - return AbstractNode::changeTrust(id, diff); -} - -bool DataBaseNode::changeTrust(const QString &id, int diff) { - if (!_db) - return false; - return _db->changeTrust(id, diff); -} - -unsigned int DataBaseNode::sendData(const AbstractData *resp, - const QVariant &nodeId, - const Header *req) { - - auto nodes = connections(); - - for (auto it = nodes.begin(); it != nodes.end(); ++it) { - auto info = dynamic_cast(it.value()); - if (info && info->id() == nodeId) { - return sendData(resp, info, req); - } - } - - return 0; -} - -unsigned int DataBaseNode::sendData(const AbstractData *resp, const HostAddress &nodeId, - const Header *req) { - return AbstractNode::sendData(resp, nodeId, req); - -} - -unsigned int DataBaseNode::sendData(const PKG::AbstractData *resp, - const AbstractNodeInfo *node, - const Header *req) { - return AbstractNode::sendData(resp, node, req); -} - -ParserResult DataBaseNode::parsePackage(const QSharedPointer &pkg, - const Header &pkgHeader, - const AbstractNodeInfo *sender) { - auto parentResult = AbstractNode::parsePackage(pkg, pkgHeader, sender); - if (parentResult != ParserResult::NotProcessed) { - return parentResult; - } - - if (WebSocket::command() == pkg->cmd()) { - WebSocket *obj = static_cast(pkg.data()); - - auto requesterId = getSender(sender, obj); - if (!obj->isValid()) { - badRequest(sender->networkAddress(), pkgHeader, - { - ErrorCodes::InvalidRequest, - "WebSocket request is invalid" - }); - return ParserResult::Error; - } - - if (!workWithSubscribe(*obj, requesterId, sender)) { - badRequest(sender->networkAddress(), pkgHeader, { - ErrorCodes::InvalidRequest, - "WebSocket request is invalid" - }); - return ParserResult::Error; - } - - return ParserResult::Processed; - - } - - return ParserResult::NotProcessed; -} - -QByteArray DataBaseNode::hashgenerator(const QByteArray &pass) const { - if (pass.isEmpty()) - return {}; - - return QCryptographicHash::hash( - QCryptographicHash::hash(pass, QCryptographicHash::Sha256) + "QuassarAppSoult", - QCryptographicHash::Sha256); -} - -DataBase *DataBaseNode::db() const { - return _db; -} - -bool DataBaseNode::workWithSubscribe(const WebSocket &rec, - const QString &clientOrNodeid, - const AbstractNodeInfo * sender) { - - auto _db = db(); - if (!_db) - return false; - - switch (static_cast(rec.getRequestCmd())) { - - case WebSocketRequest::Subscribe: { - _webSocketWorker->subscribe(clientOrNodeid, rec.subscribeId()); - memberSubsribed(clientOrNodeid, rec.subscribeId()); - return true; - } - - case WebSocketRequest::Unsubscribe: { - _webSocketWorker->unsubscribe(clientOrNodeid, rec.subscribeId()); - memberUnsubsribed(clientOrNodeid, rec.subscribeId()); - return true; - } - - case WebSocketRequest::SubscribeList: { - - WebSocketSubscriptions resp; - resp.setAddresses(_webSocketWorker->list(clientOrNodeid)); - - return sendData(&resp, sender); - } - - default: break; - } - - return false; -} - -DBOperationResult -QH::DataBaseNode::getObject(const QString &requester, - const QH::DBObject &templateObj, - QSharedPointer &result) const { - - if (!_db) { - return DBOperationResult::Unknown; - } - return _db->getObject(requester, templateObj, result); -} - -DBOperationResult -DataBaseNode::getObjects(const QString &requester, - const DBObject &templateObj, - QList> &result) const { - - if (!_db) { - return DBOperationResult::Unknown; - } - return _db->getObjects(requester, templateObj, result); -} - -DBOperationResult -DataBaseNode::updateObject(const QString &requester, - const QSharedPointer &saveObject) { - - if (!_db) { - return DBOperationResult::Unknown; - } - return _db->updateObject(requester, saveObject); -} - -DBOperationResult -DataBaseNode::createObject(const QString &requester, - const QSharedPointer &obj) { - - if (!_db) { - return DBOperationResult::Unknown; - } - return _db->createObject(requester, obj); -} - -DBOperationResult -DataBaseNode::updateIfNotExistsCreateObject(const QString &requester, - const QSharedPointer &obj) { - - if (!_db) { - return DBOperationResult::Unknown; - } - return _db->updateIfNotExistsCreateObject(requester, obj); -} - -DBOperationResult -DataBaseNode::changeObjects(const QString &requester, - const DBObject &templateObj, - const std::function &)> &changeAction) { - - if (!_db) { - return DBOperationResult::Unknown; - } - return _db->changeObjects(requester, templateObj, changeAction); -} - -QString DataBaseNode::getSender(const AbstractNodeInfo *connectInfo, - const AbstractData *) const { - - auto info = dynamic_cast(connectInfo); - if (!info) - return {}; - - return info->id(); -} - -DBOperationResult -DataBaseNode::deleteObject(const QString &requester, - const QSharedPointer &dbObject) { - - if (!_db) { - return DBOperationResult::Unknown; - } - return _db->deleteObject(requester, dbObject); -} - -} - diff --git a/Heart/DataBaseSpace/databasenode.h b/Heart/DataBaseSpace/databasenode.h deleted file mode 100644 index 8114ce57..00000000 --- a/Heart/DataBaseSpace/databasenode.h +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef DATABASENODE_H -#define DATABASENODE_H - -#include "abstractnode.h" -#include -#include -#include - - -namespace QH { - -namespace PKG { -class WebSocket; -class ISubscribableData; - -} - -class ISqlDBCache; -class SqlDBWriter; -class WebSocketController; -class DbAddress; -class NodeId; -class iObjectProvider; -class DataBase; - - -/** - * @brief The BaseNode class is database base implementation of nodes or servers. - * This implementation contains methods for work with database. - * DataBaseNode is thread save class. - * @see DBObject - */ -class HEARTSHARED_EXPORT DataBaseNode : public AbstractNode -{ - Q_OBJECT -public: - - DataBaseNode(QObject * ptr = nullptr); - ~DataBaseNode() override; - - bool run(const QString &addres, unsigned short port) override; - - /** - * @brief run This method is some as AbstractNode::run but set for node custom work folder. - * This maybe use for multiple deployment nodes on one host. - * @param addres This is network address of work node or server. - * If address is empty then server will be listen all addresses of all interfaces else listen only selected address. - * @param port This is port of deployment node (server). - * @return Result of deployment node (sever). (True if deploy finished successful else false). - * @param localNodeName This is name of node and work folder of node. - */ - virtual bool run(const QString &addres, unsigned short port, - const QString &localNodeName); - - void stop() override; - - /** - * @brief sendData This method is some as AbstractNode::sendData but it try send data to the id. - * This implementation do not prepare object to sending. - * @param resp This is sending object to the nodeId. - * @param nodeId This is id of target node. - * @param req This is header of request. - * @return true if a data send successful. - */ - virtual unsigned int sendData(const PKG::AbstractData *resp, const QVariant &nodeId, - const Header *req = nullptr); - - unsigned int sendData(const PKG::AbstractData *resp, const HostAddress &nodeId, - const Header *req = nullptr) override; - - unsigned int sendData(const PKG::AbstractData *resp, const AbstractNodeInfo *node, - const Header *req = nullptr) override; - - /** - * @brief deleteObject This method delete object by database address. - * @note If you want to delete any object use only this method because this method check permission of requester to execute this action. - * @param requester This is pointer to network member that send this request. - * @param dbObject This is pointer to object of database to remove. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult deleteObject(const QString &requester, - const QSharedPointer &dbObject); - - /** - * @brief getObject This method try get an object by database address. - * @note If you want to get any object use only this method because this method check permission of requester to execute this action - * @param requester This is pointer to network member that send this request. - * @param templateObj This is pointer to object of database with data for generation the sql select request. - * @param result This is a shared pointer for save result of request. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult getObject(const QString &requester, - const PKG::DBObject &templateObj, - QSharedPointer &result) const; - - /** - * @brief getObjects This method try get objects by template object. - * @note If you want to get any objects use only this method because this method check permission of requester to execute this action - * @param requester This is pointer to network member that send this request. - * @param templateObj This is pointer to object of database with data for generation the sql select request. - * @param result This is reference to the list of result objects. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult getObjects(const QString &requester, - const PKG::DBObject &templateObj, - QList> &result) const; - - /** - * @brief updateObject This method try save or update database object. - * @note If you want to save or update any objects use only this method because this method check permission of requester to execute this action - * @param requester This is network mebmer that send this request. - * @param saveObject This is pointer to object of database for save or update. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult updateObject(const QString &requester, - const QSharedPointer &saveObject); - - /** - * @brief createObject This method create a new object in the database and add all permissions for the objects creator. - * @note If you want to create any objects use only this method because this method check permission of requester to execute this action - * @param requester This is network member that send this request. - * @param obj This is pointer to object of database for save or update. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult createObject(const QString &requester, - const QSharedPointer &obj); - - /** - * @brief updateIfNotExistsCreateObject This is wraper of the updateObject and createObjects methods. - * 1. Try update object - * 2. If object not exists Try create new object. - * 3. Return operation result - * @param requester This is network member that send this request. - * @param obj This is initializing object. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult updateIfNotExistsCreateObject(const QString &requester, - const QSharedPointer &obj); - - /** - * @brief changeObjects This is wrapper of the "ISqlDBCache::changeObjects" method. - * Key difference between a base method is checking of the permision for needed action. - * @note If you want to change any objects use only this method because this method check permission of requester to execute this action - * @param requester This is network member that send this request. - * @param templateObj This is pointer to object of database with data for generation the sql select request. - * @param changeAction This is action function for change all selected objects. - * @return result of operation (allow, forbidden, unknown). - * For more information about results see the DBOperationResult enum. - */ - DBOperationResult changeObjects(const QString &requester, - const PKG::DBObject &templateObj, - const std::function&)> &changeAction); - - /** - * @brief isSqlInited This method return true if database initialized successful. - * @return True if database initialized successful. - */ - bool isSqlInited() const; - - /** - * @brief checkPermision This method check a permision of requester, to database object with objectAddress. - * Override this method if you have a custom database structure. - * @param requester This is user, node or another object of network - * @param objectAddress This is address to database object - * @param requarimentPermision This is needed permission for requester - * @return DBOperationResult::Alowed if permission granted. - * For more information about result see the DBOperationResult enum. - */ - DBOperationResult checkPermission(const QString &requester, - const DbAddress& objectAddress, - const Permission& requarimentPermision) const; - - -protected: - - /** - * @brief setDb This method sets new object of the database. - * @param newDb this is new object of the database - * @note use in the initDatabase method. - */ - void setDb(DataBase *newDb); - - ParserResult parsePackage(const QSharedPointer &pkg, - const Header& pkgHeader, - const AbstractNodeInfo* sender) override; - - AbstractNodeInfo *createNodeInfo(QAbstractSocket *socket, const HostAddress *clientAddress) const override; - - bool changeTrust(const HostAddress &id, int diff) override; - - /** - * @brief changeTrust This implementation of change trust is change trust node or user by self id. - * All changes of trust saving into local database. - * @param id This is id of user of other network member object. - * @param diff This is difference of trust. - * @return true if trust of user changed successful. - */ - virtual bool changeTrust(const QString &id, int diff); - - /** - * @brief hashgenerator This method generate a hash from any value. - * Override this method for set your custom salt. - * @param data This input byte array. - */ - virtual QByteArray hashgenerator(const QByteArray &data) const; - - void nodeConnected(AbstractNodeInfo *node) override; - void nodeDisconnected(AbstractNodeInfo *node) override; - - - /** - * @brief memberSubsribed This method invoked when client with @a clientId subscribed on object with @a subscribeId. - * @param clientId This is id of the client member. - * @param subscribeId This is id of the subscribeObject. - */ - virtual void memberSubsribed(const QVariant &clientId, unsigned int subscribeId); - - /** - * @brief memberUnSubsribed This method invoked when client with @a clientId unsubsribed on object with @a subscribeId - * @param clientId This is id of the client member. - * @param subscribeId This is id of the subscribeObject. - */ - virtual void memberUnsubsribed(const QVariant &clientId, unsigned int subscribeId); - - /** - * @brief db This node return pointer to database object. - * @return The pointer to data base. - */ - DataBase* db() const; - - /** - * @brief getSender This method return id of requester. - * By Default base implementation get id from BaseNdoeInfo. - * override this method for correctly work of the DataBaseNode::ParsePacakge method. - * @param connectInfo This is info about connection. - * @param requestData This is data of request. - * @return id of requester member. - */ - virtual QString getSender(const AbstractNodeInfo *connectInfo, const PKG::AbstractData *requestData) const; - - /** - * @brief dbLocation This method return location of nodes or clients database. - * @return path to the location of database. - */ - QString dbLocation() const; - - /** - * @brief welcomeAddress This method send to the node information about self. - * Override this method if you want send custom data to incoming connection. - * @param node This is info object of the peer node. - * @return true if all information sender successful. - */ - virtual bool welcomeAddress(AbstractNodeInfo *node); - - /** - * @brief isBanned This method check trust of node, if node trust is lover of 0 return true. - * @param member This is member of network (node, client or server). - * @return true if node is banned. - */ - bool isBanned(const QString &member) const; - - bool isBanned(const AbstractNodeInfo *member) const override; - - /** - * @brief notifyObjectChanged This method send all subscriptions message with this object. - * @param item changed object. - * @return true if an item object sendible. - */ - bool notifyObjectChanged(const QSharedPointer &item); - - /** - * @brief objectRemoved This method invoked when object with @a address removed from database. - * Oberride this method for handle this event. Default implementation do nothing. - * @param address This is address of the deteted object. - */ - virtual void objectRemoved(const DbAddress& address); - - /** - * @brief objectChanged This method invoked when object with @a address changed in database. - * Override this method for handle this event. Default implementation do nothing. - * @param obj This is address of the changed object. - */ - virtual void objectChanged(const QSharedPointer& obj); - - /** - * @brief initDatabase This method initialize the default DataBase object. - * @return true if database initialized succesful else false. - * @see DataBase; - */ - virtual bool initDatabase(); -private slots: - void handleObjectChanged(const QSharedPointer &item); - void handleObjectDeleted(const QH::DbAddress &item); - - -private: - /** - * @brief workWithSubscribe This method work with subscribe commnads. - * @param rec This is request data. - * @param address This is sender address. - * @return true if data parsed successful. - */ - bool workWithSubscribe(const PKG::WebSocket &rec, - const QString &clientOrNodeid, - const AbstractNodeInfo *sender); - - - DataBase *_db = nullptr; - WebSocketController *_webSocketWorker = nullptr; - - - friend class WebSocketController; - -}; - - -} - -#endif // DATABASENODE_H diff --git a/Heart/DataBaseSpace/dbaddress.h b/Heart/DataBaseSpace/dbaddress.h index 9e105fbf..e6ecb80c 100644 --- a/Heart/DataBaseSpace/dbaddress.h +++ b/Heart/DataBaseSpace/dbaddress.h @@ -9,7 +9,6 @@ #define DBADDRESS_H #include "streambase.h" -#include "basedefines.h" namespace QH { diff --git a/Heart/DataBaseSpace/dbcachekey.cpp b/Heart/DataBaseSpace/dbcachekey.cpp deleted file mode 100644 index 8a15f6d1..00000000 --- a/Heart/DataBaseSpace/dbcachekey.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "dbcachekey.h" - -#include -namespace QH { - -DBCacheKey *DBCacheKey::instance() { - static auto ptr = new DBCacheKey(); - return ptr; -} - -QString DBCacheKey::description(uint hash) const { - auto val = value(hash); - - if (!val) - return ""; - - return val->toString(); -} - -DBCacheKey::DBCacheKey() {} -} - diff --git a/Heart/DataBaseSpace/dbcachekey.h b/Heart/DataBaseSpace/dbcachekey.h deleted file mode 100644 index ba68e2ca..00000000 --- a/Heart/DataBaseSpace/dbcachekey.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef DBCACHEKEY_H -#define DBCACHEKEY_H - -#include -#include -#include - -namespace QH { - -/** - * @brief The DBCacheKey class is memory storage for registered key values. - * This class have a static array for contains all child classes of the AbstractKey class. - * - * Description: - * - * Any key it is unsigned int implementation of any AbstractKey child objects. - * This class provide functions: - * - The Get of value of AbstractKey child classes (it hash). for more information see the AbstractKey::hash method. - * For this use the HASH_KEY(X) macros. - * - The Calc of hash value of any AbstractKey child classes (it hash). - * If the hash is has been calculated then hash returned from the cache of DBCacheKey. - * For this use the VALUE_KEY(X) macros. - * - The Generate of keys description. - * For this use the DESCRIPTION_KEY(X) macros. - * - * @note This class is implementation of the Singleton pattern. Use carefully. - */ -class HEARTSHARED_EXPORT DBCacheKey -{ -public: - - /** - * @brief instance This method return instance of this singleton object. - * @return singleton of object. - */ - static DBCacheKey* instance(); - - template - /** - * @brief value This method return the value from key. For more convenient use the HASH_KEY(X) macros. - * @param key This is hash of key value - * @return value of key. - */ - const TYPE* value(uint key) const { - return dynamic_cast(_data.value(key, nullptr)); - } - - template - /** - * @brief key This method return hash key and save object into objects table. For more convenient use the VALUE_KEY(X) macros - * @param value This is value of a key object. - * @return hash of input value. - */ - uint key(const TYPE& value) { - auto object = dynamic_cast(&value); - - if (!object) { - return 0; - } - - uint hash = object->hash(); - if (_data.contains(hash)) { - _data[hash] = new TYPE(value); - } - return hash; - } - - /** - * @brief description This method return string description of id (hash). For more convenient use the DESCRIPTION_KEY(X) macros. - * @param hash This is hash value of object (id). - * @return information about this hash value. - */ - QString description(uint hash) const; - -private: - QHash _data; - DBCacheKey(); - -}; - -#define HASH_KEY(X) DBCacheKey::instance()->key(X) -#define VALUE_KEY(X) DBCacheKey::instance()->value(X) -#define DESCRIPTION_KEY(X) DBCacheKey::instance()->description(X) - -} - -#endif // DBCACHEKEY_H diff --git a/Heart/DataBaseSpace/dberrorcodes.h b/Heart/DataBaseSpace/dberrorcodes.h deleted file mode 100644 index 5ab1be12..00000000 --- a/Heart/DataBaseSpace/dberrorcodes.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2020-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef DB_ERRORCODES_H -#define DB_ERRORCODES_H - -#include "abstracterrorcodes.h" -namespace QH { - -namespace ErrorCodes { - -/** - * @brief The DBErrorCodes enum This is AuthRequest error codes. For more information see the QH::AuthRequest class. - */ -enum DBErrorCodes: Code { - /// User not registered because database not inited or other error occurred. - InternalError = AbstractErrorCodes::AbstractErrorCodes, - /// User not have a permission of execute a requested operation. - OperatioForbiden, - /// User not registered because user already exists. - UserExits, - /// User not logged because you need register user before login. - UserNotExits, - /// User is not Logged. - UserNotLogged, - /// User not logged because have an invalid password. - UserInvalidPasswoed, - /// User Already Logged. - UserAlreadyLogged, - /// User not logged or registered because time out. Emitted after 10 sec if not response from server. - TimeOutError, - /// This case using for inheritance new enum classes. - DBErrorCodes, - - -}; - -/** - * @brief The DBErrorCodesHelper class use for translate the error codes to the string values. - * This class known about all error codes of the DBErrorCodes enum and AbstractErrorCodes enum. - */ -class HEARTSHARED_EXPORT DBErrorCodesHelper { -public: - /** - * @brief toString This method have a cases for the translate all ErrorCodes of the QuasarApp Heart library. - * @param enumData This is error code. - * @return string value of the error code. - * @note This helper support all enum from the AbstractErrorCodesHelper class. - */ - static QString toString(Code enumData); - -private: - DBErrorCodesHelper() = default; - -}; - -} -} -#endif // SingleERRORCODES_H diff --git a/Heart/DataBaseSpace/isqldbcache.cpp b/Heart/DataBaseSpace/isqldb.cpp similarity index 82% rename from Heart/DataBaseSpace/isqldbcache.cpp rename to Heart/DataBaseSpace/isqldb.cpp index bf78c9f8..45dd150b 100644 --- a/Heart/DataBaseSpace/isqldbcache.cpp +++ b/Heart/DataBaseSpace/isqldb.cpp @@ -5,7 +5,7 @@ * of this license document, but changing it is not allowed. */ -#include "isqldbcache.h" +#include "isqldb.h" #include "quasarapp.h" #include "sqldbwriter.h" #include "dbaddresskey.h" @@ -22,7 +22,7 @@ namespace QH { using namespace PKG; -void ISqlDBCache::globalUpdateDataBase(SqlDBCasheWriteMode mode) { +void ISqlDB::globalUpdateDataBase(SqlDBCasheWriteMode mode) { qint64 currentTime = QDateTime::currentMSecsSinceEpoch(); if (currentTime - lastUpdateTime > updateInterval || @@ -50,7 +50,7 @@ void ISqlDBCache::globalUpdateDataBase(SqlDBCasheWriteMode mode) { } } -bool ISqlDBCache::updateObjectP(const QSharedPointer &saveObject, +bool ISqlDB::updateObjectP(const QSharedPointer &saveObject, bool wait) { if (updateCache(saveObject)) { @@ -70,7 +70,7 @@ bool ISqlDBCache::updateObjectP(const QSharedPointer &saveObject, _writer->updateObject(saveObject, wait); } -bool ISqlDBCache::deleteObjectP(const QSharedPointer &delObj, +bool ISqlDB::deleteObjectP(const QSharedPointer &delObj, bool wait) { deleteFromCache(delObj); @@ -83,7 +83,7 @@ bool ISqlDBCache::deleteObjectP(const QSharedPointer &delObj, return false; } -bool ISqlDBCache::insertObjectP(const QSharedPointer &saveObject, +bool ISqlDB::insertObjectP(const QSharedPointer &saveObject, bool wait) { if (insertToCache(saveObject)) { @@ -104,41 +104,41 @@ bool ISqlDBCache::insertObjectP(const QSharedPointer &saveObject, _writer->insertObject(saveObject, wait); } -qint64 ISqlDBCache::getLastUpdateTime() const { +qint64 ISqlDB::getLastUpdateTime() const { return lastUpdateTime; } -void ISqlDBCache::setLastUpdateTime(const qint64 &value) { +void ISqlDB::setLastUpdateTime(const qint64 &value) { lastUpdateTime = value; } -void ISqlDBCache::pushToQueue(const QSharedPointer &obj, +void ISqlDB::pushToQueue(const QSharedPointer &obj, CacheAction type) { _saveLaterMutex.lock(); _changes.insert(type, obj); _saveLaterMutex.unlock(); } -ISqlDBCache::ISqlDBCache(qint64 updateInterval, SqlDBCasheWriteMode mode) { +ISqlDB::ISqlDB(qint64 updateInterval, SqlDBCasheWriteMode mode) { lastUpdateTime = QDateTime::currentMSecsSinceEpoch(); this->updateInterval = updateInterval; setMode(mode); } -ISqlDBCache::~ISqlDBCache() { +ISqlDB::~ISqlDB() { } -SqlDBWriter *ISqlDBCache::writer() const { +SqlDBWriter *ISqlDB::writer() const { return _writer; } -void ISqlDBCache::setWriter(SqlDBWriter *writer) { +void ISqlDB::setWriter(SqlDBWriter *writer) { _writer = writer; } -bool ISqlDBCache::getAllObjects(const DBObject &templateObject, +bool ISqlDB::getAllObjects(const DBObject &templateObject, QList> &result) { result = getFromCache(&templateObject); @@ -165,7 +165,7 @@ bool ISqlDBCache::getAllObjects(const DBObject &templateObject, return false; } -bool ISqlDBCache::deleteObject(const QSharedPointer &delObj, +bool ISqlDB::deleteObject(const QSharedPointer &delObj, bool wait) { if (!delObj) @@ -184,7 +184,7 @@ bool ISqlDBCache::deleteObject(const QSharedPointer &delObj, } -bool ISqlDBCache::updateObject(const QSharedPointer &saveObject, +bool ISqlDB::updateObject(const QSharedPointer &saveObject, bool wait) { if (!saveObject || !saveObject->isValid()) { @@ -200,7 +200,7 @@ bool ISqlDBCache::updateObject(const QSharedPointer &saveObject, return true; } -bool ISqlDBCache::insertObject(const QSharedPointer &saveObject, bool wait) { +bool ISqlDB::insertObject(const QSharedPointer &saveObject, bool wait) { if (!saveObject || !saveObject->isValid()) { return false; } @@ -214,7 +214,7 @@ bool ISqlDBCache::insertObject(const QSharedPointer &saveObject, bool return true; } -bool ISqlDBCache::doQuery(const QString &query, bool wait, +bool ISqlDB::doQuery(const QString &query, bool wait, QSqlQuery *result) const { if (!_writer) { @@ -224,7 +224,7 @@ bool ISqlDBCache::doQuery(const QString &query, bool wait, return _writer->doQuery(query, wait, result); } -bool ISqlDBCache::doSql(const QString &sqlFile, bool wait) const { +bool ISqlDB::doSql(const QString &sqlFile, bool wait) const { if (!_writer) { return false; } @@ -232,7 +232,7 @@ bool ISqlDBCache::doSql(const QString &sqlFile, bool wait) const { return _writer->doSql(sqlFile, wait); } -bool ISqlDBCache::init(const QString &initDbParams) { +bool ISqlDB::init(const QString &initDbParams) { if (!_writer) { return false; @@ -241,7 +241,7 @@ bool ISqlDBCache::init(const QString &initDbParams) { return _writer->initDb(initDbParams); } -bool ISqlDBCache::init(const QVariantMap ¶ms) { +bool ISqlDB::init(const QVariantMap ¶ms) { if (!_writer) { return false; @@ -250,17 +250,17 @@ bool ISqlDBCache::init(const QVariantMap ¶ms) { return _writer->initDb(params); } -void ISqlDBCache::setSQLSources(const QStringList &list) { +void ISqlDB::setSQLSources(const QStringList &list) { auto db = writer(); if (db) db->setSQLSources(list); } -void ISqlDBCache::prepareForDelete() { +void ISqlDB::prepareForDelete() { globalUpdateDataBase(SqlDBCasheWriteMode::Force); } -bool ISqlDBCache::changeObjects(const DBObject &templateObject, +bool ISqlDB::changeObjects(const DBObject &templateObject, const std::function&)> &changeAction) { QList> list; @@ -285,15 +285,15 @@ bool ISqlDBCache::changeObjects(const DBObject &templateObject, return true; } -SqlDBCasheWriteMode ISqlDBCache::getMode() const { +SqlDBCasheWriteMode ISqlDB::getMode() const { return _mode; } -void ISqlDBCache::setMode(const SqlDBCasheWriteMode &mode) { +void ISqlDB::setMode(const SqlDBCasheWriteMode &mode) { _mode = mode; } -void ISqlDBCache::globalUpdateDataBasePrivate(qint64 currentTime) { +void ISqlDB::globalUpdateDataBasePrivate(qint64 currentTime) { QMutexLocker lock(&_saveLaterMutex); for (auto it = _changes.begin(); it != _changes.end(); ++it) { @@ -355,11 +355,11 @@ void ISqlDBCache::globalUpdateDataBasePrivate(qint64 currentTime) { setLastUpdateTime(currentTime); } -qint64 ISqlDBCache::getUpdateInterval() const { +qint64 ISqlDB::getUpdateInterval() const { return updateInterval; } -void ISqlDBCache::setUpdateInterval(const qint64 &value) { +void ISqlDB::setUpdateInterval(const qint64 &value) { updateInterval = value; } diff --git a/Heart/DataBaseSpace/isqldbcache.h b/Heart/DataBaseSpace/isqldb.h similarity index 95% rename from Heart/DataBaseSpace/isqldbcache.h rename to Heart/DataBaseSpace/isqldb.h index e501481d..9a841dc6 100644 --- a/Heart/DataBaseSpace/isqldbcache.h +++ b/Heart/DataBaseSpace/isqldb.h @@ -5,10 +5,9 @@ * of this license document, but changing it is not allowed. */ -#ifndef ISQLDBCACHE_H -#define ISQLDBCACHE_H +#ifndef ISQLDB_H +#define ISQLDB_H -#include "dbcachekey.h" #include "iobjectprovider.h" #include @@ -17,7 +16,6 @@ #include #include #include -#include "basedefines.h" #include "softdelete.h" namespace QH { @@ -55,7 +53,7 @@ enum class CacheAction: int { }; /** - * @brief The ISqlDBCache class it is db cache and bridge for DbWriters. + * @brief The ISqlDB class it is db cache and bridge for DbWriters. * Work Scheme of the database cache: * * \image html DatabseCache.svg width=800px @@ -71,19 +69,19 @@ enum class CacheAction: int { * If you try delete this object without using softDelete method then destructor of this object emit runtime error exception (on the debug mode only). * */ -class HEARTSHARED_EXPORT ISqlDBCache: public QObject, public iObjectProvider, public SoftDelete +class HEARTSHARED_EXPORT ISqlDB: public QObject, public iObjectProvider, public SoftDelete { Q_OBJECT public: /** - * @brief SqlDBCache This is default constructor of dbcache. + * @brief ISqlDB This is default constructor of dbcache. * @param updateInterval See the SqlDBCache::setUpdateInterval for more information. * @param mode See the SqlDBCache::setMode method for more information. */ - ISqlDBCache(qint64 updateInterval = DEFAULT_UPDATE_INTERVAL, + ISqlDB(qint64 updateInterval = DEFAULT_UPDATE_INTERVAL, SqlDBCasheWriteMode mode = SqlDBCasheWriteMode::Default); - ~ISqlDBCache() override; + ~ISqlDB() override; /** * @brief writer This method return is database writer object. For more inforamation about writer see the SqlDBWriter class. @@ -275,4 +273,4 @@ constexpr inline uint qHash(CacheAction action) { } -#endif // ISQLDBCACHE_H +#endif // ISQLDB_H diff --git a/Heart/DataBaseSpace/packages/abstractnetworkmember.cpp b/Heart/DataBaseSpace/packages/abstractnetworkmember.cpp deleted file mode 100644 index f4103ddd..00000000 --- a/Heart/DataBaseSpace/packages/abstractnetworkmember.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "abstractnetworkmember.h" -#include -#include -#include -#include - - -namespace QH { -namespace PKG { - -AbstractNetworkMember::AbstractNetworkMember() { - -} - -AbstractNetworkMember::AbstractNetworkMember(const Package &pkg): - AbstractNetworkMember() { - fromBytes(pkg.data); -} - -AbstractNetworkMember::AbstractNetworkMember(const QString& id): - AbstractNetworkMember() { - setId(id); -} - -bool AbstractNetworkMember::fromSqlRecord(const QSqlRecord &q) { - - setId(q.value("id").toString()); - setAuthenticationData(q.value("authenticationData").toByteArray()); - setTrust(q.value("trust").toInt()); - - return AbstractNetworkMember::isValid(); -} - -QByteArray AbstractNetworkMember::authenticationData() const { - return _authenticationData; -} - -void AbstractNetworkMember::setAuthenticationData(const QByteArray &publickKey) { - _authenticationData = publickKey; -} - -QDataStream &AbstractNetworkMember::fromStream(QDataStream &stream) { - DBObject::fromStream(stream); - - stream >> _id; - stream >> _authenticationData; - stream >> _trust; - - return stream; -} - -QDataStream &AbstractNetworkMember::toStream(QDataStream &stream) const { - stream << _id; - stream << _authenticationData; - stream << _trust; - return stream; -} - -DBVariantMap AbstractNetworkMember::variantMap() const { - - return {{"id", {_id, QH::PKG::MemberType::PrimaryKey}}, - {"authenticationData", {_authenticationData, QH::PKG::MemberType::InsertUpdate}}, - {"trust", {_trust, QH::PKG::MemberType::InsertUpdate}}, - - }; -} - -QString AbstractNetworkMember::primaryKey() const { - return "id"; -} - -QString AbstractNetworkMember::primaryValue() const { - return _id; -} - -const QString &AbstractNetworkMember::getId() const { - return _id; -} - -void AbstractNetworkMember::setId(const QString &newId) { - _id = newId; -} - -QString AbstractNetworkMember::table() const { - return "NetworkMembers"; -} - -int AbstractNetworkMember::trust() const { - return _trust; -} - -void AbstractNetworkMember::changeTrust(int diff) { - _trust += diff; -} - -void AbstractNetworkMember::setTrust(int trust) { - _trust = trust; -} - -bool AbstractNetworkMember::isValid() const { - return DBObject::isValid(); -} - -bool AbstractNetworkMember::copyFrom(const AbstractData * other) { - if (!DBObject::copyFrom(other)) - return false; - - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - this->_id = otherObject->_id; - this->_authenticationData = otherObject->_authenticationData; - this->_trust = otherObject->_trust; - - return true; -} - -} -} diff --git a/Heart/DataBaseSpace/packages/abstractnetworkmember.h b/Heart/DataBaseSpace/packages/abstractnetworkmember.h deleted file mode 100644 index 811fe565..00000000 --- a/Heart/DataBaseSpace/packages/abstractnetworkmember.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef ABSTRACTNETWORKMEMBER_H -#define ABSTRACTNETWORKMEMBER_H - -#include "dbobject.h" - - -namespace QH { -namespace PKG { - -/** - * @brief The AbstractNetworkMember class is structure of network member. - * Usually it is base informations of node or client. - */ -class HEARTSHARED_EXPORT AbstractNetworkMember: public DBObject -{ - QH_PACKAGE(AbstractNetworkMember, "AbstractNetworkMember") - -public: - AbstractNetworkMember(); - AbstractNetworkMember(const Package& pkg); - AbstractNetworkMember(const QString &id); - - // DBObject interface - bool fromSqlRecord(const QSqlRecord &q) override; - - /** - * @brief authenticationData is data array requirement for authentication node or client on the network. - * @return The byte Array of authentication data. - */ - QByteArray authenticationData() const; - - /** - * @brief setAuthenticationData This method set new array of authentication data. - * @param data This is new data of authentication data. - */ - void setAuthenticationData(const QByteArray &data); - - // AbstractData interface - bool isValid() const override; - bool copyFrom(const AbstractData *) override; - DBVariantMap variantMap() const override; - - /** - * @brief trust This is trust level of current Network member. - * IF the trust level less then 0 node or client will be blocked (banned). - * @return current trust level of this node. - */ - int trust() const; - - /** - * @brief changeTrust This method change a current trust level. - * @param diff This is a diff of current value. (currentTrust += diff;) - */ - void changeTrust(int diff); - - /** - * @brief setTrust This method set a new value of trust level of the node. - * @param trust This is a new value. - */ - void setTrust(int trust); - - /** - * @brief getId This method return id of this object in database. - * @return id of this object in database. - */ - const QString &getId() const; - - /** - * @brief setId This method sets new id of this object. - * @param newId This is new value of @a id of this object. - */ - void setId(const QString &newId); - - QString table() const override; -protected: - - // StreamBase interface - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - QString primaryKey() const override; - QString primaryValue() const override; - -private: - QString _id; - QByteArray _authenticationData; - int _trust; - - -}; -} -} -#endif // ABSTRACTNETWORKMEMBER_H diff --git a/Heart/DataBaseSpace/packages/authrequest.cpp b/Heart/DataBaseSpace/packages/authrequest.cpp deleted file mode 100644 index bf4ce505..00000000 --- a/Heart/DataBaseSpace/packages/authrequest.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "authrequest.h" - -#include - -namespace QH { - - -namespace PKG { -AuthRequest::AuthRequest() { - -} - -AuthRequest::AuthRequest(const Package &pkg) { - fromBytes(pkg.data); -} - -unsigned char AuthRequest::getRequestCmd() const { - return static_cast(_request); -} - -QDataStream &AuthRequest::fromStream(QDataStream &stream) { - UserMember::fromStream(stream); - stream >> _request; - return stream; -} - -QDataStream &AuthRequest::toStream(QDataStream &stream) const { - UserMember::toStream(stream); - stream << _request; - return stream; -} - - -void AuthRequest::setRequest(const UserRequestType &request) { - _request = request; -} - -} -} diff --git a/Heart/DataBaseSpace/packages/authrequest.h b/Heart/DataBaseSpace/packages/authrequest.h deleted file mode 100644 index cfc360ad..00000000 --- a/Heart/DataBaseSpace/packages/authrequest.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef AUTHREQUEST_H -#define AUTHREQUEST_H - -#include "usermember.h" - -#include - -namespace QH { - - -namespace PKG { - -/** - * @brief The UserRequestType enum is types of request. - */ -enum class UserRequestType: unsigned char { - /// Request to registration a new user. - SignUp, - /// Request to login an exists user. - LogIn, - /// Request to logout an exists user. This request remove the generated accesses token from server. - LogOut -}; - -/** - * @brief The AuthRequest class This class using for send to the SingleServer request to login or registration. - * Use the Request::getRequestCmd and Request::setRequestCmd methods for set an UserRequestType value. - */ -class HEARTSHARED_EXPORT AuthRequest: public UserMember, public Request -{ - QH_PACKAGE(AuthRequest, "AuthRequest") - -public: - AuthRequest(); - AuthRequest(const Package& pkg); - unsigned char getRequestCmd() const override; - - // StreamBase interface - /** - * @brief setRequest This method set request type for this object. - * @param request - */ - void setRequest(const UserRequestType &request); - -protected: - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - - -private: - UserRequestType _request; -}; -} -} -#endif // AUTHREQUEST_H diff --git a/Heart/DataBaseSpace/packages/dbobject.cpp b/Heart/DataBaseSpace/packages/dbobject.cpp index 4e9aa3da..a0a28321 100644 --- a/Heart/DataBaseSpace/packages/dbobject.cpp +++ b/Heart/DataBaseSpace/packages/dbobject.cpp @@ -6,7 +6,6 @@ */ #include "dbaddresskey.h" -#include "dbcachekey.h" #include "dbobject.h" #include #include @@ -327,14 +326,6 @@ bool DBObject::copyFrom(const AbstractData * other) { return AbstractData::copyFrom(other); } -unsigned int DBObject::subscribeId() const { - return dbKey(); -} - -unsigned int DBObject::subscribeId(const DbAddress &address) { - return HASH_KEY(DbAddressKey(address)); -} - bool DBObject::isHaveAPrimaryKey() const { return primaryKey().size(); } diff --git a/Heart/DataBaseSpace/packages/dbobject.h b/Heart/DataBaseSpace/packages/dbobject.h index 1bb3650c..8d291d00 100644 --- a/Heart/DataBaseSpace/packages/dbobject.h +++ b/Heart/DataBaseSpace/packages/dbobject.h @@ -12,9 +12,6 @@ #include "abstractdata.h" #include "heart_global.h" #include "dbaddress.h" -#include "basedefines.h" -#include "dbcachekey.h" -#include "isubscribabledata.h" class QSqlQuery; @@ -96,7 +93,7 @@ typedef QMap DBVariantMap; * @warning Object with empty table name is invalid. * @see DataBaseNode */ -class HEARTSHARED_EXPORT DBObject : public AbstractData, public ISubscribableData +class HEARTSHARED_EXPORT DBObject : public AbstractData { QH_PACKAGE(DBObject, "DBObject") @@ -108,14 +105,6 @@ class HEARTSHARED_EXPORT DBObject : public AbstractData, public ISubscribableDat bool isValid() const override; bool copyFrom(const AbstractData * other) override; - unsigned int subscribeId() const override; - - /** - * @brief subscribeId This static method convert database address to the subscribe id. - * @param address This is input value of the database address. - * @return subscribe id. - */ - static unsigned int subscribeId(const DbAddress& address); /** * @brief isHaveAPrimaryKey This method return true if this object has a primary key. diff --git a/Heart/DataBaseSpace/packages/defaultpermision.cpp b/Heart/DataBaseSpace/packages/defaultpermision.cpp deleted file mode 100644 index 49a26b2a..00000000 --- a/Heart/DataBaseSpace/packages/defaultpermision.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2021-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "defaultpermision.h" -namespace QH { -namespace PKG { - -DefaultPermision::DefaultPermision(): - MemberPermisionObject() { - -} - -DefaultPermision::DefaultPermision(const PermisionData &permision): - DefaultPermision() { - setKey(permision); -} - -DBVariantMap DefaultPermision::variantMap() const { - return {{"dbAddress", {key().addressHash(), MemberType::PrimaryKey}}, - {"lvl", {static_cast(permisions()), MemberType::InsertUpdate}}}; -} - -bool DefaultPermision::isValid() const { - return key().addressHash().size(); -} - -DBObject *DefaultPermision::createDBObject() const { - return create(); -} - -bool DefaultPermision::fromSqlRecord(const QSqlRecord &q) { - PermisionData permision({}, q.value("dbAddress").toString()); - - setKey(permision); - - setPermisions(static_cast(q.value("lvl").toUInt())); - return isValid(); -} - -QString DefaultPermision::condition() const { - QString result; - - result += "dbAddress='" + key().addressHash() + "'"; - return result; -} - -QString DefaultPermision::table() const { - return "DefaultPermissions"; -} - -} -} diff --git a/Heart/DataBaseSpace/packages/defaultpermision.h b/Heart/DataBaseSpace/packages/defaultpermision.h deleted file mode 100644 index 79cfa261..00000000 --- a/Heart/DataBaseSpace/packages/defaultpermision.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2021-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef DEFAULTPERMISION_H -#define DEFAULTPERMISION_H - -#include "memberpermisionobject.h" -#include "permission.h" - - -namespace QH { -namespace PKG { - -/** - * @brief The DefaultPermision class contains default of network members - * This class works with the DefaultPermissions sql table. - */ -class HEARTSHARED_EXPORT DefaultPermision: public MemberPermisionObject -{ - QH_PACKAGE(DefaultPermision, "DefaultPermision") - -public: - DefaultPermision(); - DefaultPermision(const PermisionData& permision); - - DBVariantMap variantMap() const override; - - bool isValid() const override; - - bool fromSqlRecord(const QSqlRecord &q) override; - DBObject *createDBObject() const override; - QString condition() const override; - - QString table () const override; -}; -} -} -#endif // DEFAULTPERMISION_H diff --git a/Heart/DataBaseSpace/packages/isubscribabledata.cpp b/Heart/DataBaseSpace/packages/isubscribabledata.cpp deleted file mode 100644 index 46164928..00000000 --- a/Heart/DataBaseSpace/packages/isubscribabledata.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2021-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "isubscribabledata.h" -namespace QH { -namespace PKG { - -ISubscribableData::ISubscribableData() { - -} -} -} diff --git a/Heart/DataBaseSpace/packages/isubscribabledata.h b/Heart/DataBaseSpace/packages/isubscribabledata.h deleted file mode 100644 index 0407d22f..00000000 --- a/Heart/DataBaseSpace/packages/isubscribabledata.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2021-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef ISUBSCRIBABLEDATA_H -#define ISUBSCRIBABLEDATA_H -#include "heart_global.h" -#include - -namespace QH { - -namespace PKG { - - -/** - * @brief The ISubscribableData class is interface provide subscribe functionality. - * If you want to create a data object with support of the subscribe functionality then you need to inherit form this class. - */ -class HEARTSHARED_EXPORT ISubscribableData -{ -public: - ISubscribableData(); - - /** - * @brief subscribeId All subscribable object should be override this method. - * This method should be return signed int id. - * @return unique id of the subscribe object. - */ - virtual unsigned int subscribeId() const = 0; -}; -} -} - -#endif // ISUBSCRIBABLEDATA_H diff --git a/Heart/DataBaseSpace/packages/memberpermisionobject.cpp b/Heart/DataBaseSpace/packages/memberpermisionobject.cpp deleted file mode 100644 index e2cb2023..00000000 --- a/Heart/DataBaseSpace/packages/memberpermisionobject.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "memberpermisionobject.h" - -#include -#include -#include - -namespace QH { -namespace PKG { - -MemberPermisionObject::MemberPermisionObject() { - -} - -MemberPermisionObject::MemberPermisionObject(const Package &pkg): - MemberPermisionObject() { - fromBytes(pkg.data); - -} - -MemberPermisionObject::MemberPermisionObject(const PermisionData &id): - MemberPermisionObject() { - setKey(id); -} - -bool MemberPermisionObject::isValid() const { - return _key.isValid(); -} - -bool MemberPermisionObject::copyFrom(const AbstractData *other) { - if (!DBObject::copyFrom(other)) - return false; - - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - this->_key = otherObject->_key; - this->_permision = otherObject->_permision; - - return true; -} - -DBObject *MemberPermisionObject::createDBObject() const { - return create(); -} - -uint MemberPermisionObject::dbKey() const { - return HASH_KEY(_key); -} - -bool MemberPermisionObject::fromSqlRecord(const QSqlRecord &q) { - - PermisionData permision(q.value("memberId").toString(), - q.value("dbAddress").toString()); - - setKey(permision); - - setPermisions(static_cast(q.value("lvl").toUInt())); - return isValid(); -} - -bool MemberPermisionObject::isCached() const { - return true; -} - -QDataStream &MemberPermisionObject::fromStream(QDataStream &stream) { - - stream >> _key; - stream >> _permision; - - return stream; -} - -QDataStream &MemberPermisionObject::toStream(QDataStream &stream) const { - stream << _key; - stream << _permision; - - return stream; -} - -DBVariantMap MemberPermisionObject::variantMap() const { - return {{"memberId", {_key.id(), MemberType::InsertUpdate}}, - {"dbAddress", {_key.addressHash(), MemberType::InsertUpdate}}, - {"lvl", {static_cast(_permision), MemberType::InsertUpdate}}}; -} - -QString MemberPermisionObject::table() const { - return "MemberPermisions"; -} - -QString MemberPermisionObject::condition() const { - QString result; - if (_key.id().isValid()) { - result += "memberId='" + _key.id().toString() + "'"; - } - - if (_key.addressHash().size()) { - if (result.size()) { - result += " AND "; - } - result += "dbAddress='" + _key.addressHash()+ "'"; - } - - return result; -} - -QString MemberPermisionObject::primaryKey() const { - return ""; -} - -QString MemberPermisionObject::primaryValue() const { - return ""; -} - -PermisionData MemberPermisionObject::key() const { - return _key; -} - -void MemberPermisionObject::setKey(const PermisionData &key) { - _key = key; -} - -Permission MemberPermisionObject::permisions() const { - return _permision; -} - -void MemberPermisionObject::setPermisions(const Permission &permisions) { - _permision = permisions; -} -} -} diff --git a/Heart/DataBaseSpace/packages/memberpermisionobject.h b/Heart/DataBaseSpace/packages/memberpermisionobject.h deleted file mode 100644 index 9532b180..00000000 --- a/Heart/DataBaseSpace/packages/memberpermisionobject.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef NODESPERMISIONOBJECT_H -#define NODESPERMISIONOBJECT_H - -#include "dbcachekey.h" -#include "dbobject.h" -#include "permisiondata.h" -#include "permission.h" - -namespace QH { -namespace PKG { - -/** - * @brief The NodesPermisionObject class contains permissions data of node or client. - * This class is representation of database object from the MemberPermisions table. - */ -class HEARTSHARED_EXPORT MemberPermisionObject: public DBObject -{ - QH_PACKAGE(MemberPermisionObject, "MemberPermisionObject") - -public: - MemberPermisionObject(); - MemberPermisionObject(const Package& pkg); - MemberPermisionObject(const PermisionData& id); - - // AbstractData interface - bool isValid() const override; - bool copyFrom(const AbstractData *other) override; - - // DBObject interface - DBObject *createDBObject() const override; - uint dbKey() const override; - bool fromSqlRecord(const QSqlRecord &q) override; - bool isCached() const override; - DBVariantMap variantMap() const override; - - QString table() const override; - - /** - * @brief permisions This method return value permission of object. - * For select object set it id using a MemberPermisionObject::setKey method. - * @return Permission level. For more information see the Permission enum. - */ - Permission permisions() const; - - /** - * @brief setPermisions This method set a new value of permissions level. - * @param permisions This is a new value of permissions. - */ - void setPermisions(const Permission &permisions); - - /** - * @brief key This method return key (database address) of a checked object. - * @return PermisionData key. For more information see PermisionData class. - */ - PermisionData key() const; - - /** - * @brief setKey This method set new value of PermisionData. - * @param key This is new value of PermisionData. - */ - void setKey(const PermisionData &key); - -protected: - - // StreamBase interface - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - QString condition() const override; - QString primaryKey() const override; - QString primaryValue() const override; - -private: - Permission _permision; - PermisionData _key; - -}; -} -} -#endif // NODESPERMISIONOBJECT_H diff --git a/Heart/DataBaseSpace/packages/networkmember.cpp b/Heart/DataBaseSpace/packages/networkmember.cpp deleted file mode 100644 index a808e24c..00000000 --- a/Heart/DataBaseSpace/packages/networkmember.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "networkmember.h" - -namespace QH { -namespace PKG { - -NetworkMember::NetworkMember() { - -} - -NetworkMember::NetworkMember(const QString &id): AbstractNetworkMember(id) { - -} - -DBObject *NetworkMember::createDBObject() const { - return create(); -} -} - -} diff --git a/Heart/DataBaseSpace/packages/networkmember.h b/Heart/DataBaseSpace/packages/networkmember.h deleted file mode 100644 index a68b9c0e..00000000 --- a/Heart/DataBaseSpace/packages/networkmember.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef NETWORKMEMBER_H -#define NETWORKMEMBER_H - -#include - -namespace QH { -namespace PKG { - -/** - * @brief The NetworkMember class is base implementation of the AbstractNetworkMember. - * This class contains all default settings of the AbstractNetworkMember class. - * If you want to create a own member class then use the AbstractNetworkMember class. - */ -class HEARTSHARED_EXPORT NetworkMember: public AbstractNetworkMember -{ - QH_PACKAGE(NetworkMember, "NetworkMember") - -public: - NetworkMember(); - NetworkMember(const QString& id); - -public: - DBObject *createDBObject() const override; -}; - -} -} -#endif // NETWORKMEMBER_H diff --git a/Heart/DataBaseSpace/packages/usermember.cpp b/Heart/DataBaseSpace/packages/usermember.cpp deleted file mode 100644 index 32207209..00000000 --- a/Heart/DataBaseSpace/packages/usermember.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "usermember.h" - -#include -namespace QH { -namespace PKG { - -UserMember::UserMember() { - setTrust(100); -} - -UserMember::UserMember(const Package &pkg): - UserMember() { - fromBytes(pkg.data); -} - -UserMember::UserMember(const QString &id): - UserMember() { - setId(id); -} - -bool UserMember::copyFrom(const AbstractData *other) { - if (!AbstractNetworkMember::copyFrom(other)) - return false; - - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - this->_token = otherObject->_token; - - return true; -} - -bool UserMember::fromSqlRecord(const QSqlRecord &q) { - if (!AbstractNetworkMember::fromSqlRecord(q)) { - return false; - } - - setSignToken(AccessToken(q.value("token").toByteArray())); - - return UserMember::isValid(); -} - -DBObject *UserMember::createDBObject() const { - return create(); -} - -bool UserMember::isValid() const { - return AbstractNetworkMember::isValid() && trust() <= 100; -} - -QDataStream &UserMember::fromStream(QDataStream &stream) { - AbstractNetworkMember::fromStream(stream); - stream >> _token; - - return stream; -} - -QDataStream &UserMember::toStream(QDataStream &stream) const { - AbstractNetworkMember::toStream(stream); - stream << _token; - - return stream; -} - -const AccessToken &UserMember::getSignToken() const { - return _token; -} - - -DBVariantMap UserMember::variantMap() const { - auto map = AbstractNetworkMember::variantMap(); - map.insert("token", {_token.toBytes(), MemberType::InsertUpdate}); - - return map; -} - -void UserMember::setSignToken(const AccessToken &token) { - _token = token; -} -} -} diff --git a/Heart/DataBaseSpace/packages/usermember.h b/Heart/DataBaseSpace/packages/usermember.h deleted file mode 100644 index 7076f4eb..00000000 --- a/Heart/DataBaseSpace/packages/usermember.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef USER_H -#define USER_H - -#include "abstractnetworkmember.h" -#include "accesstoken.h" - -#include "itoken.h" - -namespace QH { - - -namespace PKG { - - -/** - * @brief The UserMember class is some as a AbstractNetworkMember class. - * All registered users on the singelServer have own list database object with own permissions. - * If you want create a custom permissions table with the custom user then override this class. - * - * @note The UserMember class has no members of its own, so it is safe to use static_cast on User <<>> AbstractNetworkMember. - */ -class HEARTSHARED_EXPORT UserMember: public AbstractNetworkMember -{ - QH_PACKAGE(UserMember, "UserMember") - -public: - UserMember(); - UserMember(const Package &pkg); - UserMember(const QString &id); - - bool copyFrom(const AbstractData *other) override; - bool fromSqlRecord(const QSqlRecord &q) override; - DBObject *createDBObject() const override; - bool isValid() const override; - DBVariantMap variantMap() const override; - - void setSignToken(const AccessToken &token); - const AccessToken &getSignToken() const; - -protected: - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - -private: - - AccessToken _token; - -}; -} -} -#endif // USER_H diff --git a/Heart/DataBaseSpace/packages/websocket.cpp b/Heart/DataBaseSpace/packages/websocket.cpp deleted file mode 100644 index ba389322..00000000 --- a/Heart/DataBaseSpace/packages/websocket.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "websocket.h" - -#include -#include -namespace QH { -namespace PKG { - -WebSocket::WebSocket(): AbstractData(){ - -} - -WebSocket::WebSocket(const Package &package): - WebSocket() { - fromBytes(package.data); - -} - -QDataStream &WebSocket::fromStream(QDataStream &stream) { - stream >> _request; - stream >> _subscribeId; - - return stream; -} - -QDataStream &WebSocket::toStream(QDataStream &stream) const { - stream << _request; - stream << _subscribeId; - - return stream; -} - -unsigned char WebSocket::getRequestCmd() const { - return static_cast(_request); -} - -unsigned int WebSocket::subscribeId() const { - return _subscribeId; -} - -void WebSocket::setSubscribeId(unsigned int address) { - _subscribeId = address; -} - -void WebSocket::setRequestCommnad(const WebSocketRequest &requset) { - _request = requset; -} - -bool WebSocket::isValid() const { - return _request > WebSocketRequest::Invalied - && AbstractData::isValid(); -} - -} -} diff --git a/Heart/DataBaseSpace/packages/websocket.h b/Heart/DataBaseSpace/packages/websocket.h deleted file mode 100644 index 210ea20a..00000000 --- a/Heart/DataBaseSpace/packages/websocket.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef WEBSOCKET_H -#define WEBSOCKET_H - -#include "dbobject.h" -#include "request.h" - - -namespace QH { -namespace PKG { - -/** - * @brief The WebSocketRequest enum This enum is list of available request of WebSocket functions. - */ -enum class WebSocketRequest { - /// This is value for reserve invalid data. All request must be not equal 0. - Invalied = 0, - /// Subscribe to changes of the databases object. - Subscribe = 1, - - /// Subscribe to changes of the databases object. - Unsubscribe = 2, - - /// send request of get a list of current subscribes. - SubscribeList = 3 -}; - -/** - * @brief The WebSocket class is contains methods for work with stream data. - */ -class HEARTSHARED_EXPORT WebSocket: - public AbstractData, public Request -{ - QH_PACKAGE(WebSocket, "WebSocket") - -public: - WebSocket(); - WebSocket(const Package& package); - - bool isValid() const override; - - /** - * @brief subscribeId This method return address(unique id) of the subscribe object. - * @return unique id of the subscribe object. - */ - unsigned int subscribeId() const; - - /** - * @brief setSubscribeId This method set a unique id of the subscribe object. - * @param address This is a new database unique id of the subscribe object. - */ - void setSubscribeId(unsigned int address); - - /** - * @brief setRequestCommnad This method sets requset command. - * @param requset This is new request command. - */ - void setRequestCommnad(const WebSocketRequest& requset); - - unsigned char getRequestCmd() const override; -protected: - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - -private: - unsigned int _subscribeId; - WebSocketRequest _request = WebSocketRequest::Invalied; - // Request interface - -}; - -} -} -#endif // WEBSOCKET_H diff --git a/Heart/DataBaseSpace/packages/websocketsubscriptions.cpp b/Heart/DataBaseSpace/packages/websocketsubscriptions.cpp deleted file mode 100644 index 199e43b0..00000000 --- a/Heart/DataBaseSpace/packages/websocketsubscriptions.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "websocketsubscriptions.h" - -#include - -namespace QH { -namespace PKG { - -WebSocketSubscriptions::WebSocketSubscriptions() -{ - - -} - -WebSocketSubscriptions::WebSocketSubscriptions(const QH::Package &package): - WebSocketSubscriptions() -{ - fromBytes(package.data); - -} - -QDataStream &WebSocketSubscriptions::fromStream(QDataStream &stream) { - - return stream >> _subscribeIds; -} - -QDataStream &WebSocketSubscriptions::toStream(QDataStream &stream) const { - - return stream << _subscribeIds; -} - -QSet WebSocketSubscriptions::addresses() const { - return _subscribeIds; -} - -void WebSocketSubscriptions::setAddresses(const QSet &addresses) { - _subscribeIds = addresses; -} - -} -} - diff --git a/Heart/DataBaseSpace/packages/websocketsubscriptions.h b/Heart/DataBaseSpace/packages/websocketsubscriptions.h deleted file mode 100644 index f6a388c3..00000000 --- a/Heart/DataBaseSpace/packages/websocketsubscriptions.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef WEBSOCKETSUBSCRIPTIONS_H -#define WEBSOCKETSUBSCRIPTIONS_H - -#include "abstractdata.h" - -#include -#include - - -namespace QH { -namespace PKG { - -/** - * @brief The WebSocketSubscriptions class is list of subscribers object. - * Using for transporting a informations about subscribers. - */ -class HEARTSHARED_EXPORT WebSocketSubscriptions: public AbstractData -{ - QH_PACKAGE(WebSocketSubscriptions, "WebSocketSubscriptions") - -public: - WebSocketSubscriptions(); - WebSocketSubscriptions(const Package& package); - - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - - /** - * @brief addresses This is list of subscribers. - */ - QSet addresses() const; - - /** - * @brief setAddresses This method set a new list of subscribers. - * @param addresses This is a new list of subscribers. - */ - void setAddresses(const QSet &addresses); - -private: - QSet _subscribeIds; - - -}; - -} -} -#endif // WEBSOCKETSUBSCRIPTIONS_H diff --git a/Heart/DataBaseSpace/permisiondata.cpp b/Heart/DataBaseSpace/permisiondata.cpp deleted file mode 100644 index 75c3dec1..00000000 --- a/Heart/DataBaseSpace/permisiondata.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "dbaddress.h" -#include "permisiondata.h" -#include -#include -#include - -namespace QH { - -bool operator ==(const PermisionData &left, const PermisionData &right) { - return left._id == right._id && left._addressHash == right._addressHash; -} - -PermisionData::PermisionData(const QVariant &subject, const DbAddress &objcet) { - setId(subject); - setAddress(objcet); -} - -PermisionData::PermisionData(const QVariant &subject, const QString &objectAddress) { - setId(subject); - setAddress(objectAddress); -} - -unsigned int PermisionData::hash() const { - QByteArray data; - QDataStream stream(&data, QIODevice::WriteOnly); - - stream << _id; - stream << _addressHash; - return qHash(data); -} - -bool PermisionData::isValid() const { - return _addressHash.size() && _id.isValid(); -} - -bool PermisionData::equal(const AbstractKey *other) const { - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - return _addressHash == otherObject->_addressHash && _id == otherObject->_id; -} - -QString PermisionData::toString() const { - return QString("DBAddressHash: %0, Owner Id: %1"). - arg(_addressHash, _id.toString()); -} - -const QString& PermisionData::addressHash() const { - return _addressHash; -} - -void PermisionData::setAddress(const DbAddress &address) { - setAddress(address.SHA256Hash().toBase64(QByteArray::Base64UrlEncoding)); -} - -void PermisionData::setAddress(const QString &addressHash) { - _addressHash = addressHash; -} - -QDataStream &PermisionData::fromStream(QDataStream &stream) { - stream >> _id; - stream >> _addressHash; - - return stream; -} - -QDataStream &PermisionData::toStream(QDataStream &stream) const { - stream << _id; - stream << _addressHash; - - return stream; -} - -const QVariant& PermisionData::id() const { - return _id; -} - -void PermisionData::setId(const QVariant &Id) { - _id = Id; -} - -} diff --git a/Heart/DataBaseSpace/permisiondata.h b/Heart/DataBaseSpace/permisiondata.h deleted file mode 100644 index 805056ab..00000000 --- a/Heart/DataBaseSpace/permisiondata.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef PERMISIONDATA_H -#define PERMISIONDATA_H - -#include -#include -#include "dbaddress.h" - -namespace QH { - -/** - * @brief The PermisionData class stores one correspondence to a network member and an object in the database. - * Network member - database address. - */ -class HEARTSHARED_EXPORT PermisionData: public AbstractKey, public StreamBase { - -public: - - PermisionData() = default; - PermisionData(const QVariant& subject, const DbAddress& objcet); - PermisionData(const QVariant& subject, const QString& objectAddress); - - friend bool operator == (const PermisionData& left, const PermisionData& right); - unsigned int hash() const override; - bool isValid() const override; - bool equal(const AbstractKey *other) const override; - QString toString() const override; - - /** - * @brief setId This method set id of Network member. - * @param Id Value of network member id. - */ - void setId(const QVariant &Id); - - /** - * @brief addressHash This method return sha256 hash of the address of database object. - * The hash encoded as a base64. - * @return address of database object. - */ - const QString &addressHash() const; - - /** - * @brief setAddress This method set address of database object. - * @param address This is new value of database address. - */ - void setAddress(const DbAddress &address); - - /** - * @brief setAddress This implementation sets sha256 hash of the address (hash must be write in base64 encoding) - * @param addressHash This is base64 string of a sha256 hash code. - */ - void setAddress(const QString &addressHash); - - // StreamBase interface - const QVariant &id() const; - -protected: - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - -private: - - /// id of user of node - QVariant _id; - - /// table of target object (second part of key) - QString _addressHash; - -}; - -} -#endif // PERMISIONDATA_H diff --git a/Heart/DataBaseSpace/permission.h b/Heart/DataBaseSpace/permission.h deleted file mode 100644 index 93e4f396..00000000 --- a/Heart/DataBaseSpace/permission.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef PERMISIONS_H -#define PERMISIONS_H -namespace QH { - -/** - * @brief The Permission enum - * permision to data in database - */ -enum class Permission: unsigned char { - /// The network member do not have any permissions for an object. - NoPermission = 0x00, - /// The network member can read a object. - Read = 0x01, - /// The network member can Read and Write a new data into object. But can not be removed. - Update = 0x02, - /// The network member have all permissions to an object. - Write = 0x03, -}; - -} -#endif // PERMISIONS_H diff --git a/Heart/DataBaseSpace/singlebase.cpp b/Heart/DataBaseSpace/singlebase.cpp deleted file mode 100644 index 59910834..00000000 --- a/Heart/DataBaseSpace/singlebase.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "itoken.h" -#include "singlebase.h" - -#include -#include -#include -#include "usermember.h" - -namespace QH { - -SingleBase::SingleBase() { - registerPackageType(); - -} - -bool SingleBase::checkToken(const PKG::AbstractData *pkg) const { - return dynamic_cast(pkg); -} - -} diff --git a/Heart/DataBaseSpace/singlebase.h b/Heart/DataBaseSpace/singlebase.h deleted file mode 100644 index 1ba4f1e3..00000000 --- a/Heart/DataBaseSpace/singlebase.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef SINGLESERVERBASE_H -#define SINGLESERVERBASE_H - -#include "databasenode.h" - - -namespace QH { - -/** - * @brief The SingleServerBase class This is base class of SingleClient adn SingleServer - */ -class HEARTSHARED_EXPORT SingleBase: public DataBaseNode -{ - Q_OBJECT -public: - SingleBase(); - -protected: - /** - * @brief checkToken This method check pkg on token validation support. - * @param pkg This is parsed package. - * @return true if the package not support token validation. - * - * For get more information see IToken class. - */ - bool checkToken(const PKG::AbstractData *pkg) const; -}; -} -#endif // SINGLESERVERBASE_H diff --git a/Heart/DataBaseSpace/singleclient.cpp b/Heart/DataBaseSpace/singleclient.cpp deleted file mode 100644 index 86751522..00000000 --- a/Heart/DataBaseSpace/singleclient.cpp +++ /dev/null @@ -1,521 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "singleclient.h" -#include "quasarapp.h" -#include "authrequest.h" -#include "dberrorcodes.h" - -#include -#include -#include -#include - -namespace QH { - -SingleClient::SingleClient() { - - qRegisterMetaType(); - - setMaxPendingConnections(1); - - registerPackageType(); - - connect(this, &SingleClient::requestError, - this, &SingleClient::handleError); -} - -ParserResult SingleClient::parsePackage(const QSharedPointer &pkg, - const Header& pkgHeader, - const AbstractNodeInfo* sender) { - - auto parentResult = DataBaseNode::parsePackage(pkg, pkgHeader, sender); - if (parentResult != QH::ParserResult::NotProcessed) { - return parentResult; - } - - if (QH::PKG::UserMember::command() == pkg->cmd()) { - QH::PKG::UserMember *obj = static_cast(pkg.data()); - - if (!(obj->isValid() && obj->getSignToken().isValid())) { - return ParserResult::Error; - } - - setMember(*obj); - setStatus(ClientStatus::Logined); - - emit currentUserChanged(); - - return QH::ParserResult::Processed; - - } else if (PKG::WebSocketSubscriptions::command() == pkg->cmd()) { - PKG::WebSocketSubscriptions *obj = static_cast(pkg.data()); - if (!obj->isValid()) { - return ParserResult::Error; - } - - setSubscribersList(obj->addresses()); - return ParserResult::Processed; - } - - handleRestRequest(pkg, pkgHeader); - - return QH::ParserResult::NotProcessed; -} - -ClientStatus SingleClient::getStatus() const { - return _status; -} - -bool SingleClient::login(const QString &userId, const QString &rawPassword) { - if (getStatus() < ClientStatus::Connected) { - QuasarAppUtils::Params::log("You try make login on the offline client." - " Please wait of ClientStatus::Connected status.", - QuasarAppUtils::Error); - return false; - } - - if (!p_login(userId, hashgenerator(rawPassword.toLatin1()))) { - return false; - }; - - if (getStatus() < ClientStatus::Loginning) { - setStatus(ClientStatus::Loginning); - } - - return true; -} - -bool SingleClient::login(const PKG::UserMember &memberData) { - - if (memberData.getSignToken() == getMember().getSignToken()) { - if (isLogined()) { - return true; - } - - return login(); - } - - setMember(memberData); - return login(); -} - -bool SingleClient::logout() { - if (getStatus() < ClientStatus::Logined) { - QuasarAppUtils::Params::log("You try logout on the not Loggined client." - " Please wait of ClientStatus::Logined status.", - QuasarAppUtils::Error); - return false; - } - - - QH::PKG::AuthRequest request; - request.copyFrom(&getMember()); - request.setRequest(PKG::UserRequestType::LogOut); - - if (!sendData(&request, realServerAddress())) { - return false; - }; - - resetUser(); - - return true; -} - -bool SingleClient::signup(const QString &userId, const QString &rawPassword) { - if (getStatus() < ClientStatus::Connected) { - QuasarAppUtils::Params::log("You try make signup on the offline client." - " Please wait of ClientStatus::Connected status.", - QuasarAppUtils::Error); - return false; - } - - if (!p_signup(userId, hashgenerator(rawPassword.toLatin1()))) { - return false; - }; - - if (getStatus() < ClientStatus::Loginning) { - setStatus(ClientStatus::Loginning); - } - - return true; -} - -bool SingleClient::removeUser() { - if (getStatus() < ClientStatus::Logined) { - QuasarAppUtils::Params::log("You try make remove on the not Loggined client." - " Please wait of ClientStatus::Logined status.", - QuasarAppUtils::Error); - return false; - } - - - QH::PKG::DeleteObject request; - request.setAddress(getMember().dbAddress()); - - if (!sendData(&request, realServerAddress())) { - return false; - }; - - return true; -} - -bool SingleClient::connectToServer() { - if (getStatus() >= ClientStatus::Connected) { - QuasarAppUtils::Params::log(" This client alredy connected to server.", - QuasarAppUtils::Warning); - return true; - } - - if (getStatus() < ClientStatus::Connecting) { - setStatus(ClientStatus::Connecting); - } - auto address = serverAddress(); - DataBaseNode::addNode(address.first, address.second); - - return true; -} - -void SingleClient::disconnectFromServer() { - if (getStatus() == ClientStatus::Dissconnected) { - return; - } - - DataBaseNode::removeNode(realServerAddress()); -} - -void SingleClient::setStatus(const ClientStatus &status) { - if (status == _status) - return; - - auto oldStatus = _status; - - if (status == ClientStatus::Connecting || status == ClientStatus::Loginning) { - QTimer::singleShot(WAIT_RESPOCE_TIME, this, [this, oldStatus]() { - if (_status == ClientStatus::Connecting || _status == ClientStatus::Loginning) { - setStatus(oldStatus); - emit requestError(static_cast(ErrorCodes::TimeOutError), - ErrorCodes::DBErrorCodesHelper::toString(ErrorCodes::TimeOutError)); - } - }); - } - - _status = status; - emit statusChanged(_status); -} - -void SingleClient::handleError(unsigned char code, QString error) { - QuasarAppUtils::Params::log(error, QuasarAppUtils::Error); - - if (code != ErrorCodes::NoError && getStatus() == ClientStatus::Loginning) { - setStatus(ClientStatus::Connected); - } - - _lastError = code; -} - -bool SingleClient::p_login(const QString &userId, const QByteArray &hashPassword) { - const auto &userMember = getMember(); - if ((userId.isEmpty() || hashPassword.isEmpty()) && !userMember.isValid()) { - return false; - } - - QH::PKG::AuthRequest request; - if (userId.isEmpty()) - request.setId(userMember.getId()); - else - request.setId(userId); - - request.setRequest(QH::PKG::UserRequestType::LogIn); - - if (hashPassword.isEmpty()) { - if (!userMember.getSignToken().isValid()) { - return false; - } - - request.setSignToken(userMember.getSignToken()); - } else { - request.setAuthenticationData(hashPassword); - } - - return sendData(&request, realServerAddress()); -} - -bool SingleClient::p_signup(const QString &userId, const QByteArray &hashPassword) { - QH::PKG::AuthRequest request; - request.setId(userId); - request.setAuthenticationData(hashPassword); - request.setRequest(QH::PKG::UserRequestType::SignUp); - - return sendData(&request, realServerAddress()); -} - -void SingleClient::handleRestRequest(const QSharedPointer &pkg, - const Header& pkgHeader) { - QMutexLocker lock(&_handlerCacheMutex); - - if (_handlersCache.contains(pkgHeader.triggerHash)) { - auto action = _handlersCache.take(pkgHeader.triggerHash); - action(pkg); - } -} - -void SingleClient::setRealServerAddress(const HostAddress &realServerAddress) { - _realServerAddress = realServerAddress; -} - -void SingleClient::addToSubscribesList(unsigned int id) { - QMutexLocker lock(&_subscribesMutex); - _subscribes.insert(id); -} - -void SingleClient::removeFromSubscribesList(unsigned int id) { - QMutexLocker lock(&_subscribesMutex); - _subscribes.remove(id); -} - -void SingleClient::setSubscribersList(QSet ids) { - QMutexLocker lock(&_subscribesMutex); - _subscribes = ids; -} - -const HostAddress &SingleClient::realServerAddress() const { - return _realServerAddress; -} - -void SingleClient::nodeErrorOccured(AbstractNodeInfo *nodeInfo, - QAbstractSocket::SocketError errorCode, - QString errorString) { - - setStatus(ClientStatus::Dissconnected); - SingleBase::nodeErrorOccured(nodeInfo, errorCode, errorString); -} - -const PKG::UserMember &SingleClient::getMember() const { - return _member; -} - -QPair SingleClient::serverAddress() const { - return {"localhost", DEFAULT_PORT}; -} - -void SingleClient::nodeConfirmend(AbstractNodeInfo *node) { - Q_UNUSED(node) -} - -void QH::SingleClient::nodeConnected(AbstractNodeInfo *node) { - - debug_assert(!realServerAddress().isValid(), - "Internal Error detected in " - "the QH::SingleClient::nodeConnected(AbstractNodeInfo *node) method" - " If you see this error message" - " please send your bug report to the official github page" - " https://github.com/QuasarApp/Heart/issues/new" ); - - - setRealServerAddress(node->networkAddress()); - - setStatus(ClientStatus::Connected); -} - -void QH::SingleClient::nodeDisconnected(AbstractNodeInfo *node) { - Q_UNUSED(node) - setRealServerAddress(HostAddress{}); - - setStatus(ClientStatus::Dissconnected); -} - -unsigned int SingleClient::sendData(const PKG::AbstractData *resp, - const HostAddress &address, - const Header *req) { - - return DataBaseNode::sendData(resp, address, req); -} - -unsigned int SingleClient::sendData(const PKG::AbstractData *resp, - const AbstractNodeInfo *node, - const Header *req) { - - return DataBaseNode::sendData(resp, node, req); -} - -unsigned int SingleClient::sendData(const PKG::AbstractData *resp, - const QVariant &nodeId, - const Header *req) { - - return DataBaseNode::sendData(resp, nodeId, req); -} - -unsigned int SingleClient::sendData(PKG::AbstractData *resp, - const HostAddress &address, - const Header *req) { - if (!signPackageWithToken(resp)) { - return 0; - } - - return DataBaseNode::sendData(resp, address, req); -} - -unsigned int SingleClient::sendData(PKG::AbstractData *resp, - const AbstractNodeInfo *node, - const Header *req) { - if (!signPackageWithToken(resp)) { - return 0; - } - - return DataBaseNode::sendData(resp, node, req); -} - -unsigned int SingleClient::sendData(PKG::AbstractData *resp, - const QVariant &nodeId, - const Header *req) { - if (!signPackageWithToken(resp)) { - return 0; - } - - return DataBaseNode::sendData(resp, nodeId, req); -} - -void SingleClient::resetUser() { - setMember({}); - if (getStatus() > ClientStatus::Connected) - setStatus(ClientStatus::Connected); -} - -void SingleClient::setMember(const PKG::UserMember &member) { - QMutexLocker lock (&_handlerMemberMutex); - _member = member; -} - -ErrorCodes::Code SingleClient::getLastError() const { - return _lastError; -} - -ErrorCodes::Code SingleClient::takeLastError() { - auto result = _lastError; - setLastError(ErrorCodes::NoError); - - return result; -} - -QString SingleClient::getLastErrorString() const { - return ErrorCodes::DBErrorCodesHelper::toString(_lastError); -} - -bool SingleClient::isConnected() const { - return getStatus() >= ClientStatus::Connected; -} - -bool SingleClient::isLogined() const { - return getStatus() >= ClientStatus::Logined; -} - -bool SingleClient::subscribe(unsigned int id) { - if (getStatus() < ClientStatus::Logined) { - return false; - } - - PKG::WebSocket request; - request.setSubscribeId(id); - request.setRequestCommnad(PKG::WebSocketRequest::Subscribe); - - if (!sendData(&request, realServerAddress())) { - return false; - } - - addToSubscribesList(id); - return true; -} - -bool SingleClient::unsubscribe(unsigned int id) { - if (getStatus() < ClientStatus::Logined) { - return false; - } - - PKG::WebSocket request; - request.setSubscribeId(id); - request.setRequestCommnad(PKG::WebSocketRequest::Unsubscribe); - - if (!sendData(&request, realServerAddress())) { - return false; - } - - removeFromSubscribesList(id); - return true; -} - -QSet SingleClient::subscribesList() const { - QMutexLocker lock(&_subscribesMutex); - return _subscribes; -} - -bool SingleClient::isSubscribed(unsigned int subscribeId) const { - QMutexLocker lock(&_subscribesMutex); - return _subscribes.contains(subscribeId); -} - -bool SingleClient::syncSybscribeListWithServer(const std::function &)> &cb) { - QMutexLocker lock(&_subscribesMutex); - - PKG::WebSocket request; - request.setRequestCommnad(PKG::WebSocketRequest::SubscribeList); - - auto handler = [cb, this](const QSharedPointer & result){ - auto subscribes = static_cast(result.data()); - setSubscribersList(subscribes->addresses()); - cb(_subscribes); - }; - - return restRequest(&request, handler); -} - -bool SingleClient::signPackageWithToken(PKG::AbstractData *pkg) const { - auto tokenObject = dynamic_cast(pkg); - if (!tokenObject) { - return true; - } - - auto token = getMember().getSignToken(); - - if (!token.isValid()) - return false; - - tokenObject->setSignToken(token); - - return true; -} - -bool SingleClient::restRequest(PKG::AbstractData *req, - const HandlerMethod &handler) { - - - if (!signPackageWithToken(req)) { - QuasarAppUtils::Params::log("Fail to sign package with token", QuasarAppUtils::Error); - return false; - } - - unsigned int pkgHash = sendData(req, realServerAddress()); - - if (!pkgHash) - return false; - - QMutexLocker lock(&_handlerCacheMutex); - _handlersCache[pkgHash] = handler; - - QTimer::singleShot(WAIT_RESPOCE_TIME, this, [this, pkgHash]() { - QMutexLocker lock(&_handlerCacheMutex); - _handlersCache.remove(pkgHash); - }); - - return true; -} - -void SingleClient::setLastError(const ErrorCodes::Code &lastError) { - _lastError = lastError; -} - -} diff --git a/Heart/DataBaseSpace/singleclient.h b/Heart/DataBaseSpace/singleclient.h deleted file mode 100644 index 6e3a6e52..00000000 --- a/Heart/DataBaseSpace/singleclient.h +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (C) 2018-2020 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef SINGLECLIENT_H -#define SINGLECLIENT_H - -#include -#include "dberrorcodes.h" -#include "singlebase.h" - -namespace QH { - -/** - * @brief The ClientStatus enum contains network statuses of the client. - */ -enum class ClientStatus: unsigned char { - /// The Client is offline and do not tried connecting to server. (offline mode) - Dissconnected, - /// The Client is offline but the connectToServer method has been invoked. - /// This is mode of wait to connecting . - Connecting, - /// The Client successfully connected to server. - /// This is Online mode. In This mode client is ready to work with server but in read only mode. - Connected, - /// The Client successfully connected to server and the login method has been invoked. - /// This is mode of wait of logging. - Loginning, - /// The client successfully Loggined and ready to work with server. - Logined -}; - -/** - * @brief The SingleClient class This class provide login and singup user functionality for the SingleServer class. - * - * @note All pacakges that will be processed in this class should be sopport the token validation. - * For get more information about token validation see the IToken class. - * - * @note The client have next syntetic limitation: - * 1. Maximum connection count = 1 - * 2. Connect possible only for one server overridden in the serverAddress method. - * 3. addNode and removeNode methods unavalable in the client node. - * - * - */ -class HEARTSHARED_EXPORT SingleClient: public SingleBase -{ - Q_OBJECT -public: - typedef std::function &)> HandlerMethod; - typedef QHash HandlersCache; - - SingleClient(); - - - bool addNode(const HostAddress& address) = delete; - bool addNode(const QString& address, unsigned short) = delete; - bool removeNode(const HostAddress& address) = delete; - - QH::ParserResult parsePackage(const QSharedPointer &pkg, - const Header& pkgHeader, - const AbstractNodeInfo* sender) override; - - /** - * @brief getStatus This method return current status of the client. - * For get more information see the ClientStatus enum. - * @return status of the client. - */ - ClientStatus getStatus() const; - - /** - * @brief login This method try to loggin client. - * @param userId This is userID. In The base implementation it is String value. - * The userId must be unique for all users. - * If You want you can use the email address of the user as a user id. - * If you want login uses your local user data just sets userId is empty. This method try login uses data from the getMember method. - * @param rawPassword This is raw passwork of the userId. This method calc hash from the rawPassword and send getting value to server. For calculated hash uses the hashgenerator method. If you want to override own behavior for hashing or add an own salt then you need to override the hashgenerator method. - * @return true if the user send authorization request successful. - */ - bool login(const QString &userId = {}, const QString &rawPassword = {}); - - /** - * @brief login This method try to login client with new memberData by token. - * @param memberData This is new member data, the client try login. - * @return true if the user send authorization request successful. - */ - bool login(const PKG::UserMember& memberData); - - /** - * @brief logout This method send to server request for logout. - * @return true if the user send logout request successful. - */ - bool logout(); - - /** - * @brief signup This method try to register new user. - * @param userId This is userID. In The base implementation it is String value. - * The userId must be unique for all users. - * If You want you can use the email address of the user as a user id. - * @param rawPassword This is raw passwork of the userId. - * This method calc hash from the rawPassword and send getting value to server. - * For calculated hash uses the hashgenerator method. - * If you want to override own behavior for hashing or add an own salt then you need to override the hashgenerator method. - * @return true if the user send registration request successful. - - */ - bool signup(const QString &userId, const QString &rawPassword); - - /** - * @brief removeUser This method send to server the remove user and user data request. - * @return true if the user send remove request successful. - */ - bool removeUser(); - - /** - * @brief connectToServer This method try connect client or server. - * @return true if the connect request send successful. - */ - bool connectToServer(); - - /** - * @brief disconnectFromServer This method disconnect the client from server. - */ - void disconnectFromServer(); - - /** - * @brief getLastError return last error code. - * @return last error code. - */ - ErrorCodes::Code getLastError() const; - - /** - * @brief takeLastError This method take last erro code. after call this object sets no error to last error. - * @return LastError code. - */ - ErrorCodes::Code takeLastError(); - - /** - * @brief getLastErrorString This method return the string implementation of a last code error. - * @return string value of the last error. - */ - QString getLastErrorString() const; - - /** - * @brief isConnected This method return true if the client is connected to server. - * @return true if the server has "Connected" status. - */ - bool isConnected() const; - - /** - * @brief isLogined This method return true if the client is logged. - * @return true if the server has "Logged" status. - */ - bool isLogined() const; - - /** - * @brief subscribe This method subscribe current logged user to the object with @a id. - * @param id This is subscriber id of the object. - * @return true if subscribe request sent successful. - * \sa { syncSybscribeListWithServer, unsubscribe, isSubscribed, subscribesList } - */ - bool subscribe(unsigned int id); - - /** - * @brief unsubscribe This method unsubscribe current logged user to the object with @a id. - * @param id This is unsubscribe id of the object. - * @return true if unsubscribe request sent successful. - * \sa { syncSybscribeListWithServer, subscribe, isSubscribed, subscribesList } - */ - bool unsubscribe(unsigned int id); - - /** - * @brief subscribesList This method returns local reference to local list with subsribes. - * @warning This list updated when invoked subscribe and unsubscribe methods, so if your client have a unstable network connectin this value may be wrong. - * @return lvalue to a subscrubes ids list.] - * - * @note This method is thread safe, so if you want check is subscribe only then use the SingleClient::isSubscribed method. - * \sa { syncSybscribeListWithServer, subscribe, isSubscribed, unsubscribe } - - */ - QSet subscribesList() const; - - /** - * @brief isSubscribed This method check object with @a subscribeId to isSubscribed. - * @warning This method use the local subscribed list, so it is may be works wrong if your client have a unstable network connection this value may be wrong. - * @return true if the your client subscribed to subscribeId. - * \sa { unsubscribe, subscribe, syncSybscribeListWithServer, subscribesList } - */ - bool isSubscribed(unsigned int subscribeId) const; - - /** - * @brief syncSybscribeListWithServer This method sends to server rest request to get subscribers list. - * @param cb This is call back functions with a new subcribes list. - * @return true if the reqest sendet successful. - * \sa { unsubscribe, subscribe, isSubscribed } - */ - bool syncSybscribeListWithServer(const std::function&)> &cb = {}); - - /** - * @brief restRequest This method send to server rest request and if the server send response invoke a handler method. - * @param req This is request object. This maybe any objects from the PKH name space. - * @param handler This is lambda function. This function invoked when client receive from server response of the sent request. - * @return True if the request sent successfull. - * - * @b Example - * @code{cpp} - * auto cb = [](const QSharedPointer &pkg) { - * ... - * - * }; - * - * MyDataRequest request; - request.setId(userId); - * - * restRequest() - * @endcode - */ - bool restRequest(PKG::AbstractData *req, const HandlerMethod& handler); - - /** - * @brief sendData This method is wraper of default sendData method but add sign to sendet pacakge. - * @param resp This is pointer to sendet object. - * @param address This is target addres for sending. - * @param req This is header of request. - * @return hash of the sendet package. If function is failed then return 0. - */ - unsigned int sendData(const PKG::AbstractData *resp, - const HostAddress &address, - const Header *req = nullptr) override; - - /** - * @brief sendData This method is wraper of default sendData method but add sign to sendet pacakge. - * @param resp This is pointer to sendet object. - * @param address This is target addres for sending. - * @param req This is header of request. - * @return hash of the sendet package. If function is failed then return 0. - */ - unsigned int sendData(const PKG::AbstractData *resp, - const AbstractNodeInfo *node, - const Header *req = nullptr) override; - - /** - * @brief sendData This method is wraper of default sendData method but add sign to sendet pacakge. - * @param resp This is sending object to the nodeId. - * @param nodeId This is id of target node. - * @param req This is header of request. - * @return true if a data send successful. - */ - unsigned int sendData(const PKG::AbstractData *resp, - const QVariant &nodeId, - const Header *req = nullptr) override; - - - /** - * @brief sendData This method is wraper of default sendData method but add sign to sendet pacakge. - * @param resp This is pointer to sendet object. - * @param address This is target addres for sending. - * @param req This is header of request. - * @return hash of the sendet package. If function is failed then return 0. - */ - virtual unsigned int sendData(PKG::AbstractData *resp, - const HostAddress &address, - const Header *req = nullptr); - - /** - * @brief sendData This method is wraper of default sendData method but add sign to sendet pacakge. - * @param resp This is pointer to sendet object. - * @param address This is target addres for sending. - * @param req This is header of request. - * @return hash of the sendet package. If function is failed then return 0. - */ - virtual unsigned int sendData(PKG::AbstractData *resp, - const AbstractNodeInfo *node, - const Header *req = nullptr); - - /** - * @brief sendData This method is wraper of default sendData method but add sign to sendet pacakge. - * @param resp This is sending object to the nodeId. - * @param nodeId This is id of target node. - * @param req This is header of request. - * @return true if a data send successful. - */ - virtual unsigned int sendData(PKG::AbstractData *resp, - const QVariant &nodeId, - const Header *req = nullptr); - -signals: - /** - * @brief statusChanged This signal emitted when the client change an own status. - * @param status This is new status of the client. - * For more information about the statuses see the ClientStatus enum. - */ - void statusChanged(QH::ClientStatus status); - - /** - * @brief currentUserChanged This method invoked when user is logged and receive new token from server. - * handle this signal if you want to save token in to database. - */ - void currentUserChanged(); - -protected: - /** - * @brief setStatus This method sets a new status of the client. This method will be emitted the statusChanged signal. - * @param status This is new status of the client. - * @note The ClientStatus::Loginning and ClientStatus::Connecting statuses create a singleshot timer for check if the server response times out. - */ - void setStatus(const ClientStatus &status); - - /** - * @brief getMember This method return the UserMember object of logged user. - * @return UserMember object. - */ - const PKG::UserMember &getMember() const; - - /** - * @brief setLastError This method sets new error code. - * @param lastError This is new error code. - */ - void setLastError(const ErrorCodes::Code &lastError); - - /** - * @brief serverAddress This method return the pair {ip/domain,port} of server. - * Override this method for change server address. - * Default implementation return the localhost address with the 3090 port. - * @return host of the server. - */ - virtual QPair serverAddress() const; - - /** - * @brief signPackageWithToken This method insert token into sending package. The package @a pkg should be inherited of the IToken interface. IF @a pkg do not have a Itoken parent then this method ignore this validation and return true. - * @param pkg This is pointer to the package object. - * @note The @a pkg object will be changed after invoke this method. - * @return true if the package get a token successful or package not support token validation else false. - */ - bool signPackageWithToken(PKG::AbstractData *pkg) const; - - /** - * @brief resetUser This method remove user member data and sets new status for this node (client). - * If user alredy loggined then status will be changed to connected. - */ - void resetUser(); - - void nodeConfirmend(AbstractNodeInfo *node) override; - void nodeConnected(AbstractNodeInfo *node) override; - void nodeDisconnected(AbstractNodeInfo *node) override; - - - /** - * @brief realServerAddress This method return the real server address that connected with this node. - * @return The real server address that connected with this node. - */ - const HostAddress& realServerAddress() const; - -protected slots: - void nodeErrorOccured(QH::AbstractNodeInfo *nodeInfo, - QAbstractSocket::SocketError errorCode, - QString errorString) override; - -private slots: - /** - * @brief handleError This handle method invoked when the client received the BadRequest from server. - * Override this method for add actions for this event. - * @param code This is number of the error code. - * @param error This is test message from a server. - */ - void handleError(unsigned char code, QString error); - // AbstractNode interface -private: - - /** - * @brief setMember This method sets member data. Use this method if you restore your account data from the local storage. - * @param member This is new network member data. - */ - void setMember(const PKG::UserMember &member); - - bool p_login(const QString &userId, const QByteArray &hashPassword = {}); - bool p_signup(const QString &userId, const QByteArray &hashPassword); - - void handleRestRequest(const QSharedPointer &pkg, const Header &pkgHeader); - void setRealServerAddress(const HostAddress &realServerAddress); - - void addToSubscribesList(unsigned int id); - void removeFromSubscribesList(unsigned int id); - void setSubscribersList(QSet ids); - - mutable QMutex _subscribesMutex; - QSet _subscribes; - - ClientStatus _status = ClientStatus::Dissconnected; - QMutex _handlerMemberMutex; - - PKG::UserMember _member; - ErrorCodes::Code _lastError = ErrorCodes::NoError; - - QMutex _handlerCacheMutex; - HandlersCache _handlersCache; - - HostAddress _realServerAddress; - - -}; - -} -Q_DECLARE_METATYPE(QH::ClientStatus) - -#endif // SINGLECLIENT_H diff --git a/Heart/DataBaseSpace/singleserver.cpp b/Heart/DataBaseSpace/singleserver.cpp deleted file mode 100644 index 9cce7a97..00000000 --- a/Heart/DataBaseSpace/singleserver.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "itoken.h" -#include "singleserver.h" - -#include -#include -#include -#include -#include -#include -#include "deleteobject.h" -#include "getsinglevalue.h" -#include "isqldbcache.h" - -namespace QH { - -SingleServer::SingleServer() -{ - - registerPackageType(); -} - -ErrorCodes::Code SingleServer::registerNewUser(PKG::UserMember user, - const AbstractNodeInfo *info) { - auto sdb = dynamic_cast(db()); - - if (!sdb) { - return ErrorCodes::InternalError; - } - - auto rawDb = sdb->rawDb(); - if (!rawDb) { - return ErrorCodes::InternalError; - } - - auto localObject = rawDb->getObject(user); - - if (localObject) { - return ErrorCodes::UserExits; - } - - auto rawPassword = user.authenticationData(); - user.setAuthenticationData(hashgenerator(rawPassword)); - - if (!rawDb->insertObject(QSharedPointer::create(user), true)) { - return ErrorCodes::InternalError; - }; - - user.setAuthenticationData(rawPassword); - - // get id of the user - sdb->addUpdatePermission(user.getId(), user.dbAddress(), Permission::Write); - - return loginUser(user, info); -} - -// To-Do fix me bug #12 https://github.com/QuasarApp/Heart/issues/12 -ErrorCodes::Code SingleServer::loginUser(const PKG::UserMember &user, - const AbstractNodeInfo *info) { - - auto sdb = dynamic_cast(db()); - - if (!sdb) { - return ErrorCodes::InternalError; - } - - auto rawDb = sdb->rawDb(); - if (!rawDb) { - return ErrorCodes::InternalError; - } - - QSharedPointer localObject = rawDb->getObject(user); - - if (!localObject) { - return ErrorCodes::UserNotExits; - } - - auto nodeinfo = dynamic_cast(info); - if (!nodeinfo) - return ErrorCodes::InternalError; - - if (!(user.getSignToken().isValid() && localObject->getSignToken() == user.getSignToken())) { - if (localObject->authenticationData() != hashgenerator(user.authenticationData())) { - return ErrorCodes::UserInvalidPasswoed; - } - } - - auto editableNodeInfo = static_cast(getInfoPtr(info->networkAddress())); - if (!editableNodeInfo) - return ErrorCodes::InternalError; - - if (!localObject->getSignToken().isValid()) { - localObject->setSignToken(generateToken(AccessToken::Year)); - if (!rawDb->updateObject(localObject, true)) { - return ErrorCodes::InternalError; - } - } - - editableNodeInfo->setToken(localObject->getSignToken()); - editableNodeInfo->setId(localObject->getId()); - - localObject->setAuthenticationData(""); - if (!sendData(localObject.data(), info->networkAddress())) { - return ErrorCodes::InternalError; - }; - - return ErrorCodes::NoError; -} - -ErrorCodes::Code SingleServer::logOutUser(const PKG::UserMember &user, - const AbstractNodeInfo *info) { - - auto sdb = dynamic_cast(db()); - - if (!sdb) { - return ErrorCodes::InternalError; - } - - auto rawDb = sdb->rawDb(); - if (!rawDb) { - return ErrorCodes::InternalError; - } - - auto localObject = rawDb->getObject(user); - - if (!localObject) { - return ErrorCodes::UserNotExits; - } - - auto nodeinfo = dynamic_cast(info); - if (!nodeinfo) - return ErrorCodes::InternalError; - - AccessToken token((nodeinfo->token().toBytes())); - if (!token.isValid()) { - return ErrorCodes::UserNotLogged; - } - - if (user.getSignToken() != token) { - return ErrorCodes::UserNotLogged; - } - - auto mutableNodeInfo = dynamic_cast(getInfoPtr(info->networkAddress())); - if (!mutableNodeInfo) - return ErrorCodes::InternalError; - - mutableNodeInfo->setToken(AccessToken{}); - mutableNodeInfo->setId({}); - - return ErrorCodes::NoError; - -} - -bool SingleServer::signValidation(const PKG::AbstractData *data, const AbstractNodeInfo *sender) const { - auto iToken = dynamic_cast(data); - auto senderInfo = dynamic_cast(sender); - - if (!(iToken && senderInfo )) - return false; - - - return iToken->getSignToken() == senderInfo->token(); - -} - -AccessToken SingleServer::generateToken(int length) { - return AccessToken(length); -} - -ParserResult SingleServer::parsePackage(const QSharedPointer &pkg, - const Header &pkgHeader, - const AbstractNodeInfo *sender) { - - auto parentResult = DataBaseNode::parsePackage(pkg, pkgHeader, sender); - if (parentResult != QH::ParserResult::NotProcessed) { - return parentResult; - } - - if (QH::PKG::AuthRequest::command() == pkg->cmd()) { - auto obj = pkg.staticCast(); - - if (!obj->isValid()) { - prepareAndSendBadRequest(sender->networkAddress(), pkgHeader, - ErrorCodes::InvalidRequest, REQUEST_ERROR); - return ParserResult::Error; - } - - if (!workWithUserRequest(obj, pkgHeader, sender)) { - return QH::ParserResult::Error; - } - - return QH::ParserResult::Processed; - - } - - if (!signValidation(pkg.data(), sender)) { - - prepareAndSendBadRequest(sender->networkAddress(), pkgHeader, - ErrorCodes::OperatioForbiden, REQUEST_ERROR); - - QuasarAppUtils::Params::log("For The SingleServerClient classes you must be add" - " support of the Token validation." - " All package classes must be inherited" - " of the IToken interface", - - QuasarAppUtils::Error); - - return ParserResult::Error; - }; - - - if (PKG::DeleteObject::command() == pkg->cmd()) { - auto obj = pkg.staticCast(); - - auto requesterId = getSender(sender, obj.data()); - if (deleteObject(requesterId, obj) == DBOperationResult::Forbidden) { - badRequest(sender->networkAddress(), pkgHeader, { - ErrorCodes::OperatioForbiden, - "Permision denied" - }); - return ParserResult::Error; - - } - - return QH::ParserResult::Processed; - } - - return QH::ParserResult::NotProcessed; - -} - -QByteArray SingleServer::hashgenerator(const QByteArray &data) const { - return DataBaseNode::hashgenerator(data + "singelserversoult"); -} - -bool SingleServer::workWithUserRequest(const QSharedPointer& obj, - const Header &hdr, - const AbstractNodeInfo *sender) { - - ErrorCodes::Code result = ErrorCodes::InternalError; - - auto request = obj.dynamicCast(); - - if (!request) { - return false; - } - - if (request->getRequestCmd() == static_cast(PKG::UserRequestType::LogIn)) { - result = loginUser(*obj, sender); - } else if (request->getRequestCmd() == static_cast(PKG::UserRequestType::SignUp)) { - result = registerNewUser(*obj, sender); - } else if (request->getRequestCmd() == static_cast(PKG::UserRequestType::LogOut)) { - result = logOutUser(*obj, sender); - } - - if (result == ErrorCodes::InternalError) { - QuasarAppUtils::Params::log("Internal error ocured in the loginUser or registerNewUser method.", - QuasarAppUtils::Error); - prepareAndSendBadRequest(sender->networkAddress(), hdr, - result, REQUEST_INTERNAL_ERROR); - - return false; - } - - if (result != ErrorCodes::NoError) { - prepareAndSendBadRequest(sender->networkAddress(), hdr, - result, REQUEST_INTERNAL_ERROR); - } - - return true; -} - -void SingleServer::prepareAndSendBadRequest(const HostAddress& address, - const Header& lastHeader, - unsigned char error, - int punishment) { - - badRequest(address, lastHeader, - { - error, - ErrorCodes::DBErrorCodesHelper::toString(error) - }, - punishment); - -} - -bool SingleServer::initDatabase() { - setDb(new SingleServerDB); - return true; -} - -} diff --git a/Heart/DataBaseSpace/singleserver.h b/Heart/DataBaseSpace/singleserver.h deleted file mode 100644 index 6cec368b..00000000 --- a/Heart/DataBaseSpace/singleserver.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef SINGLESERVER_H -#define SINGLESERVER_H - -#include -#include "dberrorcodes.h" -#include "singlebase.h" - -namespace QH { - -namespace PKG { -class AuthRequest; -class UserMember; -} - -#define REQUEST_INTERNAL_ERROR 0 -#define REQUEST_LOGIN_ERROR -1 - -/** - * @brief The SingleServer class This class is classic server with support all base server functions. - * classic server support: - * - ssl encryption (See the SslMode enum). - * - multitrading working. - * - user registration (See The PKG::User class). - * - working with dabase (See the DBObject class). - * - * Examples - * - * \code{cpp} - * \endcode - * - * @note All packges that will be processed in this class should be support the token validation. - * For get more information about token validation see the IToken class. - * - */ -class HEARTSHARED_EXPORT SingleServer : public SingleBase -{ - Q_OBJECT -public: - - SingleServer(); - - // AbstractNode interface -protected: - /** - * @brief registerNewUser This method add record into database about new user. After registered this method invoke the SingleServer::loginUser method. - * @param user This is data of new user. - * @param info This is info about requested client. - - * @return status of registration a new user. For more information about result statuses see the UserOperationResult enum. - * - * @note This method send userData with new token to the client. - */ - virtual ErrorCodes::Code registerNewUser(PKG::UserMember user, - const AbstractNodeInfo* info); - - /** - * @brief loginUser This method generate the token for a requested user. - * @param user This is user data with name and password. - * For login use PKG::User::getID and PKG::User::authenticationData like userName and password hash. - * @param info This is info about requested client. - * @return status of login a user. For more information about result statuses see the UserOperationResult enum. - * - * @note This method send userData with new token to the client. - */ - virtual ErrorCodes::Code loginUser(const PKG::UserMember &user, const AbstractNodeInfo* info); - - /** - * @brief logOutUser This method remove the generated accesses token from server. - * @param user This is network member data (user data) - * @param info This is info about requested client. - * @return status of operation. For more information about result statuses see the UserOperationResult enum. - */ - virtual ErrorCodes::Code logOutUser(const PKG::UserMember &user, const AbstractNodeInfo* info); - - /** - * @brief signValidation This method return true if the package of the user have a token and it token is valid. - * Except is login request. User must be send own login and hash password. - * @param data This is validation package data. - * @param sender This is package sender node information. - * @return true if the token is valid. - */ - virtual bool signValidation(const PKG::AbstractData* data, const AbstractNodeInfo *sender) const; - - /** - * @brief generateToken This method generate a new token. - * @param duration This is duration of valid. - * @return A new token. - */ - AccessToken generateToken(int duration = AccessToken::Day); - - ParserResult parsePackage(const QSharedPointer &pkg, - const Header& pkgHeader, - const AbstractNodeInfo* sender) override; - QByteArray hashgenerator(const QByteArray &data) const override; - - bool initDatabase() override; - - -private: - - bool workWithUserRequest(const QSharedPointer &obj, - const Header &pkg, - const AbstractNodeInfo *sender); - - void prepareAndSendBadRequest(const HostAddress& address, - const Header& lastHeader, - unsigned char error, - int punishment); - - - - - -}; - -} -#endif // SINGLESERVER_H diff --git a/Heart/DataBaseSpace/sqldb.cpp b/Heart/DataBaseSpace/sqldb.cpp index 5980b7f7..04a4ab51 100644 --- a/Heart/DataBaseSpace/sqldb.cpp +++ b/Heart/DataBaseSpace/sqldb.cpp @@ -9,7 +9,7 @@ namespace QH { SqlDB::SqlDB(): - ISqlDBCache(0, SqlDBCasheWriteMode::Force) { + ISqlDB(0, SqlDBCasheWriteMode::Force) { } void SqlDB::deleteFromCache(const QSharedPointer &delObj) { diff --git a/Heart/DataBaseSpace/sqldb.h b/Heart/DataBaseSpace/sqldb.h index 3ea31d23..77b6c272 100644 --- a/Heart/DataBaseSpace/sqldb.h +++ b/Heart/DataBaseSpace/sqldb.h @@ -7,7 +7,7 @@ #ifndef SQLDB_H #define SQLDB_H -#include "isqldbcache.h" +#include "isqldb.h" namespace QH { @@ -15,7 +15,7 @@ namespace QH { * @brief The SqlDB class This is base implementation fo datatbase. * The SqlDB do not use caches, all request run on the sqlwtiter class. */ -class HEARTSHARED_EXPORT SqlDB final: public ISqlDBCache { +class HEARTSHARED_EXPORT SqlDB final: public ISqlDB { Q_OBJECT public: SqlDB(); diff --git a/Heart/DataBaseSpace/sqldbcache.cpp b/Heart/DataBaseSpace/sqldbcache.cpp deleted file mode 100644 index 36cf7d00..00000000 --- a/Heart/DataBaseSpace/sqldbcache.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifdef HEART_DB_CACHE - -#include "sqldbcache.h" -#include "quasarapp.h" -#include "sqldbwriter.h" -#include "dbaddresskey.h" -#include "permisiondata.h" - -#include -#include - -#include -#include - - -namespace QH { - -using namespace PKG; - -QSharedPointer SqlDBCache::getFromCacheById(quint32 dbKey) { - - QMutexLocker locker(&_cacheMutex); - - return _cache.value(dbKey, nullptr); -} - - -SqlDBCache::SqlDBCache(qint64 updateInterval): - ISqlDBCache(updateInterval, SqlDBCasheWriteMode::Force) { - -} - -SqlDBCache::~SqlDBCache() { - -} - -void SqlDBCache::deleteFromCache(const QSharedPointer& delObj) { - if (!delObj) - return; - - _cacheMutex.lock(); - _cache.remove(delObj->dbKey()); - _cacheMutex.unlock(); -} - -bool SqlDBCache::insertToCache(const QSharedPointer& obj) { - if (!obj || !obj->isCached()) - return false; - - // obj must be have valid id of save into cache - if (!obj->getId().isValid()) - return false; - - QMutexLocker lock(&_cacheMutex); - - if (_cache.contains(obj->dbKey())) { - return false; - } - - _cache[obj->dbKey()] = obj->clone(); - - return true; - -} - -bool SqlDBCache::updateCache(const QSharedPointer& obj) { - if (!obj || !obj->isCached()) - return false; - - QMutexLocker lock(&_cacheMutex); - - auto existsObject = _cache.value(obj->dbKey(), nullptr); - - if (!existsObject) { - return false; - } - - if (existsObject->cmd() != obj->cmd()) { - _cache[obj->dbKey()] = obj->clone(); - - } else { - if (!existsObject->copyFrom(obj.data())) { - return false; - } - } - - return true; -} - -QList > -SqlDBCache::getFromCache(const DBObject *obj) { - - using resultType = QList>; - if (obj->getId().isValid()) { - auto result = getFromCacheById(obj->dbKey()); - if (!result) - return resultType{}; - - return resultType{result}; - } - - return resultType{}; -} -} -#endif diff --git a/Heart/DataBaseSpace/sqldbcache.h b/Heart/DataBaseSpace/sqldbcache.h deleted file mode 100644 index 0ce83ddf..00000000 --- a/Heart/DataBaseSpace/sqldbcache.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifdef HEART_DB_CACHE - -#ifndef SQLDBCASHE_H -#define SQLDBCASHE_H - - -#include "iobjectprovider.h" -#include "isqldbcache.h" - - -namespace QH { - -/** - * @brief The SqlDBCache class is universal implementation of the database cache. - * This implementation have a one hashMap for the database object. - * This is work for all Databases types but some objects like a DBObjectSet or DBObjectsRequest class not supported because this is set objects. - * @note This cache works only for select queries. Uses SqlDBCasheWriteMode::Force mode For more information about modes see the SqlDBCasheWriteMode enum class. - */ -class HEARTSHARED_EXPORT SqlDBCache final: public ISqlDBCache -{ - Q_OBJECT - -public: - SqlDBCache(qint64 updateInterval = DEFAULT_UPDATE_INTERVAL); - - ~SqlDBCache(); - // ISqlDBCache interface -protected: - void deleteFromCache(const QSharedPointer& delObj) override; - bool insertToCache(const QSharedPointer& obj) override; - bool updateCache(const QSharedPointer& obj) override; - QList> - getFromCache(const PKG::DBObject *obj) override; - -private: - QSharedPointer getFromCacheById(quint32 dbKey); - - - QMutex _saveLaterMutex; - QMutex _cacheMutex; - QHash> _cache; - QHash> _changes; - }; - -} -#endif // SQLDBCASHE_H - -#endif diff --git a/Heart/DataBaseSpace/websocketcontroller.cpp b/Heart/DataBaseSpace/websocketcontroller.cpp deleted file mode 100644 index 2181aca3..00000000 --- a/Heart/DataBaseSpace/websocketcontroller.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "databasenode.h" -#include "abstractnodeinfo.h" -#include "websocketcontroller.h" -#include -#include - -namespace QH { - -using namespace PKG; - -WebSocketController::WebSocketController(DataBaseNode *node) { - _node = node; - assert(_node); - -} - -void WebSocketController::subscribe(const QString &subscriber, - unsigned int item) { - - _subscribsMutex.lock(); - _itemsMutex.lock(); - - subscribePrivate(subscriber, item); - - _itemsMutex.unlock(); - _subscribsMutex.unlock(); -} - -void WebSocketController::unsubscribe(const QString &subscriber, - unsigned int item) { - _subscribsMutex.lock(); - _itemsMutex.lock(); - - unsubscribePrivate(subscriber, item); - - _itemsMutex.unlock(); - _subscribsMutex.unlock(); -} - -QSet WebSocketController::list(const QString &subscriber) { - QMutexLocker locker(&_itemsMutex); - return _items[subscriber]; -} - -void WebSocketController::handleItemChanged(const QSharedPointer &item) { - - QMutexLocker locker(&_subscribsMutex); - foreachSubscribers(item, _subscribs.value(item->subscribeId())); -} - -void WebSocketController::foreachSubscribers(const QSharedPointer &item, - const QSet &subscribersList) { - - for (const auto &subscriber : subscribersList) { - - auto abstractItem = item.dynamicCast(); - - if (!abstractItem) { - QuasarAppUtils::Params::log("All Subsribable objects must be child classes of the AbstractData." + subscriber, - QuasarAppUtils::Error); - unsubscribePrivate(subscriber, item->subscribeId()); - - } - - auto dbObject = item.dynamicCast(); - - bool fAllowed = true; - if (dbObject) { - fAllowed = _node->checkPermission(subscriber, dbObject->dbAddress(), Permission::Read) == - DBOperationResult::Allowed; - } - - if (fAllowed && !_node->sendData(abstractItem.data(), subscriber)) { - QuasarAppUtils::Params::log("Send update failed for " + subscriber, - QuasarAppUtils::Warning); - - unsubscribePrivate(subscriber, item->subscribeId()); - } - - if (!fAllowed) { - QuasarAppUtils::Params::log(QString("Internal Error. Member:%0 not have permission to object %1"). - arg(subscriber, abstractItem->toString()), - QuasarAppUtils::Error); - unsubscribePrivate(subscriber, item->subscribeId()); - } - } -} - -void WebSocketController::unsubscribePrivate(const QString &subscriber, - unsigned int item) { - _subscribs[item].remove(subscriber); - _items[subscriber].remove(item); -} - -void WebSocketController::subscribePrivate(const QString &subscriber, - unsigned int item) { - - _subscribs[item].insert(subscriber); - _items[subscriber].insert(item); -} -} - -uint qHash(const QVariant &variant) { - return qHash(variant.toByteArray()); -} diff --git a/Heart/DataBaseSpace/websocketcontroller.h b/Heart/DataBaseSpace/websocketcontroller.h deleted file mode 100644 index 4d67d41d..00000000 --- a/Heart/DataBaseSpace/websocketcontroller.h +++ /dev/null @@ -1,90 +0,0 @@ - -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef WEBSOCKETCONTROLLER_H -#define WEBSOCKETCONTROLLER_H - -#include -#include -#include -#include - -namespace QH { - -class AbstractNodeInfo; -class DataBaseNode; - -/** - * @brief The WebSocketController class is manage subscribe. This class contains information about users and him subscriptions. - */ -class HEARTSHARED_EXPORT WebSocketController -{ - -public: - /** - * @brief WebSocketController default constructor. - * @param node This is pointer to node object. - */ - WebSocketController(DataBaseNode *node); - - /** - * @brief subscribe This method subscribe a subscriber to the item. - * @param subscriber This is network member that want get information about update of the item. - * @param item This is a subscribable object id. - * @return true if method finished successful. - */ - void subscribe(const QString &subscriber, - unsigned int item); - - /** - * @brief unsubscribe This method unsubscribe a subscriber from the item. - * @param subscriber This is network member that want disable getting information about update of the item. - * @param item This is a subscribable object id. - * @return true if method finished successful. - */ - void unsubscribe(const QString &subscriber, - unsigned int item); - - /** - * @brief list This method return a list of subscribed items of subscriber. - * @param subscriber This is network member that want get a list of own subscription. - * @return true if method finished successful. - */ - QSet list(const QString& subscriber); - - /** - * @brief handleItemChanged This method invoked when item on database changed. - * @param item This is changed item. - */ - void handleItemChanged(const QSharedPointer &item); - -private: - void foreachSubscribers(const QSharedPointer &item, - const QSet &subscribersList); - - void unsubscribePrivate(const QString &subscriber, - unsigned int item); - - void subscribePrivate(const QString &subscriber, - unsigned int item); - - /// subscribers it is nodes or clients - QHash> _subscribs; - QHash> _items; - - QMutex _subscribsMutex; - QMutex _itemsMutex; - - DataBaseNode *_node = nullptr; - -}; - -} - -uint qHash(const QVariant& variant); -#endif // WEBSOCKETCONTROLLER_H diff --git a/Heart/NetworkSpace/Res/NetworkDB.sql b/Heart/NetworkSpace/Res/NetworkDB.sql deleted file mode 100644 index 5c11219c..00000000 --- a/Heart/NetworkSpace/Res/NetworkDB.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE IF NOT EXISTS NetworkMembers ( - id VARCHAR(64) PRIMARY KEY NOT NULL , - authenticationData BLOB NOT NULL, - trust INTEGER default 0 -); - -CREATE TABLE IF NOT EXISTS MemberPermisions ( - memberId VARCHAR(64) NOT NULL, - dbAddress BLOB NOT NULL, - lvl tinyint NOT NULL, - - FOREIGN KEY(memberId) REFERENCES NetworkMembers(id) - ON UPDATE CASCADE - ON DELETE CASCADE - -); -CREATE UNIQUE INDEX IF NOT EXISTS MemberPermisionsIndex ON MemberPermisions(memberId, dbAddress); diff --git a/Heart/NetworkSpace/consensus.cpp b/Heart/NetworkSpace/consensus.cpp deleted file mode 100644 index 42bb211c..00000000 --- a/Heart/NetworkSpace/consensus.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "consensus.h" - -namespace QH { - -const QStringList Consensus::Nodes = { - "QuasarApp.ddns.net" -}; - -const short Consensus::networkPort = 8211; - -} diff --git a/Heart/NetworkSpace/consensus.h b/Heart/NetworkSpace/consensus.h deleted file mode 100644 index 9d990263..00000000 --- a/Heart/NetworkSpace/consensus.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef CONSENSUS_H -#define CONSENSUS_H - -#include "heart_global.h" -#include - -namespace QH { - -/** - * @brief The Consensus namespace - a bundle of general rules constants for behavior of nodes network. - */ -namespace Consensus { - /** - * @brief Nodes - list of main nodes of network - */ - extern const QStringList Nodes; - - /** - * @brief networkPort - sync network port - */ - extern const short networkPort; - -}; - -} -#endif // CONSENSUS_Hs diff --git a/Heart/NetworkSpace/networkerrorcodes.h b/Heart/NetworkSpace/networkerrorcodes.h deleted file mode 100644 index 7c67a174..00000000 --- a/Heart/NetworkSpace/networkerrorcodes.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef NETWORKERRORCODES_H -#define NETWORKERRORCODES_H - -#include "dberrorcodes.h" - -namespace QH { - - -namespace ErrorCodes { - -/** - * @brief The AbstractEccorCodes enum This enum with dafault error codes. - */ -enum NetworkErrorCodes: unsigned char { - /// This case using for inheritance new enum classes. - NetworkErrorCodes = DBErrorCodes::DBErrorCodes, -}; -} -} - -#endif // NETWORKERRORCODES_H diff --git a/Heart/NetworkSpace/networknode.cpp b/Heart/NetworkSpace/networknode.cpp deleted file mode 100644 index 4e7e292d..00000000 --- a/Heart/NetworkSpace/networknode.cpp +++ /dev/null @@ -1,610 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "accesstoken.h" -#include "networknode.h" -#include "basenodeinfo.h" -#include "sqldbcache.h" -#include "sqldbwriter.h" -#include "websocketcontroller.h" -#include "badnoderequest.h" -#include "sign.h" -#include "asyncsqldbwriter.h" -#include "router.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "networkerrorcodes.h" - - - -#define THIS_NODE "this_node_key" -namespace QH { - -using namespace PKG; - -NetworkNode::NetworkNode(QObject *ptr): - DataBaseNode(ptr) { - - _nodeKeys = new KeyStorage(new QSecretRSA2048()); - _router = new Router(); - -} - -bool NetworkNode::run(const QString &addres, unsigned short port) { - if (!DataBaseNode::run(addres, port)) { - return false; - } - - _nodeKeys->initDefaultStorageLocation(); - _nodeKeys->start(); - - return true; -} - -bool NetworkNode::run(const QString &addres, - unsigned short port, - const QString &localNodeName) { - - if (!DataBaseNode::run(addres, port, localNodeName)) { - return false; - } - - _nodeKeys->initDefaultStorageLocation(localNodeName); - _nodeKeys->start(); - - return true; -} - -void NetworkNode::stop() { - DataBaseNode::stop(); - -} - -NetworkNode::~NetworkNode() { - delete _nodeKeys; - delete _router; -} - -NodeId NetworkNode::nodeId() const { - - auto keys = _nodeKeys->getNextPair(THIS_NODE); - return QCryptographicHash::hash(keys.publicKey(), QCryptographicHash::Sha256); -} - -unsigned int NetworkNode::sendData(AbstractData *resp, const QVariant &nodeId, const Header *req) { - return sendData(resp, NodeId(nodeId), req); -} - -unsigned int NetworkNode::sendData(const AbstractData *resp, const QVariant &nodeId, const Header *req) { - return sendData(resp, NodeId(nodeId), req); -} - -unsigned int NetworkNode::sendData(AbstractData *resp, - const HostAddress &nodeId, - const Header *req) { - return DataBaseNode::sendData(resp, nodeId, req); -} - -unsigned int NetworkNode::sendData(const AbstractData *resp, - const HostAddress &nodeId, - const Header *req) { - return DataBaseNode::sendData(resp, nodeId, req); -} - -unsigned int NetworkNode::sendData(const AbstractData *resp, - const NodeId &nodeId, - const Header *req) { - auto nodes = connections(); - - for (auto it = nodes.begin(); it != nodes.end(); ++it) { - auto info = dynamic_cast(it.value()); - if (info && info->isKnowAddress(nodeId)) { - return sendData(resp, it.key(), req); - } - } - - auto brodcast = [this, &nodes, req](const AbstractData *data) -> unsigned int { - bool result = false; - unsigned int hashCode = 0; - for (auto it = nodes.begin(); it != nodes.end(); ++it) { - hashCode = sendData(data, it.key(), req); - result += hashCode; - } - - if (result) { - return hashCode; - } - - return 0; - }; - - - if (resp->cmd() != H_16()) { - TransportData data(address()); - data.setTargetAddress(nodeId); - if (!data.setData(*resp)) { - return false; - } - - data.setRoute(_router->getRoute(nodeId)); - data.setSenderID(this->nodeId()); - data.prepareToSend(); - - return brodcast(&data); - } - - return brodcast(resp); -} - -unsigned int NetworkNode::sendData(AbstractData *resp, const NodeId &nodeId, const Header *req) { - if (!resp || !resp->prepareToSend()) { - return false; - } - - return sendData(const_cast(resp), nodeId, req); -} - - -bool NetworkNode::checkSignOfRequest(const AbstractData *request) { - auto object = dynamic_cast(request); - auto dbObject = dynamic_cast(request); - - if (!(object && dbObject)) { - return false; - } - - auto node = db()->getObject(NetworkMember{dbObject->senderID().toRaw()}); - return _nodeKeys->check(_nodeKeys->concatSign(object->dataForSigned(), - object->sign()), node->authenticationData()); -} - -void NetworkNode::thisNode(NodeObject& res) const { - auto keys = _nodeKeys->getNextPair(THIS_NODE); - - res.setAuthenticationData(keys.publicKey()); - res.setTrust(0); - - res.prepareToSend(); - -} - -QSet NetworkNode::myKnowAddresses() const { - QSet res; - const auto connects = connections(); - for (const AbstractNodeInfo *i : connects) { - auto info = dynamic_cast(i); - if (info && info->selfId().isValid()) { - res += info->selfId(); - } - } - - return res; -} - -bool NetworkNode::welcomeAddress(AbstractNodeInfo *node) { - NodeObject self; - thisNode(self); - - if (!sendData(&self, node->networkAddress())) { - return false; - } - - if (connections().size()) { - - auto knowAddresses = myKnowAddresses(); - if (knowAddresses.size()) { - KnowAddresses addressesData; - addressesData.setKnowAddresses(knowAddresses); - - if (!sendData(&addressesData, node->networkAddress())) { - return false; - } - } - } - - return true; - -} - -void NetworkNode::nodeConnected(AbstractNodeInfo *node) { - DataBaseNode::nodeConnected(node); -} - -void NetworkNode::nodeConfirmend(AbstractNodeInfo *node) { - DataBaseNode::nodeConfirmend(node); - - auto nodeInfo = dynamic_cast(node); - if (!nodeInfo) { - return; - } - - _connectionsMutex.lock(); - NetworkNodeInfo* oldNodeInfo = _connections.value(nodeInfo->selfId(), nullptr); - _connectionsMutex.unlock(); - - if (oldNodeInfo) { - removeNode(node->networkAddress()); - return; - } - - _connectionsMutex.lock(); - _connections.insert(nodeInfo->selfId(), nodeInfo); - - _connectionsMutex.unlock(); - -} - -void NetworkNode::nodeDisconnected(AbstractNodeInfo *node) { - AbstractNode::nodeDisconnected(node); - - auto nodeInfo = dynamic_cast(node); - if (!nodeInfo) { - return; - } - - _connectionsMutex.lock(); - _connections.remove(nodeInfo->selfId()); - _connectionsMutex.unlock(); -} - -void NetworkNode::incomingData(AbstractData *, const NodeId &) {} - -void NetworkNode::incomingData(AbstractData *pkg, const AbstractNodeInfo *sender) { - DataBaseNode::incomingData(pkg, sender); -} - -QString NetworkNode::keyStorageLocation() const { - return _nodeKeys->storageLocation(); -} - -ParserResult NetworkNode::parsePackage(const QSharedPointer &pkg, - const Header &pkgHeader, - const AbstractNodeInfo *sender) { - auto parentResult = DataBaseNode::parsePackage(pkg, pkgHeader, sender); - if (parentResult != ParserResult::NotProcessed) { - return parentResult; - } - - auto baseSender = dynamic_cast(sender); - if (!baseSender) { - QuasarAppUtils::Params::log("Sender is not basenode info!", - QuasarAppUtils::Error); - return ParserResult::Error; - } - - if (H_16() == pkgHeader.command) { - auto cmd = pkg.staticCast(); - - incomingData(cmd.data(), baseSender->selfId()); - emit requestError(cmd->errCode(), cmd->err()); - - return ParserResult::Processed; - - } else if (H_16() == pkgHeader.command) { - auto cmd = pkg.staticCast(); - - return workWithTransportData(cmd.data(), sender, pkgHeader); - - - } else if (H_16() == pkgHeader.command) { - auto obj = QSharedPointer::create(pkg); - if (!obj->isValid()) { - badRequest(sender->networkAddress(), pkgHeader, - { - ErrorCodes::InvalidRequest, - "NodeObject request is invalid" - } - ); - return ParserResult::Error; - } - - if (!workWithNodeObjectData(obj, sender)) { - badRequest(obj->senderID(), pkgHeader, - { - ErrorCodes::InvalidRequest, - "NodeObject request is invalid" - } - ); - return ParserResult::Error; - } - - return ParserResult::Processed; - } else if (H_16() == pkgHeader.command) { - auto obj = pkg.staticCast(); - - if (!obj->isValid()) { - badRequest(sender->networkAddress(), pkgHeader, - { - ErrorCodes::InvalidRequest, - "KnowAddresses request is invalid" - } - ); - return ParserResult::Error; - } - - if (!workWithKnowAddresses(*obj, sender)) { - badRequest(sender->networkAddress(), pkgHeader, - { - ErrorCodes::InvalidRequest, - "KnowAddresses request is invalid" - } - ); - return ParserResult::Error; - } - - return ParserResult::Processed; - } else if (H_16() == pkgHeader.command) { - auto cmd = pkg.staticCast(); - - if (!cmd->ansver()) { - cmd->setAnsver(true); - sendData(cmd.data(), cmd->senderID(), &pkgHeader); - } - - incomingData(cmd.data(), baseSender->selfId()); - return ParserResult::Processed; - } else if (H_16() == pkgHeader.command) { - auto cmd = pkg.staticCast(); - - if (!cmd->isValid()) { - badRequest(baseSender->selfId(), pkgHeader, - { - ErrorCodes::InvalidRequest, - "NetworkRequest request is invalid" - } - ); - return ParserResult::Error; - } - - workWithNetworkRequest(cmd.data(), baseSender); - return ParserResult::Processed; - } - - return ParserResult::NotProcessed; -} - -bool NetworkNode::workWithNodeObjectData(const QSharedPointer &node, - const AbstractNodeInfo* nodeInfo) { - - if (!db()) { - return false; - } - - auto localObjec = db()->getObject(*node.data()); - - if (localObjec) { - node->setTrust(std::min(node->trust(), localObjec->trust())); - - if (!db()->updateObject(node)) { - QuasarAppUtils::Params::log("Error on precessing of NodeObject updateObject is failed"); - return false; - }; - } else { - node->setTrust(0); - - if (!db()->insertObject(node)) { - QuasarAppUtils::Params::log("Error on precessing of NodeObject insertObject is failed"); - return false; - }; - } - - auto peerNodeInfo = dynamic_cast(getInfoPtr(nodeInfo->networkAddress())); - if (!peerNodeInfo) { - QuasarAppUtils::Params::log("Error on precessing of NodeObject peerNodeInfo is null"); - return false; - } - - peerNodeInfo->setSelfId(NodeId(node->getId())); - - return true; -} - -bool NetworkNode::workWithKnowAddresses(const KnowAddresses &obj, - const AbstractNodeInfo *nodeInfo) { - - auto peerNodeInfo = dynamic_cast(getInfoPtr(nodeInfo->networkAddress())); - if (!peerNodeInfo) - return false; - - peerNodeInfo->addKnowAddresses(obj.knowAddresses()); - - return true; -} - -ParserResult NetworkNode::workWithTransportData(const QSharedPointer & transportData, - const AbstractNodeInfo* sender, - const Header& hdr) { - - // convert transoprt pakcage - auto cmd = transportData.dynamicCast(); - - if (!cmd) - return ParserResult::Error; - - // ignore processed packages - if (_router->isProcessed(cmd->packageId())) - return ParserResult::Processed; - - // check distanation - if (cmd->targetAddress() == nodeId()) { - - // inversion route and update route to sender - _router->updateRoute(cmd->senderID(), - {cmd->route().rbegin(), cmd->route().rend()}); - - return parsePackage(transportData, hdr, sender); - } - - bool fRouteIsValid = false; - - // find route if transport command do not have own route. - if (!cmd->isHaveRoute() && _router->contains(cmd->targetAddress())) { - auto route = _router->getRoute(cmd->targetAddress()); - - auto cmdRute = cmd->route(); - - cmdRute.push_back(address()); - cmdRute.append(route); - - cmd->setRoute(cmdRute); - } - - // check exists route - if (cmd->isHaveRoute()) { - - // if package have a route then remove all nodes from sender to this node from route and update route - if (!sender) - return ParserResult::Error; - - cmd->strip(sender->networkAddress(), address()); - - // send this package to first available node of knownnodes route nodes - auto it = cmd->route().rbegin(); - while (it != cmd->route().rend() && !sendData(cmd.data(), *it, &hdr)) { - it++; - } - - fRouteIsValid = it != cmd->route().rend(); - - } else { - // if command not have a route or route is not completed then add this node to end route - cmd->addNodeToRoute(address()); - } - - // save route for sender node from this node - auto routeFromSenderToHere = cmd->route(); - int index = routeFromSenderToHere.indexOf(address()); - - if (index < 0) { - QuasarAppUtils::Params::log("own node no findet on route.", - QuasarAppUtils::Error); - } - -#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - routeFromSenderToHere.erase(routeFromSenderToHere.cbegin(), routeFromSenderToHere.cbegin() + index); -#else - routeFromSenderToHere.erase(routeFromSenderToHere.begin(), routeFromSenderToHere.begin() + index); -#endif - - // inversion route and update route to sender - _router->updateRoute(cmd->senderID(), - {routeFromSenderToHere.rbegin(), routeFromSenderToHere.rend()}); - - // remove invalid route nodes and fix exists route. - if (!fRouteIsValid) { - cmd->setRoute(routeFromSenderToHere); - cmd->completeRoute(false); - - // send bodcast if route is invalid - if (!sendData(cmd.data(), cmd->targetAddress(), &hdr)) { - return ParserResult::Error; - } - } - - _router->addProcesedPackage(cmd->packageId()); - return ParserResult::Processed; - -} - -ParserResult NetworkNode::workWithNetworkRequest(const QSharedPointer &networkRequest, - const AbstractNodeInfo *sender) { - // convert transoprt pakcage - auto cmd = networkRequest.dynamicCast(); - - if (!cmd) - return ParserResult::Error; - - if (cmd->isComplete()) { - if (cmd->askedNodes().contains(nodeId())) { - auto data = prepareData(cmd->dataResponce()); - if (!data) - return ParserResult::Error; - - return parsePackage(data, sender); - } - - return ParserResult::Processed; - } - - return parsePackage(cmd->dataRequest(), sender); -} - -void NetworkNode::incomingData(AbstractData *pkg, const HostAddress &sender) { - AbstractNode::incomingData(pkg, sender); -} - -AbstractNodeInfo *NetworkNode::createNodeInfo(QAbstractSocket *socket, - const HostAddress* clientAddress) const { - return new NetworkNodeInfo(socket, clientAddress); -} - -void NetworkNode::badRequest(const HostAddress &address, const Header &req, - const ErrorData &err, qint8 diff) { - DataBaseNode::badRequest(address, req, err, diff); -} - -void NetworkNode::badRequest(const NodeId &address, const Header &req, - const ErrorData &err, qint8 diff) { - if (!changeTrust(address, diff)) { - - QuasarAppUtils::Params::log("Bad request detected, bud response command not sent!" - " because trust not changed", - QuasarAppUtils::Error); - - return; - } - - auto bad = BadRequest(err); - if (!sendData(&bad, address, &req)) { - return; - } - - QuasarAppUtils::Params::log("Bad request sendet to adderess: " + - address.toString(), - QuasarAppUtils::Info); -} - -bool NetworkNode::changeTrust(const QVariant &id, int diff) { - return DataBaseNode::changeTrust(id, diff); -} - -bool NetworkNode::changeTrust(const HostAddress &id, int diff) { - return DataBaseNode::changeTrust(id, diff); -} - -QStringList NetworkNode::SQLSources() const { - return {":/sql/NetworkSpace/Res/NetworkDB.sql"}; -} - -bool NetworkNode::changeTrust(const NodeId &id, int diff) { - return DataBaseNode::changeTrust(id.toRaw(), diff); -} - -bool NetworkNode::ping(const NodeId &id) { - LongPing cmd(nodeId()); - return sendData(&cmd, id); -} - -} - diff --git a/Heart/NetworkSpace/networknode.h b/Heart/NetworkSpace/networknode.h deleted file mode 100644 index 6eb4439c..00000000 --- a/Heart/NetworkSpace/networknode.h +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef NETWORKNODE_H -#define NETWORKNODE_H - -#include -#include -#include -#include - -#include "nodeid.h" - -namespace QH { - -namespace PKG { -class AbstractNetworkMember; -class MemberPermisionObject; -class KnowAddresses; -} - -class KeyStorage; -class Router; -class NetworkNodeInfo; - -/** - * @brief The BaseNode class - base inplementation of nodes. This implementation contains methods for work with database and work with data transopt on network. - * BaseNode - is thread save class - */ -class HEARTSHARED_EXPORT NetworkNode : public DataBaseNode -{ - Q_OBJECT -public: - - /** - * @brief BaseNode - * @param ptr - */ - NetworkNode(QObject * ptr = nullptr); - ~NetworkNode() override; - - /** - * @brief run server on address an port - * @param addres - If address is empty then serve weel be listen all addreses of all interfaces - * @param port - * @return recomendet befor invoke this method call the intSqlDb. - * If you skeap a call of intSqlDb method then data base inited with default parameters. - */ - bool run(const QString &addres, unsigned short port) override; - - /** - * @brief run server on address an port with local name of storage of keys - * @param addres - network address of node - * @param port - port of node - * @param localNodeName - this is locale node name. Sets name of folder with the data for current node. - * @return true if node is deployed successful - */ - bool run(const QString &addres, unsigned short port, - const QString &localNodeName) override; - - /** - * @brief stop - this implementation stop work database and push to database all cache data. - */ - void stop() override; - - /** - * @brief ping - ping node by node id - * @param id - * @return - */ - bool ping( const NodeId& id); - - /** - * @brief nodeId - * @return - */ - NodeId nodeId() const; - -protected: - - /** - * @brief sendData This implementation of the sendData sending pacakge to the network by node id. - * @param resp This is sendet pacakge - * @param nodeId This is id of target node - * @param req This is header of pacakga that this pacakge ansvered. - * @return true if the package sendet successful. - */ - virtual unsigned int sendData(PKG::AbstractData *resp, const NodeId &nodeId, - const Header *req = nullptr); - - /** - * @brief sendData This implementation no prepare data for sendint. for prepare data for sending use the not const object of resp. - * @param resp This is sendet pacakge - * @param nodeId This is id of target node - * @param req This is header of pacakga that this pacakge ansvered. - * @return true if the package sendet successful. - */ - virtual unsigned int sendData(const PKG::AbstractData *resp, const NodeId &nodeId, - const Header *req = nullptr); - - unsigned int sendData(PKG::AbstractData *resp, const HostAddress &nodeId, - const Header *req = nullptr) override; - - unsigned int sendData(const PKG::AbstractData *resp, const HostAddress &nodeId, - const Header *req = nullptr) override; - - unsigned int sendData(PKG::AbstractData *resp, const QVariant &nodeId, - const Header *req = nullptr) override; - - unsigned int sendData(const PKG::AbstractData *resp, const QVariant &nodeId, - const Header *req = nullptr) override; - - void badRequest(const HostAddress &address, const Header &req, - const PKG::ErrorData& err, qint8 diff = REQUEST_ERROR) override; - - /** - * @brief badRequest This implementation of the AbstractNode::badRequest method - * send bad request to node with id. - * @param address This is id of target node or client - * @param req This is header of request. - * @param err This is message and code for target node about error. For more onformation see the PKG::ErrorData struct. - * @param diff This is difference of current trust (currenTrus += diff) - * By default diff equals REQUEST_ERROR - */ - virtual void badRequest(const NodeId &address, const Header &req, - const PKG::ErrorData& err, qint8 diff = REQUEST_ERROR); - - - bool changeTrust(const QVariant &id, int diff) override; - bool changeTrust(const HostAddress &id, int diff) override; - - QStringList SQLSources() const override; - - /** - * @brief changeTrust This implementation is some as AbstractNode::changeTrust but change trust of node by id and save changes on local database. - * @param id This is id of node or client. - * @param diff This is integer value of trust lavel changes. - * @return true if functin finished seccussful - */ - virtual bool changeTrust(const NodeId &id, int diff); - - /** - * @brief parsePackage - * @param pkg - * @param sender - * @return - */ - ParserResult parsePackage(const QSharedPointer &pkg, - const Header& pkgHeader, - const AbstractNodeInfo* sender) override; - - /** - * @brief createNodeInfo - this method create a new node from socket. override this mehod if you want to create a own clasess of nodes. - * @param socket - * @return pointer to new node info - */ - AbstractNodeInfo* createNodeInfo(QAbstractSocket *socket, const HostAddress *clientAddress) const override; - - /** - * @brief savePermision - this method save a new changes in to permisions table. - * Befor save new data node can be validate new data with consensus. - * @param permision - data of new permision - * @return true if new cghanges saved successful. - */ - bool savePermision(const PKG::NodeObject &node, const PKG::MemberPermisionObject& permision); - /** - * @brief checkSignOfRequest - * @param request - package - * @return true if request signed. - */ - virtual bool checkSignOfRequest(const PKG::AbstractData *request); - - /** - * @brief thisNode This method return the node object of this node - * @param returnValue This is return value of nodeobject - * @return This node object value. - */ - void thisNode(PKG::NodeObject & returnValue) const; - - /** - * @brief myKnowAddresses - * @return set of know addresses - */ - QSet myKnowAddresses() const; - - bool welcomeAddress(AbstractNodeInfo *node) override; - - /** - * @brief connectionRegistered - this impletation send incomming node welcom message with information about yaster self. - * @param info incominng node info. - */ - void nodeConnected(AbstractNodeInfo *node) override; - - /** - * @brief nodeConfirmend - this implementation test nodes to double connections - * @param mode - */ - void nodeConfirmend(AbstractNodeInfo *sender) override; - - /** - * @brief nodeDisconnected - this implementation remove nodes info from connection cache - * @param sender - */ - void nodeDisconnected(AbstractNodeInfo *node) override; - - /** - * @brief incomingData - this signal invoked when node get command or ansver - * @param pkg - received package - * @param sender - sender of the package - * @note override this method for get a signals. - */ - virtual void incomingData(PKG::AbstractData* pkg, - const NodeId& sender); - - void incomingData(PKG::AbstractData* pkg, - const AbstractNodeInfo* sender) override; - - /** - * @brief keyStorageLocation - return location of storagge of keys. - * @return path to the location of keys storage - */ - QString keyStorageLocation() const; - - -private: - - /** - * @brief workWithNodeObjectData - this method working with received node object data. - * @param node - * @param nodeInfo - * @return true if function finished successful - */ - bool workWithNodeObjectData(const QSharedPointer &node, const AbstractNodeInfo *nodeInfo); - - /** - * @brief workWithKnowAddresses - * @param node - * @param nodeInfo - * @return - */ - bool workWithKnowAddresses(const PKG::KnowAddresses &obj, const AbstractNodeInfo *nodeInfo); - - /** - * @brief workWithTransportData - * @param transportData - * @param sender - * @param pkg - * @return - */ - ParserResult workWithTransportData(const QSharedPointer &, - const AbstractNodeInfo *sender, const Header &hdr); - - /** - * @brief workWithNetworkRequest - * @param networkRequest - * @param sender - * @param pkg - * @return - */ - ParserResult workWithNetworkRequest(const QSharedPointer &networkRequest, - const AbstractNodeInfo *sender); - - - /** - * @brief optimizeRoute - this method reduces the size of the route by removing unnecessary nodes. - * @param node - * @param rawRoute - * @return - */ - bool optimizeRoute(const NodeId& node, - const HostAddress& currentNodeAddress, const AbstractNodeInfo *sender, - QList rawRoute); - - /** - * @brief incomingData - this implementation move old incoming method into private section - * becouse base node work with BaseID addresses. - * @warning Do not call this implementation on this class, - * use the ncomingData(AbstractData* pkg, const HostAddress& sender) implementation. - */ - void incomingData(PKG::AbstractData* pkg, - const HostAddress& sender) override final; - - - KeyStorage *_nodeKeys = nullptr; - - Router *_router = nullptr; - - QHash _connections; - - mutable QMutex _connectionsMutex; - -}; - - -} -#endif // NETWORKNODE_H diff --git a/Heart/NetworkSpace/networknodeinfo.cpp b/Heart/NetworkSpace/networknodeinfo.cpp deleted file mode 100644 index fb16fae5..00000000 --- a/Heart/NetworkSpace/networknodeinfo.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "networknodeinfo.h" -#include "dbaddress.h" -#include -#include - -namespace QH { - - -NetworkNodeInfo::NetworkNodeInfo(QAbstractSocket *tcp, const HostAddress* address): - AbstractNodeInfo(tcp, address){} - -NetworkNodeInfo::~NetworkNodeInfo() = default; - -bool NetworkNodeInfo::isValid() const { - return AbstractNodeInfo::isValid(); -} - -bool NetworkNodeInfo::isKnowAddress(const NodeId &address) const { - return _knowAddresses.contains(address); -} - -void NetworkNodeInfo::setSelfId(const NodeId &selfId) { - _selfId = selfId; - _knowAddresses.insert(_selfId); -} - -void NetworkNodeInfo::addKnowAddresses(const QSet &newAddressses) { - _knowAddresses += newAddressses; -} - -bool NetworkNodeInfo::confirmData() const { - return AbstractNodeInfo::confirmData() && _selfId.isValid(); -} - -const NodeId &NetworkNodeInfo::selfId() const -{ - return _selfId; -} - -} diff --git a/Heart/NetworkSpace/networknodeinfo.h b/Heart/NetworkSpace/networknodeinfo.h deleted file mode 100644 index b743193c..00000000 --- a/Heart/NetworkSpace/networknodeinfo.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef NETWORKCONNECTIONINFO_H -#define NETWORKCONNECTIONINFO_H - -#include "basenodeinfo.h" -#include "nodeid.h" -#include "heart_global.h" -#include - -class QAbstractSocket; -namespace QH { - -class DbAddress; - -/** - * @brief The BaseNodeInfo class contaisn list of nodes id of know this node. - */ -class HEARTSHARED_EXPORT NetworkNodeInfo: public AbstractNodeInfo { - -public: - - /** - * @brief NetworkNodeInfo - create node info from the tcp descriptor - * @param tcp - tcp socket dsscriptor - */ - explicit NetworkNodeInfo(QAbstractSocket * tcp = nullptr, - const HostAddress* clientAddress = nullptr); - ~NetworkNodeInfo() override; - - /** - * @brief isValid - * @return true if node is valid. - */ - bool isValid() const override; - - /** - * @brief isKnowAddress - * @param address - * @return - */ - bool isKnowAddress(const NodeId& address) const; - - /** - * @brief setSelfId - * @param selfId - */ - void setSelfId(const NodeId &selfId); - - /** - * @brief addKnowAddresses - */ - void addKnowAddresses(const QSet &newAddressses); - - /** - * @brief confirmData - this implementaton check self id of node. - * @return true if node contains valid self id. - */ - bool confirmData() const override; - - /** - * @brief selfId This method return id of This node. - * @return return selfId object - */ - const NodeId& selfId() const; - -protected: - QSet _knowAddresses; - NodeId _selfId; -}; - -} - -#endif // NETWORKCONNECTIONINFO_H diff --git a/Heart/NetworkSpace/nodeid.cpp b/Heart/NetworkSpace/nodeid.cpp deleted file mode 100644 index 88c6ad05..00000000 --- a/Heart/NetworkSpace/nodeid.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "nodeid.h" -namespace QH { - -NodeId::NodeId() = default; - - -QH::NodeId::NodeId(const QVariant &val) { - QVariant::Type type = val.type(); - if(type == QVariant::Type::ByteArray) { - fromRaw(val.toByteArray()); - } else if (type == QVariant::Type::String) { - fromBase64(val.toByteArray()); - } else { - unsigned int integer = val.toUInt(); - fromRaw(reinterpret_cast(&integer), sizeof (integer)); - } -} - -NodeId::NodeId(unsigned int val) { - fromRaw(reinterpret_cast(&val), sizeof (val)); -} - -NodeId::NodeId(const QByteArray &raw) { - fromRaw(raw); -} - -NodeId::NodeId(const QString &base64) { - fromBase64(base64.toLatin1()); -} - -bool NodeId::fromBase64(const QByteArray &base64) { - return fromRaw(QByteArray::fromBase64(base64, QByteArray::Base64UrlEncoding)); -} - -bool NodeId::fromRaw(const QByteArray &raw) { - _data = raw; - return isValid(); -} - -bool NodeId::fromRaw(const char *data, int len) { - _data.clear(); - _data.insert(0, data, len); - return isValid(); -} - -QByteArray NodeId::toBase64() const { - return _data.toBase64(QByteArray::Base64UrlEncoding); -} - -const QByteArray& NodeId::toRaw() const { - return _data; -} - -bool NodeId::isValid() const { - return _data.size(); -} - -void NodeId::clear() { - _data.clear(); -} - -QString NodeId::toString() const { - return toBase64(); -} - -QDataStream &NodeId::fromStream(QDataStream &stream) { - stream >> _data; - return stream; -} - -QDataStream &NodeId::toStream(QDataStream &stream) const { - stream << _data; - return stream; -} - -bool operator==(const NodeId &left, const NodeId &other) { - return left._data == other._data; -} - - -uint qHash(const QH::NodeId &object) { - return qHash(object.toRaw()); -} - -} - diff --git a/Heart/NetworkSpace/nodeid.h b/Heart/NetworkSpace/nodeid.h deleted file mode 100644 index e85c0a1a..00000000 --- a/Heart/NetworkSpace/nodeid.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef BaseId_H -#define BaseId_H - -#include -#include - -namespace QH { - -/** - * @brief The NodeId class. General class for work with database id. - * The Database id is hash (sha256) from object value. - * For more information about get hash code of databae objects see the DBObject::generateId method. - */ -class HEARTSHARED_EXPORT NodeId: public StreamBase -{ -public: - NodeId(); - - /** - * @brief NodeId This constructor for init NodeId from the QVariantObject - * @param val - */ - explicit NodeId(const QVariant& val); - - - /** - * @brief NodeId This contructor init the id from int value. - * @param val This is new data value. - */ - NodeId(unsigned int val); - - /** - * @brief NodeId This contructor init this object from raw bytearray. - * @param raw - */ - NodeId(const QByteArray& raw); - - /** - * @brief NodeId This constructor init this object from base 64 codec. - * @param base64 string with base 64 codec. This string will bew converted to a bytes array. - */ - NodeId(const QString& base64); - - /** - * @brief fromBase64 This method is wraper of QByteArray::fromBase64 method of Qt. - * @param base64 string with base 64 codec. This string will bew converted to a bytes array. - * @return True if the initialize of this object fuinished successful. - */ - bool fromBase64(const QByteArray& base64); - - /** - * @brief fromRaw This method conver a raw QByteArray to the BaseId key. - * @param raw This is raw bytes array. - * @return True if the initialize of this object fuinished successful. - */ - bool fromRaw(const QByteArray& raw); - - /** - * @brief fromRaw This is wraper initializing from the C bytes array. - * @param data This is raw data array. - * @param len This is length of data. - * @return True if the initialize of this object fuinished successful. - */ - bool fromRaw(const char* data, int len); - - /** - * @brief toBase64 This method convert this object to the base 64 string. - * @return The base64 string value. - */ - QByteArray toBase64() const; - - /** - * @brief toRaw This method convert this object to raw bytes array. - * @return raw data array. - */ - const QByteArray& toRaw() const; - - /** - * @brief isValid This method check this object to valid. - * @return true if object is valid. - */ - bool isValid() const; - - /** - * @brief clear This method reset all data members of this object. - */ - void clear(); - - /** - * @brief toString This method return base64 stringValue of the address. - * @return string value of address. - */ - QString toString() const; - - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - - friend bool operator== (const NodeId& left, const NodeId& other); - -private: - QByteArray _data; -}; - - -/** - * @brief qHash This function calc the 32bit hash of the BaseId object. - * @param object This is input object data. - * @return unsigned int 32 value. - */ -uint qHash(const QH::NodeId& object); - -} - - -#endif // BaseId_H diff --git a/Heart/NetworkSpace/packages/badnoderequest.cpp b/Heart/NetworkSpace/packages/badnoderequest.cpp deleted file mode 100644 index 795d153e..00000000 --- a/Heart/NetworkSpace/packages/badnoderequest.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "badnoderequest.h" -namespace QH { -namespace PKG { - -BadNodeRequest::BadNodeRequest() { - -} - -BadNodeRequest::BadNodeRequest(const ErrorData &err):BadRequest(err) { - -} - -BadNodeRequest::BadNodeRequest(const Package &package): BadRequest(package) { - -} - -bool BadNodeRequest::isValid() const { - return BadRequest::isValid() && senderID().isValid(); -} - -bool BadNodeRequest::copyFrom(const AbstractData * other) { - if (!BadRequest::copyFrom(other)) - return false; - - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - setSenderID(otherObject->senderID()); - return true; -} - -QDataStream &BadNodeRequest::fromStream(QDataStream &stream) { - BadRequest::fromStream(stream); - - NodeId senderNode; - stream >> senderNode; - setSenderID(senderNode); - - return stream; -} - -QDataStream &BadNodeRequest::toStream(QDataStream &stream) const { - BadRequest::toStream(stream); - stream << senderID(); - - return stream; -} -} -} diff --git a/Heart/NetworkSpace/packages/badnoderequest.h b/Heart/NetworkSpace/packages/badnoderequest.h deleted file mode 100644 index 69961c74..00000000 --- a/Heart/NetworkSpace/packages/badnoderequest.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef BADNODEREQUEST_H -#define BADNODEREQUEST_H - -#include "senderdata.h" - -#include - -namespace QH { -namespace PKG { - -/** - * @brief The BadNodeRequest class - bad request command for bae node level - */ -class HEARTSHARED_EXPORT BadNodeRequest: public BadRequest, public SenderData -{ -public: - explicit BadNodeRequest(); - explicit BadNodeRequest(const ErrorData &err); - explicit BadNodeRequest(const Package& package); - - // AbstractData interface - bool isValid() const; - bool copyFrom(const AbstractData *); - - // StreamBase interface -protected: - QDataStream &fromStream(QDataStream &stream); - QDataStream &toStream(QDataStream &stream) const; -}; -} -} -#endif // BADNODEREQUEST_H diff --git a/Heart/NetworkSpace/packages/knowaddresses.cpp b/Heart/NetworkSpace/packages/knowaddresses.cpp deleted file mode 100644 index fb79b46c..00000000 --- a/Heart/NetworkSpace/packages/knowaddresses.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "knowaddresses.h" - -#include - -namespace QH { -namespace PKG { - -KnowAddresses::KnowAddresses() { - -} - -KnowAddresses::KnowAddresses(const Package &pkg) { - fromBytes(pkg.toBytes()); - -} - -bool KnowAddresses::isValid() const { - return AbstractData::isValid(); -} - -bool KnowAddresses::copyFrom(const AbstractData * other) { - if (!AbstractData::copyFrom(other)) - return false; - - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - this->_knowAddresses = otherObject->_knowAddresses; - - return true; -} - -QDataStream &KnowAddresses::fromStream(QDataStream &stream) { - AbstractData::fromStream(stream); - - stream >> _knowAddresses; - - return stream; -} - -QDataStream &KnowAddresses::toStream(QDataStream &stream) const { - AbstractData::toStream(stream); - - stream << _knowAddresses; - - return stream; -} - -QSet KnowAddresses::knowAddresses() const { - return _knowAddresses; -} - -void KnowAddresses::setKnowAddresses(const QSet &knowAddresses) { - _knowAddresses = knowAddresses; -} -} -} diff --git a/Heart/NetworkSpace/packages/knowaddresses.h b/Heart/NetworkSpace/packages/knowaddresses.h deleted file mode 100644 index 65fba07e..00000000 --- a/Heart/NetworkSpace/packages/knowaddresses.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef KNOWADDRESSES_H -#define KNOWADDRESSES_H - -#include -#include -#include - -namespace QH { -namespace PKG { - -/** - * @brief The KnowAddresses class - this class is package for send the list of know addresses of node to other node object. - */ -class HEARTSHARED_EXPORT KnowAddresses: public AbstractData -{ -public: - KnowAddresses(); - KnowAddresses(const Package &pkg); - - // AbstractData interface - bool isValid() const override; - bool copyFrom(const AbstractData *) override; - - QSet knowAddresses() const; - void setKnowAddresses(const QSet &knowAddresses); - - - // StreamBase interface -protected: - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - -private: - QSet _knowAddresses; -}; -} -} -#endif // KNOWADDRESSES_H diff --git a/Heart/NetworkSpace/packages/longping.cpp b/Heart/NetworkSpace/packages/longping.cpp deleted file mode 100644 index b1f63c6d..00000000 --- a/Heart/NetworkSpace/packages/longping.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "longping.h" - -namespace QH { -namespace PKG { - -LongPing::LongPing(const NodeId &sender) { - - setSenderID(sender); -} - -LongPing::LongPing(const Package &from) { - fromBytes(from.data); -} - -bool LongPing::isValid() const { - return Ping::isValid() && _senderID.isValid(); -} - -bool LongPing::copyFrom(const AbstractData * other) { - if (!Ping::copyFrom(other)) - return false; - - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - this->_senderID = otherObject->_senderID; - return true; -} - -QDataStream &LongPing::fromStream(QDataStream &stream) { - Ping::fromStream(stream); - stream >> _senderID; - return stream; -} - -QDataStream &LongPing::toStream(QDataStream &stream) const { - Ping::toStream(stream); - stream << _senderID; - return stream; -} -} -} diff --git a/Heart/NetworkSpace/packages/longping.h b/Heart/NetworkSpace/packages/longping.h deleted file mode 100644 index b7f57df9..00000000 --- a/Heart/NetworkSpace/packages/longping.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef LONGPING_H -#define LONGPING_H - -#include "ping.h" -#include - -namespace QH { -namespace PKG { - -/** - * @brief The LongPing class - test class for big network with return addresse - */ -class HEARTSHARED_EXPORT LongPing: public Ping, public SenderData -{ -public: - LongPing(const NodeId &sender); - LongPing(const Package& from); - - // AbstractData interface - bool isValid() const override; - bool copyFrom(const AbstractData *) override; - - // StreamBase interface -protected: - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - -}; -} -} -#endif // LONGPING_H diff --git a/Heart/NetworkSpace/packages/networkrequest.cpp b/Heart/NetworkSpace/packages/networkrequest.cpp deleted file mode 100644 index a7cd312d..00000000 --- a/Heart/NetworkSpace/packages/networkrequest.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "networkrequest.h" - -#include -namespace QH { -namespace PKG { - -NetworkRequest::NetworkRequest() { - -} - -NetworkRequest::NetworkRequest(const Package &package): - NetworkRequest() { - - fromBytes(package.data); -} - -bool NetworkRequest::isValid() const { - return AbstractData::isValid() && _askedNodes.size() && _dataRequest.isValid(); -} - -bool NetworkRequest::copyFrom(const AbstractData * other) { - if (!AbstractData::copyFrom(other)) - return false; - - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - this->_dataRequest = otherObject->_dataRequest; - this->_askedNodes = otherObject->_askedNodes; - this->_dataResponce = otherObject->_dataResponce; - - return true; -} - -Package NetworkRequest::dataRequest() const { - return _dataRequest; -} - -void NetworkRequest::setDataRequest(const Package &data) { - _dataRequest = data; -} - -Package NetworkRequest::dataResponce() const { - return _dataResponce; -} - -void NetworkRequest::setDataResponce(const Package &data) { - _dataResponce = data; -} - -bool NetworkRequest::isComplete() const { - return _dataResponce.isValid(); -} - -void NetworkRequest::addNodeRequiringData(const NodeId &node) { - _askedNodes.insert(node); -} - -QDataStream &NetworkRequest::fromStream(QDataStream &stream) { - AbstractData::fromStream(stream); - - stream >> _dataRequest; - stream >> _askedNodes; - stream >> _dataResponce; - return stream; - -} - -QDataStream &NetworkRequest::toStream(QDataStream &stream) const { - AbstractData::toStream(stream); - - stream << _dataRequest; - stream << _askedNodes; - stream << _dataResponce; - - return stream; -} - -QSet NetworkRequest::askedNodes() const { - return _askedNodes; -} - -void NetworkRequest::removeNodeFromAskedList(const NodeId &node) { - _askedNodes.remove(node); -} - - -} -} diff --git a/Heart/NetworkSpace/packages/networkrequest.h b/Heart/NetworkSpace/packages/networkrequest.h deleted file mode 100644 index 8dace2f7..00000000 --- a/Heart/NetworkSpace/packages/networkrequest.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef NETWORKREQUEST_H -#define NETWORKREQUEST_H - -#include -#include -#include - - -namespace QH { -namespace PKG { - -/** - * @brief The NetworkRequest class - this is pakcage wraper for sending requests to network. - * this packages generated when current node can not process a request from client node. - * This request moving by network while do not get a ansver. - * The Ansver (or Responce) it is package with all needed data for processing of a request. - */ -class HEARTSHARED_EXPORT NetworkRequest: public AbstractData -{ -public: - explicit NetworkRequest(); - explicit NetworkRequest(const Package& package); - - // AbstractData interface - /** - * @brief isValid chck this package - * @return true if package is valid - */ - bool isValid() const override; - - /** - * @brief copyFrom - create a copy of this pacakge - * @return - */ - bool copyFrom(const AbstractData *) override; - - /** - * @brief dataRequest - this is package of not processed reqest. - * @return Package of request - */ - Package dataRequest() const; - - /** - * @brief setDataRequest - set Data of Reqest Package. - * @param data new pakcage. - */ - void setDataRequest(const Package &data); - - /** - * @brief dataResponce - this is package of responce of request. - * The Responce package contains all needed data for procesing a request. - * @return pakage of Responce - */ - Package dataResponce() const; - - /** - * @brief setDataResponce - set Data of Responce package. - * @note If this package contains a responce of request then package is completed. - * @param data - is Responce pacakge - */ - void setDataResponce(const Package &data); - - /** - * @brief isComplete - return complete status. If this package contains a responce of request then package is completed. - * @return true if package is complete. - */ - bool isComplete() const; - - /** - * @brief addNodeRequiringData - add a node to the list of nodes that need a responce of the request - * @param node - id of node - */ - void addNodeRequiringData(const NodeId& node); - - /** - * @brief askedNodes - return list of nodes that need a responce of the request - * @return list of nodes id. - */ - QSet askedNodes() const; - - /** - * @brief removeNodeFromAskedList - remove a node from list of nodes that need a responce of the request. - * Invoke this method when the node will get a responce. - * @param node - */ - void removeNodeFromAskedList(const NodeId& node); - -protected: - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - -private: - Package _dataRequest; - QSet _askedNodes; - Package _dataResponce; - -}; -} -} -#endif // NETWORKREQUEST_H diff --git a/Heart/NetworkSpace/packages/nodeobject.cpp b/Heart/NetworkSpace/packages/nodeobject.cpp deleted file mode 100644 index 4d793f57..00000000 --- a/Heart/NetworkSpace/packages/nodeobject.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "nodeobject.h" -#include - -namespace QH { -namespace PKG { - -NodeObject::NodeObject() { - -} - -NodeObject::NodeObject(const Package &pkg): - AbstractNetworkMember(pkg) { - -} - -QDataStream &NodeObject::fromStream(QDataStream &stream) { - - AbstractNetworkMember::fromStream(stream); - - stream >> _senderID; - - return stream; -} - -QDataStream &NodeObject::toStream(QDataStream &stream) const { - AbstractNetworkMember::toStream(stream); - - stream << _senderID; - - return stream; -} - -bool NodeObject::init() { - if (!AbstractNetworkMember::init()) - return false; - - if (authenticationData().isEmpty()) { - return true; - } - - setId(QString(NodeId(QCryptographicHash::hash(authenticationData(), - QCryptographicHash::Sha256)).toBase64())); - - return true; -} - -DBObject *NodeObject::createDBObject() const { - return create(); -} - -bool NodeObject::copyFrom(const AbstractData *other) { - if (!AbstractNetworkMember::copyFrom(other)) { - return false; - } - - auto otherObject = dynamic_cast(other); - if (!otherObject) - return false; - - _senderID = otherObject->_senderID; - - return true; -} - -} -} diff --git a/Heart/NetworkSpace/packages/nodeobject.h b/Heart/NetworkSpace/packages/nodeobject.h deleted file mode 100644 index 956b8e29..00000000 --- a/Heart/NetworkSpace/packages/nodeobject.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef NODEOBJECT_H -#define NODEOBJECT_H - -#include -#include -namespace QH { -namespace PKG { - -/** - * @brief The NodeObject class - */ -class HEARTSHARED_EXPORT NodeObject: public AbstractNetworkMember, public SenderData -{ -public: - NodeObject(); - NodeObject(const Package& pkg); - - DBObject *createDBObject() const override; - bool copyFrom(const AbstractData *other) override; - - // StreamBase interface -protected: - QDataStream &fromStream(QDataStream &stream) override; - QDataStream &toStream(QDataStream &stream) const override; - bool init() override; -}; -} -} -#endif // NODEOBJECT_H diff --git a/Heart/NetworkSpace/packages/transportdata.cpp b/Heart/NetworkSpace/packages/transportdata.cpp deleted file mode 100644 index d6033f7e..00000000 --- a/Heart/NetworkSpace/packages/transportdata.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "transportdata.h" -#include -#include -#include -namespace QH { -namespace PKG { - -TransportData::TransportData() { - -} - -TransportData::TransportData(const HostAddress &sender): - TransportData() { - - addNodeToRoute(sender); -} - -TransportData::TransportData(const Package &package): - TransportData() { - - fromBytes(package.data); -} - -void TransportData::completeRoute(bool fRouteIsComplete) { - _fRouteIsComplete = fRouteIsComplete; -} - -const Package &TransportData::data() const { - return _data; -} - -void TransportData::setData(const Package &data) { - _data = data; - - QByteArray tmp = _data.data; - quint64 time = QDateTime::currentMSecsSinceEpoch(); - tmp.insert(sizeof(time), reinterpret_cast(&time)); - - _packageId.fromRaw(QCryptographicHash::hash(tmp, QCryptographicHash::Sha256)); -} - -bool TransportData::setData(const AbstractData &data) { - Package pkg; - if (!data.toPackage(pkg)) { - return false; - } - - setData(pkg); - return true; -} - -QDataStream &TransportData::fromStream(QDataStream &stream) { - AbstractData::fromStream(stream); - - stream >> _targetAddress; - stream >> _senderID; - stream >> _packageId; - stream >> _fRouteIsComplete; - stream >> _route; - - QByteArray array; - stream >> array; - _data.fromBytes(array); - - return stream; -} - -QDataStream &TransportData::toStream(QDataStream &stream) const { - - AbstractData::toStream(stream); - - stream << _targetAddress; - stream << _senderID; - stream << _packageId; - stream << _fRouteIsComplete; - stream << _route; - - stream << _data.toBytes(); - - return stream; -} - -const NodeId& TransportData::packageId() const { - return _packageId; -} - -const QList& TransportData::route() const { - return _route; -} - -bool TransportData::setRoute(const QList &route) { - - QSet test; - for (const auto& address: route) { - if (test.contains(address)) - return false; - - test.insert(address); - } - - _route = route; - completeRoute(_route.size()); - - return _route.size(); -} - -void TransportData::addNodeToRoute(const HostAddress &node) { - _route.push_back(node); -} - -bool TransportData::strip(const HostAddress &correntAddress, - const HostAddress &availabelTarget) { - - QList::Iterator begin = _route.end(); - QList::Iterator end = _route.end(); - - for (auto it = _route.begin(); it != _route.end(); ++it) { - if (correntAddress == *it) { - begin = it; - } - - if (availabelTarget == *it) { - end = it; - break; - } - } - - if (begin != _route.end() && end != _route.end()) { - _route.erase(begin, end); - return true; - } - - return false; -} - -const NodeId &TransportData::targetAddress() const { - return _targetAddress; -} - -void TransportData::setTargetAddress(const NodeId &targetAddress) { - _targetAddress = targetAddress; -} - -bool TransportData::isValid() const { - return AbstractData::isValid() && _data.isValid() && _targetAddress.isValid(); -} - -bool TransportData::isHaveRoute() const { - return isValid() && _route.size() && _fRouteIsComplete; -} -} -} diff --git a/Heart/NetworkSpace/packages/transportdata.h b/Heart/NetworkSpace/packages/transportdata.h deleted file mode 100644 index 22ce9fd9..00000000 --- a/Heart/NetworkSpace/packages/transportdata.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef TRANSPORTDATA_H -#define TRANSPORTDATA_H - -#include "abstractdata.h" -#include "senderdata.h" - -#include "hostaddress.h" - -namespace QH { -namespace PKG { - -class HEARTSHARED_EXPORT TransportData: public AbstractData, public SenderData -{ - -public: - - explicit TransportData(const HostAddress& sender); - explicit TransportData(const Package& package); - - const Package& data() const; - void setData(const Package &data); - bool setData(const AbstractData& data); - bool isValid() const; - bool isHaveRoute() const; - - /** - * @brief targetAddress - targetAddress - * @return - */ - const NodeId& targetAddress() const; - void setTargetAddress(const NodeId &targetAddress); - - /** - * @brief route - is list of addresses of node was the TransportData has been moved. - * @return - */ - const QList &route() const; - - /** - * @brief setRoute - set and validate route. - * @param route - * @return true if a new route is valid - */ - bool setRoute(const QList &route); - - /** - * @brief addNodeToRoute - push back new node to route - * @param node - node address - */ - void addNodeToRoute(const HostAddress &node); - - /** - * @brief strip - this method remove a range addresses from route of transport data. from correntAddress to availabelTarget - * @param correntAddress - begin of remove - * @param availabelTarget - end of remove - * @return true if all addresses is removed - */ - bool strip(const HostAddress& correntAddress, const HostAddress& availabelTarget); - - /** - * @brief packageId - * @return unique package id. - */ - const NodeId &packageId() const; - - /** - * @brief completeRoute - set bool variable of route complete. - * @param fRouteIsComplete - new value for complete route default is true - */ - void completeRoute(bool fRouteIsComplete = true); - -protected: - QDataStream &fromStream(QDataStream &stream); - QDataStream &toStream(QDataStream &stream) const; - -private: - explicit TransportData(); - - Package _data; - NodeId _targetAddress; - QList _route; - NodeId _packageId; - bool _fRouteIsComplete = false; - - - -}; -} -} -#endif // TRANSPORTDATA_H diff --git a/Heart/NetworkSpace/qsecretrsa2048.cpp b/Heart/NetworkSpace/qsecretrsa2048.cpp deleted file mode 100644 index bc2d2072..00000000 --- a/Heart/NetworkSpace/qsecretrsa2048.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "cryptopairkeys.h" -#include "qsecretrsa2048.h" -#include -#include - -namespace QH { - -QSecretRSA2048::QSecretRSA2048() { - qtSecret = new QRSAEncryption(QRSAEncryption::RSA_2048); -} - -CryptoPairKeys QSecretRSA2048::generate(const QByteArray &genesis) const { - QByteArray pubKey; - QByteArray privKey; - - qtSecret->generatePairKey(pubKey, privKey, genesis); - - return {pubKey, privKey}; -} - -bool QSecretRSA2048::crypt(QByteArray *data, - const QByteArray &publicKey) { - *data = qtSecret->encode(*data, publicKey); - - return data->size(); -} - -bool QSecretRSA2048::decrypt(QByteArray *cryptedData, - const QByteArray &privateKey) { - *cryptedData = qtSecret->decode(*cryptedData, privateKey); - - return cryptedData->size(); -} - -bool QSecretRSA2048::sign(QByteArray *data, - const QByteArray &privateKey) { - - *data = qtSecret->signMessage(*data, privateKey); - return data->size(); - -} - -bool QSecretRSA2048::check(const QByteArray &signedData, - const QByteArray &publicKey) { - - return qtSecret->checkSignMessage(signedData, publicKey); -} - -QByteArray QSecretRSA2048::extractSign(const QByteArray &data) { - - int end = data.lastIndexOf("-SIGN-"); - int begin = data.lastIndexOf("-SIGN-", end); - - if (end < 0 || begin < 0) { - return {}; - } - - return QByteArray::fromHex(data.mid(begin, begin - end)); -} - -QByteArray QSecretRSA2048::concatSign(const QByteArray &data, const QByteArray &sign) { - return data + "-SIGN-" + sign.toHex() + "-SIGN-"; -} - -bool QSecretRSA2048::isValid() const { - return qtSecret; -} - -QSecretRSA2048::~QSecretRSA2048() { - delete qtSecret; -} - -} diff --git a/Heart/NetworkSpace/qsecretrsa2048.h b/Heart/NetworkSpace/qsecretrsa2048.h deleted file mode 100644 index 62fbbd0a..00000000 --- a/Heart/NetworkSpace/qsecretrsa2048.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef QSECRETRSA2048_H -#define QSECRETRSA2048_H - -#include "icrypto.h" - -#include - -class QRSAEncryption; - -namespace QH { - -/** - * @brief The QSecretRSA2048 class Use a QtSecret library for implementation RSA alghoritms. - */ -class HEARTSHARED_EXPORT QSecretRSA2048: public ICrypto -{ - // ICrypto interface -public: - QSecretRSA2048(); - ~QSecretRSA2048() override; - bool crypt(QByteArray *data, const QByteArray &publicKey) override; - bool decrypt(QByteArray *cryptedData, const QByteArray &privateKey) override; - bool sign(QByteArray *data, const QByteArray &privateKey) override; - bool check(const QByteArray &signedData, const QByteArray &publicKey) override; - QByteArray extractSign(const QByteArray &data) override; - QByteArray concatSign(const QByteArray &data, const QByteArray &sign) override; - - bool isValid() const override; - -protected: - CryptoPairKeys generate(const QByteArray& genesis = {}) const override; - - -private: - QRSAEncryption *qtSecret = nullptr; - - -}; -} -#endif // QSECRETRSA2048_H diff --git a/Heart/NetworkSpace/router.cpp b/Heart/NetworkSpace/router.cpp deleted file mode 100644 index 77340bdd..00000000 --- a/Heart/NetworkSpace/router.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "router.h" -#include - -#include -#include -namespace QH { - -Router::Router() { -} - -QList Router::getRoute(const NodeId &node) const { - QMutexLocker locker(&_routesMutex); - return _routes.value(node); -} - -bool Router::contains(const NodeId &node) const { - QMutexLocker locker(&_routesMutex); - return _routes.contains(node); -} - -void Router::updateRoute(const NodeId &node, const QList &route) { - QMutexLocker locker(&_routesMutex); - - debug_assert(node.isValid()); - - if (!_routes.contains(node) || _routes.value(node).size() > route.size()) { - - _routesTimeMap.insert(QDateTime::currentSecsSinceEpoch(), node); - _routes.insert(node, route); - - if (ROUTE_CACHE_LIMIT < _processedPackages.size()) { - _routes.remove(*_routesTimeMap.begin()); - _routesTimeMap.erase(_routesTimeMap.begin()); - } - } -} - -void Router::addProcesedPackage(const NodeId &id) { - QMutexLocker locker(&_processedPackagesMutex); - - _processedPackages.insert(id); - _processedPackagesTimeMap.insert(QDateTime::currentSecsSinceEpoch(), id); - - if (TRANSPORT_PACKAGES_CACHE < _processedPackages.size()) { - _processedPackages.remove(*_processedPackagesTimeMap.begin()); - _processedPackagesTimeMap.erase(_processedPackagesTimeMap.begin()); - } -} - -bool Router::isProcessed(const NodeId &id) const { - QMutexLocker locker(&_processedPackagesMutex); - - return _processedPackages.contains(id); - -} -} diff --git a/Heart/NetworkSpace/router.h b/Heart/NetworkSpace/router.h deleted file mode 100644 index 189663e3..00000000 --- a/Heart/NetworkSpace/router.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef ROUTER_H -#define ROUTER_H -#include -#include "nodeid.h" -#include -#include -#include - -namespace QH { - -/** - * @brief The Router class - this class contains routes of nodes and optimise exists routes - * router - is thread save class. - */ -class Router -{ -public: - Router(); - - /** - * @brief getRoute - * @return return route to node from this node - */ - QList getRoute(const NodeId& node) const; - - /** - * @brief contains - check contains route fo node id. - * @param node - id of node - * @return true if route findet. - */ - bool contains(const NodeId& node) const; - - - /** - * @brief updateRoute - set a new route for a node if the new route is shorter than the old route - * @param node - * @param route - */ - void updateRoute(const NodeId& node, const QList& route); - - /** - * @brief addProcesedPackage - add id of processed package - * @param id - */ - void addProcesedPackage(const NodeId& id); - - /** - * @brief isProcessed - * @param id - * @return true if package is processed - */ - bool isProcessed(const NodeId& id) const; -private: - QHash> _routes; - QMap _routesTimeMap; - mutable QMutex _routesMutex; - - QSet _processedPackages; - QMap _processedPackagesTimeMap; - mutable QMutex _processedPackagesMutex; - -}; -} -#endif // ROUTER_H diff --git a/Heart/NetworkSpace/senderdata.cpp b/Heart/NetworkSpace/senderdata.cpp deleted file mode 100644 index f4a621fc..00000000 --- a/Heart/NetworkSpace/senderdata.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "senderdata.h" -namespace QH { - -SenderData::SenderData() { - -} - -const NodeId &SenderData::senderID() const { - return _senderID; -} - -void SenderData::setSenderID(const NodeId &senderID) { - _senderID = senderID; -} -} diff --git a/Heart/NetworkSpace/senderdata.h b/Heart/NetworkSpace/senderdata.h deleted file mode 100644 index 420e983d..00000000 --- a/Heart/NetworkSpace/senderdata.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef SENDERDATA_H -#define SENDERDATA_H -#include "nodeid.h" - -namespace QH { - -/** - * @brief The SenderData class - this is base interface class for get sender id of data base objects - */ -class HEARTSHARED_EXPORT SenderData -{ -public: - SenderData(); - - const NodeId& senderID() const; - void setSenderID(const NodeId &senderID); - -protected: - NodeId _senderID; -}; -} -#endif // SENDERDATA_H diff --git a/Heart/NetworkSpace/sign.cpp b/Heart/NetworkSpace/sign.cpp deleted file mode 100644 index 38f0646d..00000000 --- a/Heart/NetworkSpace/sign.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "sign.h" -namespace QH { - -Sign::Sign() -{ - -} - -QByteArray Sign::sign() const { - return _sign; -} - -void Sign::setSign(const QByteArray &sign) { - _sign = sign; -} -} diff --git a/Heart/NetworkSpace/sign.h b/Heart/NetworkSpace/sign.h deleted file mode 100644 index 1bd1ce3a..00000000 --- a/Heart/NetworkSpace/sign.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef SIGN_H -#define SIGN_H - -#include -#include "heart_global.h" - - -namespace QH { - -/** - * @brief The Sign class - this class contains sign of child data package. - */ -class HEARTSHARED_EXPORT Sign -{ -public: - Sign(); - - QByteArray sign() const; - void setSign(const QByteArray &sign); - - QByteArray& sign(); - - /** - * @brief dataForSigned - thism metho return byte array for signed - * @return data array - */ - virtual QByteArray dataForSigned() const = 0; - -private: - QByteArray _sign; -}; -} -#endif // SIGN_H diff --git a/HeartTests/DataBaseSpace/databasetestnode.h b/HeartTests/DataBaseSpace/databasetestnode.h index 515aa5b4..5b1c1787 100644 --- a/HeartTests/DataBaseSpace/databasetestnode.h +++ b/HeartTests/DataBaseSpace/databasetestnode.h @@ -4,7 +4,7 @@ #include namespace QH { -class ISqlDBCache; +class ISqlDB; class SqlDBWriter; } @@ -12,7 +12,7 @@ template class DataBaseTestNode: public BASE { protected: - void initDefaultDbObjects(QH::ISqlDBCache *cache, + void initDefaultDbObjects(QH::ISqlDB *cache, QH::SqlDBWriter *writer) override { if (!writer) { writer = new WRITER(); diff --git a/HeartTests/DataBaseSpace/upgradedatabasetest.cpp b/HeartTests/DataBaseSpace/upgradedatabasetest.cpp index 350efb34..6ec50f63 100644 --- a/HeartTests/DataBaseSpace/upgradedatabasetest.cpp +++ b/HeartTests/DataBaseSpace/upgradedatabasetest.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include From 6a635443759cc37ce8900fddfa232b48f159f61d Mon Sep 17 00:00:00 2001 From: EndrII Date: Fri, 25 Nov 2022 21:12:36 +0300 Subject: [PATCH 05/19] fix build --- Heart/AbstractSpace/abstractnode.cpp | 4 +- Heart/AbstractSpace/abstractnodeinfo.cpp | 1 + Heart/AbstractSpace/abstractnodeinfo.h | 53 ++--- Heart/AbstractSpace/apiversionparser.cpp | 9 +- Heart/AbstractSpace/apiversionparser.h | 6 +- Heart/AbstractSpace/distversion.cpp | 39 +++ Heart/AbstractSpace/distversion.h | 51 ++++ Heart/DataBaseSpace/Res/BaseDB.sql | 30 --- Heart/DataBaseSpace/Res/UserDB.sql | 39 --- Heart/DataBaseSpace/database.cpp | 31 --- Heart/DataBaseSpace/database.h | 16 -- Heart/DataBaseSpace/dberrorcodes.cpp | 57 ----- Heart/DataBaseSpace/isqldb.cpp | 1 - Heart/DataBaseSpace/packages/dbobject.cpp | 4 - Heart/DataBaseSpace/packages/dbobject.h | 8 - Heart/ProtockolResusces.qrc | 2 - Heart/heart.h | 11 - .../private/testsingleserver.cpp | 20 -- .../DataBaseSpace/private/testsingleserver.h | 31 --- .../private/testsingleserverclient.cpp | 31 --- .../private/testsingleserverclient.h | 36 --- HeartTests/DataBaseSpace/singleservertest.cpp | 224 ------------------ HeartTests/DataBaseSpace/singleservertest.h | 47 ---- HeartTests/NetworkSpace/networknodetest.cpp | 175 -------------- HeartTests/NetworkSpace/networknodetest.h | 81 ------- .../NetworkSpace/networknodeunittests.cpp | 33 --- .../NetworkSpace/networknodeunittests.h | 27 --- HeartTests/NetworkSpace/networktestutils.cpp | 124 ---------- HeartTests/NetworkSpace/networktestutils.h | 37 --- 29 files changed, 119 insertions(+), 1109 deletions(-) create mode 100644 Heart/AbstractSpace/distversion.cpp create mode 100644 Heart/AbstractSpace/distversion.h delete mode 100644 Heart/DataBaseSpace/Res/UserDB.sql delete mode 100644 Heart/DataBaseSpace/dberrorcodes.cpp delete mode 100644 HeartTests/DataBaseSpace/private/testsingleserver.cpp delete mode 100644 HeartTests/DataBaseSpace/private/testsingleserver.h delete mode 100644 HeartTests/DataBaseSpace/private/testsingleserverclient.cpp delete mode 100644 HeartTests/DataBaseSpace/private/testsingleserverclient.h delete mode 100644 HeartTests/DataBaseSpace/singleservertest.cpp delete mode 100644 HeartTests/DataBaseSpace/singleservertest.h delete mode 100644 HeartTests/NetworkSpace/networknodetest.cpp delete mode 100644 HeartTests/NetworkSpace/networknodetest.h delete mode 100644 HeartTests/NetworkSpace/networknodeunittests.cpp delete mode 100644 HeartTests/NetworkSpace/networknodeunittests.h delete mode 100644 HeartTests/NetworkSpace/networktestutils.cpp delete mode 100644 HeartTests/NetworkSpace/networktestutils.h diff --git a/Heart/AbstractSpace/abstractnode.cpp b/Heart/AbstractSpace/abstractnode.cpp index 57d280ce..09108eb4 100644 --- a/Heart/AbstractSpace/abstractnode.cpp +++ b/Heart/AbstractSpace/abstractnode.cpp @@ -69,8 +69,8 @@ AbstractNode::AbstractNode( QObject *ptr): _tasksheduller = new TaskScheduler(); _apiVersionParser = new APIVersionParser(this); - _apiVersionParser->addApiParser(); - _apiVersionParser->addApiParser(); + _apiVersionParser->addApiParser(this); + _apiVersionParser->addApiParser(this); qRegisterMetaType>(); #ifdef USE_HEART_SSL diff --git a/Heart/AbstractSpace/abstractnodeinfo.cpp b/Heart/AbstractSpace/abstractnodeinfo.cpp index 68094d65..37a7880d 100644 --- a/Heart/AbstractSpace/abstractnodeinfo.cpp +++ b/Heart/AbstractSpace/abstractnodeinfo.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace QH { diff --git a/Heart/AbstractSpace/abstractnodeinfo.h b/Heart/AbstractSpace/abstractnodeinfo.h index a1a43762..e0503284 100644 --- a/Heart/AbstractSpace/abstractnodeinfo.h +++ b/Heart/AbstractSpace/abstractnodeinfo.h @@ -9,7 +9,9 @@ #define ABSTRACTNODEINFO_H #include "hostaddress.h" +#include "distversion.h" #include "heart_global.h" +#include "iparser.h" #include @@ -18,25 +20,6 @@ class QHostInfo; namespace QH { -class iParser; - -/** - * @brief The DistVersion class This is infirmation of supported versions of the distanation api. - */ -struct DistVersion { - - /// This is monimum supported version. - unsigned short min = 0; - - /// This is maximum supported version. - unsigned short max = 0; -}; - -/** - * @brief VersionData This is array of all avalable apis and supported its versions. - */ -typedef QHash VersionData; - /** * @brief The TrustNode enum contains cases for trust of the client or nodes. */ @@ -246,6 +229,22 @@ class HEARTSHARED_EXPORT AbstractNodeInfo: public QObject */ void setFVersionDelivered(bool newFVersionDelivered); + /** + * @brief getParser This method return parser of choosed command. + * @param cmd This is command that need to parse. + * @return parser of the @a cmd comand. + */ + QSharedPointer getParser(unsigned short cmd); + + /** + * @brief addParser This method add to cache new parser for command . + * @param cmd + * @param parser + * @note All parsers will be removed after reconnect of this node. + */ + void addParser(unsigned short cmd, QSharedPointer parser); + + public slots: /** * @brief removeSocket This method use for remove socket. @@ -298,22 +297,6 @@ public slots: */ void statusChaned(QH::AbstractNodeInfo* thisNode, QH::NodeCoonectionStatus status); - /** - * @brief getParser This method return parser of choosed command. - * @param cmd This is command that need to parse. - * @return parser of the @a cmd comand. - */ - QSharedPointer getParser(unsigned short cmd); - - /** - * @brief addParser This method add to cache new parser for command . - * @param cmd - * @param parser - * @note All parsers will be removed after reconnect of this node. - */ - void addParser(unsigned short cmd, QSharedPointer parser); - - protected: /** diff --git a/Heart/AbstractSpace/apiversionparser.cpp b/Heart/AbstractSpace/apiversionparser.cpp index e7ba21eb..3f9db045 100644 --- a/Heart/AbstractSpace/apiversionparser.cpp +++ b/Heart/AbstractSpace/apiversionparser.cpp @@ -7,6 +7,7 @@ #include "apiversionparser.h" #include "abstractnodeinfo.h" +#include "distversion.h" #include #include @@ -107,7 +108,7 @@ APIVersionParser::selectParser(const VersionData &distVersion) const { QHash> result; for (auto it = distVersion.begin(); it != distVersion.end(); ++it) { - for (int version = it->max; version >= it->min; --version) { + for (int version = it->max(); version >= it->min(); --version) { auto parser = _apiParsers[it.key()].value(version, nullptr); if (parser) result[it.key()] = parser; @@ -175,11 +176,11 @@ bool APIVersionParser::processAppVersion(const QSharedPointer &messa QuasarAppUtils::Params::log(QString("Can't found %0 parser for versions: %1-%2"). arg(parserKey). - arg(requiredApi.min). - arg(requiredApi.max), + arg(requiredApi.min()). + arg(requiredApi.max()), QuasarAppUtils::Error); - unsigned short distMinVersion = sender->version().value(parserKey).min; + unsigned short distMinVersion = sender->version().value(parserKey).min(); if (distMinVersion > maximumApiVersion(parserKey)) { emit sigNoLongerSupport(parserKey, distMinVersion); diff --git a/Heart/AbstractSpace/apiversionparser.h b/Heart/AbstractSpace/apiversionparser.h index 5b20995f..c7a08a70 100644 --- a/Heart/AbstractSpace/apiversionparser.h +++ b/Heart/AbstractSpace/apiversionparser.h @@ -62,9 +62,9 @@ class APIVersionParser: public QObject, public iParser * @brief addApiParser This is template metod that add sipport of new apiparser @a ApiType * @tparam ApiType This is type of new apiParser that will be added to the main parser. */ - template - void addApiParser() { - addApiParser(QSharedPointer::create(this)); + template + void addApiParser(Args&&... arg) { + addApiParser(QSharedPointer::create(std::forward(arg)...)); } /** diff --git a/Heart/AbstractSpace/distversion.cpp b/Heart/AbstractSpace/distversion.cpp new file mode 100644 index 00000000..bd72d9da --- /dev/null +++ b/Heart/AbstractSpace/distversion.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018-2022 QuasarApp. + * Distributed under the lgplv3 software license, see the accompanying + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. +*/ + +#include "distversion.h" +namespace QH { + +unsigned short DistVersion::max() const { + return _max; +} + +void DistVersion::setMax(unsigned short newMax) { + _max = newMax; +} + +QDataStream &DistVersion::fromStream(QDataStream &stream) { + stream >> _min; + stream >> _max; + return stream; +} + +QDataStream &DistVersion::toStream(QDataStream &stream) const { + stream << _min; + stream << _max; + return stream; +} + +unsigned short DistVersion::min() const { + return _min; +} + +void DistVersion::setMin(unsigned short newMin) { + _min = newMin; +} + +} diff --git a/Heart/AbstractSpace/distversion.h b/Heart/AbstractSpace/distversion.h new file mode 100644 index 00000000..6c8d3f95 --- /dev/null +++ b/Heart/AbstractSpace/distversion.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2018-2022 QuasarApp. + * Distributed under the lgplv3 software license, see the accompanying + * Everyone is permitted to copy and distribute verbatim copies + * of this license document, but changing it is not allowed. +*/ + +#ifndef DISTVERSION_H +#define DISTVERSION_H + +#include +#include + + +namespace QH { + +/** + * @brief The DistVersion class This is infirmation of supported versions of the distanation api. + */ +class DistVersion: public StreamBase { + +public: + + unsigned short min() const; + void setMin(unsigned short newMin); + unsigned short max() const; + void setMax(unsigned short newMax); + +protected: + + QDataStream &fromStream(QDataStream &stream) override; + QDataStream &toStream(QDataStream &stream) const override; + +private: + + /// This is monimum supported version. + unsigned short _min = 0; + + /// This is maximum supported version. + unsigned short _max = 0; + +}; + + +/** + * @brief VersionData This is array of all avalable apis and supported its versions. + */ +typedef QHash VersionData; + +} +#endif // DISTVERSION_H diff --git a/Heart/DataBaseSpace/Res/BaseDB.sql b/Heart/DataBaseSpace/Res/BaseDB.sql index 4aaef506..1c1fdeb8 100644 --- a/Heart/DataBaseSpace/Res/BaseDB.sql +++ b/Heart/DataBaseSpace/Res/BaseDB.sql @@ -1,35 +1,5 @@ -- This is base table of network member (clients) -- all additional information must be conteins in the another tables with links to the NetworkMembers table. -CREATE TABLE IF NOT EXISTS NetworkMembers ( - id VARCHAR(32) PRIMARY KEY, - authenticationData BLOB NOT NULL, - trust INTEGER default 0 -); - --- The MemberPermisions table contains link to anothe database object and links to users of the database with permission lvl. -CREATE TABLE IF NOT EXISTS MemberPermisions ( - memberId VARCHAR(32) NOT NULL, - -- This field contatins a base64 implementation of a sha256 (requariment 44 bytes) hash code of a database address - dbAddress VARCHAR(44) NOT NULL, - lvl tinyint NOT NULL, - - FOREIGN KEY(memberId) REFERENCES NetworkMembers(id) - ON UPDATE CASCADE - ON DELETE CASCADE - -); - -CREATE UNIQUE INDEX IF NOT EXISTS MemberPermisionsIndex ON MemberPermisions(memberId, dbAddress); - --- The DefaultPermissions table contains addresses of tables. and default permisions for all network members -CREATE TABLE IF NOT EXISTS DefaultPermissions ( - dbAddress VARCHAR(44) NOT NULL UNIQUE, - lvl tinyint NOT NULL, - - FOREIGN KEY(dbAddress) REFERENCES MemberPermisions(dbAddress) - ON UPDATE CASCADE - ON DELETE CASCADE -); CREATE TABLE IF NOT EXISTS DataBaseAttributes ( name TEXT NOT NULL PRIMARY KEY, diff --git a/Heart/DataBaseSpace/Res/UserDB.sql b/Heart/DataBaseSpace/Res/UserDB.sql deleted file mode 100644 index d3b4dee7..00000000 --- a/Heart/DataBaseSpace/Res/UserDB.sql +++ /dev/null @@ -1,39 +0,0 @@ --- This is base table of network member (users) --- id is unique fiels for login and execute select queries (for get user information without user id). --- all additional information must be conteins in the another tables with links to the NetworkMembers table. -CREATE TABLE IF NOT EXISTS NetworkMembers ( - id VARCHAR(32) PRIMARY KEY, - authenticationData BLOB NOT NULL, - trust INTEGER default 0, - token BLOB default NULL -); - --- The MemberPermisions table contains link to anothe database object and links to users of the database with permission lvl. -CREATE TABLE IF NOT EXISTS MemberPermisions ( - memberId VARCHAR(32) NOT NULL, - -- This field contatins a base64 implementation of a sha256 (requariment 44 bytes) hash code of a database address - dbAddress VARCHAR(44) NOT NULL, - lvl tinyint NOT NULL, - - FOREIGN KEY(memberId) REFERENCES NetworkMembers(id) - ON UPDATE CASCADE - ON DELETE CASCADE - -); - -CREATE UNIQUE INDEX IF NOT EXISTS MemberPermisionsIndex ON MemberPermisions(memberId, dbAddress); - --- The DefaultPermissions table contains addresses of tables. and default permisions for all network members -CREATE TABLE IF NOT EXISTS DefaultPermissions ( - dbAddress VARCHAR(44) NOT NULL UNIQUE, - lvl tinyint NOT NULL, - - FOREIGN KEY(dbAddress) REFERENCES MemberPermisions(dbAddress) - ON UPDATE CASCADE - ON DELETE CASCADE -); - -CREATE TABLE IF NOT EXISTS DataBaseAttributes ( - name TEXT NOT NULL PRIMARY KEY, - value INT NOT NULL UNIQUE -); diff --git a/Heart/DataBaseSpace/database.cpp b/Heart/DataBaseSpace/database.cpp index cd11535e..7432d6fe 100644 --- a/Heart/DataBaseSpace/database.cpp +++ b/Heart/DataBaseSpace/database.cpp @@ -6,14 +6,11 @@ */ #include "database.h" -#include "sqldbcache.h" #include "sqldbwriter.h" #include "asyncsqldbwriter.h" #include #include -#include -#include #include #include #include @@ -132,16 +129,6 @@ bool DataBase::welcomeAddress(AbstractNodeInfo *) { return true; } -bool DataBase::isBanned(const QString &node) const { - NetworkMember member(node); - auto objectFromDataBase = db()->getObject(member); - - if (!objectFromDataBase) - return false; - - return objectFromDataBase->trust() <= 0; -} - QStringList DataBase::SQLSources() const{ return { DEFAULT_DB_INIT_FILE_PATH @@ -186,24 +173,6 @@ QString DataBase::dbLocation() const { return ""; } -bool DataBase::changeTrust(const QString &id, int diff) { - if (!_db) - return false; - - auto action = [diff](const QSharedPointer &object) { - auto obj = object.dynamicCast(); - if (!obj) { - return false; - } - - obj->changeTrust(diff); - - return true; - }; - - return _db->changeObjects(NetworkMember{id}, action); -} - ISqlDB *DataBase::db() const { return _db; } diff --git a/Heart/DataBaseSpace/database.h b/Heart/DataBaseSpace/database.h index e100a53f..1f883f3c 100644 --- a/Heart/DataBaseSpace/database.h +++ b/Heart/DataBaseSpace/database.h @@ -89,28 +89,12 @@ class HEARTSHARED_EXPORT DataBase: public QObject */ virtual QVariantMap defaultDbParams() const; - /** - * @brief isBanned This method check trust of node, if node trust is lover of 0 return true. - * @param member This is member of network (node, client or server). - * @return true if node is banned. - */ - bool isBanned(const QString &member) const; - /** * @brief dbLocation This method return location of nodes or clients database. * @return path to the location of database. */ QString dbLocation() const; - /** - * @brief changeTrust This implementation of change trust is change trust node or user by self id. - * All changes of trust saving into local database. - * @param id This is id of user of other network member object. - * @param diff This is difference of trust. - * @return true if trust of user changed successful. - */ - bool changeTrust(const QString &id, int diff); - signals: /** diff --git a/Heart/DataBaseSpace/dberrorcodes.cpp b/Heart/DataBaseSpace/dberrorcodes.cpp deleted file mode 100644 index cd5bf2ea..00000000 --- a/Heart/DataBaseSpace/dberrorcodes.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2020-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "dberrorcodes.h" -namespace QH { - -namespace ErrorCodes { - -QString DBErrorCodesHelper::toString(QH::ErrorCodes::Code enumData) { - switch (enumData) { - - case ErrorCodes::InternalError: { - return "Internal server error." - " Please create issue about this problem in the support page " - " https://github.com/QuasarApp/Heart/issues/new"; - } - - case ErrorCodes::UserExits: { - return "Such user already exists "; - } - - case ErrorCodes::UserNotExits: { - return "Such user not exists "; - } - - case ErrorCodes::UserInvalidPasswoed: { - return "Invalid password "; - } - - case ErrorCodes::UserAlreadyLogged: { - return "User Already Logged"; - } - - case ErrorCodes::UserNotLogged: { - return "User is not Logged"; - } - - case ErrorCodes::TimeOutError: { - return "Server response timed out "; - } - - case OperatioForbiden: { - return "Permission denied"; - } - - default: return AbstractErrorCodesHelper::toString(enumData); - - } -} - -} - -} diff --git a/Heart/DataBaseSpace/isqldb.cpp b/Heart/DataBaseSpace/isqldb.cpp index 45dd150b..083b9797 100644 --- a/Heart/DataBaseSpace/isqldb.cpp +++ b/Heart/DataBaseSpace/isqldb.cpp @@ -9,7 +9,6 @@ #include "quasarapp.h" #include "sqldbwriter.h" #include "dbaddresskey.h" -#include "permisiondata.h" #include #include diff --git a/Heart/DataBaseSpace/packages/dbobject.cpp b/Heart/DataBaseSpace/packages/dbobject.cpp index a0a28321..4b87d05c 100644 --- a/Heart/DataBaseSpace/packages/dbobject.cpp +++ b/Heart/DataBaseSpace/packages/dbobject.cpp @@ -161,10 +161,6 @@ bool DBObject::isBundle() const { return false; } -uint DBObject::dbKey() const { - return HASH_KEY(DbAddressKey(dbAddress())); -} - QString DBObject::condition() const { // prepare key value to string condition diff --git a/Heart/DataBaseSpace/packages/dbobject.h b/Heart/DataBaseSpace/packages/dbobject.h index 8d291d00..fb20bba0 100644 --- a/Heart/DataBaseSpace/packages/dbobject.h +++ b/Heart/DataBaseSpace/packages/dbobject.h @@ -320,14 +320,6 @@ class HEARTSHARED_EXPORT DBObject : public AbstractData */ virtual bool isBundle() const; - /** - * @brief dbKey This method return unique key for this object. - * For more information see AbstractKey::hash method. - * This method calc hash of {id:table} data. - * @return unique key of this object. - */ - virtual uint dbKey() const; - /** * @brief dbAddress This method return address of the database object. * IF the object is not valid then this method return an invalid database address. diff --git a/Heart/ProtockolResusces.qrc b/Heart/ProtockolResusces.qrc index 20c66c9d..ac86a4ff 100644 --- a/Heart/ProtockolResusces.qrc +++ b/Heart/ProtockolResusces.qrc @@ -2,7 +2,5 @@ DataBaseSpace/Res/DbConfig.json DataBaseSpace/Res/BaseDB.sql - NetworkSpace/Res/NetworkDB.sql - DataBaseSpace/Res/UserDB.sql diff --git a/Heart/heart.h b/Heart/heart.h index 5c199951..555b8d20 100644 --- a/Heart/heart.h +++ b/Heart/heart.h @@ -9,18 +9,7 @@ #define NETWORKPROTOCOL_H #include "package.h" - -#if HEART_BUILD_LVL >= 0 #include "abstractnode.h" -#endif - -#if HEART_BUILD_LVL >= 1 -#include "databasenode.h" -#endif - -#if HEART_BUILD_LVL >= 2 -#include "networknode.h" -#endif inline void initResources() { Q_INIT_RESOURCE(ProtockolResusces); } diff --git a/HeartTests/DataBaseSpace/private/testsingleserver.cpp b/HeartTests/DataBaseSpace/private/testsingleserver.cpp deleted file mode 100644 index db9a7014..00000000 --- a/HeartTests/DataBaseSpace/private/testsingleserver.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2020-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "testsingleserver.h" - -const QH::PKG::Ping &TestSingleServer::getPing() const { - return _ping; -} - -void TestSingleServer::incomingData(const QH::PKG::AbstractData *pkg, const QH::AbstractNodeInfo *sender) { - Q_UNUSED(sender) - - auto ping = dynamic_cast(pkg); - if (ping) - _ping.setAnsver(ping->ansver()); -} diff --git a/HeartTests/DataBaseSpace/private/testsingleserver.h b/HeartTests/DataBaseSpace/private/testsingleserver.h deleted file mode 100644 index b3b812a5..00000000 --- a/HeartTests/DataBaseSpace/private/testsingleserver.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2020-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef TESTSINGLESERVER_H -#define TESTSINGLESERVER_H -#include -#include -#include - -class TestSingleServer: public QH::SingleServer { - - Q_OBJECT - - // AbstractNode interface -public: - const QH::PKG::Ping& getPing() const; - -protected: - void incomingData(const QH::PKG::AbstractData *pkg, const QH::AbstractNodeInfo* sender) override; - -private: - QH::PKG::Ping _ping; - - friend class SingleServerTest; -}; - -#endif // TESTSINGLESERVER_H diff --git a/HeartTests/DataBaseSpace/private/testsingleserverclient.cpp b/HeartTests/DataBaseSpace/private/testsingleserverclient.cpp deleted file mode 100644 index 30c03a09..00000000 --- a/HeartTests/DataBaseSpace/private/testsingleserverclient.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2020-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "testsingleserverclient.h" -#include "test.h" - -const QH::PKG::Ping &TestSingleServerClient::getPing() const { - return _ping; -} - -void TestSingleServerClient::setStatus(const QH::ClientStatus &status) { - QH::SingleClient::setStatus(status); -} - -QPair TestSingleServerClient::serverAddress() const { - return {TEST_LOCAL_HOST, LOCAL_TEST_PORT}; -} - -void TestSingleServerClient::incomingData(const QH::PKG::AbstractData *pkg, - const QH::AbstractNodeInfo *sender) { - Q_UNUSED(sender) - - auto ping = dynamic_cast(pkg); - if (ping) - _ping.setAnsver(ping->ansver()); -} diff --git a/HeartTests/DataBaseSpace/private/testsingleserverclient.h b/HeartTests/DataBaseSpace/private/testsingleserverclient.h deleted file mode 100644 index 92a3df0d..00000000 --- a/HeartTests/DataBaseSpace/private/testsingleserverclient.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2020-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#ifndef TESTSINGLESERVERCLIENT_H -#define TESTSINGLESERVERCLIENT_H - -#include -#include -#define LOCAL_TEST_PORT TEST_PORT + 3 - - -class TestSingleServerClient: public QH::SingleClient -{ -public: - Q_OBJECT - - // AbstractNode interface -public: - const QH::PKG::Ping& getPing() const; - void setStatus(const QH::ClientStatus &status);; - -protected: - QPair serverAddress() const override; - void incomingData(const QH::PKG::AbstractData *pkg, const QH::AbstractNodeInfo* sender) override; - -private: - QH::PKG::Ping _ping; - - friend class SingleServerTest; -}; - -#endif // TESTSINGLESERVERCLIENT_H diff --git a/HeartTests/DataBaseSpace/singleservertest.cpp b/HeartTests/DataBaseSpace/singleservertest.cpp deleted file mode 100644 index abb2c2dd..00000000 --- a/HeartTests/DataBaseSpace/singleservertest.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2020-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - -#include "singleservertest.h" - -#include - -#include -#include - -SingleServerTest::SingleServerTest() { - _client = new TestSingleServerClient(); - _server = new TestSingleServer(); - - -} - -SingleServerTest::~SingleServerTest() { - _client->softDelete(); - _server->softDelete(); -} - -void SingleServerTest::test() { - QVERIFY(initTest()); - loginTest(); -} - -void SingleServerTest::loginTest() { - - // Init default client and server objects. - auto client = dynamic_cast(_client); - auto server = dynamic_cast(_server); - - const QString user = "client"; - const QString userPassword = "123"; - - // init using lymbda functions. - auto connectToserver = [client](){ - return client->connectToServer(); - }; - - auto removeRequest = [client]() { - return client->removeUser(); - }; - - auto loginRequestWithPassword = [client, &user, &userPassword]() { - return client->login(user, userPassword); - }; - - auto loginRequestWithInvalidPassword = [client, &user]() { - return client->login(user, "zz"); - }; - - auto loginRequestUsesToken = [client, &user]() { - return client->login(user); - }; - - auto logout = [client]() { - return client->logout(); - }; - - auto sigupRequest = [client, &user, &userPassword]() { - return client->signup(user, userPassword); - }; - - auto dissconnectRequest = [client]() { - client->disconnectFromServer(); - return true; - }; - - auto checkLoginedStatus = [client](){ - return client->getStatus() == QH::ClientStatus::Logined; - }; - - auto checkDisconnectedStatus = [client](){ - return client->getStatus() == QH::ClientStatus::Dissconnected; - }; - - auto checkConnectedStatus = [client](){ - return client->getStatus() == QH::ClientStatus::Connected; - }; - - auto checkLoginNonExitsUser = [client](){ - return client->takeLastError() == static_cast(QH::ErrorCodes::UserNotExits); - }; - - auto checksigupExitsUser = [client](){ - return client->takeLastError() == static_cast(QH::ErrorCodes::UserExits); - }; - - auto checkLoginInvalidPassword = [client](){ - return client->takeLastError() == static_cast(QH::ErrorCodes::UserInvalidPasswoed); - }; - - auto checkRemoveNotLoginningClient = [client](){ - return client->takeLastError() == static_cast(QH::ErrorCodes::UserNotLogged); - }; - - QVERIFY(client && server); - - if (!client) - return; - - // Client must be gat a QH::ClientStatus::Dissconnected status. - QVERIFY(client->getStatus() == QH::ClientStatus::Dissconnected); - - QVERIFY(client->connectToServer()); - - - // Client must be gat a QH::ClientStatus::Connecting status after connect. - QVERIFY(client->getStatus() == QH::ClientStatus::Connecting); - - // All attempts of the loginor or registered must be failed because the client have an offline status. - QVERIFY(!client->login(user)); - - QVERIFY(!client->login(user, userPassword)); - - QVERIFY(!client->signup(user, userPassword)); - - // Run server - QVERIFY(server->run(TEST_LOCAL_HOST, LOCAL_TEST_PORT, "SingleServer")); - - // Clent must be connected because the server alredy started successful. - QVERIFY(funcPrivateConnect(connectToserver, checkConnectedStatus)); - - // The attempt of the login must be failed bacause the server do not have a user with wroted name. - QVERIFY(client->login(user, userPassword)); - - // Client must be gat a QH::ClientStatus::Loginning status after a successful login. - QVERIFY(client->getStatus() == QH::ClientStatus::Loginning); - - QVERIFY(funcPrivateConnect([](){return true;}, checkLoginNonExitsUser)); - - QVERIFY(funcPrivateConnect(loginRequestWithPassword, checkLoginNonExitsUser)); - - // The attempt of the signup must be finished successful bacause user with wroted name not exists. - QVERIFY(funcPrivateConnect(sigupRequest, checkLoginedStatus)); - - // logout client and try login again. - QVERIFY(funcPrivateConnect(logout, checkConnectedStatus)); - - // waiting of the reflection of the server. This needed because server do not responce about successful logout. - wait([](){return false;}, 500); - - // This login must be failed bacause clients token is removed after logout mehod. - QVERIFY(!client->login(user)); - - // must be finished successful because client is unlogined. - QVERIFY(funcPrivateConnect(loginRequestWithPassword, checkLoginedStatus)); - - // disconnect client and try login again with login without password. - QVERIFY(funcPrivateConnect(dissconnectRequest, checkDisconnectedStatus)); - - // Client must be gat a QH::ClientStatus::Dissconnected status. - QVERIFY(client->getStatus() == QH::ClientStatus::Dissconnected); - - // Clent must be connected because the server alredy started successful. - QVERIFY(funcPrivateConnect(connectToserver, checkConnectedStatus)); - - // must be finished successful because an unlogined client have a valid token. - QVERIFY(funcPrivateConnect(loginRequestUsesToken, checkLoginedStatus)); - - // logout client and try login again. - QVERIFY(funcPrivateConnect(logout, checkConnectedStatus)); - - // waiting of the reflection of the server. This needed because server do not responce about successful logout. - wait([](){return false;}, 500); - - // must be finished failed because client wrote invalid password. - QVERIFY(funcPrivateConnect(loginRequestWithInvalidPassword, checkLoginInvalidPassword)); - - // check client status after invalid login. status must be equal Connected because client receive a error message from server. - QVERIFY(client->getStatus() == QH::ClientStatus::Connected); - - // must be finished failed because client with wroted name is exists. - QVERIFY(funcPrivateConnect(sigupRequest, checksigupExitsUser)); - - //must be failed - QVERIFY(!client->removeUser()); - - // force set status loginned for testing validation on server. - client->setStatus(QH::ClientStatus::Logined); - - // must be finished failed because client is not loginned. and failed - QVERIFY(!funcPrivateConnect(removeRequest, checkRemoveNotLoginningClient)); - - client->setStatus(QH::ClientStatus::Connected); - - // must be finished successful because client is unlogined. - QVERIFY(funcPrivateConnect(loginRequestWithPassword, checkLoginedStatus)); - - //must be finished successful bacause client is loginned - QVERIFY(client->removeUser()); - - // waiting of the reflection of the server. This needed because server do not responce about successful operation. - wait([](){return false;}, 500); - - // must be finished successful because old user is removeed. - QVERIFY(funcPrivateConnect(sigupRequest, checkLoginedStatus)); - - // all tests is completed - -} - -bool SingleServerTest::initTest() { - auto server = dynamic_cast(_server); - - if (!server->run(TEST_LOCAL_HOST, LOCAL_TEST_PORT, "SingleServer")) { - return false; - } - - QString database = server->dbLocation(); - server->stop(); - - if (QFileInfo::exists(database) && !QFile::remove(database)) { - return false; - } - - return true; -} diff --git a/HeartTests/DataBaseSpace/singleservertest.h b/HeartTests/DataBaseSpace/singleservertest.h deleted file mode 100644 index 4d5dd380..00000000 --- a/HeartTests/DataBaseSpace/singleservertest.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2020-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef SINGLESERVERTESTS_H -#define SINGLESERVERTESTS_H -#include "basetestutils.h" -#include "test.h" -#include "testutils.h" -#include - -/** - * @brief The SingleServerTest class testing the QH::SingleServer and QH::SingleClient clases. - * This test case check next situations: - * 1. connect client to sercer - * 2. signup client to server - * 3. login client to server - * 4. remove clent record from server. - */ -class SingleServerTest: public Test, protected BaseTestUtils -{ -public: - SingleServerTest(); - ~SingleServerTest(); - - void test() override; - -private: - /** - * @brief connectNetworkTest - * this test check nodes connections greatThen 3 node - * @return - */ - void loginTest(); - - bool initTest(); - - - QH::AbstractNode *_server = nullptr; - QH::AbstractNode *_client = nullptr; -}; - -#endif // SINGLESERVERTESTS_H diff --git a/HeartTests/NetworkSpace/networknodetest.cpp b/HeartTests/NetworkSpace/networknodetest.cpp deleted file mode 100644 index 286f284d..00000000 --- a/HeartTests/NetworkSpace/networknodetest.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "networknodetest.h" -#include "networknodeunittests.h" -#include "testutils.h" - -#include -#include -#include -#include -#include - -class TestingNetworkClient: public QH::NetworkNode { - - - // AbstractNode interface -public: - const QH::PKG::Ping& getPing() const { - return _ping; - } - -protected: - void incomingData(QH::PKG::AbstractData *pkg, const QH::NodeId &sender) { - Q_UNUSED(sender); - - auto ping = dynamic_cast(pkg); - if (ping) - _ping.setAnsver(ping->ansver()); - } - -private: - QH::PKG::Ping _ping; -}; - -NetworkNodeTest::NetworkNodeTest() { - _nodeA = new TestingNetworkClient(); - _nodeB = new QH::NetworkNode(); - _nodeC = new TestingNetworkClient(); - -} - -NetworkNodeTest::~NetworkNodeTest() { - _nodeA->softDelete(); - _nodeB->softDelete(); - _nodeC->softDelete(); - -} - -void NetworkNodeTest::test() { - QVERIFY(dbTest()); - QVERIFY(powerTest()); - QVERIFY(connectNetworkTest()); - QVERIFY(transportDataTest()); - -// QVERIFY(performanceTest()); -// QVERIFY(securityTest()); - -} - -bool NetworkNodeTest::powerTest() { - auto _nodeAPtr = new QH::NetworkNode(); - - if (!_nodeAPtr->run(TEST_LOCAL_HOST, TEST_PORT, "powerTest")) { - return false; - }; - - _nodeAPtr->softDelete(); - - return true; -} - -bool NetworkNodeTest::dbTest() { - auto node = new NetworkNodeUnitTests; - - if (!node->test()) { - return false; - } - - node->softDelete(); - - return true; -} - -bool NetworkNodeTest::connectNetworkTest() { - int nodeAPort = TEST_PORT + 0; - int nodeBPort = TEST_PORT + 1; - int nodeCPort = TEST_PORT + 2; - - - auto _nodeAPtr = dynamic_cast(_nodeA); - auto _nodeBPtr = dynamic_cast(_nodeB); - auto _nodeCPtr = dynamic_cast(_nodeC); - - if (!_nodeAPtr->run(TEST_LOCAL_HOST, nodeAPort, "TestNodeA")) { - return false; - } - if (!_nodeBPtr->run(TEST_LOCAL_HOST, nodeBPort, "TestNodeB")) { - return false; - }; - if (!_nodeCPtr->run(TEST_LOCAL_HOST, nodeCPort, "TestNodeC")) { - return false; - }; - - auto nodeA = _nodeAPtr->nodeId(); - auto nodeB = _nodeBPtr->nodeId(); - auto nodeC = _nodeCPtr->nodeId(); - - - auto addNodeRequest = [_nodeAPtr, nodeBPort, nodeCPort, _nodeBPtr, nodeC]() { - _nodeAPtr->addNode(QH::HostAddress(TEST_LOCAL_HOST, nodeBPort)); - _nodeBPtr->addNode(QH::HostAddress(TEST_LOCAL_HOST, nodeCPort)); - return true; - }; - - auto checkNode = [_nodeAPtr, _nodeBPtr](){ - return _nodeAPtr->confirmendCount() && _nodeBPtr->confirmendCount(); - }; - - if (!funcPrivateConnect(addNodeRequest, checkNode)) { - return false; - } - - // need to wait for add node - - auto request = [_nodeAPtr, nodeC]() { - return _nodeAPtr->ping(nodeC); - }; - - auto client = dynamic_cast(_nodeAPtr); - - auto check = [client](){ - return client->getPing().ansver(); - }; - - return funcPrivateConnect(request, check); - -} - -bool NetworkNodeTest::transportDataTest() { - auto coreNode = getCoreNode(); - - auto network = generateNetworkNode(30); - - if (!(network.size() && coreNode->confirmendCount() == 30)) { - return false; - } - - return true; -} - -bool NetworkNodeTest::performanceTest() { - return false; -} - -bool NetworkNodeTest::securityTest() { - return false; -} - -bool NetworkNodeTest::testICtypto() { - // check - if (!validationCrypto()) { - return false; - } - - return true; -} - - - diff --git a/HeartTests/NetworkSpace/networknodetest.h b/HeartTests/NetworkSpace/networknodetest.h deleted file mode 100644 index 311b09ef..00000000 --- a/HeartTests/NetworkSpace/networknodetest.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef NETWORKNODETEST_H -#define NETWORKNODETEST_H -#include "networktestutils.h" -#include "test.h" -#include "testutils.h" - -#include - - -class NetworkNodeTest: public Test, protected NetworkTestUtils -{ -public: - NetworkNodeTest(); - ~NetworkNodeTest(); - - void test(); - -private: - QH::AbstractNode *_nodeA = nullptr; - QH::AbstractNode *_nodeB = nullptr; - QH::AbstractNode *_nodeC = nullptr; - - - /** - * @brief testICtypto This test checks a working of the keyStorages (QtSecret2048) - * @return true if tewst fifnished succesful - */ - bool testICtypto(); - - - /** - * @brief powerTest - this test just create a new object of node and distruct it. - * check constructors and distructors of nodes objects. - * @return true if the test finished successful - */ - bool powerTest(); - - /** - * @brief dbTest - test base functions of database of nodes. - * @return true if test finished successful. - */ - bool dbTest(); - - /** - * @brief connectNetworkTest - * this test check nodes connections greatThen 3 node - * @return - */ - bool connectNetworkTest(); - - /** - * @brief transportDataTest - * this test create a small network and sending data to next route : A >> B >> C and C >> B >> A - * @return - */ - bool transportDataTest(); - - /** - * @brief performanceTest - * this test crate a big network from 100 or biger nodes count and send data for all nodes of network. - * @return - */ - bool performanceTest(); - - /** - * @brief securityTest - this test create big network and create not valid nodes. After created the network a not valid nodes try conquer network. - * @return - */ - bool securityTest(); - -}; - -#endif // NETWORKNODETEST_H diff --git a/HeartTests/NetworkSpace/networknodeunittests.cpp b/HeartTests/NetworkSpace/networknodeunittests.cpp deleted file mode 100644 index e0c28c2a..00000000 --- a/HeartTests/NetworkSpace/networknodeunittests.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "networknodeunittests.h" -#include "test.h" -#include "sqldbcache.h" -#include -#include - -#define DB_NODE_NAME "DbTestNetworkNode" - -NetworkNodeUnitTests::NetworkNodeUnitTests(): - TemplateDataBaseNodeUnitTests(DB_NODE_NAME) { - -} - -QH::PKG::NodeObject *NetworkNodeUnitTests::randomMember() const { - - srand(time(nullptr)); - - QH::PKG::NodeObject * res = new QH::PKG::NodeObject(); - - res->setAuthenticationData(randomArray(64)); - res->setTrust(0); - res->prepareToSend(); - - return res; -} diff --git a/HeartTests/NetworkSpace/networknodeunittests.h b/HeartTests/NetworkSpace/networknodeunittests.h deleted file mode 100644 index 33efd41b..00000000 --- a/HeartTests/NetworkSpace/networknodeunittests.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef NETWORK_DBTESTS_H -#define NETWORK_DBTESTS_H - -#include -#include - -/** - * @brief The DbTestsNode class - this implementation of node gor testing database - */ -class NetworkNodeUnitTests: public TemplateDataBaseNodeUnitTests -{ -public: - NetworkNodeUnitTests(); - -protected: - QH::PKG::NodeObject *randomMember() const override; -}; - -#endif // NETWORK_DBTESTS_H diff --git a/HeartTests/NetworkSpace/networktestutils.cpp b/HeartTests/NetworkSpace/networktestutils.cpp deleted file mode 100644 index c0af50db..00000000 --- a/HeartTests/NetworkSpace/networktestutils.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "networktestutils.h" - -#include -#include "test.h" - -NetworkTestUtils::NetworkTestUtils() { - -} - -NetworkTestUtils::~NetworkTestUtils() { - if (coreNode) { - delete coreNode; - } -} - -QH::NetworkNode *NetworkTestUtils::initNewNode() const { - int port = nextPort(); - QString name = (coreNode)? QString("TestNode-%0").arg(port): QString("CoreNode-%0").arg(port); - - auto node = new QH::NetworkNode(); - - if (!node->run(TEST_LOCAL_HOST, port, name)) { - delete node; - return nullptr; - } - - return node; -} - -const QH::NetworkNode *NetworkTestUtils::getCoreNode() { - if (!coreNode) - coreNode = initNewNode(); - - - return coreNode; -} - -bool NetworkTestUtils::deployNewNode(QH::NetworkNode* node) const { - - if (!node) - return false; - - if (coreNode) { - - auto addNodeRequest = [node, this]() { - node->addNode(coreNode->address()); - return true; - }; - - auto checkNode = [node](){ - return node->confirmendCount(); - }; - - if (!funcPrivateConnect(addNodeRequest, checkNode)) { - delete node; - return false; - } - } - - return true; -} - -QHash -NetworkTestUtils::generateNetworkNode(int count) const { - - QHash result; - QSet tmp; - - auto deinit = [&tmp]() { - for (QH::NetworkNode * node : tmp) { - delete node; - } - tmp.clear(); - }; - - for (int i = 0; i < count; ++i) { - QH::NetworkNode *tmpNode = initNewNode(); - if (tmpNode) - tmp.insert(tmpNode); - } - - if (tmp.size() != count) { - deinit(); - return {}; - } - - for (QH::NetworkNode *node: tmp) { - if (!deployNewNode(node)) { - deinit(); - return {}; - } - } - - for (auto i : tmp) { - result.insert(i->nodeId(), i); - } - - auto check = [this, count](){ - return coreNode->confirmendCount() == count; - }; - - if (!funcPrivateConnect(nullptr, check)) { - deinit(); - return {}; - } - - result.insert(coreNode->nodeId(), coreNode); - - return result; -} - -int NetworkTestUtils::nextPort() const { - static int port = 0; - int baseTestPort = TEST_PORT + 1000; - return baseTestPort + port++; -} diff --git a/HeartTests/NetworkSpace/networktestutils.h b/HeartTests/NetworkSpace/networktestutils.h deleted file mode 100644 index bd2beda0..00000000 --- a/HeartTests/NetworkSpace/networktestutils.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef NETWORKTESTUTILS_H -#define NETWORKTESTUTILS_H - -#include -namespace QH { -class NetworkNode; -class NodeId; -} - -class NetworkTestUtils: public BaseTestUtils -{ -public: - NetworkTestUtils(); - ~NetworkTestUtils(); - - bool deployNewNode(QH::NetworkNode* node) const; - QHash generateNetworkNode(int count) const; - - QH::NetworkNode *initNewNode() const; - -protected: - const QH::NetworkNode* getCoreNode(); -private: - int nextPort() const; - - QH::NetworkNode* coreNode = nullptr; -}; - -#endif // NETWORKTESTUTILS_H From 0c2f937f81f78021b91039041db327657c712b8c Mon Sep 17 00:00:00 2001 From: EndrII Date: Sat, 26 Nov 2022 12:59:33 +0300 Subject: [PATCH 06/19] fix build --- .../Private/abstractnodeparser.cpp | 2 - Heart/AbstractSpace/abstractnode.cpp | 19 +--------- Heart/AbstractSpace/abstractnode.h | 22 ++--------- Heart/AbstractSpace/iparser.cpp | 17 ++++++++- Heart/AbstractSpace/iparser.h | 25 ++++++++++++- HeartTests/AbstractSpace/bigdatatest.cpp | 37 +++++++++++++------ 6 files changed, 70 insertions(+), 52 deletions(-) diff --git a/Heart/AbstractSpace/Private/abstractnodeparser.cpp b/Heart/AbstractSpace/Private/abstractnodeparser.cpp index 9506a131..58bef1e5 100644 --- a/Heart/AbstractSpace/Private/abstractnodeparser.cpp +++ b/Heart/AbstractSpace/Private/abstractnodeparser.cpp @@ -49,8 +49,6 @@ ParserResult AbstractNodeParser::parsePackage(const QSharedPointerincomingData(pkg.data(), sender); - if (PKG::Ping::command() == pkg->cmd()) { auto cmd = static_cast(pkg.data()); if (!cmd->ansver()) { diff --git a/Heart/AbstractSpace/abstractnode.cpp b/Heart/AbstractSpace/abstractnode.cpp index 09108eb4..3856b1b2 100644 --- a/Heart/AbstractSpace/abstractnode.cpp +++ b/Heart/AbstractSpace/abstractnode.cpp @@ -53,8 +53,7 @@ namespace QH { using namespace PKG; AbstractNode::AbstractNode( QObject *ptr): - QTcpServer(ptr), - iParser(this) { + QTcpServer(ptr) { initThreadId(); @@ -103,14 +102,6 @@ AbstractNode::~AbstractNode() { delete _apiVersionParser; } -int AbstractNode::version() const { - return 0; -} - -QString AbstractNode::parserId() const { - return ""; -} - bool AbstractNode::run(const QString &addres, unsigned short port) { if (!port) @@ -1168,7 +1159,7 @@ void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender, if (parseResult != ParserResult::Processed) { auto message = QString("Package not parsed! %0 \nresult: %1. \n%2"). - arg(pkg.toString(), pareseResultToString(parseResult), data->toString()); + arg(pkg.toString(), iParser::pareseResultToString(parseResult), data->toString()); QuasarAppUtils::Params::log(message, QuasarAppUtils::Warning); @@ -1211,12 +1202,6 @@ SslMode AbstractNode::getMode() const { return _mode; } -void AbstractNode::incomingData(const AbstractData *pkg, const AbstractNodeInfo *sender) { - Q_UNUSED(pkg) - Q_UNUSED(sender) - -} - QHash AbstractNode::connections() const { return _connections; } diff --git a/Heart/AbstractSpace/abstractnode.h b/Heart/AbstractSpace/abstractnode.h index cbc8606f..b2841dce 100644 --- a/Heart/AbstractSpace/abstractnode.h +++ b/Heart/AbstractSpace/abstractnode.h @@ -109,7 +109,7 @@ class Abstract; * @see AbstractNode::registerPackageType * @see AbstractNode::parsePackage */ -class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete, private iParser +class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete { Q_OBJECT @@ -497,19 +497,6 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete, pr bool disableSSL(); #endif - /** - * @brief incomingData This method invoked when node get command or ansver. - * This method invoked befor parsing in the parsePackage method. - * @note use this method for handling received data, but do not change the @a pkg object. - * If You want change pkg object use the parsePackage method. - * @param pkg This is received package (in this implementation it is only the Ping command) - * @param sender This is information of sender of the package. - * @note override this method for get a signals. - * @note This method will be invoked in the own thread. - */ - virtual void incomingData(const PKG::AbstractData* pkg, - const AbstractNodeInfo* sender); - /** * @brief connections - Return hash map of all connections of this node. * @return return map of connections. @@ -653,13 +640,10 @@ private slots: // iParser interface ParserResult parsePackage(const QSharedPointer &pkg, const Header &pkgHeader, - AbstractNodeInfo *sender) override; + AbstractNodeInfo *sender); QSharedPointer - genPackage(unsigned short cmd) const override final; - - int version() const override; - QString parserId() const override; + genPackage(unsigned short cmd) const; /** @note just disaable listen method in the node objects. diff --git a/Heart/AbstractSpace/iparser.cpp b/Heart/AbstractSpace/iparser.cpp index 574a102a..63344571 100644 --- a/Heart/AbstractSpace/iparser.cpp +++ b/Heart/AbstractSpace/iparser.cpp @@ -10,6 +10,8 @@ #include #include +#include "abstractnode.h" + namespace QH { iParser::iParser(AbstractNode *parentNode) { @@ -17,7 +19,7 @@ iParser::iParser(AbstractNode *parentNode) { debug_assert(_node, "All parsers shold be initialized with parent node"); } -QString iParser::pareseResultToString(const ParserResult &parseResult) const { +QString iParser::pareseResultToString(const ParserResult &parseResult) { switch (parseResult) { case ParserResult::Processed: @@ -46,4 +48,17 @@ AbstractNode *iParser::node() const { return _node; } +unsigned int iParser::sendData(const PKG::AbstractData *resp, + const HostAddress &address, + const Header *req) { + return node()->sendData(resp, address, req); +} + +unsigned int iParser::sendData(const PKG::AbstractData *resp, + const AbstractNodeInfo *dist, + const Header *req) { + return node()->sendData(resp, dist, req); + +} + } diff --git a/Heart/AbstractSpace/iparser.h b/Heart/AbstractSpace/iparser.h index 3209e334..084c67a6 100644 --- a/Heart/AbstractSpace/iparser.h +++ b/Heart/AbstractSpace/iparser.h @@ -9,6 +9,7 @@ #ifndef IPARSER_H #define IPARSER_H +#include "hostaddress.h" #include #include @@ -115,7 +116,7 @@ class HEARTSHARED_EXPORT iParser * @brief pareseResultToString This method convert ParserResult value to string. * @return The String value of pareseresult. */ - QString pareseResultToString(const ParserResult& parseResult) const; + static QString pareseResultToString(const ParserResult& parseResult); /** * @brief version This method return version of parser object @@ -206,6 +207,28 @@ class HEARTSHARED_EXPORT iParser protected: AbstractNode *node() const; + /** + * @brief sendData This method send data object another to node + * @param resp This is pointer to sendet object. + * @param address This is target addres for sending. + * @param req This is header of request. + * @return hash of the sendet package. If function is failed then return 0. + * @note This method is a just wraper of the AbstractNode::sendData method. + */ + virtual unsigned int sendData(const PKG::AbstractData *resp, const HostAddress& address, + const Header *req = nullptr); + + /** + * @brief sendData This method send data object another to node + * @param resp This is pointer to sendet object. + * @param address This is target addres for sending. + * @param req This is header of request. + * @return hash of the sendet package. If function is failed then return 0. + * @note This method is a just wraper of the AbstractNode::sendData method. + */ + virtual unsigned int sendData(const PKG::AbstractData *resp, const AbstractNodeInfo *node, + const Header *req = nullptr); + private: QHash> _registeredTypes; AbstractNode *_node; diff --git a/HeartTests/AbstractSpace/bigdatatest.cpp b/HeartTests/AbstractSpace/bigdatatest.cpp index 589fa449..2ec9dd73 100644 --- a/HeartTests/AbstractSpace/bigdatatest.cpp +++ b/HeartTests/AbstractSpace/bigdatatest.cpp @@ -34,17 +34,16 @@ class BigPackage: public QH::PKG::AbstractData { }; }; -class TestingClientBigData: public QH::AbstractNode { - - // AbstractNode interface -public: - TestingClientBigData(int i) { - Q_UNUSED(i); +class BigDataTestParser: public QH::iParser { + BigDataTestParser(QH::AbstractNode* parentNode): QH::iParser(parentNode) { registerPackageType(); data = new BigPackage(); + } + // iParser interface +public: bool sendRequest(const QByteArray& data) { BigPackage pkg; pkg.data = data; @@ -57,9 +56,9 @@ class TestingClientBigData: public QH::AbstractNode { return data; } -protected: - void incomingData(const QH::PKG::AbstractData *pkg, const QH::AbstractNodeInfo *sender) override { - Q_UNUSED(sender); + QH::ParserResult parsePackage(const QSharedPointer &pkg, + const QH::Header &pkgHeader, + QH::AbstractNodeInfo *sender) override { if (pkg->cmd() == BigPackage::command()) { @@ -67,17 +66,31 @@ class TestingClientBigData: public QH::AbstractNode { data->copy(*pkg); _mData.unlock(); sendData(data, sender); + return QH::ParserResult::Processed; } - } + + return QH::ParserResult::NotProcessed; + }; + int version() const override {return 0;}; + QString parserId() const override {return "BigDataTestParser";}; private: mutable QMutex _mData; BigPackage *data = nullptr; }; +class TestingClientBigData: public QH::AbstractNode { + + + // AbstractNode interface +public: + TestingClientBigData() { + } +}; + BigDataTest::BigDataTest() { - _nodeA = new TestingClientBigData(0); - _nodeB = new TestingClientBigData(0); + _nodeA = new TestingClientBigData(); + _nodeB = new TestingClientBigData(); } BigDataTest::~BigDataTest() { From 4336953a917cc50996fb931130e128c2fea8554a Mon Sep 17 00:00:00 2001 From: EndrII Date: Sun, 27 Nov 2022 16:19:41 +0300 Subject: [PATCH 07/19] temp commit --- Heart/AbstractSpace/Private/abstractnodeparser.cpp | 5 +++-- Heart/AbstractSpace/Private/abstractnodeparser.h | 10 ++++++++++ Heart/AbstractSpace/abstractnode.h | 1 + Heart/AbstractSpace/apiversionparser.h | 1 - Heart/AbstractSpace/iparser.h | 3 ++- HeartTests/AbstractSpace/abstractnodetest.cpp | 3 ++- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Heart/AbstractSpace/Private/abstractnodeparser.cpp b/Heart/AbstractSpace/Private/abstractnodeparser.cpp index 58bef1e5..380fc7a1 100644 --- a/Heart/AbstractSpace/Private/abstractnodeparser.cpp +++ b/Heart/AbstractSpace/Private/abstractnodeparser.cpp @@ -50,10 +50,11 @@ ParserResult AbstractNodeParser::parsePackage(const QSharedPointercmd()) { - auto cmd = static_cast(pkg.data()); + auto cmd = pkg.staticCast(); if (!cmd->ansver()) { cmd->setAnsver(true); - nodePtr->sendData(cmd, sender, &pkgHeader); + nodePtr->sendData(cmd.data(), sender, &pkgHeader); + emit sigPingReceived(cmd); } return ParserResult::Processed; diff --git a/Heart/AbstractSpace/Private/abstractnodeparser.h b/Heart/AbstractSpace/Private/abstractnodeparser.h index 6ff4c112..523830f6 100644 --- a/Heart/AbstractSpace/Private/abstractnodeparser.h +++ b/Heart/AbstractSpace/Private/abstractnodeparser.h @@ -10,6 +10,7 @@ #define ABSTRACTNODEPARSER_H #include +#include namespace QH { @@ -18,6 +19,7 @@ namespace QH { */ class AbstractNodeParser: public iParser { + Q_OBJECT public: AbstractNodeParser(AbstractNode *parentNode); ~AbstractNodeParser() override; @@ -27,6 +29,14 @@ class AbstractNodeParser: public iParser int version() const override; QString parserId() const override; +signals: + + /** + * @brief sigPingReceived This method emited + * @param ping this is received ping object. + */ + void sigPingReceived(QSharedPointer ping); + }; } #endif // ABSTRACTNODEPARSER_H diff --git a/Heart/AbstractSpace/abstractnode.h b/Heart/AbstractSpace/abstractnode.h index b2841dce..a87786dc 100644 --- a/Heart/AbstractSpace/abstractnode.h +++ b/Heart/AbstractSpace/abstractnode.h @@ -340,6 +340,7 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete const QList &ignoreSslErrors() const; #endif + getParser(); signals: /** * @brief requestError This signal emited when client or node received from remoute server or node the BadRequest package. diff --git a/Heart/AbstractSpace/apiversionparser.h b/Heart/AbstractSpace/apiversionparser.h index c7a08a70..5792188e 100644 --- a/Heart/AbstractSpace/apiversionparser.h +++ b/Heart/AbstractSpace/apiversionparser.h @@ -82,7 +82,6 @@ class APIVersionParser: public QObject, public iParser * @return parser for the @a cmd command */ QSharedPointer - selectParser(unsigned short cmd, AbstractNodeInfo *sender); /** * @brief maximumApiVersion This method return maximum supported api version of this node. diff --git a/Heart/AbstractSpace/iparser.h b/Heart/AbstractSpace/iparser.h index 084c67a6..9bd4d587 100644 --- a/Heart/AbstractSpace/iparser.h +++ b/Heart/AbstractSpace/iparser.h @@ -44,8 +44,9 @@ enum class ParserResult { * @see AbstractNode::parsePackage * @see AbstractNode */ -class HEARTSHARED_EXPORT iParser +class HEARTSHARED_EXPORT iParser: public QObject { + Q_OBJECT public: iParser(AbstractNode* parentNode); virtual ~iParser() = default; diff --git a/HeartTests/AbstractSpace/abstractnodetest.cpp b/HeartTests/AbstractSpace/abstractnodetest.cpp index 32f84e3e..d3574ec2 100644 --- a/HeartTests/AbstractSpace/abstractnodetest.cpp +++ b/HeartTests/AbstractSpace/abstractnodetest.cpp @@ -23,7 +23,8 @@ class TestingClient: public QH::AbstractNode { } protected: - void incomingData(const QH::PKG::AbstractData *pkg, const QH::AbstractNodeInfo *sender) override { + void incomingData(const QH::PKG::AbstractData *pkg, + const QH::AbstractNodeInfo *sender) override { Q_UNUSED(sender); auto ping = dynamic_cast(pkg); From 97103fa491433542f01d87a6456da59b45fddb01 Mon Sep 17 00:00:00 2001 From: EndrII Date: Mon, 28 Nov 2022 00:26:07 +0300 Subject: [PATCH 08/19] added initialize method for the nodes --- Heart/AbstractSpace/abstractnode.cpp | 26 ++++++++++++-- Heart/AbstractSpace/abstractnode.h | 42 +++++++++++++++++++++-- Heart/AbstractSpace/apiversionparser.cpp | 10 +++++- Heart/AbstractSpace/apiversionparser.h | 26 +++++++------- Heart/DataBaseSpace/packages/dbobject.cpp | 1 - 5 files changed, 85 insertions(+), 20 deletions(-) diff --git a/Heart/AbstractSpace/abstractnode.cpp b/Heart/AbstractSpace/abstractnode.cpp index 3856b1b2..e2a28a07 100644 --- a/Heart/AbstractSpace/abstractnode.cpp +++ b/Heart/AbstractSpace/abstractnode.cpp @@ -68,8 +68,6 @@ AbstractNode::AbstractNode( QObject *ptr): _tasksheduller = new TaskScheduler(); _apiVersionParser = new APIVersionParser(this); - _apiVersionParser->addApiParser(this); - _apiVersionParser->addApiParser(this); qRegisterMetaType>(); #ifdef USE_HEART_SSL @@ -84,6 +82,12 @@ AbstractNode::AbstractNode( QObject *ptr): } +void AbstractNode::initialize() { + if (!isInited()) { + init(); + } +} + AbstractNode::~AbstractNode() { _senderThread->quit(); @@ -104,6 +108,8 @@ AbstractNode::~AbstractNode() { bool AbstractNode::run(const QString &addres, unsigned short port) { + initialize(); + if (!port) return false; @@ -212,6 +218,7 @@ bool AbstractNode::addNode(const HostAddress &address) { return true; }; + initialize(); return _socketWorker->run(action); } @@ -513,6 +520,13 @@ const QList &AbstractNode::ignoreSslErrors() const { return _ignoreSslErrors; } +void AbstractNode::configureParser(const QSharedPointer &) {} + +void AbstractNode::init() { + addApiParser(this); + addApiParser(this); +} + void AbstractNode::setIgnoreSslErrors(const QList &newIgnoreSslErrors) { _ignoreSslErrors = newIgnoreSslErrors; }; @@ -560,6 +574,10 @@ void AbstractNode::handleEncrypted(AbstractNodeInfo *node) { handleNodeStatusChanged(node, NodeCoonectionStatus::Connected); } +void AbstractNode::addApiParser(const QSharedPointer &parserObject) { + configureParser(_apiVersionParser->addApiParser(parserObject)); +} + void AbstractNode::handleSslErrorOcurredPrivate(SslSocket * sslScocket, const QList &errors) { QList ignore; @@ -1142,6 +1160,10 @@ int AbstractNode::sheduledTaskCount() const { return _tasksheduller->taskCount(); } +bool AbstractNode::isInited() const { + return _apiVersionParser && _apiVersionParser->parsersTypedCount(); +} + void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender, const HostAddress& id) { diff --git a/Heart/AbstractSpace/abstractnode.h b/Heart/AbstractSpace/abstractnode.h index a87786dc..a1115847 100644 --- a/Heart/AbstractSpace/abstractnode.h +++ b/Heart/AbstractSpace/abstractnode.h @@ -132,6 +132,7 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete */ virtual bool run(const QString& addres, unsigned short port); + /** * @brief stop - Stopped this node and close all network connections. */ @@ -317,7 +318,6 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete * @param taskId This is task id that will be removed. * @see AbstractNode::sheduleTask * @see AbstractNode::sheduledTaskCount - */ void removeTask(int taskId); @@ -326,10 +326,15 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete * @return count of sheduled tasks. * @see AbstractNode::sheduleTask * @see AbstractNode::removeTask - */ int sheduledTaskCount() const; + /** + * @brief isInited This method return true if this node object initialized else false. + * @return true if this node object initialized else false. + */ + bool isInited() const; + #ifdef USE_HEART_SSL /** @@ -340,7 +345,6 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete const QList &ignoreSslErrors() const; #endif - getParser(); signals: /** * @brief requestError This signal emited when client or node received from remoute server or node the BadRequest package. @@ -568,6 +572,29 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete */ virtual void nodeAddedSucessful(AbstractNodeInfo* node); + /** + * @brief configureParser This method will invoke for the all added parsers of this node. + * @param parser This is current configured parser. + * @see AbstractNode::addApiParser + */ + virtual void configureParser(const QSharedPointer &parser); + + /** + * @brief addApiParser This is template metod that add sipport of new apiparser @a ApiType + * @tparam ApiType This is type of new apiParser that will be added to the main parser. + * @tparam Args This is argumets that will forward to the Parser constructor. + * @see AbstractNode::configureParser + */ + template + void addApiParser(Args&&... arg) { + return addApiParser(QSharedPointer::create(std::forward(arg)...)); + } + + /** + * @brief init This method will invoke in when the node sent first packge or run as aserver. + */ + virtual void init(); + protected slots: /** * @brief nodeErrorOccured This slot invoked when error ocured in the @a nodeInfo. @@ -593,6 +620,8 @@ protected slots: private slots: + void initialize(); + void avelableBytes(QH::AbstractNodeInfo* sender); /** @@ -638,6 +667,13 @@ private slots: private: + /** + * @brief addApiParser This method add new Api parser for this node. + * @param parserObject This is bew api parser. + * @return added parser. + */ + void addApiParser(const QSharedPointer& parserObject); + // iParser interface ParserResult parsePackage(const QSharedPointer &pkg, const Header &pkgHeader, diff --git a/Heart/AbstractSpace/apiversionparser.cpp b/Heart/AbstractSpace/apiversionparser.cpp index 3f9db045..53b21884 100644 --- a/Heart/AbstractSpace/apiversionparser.cpp +++ b/Heart/AbstractSpace/apiversionparser.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace QH { @@ -99,8 +100,11 @@ APIVersionParser::getSelectedApiParser(const QString &apiKey, return selectParser(node->version()).value(apiKey, nullptr); } -void APIVersionParser::addApiParser(const QSharedPointer &parserObject) { +const QSharedPointer& APIVersionParser::addApiParser(const QSharedPointer &parserObject) { + debug_assert(parserObject, "Parser object should not be nullptr"); + _apiParsers[parserObject->parserId()][parserObject->version()] = parserObject; + return _apiParsers[parserObject->parserId()][parserObject->version()]; } QHash> @@ -118,6 +122,10 @@ APIVersionParser::selectParser(const VersionData &distVersion) const { return result; } +unsigned int APIVersionParser::parsersTypedCount() const { + return _apiParsers.size(); +} + QSharedPointer APIVersionParser::selectParser(unsigned short cmd, AbstractNodeInfo *sender) { auto parser = sender->getParser(cmd); diff --git a/Heart/AbstractSpace/apiversionparser.h b/Heart/AbstractSpace/apiversionparser.h index 5792188e..a0416a0f 100644 --- a/Heart/AbstractSpace/apiversionparser.h +++ b/Heart/AbstractSpace/apiversionparser.h @@ -21,7 +21,7 @@ class VersionIsReceived; * @brief The APIVersionParser class This is main parser forthe main command. * This parsers work only with the APIVersion packge; */ -class APIVersionParser: public QObject, public iParser +class APIVersionParser: public iParser { Q_OBJECT public: @@ -50,22 +50,15 @@ class APIVersionParser: public QObject, public iParser * @return needed parser of the distanation node. */ QSharedPointer getSelectedApiParser(const QString& apiKey, - QH::AbstractNodeInfo *node) const; + QH::AbstractNodeInfo *node) const; /** * @brief addApiParser This method add new Api parser for this node. * @param parserObject This is bew api parser. + * @return added parser. */ - void addApiParser(const QSharedPointer& parserObject); - - /** - * @brief addApiParser This is template metod that add sipport of new apiparser @a ApiType - * @tparam ApiType This is type of new apiParser that will be added to the main parser. - */ - template - void addApiParser(Args&&... arg) { - addApiParser(QSharedPointer::create(std::forward(arg)...)); - } + const QSharedPointer& + addApiParser(const QSharedPointer& parserObject); /** * @brief selectParser This method select api parser betwin nodes. @@ -75,13 +68,20 @@ class APIVersionParser: public QObject, public iParser QHash> selectParser(const VersionData& distVersion) const; + /** + * @brief parsersTypedCount This method return count of the parsers types. + * @return count of the parsers types. + */ + unsigned int parsersTypedCount() const; + /** * @brief selectParser This method select parser by command and sender. * @param cmd this is command that need to parse. * @param sender this is node that sent this command. * @return parser for the @a cmd command */ - QSharedPointer + QSharedPointer selectParser(unsigned short cmd, + AbstractNodeInfo *sender); /** * @brief maximumApiVersion This method return maximum supported api version of this node. diff --git a/Heart/DataBaseSpace/packages/dbobject.cpp b/Heart/DataBaseSpace/packages/dbobject.cpp index 4b87d05c..17483c93 100644 --- a/Heart/DataBaseSpace/packages/dbobject.cpp +++ b/Heart/DataBaseSpace/packages/dbobject.cpp @@ -5,7 +5,6 @@ * of this license document, but changing it is not allowed. */ -#include "dbaddresskey.h" #include "dbobject.h" #include #include From 1356ee8975830c0a8ece9500561c5864d78bc890 Mon Sep 17 00:00:00 2001 From: EndrII Date: Mon, 28 Nov 2022 21:48:16 +0300 Subject: [PATCH 09/19] some fixes --- Heart/AbstractSpace/abstractnode.cpp | 11 +++++--- Heart/AbstractSpace/abstractnode.h | 19 +++++++++++--- HeartTests/AbstractSpace/abstractnodetest.cpp | 18 ++++++++----- HeartTests/AbstractSpace/bigdatatest.cpp | 26 ++++++++++++++----- HeartTests/AbstractSpace/bigdatatest.h | 3 +++ 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/Heart/AbstractSpace/abstractnode.cpp b/Heart/AbstractSpace/abstractnode.cpp index e2a28a07..0c94e5a6 100644 --- a/Heart/AbstractSpace/abstractnode.cpp +++ b/Heart/AbstractSpace/abstractnode.cpp @@ -523,8 +523,8 @@ const QList &AbstractNode::ignoreSslErrors() const { void AbstractNode::configureParser(const QSharedPointer &) {} void AbstractNode::init() { - addApiParser(this); - addApiParser(this); + addApiParser(); + addApiParser(); } void AbstractNode::setIgnoreSslErrors(const QList &newIgnoreSslErrors) { @@ -574,8 +574,11 @@ void AbstractNode::handleEncrypted(AbstractNodeInfo *node) { handleNodeStatusChanged(node, NodeCoonectionStatus::Connected); } -void AbstractNode::addApiParser(const QSharedPointer &parserObject) { - configureParser(_apiVersionParser->addApiParser(parserObject)); +const QSharedPointer & +AbstractNode::addApiParser(const QSharedPointer &parserObject) { + const auto &parser = _apiVersionParser->addApiParser(parserObject); + configureParser(parser); + return parser; } void AbstractNode::handleSslErrorOcurredPrivate(SslSocket * sslScocket, const QList &errors) { diff --git a/Heart/AbstractSpace/abstractnode.h b/Heart/AbstractSpace/abstractnode.h index a1115847..81396fef 100644 --- a/Heart/AbstractSpace/abstractnode.h +++ b/Heart/AbstractSpace/abstractnode.h @@ -579,15 +579,28 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete */ virtual void configureParser(const QSharedPointer &parser); + /** + * @brief addApiParserNative This is template metod that add sipport of new apiparser @a ApiType + * @tparam ApiType This is type of new apiParser that will be added to the main parser. + * @tparam Args This is argumets that will forward to the Parser constructor. + * @return shared pointer to the @a ApiType + * @see AbstractNode::configureParser + */ + template + const QSharedPointer & addApiParserNative(Args&&... arg) { + return addApiParser(QSharedPointer::create(this, std::forward(arg)...)).template static_canst(); + } + /** * @brief addApiParser This is template metod that add sipport of new apiparser @a ApiType * @tparam ApiType This is type of new apiParser that will be added to the main parser. * @tparam Args This is argumets that will forward to the Parser constructor. + * @return shared pointer to the iParser * @see AbstractNode::configureParser */ template - void addApiParser(Args&&... arg) { - return addApiParser(QSharedPointer::create(std::forward(arg)...)); + const QSharedPointer & addApiParser(Args&&... arg) { + return addApiParser(QSharedPointer::create(this, std::forward(arg)...)); } /** @@ -672,7 +685,7 @@ private slots: * @param parserObject This is bew api parser. * @return added parser. */ - void addApiParser(const QSharedPointer& parserObject); + const QSharedPointer & addApiParser(const QSharedPointer& parserObject); // iParser interface ParserResult parsePackage(const QSharedPointer &pkg, diff --git a/HeartTests/AbstractSpace/abstractnodetest.cpp b/HeartTests/AbstractSpace/abstractnodetest.cpp index d3574ec2..616ebb60 100644 --- a/HeartTests/AbstractSpace/abstractnodetest.cpp +++ b/HeartTests/AbstractSpace/abstractnodetest.cpp @@ -12,6 +12,8 @@ #include #include +#include + #define LOCAL_TEST_PORT TEST_PORT + 1 class TestingClient: public QH::AbstractNode { @@ -23,13 +25,17 @@ class TestingClient: public QH::AbstractNode { } protected: - void incomingData(const QH::PKG::AbstractData *pkg, - const QH::AbstractNodeInfo *sender) override { - Q_UNUSED(sender); + void configureParser(const QSharedPointer& parser) { + if (parser->parserId() == "HeartLibAbstractAPI") { + connect(static_cast(parser.data()), &QH::AbstractNodeParser::sigPingReceived, + this, &TestingClient::receivePing, Qt::DirectConnection); + } + + }; - auto ping = dynamic_cast(pkg); - if (ping) - _ping.setAnsver(ping->ansver()); +private slots: + void receivePing(QSharedPointer ping) { + _ping = *ping; } private: diff --git a/HeartTests/AbstractSpace/bigdatatest.cpp b/HeartTests/AbstractSpace/bigdatatest.cpp index 2ec9dd73..6057be09 100644 --- a/HeartTests/AbstractSpace/bigdatatest.cpp +++ b/HeartTests/AbstractSpace/bigdatatest.cpp @@ -57,7 +57,7 @@ class BigDataTestParser: public QH::iParser { } QH::ParserResult parsePackage(const QSharedPointer &pkg, - const QH::Header &pkgHeader, + const QH::Header &, QH::AbstractNodeInfo *sender) override { if (pkg->cmd() == BigPackage::command()) { @@ -81,16 +81,27 @@ class BigDataTestParser: public QH::iParser { class TestingClientBigData: public QH::AbstractNode { - // AbstractNode interface public: TestingClientBigData() { + _parser = addApiParser(); + } + + const QSharedPointer& parser() const { + return _parser; } + +private: + QSharedPointer _parser; }; BigDataTest::BigDataTest() { _nodeA = new TestingClientBigData(); + _nodeAParser = static_cast(_nodeA)->parser(); + _nodeB = new TestingClientBigData(); + _nodeBParser = static_cast(_nodeB)->parser(); + } BigDataTest::~BigDataTest() { @@ -124,14 +135,17 @@ bool BigDataTest::sendDataTest() { } auto request = [this, testData](){ - return static_cast(_nodeB)->sendRequest(testData); + return _nodeBParser.staticCast()->sendRequest(testData); }; - auto client = dynamic_cast(_nodeB); + auto client = _nodeBParser.staticCast(); + auto server = _nodeAParser.staticCast(); - auto check = [client, testData](){ - return client->getData() && client->getData()->data == testData; + auto check = [client, server, testData](){ + return client->getData() && server->getData()->data == testData; }; return funcPrivateConnect(request, check); } + + diff --git a/HeartTests/AbstractSpace/bigdatatest.h b/HeartTests/AbstractSpace/bigdatatest.h index 551407e7..bca3710a 100644 --- a/HeartTests/AbstractSpace/bigdatatest.h +++ b/HeartTests/AbstractSpace/bigdatatest.h @@ -28,6 +28,9 @@ class BigDataTest: public Test, protected TestUtils private: QH::AbstractNode *_nodeA = nullptr; QH::AbstractNode *_nodeB = nullptr; + QSharedPointer _nodeBParser = nullptr; + QSharedPointer _nodeAParser = nullptr; + bool connectTest(); bool sendDataTest(); From 388ddbd4556204e0d22d6b7e87930ed22e3772e8 Mon Sep 17 00:00:00 2001 From: EndrII Date: Mon, 28 Nov 2022 23:15:10 +0300 Subject: [PATCH 10/19] refactoring project structure --- .gitignore | 6 +- CMakeLists.txt | 2 +- Heart/AbstractSpace/Diagrams/Async.svg | 2321 ----------------- Heart/AbstractSpace/Diagrams/DatabseCache.svg | 871 ------- Heart/AbstractSpace/Diagrams/async.qmodel | 1533 ----------- .../Diagrams/databasecache.qmodel | 521 ---- Heart/AbstractSpace/Diagrams/header.h | 0 Heart/CMakeLists.txt | 124 - Heart/ProtockolResusces.qrc | 6 - HeartTests/CMakeLists.txt | 42 +- HeartTests/DataBaseSpace/basenodetest.cpp | 132 - HeartTests/DataBaseSpace/basenodetest.h | 61 - HeartTests/DataBaseSpace/basetestutils.cpp | 19 - HeartTests/DataBaseSpace/basetestutils.h | 26 - .../databasenodetesttemplate.cpp | 1 - .../DataBaseSpace/databasenodetesttemplate.h | 32 - .../DataBaseSpace/databasenodeunittests.cpp | 49 - .../DataBaseSpace/databasenodeunittests.h | 25 - HeartTests/DataBaseSpace/databasetestnode.cpp | 1 - HeartTests/DataBaseSpace/databasetestnode.h | 31 - .../templatedatabasenodeunittests.cpp | 21 - .../templatedatabasenodeunittests.h | 243 -- HeartTests/ProtocolTests.pro | 35 - HeartTests/tst_testprotockol.cpp | 18 - .../abstractnodetest.cpp | 19 +- .../abstractnodetest.h | 0 .../{AbstractSpace => units}/bigdatatest.cpp | 1 + .../{AbstractSpace => units}/bigdatatest.h | 0 .../ecdsaauthtest.cpp | 0 .../{AbstractSpace => units}/ecdsaauthtest.h | 0 HeartTests/{AbstractSpace => units}/itest.cpp | 0 HeartTests/{AbstractSpace => units}/itest.h | 0 .../{AbstractSpace => units}/keystoragetest.h | 0 .../shedullertest.cpp | 0 .../{AbstractSpace => units}/shedullertest.h | 0 HeartTests/{AbstractSpace => units}/test.cpp | 0 HeartTests/{AbstractSpace => units}/test.h | 0 .../{AbstractSpace => units}/testutils.cpp | 0 .../{AbstractSpace => units}/testutils.h | 0 .../upgradedatabasetest.cpp | 1 - .../upgradedatabasetest.h | 4 +- src/CMakeLists.txt | 80 + src/ProtockolResusces.qrc | 6 + {Heart => src}/heart.cpp | 0 {Heart => src}/heart.h | 0 {Heart => src}/heart_global.h.in | 0 .../private}/abstractnodeparser.cpp | 0 .../private}/abstractnodeparser.h | 2 +- .../Private => src/private}/apiversion.cpp | 0 .../Private => src/private}/apiversion.h | 0 .../Private => src/private}/bigdataparser.cpp | 0 .../Private => src/private}/bigdataparser.h | 0 .../Private => src/private}/datasender.cpp | 0 .../Private => src/private}/datasender.h | 0 .../Private => src/private}/packadata.cpp | 0 .../Private => src/private}/packadata.h | 0 .../Private => src/private}/receivedata.cpp | 0 .../Private => src/private}/receivedata.h | 0 .../Private => src/private}/sslsocket.cpp | 0 .../Private => src/private}/sslsocket.h | 0 .../Private => src/private}/taskscheduler.cpp | 0 .../Private => src/private}/taskscheduler.h | 0 .../Private => src/private}/tcpsocket.cpp | 0 .../Private => src/private}/tcpsocket.h | 0 .../private}/versionisreceived.cpp | 0 .../private}/versionisreceived.h | 0 .../public}/abstracterrorcodes.cpp | 0 .../public}/abstracterrorcodes.h | 0 .../public}/abstractkey.cpp | 0 .../public}/abstractkey.h | 0 .../public}/abstractnode.cpp | 30 +- .../public}/abstractnode.h | 29 +- .../public}/abstractnodeinfo.cpp | 0 .../public}/abstractnodeinfo.h | 0 .../public}/abstracttask.cpp | 0 .../public}/abstracttask.h | 0 .../public}/accesstoken.cpp | 0 .../public}/accesstoken.h | 0 .../public}/apiversionparser.cpp | 0 .../public}/apiversionparser.h | 0 {Heart/AbstractSpace => src/public}/async.cpp | 0 {Heart/AbstractSpace => src/public}/async.h | 0 .../public}/asynclauncher.cpp | 0 .../public}/asynclauncher.h | 0 .../public}/asyncsqldbwriter.cpp | 0 .../public}/asyncsqldbwriter.h | 0 .../public}/atomicmetatypes.h | 0 {Heart/AbstractSpace => src/public}/config.h | 2 +- .../DataBaseSpace => src/public}/database.cpp | 0 .../DataBaseSpace => src/public}/database.h | 0 .../public}/dbaddress.cpp | 0 .../DataBaseSpace => src/public}/dbaddress.h | 0 .../public}/dbaddresskey.cpp | 0 .../public}/dbaddresskey.h | 0 .../DataBaseSpace => src/public}/dbpatch.cpp | 0 {Heart/DataBaseSpace => src/public}/dbpatch.h | 0 .../public}/distversion.cpp | 0 .../public}/distversion.h | 0 .../public}/hcrypto/ecdsassl11.cpp | 4 +- .../public}/hcrypto/ecdsassl11.h | 0 .../public}/hcrypto/icrypto.cpp | 0 .../public}/hcrypto/icrypto.h | 0 .../public}/hcryptoFeatures/asynckeysauth.h | 0 .../public}/hcryptoFeatures/authecdsa.h | 0 .../public}/hcryptoFeatures/ecdsasigner.h | 0 .../hcryptoFeatures/isignerdelegate.cpp | 0 .../public}/hcryptoFeatures/isignerdelegate.h | 0 .../public}/hcryptoFeatures/signer.h | 0 .../AbstractSpace => src/public}/header.cpp | 0 {Heart/AbstractSpace => src/public}/header.h | 0 .../public}/hostaddress.cpp | 0 .../public}/hostaddress.h | 0 .../public}/iobjectprovider.cpp | 0 .../public}/iobjectprovider.h | 0 .../AbstractSpace => src/public}/iparser.cpp | 0 {Heart/AbstractSpace => src/public}/iparser.h | 0 .../DataBaseSpace => src/public}/isqldb.cpp | 0 {Heart/DataBaseSpace => src/public}/isqldb.h | 2 +- .../DataBaseSpace => src/public}/itoken.cpp | 0 {Heart/DataBaseSpace => src/public}/itoken.h | 0 .../AbstractSpace => src/public}/package.cpp | 0 {Heart/AbstractSpace => src/public}/package.h | 0 .../public}/packagemanager.cpp | 0 .../public}/packagemanager.h | 0 .../public}/packages/abstractdata.cpp | 0 .../public}/packages/abstractdata.h | 0 .../public}/packages/badrequest.cpp | 0 .../public}/packages/badrequest.h | 0 .../public}/packages/bigdatabase.cpp | 0 .../public}/packages/bigdatabase.h | 0 .../public}/packages/bigdataheader.cpp | 0 .../public}/packages/bigdataheader.h | 0 .../public}/packages/bigdatapart.cpp | 0 .../public}/packages/bigdatapart.h | 0 .../public}/packages/bigdatarequest.cpp | 0 .../public}/packages/bigdatarequest.h | 0 .../public}/packages/bigdatawraper.cpp | 0 .../public}/packages/bigdatawraper.h | 2 +- .../packages/cacheddbobjectsrequest.cpp | 0 .../public}/packages/cacheddbobjectsrequest.h | 0 .../public}/packages/closeconnection.cpp | 0 .../public}/packages/closeconnection.h | 0 .../public}/packages/customdbrequest.cpp | 0 .../public}/packages/customdbrequest.h | 0 .../public}/packages/datapack.cpp | 0 .../public}/packages/datapack.h | 0 .../public}/packages/dbobject.cpp | 0 .../public}/packages/dbobject.h | 0 .../public}/packages/dbobjectset.cpp | 0 .../public}/packages/dbobjectset.h | 0 .../public}/packages/dbobjectsrequest.cpp | 0 .../public}/packages/dbobjectsrequest.h | 0 .../packages/dbobjectsrequestwithStream.cpp | 0 .../packages/dbobjectsrequestwithStream.h | 0 .../public}/packages/deleteobject.cpp | 0 .../public}/packages/deleteobject.h | 0 .../public}/packages/getmaxintegerid.cpp | 0 .../public}/packages/getmaxintegerid.h | 0 .../public}/packages/getsinglevalue.cpp | 0 .../public}/packages/getsinglevalue.h | 0 .../public}/packages/ping.cpp | 0 .../public}/packages/ping.h | 0 .../public}/packages/setsinglevalue.cpp | 0 .../public}/packages/setsinglevalue.h | 0 .../AbstractSpace => src/public}/request.cpp | 0 {Heart/AbstractSpace => src/public}/request.h | 0 .../public}/softdelete.cpp | 0 .../AbstractSpace => src/public}/softdelete.h | 0 {Heart/DataBaseSpace => src/public}/sqldb.cpp | 0 {Heart/DataBaseSpace => src/public}/sqldb.h | 0 .../public}/sqldbwriter.cpp | 0 .../public}/sqldbwriter.h | 0 .../public}/sqlitedbcache.cpp | 0 .../public}/sqlitedbcache.h | 0 .../public}/streambase.cpp | 0 .../AbstractSpace => src/public}/streambase.h | 0 .../public}/workstate.cpp | 0 .../AbstractSpace => src/public}/workstate.h | 0 .../DataBaseSpace/Res => src/res}/BaseDB.sql | 0 .../Res => src/res}/DbConfig.json | 0 180 files changed, 126 insertions(+), 6176 deletions(-) delete mode 100644 Heart/AbstractSpace/Diagrams/Async.svg delete mode 100644 Heart/AbstractSpace/Diagrams/DatabseCache.svg delete mode 100644 Heart/AbstractSpace/Diagrams/async.qmodel delete mode 100644 Heart/AbstractSpace/Diagrams/databasecache.qmodel delete mode 100644 Heart/AbstractSpace/Diagrams/header.h delete mode 100644 Heart/CMakeLists.txt delete mode 100644 Heart/ProtockolResusces.qrc delete mode 100644 HeartTests/DataBaseSpace/basenodetest.cpp delete mode 100644 HeartTests/DataBaseSpace/basenodetest.h delete mode 100644 HeartTests/DataBaseSpace/basetestutils.cpp delete mode 100644 HeartTests/DataBaseSpace/basetestutils.h delete mode 100644 HeartTests/DataBaseSpace/databasenodetesttemplate.cpp delete mode 100644 HeartTests/DataBaseSpace/databasenodetesttemplate.h delete mode 100644 HeartTests/DataBaseSpace/databasenodeunittests.cpp delete mode 100644 HeartTests/DataBaseSpace/databasenodeunittests.h delete mode 100644 HeartTests/DataBaseSpace/databasetestnode.cpp delete mode 100644 HeartTests/DataBaseSpace/databasetestnode.h delete mode 100644 HeartTests/DataBaseSpace/templatedatabasenodeunittests.cpp delete mode 100644 HeartTests/DataBaseSpace/templatedatabasenodeunittests.h delete mode 100644 HeartTests/ProtocolTests.pro rename HeartTests/{AbstractSpace => units}/abstractnodetest.cpp (73%) rename HeartTests/{AbstractSpace => units}/abstractnodetest.h (100%) rename HeartTests/{AbstractSpace => units}/bigdatatest.cpp (99%) rename HeartTests/{AbstractSpace => units}/bigdatatest.h (100%) rename HeartTests/{AbstractSpace => units}/ecdsaauthtest.cpp (100%) rename HeartTests/{AbstractSpace => units}/ecdsaauthtest.h (100%) rename HeartTests/{AbstractSpace => units}/itest.cpp (100%) rename HeartTests/{AbstractSpace => units}/itest.h (100%) rename HeartTests/{AbstractSpace => units}/keystoragetest.h (100%) rename HeartTests/{AbstractSpace => units}/shedullertest.cpp (100%) rename HeartTests/{AbstractSpace => units}/shedullertest.h (100%) rename HeartTests/{AbstractSpace => units}/test.cpp (100%) rename HeartTests/{AbstractSpace => units}/test.h (100%) rename HeartTests/{AbstractSpace => units}/testutils.cpp (100%) rename HeartTests/{AbstractSpace => units}/testutils.h (100%) rename HeartTests/{DataBaseSpace => units}/upgradedatabasetest.cpp (98%) rename HeartTests/{DataBaseSpace => units}/upgradedatabasetest.h (68%) create mode 100644 src/CMakeLists.txt create mode 100644 src/ProtockolResusces.qrc rename {Heart => src}/heart.cpp (100%) rename {Heart => src}/heart.h (100%) rename {Heart => src}/heart_global.h.in (100%) rename {Heart/AbstractSpace/Private => src/private}/abstractnodeparser.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/abstractnodeparser.h (93%) rename {Heart/AbstractSpace/Private => src/private}/apiversion.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/apiversion.h (100%) rename {Heart/AbstractSpace/Private => src/private}/bigdataparser.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/bigdataparser.h (100%) rename {Heart/AbstractSpace/Private => src/private}/datasender.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/datasender.h (100%) rename {Heart/AbstractSpace/Private => src/private}/packadata.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/packadata.h (100%) rename {Heart/AbstractSpace/Private => src/private}/receivedata.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/receivedata.h (100%) rename {Heart/AbstractSpace/Private => src/private}/sslsocket.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/sslsocket.h (100%) rename {Heart/AbstractSpace/Private => src/private}/taskscheduler.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/taskscheduler.h (100%) rename {Heart/AbstractSpace/Private => src/private}/tcpsocket.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/tcpsocket.h (100%) rename {Heart/AbstractSpace/Private => src/private}/versionisreceived.cpp (100%) rename {Heart/AbstractSpace/Private => src/private}/versionisreceived.h (100%) rename {Heart/AbstractSpace => src/public}/abstracterrorcodes.cpp (100%) rename {Heart/AbstractSpace => src/public}/abstracterrorcodes.h (100%) rename {Heart/DataBaseSpace => src/public}/abstractkey.cpp (100%) rename {Heart/DataBaseSpace => src/public}/abstractkey.h (100%) rename {Heart/AbstractSpace => src/public}/abstractnode.cpp (98%) rename {Heart/AbstractSpace => src/public}/abstractnode.h (97%) rename {Heart/AbstractSpace => src/public}/abstractnodeinfo.cpp (100%) rename {Heart/AbstractSpace => src/public}/abstractnodeinfo.h (100%) rename {Heart/AbstractSpace => src/public}/abstracttask.cpp (100%) rename {Heart/AbstractSpace => src/public}/abstracttask.h (100%) rename {Heart/DataBaseSpace => src/public}/accesstoken.cpp (100%) rename {Heart/DataBaseSpace => src/public}/accesstoken.h (100%) rename {Heart/AbstractSpace => src/public}/apiversionparser.cpp (100%) rename {Heart/AbstractSpace => src/public}/apiversionparser.h (100%) rename {Heart/AbstractSpace => src/public}/async.cpp (100%) rename {Heart/AbstractSpace => src/public}/async.h (100%) rename {Heart/AbstractSpace => src/public}/asynclauncher.cpp (100%) rename {Heart/AbstractSpace => src/public}/asynclauncher.h (100%) rename {Heart/DataBaseSpace => src/public}/asyncsqldbwriter.cpp (100%) rename {Heart/DataBaseSpace => src/public}/asyncsqldbwriter.h (100%) rename {Heart/AbstractSpace => src/public}/atomicmetatypes.h (100%) rename {Heart/AbstractSpace => src/public}/config.h (93%) rename {Heart/DataBaseSpace => src/public}/database.cpp (100%) rename {Heart/DataBaseSpace => src/public}/database.h (100%) rename {Heart/DataBaseSpace => src/public}/dbaddress.cpp (100%) rename {Heart/DataBaseSpace => src/public}/dbaddress.h (100%) rename {Heart/DataBaseSpace => src/public}/dbaddresskey.cpp (100%) rename {Heart/DataBaseSpace => src/public}/dbaddresskey.h (100%) rename {Heart/DataBaseSpace => src/public}/dbpatch.cpp (100%) rename {Heart/DataBaseSpace => src/public}/dbpatch.h (100%) rename {Heart/AbstractSpace => src/public}/distversion.cpp (100%) rename {Heart/AbstractSpace => src/public}/distversion.h (100%) rename {Heart/AbstractSpace => src/public}/hcrypto/ecdsassl11.cpp (97%) rename {Heart/AbstractSpace => src/public}/hcrypto/ecdsassl11.h (100%) rename {Heart/AbstractSpace => src/public}/hcrypto/icrypto.cpp (100%) rename {Heart/AbstractSpace => src/public}/hcrypto/icrypto.h (100%) rename {Heart/AbstractSpace => src/public}/hcryptoFeatures/asynckeysauth.h (100%) rename {Heart/AbstractSpace => src/public}/hcryptoFeatures/authecdsa.h (100%) rename {Heart/AbstractSpace => src/public}/hcryptoFeatures/ecdsasigner.h (100%) rename {Heart/AbstractSpace => src/public}/hcryptoFeatures/isignerdelegate.cpp (100%) rename {Heart/AbstractSpace => src/public}/hcryptoFeatures/isignerdelegate.h (100%) rename {Heart/AbstractSpace => src/public}/hcryptoFeatures/signer.h (100%) rename {Heart/AbstractSpace => src/public}/header.cpp (100%) rename {Heart/AbstractSpace => src/public}/header.h (100%) rename {Heart/AbstractSpace => src/public}/hostaddress.cpp (100%) rename {Heart/AbstractSpace => src/public}/hostaddress.h (100%) rename {Heart/DataBaseSpace => src/public}/iobjectprovider.cpp (100%) rename {Heart/DataBaseSpace => src/public}/iobjectprovider.h (100%) rename {Heart/AbstractSpace => src/public}/iparser.cpp (100%) rename {Heart/AbstractSpace => src/public}/iparser.h (100%) rename {Heart/DataBaseSpace => src/public}/isqldb.cpp (100%) rename {Heart/DataBaseSpace => src/public}/isqldb.h (99%) rename {Heart/DataBaseSpace => src/public}/itoken.cpp (100%) rename {Heart/DataBaseSpace => src/public}/itoken.h (100%) rename {Heart/AbstractSpace => src/public}/package.cpp (100%) rename {Heart/AbstractSpace => src/public}/package.h (100%) rename {Heart/AbstractSpace => src/public}/packagemanager.cpp (100%) rename {Heart/AbstractSpace => src/public}/packagemanager.h (100%) rename {Heart/AbstractSpace => src/public}/packages/abstractdata.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/abstractdata.h (100%) rename {Heart/AbstractSpace => src/public}/packages/badrequest.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/badrequest.h (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdatabase.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdatabase.h (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdataheader.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdataheader.h (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdatapart.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdatapart.h (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdatarequest.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdatarequest.h (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdatawraper.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/bigdatawraper.h (97%) rename {Heart/DataBaseSpace => src/public}/packages/cacheddbobjectsrequest.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/cacheddbobjectsrequest.h (100%) rename {Heart/AbstractSpace => src/public}/packages/closeconnection.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/closeconnection.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/customdbrequest.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/customdbrequest.h (100%) rename {Heart/AbstractSpace => src/public}/packages/datapack.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/datapack.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/dbobject.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/dbobject.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/dbobjectset.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/dbobjectset.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/dbobjectsrequest.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/dbobjectsrequest.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/dbobjectsrequestwithStream.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/dbobjectsrequestwithStream.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/deleteobject.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/deleteobject.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/getmaxintegerid.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/getmaxintegerid.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/getsinglevalue.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/getsinglevalue.h (100%) rename {Heart/AbstractSpace => src/public}/packages/ping.cpp (100%) rename {Heart/AbstractSpace => src/public}/packages/ping.h (100%) rename {Heart/DataBaseSpace => src/public}/packages/setsinglevalue.cpp (100%) rename {Heart/DataBaseSpace => src/public}/packages/setsinglevalue.h (100%) rename {Heart/AbstractSpace => src/public}/request.cpp (100%) rename {Heart/AbstractSpace => src/public}/request.h (100%) rename {Heart/AbstractSpace => src/public}/softdelete.cpp (100%) rename {Heart/AbstractSpace => src/public}/softdelete.h (100%) rename {Heart/DataBaseSpace => src/public}/sqldb.cpp (100%) rename {Heart/DataBaseSpace => src/public}/sqldb.h (100%) rename {Heart/DataBaseSpace => src/public}/sqldbwriter.cpp (100%) rename {Heart/DataBaseSpace => src/public}/sqldbwriter.h (100%) rename {Heart/DataBaseSpace => src/public}/sqlitedbcache.cpp (100%) rename {Heart/DataBaseSpace => src/public}/sqlitedbcache.h (100%) rename {Heart/AbstractSpace => src/public}/streambase.cpp (100%) rename {Heart/AbstractSpace => src/public}/streambase.h (100%) rename {Heart/AbstractSpace => src/public}/workstate.cpp (100%) rename {Heart/AbstractSpace => src/public}/workstate.h (100%) rename {Heart/DataBaseSpace/Res => src/res}/BaseDB.sql (100%) rename {Heart/DataBaseSpace/Res => src/res}/DbConfig.json (100%) diff --git a/.gitignore b/.gitignore index 7c827b5a..4ec7f1f8 100644 --- a/.gitignore +++ b/.gitignore @@ -54,12 +54,12 @@ CMakeCache.txt CMakeFiles/ *_autogen -Heart/Heart_autogen/ -Heart/cmake_install.cmake +src/Heart_autogen/ +src/cmake_install.cmake HeartTests/cmake_install.cmake cmake_install.cmake docs/ -Heart/heart_global.h +src/heart_global.h # git *.orig diff --git a/CMakeLists.txt b/CMakeLists.txt index 77172b5a..08eccd46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network Sql Concurrent REQUIR add_subdirectory(QuasarAppLib) add_subdirectory(submodules/crc) -add_subdirectory(Heart) +add_subdirectory(src) if (HEART_TESTS) add_subdirectory(HeartTests) diff --git a/Heart/AbstractSpace/Diagrams/Async.svg b/Heart/AbstractSpace/Diagrams/Async.svg deleted file mode 100644 index d3e4221b..00000000 --- a/Heart/AbstractSpace/Diagrams/Async.svg +++ /dev/null @@ -1,2321 +0,0 @@ - - -Qt SVG Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -IncommingData - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -NP - - - - - - - - - - - - -AbstractNode - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The parse package method - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The receive requests queue - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The send data quese - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The creqate new thread method - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The node local database - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The database query queue - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The database query responce - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Reactor - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Resources - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The read access resource method - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The write access resource method - - - - - - - - - - - - - - - - - - - - - -(from AbstractSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -New Thread - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Main Thread - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Local Storagge - - - - - - - - - - - - - - - - - - - - - diff --git a/Heart/AbstractSpace/Diagrams/DatabseCache.svg b/Heart/AbstractSpace/Diagrams/DatabseCache.svg deleted file mode 100644 index 3b316895..00000000 --- a/Heart/AbstractSpace/Diagrams/DatabseCache.svg +++ /dev/null @@ -1,871 +0,0 @@ - - -Qt SVG Document -Generated with Qt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Database - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The Node (Server) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -QH - - - - - - - - - - - - -SqlDBWriter - - - - - - - - - - - - - - - - - - - - - -(from DataBaseSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -QH - - - - - - - - - - - - -SqlDBCache - - - - - - - - - - - - - - - - - - - - - -(from DataBaseSpace) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -This is external requester -of the objects. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -This class retun object of -request if object contains in the cache. -Else send request to SqlDBWriter. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -This class read objects -from the database. - - - - - - - - - - - - - - - - - - - - - diff --git a/Heart/AbstractSpace/Diagrams/async.qmodel b/Heart/AbstractSpace/Diagrams/async.qmodel deleted file mode 100644 index cab728d0..00000000 --- a/Heart/AbstractSpace/Diagrams/async.qmodel +++ /dev/null @@ -1,1533 +0,0 @@ - - - - {1974d1c6-c7fd-48c9-8716-2963ce55ae17} - - - - - - - - {1b070744-3368-47f3-a6d5-cba2dcf13046} - - - ASync - - - - - - - {86c65e6e-c6f3-4bdf-bf60-d469507385f7} - - - - - - - - {86c65e6e-c6f3-4bdf-bf60-d469507385f7} - 1 - - - AbstractSpace - - - - - - - {40b050a2-cbb3-434a-9820-a0408dd9cc65} - - - - - - - - {40b050a2-cbb3-434a-9820-a0408dd9cc65} - 1 - - - Abstractnode - - - - - - - - - - {8545c84f-1e54-4c66-89cc-144f97258d62} - - - - - - - - {8545c84f-1e54-4c66-89cc-144f97258d62} - - - Query Requests - - - - - - - - - - {a70d4258-8d62-43ef-b4e7-1692461ccf90} - - - - - - - - {a70d4258-8d62-43ef-b4e7-1692461ccf90} - - - Query Ansvers - - - - - - - - - - {afca4323-c099-43df-bcf7-7a27bbc1f446} - - - - - - - - {afca4323-c099-43df-bcf7-7a27bbc1f446} - - - ParsePackages - - - - - - - - - - {e7079bb7-d428-4713-a2f3-57f9a3375122} - - - - - - - - {e7079bb7-d428-4713-a2f3-57f9a3375122} - 1 - - - AbstractNode - - - NP - - - - - - - - {8f375085-5620-4004-9ae7-7e32c43feea5} - - - - - - - - {8f375085-5620-4004-9ae7-7e32c43feea5} - - - The parse package method - - - - - - - {cf56cda1-41e3-489b-86a2-86339b791932} - - - - - - - - {cf56cda1-41e3-489b-86a2-86339b791932} - - - {8f375085-5620-4004-9ae7-7e32c43feea5} - {1373dedb-4ef1-4be0-9460-0ba97d459b90} - - - - - - - - - - {6a3d28a1-2c8e-409a-b753-7dc67d47e018} - - - - - - - - {6a3d28a1-2c8e-409a-b753-7dc67d47e018} - - - {8f375085-5620-4004-9ae7-7e32c43feea5} - {bf0a2ec5-b735-486d-a6fe-c6eb9d5015a2} - - - - - - - - - - {0f996b7d-48da-4943-a892-7366c1f9b281} - - - - - - - - {0f996b7d-48da-4943-a892-7366c1f9b281} - - - {8f375085-5620-4004-9ae7-7e32c43feea5} - {84ebdf50-06cb-4925-96dc-0f99b01e3c1f} - - - - - - - - - - {4d4021b6-9181-4f94-9c09-4156208757e8} - - - - - - - - {4d4021b6-9181-4f94-9c09-4156208757e8} - - - {8f375085-5620-4004-9ae7-7e32c43feea5} - {40d2a713-bd35-4771-8c50-37751fe5189f} - - - - - - - - - - - - - - - - - - - - - {f24ea0a9-3593-416e-a111-88940ce34f49} - - - - - - - - {f24ea0a9-3593-416e-a111-88940ce34f49} - - - The receive requests queue - - - - - - - {fddcabd3-67ca-4a34-be6b-4260bcb3061d} - - - - - - - - {fddcabd3-67ca-4a34-be6b-4260bcb3061d} - - - {f24ea0a9-3593-416e-a111-88940ce34f49} - {5de24217-86bc-4d17-af6e-f04b85f06dd0} - - - - - - - - - - - - - - - - - - - - - {1373dedb-4ef1-4be0-9460-0ba97d459b90} - - - - - - - - {1373dedb-4ef1-4be0-9460-0ba97d459b90} - - - The send data quese - - - - - - - - - - {5de24217-86bc-4d17-af6e-f04b85f06dd0} - - - - - - - - {5de24217-86bc-4d17-af6e-f04b85f06dd0} - - - The creqate new thread method - - - - - - - {9e47f596-226e-40b4-8924-2d7a94598965} - - - - - - - - {9e47f596-226e-40b4-8924-2d7a94598965} - - - {5de24217-86bc-4d17-af6e-f04b85f06dd0} - {8f375085-5620-4004-9ae7-7e32c43feea5} - - - - - - - - - - - - - - - - - - - - - {65d31fce-4ab2-480f-ba4e-c7d9ef88ec5a} - - - - - - - - {65d31fce-4ab2-480f-ba4e-c7d9ef88ec5a} - - - database - - - - - The node local database - - - - - - - {d5513e8f-8603-4a7f-b2ff-701ef575832b} - - - - - - - - {d5513e8f-8603-4a7f-b2ff-701ef575832b} - - - {65d31fce-4ab2-480f-ba4e-c7d9ef88ec5a} - {1de1752c-e400-4b0e-ad11-09545278d17a} - - - - - - - - - - - - - - - - - - - - - {bf0a2ec5-b735-486d-a6fe-c6eb9d5015a2} - - - - - - - - {bf0a2ec5-b735-486d-a6fe-c6eb9d5015a2} - - - The database query queue - - - - - - - {bb488713-7f01-4415-a0bf-2cb4cbe178ec} - - - - - - - - {bb488713-7f01-4415-a0bf-2cb4cbe178ec} - - - {bf0a2ec5-b735-486d-a6fe-c6eb9d5015a2} - {65d31fce-4ab2-480f-ba4e-c7d9ef88ec5a} - - - - - - - - - - - - - - - - - - - - - {1de1752c-e400-4b0e-ad11-09545278d17a} - - - - - - - - {1de1752c-e400-4b0e-ad11-09545278d17a} - - - The database query responce - - - - - - - {980d3496-d03f-41e8-991a-99acf90eccce} - - - - - - - - {980d3496-d03f-41e8-991a-99acf90eccce} - - - {1de1752c-e400-4b0e-ad11-09545278d17a} - {8f375085-5620-4004-9ae7-7e32c43feea5} - - - - - - - - - - - - - - - - - - - - - {73f9a73d-09fb-4229-ac05-3660187042ad} - - - - - - - - {73f9a73d-09fb-4229-ac05-3660187042ad} - - - control - - - - - Reactor - - - - - - - - - - {6edf2143-f2a9-4105-aa4b-002be4c94598} - - - - - - - - {6edf2143-f2a9-4105-aa4b-002be4c94598} - - - Resources - - - - - - - {40cd4b53-4259-4a9c-b431-567256b55a89} - - - - - - - - {40cd4b53-4259-4a9c-b431-567256b55a89} - - - {6edf2143-f2a9-4105-aa4b-002be4c94598} - {ebf2dda3-0bb1-45e1-ae30-409baca6ee35} - - - - - - - - - - - - - - - - - - - - - {ebf2dda3-0bb1-45e1-ae30-409baca6ee35} - - - - - - - - {ebf2dda3-0bb1-45e1-ae30-409baca6ee35} - - - The read access resource method - - - - - - - {70b4c7b3-c196-4773-808a-4379f43951ce} - - - - - - - - {70b4c7b3-c196-4773-808a-4379f43951ce} - - - {ebf2dda3-0bb1-45e1-ae30-409baca6ee35} - {8f375085-5620-4004-9ae7-7e32c43feea5} - - - - - - - - - - - - - - - - - - - - - {40d2a713-bd35-4771-8c50-37751fe5189f} - - - - - - - - {40d2a713-bd35-4771-8c50-37751fe5189f} - - - The write access resource method - - - - - - - {cea9150d-5e52-45de-91d6-a4e449e02b7f} - - - - - - - - {cea9150d-5e52-45de-91d6-a4e449e02b7f} - - - {40d2a713-bd35-4771-8c50-37751fe5189f} - {6edf2143-f2a9-4105-aa4b-002be4c94598} - - - - - - - - - - {00b549d9-14df-49f9-88c5-f6f17429cf68} - - - - - - - - {00b549d9-14df-49f9-88c5-f6f17429cf68} - - - {40d2a713-bd35-4771-8c50-37751fe5189f} - {84ebdf50-06cb-4925-96dc-0f99b01e3c1f} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {0ab10749-acf2-4e9e-b842-70cad3fc4fe3} - - - - - - - - - - {0ab10749-acf2-4e9e-b842-70cad3fc4fe3} - - - Async - - - - - - - - - - {2395da40-7373-418f-8c2d-d91a7b380768} - - - 850 - - - - - - - - - {d11cc136-9832-4aec-abe0-03c63f7094a0} - - - New Thread - x:1214;y:20 - x:0;y:0;w:131;h:35 - false - 1 - - - - - - - - - {0e0c334c-818f-4c92-9e29-c031cf2ce1c7} - - - Main Thread - x:345;y:20 - x:0;y:0;w:130.203;h:35 - false - 1 - - - - - - - - - - - {bd8919c0-bcf8-42fa-8676-7f2861b755a3} - - - {e7079bb7-d428-4713-a2f3-57f9a3375122} - AbstractSpace - AbstractNode - x:390;y:560 - x:-330;y:-380;w:660;h:760 - false - 0 - - - NP - true - - - - - - - - - {9c9b85d3-f59f-4779-9d17-eecf5bbe10b2} - - - 847 - - - - - - - - - - - {23685ca4-7c6a-414e-9ef5-3326d1089b89} - - - {8f375085-5620-4004-9ae7-7e32c43feea5} - AbstractSpace - The parse package method - x:1250;y:410 - x:-160;y:-230;w:320;h:460 - false - 0 - - - false - - - - - - - - - - - {20b03ae8-9739-4586-9194-7b7e782d3fc2} - - - {f24ea0a9-3593-416e-a111-88940ce34f49} - AbstractSpace - The receive requests queue - x:390;y:320 - x:-210;y:-25;w:420;h:50 - false - 0 - - - false - - - - - - - - - - - {2daf0614-b530-4b06-b55c-728d9fbd31c9} - - - {1373dedb-4ef1-4be0-9460-0ba97d459b90} - AbstractSpace - The send data quese - x:390;y:480 - x:-210;y:-25;w:420;h:50 - false - 0 - - - false - - - - - - - - - - - {050ed47c-af5b-4682-a3fa-acf6fd9bef76} - - - {5de24217-86bc-4d17-af6e-f04b85f06dd0} - AbstractSpace - The creqate new thread method - x:390;y:400 - x:-210;y:-25;w:420;h:50 - false - 0 - - - false - - - - - - - - - - - {370f4db6-c64f-456c-8347-cb224eede005} - - - {fddcabd3-67ca-4a34-be6b-4260bcb3061d} - {20b03ae8-9739-4586-9194-7b7e782d3fc2} - {050ed47c-af5b-4682-a3fa-acf6fd9bef76} - - - - - - - - - - - - - {07029368-3504-405d-8f65-9427efc3d7e4} - - - {9e47f596-226e-40b4-8924-2d7a94598965} - {050ed47c-af5b-4682-a3fa-acf6fd9bef76} - {23685ca4-7c6a-414e-9ef5-3326d1089b89} - - - - - - - - - - - - - {6e9a48e7-7922-472c-a9a5-096b550f7b38} - - - {cf56cda1-41e3-489b-86a2-86339b791932} - {23685ca4-7c6a-414e-9ef5-3326d1089b89} - {2daf0614-b530-4b06-b55c-728d9fbd31c9} - - - - - - - - - - - - - {b3e457d3-9253-4426-8ed3-7f74da75c214} - - - {65d31fce-4ab2-480f-ba4e-c7d9ef88ec5a} - - - database - - - AbstractSpace - The node local database - x:-205;y:585 - x:-170;y:-130;w:340;h:260 - false - 0 - - - - - - - - - - - - - {9d146685-5100-4a63-b8bd-a046bac771d4} - - - {bf0a2ec5-b735-486d-a6fe-c6eb9d5015a2} - AbstractSpace - The database query queue - x:390;y:620 - x:-210;y:-25;w:420;h:50 - false - 0 - - - false - - - - - - - - - - - {93fdf02a-73f5-45eb-9670-ab53850ff8e1} - - - {1de1752c-e400-4b0e-ad11-09545278d17a} - AbstractSpace - The database query responce - x:390;y:560 - x:-210;y:-25;w:420;h:50 - false - 0 - - - false - - - - - - - - - - - {13f182c2-05e1-47d8-95e8-43935f14efad} - - - {bb488713-7f01-4415-a0bf-2cb4cbe178ec} - {9d146685-5100-4a63-b8bd-a046bac771d4} - {b3e457d3-9253-4426-8ed3-7f74da75c214} - - - - - - - - - - - - - {e434b177-2e13-451b-9e75-fa5bbfa2b5d4} - - - {d5513e8f-8603-4a7f-b2ff-701ef575832b} - {b3e457d3-9253-4426-8ed3-7f74da75c214} - {93fdf02a-73f5-45eb-9670-ab53850ff8e1} - - - - - - - - - - - - - {318f0dbe-2a94-4ba2-938a-a6124524149f} - - - {980d3496-d03f-41e8-991a-99acf90eccce} - {93fdf02a-73f5-45eb-9670-ab53850ff8e1} - {23685ca4-7c6a-414e-9ef5-3326d1089b89} - - - - - - - - - - - - - {7e188553-1343-499b-9a3a-ee744ba82255} - - - {6a3d28a1-2c8e-409a-b753-7dc67d47e018} - {23685ca4-7c6a-414e-9ef5-3326d1089b89} - {9d146685-5100-4a63-b8bd-a046bac771d4} - - - - - - - - - - - - - {2345e06d-8b72-4e2f-af25-292d24b9ace0} - - - {73f9a73d-09fb-4229-ac05-3660187042ad} - - - control - - - AbstractSpace - Reactor - x:700;y:215 - x:-75;y:-75;w:150;h:150 - false - 7 - - - - - - - - - - - - - {c839657e-fc23-401a-9a2e-3f382ba23c00} - - - {84ebdf50-06cb-4925-96dc-0f99b01e3c1f} - IncommingData - x:1250;y:815 - x:-160;y:-125;w:320;h:250 - false - 0 - - - false - - - - - - - - - - - {b4494e04-29bc-4a92-b70b-47bd9105a420} - - - {0f996b7d-48da-4943-a892-7366c1f9b281} - {23685ca4-7c6a-414e-9ef5-3326d1089b89} - {c839657e-fc23-401a-9a2e-3f382ba23c00} - - - - - - - - - - - - - {4528e67d-57d8-49d8-a199-f5952fee44dc} - - - {6edf2143-f2a9-4105-aa4b-002be4c94598} - AbstractSpace - Resources - x:275;y:775 - x:-95;y:-85;w:190;h:170 - false - 0 - - - - - - - - - - - - - {9ca6020c-5ca9-40ae-8241-b73042ba903e} - - - {ebf2dda3-0bb1-45e1-ae30-409baca6ee35} - AbstractSpace - The read access resource method - x:495;y:825 - x:-100;y:-35;w:200;h:70 - false - 0 - - - false - - - - - - - - - - - {92eb5579-50a4-4998-9562-6b5b3e87cd74} - - - {40d2a713-bd35-4771-8c50-37751fe5189f} - AbstractSpace - The write access resource method - x:495;y:725 - x:-100;y:-35;w:200;h:70 - false - 0 - - - false - - - - - - - - - - - {21d44974-21d3-4313-971e-ef4f6f7e6e87} - - - {70b4c7b3-c196-4773-808a-4379f43951ce} - {9ca6020c-5ca9-40ae-8241-b73042ba903e} - {23685ca4-7c6a-414e-9ef5-3326d1089b89} - - - - - - - - - - - - - {6e3a6e67-72d1-4b47-bf87-fbc84e21eeaa} - - - {4d4021b6-9181-4f94-9c09-4156208757e8} - {23685ca4-7c6a-414e-9ef5-3326d1089b89} - {92eb5579-50a4-4998-9562-6b5b3e87cd74} - - - - - - - - - - - - - {95b4600e-1953-4913-93aa-e2cc66b7fbb5} - - - {cea9150d-5e52-45de-91d6-a4e449e02b7f} - {92eb5579-50a4-4998-9562-6b5b3e87cd74} - {4528e67d-57d8-49d8-a199-f5952fee44dc} - - - - - - - - - - - - - {7271e4c8-ec7e-4b94-9b1c-0d5e0306e4d8} - - - {40cd4b53-4259-4a9c-b431-567256b55a89} - {4528e67d-57d8-49d8-a199-f5952fee44dc} - {9ca6020c-5ca9-40ae-8241-b73042ba903e} - - - - - - - - - - - - - {a5b780b8-5ec5-4c6a-8953-309a8c42ba76} - - - {e26d62d4-6936-49c9-80ff-eb212b121fed} - {c839657e-fc23-401a-9a2e-3f382ba23c00} - {9ca6020c-5ca9-40ae-8241-b73042ba903e} - - - - - - - - - - - - - {0f7155a8-8c30-4702-96c6-19b1c9551c35} - - - {00b549d9-14df-49f9-88c5-f6f17429cf68} - {92eb5579-50a4-4998-9562-6b5b3e87cd74} - {c839657e-fc23-401a-9a2e-3f382ba23c00} - - - - - - - - - - - {af7cc666-5e8e-4f97-9b57-3888b2009fa1} - - - 10 - - - - - - - - - {5bf725ef-8090-4a3e-b7fb-25dd65b64da1} - - - Local Storagge - x:-250;y:15 - x:0;y:0;w:123.438;h:35 - 1 - - - - - - 1596271151387 - General - - - - - - - - - - {94da9025-f1f6-4091-bebe-80acdd46e633} - - - - - - - - {94da9025-f1f6-4091-bebe-80acdd46e633} - - - Создать пакет - - - - - - - - - - {84ebdf50-06cb-4925-96dc-0f99b01e3c1f} - - - - - - - - {84ebdf50-06cb-4925-96dc-0f99b01e3c1f} - - - IncommingData - - - - - - - {1cc78f12-2952-490e-952c-d76d678671a3} - - - - - - - - {1cc78f12-2952-490e-952c-d76d678671a3} - - - {84ebdf50-06cb-4925-96dc-0f99b01e3c1f} - {8f375085-5620-4004-9ae7-7e32c43feea5} - - - - - - - - - - {e26d62d4-6936-49c9-80ff-eb212b121fed} - - - - - - - - {e26d62d4-6936-49c9-80ff-eb212b121fed} - - - {84ebdf50-06cb-4925-96dc-0f99b01e3c1f} - {ebf2dda3-0bb1-45e1-ae30-409baca6ee35} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Heart/AbstractSpace/Diagrams/databasecache.qmodel b/Heart/AbstractSpace/Diagrams/databasecache.qmodel deleted file mode 100644 index e2daf69b..00000000 --- a/Heart/AbstractSpace/Diagrams/databasecache.qmodel +++ /dev/null @@ -1,521 +0,0 @@ - - - - {74767b34-577e-40e7-979a-70bae6bf1b38} - - - - - - - - {6c8182f4-8824-4ed8-9fa7-07153e037552} - - - DatabaseCache. - - - - - - - {867d837e-052d-4bad-9548-37d1b369cd2c} - - - - - - - - - - {867d837e-052d-4bad-9548-37d1b369cd2c} - - - DatabaseCache. - - - - - - - - - - - - {5275139d-b9c2-499a-a2e3-67aacbb3671b} - - - {5d69d18e-cfe4-431b-b08d-5df5e10f58be} - DataBaseSpace - SqlDBWriter - x:235;y:240 - x:-105;y:-70;w:210;h:140 - false - 0 - - - QH - - - - - - - - - - - {8341593d-55f5-4569-809e-1c3a85f629c9} - - - {0e3a28ff-c52c-4147-ac16-52ddb5fa0656} - DataBaseSpace - SqlDBCache - x:500;y:240 - x:-105;y:-70;w:210;h:140 - false - 0 - - - QH - - - - - - - - - - - {c61245b9-dbc5-4fd0-ba4f-8eabdf5d902e} - - - {063973c9-6c27-4495-987a-6babc00970c0} - - - database - - - Database - x:-10;y:240 - x:-70;y:-55;w:140;h:110 - false - 0 - - - - - - - - - - - - - {6636ba88-0ce4-457e-a140-38308397c834} - - - {665414d0-1cb8-4e39-aec7-a5e7c974bd48} - The Node (Server) - x:765;y:240 - x:-105;y:-70;w:210;h:140 - false - 0 - - - false - - - - - - - - - - - {7f2eb5af-674c-44f5-8ce7-f541c101dea7} - - - {316af325-49e1-4ce1-afeb-2ced34d3c057} - {6636ba88-0ce4-457e-a140-38308397c834} - {8341593d-55f5-4569-809e-1c3a85f629c9} - - - 2 - - - - - - - - - - - {31108c9b-d93f-459a-b9f7-f67d0e5a58ce} - - - {8afa1668-c4b7-41b2-ae22-4f0d9eb8a3c3} - {8341593d-55f5-4569-809e-1c3a85f629c9} - {5275139d-b9c2-499a-a2e3-67aacbb3671b} - - - 2 - - - - - - - - - - - {a49281c7-adf2-4495-aa6d-694efce4805c} - - - {99cef98d-393f-4698-9b81-c9ff1224e5ee} - {5275139d-b9c2-499a-a2e3-67aacbb3671b} - {c61245b9-dbc5-4fd0-ba4f-8eabdf5d902e} - - - 2 - - - - - - - - - {ba3a6b29-f690-4cc7-864e-b120ad14ba4d} - - - This is external requester -of the objects. - x:680;y:250 - x:0;y:0;w:167.406;h:44 - false - - - - - - - - - {5c60784c-2947-45cf-b749-6101417876e1} - - - This class retun object of -request if object contains in the cache. -Else send request to SqlDBWriter. - x:395;y:250 - x:0;y:0;w:207.109;h:58 - - - - - - - - - {8a6b1c06-9153-4df3-af67-d94014aea61f} - - - This class read objects -from the database. - x:170;y:250 - x:0;y:0;w:128.766;h:44 - - - - - - 1601136597093 - General - - - - - - - - - - {2e31be9f-4672-4ecb-942c-7a74d2f10840} - - - - - - - - {2e31be9f-4672-4ecb-942c-7a74d2f10840} - 1 - - - DataBaseSpace - - - - - - - {e32f89a1-9cdb-4e89-859a-55b887d78776} - - - - - - - - {e32f89a1-9cdb-4e89-859a-55b887d78776} - 1 - - - AsyncSqlDb - - - QH - - - - - - - - {0e3a28ff-c52c-4147-ac16-52ddb5fa0656} - - - - - - - - {0e3a28ff-c52c-4147-ac16-52ddb5fa0656} - 1 - - - SqlDBCache - - - - - - - {8afa1668-c4b7-41b2-ae22-4f0d9eb8a3c3} - - - - - - - - {8afa1668-c4b7-41b2-ae22-4f0d9eb8a3c3} - - - {0e3a28ff-c52c-4147-ac16-52ddb5fa0656} - {5d69d18e-cfe4-431b-b08d-5df5e10f58be} - - - 2 - - - - - - - - - - - - QH - - - - - - - - {5d69d18e-cfe4-431b-b08d-5df5e10f58be} - - - - - - - - {5d69d18e-cfe4-431b-b08d-5df5e10f58be} - 1 - - - SqlDBWriter - - - - - - - {99cef98d-393f-4698-9b81-c9ff1224e5ee} - - - - - - - - {99cef98d-393f-4698-9b81-c9ff1224e5ee} - - - {5d69d18e-cfe4-431b-b08d-5df5e10f58be} - {063973c9-6c27-4495-987a-6babc00970c0} - - - 2 - - - - - - - - - - - - QH - - - - - - - - {129f3a85-eca4-4d75-bae0-d35e201e3047} - - - - - - - - {129f3a85-eca4-4d75-bae0-d35e201e3047} - 1 - - - DataBaseNode - - - QH - - - - - - - - - - - - - - - - - - - {063973c9-6c27-4495-987a-6babc00970c0} - - - - - - - - {063973c9-6c27-4495-987a-6babc00970c0} - - - database - - - - - Database - - - - - - - - - - {665414d0-1cb8-4e39-aec7-a5e7c974bd48} - - - - - - - - {665414d0-1cb8-4e39-aec7-a5e7c974bd48} - - - The Node (Server) - - - - - - - {316af325-49e1-4ce1-afeb-2ced34d3c057} - - - - - - - - {316af325-49e1-4ce1-afeb-2ced34d3c057} - - - {665414d0-1cb8-4e39-aec7-a5e7c974bd48} - {0e3a28ff-c52c-4147-ac16-52ddb5fa0656} - - - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Heart/AbstractSpace/Diagrams/header.h b/Heart/AbstractSpace/Diagrams/header.h deleted file mode 100644 index e69de29b..00000000 diff --git a/Heart/CMakeLists.txt b/Heart/CMakeLists.txt deleted file mode 100644 index 89d34e2b..00000000 --- a/Heart/CMakeLists.txt +++ /dev/null @@ -1,124 +0,0 @@ -# -# Copyright (C) 2018-2022 QuasarApp. -# Distributed under the lgplv3 software license, see the accompanying -# Everyone is permitted to copy and distribute verbatim copies -# of this license document, but changing it is not allowed. -# - -cmake_minimum_required(VERSION 3.10) - - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -updateGitVars() - -add_definitions(-DHEART_LIBRARY) - -set(SLL_DEFINE "WITHOUT_SSL") - -if (HEART_SSL) - - list(APPEND CMAKE_FIND_ROOT_PATH "$ENV{OPENSSL_ROOT_DIR}") - find_package(OpenSSL REQUIRED) - set(SLL_DEFINE "USE_HEART_SSL") -endif() - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/heart_global.h.in ${CMAKE_CURRENT_SOURCE_DIR}/heart_global.h @ONLY) - -if (${HEART_BUILD_LVL} GREATER_EQUAL 0) - message("BUILD LVL >= 0") - file(GLOB SOURCE_CPP_LVL_0 - "*.cpp" "*.h" "*.qrc" - "AbstractSpace/*.cpp" "AbstractSpace/*.h" "AbstractSpace/*.qrc" - "AbstractSpace/packages/*.cpp" "AbstractSpace/packages/*.h" "AbstractSpace/packages/*.qrc" - "AbstractSpace/Private/*.cpp" "AbstractSpace/Private/*.h" "AbstractSpace/Private/*.qrc" - "AbstractSpace/hcrypto/*.cpp" "AbstractSpace/hcrypto/*.h" "AbstractSpace/hcrypto/*.qrc" - "AbstractSpace/hcryptoFeatures/*.cpp" "AbstractSpace/hcryptoFeatures/*.h" "AbstractSpace/hcryptoFeatures/*.qrc" - - ) - - set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/AbstractSpace") - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/AbstractSpace/packages") - set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/AbstractSpace/Private") - -endif() - -if (${HEART_BUILD_LVL} GREATER_EQUAL 1) - message("BUILD LVL >= 1") - file(GLOB SOURCE_CPP_LVL_1 - "DataBaseSpace/*.cpp" "DataBaseSpace/*.h" "DataBaseSpace/*.qrc" - "DataBaseSpace/packages/*.cpp" "DataBaseSpace/packages/*.h" "DataBaseSpace/packages/*.qrc" - "DataBaseSpace/Private/*.cpp" "DataBaseSpace/Private/*.h" "DataBaseSpace/Private/*.qrc" - ) - - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/DataBaseSpace") - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/DataBaseSpace/packages") - - set(PRIVATE_INCUDE_DIR ${PRIVATE_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/DataBaseSpace/Private") - -endif() - -if (${HEART_BUILD_LVL} GREATER_EQUAL 2) - message("BUILD LVL >= 2") - file(GLOB SOURCE_CPP_LVL_2 - "NetworkSpace/*.cpp" "NetworkSpace/*.h" "NetworkSpace/*.qrc" - "NetworkSpace/packages/*.cpp" "NetworkSpace/packages/*.h" "NetworkSpace/packages/*.qrc" - "NetworkSpace/Private/*.cpp" "NetworkSpace/Private/*.h" "NetworkSpace/Private/*.qrc" - ) - - - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/NetworkSpace") - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/NetworkSpace/packages") - - set(PRIVATE_INCUDE_DIR ${PRIVATE_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/NetworkSpace/Private") - -endif() - -set(SOURCE_CPP ${SOURCE_CPP_LVL_0} ${SOURCE_CPP_LVL_1} ${SOURCE_CPP_LVL_2}) - - -add_library(${PROJECT_NAME} ${SOURCE_CPP}) -target_link_libraries(${PROJECT_NAME} PUBLIC Qt::Core Qt::Network Qt::Sql Qt::Concurrent QuasarApp crc) -if (HEART_SSL) - - if (HEART_STATIC_SSL) - - message("Use static ssl") - target_link_libraries(${PROJECT_NAME} PUBLIC libcrypto.a libssl.a) - - else() - - message("Use shared ssl ") - target_link_libraries(${PROJECT_NAME} PUBLIC OpenSSL::Crypto OpenSSL::SSL) - - - if (ANDROID) - set(OPENSSL_ROOT_PATH "$ENV{OPENSSL_ROOT_DIR}") - - set(ANDROID_EXTRA_LIBS - ${OPENSSL_ROOT_PATH}/lib/libcrypto_1_1.so - ${OPENSSL_ROOT_PATH}/lib/libssl_1_1.so - CACHE INTERNAL "") - - message(ANDROID_EXTRA_LIBS = ${ANDROID_EXTRA_LIBS}) - endif() - endif() - message("Use the OpenSSL libraries: ${OPENSSL_LIBRARIES}") - -endif() - -if (${HEART_BUILD_LVL} GREATER_EQUAL 2) - target_link_libraries(${PROJECT_NAME} PUBLIC Qt-Secret) -endif() - - -target_include_directories(${PROJECT_NAME} PUBLIC ${PUBLIC_INCUDE_DIR}) -target_include_directories(${PROJECT_NAME} PRIVATE ${PRIVATE_INCUDE_DIR}) - - -setVersion(1 1 ${GIT_COMMIT_COUNT}) diff --git a/Heart/ProtockolResusces.qrc b/Heart/ProtockolResusces.qrc deleted file mode 100644 index ac86a4ff..00000000 --- a/Heart/ProtockolResusces.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - DataBaseSpace/Res/DbConfig.json - DataBaseSpace/Res/BaseDB.sql - - diff --git a/HeartTests/CMakeLists.txt b/HeartTests/CMakeLists.txt index f582f0e3..6560f093 100644 --- a/HeartTests/CMakeLists.txt +++ b/HeartTests/CMakeLists.txt @@ -20,40 +20,16 @@ set(CMAKE_AUTORCC ON) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Test REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Test REQUIRED) -if (${HEART_BUILD_LVL} GREATER_EQUAL 0) - message("BUILD LVL >= 0") - file(GLOB SOURCE_CPP_LVL_0 - "*.cpp" "*.h" "*.qrc" - "AbstractSpace/*.cpp" "AbstractSpace/*.h" "AbstractSpace/*.qrc" - ) - set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/AbstractSpace") -endif() +message("BUILD LVL >= 0") +file(GLOB SOURCE_CPP + "*.cpp" "*.h" "*.qrc" + "units/*.cpp" "units/*.h" "units/*.qrc" +) +set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/units") -if (${HEART_BUILD_LVL} GREATER_EQUAL 1) - message("BUILD LVL >= 1") - file(GLOB SOURCE_CPP_LVL_1 - "DataBaseSpace/*.cpp" - "DataBaseSpace/private/*.cpp" - "DataBaseSpace/*.h" - "DataBaseSpace/private/*.h" - "DataBaseSpace/*.qrc" - ) - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/DataBaseSpace") - -endif() - -if (${HEART_BUILD_LVL} GREATER_EQUAL 2) - message("BUILD LVL >= 2") - file(GLOB SOURCE_CPP_LVL_2 - "NetworkSpace/*.cpp" "NetworkSpace/*.h" "NetworkSpace/*.qrc" - ) - set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/NetworkSpace") - -endif() - -set(SOURCE_CPP ${SOURCE_CPP_LVL_0} ${SOURCE_CPP_LVL_1} ${SOURCE_CPP_LVL_2}) +set(SOURCE_CPP ${SOURCE_CPP} ) message(SOURCE_CPP = ${SOURCE_CPP}) @@ -65,4 +41,4 @@ target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR}) initTests() -addTests("NetworkProtokol" ${CURRENT_PROJECT}) +addTests("${CURRENT_PROJECT}" ${CURRENT_PROJECT}) diff --git a/HeartTests/DataBaseSpace/basenodetest.cpp b/HeartTests/DataBaseSpace/basenodetest.cpp deleted file mode 100644 index ae741f05..00000000 --- a/HeartTests/DataBaseSpace/basenodetest.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "basenodetest.h" -#include "databasenodeunittests.h" -#include "testutils.h" - -#include -#include -#include - -#define LOCAL_TEST_PORT TEST_PORT + 2 - -class TestingBaseClient: public QH::DataBaseNode { - - Q_OBJECT - - // AbstractNode interface -public: - const QH::PKG::Ping& getPing() const { - return _ping; - } - -protected: - void incomingData(const QH::PKG::AbstractData *pkg, const QH::AbstractNodeInfo* sender) override { - Q_UNUSED(sender) - - auto ping = dynamic_cast(pkg); - if (ping) - _ping.setAnsver(ping->ansver()); - } - - -private: - QH::PKG::Ping _ping; - -}; - -class BadTstClient: public QH::DataBaseNode { - -}; - -BaseNodeTest::BaseNodeTest() { - _client1 = new TestingBaseClient(); - _client2 = new TestingBaseClient(); - - _server = new QH::DataBaseNode(); - -} - -BaseNodeTest::~BaseNodeTest() { - _client1->softDelete(); - _client2->softDelete(); - _server->softDelete(); -} - -void BaseNodeTest::test() { - dbTest(); - powerTest(); - connectNetworkTest(); - securityTest(); -} - -void BaseNodeTest::powerTest() { - auto _nodeAPtr = new QH::DataBaseNode(); - - QVERIFY(_nodeAPtr->run(TEST_LOCAL_HOST, LOCAL_TEST_PORT, "powerTest")); - - _nodeAPtr->softDelete(); -} - -void BaseNodeTest::dbTest() { - auto node = new DataBaseNodeUnitTests; - - node->test(); - - delete node; - -} - -void BaseNodeTest::connectNetworkTest() { - - auto client1 = dynamic_cast(_client1); - auto client2 = dynamic_cast(_client2); - auto server = dynamic_cast(_server); - - QVERIFY(server->run(TEST_LOCAL_HOST, LOCAL_TEST_PORT, "ServerDataBaseNode")); - - auto addNodeRequest = [client1, client2]() { - client1->addNode(QH::HostAddress(TEST_LOCAL_HOST, LOCAL_TEST_PORT)); - client2->addNode(QH::HostAddress(TEST_LOCAL_HOST, LOCAL_TEST_PORT)); - - return true; - }; - - auto checkNode = [server](){ - return server->connectionsCount() == 2; - }; - - QVERIFY(funcPrivateConnect(addNodeRequest, checkNode)); - - // need to wait for add node - - auto request = [client1, client2]() { - return client1->ping(QH::HostAddress(TEST_LOCAL_HOST, LOCAL_TEST_PORT)) && - client2->ping(QH::HostAddress(TEST_LOCAL_HOST, LOCAL_TEST_PORT)); - }; - - auto tstclient1 = dynamic_cast(client1); - auto tstclient2 = dynamic_cast(client1); - - auto check = [tstclient1, tstclient2]() { - return tstclient1->getPing().ansver() && - tstclient2->getPing().ansver(); - }; - - QVERIFY(funcPrivateConnect(request, check)); - -} - -void BaseNodeTest::securityTest() { - return; -} - - - -#include "basenodetest.moc" diff --git a/HeartTests/DataBaseSpace/basenodetest.h b/HeartTests/DataBaseSpace/basenodetest.h deleted file mode 100644 index 99669dc8..00000000 --- a/HeartTests/DataBaseSpace/basenodetest.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef BASENODETEST_H -#define BASENODETEST_H -#include "basetestutils.h" -#include "test.h" -#include "testutils.h" - -#include -#include - - -class BaseNodeTest: public Test, protected BaseTestUtils -{ -public: - BaseNodeTest(); - ~BaseNodeTest(); - - void test(); - -private: - QH::AbstractNode *_server = nullptr; - QH::AbstractNode *_client1 = nullptr; - QH::AbstractNode *_client2 = nullptr; - - - /** - * @brief powerTest - this test just create a new object of node and distruct it. - * check constructors and distructors of nodes objects. - * @return true if the test finished successful - */ - void powerTest(); - - /** - * @brief dbTest - test base functions of database of nodes. - * @return true if test finished successful. - */ - void dbTest(); - - /** - * @brief connectNetworkTest - * this test check nodes connections greatThen 3 node - * @return - */ - void connectNetworkTest(); - - /** - * @brief securityTest - this test create 2 clinet app and try get or change data of another client. - * @return - */ - void securityTest(); - -}; - -#endif // BASENODETEST_H diff --git a/HeartTests/DataBaseSpace/basetestutils.cpp b/HeartTests/DataBaseSpace/basetestutils.cpp deleted file mode 100644 index 67b5128d..00000000 --- a/HeartTests/DataBaseSpace/basetestutils.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "basetestutils.h" - -#include "test.h" - -BaseTestUtils::BaseTestUtils() { - -} - -BaseTestUtils::~BaseTestUtils() { -} - diff --git a/HeartTests/DataBaseSpace/basetestutils.h b/HeartTests/DataBaseSpace/basetestutils.h deleted file mode 100644 index 2792ff65..00000000 --- a/HeartTests/DataBaseSpace/basetestutils.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef BASETESTUTILS_H -#define BASETESTUTILS_H - -#include -namespace QH { -class DataBaseNode; -class NodeId; -} - -class BaseTestUtils: public TestUtils -{ -public: - BaseTestUtils(); - ~BaseTestUtils(); - -}; - -#endif // BASETESTUTILS_H diff --git a/HeartTests/DataBaseSpace/databasenodetesttemplate.cpp b/HeartTests/DataBaseSpace/databasenodetesttemplate.cpp deleted file mode 100644 index 743002a8..00000000 --- a/HeartTests/DataBaseSpace/databasenodetesttemplate.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "databasenodetesttemplate.h" diff --git a/HeartTests/DataBaseSpace/databasenodetesttemplate.h b/HeartTests/DataBaseSpace/databasenodetesttemplate.h deleted file mode 100644 index 3ab96a1a..00000000 --- a/HeartTests/DataBaseSpace/databasenodetesttemplate.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef DATABASENODETESTTEMPLATE_H -#define DATABASENODETESTTEMPLATE_H - -#include "databasetestnode.h" -#include "templatedatabasenodeunittests.h" - -#define DB_NODE_NAME "DatabaseTestNode" - -template - -/** - * @brief The DataBaseNodeUnitTestTemplate class This is template class for create tests. - */ -class DataBaseNodeUnitTestTemplate: public TemplateDataBaseNodeUnitTests, MEMBER> { -public: - DataBaseNodeUnitTestTemplate(): - TemplateDataBaseNodeUnitTests, MEMBER>(DB_NODE_NAME) {} -protected: - MEMBER *randomMember() const override { - srand(time(nullptr)); - - MEMBER * res = new MEMBER(); - res->setAuthenticationData(this->randomArray(64)); - res->setTrust(0); - res->setId(QString(this->randomArray(5).toHex())); - - return res; - - }; -}; - -#endif // DATABASENODETESTTEMPLATE_H diff --git a/HeartTests/DataBaseSpace/databasenodeunittests.cpp b/HeartTests/DataBaseSpace/databasenodeunittests.cpp deleted file mode 100644 index 008cb47e..00000000 --- a/HeartTests/DataBaseSpace/databasenodeunittests.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ -#include "databasenodeunittests.h" - -#include "databasenodetesttemplate.h" - -#include -#include -#include "sqldb.h" -#include -#include - -// This define create a simple class based on the BASE class and use the CHECHE and WRITER like a default cache and default writer objects. -#define TEST_CASE(NAME, BASE, MEMBER, CACHE, WRITER) \ - class NAME: public DataBaseNodeUnitTestTemplate< \ - BASE, MEMBER, CACHE, WRITER> { \ - }; - -#ifdef HEART_DB_CACHE -TEST_CASE(Case0, QH::DataBase, QH::PKG::NetworkMember, QH::SqlDBCache, QH::AsyncSqlDBWriter) -TEST_CASE(Case1, QH::DataBase, QH::PKG::NetworkMember, QH::SQLiteDBCache, QH::AsyncSqlDBWriter) -#endif -TEST_CASE(Case2, QH::DataBase, QH::PKG::NetworkMember, QH::SqlDB, QH::AsyncSqlDBWriter) - - -template -void testCase(const T& t) { - const_cast(t).test(); -} - -#define RUN_TEST_CASE(TYPE) \ - { \ - TYPE *tst = new TYPE(); \ - testCase(*tst); \ - } - -void DataBaseNodeUnitTests::test() { -#ifdef HEART_DB_CACHE - - RUN_TEST_CASE(Case0) - RUN_TEST_CASE(Case1) -#endif - RUN_TEST_CASE(Case2) - -} diff --git a/HeartTests/DataBaseSpace/databasenodeunittests.h b/HeartTests/DataBaseSpace/databasenodeunittests.h deleted file mode 100644 index b00eee2c..00000000 --- a/HeartTests/DataBaseSpace/databasenodeunittests.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef DBTESTS_H -#define DBTESTS_H - -#include -#include "itest.h" -#include - -class DataBaseNodeUnitTests: public iTest { - - - // Test interface -public: - void test() override; - -}; - -#endif // DBTESTS_H diff --git a/HeartTests/DataBaseSpace/databasetestnode.cpp b/HeartTests/DataBaseSpace/databasetestnode.cpp deleted file mode 100644 index 8ef694e5..00000000 --- a/HeartTests/DataBaseSpace/databasetestnode.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "databasetestnode.h" diff --git a/HeartTests/DataBaseSpace/databasetestnode.h b/HeartTests/DataBaseSpace/databasetestnode.h deleted file mode 100644 index 5b1c1787..00000000 --- a/HeartTests/DataBaseSpace/databasetestnode.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef DATABASETESTNODE_H -#define DATABASETESTNODE_H - -#include - -namespace QH { -class ISqlDB; -class SqlDBWriter; -} - -template -class DataBaseTestNode: public BASE { - -protected: - void initDefaultDbObjects(QH::ISqlDB *cache, - QH::SqlDBWriter *writer) override { - if (!writer) { - writer = new WRITER(); - } - - if (!cache) { - cache = new CACHE(); - } - - BASE::initDefaultDbObjects(cache, writer); - - return; - } -}; - -#endif // DATABASETESTNODE_H diff --git a/HeartTests/DataBaseSpace/templatedatabasenodeunittests.cpp b/HeartTests/DataBaseSpace/templatedatabasenodeunittests.cpp deleted file mode 100644 index dabe4dd8..00000000 --- a/HeartTests/DataBaseSpace/templatedatabasenodeunittests.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#include "templatedatabasenodeunittests.h" - - - - - - - - - - - - diff --git a/HeartTests/DataBaseSpace/templatedatabasenodeunittests.h b/HeartTests/DataBaseSpace/templatedatabasenodeunittests.h deleted file mode 100644 index 1402172c..00000000 --- a/HeartTests/DataBaseSpace/templatedatabasenodeunittests.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (C) 2018-2022 QuasarApp. - * Distributed under the lgplv3 software license, see the accompanying - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. -*/ - - -#ifndef TEMPLATEDBTESTS_H -#define TEMPLATEDBTESTS_H - -#include -#include -#include -#include -#include -#include -#include -#include "sqldbcache.h" -#include - - -template -/** - * @brief The TemplateDataBaseNodeUnitTests class This is base class for testing databases. - * You need to override this class for using. The BASE Templte is a any child class of the DataBaseNode class. - */ -class TemplateDataBaseNodeUnitTests: public BASE, public iTest -{ -public: - TemplateDataBaseNodeUnitTests(const QString DbNodeName):BASE(){ - - _dbNodeName = DbNodeName; - - } - /** - * @brief test - test work database - * @return true if database of node work is correctly. - */ - void test() override{ - - testObjec = QSharedPointer(randomMember()); - - initUnitTests(); - testReadWrite(); - testUpdate(); - testChangeTrust(); - - BASE::stop(); - } - -protected: - /** - * @brief randomMember This method generate randm network member. - * @return pointer to random network member - */ - virtual WorkType* randomMember() const = 0; - - /** - * @brief initUnitTests - init database. - * @return return true if test module initialized successful - */ - virtual void initUnitTests() { - QVERIFY(BASE::run(_dbNodeName)); - - QString database = BASE::dbLocation(); - BASE::stop(); - - QVERIFY(QFileInfo::exists(database)); - QVERIFY(QFile::remove(database)); - } - - /** - * @brief testReadWrite - test save and get object functions - * @return true if all test finished successful - */ - void testReadWrite() { - // test init database - QVERIFY(BASE::run(_dbNodeName)); - - - // try get not exists object - auto objectFromDataBase = BASE::db()->getObject(*testObjec); - - // objectFromDataBase must be equal 0x0 - QVERIFY(!objectFromDataBase); - - // generate random objects for database. - for (int i = 0; i < 100; ++i) { - auto obj = QSharedPointer(randomMember()); - - QVERIFY(obj->isValid()); - - QVERIFY(BASE::db()->insertObject(obj, true)); - } - - // create request for get all objects from database. - QH::PKG::DBObjectsRequest setRequest( - testObjec->table(), ""); - - auto list = BASE::db()->getObject(setRequest); - QVERIFY(list); - QVERIFY(list->data().size() == 100); - - // create request for get all objects from database and cached it. - QH::PKG::CachedDbObjectsRequest request(""); - - QList> result; - QVERIFY(BASE::db()->getAllObjects(request, result)); - - QVERIFY(list->data().size() == result.size()); - - // insert main object inot database. - QVERIFY(BASE::db()->insertObject(testObjec)); - - // get main object from cache database. - auto object = BASE::db()->getObject(*testObjec); - - QVERIFY(object); - QVERIFY(object->isValid()); - - testObjec->copyFrom(object.data()); - - // save state of cache of data base. - BASE::stop(); - - // run new session of server dataqbase. - QVERIFY(BASE::run(_dbNodeName)); - - // try get object from not cache. - objectFromDataBase = BASE::db()->getObject(*testObjec); - - QVERIFY(objectFromDataBase); - QVERIFY(objectFromDataBase->trust() == 0); - - } - - /** - * @brief testUpdate - test update functions - * @return true if all test finished successful. - */ - void testUpdate() { - BASE::stop(); - - QVERIFY(BASE::run(_dbNodeName)); - - - auto objectFromDataBase = BASE::db()->getObject(*testObjec); - - QVERIFY(objectFromDataBase); - QVERIFY(objectFromDataBase->trust() == 0); - - auto clone = objectFromDataBase->clone().template staticCast(); - - clone->setTrust(20); - - QVERIFY(BASE::db()->updateObject(clone)); - - objectFromDataBase = BASE::db()->getObject(*objectFromDataBase); - - QVERIFY(objectFromDataBase); - QVERIFY(objectFromDataBase->trust() == 20); - - BASE::stop(); - - QVERIFY(BASE::run(_dbNodeName)); - - objectFromDataBase = BASE::db()->getObject(*objectFromDataBase); - - QVERIFY(objectFromDataBase); - QVERIFY(objectFromDataBase->trust() == 20); - - } - - /** - * @brief testChangeTrust - this test check bad request responce for node - * @return true if all test finished successful - */ - void testChangeTrust() { - BASE::stop(); - - QVERIFY(BASE::run( _dbNodeName)); - - QVERIFY(!BASE::changeTrust("", -10)); - - QVERIFY(BASE::changeTrust(testObjec->getId(), -10)); - - auto objectFromDataBase = BASE::db()->getObject(*testObjec); - - QVERIFY(objectFromDataBase); - QVERIFY(objectFromDataBase->trust() == 10); - - BASE::stop(); - - QVERIFY(BASE::run(_dbNodeName)); - - objectFromDataBase = BASE::db()->getObject(*testObjec); - - QVERIFY(objectFromDataBase); - QVERIFY(objectFromDataBase->trust() == 10); - - QVERIFY(BASE::changeTrust(testObjec->getId(), -10)); - - objectFromDataBase = BASE::db()->getObject(*testObjec); - - QVERIFY(objectFromDataBase); - QVERIFY(objectFromDataBase->trust() == 0); - - BASE::stop(); - - QVERIFY(BASE::run(_dbNodeName)); - - objectFromDataBase = BASE::db()->getObject(*testObjec); - - QVERIFY(objectFromDataBase); - QVERIFY(objectFromDataBase->trust() == 0); - - QVERIFY(BASE::isBanned(testObjec->getId())); - - } - - QByteArray randomArray(int length) const { - QByteArray data; - - static unsigned char nance = 0; - - for (int i = 0 ; i < length; ++i) { - data.push_back(((rand() + nance) % static_cast(0xFF))); - } - - nance++; - - return data; - } - -private: - QSharedPointer testObjec = nullptr; - QString _dbNodeName = "DatabaseTestNode"; - int _testPort = TEST_PORT + 2; - -}; - -#endif // TEMPLATEDBTESTS_H diff --git a/HeartTests/ProtocolTests.pro b/HeartTests/ProtocolTests.pro deleted file mode 100644 index 60dc77a9..00000000 --- a/HeartTests/ProtocolTests.pro +++ /dev/null @@ -1,35 +0,0 @@ -QT += testlib network sql -QT -= gui - -CONFIG += qt console warn_on depend_includepath testcase -CONFIG -= app_bundle - -TEMPLATE = app - -TARGET = networkTests - -SOURCES += \ - testutils.cpp \ - tst_testsnakeserver.cpp - -CONFIG(release, debug|release): { - DESTDIR = $$PWD/build/release - -} else { - DESTDIR = $$PWD/build/debug -} - -include($$PWD/../NetworkProtocol/NetworkProtocol.pri) - - -HEADERS += \ - testutils.h - -deployTest.commands = cqtdeployer -bin $$DESTDIR clear -qmake $$QMAKE_QMAKE -targetDir $$PWD/deployTests -libDir $$PWD/../../ -recursiveDepth 5 - -test.depends = deployTest -test.commands = $$PWD/deployTests/networkTests.sh - -QMAKE_EXTRA_TARGETS += \ - deployTest \ - test diff --git a/HeartTests/tst_testprotockol.cpp b/HeartTests/tst_testprotockol.cpp index dd58b72d..9f5ca975 100644 --- a/HeartTests/tst_testprotockol.cpp +++ b/HeartTests/tst_testprotockol.cpp @@ -8,20 +8,11 @@ #include -#if HEART_BUILD_LVL >= 0 #include "abstractnodetest.h" #include #include #include -#endif -#if HEART_BUILD_LVL >= 1 -#include -#include #include -#endif -#if HEART_BUILD_LVL >= 2 -#include -#endif #define TestCase(name, testClass) \ void name() { \ @@ -38,7 +29,6 @@ class testProtockol : public QObject private slots: // BEGIN TESTS CASES -#if HEART_BUILD_LVL >= 0 TestCase(abstractNodeTest, AbstractNodeTest) TestCase(bigDataTest, BigDataTest); @@ -48,15 +38,7 @@ private slots: TestCase(ecdsaAuthTest, ECDSAAuthTest); #endif -#endif -#if HEART_BUILD_LVL >= 1 - TestCase(baseNodeTest, BaseNodeTest) - TestCase(singleNodeTest, SingleServerTest) TestCase(upgradeDataBaseTest, UpgradeDataBaseTest) -#endif -#if HEART_BUILD_LVL >= 2 - TestCase(networkNodeTest, NetworkNodeTest) -#endif // END TEST CASES diff --git a/HeartTests/AbstractSpace/abstractnodetest.cpp b/HeartTests/units/abstractnodetest.cpp similarity index 73% rename from HeartTests/AbstractSpace/abstractnodetest.cpp rename to HeartTests/units/abstractnodetest.cpp index 616ebb60..fb83087a 100644 --- a/HeartTests/AbstractSpace/abstractnodetest.cpp +++ b/HeartTests/units/abstractnodetest.cpp @@ -12,8 +12,6 @@ #include #include -#include - #define LOCAL_TEST_PORT TEST_PORT + 1 class TestingClient: public QH::AbstractNode { @@ -24,26 +22,17 @@ class TestingClient: public QH::AbstractNode { return _ping; } -protected: - void configureParser(const QSharedPointer& parser) { - if (parser->parserId() == "HeartLibAbstractAPI") { - connect(static_cast(parser.data()), &QH::AbstractNodeParser::sigPingReceived, - this, &TestingClient::receivePing, Qt::DirectConnection); - } - - }; - -private slots: - void receivePing(QSharedPointer ping) { +protected slots: + void receivePing(const QSharedPointer& ping) override { _ping = *ping; - } + }; private: QH::PKG::Ping _ping; }; AbstractNodeTest::AbstractNodeTest() { - _nodeA = new QH::AbstractNode(); + _nodeA = new TestingClient(); _nodeB = new TestingClient(); } diff --git a/HeartTests/AbstractSpace/abstractnodetest.h b/HeartTests/units/abstractnodetest.h similarity index 100% rename from HeartTests/AbstractSpace/abstractnodetest.h rename to HeartTests/units/abstractnodetest.h diff --git a/HeartTests/AbstractSpace/bigdatatest.cpp b/HeartTests/units/bigdatatest.cpp similarity index 99% rename from HeartTests/AbstractSpace/bigdatatest.cpp rename to HeartTests/units/bigdatatest.cpp index 6057be09..263cbe8a 100644 --- a/HeartTests/AbstractSpace/bigdatatest.cpp +++ b/HeartTests/units/bigdatatest.cpp @@ -36,6 +36,7 @@ class BigPackage: public QH::PKG::AbstractData { class BigDataTestParser: public QH::iParser { +public: BigDataTestParser(QH::AbstractNode* parentNode): QH::iParser(parentNode) { registerPackageType(); data = new BigPackage(); diff --git a/HeartTests/AbstractSpace/bigdatatest.h b/HeartTests/units/bigdatatest.h similarity index 100% rename from HeartTests/AbstractSpace/bigdatatest.h rename to HeartTests/units/bigdatatest.h diff --git a/HeartTests/AbstractSpace/ecdsaauthtest.cpp b/HeartTests/units/ecdsaauthtest.cpp similarity index 100% rename from HeartTests/AbstractSpace/ecdsaauthtest.cpp rename to HeartTests/units/ecdsaauthtest.cpp diff --git a/HeartTests/AbstractSpace/ecdsaauthtest.h b/HeartTests/units/ecdsaauthtest.h similarity index 100% rename from HeartTests/AbstractSpace/ecdsaauthtest.h rename to HeartTests/units/ecdsaauthtest.h diff --git a/HeartTests/AbstractSpace/itest.cpp b/HeartTests/units/itest.cpp similarity index 100% rename from HeartTests/AbstractSpace/itest.cpp rename to HeartTests/units/itest.cpp diff --git a/HeartTests/AbstractSpace/itest.h b/HeartTests/units/itest.h similarity index 100% rename from HeartTests/AbstractSpace/itest.h rename to HeartTests/units/itest.h diff --git a/HeartTests/AbstractSpace/keystoragetest.h b/HeartTests/units/keystoragetest.h similarity index 100% rename from HeartTests/AbstractSpace/keystoragetest.h rename to HeartTests/units/keystoragetest.h diff --git a/HeartTests/AbstractSpace/shedullertest.cpp b/HeartTests/units/shedullertest.cpp similarity index 100% rename from HeartTests/AbstractSpace/shedullertest.cpp rename to HeartTests/units/shedullertest.cpp diff --git a/HeartTests/AbstractSpace/shedullertest.h b/HeartTests/units/shedullertest.h similarity index 100% rename from HeartTests/AbstractSpace/shedullertest.h rename to HeartTests/units/shedullertest.h diff --git a/HeartTests/AbstractSpace/test.cpp b/HeartTests/units/test.cpp similarity index 100% rename from HeartTests/AbstractSpace/test.cpp rename to HeartTests/units/test.cpp diff --git a/HeartTests/AbstractSpace/test.h b/HeartTests/units/test.h similarity index 100% rename from HeartTests/AbstractSpace/test.h rename to HeartTests/units/test.h diff --git a/HeartTests/AbstractSpace/testutils.cpp b/HeartTests/units/testutils.cpp similarity index 100% rename from HeartTests/AbstractSpace/testutils.cpp rename to HeartTests/units/testutils.cpp diff --git a/HeartTests/AbstractSpace/testutils.h b/HeartTests/units/testutils.h similarity index 100% rename from HeartTests/AbstractSpace/testutils.h rename to HeartTests/units/testutils.h diff --git a/HeartTests/DataBaseSpace/upgradedatabasetest.cpp b/HeartTests/units/upgradedatabasetest.cpp similarity index 98% rename from HeartTests/DataBaseSpace/upgradedatabasetest.cpp rename to HeartTests/units/upgradedatabasetest.cpp index 6ec50f63..3b3f8634 100644 --- a/HeartTests/DataBaseSpace/upgradedatabasetest.cpp +++ b/HeartTests/units/upgradedatabasetest.cpp @@ -1,5 +1,4 @@ #include "upgradedatabasetest.h" -#include "databasenode.h" #include #include diff --git a/HeartTests/DataBaseSpace/upgradedatabasetest.h b/HeartTests/units/upgradedatabasetest.h similarity index 68% rename from HeartTests/DataBaseSpace/upgradedatabasetest.h rename to HeartTests/units/upgradedatabasetest.h index 97078660..b9170176 100644 --- a/HeartTests/DataBaseSpace/upgradedatabasetest.h +++ b/HeartTests/units/upgradedatabasetest.h @@ -1,9 +1,9 @@ #ifndef UPGRADEDATABASETEST_H #define UPGRADEDATABASETEST_H #include "test.h" -#include "basetestutils.h" +#include "testutils.h" -class UpgradeDataBaseTest: public Test, protected BaseTestUtils +class UpgradeDataBaseTest: public Test, protected TestUtils { public: UpgradeDataBaseTest(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..1fe325c4 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,80 @@ +# +# Copyright (C) 2018-2022 QuasarApp. +# Distributed under the lgplv3 software license, see the accompanying +# Everyone is permitted to copy and distribute verbatim copies +# of this license document, but changing it is not allowed. +# + +cmake_minimum_required(VERSION 3.10) + + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +updateGitVars() + +add_definitions(-DHEART_LIBRARY) + +set(SLL_DEFINE "WITHOUT_SSL") + +if (HEART_SSL) + + list(APPEND CMAKE_FIND_ROOT_PATH "$ENV{OPENSSL_ROOT_DIR}") + find_package(OpenSSL REQUIRED) + set(SLL_DEFINE "USE_HEART_SSL") +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/heart_global.h.in ${CMAKE_CURRENT_SOURCE_DIR}/heart_global.h @ONLY) + +file(GLOB SOURCE_CPP + "*.cpp" "*.h" "*.qrc" + "public/*.cpp" "public/*.h" "public/*.qrc" + "public/packages/*.cpp" "public/packages/*.h" "public/packages/*.qrc" + "private/*.cpp" "private/*.h" "private/*.qrc" + "public/hcrypto/*.cpp" "public/hcrypto/*.h" "public/hcrypto/*.qrc" + "public/hcryptoFeatures/*.cpp" "public/hcryptoFeatures/*.h" "public/hcryptoFeatures/*.qrc" + +) + +set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/public") +set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/public/packages") +set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/private") + + +add_library(${PROJECT_NAME} ${SOURCE_CPP}) +target_link_libraries(${PROJECT_NAME} PUBLIC Qt::Core Qt::Network Qt::Sql Qt::Concurrent QuasarApp crc) +if (HEART_SSL) + + if (HEART_STATIC_SSL) + + message("Use static ssl") + target_link_libraries(${PROJECT_NAME} PUBLIC libcrypto.a libssl.a) + + else() + + message("Use shared ssl ") + target_link_libraries(${PROJECT_NAME} PUBLIC OpenSSL::Crypto OpenSSL::SSL) + + + if (ANDROID) + set(OPENSSL_ROOT_PATH "$ENV{OPENSSL_ROOT_DIR}") + + set(ANDROID_EXTRA_LIBS + ${OPENSSL_ROOT_PATH}/lib/libcrypto_1_1.so + ${OPENSSL_ROOT_PATH}/lib/libssl_1_1.so + CACHE INTERNAL "") + + message(ANDROID_EXTRA_LIBS = ${ANDROID_EXTRA_LIBS}) + endif() + endif() + message("Use the OpenSSL libraries: ${OPENSSL_LIBRARIES}") + +endif() + + +target_include_directories(${PROJECT_NAME} PUBLIC ${PUBLIC_INCUDE_DIR}) +target_include_directories(${PROJECT_NAME} PRIVATE ${PRIVATE_INCUDE_DIR}) diff --git a/src/ProtockolResusces.qrc b/src/ProtockolResusces.qrc new file mode 100644 index 00000000..5cfb9e04 --- /dev/null +++ b/src/ProtockolResusces.qrc @@ -0,0 +1,6 @@ + + + res/BaseDB.sql + res/DbConfig.json + + diff --git a/Heart/heart.cpp b/src/heart.cpp similarity index 100% rename from Heart/heart.cpp rename to src/heart.cpp diff --git a/Heart/heart.h b/src/heart.h similarity index 100% rename from Heart/heart.h rename to src/heart.h diff --git a/Heart/heart_global.h.in b/src/heart_global.h.in similarity index 100% rename from Heart/heart_global.h.in rename to src/heart_global.h.in diff --git a/Heart/AbstractSpace/Private/abstractnodeparser.cpp b/src/private/abstractnodeparser.cpp similarity index 100% rename from Heart/AbstractSpace/Private/abstractnodeparser.cpp rename to src/private/abstractnodeparser.cpp diff --git a/Heart/AbstractSpace/Private/abstractnodeparser.h b/src/private/abstractnodeparser.h similarity index 93% rename from Heart/AbstractSpace/Private/abstractnodeparser.h rename to src/private/abstractnodeparser.h index 523830f6..08cebf2e 100644 --- a/Heart/AbstractSpace/Private/abstractnodeparser.h +++ b/src/private/abstractnodeparser.h @@ -35,7 +35,7 @@ class AbstractNodeParser: public iParser * @brief sigPingReceived This method emited * @param ping this is received ping object. */ - void sigPingReceived(QSharedPointer ping); + void sigPingReceived(const QSharedPointer &ping); }; } diff --git a/Heart/AbstractSpace/Private/apiversion.cpp b/src/private/apiversion.cpp similarity index 100% rename from Heart/AbstractSpace/Private/apiversion.cpp rename to src/private/apiversion.cpp diff --git a/Heart/AbstractSpace/Private/apiversion.h b/src/private/apiversion.h similarity index 100% rename from Heart/AbstractSpace/Private/apiversion.h rename to src/private/apiversion.h diff --git a/Heart/AbstractSpace/Private/bigdataparser.cpp b/src/private/bigdataparser.cpp similarity index 100% rename from Heart/AbstractSpace/Private/bigdataparser.cpp rename to src/private/bigdataparser.cpp diff --git a/Heart/AbstractSpace/Private/bigdataparser.h b/src/private/bigdataparser.h similarity index 100% rename from Heart/AbstractSpace/Private/bigdataparser.h rename to src/private/bigdataparser.h diff --git a/Heart/AbstractSpace/Private/datasender.cpp b/src/private/datasender.cpp similarity index 100% rename from Heart/AbstractSpace/Private/datasender.cpp rename to src/private/datasender.cpp diff --git a/Heart/AbstractSpace/Private/datasender.h b/src/private/datasender.h similarity index 100% rename from Heart/AbstractSpace/Private/datasender.h rename to src/private/datasender.h diff --git a/Heart/AbstractSpace/Private/packadata.cpp b/src/private/packadata.cpp similarity index 100% rename from Heart/AbstractSpace/Private/packadata.cpp rename to src/private/packadata.cpp diff --git a/Heart/AbstractSpace/Private/packadata.h b/src/private/packadata.h similarity index 100% rename from Heart/AbstractSpace/Private/packadata.h rename to src/private/packadata.h diff --git a/Heart/AbstractSpace/Private/receivedata.cpp b/src/private/receivedata.cpp similarity index 100% rename from Heart/AbstractSpace/Private/receivedata.cpp rename to src/private/receivedata.cpp diff --git a/Heart/AbstractSpace/Private/receivedata.h b/src/private/receivedata.h similarity index 100% rename from Heart/AbstractSpace/Private/receivedata.h rename to src/private/receivedata.h diff --git a/Heart/AbstractSpace/Private/sslsocket.cpp b/src/private/sslsocket.cpp similarity index 100% rename from Heart/AbstractSpace/Private/sslsocket.cpp rename to src/private/sslsocket.cpp diff --git a/Heart/AbstractSpace/Private/sslsocket.h b/src/private/sslsocket.h similarity index 100% rename from Heart/AbstractSpace/Private/sslsocket.h rename to src/private/sslsocket.h diff --git a/Heart/AbstractSpace/Private/taskscheduler.cpp b/src/private/taskscheduler.cpp similarity index 100% rename from Heart/AbstractSpace/Private/taskscheduler.cpp rename to src/private/taskscheduler.cpp diff --git a/Heart/AbstractSpace/Private/taskscheduler.h b/src/private/taskscheduler.h similarity index 100% rename from Heart/AbstractSpace/Private/taskscheduler.h rename to src/private/taskscheduler.h diff --git a/Heart/AbstractSpace/Private/tcpsocket.cpp b/src/private/tcpsocket.cpp similarity index 100% rename from Heart/AbstractSpace/Private/tcpsocket.cpp rename to src/private/tcpsocket.cpp diff --git a/Heart/AbstractSpace/Private/tcpsocket.h b/src/private/tcpsocket.h similarity index 100% rename from Heart/AbstractSpace/Private/tcpsocket.h rename to src/private/tcpsocket.h diff --git a/Heart/AbstractSpace/Private/versionisreceived.cpp b/src/private/versionisreceived.cpp similarity index 100% rename from Heart/AbstractSpace/Private/versionisreceived.cpp rename to src/private/versionisreceived.cpp diff --git a/Heart/AbstractSpace/Private/versionisreceived.h b/src/private/versionisreceived.h similarity index 100% rename from Heart/AbstractSpace/Private/versionisreceived.h rename to src/private/versionisreceived.h diff --git a/Heart/AbstractSpace/abstracterrorcodes.cpp b/src/public/abstracterrorcodes.cpp similarity index 100% rename from Heart/AbstractSpace/abstracterrorcodes.cpp rename to src/public/abstracterrorcodes.cpp diff --git a/Heart/AbstractSpace/abstracterrorcodes.h b/src/public/abstracterrorcodes.h similarity index 100% rename from Heart/AbstractSpace/abstracterrorcodes.h rename to src/public/abstracterrorcodes.h diff --git a/Heart/DataBaseSpace/abstractkey.cpp b/src/public/abstractkey.cpp similarity index 100% rename from Heart/DataBaseSpace/abstractkey.cpp rename to src/public/abstractkey.cpp diff --git a/Heart/DataBaseSpace/abstractkey.h b/src/public/abstractkey.h similarity index 100% rename from Heart/DataBaseSpace/abstractkey.h rename to src/public/abstractkey.h diff --git a/Heart/AbstractSpace/abstractnode.cpp b/src/public/abstractnode.cpp similarity index 98% rename from Heart/AbstractSpace/abstractnode.cpp rename to src/public/abstractnode.cpp index 0c94e5a6..cd8755dd 100644 --- a/Heart/AbstractSpace/abstractnode.cpp +++ b/src/public/abstractnode.cpp @@ -67,7 +67,11 @@ AbstractNode::AbstractNode( QObject *ptr): _socketWorker = new AsyncLauncher(_senderThread); _tasksheduller = new TaskScheduler(); _apiVersionParser = new APIVersionParser(this); + addApiParser(); + auto abstractNodeParser = addApiParserNative(); + connect(abstractNodeParser.data(), &AbstractNodeParser::sigPingReceived, + this, &AbstractNode::receivePing, Qt::DirectConnection); qRegisterMetaType>(); #ifdef USE_HEART_SSL @@ -82,12 +86,6 @@ AbstractNode::AbstractNode( QObject *ptr): } -void AbstractNode::initialize() { - if (!isInited()) { - init(); - } -} - AbstractNode::~AbstractNode() { _senderThread->quit(); @@ -108,8 +106,6 @@ AbstractNode::~AbstractNode() { bool AbstractNode::run(const QString &addres, unsigned short port) { - initialize(); - if (!port) return false; @@ -218,7 +214,6 @@ bool AbstractNode::addNode(const HostAddress &address) { return true; }; - initialize(); return _socketWorker->run(action); } @@ -520,13 +515,6 @@ const QList &AbstractNode::ignoreSslErrors() const { return _ignoreSslErrors; } -void AbstractNode::configureParser(const QSharedPointer &) {} - -void AbstractNode::init() { - addApiParser(); - addApiParser(); -} - void AbstractNode::setIgnoreSslErrors(const QList &newIgnoreSslErrors) { _ignoreSslErrors = newIgnoreSslErrors; }; @@ -576,9 +564,7 @@ void AbstractNode::handleEncrypted(AbstractNodeInfo *node) { const QSharedPointer & AbstractNode::addApiParser(const QSharedPointer &parserObject) { - const auto &parser = _apiVersionParser->addApiParser(parserObject); - configureParser(parser); - return parser; + return _apiVersionParser->addApiParser(parserObject); } void AbstractNode::handleSslErrorOcurredPrivate(SslSocket * sslScocket, const QList &errors) { @@ -1151,6 +1137,8 @@ void AbstractNode::nodeAddedSucessful(AbstractNodeInfo *) { } +void AbstractNode::receivePing(const QSharedPointer &) {}; + bool AbstractNode::sheduleTask(const QSharedPointer &task) { return _tasksheduller->shedule(task); } @@ -1163,10 +1151,6 @@ int AbstractNode::sheduledTaskCount() const { return _tasksheduller->taskCount(); } -bool AbstractNode::isInited() const { - return _apiVersionParser && _apiVersionParser->parsersTypedCount(); -} - void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender, const HostAddress& id) { diff --git a/Heart/AbstractSpace/abstractnode.h b/src/public/abstractnode.h similarity index 97% rename from Heart/AbstractSpace/abstractnode.h rename to src/public/abstractnode.h index 81396fef..22f7e2ac 100644 --- a/Heart/AbstractSpace/abstractnode.h +++ b/src/public/abstractnode.h @@ -10,6 +10,7 @@ #define ABSTRACTNODE_H #include "abstractnodeinfo.h" +#include "ping.h" #ifdef USE_HEART_SSL #include @@ -329,12 +330,6 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete */ int sheduledTaskCount() const; - /** - * @brief isInited This method return true if this node object initialized else false. - * @return true if this node object initialized else false. - */ - bool isInited() const; - #ifdef USE_HEART_SSL /** @@ -572,23 +567,15 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete */ virtual void nodeAddedSucessful(AbstractNodeInfo* node); - /** - * @brief configureParser This method will invoke for the all added parsers of this node. - * @param parser This is current configured parser. - * @see AbstractNode::addApiParser - */ - virtual void configureParser(const QSharedPointer &parser); - /** * @brief addApiParserNative This is template metod that add sipport of new apiparser @a ApiType * @tparam ApiType This is type of new apiParser that will be added to the main parser. * @tparam Args This is argumets that will forward to the Parser constructor. * @return shared pointer to the @a ApiType - * @see AbstractNode::configureParser */ template - const QSharedPointer & addApiParserNative(Args&&... arg) { - return addApiParser(QSharedPointer::create(this, std::forward(arg)...)).template static_canst(); + QSharedPointer addApiParserNative(Args&&... arg) { + return addApiParser(QSharedPointer::create(this, std::forward(arg)...)).template staticCast(); } /** @@ -596,19 +583,19 @@ class HEARTSHARED_EXPORT AbstractNode : public QTcpServer, public SoftDelete * @tparam ApiType This is type of new apiParser that will be added to the main parser. * @tparam Args This is argumets that will forward to the Parser constructor. * @return shared pointer to the iParser - * @see AbstractNode::configureParser */ template const QSharedPointer & addApiParser(Args&&... arg) { return addApiParser(QSharedPointer::create(this, std::forward(arg)...)); } +protected slots: /** - * @brief init This method will invoke in when the node sent first packge or run as aserver. + * @brief receivePing This method invoked when node receive new ping object. + * @param ping This is ping object. */ - virtual void init(); + virtual void receivePing(const QSharedPointer& ping);; -protected slots: /** * @brief nodeErrorOccured This slot invoked when error ocured in the @a nodeInfo. * @param nodeInfo This is pinter to modeInfoObject. @@ -633,8 +620,6 @@ protected slots: private slots: - void initialize(); - void avelableBytes(QH::AbstractNodeInfo* sender); /** diff --git a/Heart/AbstractSpace/abstractnodeinfo.cpp b/src/public/abstractnodeinfo.cpp similarity index 100% rename from Heart/AbstractSpace/abstractnodeinfo.cpp rename to src/public/abstractnodeinfo.cpp diff --git a/Heart/AbstractSpace/abstractnodeinfo.h b/src/public/abstractnodeinfo.h similarity index 100% rename from Heart/AbstractSpace/abstractnodeinfo.h rename to src/public/abstractnodeinfo.h diff --git a/Heart/AbstractSpace/abstracttask.cpp b/src/public/abstracttask.cpp similarity index 100% rename from Heart/AbstractSpace/abstracttask.cpp rename to src/public/abstracttask.cpp diff --git a/Heart/AbstractSpace/abstracttask.h b/src/public/abstracttask.h similarity index 100% rename from Heart/AbstractSpace/abstracttask.h rename to src/public/abstracttask.h diff --git a/Heart/DataBaseSpace/accesstoken.cpp b/src/public/accesstoken.cpp similarity index 100% rename from Heart/DataBaseSpace/accesstoken.cpp rename to src/public/accesstoken.cpp diff --git a/Heart/DataBaseSpace/accesstoken.h b/src/public/accesstoken.h similarity index 100% rename from Heart/DataBaseSpace/accesstoken.h rename to src/public/accesstoken.h diff --git a/Heart/AbstractSpace/apiversionparser.cpp b/src/public/apiversionparser.cpp similarity index 100% rename from Heart/AbstractSpace/apiversionparser.cpp rename to src/public/apiversionparser.cpp diff --git a/Heart/AbstractSpace/apiversionparser.h b/src/public/apiversionparser.h similarity index 100% rename from Heart/AbstractSpace/apiversionparser.h rename to src/public/apiversionparser.h diff --git a/Heart/AbstractSpace/async.cpp b/src/public/async.cpp similarity index 100% rename from Heart/AbstractSpace/async.cpp rename to src/public/async.cpp diff --git a/Heart/AbstractSpace/async.h b/src/public/async.h similarity index 100% rename from Heart/AbstractSpace/async.h rename to src/public/async.h diff --git a/Heart/AbstractSpace/asynclauncher.cpp b/src/public/asynclauncher.cpp similarity index 100% rename from Heart/AbstractSpace/asynclauncher.cpp rename to src/public/asynclauncher.cpp diff --git a/Heart/AbstractSpace/asynclauncher.h b/src/public/asynclauncher.h similarity index 100% rename from Heart/AbstractSpace/asynclauncher.h rename to src/public/asynclauncher.h diff --git a/Heart/DataBaseSpace/asyncsqldbwriter.cpp b/src/public/asyncsqldbwriter.cpp similarity index 100% rename from Heart/DataBaseSpace/asyncsqldbwriter.cpp rename to src/public/asyncsqldbwriter.cpp diff --git a/Heart/DataBaseSpace/asyncsqldbwriter.h b/src/public/asyncsqldbwriter.h similarity index 100% rename from Heart/DataBaseSpace/asyncsqldbwriter.h rename to src/public/asyncsqldbwriter.h diff --git a/Heart/AbstractSpace/atomicmetatypes.h b/src/public/atomicmetatypes.h similarity index 100% rename from Heart/AbstractSpace/atomicmetatypes.h rename to src/public/atomicmetatypes.h diff --git a/Heart/AbstractSpace/config.h b/src/public/config.h similarity index 93% rename from Heart/AbstractSpace/config.h rename to src/public/config.h index 80d73311..bd60a9cc 100644 --- a/Heart/AbstractSpace/config.h +++ b/src/public/config.h @@ -25,7 +25,7 @@ // Data Base settings #define DEFAULT_DB_NAME "Storage.sqlite" // default database name of server #define DEFAULT_DB_PATH QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) // default location of database. in linux systems it is ~/.local/shared// -#define DEFAULT_DB_INIT_FILE_PATH ":/sql/DataBaseSpace/Res/BaseDB.sql" // default database file path +#define DEFAULT_DB_INIT_FILE_PATH ":/sql/res/BaseDB.sql" // default database file path #define DEFAULT_UPDATE_INTERVAL 3600000 // This is interval of update database cache by default it is 1 hour // Transport Protockol settings diff --git a/Heart/DataBaseSpace/database.cpp b/src/public/database.cpp similarity index 100% rename from Heart/DataBaseSpace/database.cpp rename to src/public/database.cpp diff --git a/Heart/DataBaseSpace/database.h b/src/public/database.h similarity index 100% rename from Heart/DataBaseSpace/database.h rename to src/public/database.h diff --git a/Heart/DataBaseSpace/dbaddress.cpp b/src/public/dbaddress.cpp similarity index 100% rename from Heart/DataBaseSpace/dbaddress.cpp rename to src/public/dbaddress.cpp diff --git a/Heart/DataBaseSpace/dbaddress.h b/src/public/dbaddress.h similarity index 100% rename from Heart/DataBaseSpace/dbaddress.h rename to src/public/dbaddress.h diff --git a/Heart/DataBaseSpace/dbaddresskey.cpp b/src/public/dbaddresskey.cpp similarity index 100% rename from Heart/DataBaseSpace/dbaddresskey.cpp rename to src/public/dbaddresskey.cpp diff --git a/Heart/DataBaseSpace/dbaddresskey.h b/src/public/dbaddresskey.h similarity index 100% rename from Heart/DataBaseSpace/dbaddresskey.h rename to src/public/dbaddresskey.h diff --git a/Heart/DataBaseSpace/dbpatch.cpp b/src/public/dbpatch.cpp similarity index 100% rename from Heart/DataBaseSpace/dbpatch.cpp rename to src/public/dbpatch.cpp diff --git a/Heart/DataBaseSpace/dbpatch.h b/src/public/dbpatch.h similarity index 100% rename from Heart/DataBaseSpace/dbpatch.h rename to src/public/dbpatch.h diff --git a/Heart/AbstractSpace/distversion.cpp b/src/public/distversion.cpp similarity index 100% rename from Heart/AbstractSpace/distversion.cpp rename to src/public/distversion.cpp diff --git a/Heart/AbstractSpace/distversion.h b/src/public/distversion.h similarity index 100% rename from Heart/AbstractSpace/distversion.h rename to src/public/distversion.h diff --git a/Heart/AbstractSpace/hcrypto/ecdsassl11.cpp b/src/public/hcrypto/ecdsassl11.cpp similarity index 97% rename from Heart/AbstractSpace/hcrypto/ecdsassl11.cpp rename to src/public/hcrypto/ecdsassl11.cpp index 763aac3a..1813c6d9 100644 --- a/Heart/AbstractSpace/hcrypto/ecdsassl11.cpp +++ b/src/public/hcrypto/ecdsassl11.cpp @@ -199,11 +199,11 @@ bool ECDSASSL11::checkSign(const QByteArray &inputData, } -QByteArray ECDSASSL11::decript(const QByteArray &message, const QByteArray &key) { +QByteArray ECDSASSL11::decript(const QByteArray &, const QByteArray &) { return {}; } -QByteArray ECDSASSL11::encript(const QByteArray &message, const QByteArray &key) { +QByteArray ECDSASSL11::encript(const QByteArray &, const QByteArray &) { return {}; } diff --git a/Heart/AbstractSpace/hcrypto/ecdsassl11.h b/src/public/hcrypto/ecdsassl11.h similarity index 100% rename from Heart/AbstractSpace/hcrypto/ecdsassl11.h rename to src/public/hcrypto/ecdsassl11.h diff --git a/Heart/AbstractSpace/hcrypto/icrypto.cpp b/src/public/hcrypto/icrypto.cpp similarity index 100% rename from Heart/AbstractSpace/hcrypto/icrypto.cpp rename to src/public/hcrypto/icrypto.cpp diff --git a/Heart/AbstractSpace/hcrypto/icrypto.h b/src/public/hcrypto/icrypto.h similarity index 100% rename from Heart/AbstractSpace/hcrypto/icrypto.h rename to src/public/hcrypto/icrypto.h diff --git a/Heart/AbstractSpace/hcryptoFeatures/asynckeysauth.h b/src/public/hcryptoFeatures/asynckeysauth.h similarity index 100% rename from Heart/AbstractSpace/hcryptoFeatures/asynckeysauth.h rename to src/public/hcryptoFeatures/asynckeysauth.h diff --git a/Heart/AbstractSpace/hcryptoFeatures/authecdsa.h b/src/public/hcryptoFeatures/authecdsa.h similarity index 100% rename from Heart/AbstractSpace/hcryptoFeatures/authecdsa.h rename to src/public/hcryptoFeatures/authecdsa.h diff --git a/Heart/AbstractSpace/hcryptoFeatures/ecdsasigner.h b/src/public/hcryptoFeatures/ecdsasigner.h similarity index 100% rename from Heart/AbstractSpace/hcryptoFeatures/ecdsasigner.h rename to src/public/hcryptoFeatures/ecdsasigner.h diff --git a/Heart/AbstractSpace/hcryptoFeatures/isignerdelegate.cpp b/src/public/hcryptoFeatures/isignerdelegate.cpp similarity index 100% rename from Heart/AbstractSpace/hcryptoFeatures/isignerdelegate.cpp rename to src/public/hcryptoFeatures/isignerdelegate.cpp diff --git a/Heart/AbstractSpace/hcryptoFeatures/isignerdelegate.h b/src/public/hcryptoFeatures/isignerdelegate.h similarity index 100% rename from Heart/AbstractSpace/hcryptoFeatures/isignerdelegate.h rename to src/public/hcryptoFeatures/isignerdelegate.h diff --git a/Heart/AbstractSpace/hcryptoFeatures/signer.h b/src/public/hcryptoFeatures/signer.h similarity index 100% rename from Heart/AbstractSpace/hcryptoFeatures/signer.h rename to src/public/hcryptoFeatures/signer.h diff --git a/Heart/AbstractSpace/header.cpp b/src/public/header.cpp similarity index 100% rename from Heart/AbstractSpace/header.cpp rename to src/public/header.cpp diff --git a/Heart/AbstractSpace/header.h b/src/public/header.h similarity index 100% rename from Heart/AbstractSpace/header.h rename to src/public/header.h diff --git a/Heart/AbstractSpace/hostaddress.cpp b/src/public/hostaddress.cpp similarity index 100% rename from Heart/AbstractSpace/hostaddress.cpp rename to src/public/hostaddress.cpp diff --git a/Heart/AbstractSpace/hostaddress.h b/src/public/hostaddress.h similarity index 100% rename from Heart/AbstractSpace/hostaddress.h rename to src/public/hostaddress.h diff --git a/Heart/DataBaseSpace/iobjectprovider.cpp b/src/public/iobjectprovider.cpp similarity index 100% rename from Heart/DataBaseSpace/iobjectprovider.cpp rename to src/public/iobjectprovider.cpp diff --git a/Heart/DataBaseSpace/iobjectprovider.h b/src/public/iobjectprovider.h similarity index 100% rename from Heart/DataBaseSpace/iobjectprovider.h rename to src/public/iobjectprovider.h diff --git a/Heart/AbstractSpace/iparser.cpp b/src/public/iparser.cpp similarity index 100% rename from Heart/AbstractSpace/iparser.cpp rename to src/public/iparser.cpp diff --git a/Heart/AbstractSpace/iparser.h b/src/public/iparser.h similarity index 100% rename from Heart/AbstractSpace/iparser.h rename to src/public/iparser.h diff --git a/Heart/DataBaseSpace/isqldb.cpp b/src/public/isqldb.cpp similarity index 100% rename from Heart/DataBaseSpace/isqldb.cpp rename to src/public/isqldb.cpp diff --git a/Heart/DataBaseSpace/isqldb.h b/src/public/isqldb.h similarity index 99% rename from Heart/DataBaseSpace/isqldb.h rename to src/public/isqldb.h index 9a841dc6..6964d596 100644 --- a/Heart/DataBaseSpace/isqldb.h +++ b/src/public/isqldb.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include "config.h" #include "softdelete.h" namespace QH { diff --git a/Heart/DataBaseSpace/itoken.cpp b/src/public/itoken.cpp similarity index 100% rename from Heart/DataBaseSpace/itoken.cpp rename to src/public/itoken.cpp diff --git a/Heart/DataBaseSpace/itoken.h b/src/public/itoken.h similarity index 100% rename from Heart/DataBaseSpace/itoken.h rename to src/public/itoken.h diff --git a/Heart/AbstractSpace/package.cpp b/src/public/package.cpp similarity index 100% rename from Heart/AbstractSpace/package.cpp rename to src/public/package.cpp diff --git a/Heart/AbstractSpace/package.h b/src/public/package.h similarity index 100% rename from Heart/AbstractSpace/package.h rename to src/public/package.h diff --git a/Heart/AbstractSpace/packagemanager.cpp b/src/public/packagemanager.cpp similarity index 100% rename from Heart/AbstractSpace/packagemanager.cpp rename to src/public/packagemanager.cpp diff --git a/Heart/AbstractSpace/packagemanager.h b/src/public/packagemanager.h similarity index 100% rename from Heart/AbstractSpace/packagemanager.h rename to src/public/packagemanager.h diff --git a/Heart/AbstractSpace/packages/abstractdata.cpp b/src/public/packages/abstractdata.cpp similarity index 100% rename from Heart/AbstractSpace/packages/abstractdata.cpp rename to src/public/packages/abstractdata.cpp diff --git a/Heart/AbstractSpace/packages/abstractdata.h b/src/public/packages/abstractdata.h similarity index 100% rename from Heart/AbstractSpace/packages/abstractdata.h rename to src/public/packages/abstractdata.h diff --git a/Heart/AbstractSpace/packages/badrequest.cpp b/src/public/packages/badrequest.cpp similarity index 100% rename from Heart/AbstractSpace/packages/badrequest.cpp rename to src/public/packages/badrequest.cpp diff --git a/Heart/AbstractSpace/packages/badrequest.h b/src/public/packages/badrequest.h similarity index 100% rename from Heart/AbstractSpace/packages/badrequest.h rename to src/public/packages/badrequest.h diff --git a/Heart/AbstractSpace/packages/bigdatabase.cpp b/src/public/packages/bigdatabase.cpp similarity index 100% rename from Heart/AbstractSpace/packages/bigdatabase.cpp rename to src/public/packages/bigdatabase.cpp diff --git a/Heart/AbstractSpace/packages/bigdatabase.h b/src/public/packages/bigdatabase.h similarity index 100% rename from Heart/AbstractSpace/packages/bigdatabase.h rename to src/public/packages/bigdatabase.h diff --git a/Heart/AbstractSpace/packages/bigdataheader.cpp b/src/public/packages/bigdataheader.cpp similarity index 100% rename from Heart/AbstractSpace/packages/bigdataheader.cpp rename to src/public/packages/bigdataheader.cpp diff --git a/Heart/AbstractSpace/packages/bigdataheader.h b/src/public/packages/bigdataheader.h similarity index 100% rename from Heart/AbstractSpace/packages/bigdataheader.h rename to src/public/packages/bigdataheader.h diff --git a/Heart/AbstractSpace/packages/bigdatapart.cpp b/src/public/packages/bigdatapart.cpp similarity index 100% rename from Heart/AbstractSpace/packages/bigdatapart.cpp rename to src/public/packages/bigdatapart.cpp diff --git a/Heart/AbstractSpace/packages/bigdatapart.h b/src/public/packages/bigdatapart.h similarity index 100% rename from Heart/AbstractSpace/packages/bigdatapart.h rename to src/public/packages/bigdatapart.h diff --git a/Heart/AbstractSpace/packages/bigdatarequest.cpp b/src/public/packages/bigdatarequest.cpp similarity index 100% rename from Heart/AbstractSpace/packages/bigdatarequest.cpp rename to src/public/packages/bigdatarequest.cpp diff --git a/Heart/AbstractSpace/packages/bigdatarequest.h b/src/public/packages/bigdatarequest.h similarity index 100% rename from Heart/AbstractSpace/packages/bigdatarequest.h rename to src/public/packages/bigdatarequest.h diff --git a/Heart/AbstractSpace/packages/bigdatawraper.cpp b/src/public/packages/bigdatawraper.cpp similarity index 100% rename from Heart/AbstractSpace/packages/bigdatawraper.cpp rename to src/public/packages/bigdatawraper.cpp diff --git a/Heart/AbstractSpace/packages/bigdatawraper.h b/src/public/packages/bigdatawraper.h similarity index 97% rename from Heart/AbstractSpace/packages/bigdatawraper.h rename to src/public/packages/bigdatawraper.h index a2291c48..3cae04dd 100644 --- a/Heart/AbstractSpace/packages/bigdatawraper.h +++ b/src/public/packages/bigdatawraper.h @@ -22,7 +22,7 @@ class BigDataWraper: public AbstractData QH_PACKAGE(BigDataWraper, "BigDataWraper") public: - BigDataWraper(); + BigDataWraper() = default; /** * @brief data This method sets data that shold be sent as big data. diff --git a/Heart/DataBaseSpace/packages/cacheddbobjectsrequest.cpp b/src/public/packages/cacheddbobjectsrequest.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/cacheddbobjectsrequest.cpp rename to src/public/packages/cacheddbobjectsrequest.cpp diff --git a/Heart/DataBaseSpace/packages/cacheddbobjectsrequest.h b/src/public/packages/cacheddbobjectsrequest.h similarity index 100% rename from Heart/DataBaseSpace/packages/cacheddbobjectsrequest.h rename to src/public/packages/cacheddbobjectsrequest.h diff --git a/Heart/AbstractSpace/packages/closeconnection.cpp b/src/public/packages/closeconnection.cpp similarity index 100% rename from Heart/AbstractSpace/packages/closeconnection.cpp rename to src/public/packages/closeconnection.cpp diff --git a/Heart/AbstractSpace/packages/closeconnection.h b/src/public/packages/closeconnection.h similarity index 100% rename from Heart/AbstractSpace/packages/closeconnection.h rename to src/public/packages/closeconnection.h diff --git a/Heart/DataBaseSpace/packages/customdbrequest.cpp b/src/public/packages/customdbrequest.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/customdbrequest.cpp rename to src/public/packages/customdbrequest.cpp diff --git a/Heart/DataBaseSpace/packages/customdbrequest.h b/src/public/packages/customdbrequest.h similarity index 100% rename from Heart/DataBaseSpace/packages/customdbrequest.h rename to src/public/packages/customdbrequest.h diff --git a/Heart/AbstractSpace/packages/datapack.cpp b/src/public/packages/datapack.cpp similarity index 100% rename from Heart/AbstractSpace/packages/datapack.cpp rename to src/public/packages/datapack.cpp diff --git a/Heart/AbstractSpace/packages/datapack.h b/src/public/packages/datapack.h similarity index 100% rename from Heart/AbstractSpace/packages/datapack.h rename to src/public/packages/datapack.h diff --git a/Heart/DataBaseSpace/packages/dbobject.cpp b/src/public/packages/dbobject.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/dbobject.cpp rename to src/public/packages/dbobject.cpp diff --git a/Heart/DataBaseSpace/packages/dbobject.h b/src/public/packages/dbobject.h similarity index 100% rename from Heart/DataBaseSpace/packages/dbobject.h rename to src/public/packages/dbobject.h diff --git a/Heart/DataBaseSpace/packages/dbobjectset.cpp b/src/public/packages/dbobjectset.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/dbobjectset.cpp rename to src/public/packages/dbobjectset.cpp diff --git a/Heart/DataBaseSpace/packages/dbobjectset.h b/src/public/packages/dbobjectset.h similarity index 100% rename from Heart/DataBaseSpace/packages/dbobjectset.h rename to src/public/packages/dbobjectset.h diff --git a/Heart/DataBaseSpace/packages/dbobjectsrequest.cpp b/src/public/packages/dbobjectsrequest.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/dbobjectsrequest.cpp rename to src/public/packages/dbobjectsrequest.cpp diff --git a/Heart/DataBaseSpace/packages/dbobjectsrequest.h b/src/public/packages/dbobjectsrequest.h similarity index 100% rename from Heart/DataBaseSpace/packages/dbobjectsrequest.h rename to src/public/packages/dbobjectsrequest.h diff --git a/Heart/DataBaseSpace/packages/dbobjectsrequestwithStream.cpp b/src/public/packages/dbobjectsrequestwithStream.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/dbobjectsrequestwithStream.cpp rename to src/public/packages/dbobjectsrequestwithStream.cpp diff --git a/Heart/DataBaseSpace/packages/dbobjectsrequestwithStream.h b/src/public/packages/dbobjectsrequestwithStream.h similarity index 100% rename from Heart/DataBaseSpace/packages/dbobjectsrequestwithStream.h rename to src/public/packages/dbobjectsrequestwithStream.h diff --git a/Heart/DataBaseSpace/packages/deleteobject.cpp b/src/public/packages/deleteobject.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/deleteobject.cpp rename to src/public/packages/deleteobject.cpp diff --git a/Heart/DataBaseSpace/packages/deleteobject.h b/src/public/packages/deleteobject.h similarity index 100% rename from Heart/DataBaseSpace/packages/deleteobject.h rename to src/public/packages/deleteobject.h diff --git a/Heart/DataBaseSpace/packages/getmaxintegerid.cpp b/src/public/packages/getmaxintegerid.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/getmaxintegerid.cpp rename to src/public/packages/getmaxintegerid.cpp diff --git a/Heart/DataBaseSpace/packages/getmaxintegerid.h b/src/public/packages/getmaxintegerid.h similarity index 100% rename from Heart/DataBaseSpace/packages/getmaxintegerid.h rename to src/public/packages/getmaxintegerid.h diff --git a/Heart/DataBaseSpace/packages/getsinglevalue.cpp b/src/public/packages/getsinglevalue.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/getsinglevalue.cpp rename to src/public/packages/getsinglevalue.cpp diff --git a/Heart/DataBaseSpace/packages/getsinglevalue.h b/src/public/packages/getsinglevalue.h similarity index 100% rename from Heart/DataBaseSpace/packages/getsinglevalue.h rename to src/public/packages/getsinglevalue.h diff --git a/Heart/AbstractSpace/packages/ping.cpp b/src/public/packages/ping.cpp similarity index 100% rename from Heart/AbstractSpace/packages/ping.cpp rename to src/public/packages/ping.cpp diff --git a/Heart/AbstractSpace/packages/ping.h b/src/public/packages/ping.h similarity index 100% rename from Heart/AbstractSpace/packages/ping.h rename to src/public/packages/ping.h diff --git a/Heart/DataBaseSpace/packages/setsinglevalue.cpp b/src/public/packages/setsinglevalue.cpp similarity index 100% rename from Heart/DataBaseSpace/packages/setsinglevalue.cpp rename to src/public/packages/setsinglevalue.cpp diff --git a/Heart/DataBaseSpace/packages/setsinglevalue.h b/src/public/packages/setsinglevalue.h similarity index 100% rename from Heart/DataBaseSpace/packages/setsinglevalue.h rename to src/public/packages/setsinglevalue.h diff --git a/Heart/AbstractSpace/request.cpp b/src/public/request.cpp similarity index 100% rename from Heart/AbstractSpace/request.cpp rename to src/public/request.cpp diff --git a/Heart/AbstractSpace/request.h b/src/public/request.h similarity index 100% rename from Heart/AbstractSpace/request.h rename to src/public/request.h diff --git a/Heart/AbstractSpace/softdelete.cpp b/src/public/softdelete.cpp similarity index 100% rename from Heart/AbstractSpace/softdelete.cpp rename to src/public/softdelete.cpp diff --git a/Heart/AbstractSpace/softdelete.h b/src/public/softdelete.h similarity index 100% rename from Heart/AbstractSpace/softdelete.h rename to src/public/softdelete.h diff --git a/Heart/DataBaseSpace/sqldb.cpp b/src/public/sqldb.cpp similarity index 100% rename from Heart/DataBaseSpace/sqldb.cpp rename to src/public/sqldb.cpp diff --git a/Heart/DataBaseSpace/sqldb.h b/src/public/sqldb.h similarity index 100% rename from Heart/DataBaseSpace/sqldb.h rename to src/public/sqldb.h diff --git a/Heart/DataBaseSpace/sqldbwriter.cpp b/src/public/sqldbwriter.cpp similarity index 100% rename from Heart/DataBaseSpace/sqldbwriter.cpp rename to src/public/sqldbwriter.cpp diff --git a/Heart/DataBaseSpace/sqldbwriter.h b/src/public/sqldbwriter.h similarity index 100% rename from Heart/DataBaseSpace/sqldbwriter.h rename to src/public/sqldbwriter.h diff --git a/Heart/DataBaseSpace/sqlitedbcache.cpp b/src/public/sqlitedbcache.cpp similarity index 100% rename from Heart/DataBaseSpace/sqlitedbcache.cpp rename to src/public/sqlitedbcache.cpp diff --git a/Heart/DataBaseSpace/sqlitedbcache.h b/src/public/sqlitedbcache.h similarity index 100% rename from Heart/DataBaseSpace/sqlitedbcache.h rename to src/public/sqlitedbcache.h diff --git a/Heart/AbstractSpace/streambase.cpp b/src/public/streambase.cpp similarity index 100% rename from Heart/AbstractSpace/streambase.cpp rename to src/public/streambase.cpp diff --git a/Heart/AbstractSpace/streambase.h b/src/public/streambase.h similarity index 100% rename from Heart/AbstractSpace/streambase.h rename to src/public/streambase.h diff --git a/Heart/AbstractSpace/workstate.cpp b/src/public/workstate.cpp similarity index 100% rename from Heart/AbstractSpace/workstate.cpp rename to src/public/workstate.cpp diff --git a/Heart/AbstractSpace/workstate.h b/src/public/workstate.h similarity index 100% rename from Heart/AbstractSpace/workstate.h rename to src/public/workstate.h diff --git a/Heart/DataBaseSpace/Res/BaseDB.sql b/src/res/BaseDB.sql similarity index 100% rename from Heart/DataBaseSpace/Res/BaseDB.sql rename to src/res/BaseDB.sql diff --git a/Heart/DataBaseSpace/Res/DbConfig.json b/src/res/DbConfig.json similarity index 100% rename from Heart/DataBaseSpace/Res/DbConfig.json rename to src/res/DbConfig.json From 832eeb10b9c32a8e04641e2595919034285e7c3c Mon Sep 17 00:00:00 2001 From: EndrII Date: Tue, 29 Nov 2022 11:23:47 +0300 Subject: [PATCH 11/19] fix docs --- .gitignore | 2 +- .gitmodules | 7 +- CMakeLists.txt | 37 +- QuasarAppLib | 1 - doxygen.conf | 145 +- doxygen.conf.in | 2497 +++++++++++++++++++++++++++++++++++ res/Logo_Web_alpha.png | Bin 0 -> 75778 bytes src/CMakeLists.txt | 1 - src/heart_global.h.in | 3 +- src/public/abstractnode.cpp | 1 + submodules/QuasarAppLib | 1 + 11 files changed, 2587 insertions(+), 108 deletions(-) delete mode 160000 QuasarAppLib create mode 100644 doxygen.conf.in create mode 100644 res/Logo_Web_alpha.png create mode 160000 submodules/QuasarAppLib diff --git a/.gitignore b/.gitignore index 4ec7f1f8..ef0421ca 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,6 @@ HeartTests/cmake_install.cmake cmake_install.cmake docs/ src/heart_global.h - +doxygen.conf # git *.orig diff --git a/.gitmodules b/.gitmodules index 5d41ae3c..d50a29ef 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,6 @@ -[submodule "QuasarAppLib"] - path = QuasarAppLib - url = https://github.com/QuasarApp/QuasarAppLib.git - [submodule "submodules/crc"] path = submodules/crc url = https://github.com/QuasarApp/crc.git +[submodule "submodules/QuasarAppLib"] + path = submodules/QuasarAppLib + url = https://github.com/QuasarApp/QuasarAppLib.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 08eccd46..f8b79620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,8 @@ if(TARGET ${PROJECT_NAME}) return() endif() -include(QuasarAppLib/CMake/QuasarApp.cmake) -include(QuasarAppLib/CMake/Version.cmake) +include(submodules/QuasarAppLib/CMake/QuasarApp.cmake) +include(submodules/QuasarAppLib/CMake/Version.cmake) if (DEFINED TARGET_PLATFORM_TOOLCHAIN) if (${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32") @@ -23,26 +23,14 @@ if (DEFINED TARGET_PLATFORM_TOOLCHAIN) endif() endif() -if(NOT DEFINED HEART_BUILD_LVL) - set(HEART_BUILD_LVL 1) -endif() - -if (NOT DEFINED HEART_TESTS) - set(HEART_TESTS ON) +updateGitVars() +set(HEART_VERSION 1.2.${GIT_COMMIT_COUNT}.${GIT_COMMIT_HASH}) - if (ANDROID OR IOS) - set(HEART_TESTS OFF) - endif() -endif() - -if (NOT DEFINED HEART_DB_CACHE) - set(HEART_DB_CACHE OFF) - - if (ANDROID OR WIN32) - set(HEART_DB_CACHE OFF) - endif() +if (ANDROID OR IOS) + option(HEART_TESTS "Enable or disable tests of the heart library" OFF) +else() + option(HEART_TESTS "Enable or disable tests of the heart library" ON) endif() - # Use only for android debug builds with debugging from usb. option(HEART_STATIC_SSL "This option enable or disabled static link ssl libraryes" OFF) option(CMAKE_SHARE "This option enable or disabled ssl functions of nodes" OFF) @@ -54,16 +42,11 @@ else() option(HEART_SSL "This option enable or disabled ssl functions of nodes" ON) endif() - -if (HEART_DB_CACHE) - add_definitions(-DHEART_DB_CACHE) -endif() - # Add sub directories find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Network Sql Concurrent REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network Sql Concurrent REQUIRED) -add_subdirectory(QuasarAppLib) +add_subdirectory(submodules/QuasarAppLib) add_subdirectory(submodules/crc) add_subdirectory(src) @@ -73,4 +56,6 @@ endif() initAll() +configure_file_in(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf) addDoc(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf) + diff --git a/QuasarAppLib b/QuasarAppLib deleted file mode 160000 index c492fa2f..00000000 --- a/QuasarAppLib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c492fa2fe8b83f93806cc31498af66ee053630ae diff --git a/doxygen.conf b/doxygen.conf index 19e832d8..e3140f29 100644 --- a/doxygen.conf +++ b/doxygen.conf @@ -37,20 +37,21 @@ PROJECT_NAME = Heart # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = @HEART_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = +PROJECT_BRIEF = Heart is base back end library for your c++ Qt projects. + # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = +PROJECT_LOGO = res/Logo_Web_alpha.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is @@ -161,7 +162,7 @@ FULL_PATH_NAMES = YES # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. -STRIP_FROM_PATH = +STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which @@ -170,7 +171,7 @@ STRIP_FROM_PATH = # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -237,13 +238,13 @@ TAB_SIZE = 4 # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. -ALIASES = +ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. -TCL_SUBST = +TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -290,7 +291,7 @@ OPTIMIZE_OUTPUT_VHDL = NO # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable @@ -647,7 +648,7 @@ GENERATE_DEPRECATEDLIST= YES # sections, marked by \if ... \endif and \cond # ... \endcond blocks. -ENABLED_SECTIONS = +ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the @@ -689,7 +690,7 @@ SHOW_NAMESPACES = YES # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated @@ -702,7 +703,7 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = Heart/Qt-Secret/res/DoxyStyle/DoxygenLayout.xml +LAYOUT_FILE = submodules/CMake/DoxyStyle/DoxygenLayout.xml # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib @@ -712,7 +713,7 @@ LAYOUT_FILE = Heart/Qt-Secret/res/DoxyStyle/DoxygenLayout.xml # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. -CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages @@ -777,7 +778,7 @@ WARN_FORMAT = "$file:$line: $text" # messages should be written. If left blank the output is written to standard # error (stderr). -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files @@ -789,9 +790,9 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = Heart \ +INPUT = src \ README.md - + # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -874,9 +875,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = ./Heart/Qt-Secret \ - ./Heart/NetworkSpace \ - ./Heart/CMakeFiles +EXCLUDE = ./submodules # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -892,7 +891,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -903,13 +902,13 @@ EXCLUDE_PATTERNS = # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = +EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and @@ -950,7 +949,7 @@ IMAGE_PATH = ./Heart/AbstractSpace/Diagrams # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. -INPUT_FILTER = +INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the @@ -963,7 +962,7 @@ INPUT_FILTER = # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. -FILTER_PATTERNS = +FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for @@ -978,7 +977,7 @@ FILTER_SOURCE_FILES = NO # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. -FILTER_SOURCE_PATTERNS = +FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page @@ -1090,7 +1089,7 @@ CLANG_ASSISTED_PARSING = NO # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. -CLANG_OPTIONS = +CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index @@ -1116,7 +1115,7 @@ COLS_IN_ALPHA_INDEX = 5 # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output @@ -1160,7 +1159,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1170,7 +1169,7 @@ HTML_HEADER = # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = +HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of @@ -1182,7 +1181,7 @@ HTML_FOOTER = # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets @@ -1195,7 +1194,7 @@ HTML_STYLESHEET = # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_STYLESHEET = Heart/Qt-Secret/res/DoxyStyle/doxygenStyles.css +HTML_EXTRA_STYLESHEET = submodules/CMake/DoxyStyle/doxygenStyles.css # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note @@ -1205,7 +1204,7 @@ HTML_EXTRA_STYLESHEET = Heart/Qt-Secret/res/DoxyStyle/doxygenStyles.css # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_FILES = +HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to @@ -1216,7 +1215,7 @@ HTML_EXTRA_FILES = # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_HUE = 202 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A @@ -1224,7 +1223,7 @@ HTML_COLORSTYLE_HUE = 220 # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_SAT = 212 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 @@ -1235,7 +1234,7 @@ HTML_COLORSTYLE_SAT = 100 # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE_GAMMA = 80 +HTML_COLORSTYLE_GAMMA = 59 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this @@ -1334,7 +1333,7 @@ GENERATE_HTMLHELP = NO # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_FILE = +CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, @@ -1342,7 +1341,7 @@ CHM_FILE = # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -HHC_LOCATION = +HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). @@ -1355,7 +1354,7 @@ GENERATE_CHI = NO # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it @@ -1386,7 +1385,7 @@ GENERATE_QHP = NO # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. -QCH_FILE = +QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace @@ -1394,7 +1393,7 @@ QCH_FILE = # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_NAMESPACE = QuasarAppj +QHP_NAMESPACE = QuasarApp # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual @@ -1411,7 +1410,7 @@ QHP_VIRTUAL_FOLDER = doc # filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom @@ -1419,21 +1418,21 @@ QHP_CUST_FILTER_NAME = # filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. -QHG_LOCATION = +QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To @@ -1566,7 +1565,7 @@ MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site @@ -1574,7 +1573,7 @@ MATHJAX_EXTENSIONS = # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_CODEFILE = +MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and @@ -1607,7 +1606,7 @@ SEARCHENGINE = YES # The default value is: NO. # This tag requires that the tag SEARCHENGINE is set to YES. -SERVER_BASED_SEARCH = NO +SERVER_BASED_SEARCH = YES # When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP # script for searching. Instead the search results are written to an XML file @@ -1634,7 +1633,7 @@ EXTERNAL_SEARCH = NO # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. -SEARCHENGINE_URL = +SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the @@ -1650,7 +1649,7 @@ SEARCHDATA_FILE = searchdata.xml # projects and redirect the results back to the right project. # This tag requires that the tag SEARCHENGINE is set to YES. -EXTERNAL_SEARCH_ID = +EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are @@ -1660,7 +1659,7 @@ EXTERNAL_SEARCH_ID = # EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... # This tag requires that the tag SEARCHENGINE is set to YES. -EXTRA_SEARCH_MAPPINGS = +EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output @@ -1724,7 +1723,7 @@ PAPER_TYPE = a4 # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. -EXTRA_PACKAGES = +EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for the # generated LaTeX document. The header should contain everything until the first @@ -1740,7 +1739,7 @@ EXTRA_PACKAGES = # to HTML_HEADER. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_HEADER = +LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the # generated LaTeX document. The footer should contain everything after the last @@ -1751,7 +1750,7 @@ LATEX_HEADER = # Note: Only use a user-defined footer if you know what you are doing! # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_FOOTER = +LATEX_FOOTER = # The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined # LaTeX style sheets that are included after the standard style sheets created @@ -1762,7 +1761,7 @@ LATEX_FOOTER = # list). # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_STYLESHEET = # The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the LATEX_OUTPUT output @@ -1770,7 +1769,7 @@ LATEX_EXTRA_STYLESHEET = # markers available. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EXTRA_FILES = +LATEX_EXTRA_FILES = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is # prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will @@ -1878,14 +1877,14 @@ RTF_HYPERLINKS = NO # default style sheet that doxygen normally uses. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is # similar to doxygen's config file. A template extensions file can be generated # using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = # If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code # with syntax highlighting in the RTF output. @@ -1930,7 +1929,7 @@ MAN_EXTENSION = .3 # MAN_EXTENSION with the initial . removed. # This tag requires that the tag GENERATE_MAN is set to YES. -MAN_SUBDIR = +MAN_SUBDIR = # If the MAN_LINKS tag is set to YES and doxygen generates man output, then it # will generate one additional man file for each entity documented in the real @@ -2043,7 +2042,7 @@ PERLMOD_PRETTY = YES # overwrite each other's variables. # This tag requires that the tag GENERATE_PERLMOD is set to YES. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor @@ -2084,7 +2083,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = +INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the @@ -2092,7 +2091,7 @@ INCLUDE_PATH = # used. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that are # defined before the preprocessor is started (similar to the -D option of e.g. @@ -2111,7 +2110,7 @@ PREDEFINED = HEART_SSL # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have @@ -2140,13 +2139,13 @@ SKIP_FUNCTION_MACROS = YES # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create a # tag file that is based on the input files it reads. See section "Linking to # external documentation" for more information about the usage of tag files. -GENERATE_TAGFILE = +GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES, all external class will be listed in # the class index. If set to NO, only the inherited external classes will be @@ -2195,14 +2194,14 @@ CLASS_DIAGRAMS = YES # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. # If left empty dia is assumed to be found in the default search path. -DIA_PATH = +DIA_PATH = # If set to YES the inheritance and collaboration graphs will hide inheritance # and usage relations if the target is undocumented or is not a class. @@ -2251,7 +2250,7 @@ DOT_FONTSIZE = 10 # the path where dot can find it using this tag. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTPATH = +DOT_FONTPATH = # If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for # each documented class showing the direct and indirect inheritance relations. @@ -2397,26 +2396,26 @@ INTERACTIVE_SVG = YES # found. If left blank, it is assumed the dot tool can be found in the path. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_PATH = +DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the \dotfile # command). # This tag requires that the tag HAVE_DOT is set to YES. -DOTFILE_DIRS = +DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the \mscfile # command). -MSCFILE_DIRS = +MSCFILE_DIRS = # The DIAFILE_DIRS tag can be used to specify one or more directories that # contain dia files that are included in the documentation (see the \diafile # command). -DIAFILE_DIRS = +DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the # path where java can find the plantuml.jar file. If left blank, it is assumed @@ -2424,17 +2423,17 @@ DIAFILE_DIRS = # generate a warning when it encounters a \startuml command in this case and # will not generate output for the diagram. -PLANTUML_JAR_PATH = +PLANTUML_JAR_PATH = # When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a # configuration file for plantuml. -PLANTUML_CFG_FILE = +PLANTUML_CFG_FILE = # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. -PLANTUML_INCLUDE_PATH = +PLANTUML_INCLUDE_PATH = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes # that will be shown in the graph. If the number of nodes in a graph becomes diff --git a/doxygen.conf.in b/doxygen.conf.in new file mode 100644 index 00000000..7180cde6 --- /dev/null +++ b/doxygen.conf.in @@ -0,0 +1,2497 @@ +# Doxyfile 1.8.13 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = Heart +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = docs + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 0. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 0 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = Heart/Qt-Secret/res/DoxyStyle/DoxygenLayout.xml + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = src \ + README.md + + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = ./Heart/Qt-Secret \ + ./Heart/NetworkSpace \ + ./Heart/CMakeFiles + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = ./Heart/AbstractSpace/Diagrams + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = README.md + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse-libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = . + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = Heart/Qt-Secret/res/DoxyStyle/doxygenStyles.css + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = QuasarAppj + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = QuasarApp.Heart + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /