mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
feat: add client information
This commit is contained in:
@@ -14,11 +14,12 @@ RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
countSend = 0;
|
||||
}
|
||||
|
||||
void RecognizeSystem::initialize(DataParser *dataParser, VersionContainer *versionContainer,PostProcessorSystem *postProcessorSystem)
|
||||
void RecognizeSystem::initialize(DataParser *dataParser, VersionContainer *versionContainer,PostProcessorSystem *postProcessorSystem,Client *client)
|
||||
{
|
||||
this->versionContainer = versionContainer;
|
||||
this->postProcessorSystem = postProcessorSystem;
|
||||
this->dataParser = dataParser;
|
||||
this->client = client;
|
||||
}
|
||||
|
||||
void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
@@ -264,7 +265,10 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
|
||||
if (packetType == PacketType::TYPE_XMLANSWER_DOCS_CHANGED) //на случай общего обновления
|
||||
{
|
||||
emit sigSendPacketType(PacketType::GET_DOCS);
|
||||
if (client->getIsLoggedIn())
|
||||
{
|
||||
emit sigSendPacketType(PacketType::GET_DOCS);
|
||||
}
|
||||
}
|
||||
|
||||
if (packetType == PacketType::UPDATE_FILE_COMPLETE)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QThread>
|
||||
#include <Core\tools.h>
|
||||
#include <Core\versioncontainer.h>
|
||||
#include <Data/Client.h>
|
||||
#include <Data\streamingversiondata.h>
|
||||
#include <Core\hashcomparer.h>
|
||||
|
||||
@@ -20,7 +21,7 @@ class RecognizeSystem : public QObject
|
||||
public:
|
||||
explicit RecognizeSystem(QObject *parent = 0);
|
||||
~RecognizeSystem(){};
|
||||
void initialize(DataParser *dataParser, VersionContainer* versionContainer,PostProcessorSystem *postProcessorSystem);
|
||||
void initialize(DataParser *dataParser, VersionContainer* versionContainer,PostProcessorSystem *postProcessorSystem,Client *client);
|
||||
void recognize(QTcpSocket *socket);
|
||||
signals:
|
||||
void sigUpdateBytesAvailable();
|
||||
@@ -42,6 +43,7 @@ private:
|
||||
PacketType packetType;
|
||||
QString filePath;
|
||||
QByteArray tmpBlock;
|
||||
Client *client;
|
||||
|
||||
qint64 sizeReceiveData;
|
||||
qint64 fileSize;
|
||||
|
||||
105
Data/Client.h
Normal file
105
Data/Client.h
Normal file
@@ -0,0 +1,105 @@
|
||||
#ifndef CLIENT_H
|
||||
#define CLIENT_H
|
||||
|
||||
#include <QString>
|
||||
#include <QTcpSocket>
|
||||
|
||||
class Client
|
||||
{
|
||||
|
||||
public:
|
||||
Client(QObject *parent = nullptr):
|
||||
login(""),
|
||||
ready(false)
|
||||
{ };
|
||||
~Client(){};
|
||||
|
||||
public:
|
||||
QString getFullName()
|
||||
{
|
||||
return fullName;
|
||||
};
|
||||
|
||||
void setLogin(QString login)
|
||||
{
|
||||
this->login = login;
|
||||
isLoggedIn = true;
|
||||
fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login;
|
||||
}
|
||||
QString getLogin()
|
||||
{
|
||||
return login;
|
||||
}
|
||||
|
||||
QString getAddress()
|
||||
{
|
||||
return address;
|
||||
}
|
||||
QString getPort()
|
||||
{
|
||||
return port;
|
||||
}
|
||||
|
||||
bool getReady()
|
||||
{
|
||||
return ready;
|
||||
}
|
||||
|
||||
void setReady(bool ready)
|
||||
{
|
||||
this->ready = ready;
|
||||
}
|
||||
|
||||
bool operator == (Client* right)
|
||||
{
|
||||
return this->address == right->address;
|
||||
}
|
||||
|
||||
bool getIsLoggedIn()
|
||||
{
|
||||
return isLoggedIn;
|
||||
}
|
||||
|
||||
void setIsLoggedIn(bool value)
|
||||
{
|
||||
isLoggedIn = value;
|
||||
}
|
||||
|
||||
QString getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
void setId(QString value)
|
||||
{
|
||||
id = value;
|
||||
}
|
||||
|
||||
QByteArray getClientHash()
|
||||
{
|
||||
return clientHash;
|
||||
}
|
||||
void setClientHash(const QByteArray &value)
|
||||
{
|
||||
clientHash = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QString name;
|
||||
QString address;
|
||||
QString port;
|
||||
QString fullName;
|
||||
QString id;
|
||||
|
||||
QString login;
|
||||
bool ready;
|
||||
bool isLoggedIn;
|
||||
QByteArray clientHash;
|
||||
|
||||
};
|
||||
|
||||
#endif // CLIENT_H
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ HEADERS += \
|
||||
Core\tcpclient.h\
|
||||
Core\tools.h\
|
||||
Core\hashcomparer.h \
|
||||
Data/Client.h \
|
||||
Data/monitorInfo.h \
|
||||
Data/streamingversiondata.h \
|
||||
Data\FileData.h\
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AuthData Login="I1" Password="b59c67bf196a4758191e42f76670ceba" InstructorName="Instructor1" ClientName="Instructor1" AccessType="instructor"/>
|
||||
<AuthData Login="I1" Password="b59c67bf196a4758191e42f76670ceba" InstructorName="I1" ClientName="I1" AccessType="instructor"/>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ServerSettingsContainer>
|
||||
<ServerSettings Language="RUS" AutoStart="0" LocalPortMath="18004" UseMathModel="1" DestPortMath="18003" Address="192.168.100.83" Port="6000"/>
|
||||
<VersionData Created="Пн ноя 17 15:03:26 2025" Version="base" isChangable="0"/>
|
||||
<ServerSettings Address="192.168.100.83" Port="6000" Language="RUS" AutoStart="0" DestPortMath="18003" LocalPortMath="18004" UseMathModel="1"/>
|
||||
<VersionData Version="base2" isChangable="0"/>
|
||||
</ServerSettingsContainer>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ClientNotify Code="CHECKVERSIONLIST"/>
|
||||
<ClientNotify Code="DISABLE"/>
|
||||
|
||||
@@ -4,7 +4,7 @@ CoreManager::CoreManager(QObject *parent) :
|
||||
QObject(parent),
|
||||
isRecovery(false)
|
||||
{
|
||||
client = new TCPClient;
|
||||
tcpClient = new TCPClient;
|
||||
dataParser = new DataParser;
|
||||
dataParserOutput = new DataParserOutput;
|
||||
updateController = new UpdateController;
|
||||
@@ -16,6 +16,7 @@ CoreManager::CoreManager(QObject *parent) :
|
||||
versionContainer = new VersionContainer;
|
||||
resourceManager = new ResourceManager;
|
||||
postProcessorSystem = new PostProcessorSystem;
|
||||
client = new Client;
|
||||
}
|
||||
|
||||
void CoreManager::initialize(WidgetManager *widgetManager,QThread *workerThread)
|
||||
@@ -23,7 +24,7 @@ void CoreManager::initialize(WidgetManager *widgetManager,QThread *workerThread)
|
||||
this->workerThread = workerThread;
|
||||
this->widgetManager = widgetManager;
|
||||
|
||||
client->moveToThread(workerThread);
|
||||
tcpClient->moveToThread(workerThread);
|
||||
dataParser->moveToThread(workerThread);
|
||||
dataParserOutput->moveToThread(workerThread);
|
||||
sendSystem->moveToThread(workerThread);
|
||||
@@ -31,11 +32,8 @@ void CoreManager::initialize(WidgetManager *widgetManager,QThread *workerThread)
|
||||
recognizeSystem->moveToThread(workerThread);
|
||||
postProcessorSystem->moveToThread(workerThread);
|
||||
hashComparer->moveToThread(workerThread);
|
||||
// versionContainer->moveToThread(workerThread); //проверить работоспособность
|
||||
// resourceManager->moveToThread(workerThread); //проверить работоспособность
|
||||
|
||||
workerThread->start();
|
||||
//workerThread->setPriority(QThread::HighestPriority);
|
||||
|
||||
binding();
|
||||
initializeSystems();
|
||||
@@ -64,15 +62,15 @@ void CoreManager::binding()
|
||||
{
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnimationActivated,widgetManager,&WidgetManager::slotActivateLoadAnimation,Qt::AutoConnection);
|
||||
|
||||
connect(this,&CoreManager::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigInitializeClient,tcpClient,&TCPClient::initialize,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSetConnect,tcpClient,&TCPClient::setConnect,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendPacketType,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendCheckUpdate,sendSystem,&SendSystem::sendCheckHash,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendXMLAnswer,sendSystem,&SendSystem::xmlAnswer,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
|
||||
|
||||
connect(this,&CoreManager::sigSendUpdateToServer,updateController,&UpdateController::checkCanUpdate,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigGetConnected,client,&TCPClient::getIsConnected);
|
||||
connect(this,&CoreManager::sigGetConnected,tcpClient,&TCPClient::getIsConnected);
|
||||
connect(this,&CoreManager::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
|
||||
|
||||
connect(this,&CoreManager::sigSetLoadSettings,widgetManager,&WidgetManager::slotSetLoadSettings,Qt::AutoConnection);
|
||||
@@ -101,8 +99,8 @@ void CoreManager::binding()
|
||||
connect(updateController,&UpdateController::sigUpdateComplete,widgetManager,&WidgetManager::setCompeteState,Qt::AutoConnection);
|
||||
connect(updateController->getHashCalculator(),&FastHashCalculator::sigSendHashInfo,widgetManager->getMainWindow(),&MainWindow::updateInitInformation,Qt::AutoConnection);
|
||||
|
||||
connect(client,&TCPClient::sigConnectionState,widgetManager,&WidgetManager::setConnectionState,Qt::AutoConnection);
|
||||
connect(client,&TCPClient::sigServerDisconnect,widgetManager,&WidgetManager::setServerDisconnectState,Qt::AutoConnection);
|
||||
connect(tcpClient,&TCPClient::sigConnectionState,widgetManager,&WidgetManager::setConnectionState,Qt::AutoConnection);
|
||||
connect(tcpClient,&TCPClient::sigServerDisconnect,widgetManager,&WidgetManager::setServerDisconnectState,Qt::AutoConnection);
|
||||
|
||||
connect(sendSystem,&SendSystem::sigSend,this,&CoreManager::calcUpdateProgress,Qt::AutoConnection);
|
||||
|
||||
@@ -116,7 +114,7 @@ void CoreManager::initializeSystems()
|
||||
hashComparer->initialize(versionContainer,widgetManager->getUpdateWidget());
|
||||
postProcessorSystem->initialize(dataParserOutput,hashComparer,versionContainer,updateController);
|
||||
dataParser->initialize(postProcessorSystem);
|
||||
recognizeSystem->initialize(dataParser,versionContainer,postProcessorSystem);
|
||||
recognizeSystem->initialize(dataParser,versionContainer,postProcessorSystem,client);
|
||||
resourceManager->painting();
|
||||
|
||||
emit sigCalculateHash();
|
||||
@@ -168,6 +166,7 @@ void CoreManager::callUpdateList()
|
||||
void CoreManager::lostConnection()
|
||||
{
|
||||
widgetManager->setLostConnectionState();
|
||||
client->setIsLoggedIn(false);
|
||||
}
|
||||
|
||||
void CoreManager::serverBlocked()
|
||||
@@ -201,16 +200,19 @@ void CoreManager::checkLoginResult(ServerAuthorization *auth)
|
||||
setLocalVersion();
|
||||
widgetManager->setLoginSuccess();
|
||||
widgetManager->getMainWindow()->setClientVersionName(versionContainer->getLocalVersion());
|
||||
client->setLogin(auth->ClientName);
|
||||
client->setIsLoggedIn(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
widgetManager->setLoginFailed();
|
||||
client->setIsLoggedIn(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CoreManager::tryLogin()
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
if (!tcpClient->getIsConnected())
|
||||
{
|
||||
widgetManager->getMainWindow()->showConnectionEmpty();
|
||||
return;
|
||||
@@ -362,10 +364,10 @@ void CoreManager::saveServerSettingsWithConnect()
|
||||
settings->LocalVersionName = dataParser->getClientSettings()->LocalVersionName;
|
||||
dataParserOutput->createServerSettings(settings);
|
||||
|
||||
if(client->getIsConnected())
|
||||
if(tcpClient->getIsConnected())
|
||||
{
|
||||
emit sigSendXMLAnswer(cmd_Disable);
|
||||
client->setDisconnect();
|
||||
tcpClient->setDisconnect();
|
||||
entryWidget->showLoginWidget(true);
|
||||
widgetManager->getMainWindow()->showOfflineButton(true);
|
||||
widgetManager->activateLoadingAnimation(false);
|
||||
@@ -398,7 +400,7 @@ void CoreManager::setLanguage(const QString& language)
|
||||
void CoreManager::exit()
|
||||
{
|
||||
emit sigSendXMLAnswer(cmd_Disable);
|
||||
client->disconnect();
|
||||
tcpClient->disconnect();
|
||||
|
||||
workerThread->quit();
|
||||
workerThread->wait();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Core/hashcomparer.h>
|
||||
#include <Core/versioncontainer.h>
|
||||
#include <widgetmanager.h>
|
||||
#include <Data/Client.h>
|
||||
|
||||
#include <UI/resourcemanager.h>
|
||||
|
||||
@@ -65,7 +66,7 @@ signals:
|
||||
|
||||
private:
|
||||
QTranslator translator;
|
||||
TCPClient *client;
|
||||
TCPClient *tcpClient;
|
||||
DataParser *dataParser;
|
||||
DataParserOutput *dataParserOutput;
|
||||
UpdateController *updateController;
|
||||
@@ -77,6 +78,7 @@ private:
|
||||
VersionContainer *versionContainer;
|
||||
ResourceManager *resourceManager;
|
||||
PostProcessorSystem *postProcessorSystem;
|
||||
Client *client;
|
||||
|
||||
WidgetManager *widgetManager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user