diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index 102b856..2be5125 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -12,6 +12,11 @@ kanban-plugin: board ## bugs +- [ ] QT сервер замерзает после выхода пользователя во время скачивания +- [ ] QT клиент, если обновление в режиме инструктора доступно, кнопку запуск отключать +- [ ] QT сервер При изменении версии правильный списке с файлами прилетает со второго раза +- [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором +- [ ] QT клиент: device not open после прерывания загрузки ## feature client Unity @@ -30,9 +35,8 @@ kanban-plugin: board ## feature server -- [ ] Прибраться в Server -- [ ] рефакторинг - [ ] добавить генерацию пустых файлов, если shared не найден +- [ ] добавить подключение без DB ## NOW @@ -42,6 +46,9 @@ kanban-plugin: board ## Complete +- [ ] рефакторинг +- [ ] Прибраться в Server +- [ ] не работает восстановление файлов - [ ] запрет на удаление base - [ ] None hash - [ ] сверстать окно создания новой версии diff --git a/ServerLMS/Systems/commonclienthandler.cpp b/ServerLMS/Systems/commonclienthandler.cpp index 6012e3e..e7e769d 100644 --- a/ServerLMS/Systems/commonclienthandler.cpp +++ b/ServerLMS/Systems/commonclienthandler.cpp @@ -11,6 +11,8 @@ void CommonClientHandler::initialize(QMap *clientsMap, Pro this->processingSystem = processingSystem; this->dataParser = dataParser; this->logger = logger; + + connect(this,&CommonClientHandler::sigSendToLogger,logger,&Logger::addTextToLogger,Qt::AutoConnection); } void CommonClientHandler::sendNewVersionListToAllClient() @@ -85,7 +87,8 @@ void CommonClientHandler::slot_msgToClientFromGUI(QString login, QString text) QString str = "Msg To Client [" + peerAddress + ":" + peerPort + "] : " + textMsg; - logger->addTextToLogger(str); + emit sigSendToLogger(str); + break; } } @@ -111,7 +114,7 @@ void CommonClientHandler::slot_msgToGUIfromClient(QString login, QString text) QString str = "Msg From Client [" + peerAddress + ":" + peerPort + "] : " + textMsg; - logger->addTextToLogger(str); + emit sigSendToLogger(str); break; } } @@ -134,7 +137,7 @@ void CommonClientHandler::slot_sendTaskToClient(QString fullNameClient,QString t QString peerPort = QString::number(handler->getSocket()->peerPort()); QString str = "Task To Client [" + peerAddress + ":" + peerPort + "] : " + textTask; - logger->addTextToLogger(str); + emit sigSendToLogger(str); } } } diff --git a/ServerLMS/Systems/commonclienthandler.h b/ServerLMS/Systems/commonclienthandler.h index a6e471b..1abf5b8 100644 --- a/ServerLMS/Systems/commonclienthandler.h +++ b/ServerLMS/Systems/commonclienthandler.h @@ -27,7 +27,7 @@ public: void slot_msgToGUIfromClient(QString login, QString text); void slot_sendTaskToClient(QString fullNameClient, QString textTask); signals: - + void sigSendToLogger(QString text); private: QMap *clientsMap; ProcessingSystem *processingSystem; diff --git a/ServerLMS/Systems/sendsystem.cpp b/ServerLMS/Systems/sendsystem.cpp index 29b2324..65caacd 100644 --- a/ServerLMS/Systems/sendsystem.cpp +++ b/ServerLMS/Systems/sendsystem.cpp @@ -35,14 +35,22 @@ void SendSystem::sendMessageBlock(QString message) void SendSystem::sendFileBlock(QString path) { - qDebug() << "sendFileBlock thread: " << QThread::currentThreadId(); + QFile file(path); + QFileInfo fileInfo(file); + + if(isSendStopped) + { //Поведение на случай отключения клиента + + file.close(); + return; + } + QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); - QFile file(path); - QFileInfo fileInfo(file); + fileSize = fileInfo.size(); if(fileSize == 0){ @@ -55,20 +63,19 @@ void SendSystem::sendFileBlock(QString path) stream << path << fileSize; - if(isSendStopped) { //Поведение на случай отключения клиента - - file.close(); - return; - } - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); - if(file.open(QFile::ReadOnly)){ - while(!file.atEnd()){ + if(file.open(QFile::ReadOnly)) + { + while(!file.atEnd()) + { QByteArray data = file.read(1025*250); stream << data; - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); + + if(socket->state() == QAbstractSocket::UnconnectedState) break; countSend++; } @@ -77,7 +84,7 @@ void SendSystem::sendFileBlock(QString path) file.close(); countSend = 0; - socket->waitForBytesWritten(); + socket->waitForBytesWritten(10); socket->waitForReadyRead(100); } @@ -237,11 +244,9 @@ void SendSystem::updateFiles(QList fileSendList, QList delet socket->waitForReadyRead(100); } - if(getIsSendStopped()) return; + if(isSendStopped) return; } - - emit sigLoadHash(); sendPacketType(PacketType::TYPE_FINISH); diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 088337f..f83fd53 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -357,57 +357,6 @@ QList* UpdateController::calculateHash(QString path) } } serverDataList.append(*files); - -// QDirIterator iterator(path,QDirIterator::Subdirectories); -// QDir dir(path); -// dir.setFilter(QDir::NoDotAndDotDot); - -// while (iterator.hasNext()) -// { -// iterator.next(); -// QFileInfo fileInfo = iterator.fileInfo(); -// FileData currentFile; -// QFile file(fileInfo.absoluteFilePath()); - -// quint64 fileSize = file.size(); -// const quint64 bufferSize = 10240; - -// if (fileInfo.isHidden()) continue; - -// if(fileInfo.isFile() && file.open(QIODevice::ReadOnly) && !fileInfo.fileName().contains(".meta")) -// { -// char buffer[bufferSize]; -// int bytesRead; -// int readSize = qMin(fileSize,bufferSize); - -// QCryptographicHash hash(QCryptographicHash::Md5); -// while(readSize > 0 && (bytesRead = file.read(buffer,readSize)) > 0){ -// fileSize -= bytesRead; -// hash.addData(buffer,bytesRead); -// readSize = qMin(fileSize,bufferSize); -// } - -// hashString = QString(hash.result().toHex()); -// currentFile.hash = hashString; -// currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); - -// files->push_back(currentFile); -// file.close(); - -// } -// else if(fileInfo.isDir() && fileInfo.fileName() != ".." && !fileInfo.isRoot()) -// { -// currentFile.hash = "FOLDER"; -// currentFile.path = Tools::createLocalPath(fileInfo.path()); - -// if(!files->contains(currentFile)){ -// files->push_back(currentFile); -// } -// } -// } - -// std::sort(files->begin(),files->end()); -// return files; } diff --git a/ServerLMS/clienthandler.cpp b/ServerLMS/clienthandler.cpp index 2ab918e..30c8448 100644 --- a/ServerLMS/clienthandler.cpp +++ b/ServerLMS/clienthandler.cpp @@ -54,6 +54,7 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget, connect(this,&ClientHandler::sigSocketClose,sendSystem,&SendSystem::socketClose,Qt::AutoConnection); connect(this,&ClientHandler::sigSocketFlush,sendSystem,&SendSystem::socketFlush,Qt::AutoConnection); connect(this,&ClientHandler::sigSendPacketType,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection); + connect(this,&ClientHandler::sigSendStop,sendSystem,&SendSystem::sendStop,Qt::DirectConnection); connect(socket,&QTcpSocket::readyRead,recognizeSystem,&RecognizeSystem::recognize,Qt::AutoConnection); connect(socket, &QTcpSocket::disconnected, this, &ClientHandler::sendDisable,Qt::AutoConnection); @@ -129,8 +130,10 @@ void ClientHandler::sendNeedUpdate(bool flag, quint64 size, quint64 fileCount,qu void ClientHandler::sendDisable() { - thread->exit(); - thread->wait(); +// thread->exit(); +// thread->wait(); + thread->quit(); + emit sigSendStop(); emit sigClientDisconnected(client->getAddress(),client->getPort()); } diff --git a/ServerLMS/clienthandler.h b/ServerLMS/clienthandler.h index 7e035b8..7f840db 100644 --- a/ServerLMS/clienthandler.h +++ b/ServerLMS/clienthandler.h @@ -67,6 +67,7 @@ signals: bool sigSocketFlush(); void sigSendVersion(); void sigSendPacketType(PacketType packetType); + void sigSendStop(); public : QThread *thread; diff --git a/ServerLMS/multithreadserver.cpp b/ServerLMS/multithreadserver.cpp index 1ac463d..50a0217 100644 --- a/ServerLMS/multithreadserver.cpp +++ b/ServerLMS/multithreadserver.cpp @@ -8,7 +8,7 @@ MultiThreadServer::MultiThreadServer(ServerLMSWidget *widget,UpdateController *u dataParser(dataParser), logger(logger) { - + connect(this,&MultiThreadServer::sigSendToLogger,logger,&Logger::addTextToLogger); } void MultiThreadServer::incomingConnection(qintptr socketDesriptor) @@ -16,14 +16,14 @@ void MultiThreadServer::incomingConnection(qintptr socketDesriptor) ClientHandler* newClient = new ClientHandler; connect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize,Qt::AutoConnection); - connect(newClient,&ClientHandler::sigClientDisconnected,this,&MultiThreadServer::slotDisconnectClient,Qt::QueuedConnection); + connect(newClient,&ClientHandler::sigClientDisconnected,this,&MultiThreadServer::slotDisconnectClient,Qt::AutoConnection); emit sigInitClient(socketDesriptor,serverLmsWidget,updateController,dataParser,logger); disconnect(this,&MultiThreadServer::sigInitClient,newClient,&ClientHandler::initialize); serverLmsWidget->addClient(socketDesriptor,newClient); - logger->addTextToLogger("To Client: " + QString(SERVER_HELLO)); + emit sigSendToLogger("To Client: " + QString(SERVER_HELLO)); } void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPort) @@ -53,8 +53,7 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo } emit signalStopSendFile(); - - logger->addTextToLogger("SERVER: Client " + login + " disconnected"); + emit sigSendToLogger("SERVER: Client " + login + " disconnected"); serverLmsWidget->slotUpdateListClients(); serverLmsWidget->autorizationHandler(login); diff --git a/ServerLMS/multithreadserver.h b/ServerLMS/multithreadserver.h index 13a4c50..eb12f80 100644 --- a/ServerLMS/multithreadserver.h +++ b/ServerLMS/multithreadserver.h @@ -18,6 +18,7 @@ signals: void sigInitClient(int descriptor, ServerLMSWidget *serverWidget, UpdateController *updateController, DataParser *dataParser,Logger *logger); void signalStopSendFile(); + void sigSendToLogger(QString text); public slots: void slotDisconnectClient(QString peerAddress, QString peerPort); diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index f52eb00..b90a0c3 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -14,7 +14,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : tcpServer(nullptr), hostPort(6000), stateServer(stoped), - stateBlockAutorization(blocked), + stateBlockAutorization(unblocked), updateThread(nullptr), loggerThread(nullptr), dataParser(nullptr), @@ -44,11 +44,13 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : loggerThread = new QThread; providerDBLMS = new ProviderDBLMS(this); - connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); providerDBLMS->ConnectionToDB(); logger = new Logger(ui->listWidgetLogger); - connect(logger,&Logger::sigSendTextToLogger,this,&ServerLMSWidget::slotAddToLog,Qt::QueuedConnection); + + connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization); + connect(logger,&Logger::sigSendTextToLogger,this,&ServerLMSWidget::slotAddToLog,Qt::AutoConnection); + logger->moveToThread(loggerThread); assetsManager = new AssetsManager; @@ -194,7 +196,7 @@ void ServerLMSWidget::slotUpdateListClients() } int countClients = clientsMap.count(); - logger->addTextToLogger("SERVER: countClients = " + QString::number(countClients)); + emit sigLog("SERVER: countClients = " + QString::number(countClients)); } void ServerLMSWidget::slot_BlockAutorization(bool block)