ref: refactoring treads, check local update instructor

This commit is contained in:
semenov
2024-12-17 17:22:33 +03:00
parent 2dfd76ec18
commit 066a90691c
53 changed files with 2292 additions and 1558 deletions

View File

@@ -260,7 +260,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
continue;
}
xmlParser(array);
dataParser->xmlParser(array);
packetType = PacketType::TYPE_NONE;
}
@@ -269,102 +269,6 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
}
}
void RecognizeSystem::xmlParser(QByteArray array)
{
QXmlStreamReader xmlReader(array);
xmlReader.readNext();
while(!xmlReader.atEnd())
{
if(!xmlReader.isStartElement()) {
xmlReader.readNext();
continue;
}
if(xmlReader.name() == "ServerNotify")
{
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
{
QString name = attr.name().toString();
QString value = attr.value().toString();
if(name == "Code")
{
if (value == "END")
{
emit sigSocketDisabled();
}
if(value == "BLOCKED")
{
emit sigServerBlocked();
}
if(value == "HASHSENDCOMPLETE")
{
emit sigStartCompare();
}
}
}
}
if(xmlReader.name() == "ServerAuthorization"){
ServerAuthorization *serverAuth = new ServerAuthorization;
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes())
{
QString name = attr.name().toString();
QString value = attr.value().toString();
if (name == "Result"){
serverAuth->Result = value == "true" ? true : false;
}
if (name == "InstructorName"){
serverAuth->InstructorName = value;
}
if (name == "ClientName"){
serverAuth->ClientName = value;
}
if (name == "AccessType"){
serverAuth->AccessType = value;
checkAccessType(value);
}
}
emit sigSaveLoginData(serverAuth);
}
if(xmlReader.name() == "VersionData")
{
StreamingVersionData *serverVersion = new StreamingVersionData;
foreach(const QXmlStreamAttribute &attr,xmlReader.attributes())
{
QString name = attr.name().toString();
QString value = attr.value().toString();
if(name == "Version")
{
serverVersion->setName(value);
}
if(name == "Created")
{
serverVersion->setCreateData(QDateTime::fromString(value));
}
}
updateController->setServerVersion(serverVersion);
}
xmlReader.readNext();
}
}
void RecognizeSystem::checkAccessType(QString type)
{
if(type == "instructor")
@@ -372,3 +276,8 @@ void RecognizeSystem::checkAccessType(QString type)
mainWindow->callUpdateList();
}
}
void RecognizeSystem::setServerVersion(StreamingVersionData *serverVersion)
{
updateController->setServerVersion(serverVersion);
}