mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
карта блок-в. Блокировка правильная. Множ. доступ
This commit is contained in:
@@ -294,7 +294,7 @@ QByteArray DataParser::createDeAuthMessage(ClientDeAutorization *deAuth)
|
||||
return array;
|
||||
}
|
||||
|
||||
QByteArray DataParser::createQueryBlockAuth(bool block)
|
||||
QByteArray DataParser::createQueryBlockAuth(bool block, QString type)
|
||||
{
|
||||
QByteArray array;
|
||||
QXmlStreamWriter xmlWriter(&array);
|
||||
@@ -304,6 +304,7 @@ QByteArray DataParser::createQueryBlockAuth(bool block)
|
||||
xmlWriter.writeStartElement("BlockAuth");
|
||||
|
||||
xmlWriter.writeAttribute("Block", block ? "1" : "0");
|
||||
xmlWriter.writeAttribute("type", type);
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement();
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
QByteArray createQueryListSubProcMessage(QString dmCode);
|
||||
QByteArray createDeAuthMessage(ClientDeAutorization *deAuth);
|
||||
|
||||
QByteArray createQueryBlockAuth(bool block);
|
||||
QByteArray createQueryBlockAuth(bool block, QString type);
|
||||
|
||||
void createAuthData(ServerAuthorization *serverAuth);
|
||||
void createAuthDataOffline(QString username,QString pass);
|
||||
|
||||
@@ -260,12 +260,12 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
|
||||
if(packetType == PacketType::BUSY)
|
||||
{
|
||||
emit sigAnimationActivated(true);
|
||||
//emit sigAnimationActivated(true);
|
||||
}
|
||||
|
||||
if(packetType == PacketType::FREE)
|
||||
{
|
||||
emit sigAnimationActivated(false);
|
||||
//emit sigAnimationActivated(false);
|
||||
}
|
||||
|
||||
if(packetType == PacketType::HASH_READY)
|
||||
|
||||
@@ -57,7 +57,6 @@ signals:
|
||||
void sigShowServerDataList(QList<StreamingVersionData*> *versions);
|
||||
void sigSetVersion(StreamingVersionData* serverVersion);
|
||||
void sigNotifyVersionControl(QString text);
|
||||
void sigAnimationActivated(bool flag);
|
||||
void sigHashReady();
|
||||
void sigAnswerQuerySubProc(QList<SubProc> listSubProc, QString parentTask_dmCode);
|
||||
|
||||
|
||||
@@ -168,7 +168,6 @@ void ConnectorToServer::bindConnection()
|
||||
connect(recognizeSystem,&RecognizeSystem::signal_AnswerDocsChanged,this,&ConnectorToServer::slot_AnswerDocsChanged);
|
||||
|
||||
connect(recognizeSystem, &RecognizeSystem::sigSetVersion, this, &ConnectorToServer::signal_SetVersion);
|
||||
connect(recognizeSystem, &RecognizeSystem::sigAnimationActivated, this, &ConnectorToServer::signal_AnimationActivated);
|
||||
|
||||
connect(this, &ConnectorToServer::signal_SendCopyVersion, sendSystem, &SendSystem::sendCopyVersion);
|
||||
connect(this, &ConnectorToServer::signal_SendDeleteVersion, sendSystem, &SendSystem::sendDeleteVersion);
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
bool sendQueryTasksXML(QString type);
|
||||
bool sendQueryListSubProc(QString dmCode);
|
||||
bool sendQueryBlockAuth(bool block);
|
||||
bool sendQueryBlockAuth(bool block, QString type);
|
||||
|
||||
void sendShowVersionSelect();
|
||||
bool sendClientNotify(QString command);
|
||||
@@ -149,7 +149,6 @@ signals:
|
||||
void signal_AnswerDocsChanged();
|
||||
|
||||
void signal_SetVersion(StreamingVersionData* serverVersion);
|
||||
void signal_AnimationActivated(bool flag);
|
||||
|
||||
void signal_SendDeleteVersion(StreamingVersionData *streaming);
|
||||
void signal_SendSwitchVersion(StreamingVersionData *selectVersion);
|
||||
|
||||
@@ -95,14 +95,14 @@ bool ConnectorToServer::sendQueryListSubProc(QString dmCode)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::sendQueryBlockAuth(bool block)
|
||||
bool ConnectorToServer::sendQueryBlockAuth(bool block, QString type)
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray array = dataParser->createQueryBlockAuth(block);
|
||||
QByteArray array = dataParser->createQueryBlockAuth(block, type);
|
||||
emit sigSendAnswerToServer(array);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -77,7 +77,7 @@ void ViewerInstructors::slot_receiveMessage(ClientMessage clientMessage)
|
||||
|
||||
void ViewerInstructors::on_btnEditorInstructors_clicked()
|
||||
{
|
||||
connectorToServer->sendQueryBlockAuth(true);
|
||||
connectorToServer->sendQueryBlockAuth(true, "EditorInstructors");
|
||||
|
||||
dlgRedactor = new DialogRedactorInstructors(connectorToServer, adminMode, this);
|
||||
dlgRedactor->exec();
|
||||
@@ -91,7 +91,7 @@ void ViewerInstructors::on_btnEditorInstructors_clicked()
|
||||
if(authComplited)
|
||||
loadInstructorsFromDB();
|
||||
|
||||
connectorToServer->sendQueryBlockAuth(false);
|
||||
connectorToServer->sendQueryBlockAuth(false, "EditorInstructors");
|
||||
}
|
||||
|
||||
void ViewerInstructors::on_treeWidgetCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
|
||||
@@ -214,6 +214,8 @@ void DialogSettings::on_btnSetVersion_clicked()
|
||||
if(connectorToServer)
|
||||
if(connectorToServer->getIsConnected())
|
||||
{
|
||||
connectorToServer->sendQueryBlockAuth(true, "VersionControl");
|
||||
|
||||
dlgVersionControl = new DialogVersionControl(connectorToServer, this);
|
||||
dlgVersionControl->initialize(connectorToServer->getLoginName());
|
||||
dlgVersionControl->exec();
|
||||
@@ -223,6 +225,8 @@ void DialogSettings::on_btnSetVersion_clicked()
|
||||
delete dlgVersionControl;
|
||||
dlgVersionControl = nullptr;
|
||||
}
|
||||
|
||||
connectorToServer->sendQueryBlockAuth(false, "VersionControl");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ void DialogVersionControl::initialize(QString authorName)
|
||||
this->authorName = authorName;
|
||||
|
||||
connect (connectorToServer, &ConnectorToServer::signal_SetVersion, this, &DialogVersionControl::slot_SetVersion);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation);
|
||||
|
||||
connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_NotifyVersionControl, this, &DialogVersionControl::slot_NotifyVersionControl);
|
||||
@@ -69,6 +68,7 @@ void DialogVersionControl::initialize(QString authorName)
|
||||
|
||||
connect(this, &DialogVersionControl::signal_getVersion, connectorToServer, &ConnectorToServer::slot_getVersion);
|
||||
|
||||
waitAnimationWidget->showWithPlay();
|
||||
emit signal_getVersion();
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ void DialogVersionControl::sendCopyEmit(QString newName)
|
||||
}
|
||||
|
||||
versionContainer->setLocalVersionData(selectedVersion);
|
||||
waitAnimationWidget->showWithPlay();
|
||||
emit sigSendCopyVersion(result);
|
||||
}
|
||||
|
||||
@@ -144,6 +145,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked()
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
QString newName = dlgNewVersion->getNewName();
|
||||
waitAnimationWidget->showWithPlay();
|
||||
sendCopyEmit(newName);
|
||||
break;
|
||||
}
|
||||
@@ -171,6 +173,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked()
|
||||
|
||||
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
emit sigSendDeleteVersion(selectedVersion);
|
||||
}
|
||||
}
|
||||
@@ -186,24 +189,14 @@ void DialogVersionControl::on_switchServerVersionButton_clicked()
|
||||
|
||||
//versionContainer->setServerVersionData(selectedVersion);
|
||||
//ui->verValue->setText(selectedVersion->getViewName());
|
||||
waitAnimationWidget->showWithPlay();
|
||||
emit sigSendSwitchVersion(selectedVersion);
|
||||
}
|
||||
|
||||
void DialogVersionControl::slot_activateLoadAnimation(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
}
|
||||
else
|
||||
{
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
}
|
||||
|
||||
void DialogVersionControl::slot_showServerList(QList<StreamingVersionData *> *serverList)
|
||||
{
|
||||
fillView(serverList);
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
|
||||
void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion)
|
||||
@@ -215,11 +208,15 @@ void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion)
|
||||
connectorToServer->sendShowVersionSelect();
|
||||
|
||||
flGetVersion = true;
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
|
||||
void DialogVersionControl::slot_NotifyVersionControl(QString text)
|
||||
{
|
||||
SpecMsgBox::WarningClose(this, text);
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
|
||||
void DialogVersionControl::resizeEvent(QResizeEvent *event)
|
||||
|
||||
@@ -36,7 +36,6 @@ private slots:
|
||||
void on_verListView_itemClicked(QListWidgetItem *item);
|
||||
|
||||
private slots:
|
||||
void slot_activateLoadAnimation(bool flag);
|
||||
void slot_showServerList(QList<StreamingVersionData*> *serverList);
|
||||
void slot_SetVersion(StreamingVersionData* serverVersion);
|
||||
void slot_NotifyVersionControl(QString text);
|
||||
|
||||
@@ -111,7 +111,7 @@ void ViewerTrainees::slot_receiveMessage(ClientMessage clientMessage)
|
||||
|
||||
void ViewerTrainees::on_btnEditorTrainees_clicked()
|
||||
{
|
||||
connectorToServer->sendQueryBlockAuth(true);
|
||||
connectorToServer->sendQueryBlockAuth(true, "EditorTrainees");
|
||||
|
||||
dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this);
|
||||
dlgRedactor->exec();
|
||||
@@ -125,7 +125,7 @@ void ViewerTrainees::on_btnEditorTrainees_clicked()
|
||||
if(authComplited)
|
||||
loadTraineesFromDB();
|
||||
|
||||
connectorToServer->sendQueryBlockAuth(false);
|
||||
connectorToServer->sendQueryBlockAuth(false, "EditorTrainees");
|
||||
}
|
||||
|
||||
void ViewerTrainees::on_btnPersonalCard_clicked()
|
||||
|
||||
@@ -367,6 +367,7 @@ void ProcessParser::clientDeAuth(QXmlStreamReader &xmlReader,ClientHandler *clie
|
||||
void ProcessParser::clientBlockAuth(QXmlStreamReader &xmlReader, ClientHandler *client)
|
||||
{
|
||||
bool block = false;
|
||||
QString type = "";
|
||||
|
||||
/*Перебираем все атрибуты тега*/
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
|
||||
@@ -377,9 +378,12 @@ void ProcessParser::clientBlockAuth(QXmlStreamReader &xmlReader, ClientHandler *
|
||||
|
||||
if(name == "Block")
|
||||
block = (value == "1") ? true : false;
|
||||
|
||||
if(name == "type")
|
||||
type = value;
|
||||
}
|
||||
|
||||
processingSystem->processingClientBlockAuth(client, block);
|
||||
processingSystem->processingClientBlockAuth(client, block, type);
|
||||
}
|
||||
|
||||
void ProcessParser::queryToDb(QXmlStreamReader &xmlReader,ClientHandler *client, QByteArray array)
|
||||
|
||||
@@ -117,7 +117,7 @@ void CommonClientHandler::slot_sendPacketToAllClients(PacketType packetType)
|
||||
Logger::instance().log("AllSending " + handler->getClient()->getLogin() + " " + enumToString(packetType));
|
||||
}
|
||||
|
||||
emit sigSetServerState(packetType);
|
||||
//emit sigSetServerState(packetType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,13 +22,17 @@ public:
|
||||
void slot_ListsInstructorsTraineesChanged();
|
||||
void slot_StatusTasksAMMofTraineeChanged(int trainee_id);
|
||||
void slot_StatusTasksFIMofTraineeChanged(int trainee_id);
|
||||
void slot_sendPacketToAllClients(PacketType packetType);
|
||||
|
||||
bool slotSendMessage(QString loginFrom, QString loginTo, QString text);
|
||||
void slot_sendTaskToClient(QString fullNameClient, QString textTask);
|
||||
|
||||
void slot_DocsChanged();
|
||||
|
||||
public slots:
|
||||
void slot_sendPacketToAllClients(PacketType packetType);
|
||||
|
||||
signals:
|
||||
void sigSetServerState(PacketType packetType);
|
||||
//void sigSetServerState(PacketType packetType);
|
||||
private:
|
||||
QMap<int, ClientHandler*> *clientsMap;
|
||||
ProcessingSystem *processingSystem;
|
||||
|
||||
@@ -164,6 +164,8 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
|
||||
else if(providerDBLMS->deAuthorizationInstructor(clientDeAutorization.Login))
|
||||
{//ДеАвторизуется инструктор
|
||||
|
||||
QString fullName = client->getClient()->getFullName();
|
||||
|
||||
client->getClient()->setLogin("");
|
||||
client->getClient()->setAccessType(UserType::NONE);
|
||||
client->getClient()->setIsLoggedIn(false);
|
||||
@@ -172,6 +174,8 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
|
||||
arrayAnswer = dataParser->ClientAnswer()->deAuthorization(true, clientDeAutorization.Login);
|
||||
client->sendXmlAnswer(arrayAnswer);
|
||||
|
||||
providerDBLMS->signal_BlockAutorization(false, fullName, "DeAuthorizationInstructor");
|
||||
|
||||
//Извещаем об изменениях в авторизации
|
||||
emit sigListsInstructorsTraineesChanged();
|
||||
}
|
||||
@@ -182,9 +186,9 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessingSystem::processingClientBlockAuth(ClientHandler *client, bool block)
|
||||
void ProcessingSystem::processingClientBlockAuth(ClientHandler *client, bool block, QString type)
|
||||
{
|
||||
emit providerDBLMS->signal_BlockAutorization(block);
|
||||
bool res = emit providerDBLMS->signal_BlockAutorization(block, client->getClient()->getFullName(), type);
|
||||
}
|
||||
|
||||
//упращенная деавторизация при выключении сервера
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
void processingClientAutorization(ClientHandler *client, ClientAutorization clientAutorization);
|
||||
void processingClientDeAutorization(ClientHandler *client, ClientDeAutorization clientDeAutorization);
|
||||
void processingClientBlockAuth(ClientHandler *client, bool block);
|
||||
void processingClientBlockAuth(ClientHandler *client, bool block, QString type);
|
||||
void processingClientQueryToDB(ClientHandler *client, ClientQueryToDB clientQueryToDB, int id = 0, void* data = nullptr);
|
||||
void processingClientQueryTasksXML(ClientHandler *client, ClientQueryTasksXML clientQueryTasksXML);
|
||||
void processingClientQueryListSubProc(ClientHandler *client, QString dmCode);
|
||||
|
||||
@@ -411,7 +411,7 @@ void RecognizeSystem::recognize()
|
||||
}
|
||||
|
||||
emit sigCopyVersion(result[0],result[1],result[2]);
|
||||
sendSystem->sendPacketType(PacketType::BUSY);
|
||||
//sendSystem->sendPacketType(PacketType::BUSY); //KAV Вроде, это не нужно (дублируется)?
|
||||
}
|
||||
|
||||
if(packetType == PacketType::DELETE_DATA_VERSION)
|
||||
|
||||
@@ -44,7 +44,7 @@ void UpdateController::initialize(CommonClientHandler *commonClientHandler,DataP
|
||||
|
||||
void UpdateController::changeAssetVersion(QString versionName)
|
||||
{
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
qDebug() << "UpdateController thread ID " << QThread::currentThreadId();
|
||||
currentStreamingPath = assetManager->setVersion(versionName);
|
||||
setUpCurrentServerHash();
|
||||
@@ -52,21 +52,21 @@ void UpdateController::changeAssetVersion(QString versionName)
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY);
|
||||
commonClientHandler->sendCurrentVersionToAllClient();
|
||||
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
}
|
||||
|
||||
void UpdateController::createCopyVersion(QString versionName,QString newVersionName,QString author)
|
||||
{
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
assetManager->createCopyVersion(versionName,newVersionName,author);
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
}
|
||||
|
||||
void UpdateController::deleteAssetVersion(QString versionName)
|
||||
{
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
assetManager->deleteVersion(versionName);
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
}
|
||||
|
||||
void UpdateController::compareFiles(ClientHandler* handler, QByteArray array)
|
||||
@@ -94,7 +94,8 @@ void UpdateController::calculateFullHash()
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
qDebug() << "Start calculate... ";
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::BUSY);
|
||||
bool res = emit signal_BlockAutorization(true, "SERVER", "CalculateFullHash");
|
||||
//auto *list = calculateHash(buildPath);
|
||||
|
||||
hashCalculator->calculateHashes(buildPath);
|
||||
@@ -104,8 +105,8 @@ void UpdateController::calculateFullHash()
|
||||
calculateSharedHash();
|
||||
Logger::instance().log("Calculate hash complete");
|
||||
qDebug() << "Calculate time " << timer.elapsed();
|
||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
|
||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||
res = emit signal_BlockAutorization(false, "SERVER", "CalculateFullHash");
|
||||
}
|
||||
|
||||
void UpdateController::calculateFullHashWithSetup()
|
||||
|
||||
@@ -71,6 +71,9 @@ signals:
|
||||
|
||||
void sigInitializeFinished();
|
||||
|
||||
//сигнал о блокировке авторизации
|
||||
bool signal_BlockAutorization(bool block, QString whoFullName, QString type);
|
||||
|
||||
private:
|
||||
QList<FileData> clientDataList;
|
||||
QList<FileData> serverDataList;
|
||||
|
||||
@@ -36,14 +36,16 @@ bool MultiThreadServer::startServer()
|
||||
|
||||
if(!listen(QHostAddress::Any, hostPort))
|
||||
{
|
||||
Logger::instance().log("SERVER: start ERROR");
|
||||
stateServer = stoped;
|
||||
Logger::instance().log("SERVER: start ERROR");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::instance().log("SERVER: start OK");
|
||||
|
||||
stateServer = started;
|
||||
slot_BlockAutorization(false, "SERVER", "StartServer");
|
||||
Logger::instance().log("SERVER: start OK");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -60,6 +62,7 @@ bool MultiThreadServer::stopServer()
|
||||
//Закрываем сервер
|
||||
close();
|
||||
stateServer = stoped;
|
||||
slot_BlockAutorization(true, "SERVER", "StopServer");
|
||||
Logger::instance().log("SERVER: stop OK");
|
||||
return true;
|
||||
}
|
||||
@@ -94,8 +97,13 @@ void MultiThreadServer::disableClients()
|
||||
|
||||
handler->sigSendXmlAnswer(arrayAnswer, PacketType::TYPE_XMLANSWER);
|
||||
QString str = QString(arrayAnswer);
|
||||
|
||||
QString fullName = handler->getClient()->getFullName();
|
||||
|
||||
processingSystem->processingClientDeAutorization(handler->getClient()->getLogin());
|
||||
|
||||
slot_BlockAutorization(false, fullName, "DisableClient");
|
||||
|
||||
handler->sigSocketClose();
|
||||
//clientsMap.remove(idSocket);
|
||||
removeClient(idSocket);
|
||||
@@ -119,8 +127,12 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
|
||||
|
||||
ClientDeAutorization clientDeAutorization;
|
||||
clientDeAutorization.Login = login;
|
||||
|
||||
//QString fullName = client->getClient()->getFullName();
|
||||
|
||||
processingSystem->processingClientDeAutorization(client, clientDeAutorization);
|
||||
|
||||
//slot_BlockAutorization(false, fullName, "DisconnectClient");
|
||||
removeClient(idSocket);
|
||||
delete client;
|
||||
continue;
|
||||
@@ -135,6 +147,37 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
|
||||
serverLmsWidget->getProcessingSystem()->processingClientDeAutorization(login);
|
||||
}
|
||||
|
||||
bool MultiThreadServer::slot_BlockAutorization(bool block, QString whoFullName, QString type)
|
||||
{
|
||||
bool res = true;
|
||||
bool blockRes = false;
|
||||
|
||||
if(block)
|
||||
{
|
||||
this->blockAutorization();
|
||||
blockersMap.insert(whoFullName, type);
|
||||
blockRes = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
blockersMap.take(whoFullName);
|
||||
if(!blockersMap.count())
|
||||
this->unBlockAutorization();
|
||||
}
|
||||
|
||||
if(res)
|
||||
{
|
||||
if(blockRes)
|
||||
emit signal_sendPacketToAllClients(PacketType::BUSY);
|
||||
else
|
||||
emit signal_sendPacketToAllClients(PacketType::FREE);
|
||||
|
||||
emit signal_BlockAutorizationIndicate(block, whoFullName, type);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void MultiThreadServer::removeClient(int idSocket)
|
||||
{
|
||||
clientsMap->remove(idSocket);
|
||||
|
||||
@@ -21,14 +21,7 @@ public:
|
||||
|
||||
bool startServer();
|
||||
bool stopServer();
|
||||
void blockAutorization()
|
||||
{
|
||||
stateBlockAutorization = blocked;
|
||||
}
|
||||
void unBlockAutorization()
|
||||
{
|
||||
stateBlockAutorization = unblocked;
|
||||
}
|
||||
|
||||
EStateBlockAutorization getStateBlockAutorization() const
|
||||
{
|
||||
return stateBlockAutorization;
|
||||
@@ -37,13 +30,29 @@ public:
|
||||
{
|
||||
return stateServer;
|
||||
}
|
||||
|
||||
private:
|
||||
void blockAutorization()
|
||||
{
|
||||
stateBlockAutorization = blocked;
|
||||
}
|
||||
void unBlockAutorization()
|
||||
{
|
||||
stateBlockAutorization = unblocked;
|
||||
}
|
||||
|
||||
signals:
|
||||
void sigInitClient(int descriptor, ServerLMSWidget *serverWidget,
|
||||
UpdateController *updateController, DataParser *dataParser);
|
||||
void signalStopSendFile();
|
||||
|
||||
void signal_BlockAutorizationIndicate(bool block, QString whoFullName, QString type);
|
||||
void signal_sendPacketToAllClients(PacketType packetType);
|
||||
|
||||
public slots:
|
||||
void slotDisconnectClient(QString peerAddress, QString peerPort);
|
||||
|
||||
bool slot_BlockAutorization(bool block, QString whoFullName, QString type);
|
||||
protected:
|
||||
void incomingConnection(qintptr handle) override;
|
||||
|
||||
@@ -57,6 +66,7 @@ private:
|
||||
|
||||
EStateServer stateServer;
|
||||
EStateBlockAutorization stateBlockAutorization;
|
||||
QMap<QString, QString> blockersMap;
|
||||
|
||||
void removeClient(int idSocket);
|
||||
void addClient(qintptr descriptor, ClientHandler *client);
|
||||
|
||||
@@ -24,7 +24,7 @@ bool ProviderDBLMS::ConnectionToDB()
|
||||
{
|
||||
if(dbLMS->connectionToDB())
|
||||
{
|
||||
Q_EMIT signal_BlockAutorization(false);
|
||||
bool res = Q_EMIT signal_BlockAutorization(false, "SERVER", "DisConnectionDB");
|
||||
|
||||
mtxAccess.unlock();
|
||||
return true;
|
||||
@@ -44,7 +44,7 @@ void ProviderDBLMS::DisConnectionFromDB()
|
||||
mtxAccess.lock();
|
||||
if(dbLMS->DBisConnected())
|
||||
{
|
||||
Q_EMIT signal_BlockAutorization(true);
|
||||
bool res = Q_EMIT signal_BlockAutorization(true, "SERVER", "DisConnectionDB");
|
||||
|
||||
dbLMS->disConnectionFromDB();
|
||||
}
|
||||
@@ -230,12 +230,12 @@ bool ProviderDBLMS::deAuthorizationAll()
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_EMIT signal_BlockAutorization(true);
|
||||
bool res = Q_EMIT signal_BlockAutorization(true, "SERVER", "DeAuthorizationAll");
|
||||
|
||||
bool res1 = dbLMS->deAuthorizationAllTrainees();
|
||||
bool res2 = dbLMS->deAuthorizationAllInstructors();
|
||||
|
||||
Q_EMIT signal_BlockAutorization(false);
|
||||
res = Q_EMIT signal_BlockAutorization(false, "SERVER", "DeAuthorizationAll");
|
||||
|
||||
mtxAccess.unlock();
|
||||
return res1 && res2;
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
//сигнал о блокировке авторизации
|
||||
void signal_BlockAutorization(bool block);
|
||||
bool signal_BlockAutorization(bool block, QString whoFullName, QString type);
|
||||
signals:
|
||||
void signal_ErrorPostgreSQL(QString text);
|
||||
|
||||
|
||||
@@ -191,17 +191,17 @@ void ServerLMSWidget::start()
|
||||
startInitialization_step0();
|
||||
}
|
||||
|
||||
void ServerLMSWidget::slot_BlockAutorization(bool block)
|
||||
void ServerLMSWidget::slot_BlockAutorizationIndicate(bool block, QString whoFullName, QString type)
|
||||
{
|
||||
if(block)
|
||||
{
|
||||
server->blockAutorization();
|
||||
Logger::instance().log("Autorization is blocked");
|
||||
//server->blockAutorization();
|
||||
Logger::instance().log(QString("Server BLOCK from: %1 [type: %2]").arg(whoFullName, type));
|
||||
}
|
||||
else
|
||||
{
|
||||
server->unBlockAutorization();
|
||||
Logger::instance().log("Autorization is unblocked");
|
||||
//server->unBlockAutorization();
|
||||
Logger::instance().log(QString("Server UNBLOCK from: %1 [type: %2]").arg(whoFullName, type));
|
||||
}
|
||||
updateStateOnlyServer();
|
||||
}
|
||||
@@ -222,9 +222,9 @@ void ServerLMSWidget::on_btnStartServer_clicked()
|
||||
|
||||
ui->btnStartServer->setEnabled(false);
|
||||
ui->btnStopServer->setEnabled(true);
|
||||
slot_BlockAutorization(false);
|
||||
//slot_BlockAutorizationIndicate(false, "SERVER");
|
||||
|
||||
updateStateOnlyServer();
|
||||
//updateStateOnlyServer();
|
||||
|
||||
emit signal_Tray_ShowMessage(tr("Server is started!"));
|
||||
|
||||
@@ -240,9 +240,9 @@ void ServerLMSWidget::on_btnStopServer_clicked()
|
||||
|
||||
ui->btnStopServer->setEnabled(false);
|
||||
ui->btnStartServer->setEnabled(true);
|
||||
slot_BlockAutorization(true);
|
||||
//slot_BlockAutorizationIndicate(true, "SERVER");
|
||||
|
||||
updateStateOnlyServer();
|
||||
//updateStateOnlyServer();
|
||||
|
||||
emit signal_Tray_ShowMessage(tr("Server is stoped!"));
|
||||
|
||||
@@ -298,20 +298,6 @@ void ServerLMSWidget::on_btnSettings_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void ServerLMSWidget::slot_trySetServerState(PacketType packetType)
|
||||
{
|
||||
if (packetType == PacketType::BUSY)
|
||||
{
|
||||
server->blockAutorization();
|
||||
updateStateOnlyServer();
|
||||
}
|
||||
else if (packetType == PacketType::FREE)
|
||||
{
|
||||
server->unBlockAutorization();
|
||||
updateStateOnlyServer();
|
||||
}
|
||||
}
|
||||
|
||||
void ServerLMSWidget::setLanguageInterfase()
|
||||
{
|
||||
ServerDBSettings settings;
|
||||
@@ -366,7 +352,7 @@ void ServerLMSWidget::startInitialization_step0()
|
||||
|
||||
providerDBLMS = new ProviderDBLMS(this);
|
||||
connect(providerDBLMS, &ProviderDBLMS::signal_ErrorPostgreSQL, this, &ServerLMSWidget::slot_ErrorPostgreSQL);
|
||||
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization);
|
||||
//connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorizationIndicate);
|
||||
|
||||
mutex = new QMutex;
|
||||
|
||||
@@ -390,9 +376,13 @@ void ServerLMSWidget::startInitialization_step0()
|
||||
|
||||
commonClientHandler = new CommonClientHandler;
|
||||
connect(this, &ServerLMSWidget::signal_DocsChanged, commonClientHandler, &CommonClientHandler::slot_DocsChanged);
|
||||
connect(commonClientHandler, &CommonClientHandler::sigSetServerState, this, &ServerLMSWidget::slot_trySetServerState);
|
||||
//connect(commonClientHandler, &CommonClientHandler::sigSetServerState, this, &ServerLMSWidget::slot_trySetServerState);
|
||||
|
||||
server = new MultiThreadServer(this, updateController, processingSystem, dataParser, 6000);
|
||||
connect(server, &MultiThreadServer::signal_BlockAutorizationIndicate, this, &ServerLMSWidget::slot_BlockAutorizationIndicate);
|
||||
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, server, &MultiThreadServer::slot_BlockAutorization, Qt::DirectConnection);
|
||||
connect(updateController, &UpdateController::signal_BlockAutorization, server, &MultiThreadServer::slot_BlockAutorization, Qt::DirectConnection);
|
||||
connect(server, &MultiThreadServer::signal_sendPacketToAllClients, commonClientHandler, &CommonClientHandler::slot_sendPacketToAllClients);
|
||||
|
||||
loggerThread->start();
|
||||
updateThread->start();
|
||||
|
||||
@@ -91,7 +91,7 @@ signals:
|
||||
public slots:
|
||||
void slot_LanguageChanged(QString language);
|
||||
void slot_UpdateListClients();
|
||||
void slot_BlockAutorization(bool block);
|
||||
void slot_BlockAutorizationIndicate(bool block, QString whoFullName, QString type);
|
||||
void slot_AddMessageToLog(QString message);
|
||||
|
||||
void slot_ErrorPostgreSQL(QString text);
|
||||
@@ -102,8 +102,6 @@ public slots:
|
||||
|
||||
void slot_setVersion(QString versionStr);
|
||||
|
||||
void slot_trySetServerState(PacketType packetType);
|
||||
|
||||
public:
|
||||
QString getLanguage()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user