update license and add singelServerClient class.

This commit is contained in:
Andrei Yankovich 2021-01-31 19:51:00 +03:00
parent c7c2cea9af
commit d2a40df949
161 changed files with 473 additions and 356 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2020 QuasarApp.
# Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.
@ -178,12 +178,6 @@ void AbstractNode::addNode(const HostAddress &nodeAdderess) {
void AbstractNode::removeNode(const HostAddress &nodeAdderess) {
for (int status = static_cast<int>(NodeCoonectionStatus::NotConnected);
status < static_cast<int>(NodeCoonectionStatus::Confirmed); ++status) {
takeFromQueue(nodeAdderess, static_cast<NodeCoonectionStatus>(status));
}
if (AbstractNodeInfo *ptr = getInfoPtr(nodeAdderess)) {
if (ptr->isLocal()) {
@ -362,23 +356,18 @@ bool AbstractNode::registerSocket(QAbstractSocket *socket, const HostAddress* cl
_connectionsMutex.unlock();
connect(info, &AbstractNodeInfo::sigReadyRead, this, &AbstractNode::avelableBytes);
connect(info, &AbstractNodeInfo::sigReadyRead,
this, &AbstractNode::avelableBytes);
// using direct connection because socket clear all data of ip and port after disconnected.
connect(info, &AbstractNodeInfo::sigDisconnected, this, &AbstractNode::handleDisconnected,
Qt::DirectConnection);
connect(info, &AbstractNodeInfo::sigConnected, this, &AbstractNode::handleConnected,
connect(info, &AbstractNodeInfo::statusChaned,
this, &AbstractNode::handleNodeStatusChanged,
Qt::QueuedConnection);
if (info->isConnected()) {
emit socket->connected();
}
// check node confirmed
QTimer::singleShot(WAIT_TIME, this,
std::bind(&AbstractNode::handleCheckConfirmendOfNode, this, cliAddress));
QTimer::singleShot(WAIT_TIME, [this, info]() {
checkConfirmendOfNode(info);
});
connectionRegistered(info);
@ -766,51 +755,6 @@ void AbstractNode::avelableBytes(AbstractNodeInfo *sender) {
}
}
void AbstractNode::handleDisconnected(AbstractNodeInfo* sender) {
if (!sender) {
QuasarAppUtils::Params::log("system error in void Server::handleDisconected()"
" address not valid",
QuasarAppUtils::Error);
return;
}
sender->setStatus(NodeCoonectionStatus::NotConnected);
nodeStatusChanged(sender->networkAddress(), NodeCoonectionStatus::NotConnected);
return;
}
void AbstractNode::handleConnected(AbstractNodeInfo *sender) {
if (!sender) {
QuasarAppUtils::Params::log("system error in void Server::handleDisconected()"
" address not valid",
QuasarAppUtils::Error);
return;
}
sender->setStatus(NodeCoonectionStatus::Connected);
nodeStatusChanged(sender->networkAddress(), NodeCoonectionStatus::Connected);
return;
}
void AbstractNode::nodeConfirmet(AbstractNodeInfo *sender) {
if (!sender) {
QuasarAppUtils::Params::log("system error in void Server::handleDisconected()"
" address not valid",
QuasarAppUtils::Error);
return;
}
sender->setStatus(NodeCoonectionStatus::Confirmed);
nodeStatusChanged(sender->networkAddress(), NodeCoonectionStatus::Confirmed);
}
void AbstractNode::handleCheckConfirmendOfNode(HostAddress node) {
checkConfirmendOfNode(node);
}
void AbstractNode::handleWorkerStoped() {
auto senderObject = dynamic_cast<QFutureWatcher <bool>*>(sender());
@ -857,12 +801,7 @@ void AbstractNode::newWork(const Package &pkg, AbstractNodeInfo *sender,
}
_confirmNodeMutex.lock();
bool fConfirmed = sender->confirmData();
if (fConfirmed && sender->status() != NodeCoonectionStatus::Confirmed) {
nodeConfirmet(sender);
}
sender->updateConfirmStatus();
_confirmNodeMutex.unlock();
@ -928,44 +867,11 @@ void AbstractNode::connectionRegistered(const AbstractNodeInfo *info) {
Q_UNUSED(info)
}
void AbstractNode::pushToQueue(const std::function<void()>& action,
const HostAddress &node,
NodeCoonectionStatus triggerStatus) {
_actionCacheMutex.lock();
_actionCache[node][triggerStatus].push_back(action);
_actionCacheMutex.unlock();
}
QList<std::function<void ()> >
AbstractNode::takeFromQueue(const HostAddress &node,
NodeCoonectionStatus triggerStatus) {
_actionCacheMutex.lock();
auto list = _actionCache[node][triggerStatus];
_actionCache[node].remove(triggerStatus);
if (_actionCache[node].size() == 0)
_actionCache.remove(node);
_actionCacheMutex.unlock();
return list;
}
void AbstractNode::prepareForDelete() {
stop();
}
void AbstractNode::nodeStatusChanged(const HostAddress &node, NodeCoonectionStatus status) {
auto list = takeFromQueue(node, status);
for (const auto &action : list) {
action();
}
void AbstractNode::handleNodeStatusChanged(AbstractNodeInfo *node, NodeCoonectionStatus status) {
if (status == NodeCoonectionStatus::NotConnected) {
nodeDisconnected(node);
@ -976,26 +882,25 @@ void AbstractNode::nodeStatusChanged(const HostAddress &node, NodeCoonectionStat
}
}
void AbstractNode::nodeConfirmend(const HostAddress &node) {
void AbstractNode::nodeConfirmend(AbstractNodeInfo *node) {
Q_UNUSED(node)
}
void AbstractNode::nodeConnected(const HostAddress &node) {
void AbstractNode::nodeConnected(AbstractNodeInfo *node) {
Q_UNUSED(node)
}
void AbstractNode::nodeDisconnected(const HostAddress &node) {
void AbstractNode::nodeDisconnected(AbstractNodeInfo *node) {
Q_UNUSED(node)
}
void AbstractNode::checkConfirmendOfNode(const HostAddress &node) {
auto info = getInfoPtr(node);
void AbstractNode::checkConfirmendOfNode(AbstractNodeInfo *info) {
if(!info)
return;
if (info->status() != NodeCoonectionStatus::Confirmed) {
removeNode(node);
removeNode(info->networkAddress());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.
@ -457,56 +457,26 @@ protected:
*/
virtual void connectionRegistered(const AbstractNodeInfo *info);
/**
* @brief nodeStatusChanged This method invoked when status of node chganged.
* Base implementation do nothing. Override this method for add own functionality.
* @param node This is address of changed node.
* @param status This is new status of node.
*
*/
void nodeStatusChanged(const HostAddress& node, NodeCoonectionStatus status);
/**
* @brief nodeConfirmend This method invocked when the node status changed to "confirmend"
* default implementatio do nothing
* @param node This is address of changed node
*/
virtual void nodeConfirmend(const HostAddress& node);
virtual void nodeConfirmend(AbstractNodeInfo *node);
/**
* @brief nodeConnected This method invocked when the node status changed to "connected"
* default implementatio do nothing
* @param node This is address of changed node
*/
virtual void nodeConnected(const HostAddress& node);
virtual void nodeConnected(AbstractNodeInfo *node);
/**
* @brief nodeConnected This method invocked when the node status changed to "disconnected"
* default implementatio do nothing
* @param node This is address of changed node
*/
virtual void nodeDisconnected(const HostAddress& node);
/**
* @brief pushToQueue - This method add action to queue. When the node status will be equal 'triggerStatus' then node run a action method.
* @param node This is address of node that changed status.
* @param action This is lyamda function with action.
* @param triggerStatus This is awaiting status of node.
*/
void pushToQueue(const std::function<void ()> &action,
const HostAddress& node,
NodeCoonectionStatus triggerStatus);
/**
* @brief takeFromQueue This method take the list of actions of node.
* After invoke take elements will be removed.
* @param node This is address of node that changed status.
* @param triggerStatus This is awaiting status of node.
* @return The list of an actions
*/
QList<std::function<void ()>> takeFromQueue(const HostAddress& node,
NodeCoonectionStatus triggerStatus);
virtual void nodeDisconnected(AbstractNodeInfo *node);
void prepareForDelete() override;
@ -514,9 +484,14 @@ protected:
private slots:
void avelableBytes(AbstractNodeInfo* sender);
void handleDisconnected(AbstractNodeInfo* sender);
void handleConnected(AbstractNodeInfo* sender);
void handleCheckConfirmendOfNode(HostAddress node);
/**
* @brief handleNodeStatusChanged This method invoked when status of peer node chganged.
* @param node This is address of changed node.
* @param status This is new status of node.
*
*/
void handleNodeStatusChanged(AbstractNodeInfo* node, NodeCoonectionStatus status);
/**
* @brief handleWorkerStoped
@ -549,32 +524,22 @@ private:
*/
void newWork(const Package &pkg, AbstractNodeInfo *sender, const HostAddress &id);
/**
* @brief nodeConfirmet - this metthod invoked when node is confirment.
* @param sender - node with new status;
*/
void nodeConfirmet(AbstractNodeInfo *sender);
/**
* @brief checkConfirmendOfNode - this method remove old not confirmed node.
* @param node - node address
*/
void checkConfirmendOfNode(const HostAddress& node);
void checkConfirmendOfNode(AbstractNodeInfo *node);
SslMode _mode = SslMode::NoSSL;
QSslConfiguration _ssl;
QHash<HostAddress, AbstractNodeInfo*> _connections;
QHash<HostAddress, ReceiveData*> _receiveData;
QHash<HostAddress, QHash<NodeCoonectionStatus, QList<std::function<void()>>>> _actionCache;
DataSender * _dataSender = nullptr;
QSet<QFutureWatcher <bool>*> _workers;
mutable QMutex _connectionsMutex;
mutable QMutex _actionCacheMutex;
mutable QMutex _confirmNodeMutex;
QThreadPool *_threadPool = nullptr;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.
@ -27,16 +27,16 @@ QAbstractSocket *AbstractNodeInfo::sct() const {
return _sct;
}
void AbstractNodeInfo::disconnect(bool disableEvents) {
void AbstractNodeInfo::disconnect() {
if (_sct) {
auto socketPtr = _sct;
if (disableEvents)
socketPtr->disconnect();
socketPtr->disconnect();
_sct = nullptr;
socketPtr->close();
socketPtr->deleteLater();
setStatus(NodeCoonectionStatus::NotConnected);
}
}
@ -54,20 +54,37 @@ void AbstractNodeInfo::unBan() {
}
void AbstractNodeInfo::setSct(QAbstractSocket *sct) {
QObject::disconnect(_sct, nullptr, this, nullptr);
AbstractNodeInfo::disconnect();
_sct = sct;
if (_sct && !_sct->peerAddress().isNull()) {
if (!_sct)
return;
if (!_sct->peerAddress().isNull()) {
setNetworkAddress(HostAddress{_sct->peerAddress(), _sct->peerPort()});
}
auto connectedF = [this] () {
setStatus(NodeCoonectionStatus::Connected);
emit sigConnected(this);
};
auto diconnectedF = [this] () {
disconnect();
setStatus(NodeCoonectionStatus::NotConnected);
emit sigDisconnected(this);
};
connect(_sct, &QAbstractSocket::connected,
this, [this] (){ emit sigConnected(this);},
Qt::DirectConnection);
this, connectedF, Qt::DirectConnection);
connect(_sct, &QAbstractSocket::disconnected,
this, [this] (){ disconnect(), emit sigDisconnected(this);},
Qt::DirectConnection);
this, diconnectedF, Qt::DirectConnection);
connect(_sct, &QAbstractSocket::errorOccurred,
this, [this] (QAbstractSocket::SocketError err){emit sigErrorOccurred(this, err);},
@ -76,6 +93,10 @@ void AbstractNodeInfo::setSct(QAbstractSocket *sct) {
connect(_sct, &QAbstractSocket::readyRead,
this, [this] (){ emit sigReadyRead(this);},
Qt::DirectConnection);
if (_sct->state() == QAbstractSocket::ConnectedState) {
connectedF();
}
}
void AbstractNodeInfo::setIsLocal(bool isLocal) {
@ -87,13 +108,24 @@ NodeCoonectionStatus AbstractNodeInfo::status() const {
}
void AbstractNodeInfo::setStatus(const NodeCoonectionStatus &status) {
if (status == _status) {
return;
}
_status = status;
emit statusChaned(this, _status);
}
bool AbstractNodeInfo::confirmData() const {
return _status != NodeCoonectionStatus::NotConnected;
}
void AbstractNodeInfo::updateConfirmStatus() {
if (confirmData())
setStatus(NodeCoonectionStatus::Confirmed);
}
bool AbstractNodeInfo::isLocal() const {
return _isLocal;
}
@ -146,7 +178,7 @@ bool AbstractNodeInfo::isValid() const {
}
bool AbstractNodeInfo::isConnected() const {
return isValid() && _sct->state() == QAbstractSocket::ConnectedState;
return isValid() && status() != NodeCoonectionStatus::NotConnected;
}
QDataStream &AbstractNodeInfo::fromStream(QDataStream &stream) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.
@ -89,7 +89,7 @@ public:
* @brief disconnect This method disconnect device from host
* @param disableEvents This argument force nodeInfo object invoke a QObject::disconect method of socket object befor close connection. This using on the poweroff signals. By Default this arguments = false.
*/
virtual void disconnect(bool disableEvents = false);
virtual void disconnect();
/**
* @brief ban this node, set trust value to 0.
@ -184,11 +184,9 @@ public:
void setStatus(const NodeCoonectionStatus &status);
/**
* @brief confirmData This method check all data of node and return true
* if node is confirmed.
* @return true if node is confirmed
* @brief updateConfirmStatus This method invoked after process a received pacakge and update confitm status of the node.
*/
virtual bool confirmData() const;
void updateConfirmStatus();
/**
* @brief isLocal return true if connectuion opened on this node.
@ -230,7 +228,28 @@ signals:
*/
void sigErrorOccurred(AbstractNodeInfo* thisNode, QAbstractSocket::SocketError socketError);
/**
* @brief sigConfirmed This signal emitted when node is confirmend. The confirm status sets in the confirmData method.
* @param thisNode This is pointer to current object.
*/
void sigConfirmed(AbstractNodeInfo* thisNode);
/**
* @brief statusChaned This signal emitted when nodes status is changed.
* @param thisNode This is pointer to current object.
* @param status This is status og node. For more information see the NodeCoonectionStatus enum.
*/
void statusChaned(AbstractNodeInfo* thisNode, NodeCoonectionStatus status);
protected:
/**
* @brief confirmData This method check all data of node and return true
* if node is confirmed.
* @return true if node is confirmed
*/
virtual bool confirmData() const;
/**
* @brief setSct - set socket for this node or client
* @param sct
@ -250,4 +269,7 @@ private:
};
}
Q_DECLARE_METATYPE(QH::NodeCoonectionStatus)
#endif // ABSTRACTNODEINFO_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2020 QuasarApp.
# Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.
@ -125,7 +125,7 @@ void DataBaseNode::initDefaultDbObjects(ISqlDBCache *cache,
}
bool DataBaseNode::welcomeAddress(const HostAddress&) {
bool DataBaseNode::welcomeAddress(AbstractNodeInfo *) {
return true;
}
@ -146,7 +146,7 @@ QSet<QString> DataBaseNode::systemTables() const {
return {"NetworkMembers", "MemberPermisions"};
}
void DataBaseNode::nodeConnected(const HostAddress &node) {
void DataBaseNode::nodeConnected(AbstractNodeInfo *node) {
AbstractNode::nodeConnected(node);
welcomeAddress(node);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.
@ -147,7 +147,7 @@ protected:
*/
virtual QByteArray hashgenerator(const QByteArray &data);
void nodeConnected(const HostAddress &node) override;
void nodeConnected(AbstractNodeInfo *node) override;
/**
* @brief db this node return pointer to database object.
@ -296,12 +296,12 @@ protected:
QString dbLocation() const;
/**
* @brief welcomeAddress This method send to the ip information about yaster self.
* @brief welcomeAddress This method send to the node information about yaster self.
* Override this method if you want send custom data to incomming connection.
* @param ip This is host address of the peer node obeject
* @param node This is info object of the peer node
* @return true if all iformation sendet succesful
*/
virtual bool welcomeAddress(const HostAddress &ip);
virtual bool welcomeAddress(AbstractNodeInfo *node);
/**
* @brief isBanned This method check trust of node, if node trus is lover of 0 return true.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,7 +1,7 @@
#ifndef DELETEOBJECT_H
#define DELETEOBJECT_H
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,3 +1,10 @@
/*
* Copyright (C) 2018-2021 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 "singleserver.h"
#include <authrequest.h>

View File

@ -1,3 +1,10 @@
/*
* Copyright (C) 2018-2021 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

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2018-2021 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 "singleserverclient.h"
#include "quasarapp.h"
namespace QH {
SingleServerClient::SingleServerClient() {
}
ParserResult SingleServerClient::parsePackage(const Package &pkg, const AbstractNodeInfo *sender) {
}
ClientStatus SingleServerClient::getStatus() const {
return _status;
}
bool SingleServerClient::login(const QString &userId, const QString &rawPassword) {
}
bool SingleServerClient::signup(const QString &userId, const QString &rawPassword) {
}
void SingleServerClient::setStatus(const ClientStatus &status) {
if (status == _status)
return;
_status = status;
emit statusChanged(_status);
}
void SingleServerClient::handleError(unsigned char, const QString &error) {
QuasarAppUtils::Params::log(error, QuasarAppUtils::Error);
}
bool SingleServerClient::p_login(const QString &userId, const QByteArray &hashPassword) {
}
bool SingleServerClient::p_signIn(const QString &userId, const QByteArray &hashPassword) {
}
}

View File

@ -0,0 +1,135 @@
/*
* 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 SINGLESERVERCLIENT_H
#define SINGLESERVERCLIENT_H
#include "databasenode.h"
#include <usermember.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 SingleServerClient class This class provide login and singup user functionality for the SingleServer class.
*/
class SingleServerClient: public DataBaseNode
{
Q_OBJECT
public:
SingleServerClient();
QH::ParserResult parsePackage(const QH::Package &pkg,
const QH::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.
* @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 oveeride own behaviof for hashing or add an own salt then you need to override the hashgenerator method.
* @return true if the user send autorisation request successful.
*/
bool login(const QString &userId, const QString &rawPassword = {});
/**
* @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 oveeride own behaviof 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 datat request.
* @return true if the user send remove request successful.
*/
bool removeUser();
/**
* @brief connectToServer This method try connect client ot server.
* @return true if the connect request sendet successful.
*/
bool connectToServer();
/**
* @brief disconnectFromServer This method disconnect the clinet from server.
*/
void disconnectFromServer();
signals:
/**
* @brief statusChanged This sigmnal emited 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(ClientStatus status);
protected:
/**
* @brief setStatus This method sets a new status of the client. This method will be emited the statusChanged signal.
* @param status This is new status of the client.
*/
void setStatus(const ClientStatus &status);
protected slots:
/**
* @brief handleError This handle method invoked when the client received the BadRequest from server. Ovveride 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.
*/
virtual void handleError(unsigned char code, const QString& error);
private:
bool p_login(const QString &userId, const QByteArray &hashPassword = {});
bool p_signIn(const QString &userId, const QByteArray &hashPassword);
ClientStatus _status;
PKG::UserMember _member;
};
}
#endif // SINGLESERVERCLIENT_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 QuasarApp.
* Copyright (C) 2018-2021 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.

Some files were not shown because too many files have changed in this diff Show More