mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
TrayServerLMS рабочая версия
This commit is contained in:
@@ -16,7 +16,7 @@ bool InterfaceDataBaseLMS::connectionToDB()
|
|||||||
{
|
{
|
||||||
if(!createConnection())
|
if(!createConnection())
|
||||||
{
|
{
|
||||||
QMessageBox::critical(ownerWidget, dbSettings.dbName, tr("Connection error") /*+ db->lastError().text()*/);
|
//QMessageBox::critical(ownerWidget, dbSettings.dbName, tr("Connection error") /*+ db->lastError().text()*/);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ DialogSettings::DialogSettings(ConnectorToServer* connectorToServer, bool instru
|
|||||||
ui->checkAutoStart->setVisible(false);
|
ui->checkAutoStart->setVisible(false);
|
||||||
|
|
||||||
ui->btnSave->setEnabled(false);
|
ui->btnSave->setEnabled(false);
|
||||||
|
flSettingsServerChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogSettings::~DialogSettings()
|
DialogSettings::~DialogSettings()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<string>Instructor authorization</string>
|
<string>Instructor authorization</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset resource="../resources.qrc">
|
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||||
<normaloff>:/resources/icons/lms.png</normaloff>:/resources/icons/lms.png</iconset>
|
<normaloff>:/resources/icons/lms.png</normaloff>:/resources/icons/lms.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../resources.qrc">
|
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||||
<normaloff>:/resources/icons/eye.png</normaloff>:/resources/icons/eye.png</iconset>
|
<normaloff>:/resources/icons/eye.png</normaloff>:/resources/icons/eye.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../resources.qrc"/>
|
<include location="../InstructorsAndTrainees.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ DialogSettingsTray::DialogSettingsTray(QWidget *parent) :
|
|||||||
//Задаём два пункта с текстом локалей в комбобоксе
|
//Задаём два пункта с текстом локалей в комбобоксе
|
||||||
ui->cmbLanguage->addItems(QStringList() << "English" << "Русский");
|
ui->cmbLanguage->addItems(QStringList() << "English" << "Русский");
|
||||||
|
|
||||||
|
//Скрываем пароль
|
||||||
|
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||||
|
|
||||||
if(loadSettings(settings))
|
if(loadSettings(settings))
|
||||||
{
|
{
|
||||||
if(settings->Language == "ENG")
|
if(settings->Language == "ENG")
|
||||||
@@ -49,6 +52,7 @@ DialogSettingsTray::DialogSettingsTray(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui->btnSave->setEnabled(false);
|
ui->btnSave->setEnabled(false);
|
||||||
|
flSettingsServerChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogSettingsTray::~DialogSettingsTray()
|
DialogSettingsTray::~DialogSettingsTray()
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
ServerDBSettings getSettings();
|
ServerDBSettings getSettings();
|
||||||
|
|
||||||
bool settingsServerIsChanged(){ return flSettingsServerChanged;}
|
bool settingsDBisChanged(){ return flSettingsServerChanged;}
|
||||||
|
|
||||||
static bool loadSettings(ServerDBSettings *settings);
|
static bool loadSettings(ServerDBSettings *settings);
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ bool MultiThreadServer::stopServer()
|
|||||||
//Закрываем сервер
|
//Закрываем сервер
|
||||||
close();
|
close();
|
||||||
stateServer = stoped;
|
stateServer = stoped;
|
||||||
|
Logger::instance().log("SERVER: stop OK");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -73,7 +74,7 @@ QMap<int, ClientHandler *> *MultiThreadServer::getClientsMap() const
|
|||||||
|
|
||||||
void MultiThreadServer::updateClientList()
|
void MultiThreadServer::updateClientList()
|
||||||
{
|
{
|
||||||
serverLmsWidget->slotUpdateListClients();
|
serverLmsWidget->slot_UpdateListClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiThreadServer::disableClients()
|
void MultiThreadServer::disableClients()
|
||||||
@@ -130,19 +131,19 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
|
|||||||
emit signalStopSendFile();
|
emit signalStopSendFile();
|
||||||
Logger::instance().log("SERVER: Client " + login + " disconnected");
|
Logger::instance().log("SERVER: Client " + login + " disconnected");
|
||||||
|
|
||||||
serverLmsWidget->slotUpdateListClients();
|
serverLmsWidget->slot_UpdateListClients();
|
||||||
serverLmsWidget->getProcessingSystem()->processingClientDeAutorization(login);
|
serverLmsWidget->getProcessingSystem()->processingClientDeAutorization(login);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiThreadServer::removeClient(int idSocket)
|
void MultiThreadServer::removeClient(int idSocket)
|
||||||
{
|
{
|
||||||
clientsMap->remove(idSocket);
|
clientsMap->remove(idSocket);
|
||||||
serverLmsWidget->slotUpdateListClients();
|
serverLmsWidget->slot_UpdateListClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiThreadServer::addClient(qintptr descriptor, ClientHandler *client)
|
void MultiThreadServer::addClient(qintptr descriptor, ClientHandler *client)
|
||||||
{
|
{
|
||||||
(*clientsMap)[descriptor] = client;
|
(*clientsMap)[descriptor] = client;
|
||||||
serverLmsWidget->slotUpdateListClients();
|
serverLmsWidget->slot_UpdateListClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ ProviderDBLMS::~ProviderDBLMS()
|
|||||||
DisConnectionFromDB();
|
DisConnectionFromDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProviderDBLMS::ConnectionToDB()
|
bool ProviderDBLMS::ConnectionToDB()
|
||||||
{
|
{
|
||||||
mtxAccess.lock();
|
mtxAccess.lock();
|
||||||
if(! dbLMS->DBisConnected())
|
if(! dbLMS->DBisConnected())
|
||||||
@@ -24,9 +24,18 @@ void ProviderDBLMS::ConnectionToDB()
|
|||||||
if(dbLMS->connectionToDB())
|
if(dbLMS->connectionToDB())
|
||||||
{
|
{
|
||||||
Q_EMIT signal_BlockAutorization(false);
|
Q_EMIT signal_BlockAutorization(false);
|
||||||
|
|
||||||
|
mtxAccess.unlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mtxAccess.unlock();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mtxAccess.unlock();
|
mtxAccess.unlock();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProviderDBLMS::DisConnectionFromDB()
|
void ProviderDBLMS::DisConnectionFromDB()
|
||||||
@@ -41,6 +50,15 @@ void ProviderDBLMS::DisConnectionFromDB()
|
|||||||
mtxAccess.unlock();
|
mtxAccess.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProviderDBLMS::DBisConnected()
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
mtxAccess.lock();
|
||||||
|
res = dbLMS->DBisConnected();
|
||||||
|
mtxAccess.unlock();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
DataBaseSettings ProviderDBLMS::getDBSettings()
|
DataBaseSettings ProviderDBLMS::getDBSettings()
|
||||||
{
|
{
|
||||||
return dbLMS->getDataBaseSettings();
|
return dbLMS->getDataBaseSettings();
|
||||||
|
|||||||
@@ -75,8 +75,9 @@ Q_SIGNALS:
|
|||||||
void signal_BlockAutorization(bool block);
|
void signal_BlockAutorization(bool block);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void ConnectionToDB();
|
bool ConnectionToDB();
|
||||||
void DisConnectionFromDB();
|
void DisConnectionFromDB();
|
||||||
|
bool DBisConnected();
|
||||||
DataBaseSettings getDBSettings();
|
DataBaseSettings getDBSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
|||||||
providerDBLMS(nullptr),
|
providerDBLMS(nullptr),
|
||||||
first (true),
|
first (true),
|
||||||
language(languageENG),
|
language(languageENG),
|
||||||
errorCode(0)
|
errorCode(0),
|
||||||
|
flStartInitialization(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@@ -41,96 +42,68 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
|||||||
|
|
||||||
setLanguageInterfase();
|
setLanguageInterfase();
|
||||||
|
|
||||||
mutex = new QMutex;
|
startInitialization();
|
||||||
|
|
||||||
ui->btnStopServer->setEnabled(false);
|
tryConnectionToDB();
|
||||||
ui->btnStartServer->setEnabled(true);
|
|
||||||
|
|
||||||
updateThread = new QThread;
|
|
||||||
loggerThread = new QThread;
|
|
||||||
|
|
||||||
providerDBLMS = new ProviderDBLMS(this);
|
|
||||||
providerDBLMS->ConnectionToDB();
|
|
||||||
providerDBLMS->deAuthorizationAll();
|
|
||||||
|
|
||||||
//Настройки БД
|
|
||||||
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
|
|
||||||
QString strDBsettings = QString("%1 (%2) %3 : %4").arg(dbSettings.dbName,
|
|
||||||
dbSettings.dbType,
|
|
||||||
dbSettings.dbHostName,
|
|
||||||
QString::number(dbSettings.dbPort));
|
|
||||||
ui->lblDBsettings->setText(strDBsettings);
|
|
||||||
|
|
||||||
chatSystem = new ChatSystem();
|
|
||||||
|
|
||||||
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization);
|
|
||||||
|
|
||||||
assetsManager = new AssetsManager;
|
|
||||||
assetsManager->moveToThread(updateThread);
|
|
||||||
|
|
||||||
updateController = new UpdateController;
|
|
||||||
updateController->moveToThread(updateThread);
|
|
||||||
|
|
||||||
processingSystem = new ProcessingSystem(providerDBLMS, updateController);
|
|
||||||
//processingSystem->moveToThread(updateThread);
|
|
||||||
|
|
||||||
dataParser = new DataParser(assetsManager,processingSystem);
|
|
||||||
|
|
||||||
commonClientHandler = new CommonClientHandler;
|
|
||||||
server = new MultiThreadServer(this,updateController,processingSystem,dataParser,6000);
|
|
||||||
|
|
||||||
loggerThread->start();
|
|
||||||
updateThread->start();
|
|
||||||
|
|
||||||
commonClientHandler->initialize(server->getClientsMap(),processingSystem,dataParser);
|
|
||||||
processingSystem->initialize(server,dataParser,commonClientHandler,updateController,chatSystem);
|
|
||||||
chatSystem->initialize(commonClientHandler,dataParser,server->getClientsMap());
|
|
||||||
|
|
||||||
Logger::instance().moveToThread(loggerThread);
|
|
||||||
Logger::instance().setLoggingType(LoggingType::WIDGET);
|
|
||||||
Logger::instance().setLogToFile(true);
|
|
||||||
|
|
||||||
connect(this,&ServerLMSWidget::sigUpdateController,updateController,&UpdateController::initialize,Qt::DirectConnection);
|
|
||||||
connect(this,&ServerLMSWidget::sigCalculateFullHash,updateController,&UpdateController::calculateFullHash,Qt::AutoConnection);
|
|
||||||
connect(updateController,&UpdateController::sigErrorRequired,this,&ServerLMSWidget::setError);
|
|
||||||
connect(&Logger::instance(),&Logger::sigLogToWidget,this, &ServerLMSWidget::addToLog,Qt::QueuedConnection);
|
|
||||||
|
|
||||||
emit sigUpdateController(commonClientHandler,dataParser,assetsManager);
|
|
||||||
on_btnStartServer_clicked();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerLMSWidget::~ServerLMSWidget()
|
ServerLMSWidget::~ServerLMSWidget()
|
||||||
{
|
{
|
||||||
server->stopServer();
|
if(flStartInitialization)
|
||||||
updateThread->exit();
|
{
|
||||||
loggerThread->exit();
|
server->stopServer();
|
||||||
|
|
||||||
|
//updateThread->exit();
|
||||||
|
updateThread->quit();
|
||||||
|
updateThread->wait();
|
||||||
|
delete updateThread;
|
||||||
|
|
||||||
|
delete server;
|
||||||
|
delete commonClientHandler;
|
||||||
|
delete dataParser;
|
||||||
|
delete processingSystem;
|
||||||
|
delete updateController;
|
||||||
|
delete assetsManager;
|
||||||
|
delete chatSystem;
|
||||||
|
|
||||||
|
delete mutex;
|
||||||
|
|
||||||
|
//loggerThread->exit();
|
||||||
|
loggerThread->quit();
|
||||||
|
loggerThread->wait();
|
||||||
|
delete loggerThread;
|
||||||
|
}
|
||||||
|
|
||||||
delete server;
|
|
||||||
delete commonClientHandler;
|
|
||||||
delete dataParser;
|
|
||||||
delete processingSystem;
|
|
||||||
delete updateController;
|
|
||||||
delete assetsManager;
|
|
||||||
delete chatSystem;
|
|
||||||
delete providerDBLMS;
|
delete providerDBLMS;
|
||||||
delete loggerThread;
|
|
||||||
delete updateThread;
|
|
||||||
delete mutex;
|
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::setError(int code)
|
void ServerLMSWidget::changeEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
errorCode = code;
|
// В случае получения события изменения языка приложения
|
||||||
|
if (event->type() == QEvent::LanguageChange)
|
||||||
|
{
|
||||||
|
ui->retranslateUi(this); // переведём окно заново
|
||||||
|
|
||||||
|
if(providerDBLMS->DBisConnected())
|
||||||
|
{
|
||||||
|
//Настройки БД
|
||||||
|
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
|
||||||
|
QString strDBsettings = QString("%1 (%2) %3 : %4").arg(dbSettings.dbName,
|
||||||
|
dbSettings.dbType,
|
||||||
|
dbSettings.dbHostName,
|
||||||
|
QString::number(dbSettings.dbPort));
|
||||||
|
ui->lblDBsettings->setText(strDBsettings);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->lblDBsettings->setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ServerLMSWidget::getLanguage()
|
void ServerLMSWidget::slot_UpdateListClients()
|
||||||
{
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerLMSWidget::slotUpdateListClients()
|
|
||||||
{
|
{
|
||||||
//Очищаем список
|
//Очищаем список
|
||||||
ui->listWidget_Clients->clear();
|
ui->listWidget_Clients->clear();
|
||||||
@@ -148,7 +121,7 @@ void ServerLMSWidget::slotUpdateListClients()
|
|||||||
Logger::instance().log("SERVER: countClients = " + QString::number(countClients));
|
Logger::instance().log("SERVER: countClients = " + QString::number(countClients));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::addToLog(QString message)
|
void ServerLMSWidget::slot_AddMessageToLog(QString message)
|
||||||
{
|
{
|
||||||
ui->loggerTextField->appendPlainText(message);
|
ui->loggerTextField->appendPlainText(message);
|
||||||
}
|
}
|
||||||
@@ -185,6 +158,7 @@ void ServerLMSWidget::on_btnStartServer_clicked()
|
|||||||
ui->btnStartServer->setEnabled(false);
|
ui->btnStartServer->setEnabled(false);
|
||||||
ui->btnStopServer->setEnabled(true);
|
ui->btnStopServer->setEnabled(true);
|
||||||
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/switchOn.png")));
|
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/switchOn.png")));
|
||||||
|
slot_BlockAutorization(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,29 +169,7 @@ void ServerLMSWidget::on_btnStopServer_clicked()
|
|||||||
ui->btnStopServer->setEnabled(false);
|
ui->btnStopServer->setEnabled(false);
|
||||||
ui->btnStartServer->setEnabled(true);
|
ui->btnStartServer->setEnabled(true);
|
||||||
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/switchOff.png")));
|
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/switchOff.png")));
|
||||||
slot_BlockAutorization(false);
|
slot_BlockAutorization(true);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QMutex *ServerLMSWidget::getMutex() const
|
|
||||||
{
|
|
||||||
return mutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerLMSWidget::changeEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
// В случае получения события изменения языка приложения
|
|
||||||
if (event->type() == QEvent::LanguageChange)
|
|
||||||
{
|
|
||||||
ui->retranslateUi(this); // переведём окно заново
|
|
||||||
|
|
||||||
//Настройки БД
|
|
||||||
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
|
|
||||||
QString strDBsettings = QString("%1 (%2) %3 : %4").arg(dbSettings.dbName,
|
|
||||||
dbSettings.dbType,
|
|
||||||
dbSettings.dbHostName,
|
|
||||||
QString::number(dbSettings.dbPort));
|
|
||||||
ui->lblDBsettings->setText(strDBsettings);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,20 +188,19 @@ void ServerLMSWidget::on_btnSettings_clicked()
|
|||||||
{
|
{
|
||||||
language = dlg.getSettings().Language;
|
language = dlg.getSettings().Language;
|
||||||
|
|
||||||
if(dlg.settingsServerIsChanged())
|
if(dlg.settingsDBisChanged())
|
||||||
{//TODO Здесь нужно переподключать БД
|
{
|
||||||
|
on_btnStopServer_clicked();
|
||||||
//SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec();
|
|
||||||
|
|
||||||
providerDBLMS->deAuthorizationAll();
|
providerDBLMS->deAuthorizationAll();
|
||||||
|
|
||||||
on_btnStopServer_clicked();
|
|
||||||
|
|
||||||
providerDBLMS->DisConnectionFromDB();
|
providerDBLMS->DisConnectionFromDB();
|
||||||
|
|
||||||
providerDBLMS->ConnectionToDB();
|
ui->lblDBsettings->setText("");
|
||||||
|
|
||||||
//on_btnStartServer_clicked();
|
QMessageBox::warning(this, tr("Warning!"), tr("Database settings have been changed.\nThe server will be restarted."));
|
||||||
|
|
||||||
|
tryConnectionToDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -308,3 +259,78 @@ QString ServerLMSWidget::loadStyleSheet()
|
|||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerLMSWidget::startInitialization()
|
||||||
|
{
|
||||||
|
providerDBLMS = new ProviderDBLMS(this);
|
||||||
|
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization);
|
||||||
|
|
||||||
|
mutex = new QMutex;
|
||||||
|
|
||||||
|
updateThread = new QThread;
|
||||||
|
loggerThread = new QThread;
|
||||||
|
|
||||||
|
chatSystem = new ChatSystem();
|
||||||
|
|
||||||
|
assetsManager = new AssetsManager;
|
||||||
|
assetsManager->moveToThread(updateThread);
|
||||||
|
|
||||||
|
updateController = new UpdateController;
|
||||||
|
updateController->moveToThread(updateThread);
|
||||||
|
|
||||||
|
processingSystem = new ProcessingSystem(providerDBLMS, updateController);
|
||||||
|
//processingSystem->moveToThread(updateThread);
|
||||||
|
|
||||||
|
dataParser = new DataParser(assetsManager,processingSystem);
|
||||||
|
|
||||||
|
commonClientHandler = new CommonClientHandler;
|
||||||
|
server = new MultiThreadServer(this,updateController,processingSystem,dataParser,6000);
|
||||||
|
|
||||||
|
loggerThread->start();
|
||||||
|
updateThread->start();
|
||||||
|
|
||||||
|
commonClientHandler->initialize(server->getClientsMap(),processingSystem,dataParser);
|
||||||
|
processingSystem->initialize(server,dataParser,commonClientHandler,updateController,chatSystem);
|
||||||
|
chatSystem->initialize(commonClientHandler,dataParser,server->getClientsMap());
|
||||||
|
|
||||||
|
Logger::instance().moveToThread(loggerThread);
|
||||||
|
Logger::instance().setLoggingType(LoggingType::WIDGET);
|
||||||
|
Logger::instance().setLogToFile(true);
|
||||||
|
|
||||||
|
connect(this,&ServerLMSWidget::sigUpdateController,updateController,&UpdateController::initialize,Qt::DirectConnection);
|
||||||
|
connect(this,&ServerLMSWidget::sigCalculateFullHash,updateController,&UpdateController::calculateFullHash,Qt::AutoConnection);
|
||||||
|
connect(updateController,&UpdateController::sigErrorRequired,this,&ServerLMSWidget::setError);
|
||||||
|
connect(&Logger::instance(),&Logger::sigLogToWidget,this, &ServerLMSWidget::slot_AddMessageToLog,Qt::QueuedConnection);
|
||||||
|
|
||||||
|
emit sigUpdateController(commonClientHandler,dataParser,assetsManager);
|
||||||
|
|
||||||
|
ui->btnStopServer->setEnabled(false);
|
||||||
|
ui->btnStartServer->setEnabled(true);
|
||||||
|
|
||||||
|
flStartInitialization = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerLMSWidget::tryConnectionToDB()
|
||||||
|
{
|
||||||
|
if(! providerDBLMS->ConnectionToDB())
|
||||||
|
{
|
||||||
|
ui->lblDBsettings->setText("");
|
||||||
|
ui->btnStopServer->setEnabled(false);
|
||||||
|
ui->btnStartServer->setEnabled(false);
|
||||||
|
QMessageBox::critical(this, tr("Error!"), tr("Database connection error"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
providerDBLMS->deAuthorizationAll();
|
||||||
|
|
||||||
|
//Настройки БД
|
||||||
|
DataBaseSettings dbSettings = providerDBLMS->getDBSettings();
|
||||||
|
QString strDBsettings = QString("%1 (%2) %3 : %4").arg(dbSettings.dbName,
|
||||||
|
dbSettings.dbType,
|
||||||
|
dbSettings.dbHostName,
|
||||||
|
QString::number(dbSettings.dbPort));
|
||||||
|
ui->lblDBsettings->setText(strDBsettings);
|
||||||
|
|
||||||
|
on_btnStartServer_clicked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,34 +53,36 @@ public:
|
|||||||
static const QString languageENG;
|
static const QString languageENG;
|
||||||
static const QString languageRUS;
|
static const QString languageRUS;
|
||||||
|
|
||||||
public:
|
|
||||||
QString getLanguage();
|
|
||||||
|
|
||||||
void setError(int code);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Метод получения событий
|
// Метод получения событий
|
||||||
// В нём будет производиться проверка события смены перевода приложения
|
// В нём будет производиться проверка события смены перевода приложения
|
||||||
void changeEvent(QEvent * event) override;
|
void changeEvent(QEvent * event) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sigRecognize();
|
|
||||||
void sigCalculateFullHash();
|
|
||||||
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
|
|
||||||
|
|
||||||
QTcpSocket* sigGetSocket();
|
|
||||||
|
|
||||||
//сигнал смены языка
|
//сигнал смены языка
|
||||||
void signal_LanguageChanged(QString language);
|
void signal_LanguageChanged(QString language);
|
||||||
|
|
||||||
|
void sigRecognize();
|
||||||
|
void sigCalculateFullHash();
|
||||||
|
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
|
||||||
|
QTcpSocket* sigGetSocket();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slot_LanguageChanged(QString language);
|
void slot_LanguageChanged(QString language);
|
||||||
void slotUpdateListClients();
|
void slot_UpdateListClients();
|
||||||
void slot_BlockAutorization(bool block);
|
void slot_BlockAutorization(bool block);
|
||||||
void addToLog(QString message);
|
void slot_AddMessageToLog(QString message);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void removeClient(int socketId);
|
QString getLanguage()
|
||||||
|
{
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setError(int code)
|
||||||
|
{
|
||||||
|
errorCode = code;
|
||||||
|
}
|
||||||
|
|
||||||
int hasError() const
|
int hasError() const
|
||||||
{
|
{
|
||||||
@@ -92,7 +94,12 @@ public:
|
|||||||
return processingSystem;
|
return processingSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutex *getMutex() const;
|
QMutex *getMutex() const
|
||||||
|
{
|
||||||
|
return mutex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeClient(int socketId);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_btnStartServer_clicked();
|
void on_btnStartServer_clicked();
|
||||||
@@ -101,11 +108,13 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setLanguageInterfase();
|
void setLanguageInterfase();
|
||||||
|
|
||||||
private:
|
|
||||||
void updateMyStyleSheet();
|
void updateMyStyleSheet();
|
||||||
QString loadStyleSheet();
|
QString loadStyleSheet();
|
||||||
|
|
||||||
|
void startInitialization();
|
||||||
|
|
||||||
|
void tryConnectionToDB();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ServerLMSWidget *ui;
|
Ui::ServerLMSWidget *ui;
|
||||||
|
|
||||||
@@ -129,6 +138,8 @@ private:
|
|||||||
QTranslator qtLanguageTranslator;
|
QTranslator qtLanguageTranslator;
|
||||||
QString language;
|
QString language;
|
||||||
int errorCode;
|
int errorCode;
|
||||||
|
|
||||||
|
bool flStartInitialization;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SERVERLMSWIDGET_H
|
#endif // SERVERLMSWIDGET_H
|
||||||
|
|||||||
Binary file not shown.
@@ -9,6 +9,59 @@
|
|||||||
<translation>ООО Константа-Дизайн</translation>
|
<translation>ООО Константа-Дизайн</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>DialogSettingsTray</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="14"/>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation>Настройки</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="22"/>
|
||||||
|
<source>Main</source>
|
||||||
|
<translation>Основные</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="32"/>
|
||||||
|
<source>Language</source>
|
||||||
|
<translation>Язык</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="57"/>
|
||||||
|
<source>Data Base</source>
|
||||||
|
<translation>База Данных</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="67"/>
|
||||||
|
<source>DB name</source>
|
||||||
|
<translation>Имя БД</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="91"/>
|
||||||
|
<source>Host name</source>
|
||||||
|
<translation>Хост</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="115"/>
|
||||||
|
<source>Port</source>
|
||||||
|
<translation>Порт</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="139"/>
|
||||||
|
<source>User name</source>
|
||||||
|
<translation>Имя пользователя</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="163"/>
|
||||||
|
<source>Password</source>
|
||||||
|
<translation>Пароль</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../dialogsettingstray.ui" line="211"/>
|
||||||
|
<source>Save</source>
|
||||||
|
<translation>Сохранить</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>ServerLMSWidget</name>
|
<name>ServerLMSWidget</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -17,30 +70,35 @@
|
|||||||
<translation>Форма</translation>
|
<translation>Форма</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../serverlmswidget.ui" line="238"/>
|
<location filename="../serverlmswidget.ui" line="207"/>
|
||||||
<source>Block Authorization</source>
|
|
||||||
<translation>Блокировка авторизации</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../serverlmswidget.ui" line="181"/>
|
|
||||||
<source>Logger</source>
|
<source>Logger</source>
|
||||||
<translation>Логгер</translation>
|
<translation>Логгер</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../serverlmswidget.ui" line="146"/>
|
<location filename="../serverlmswidget.ui" line="172"/>
|
||||||
<source>Clients</source>
|
<source>Clients</source>
|
||||||
<translation>Клиенты</translation>
|
<translation>Клиенты</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../serverlmswidget.ui" line="209"/>
|
<location filename="../serverlmswidget.ui" line="150"/>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation>Настройки</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../serverlmswidget.ui" line="235"/>
|
||||||
<source>Data base: </source>
|
<source>Data base: </source>
|
||||||
<translation>База данных: </translation>
|
<translation>База данных: </translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../serverlmswidget.ui" line="216"/>
|
<location filename="../serverlmswidget.ui" line="242"/>
|
||||||
<source>...</source>
|
<source>...</source>
|
||||||
<translation></translation>
|
<translation></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../serverlmswidget.ui" line="264"/>
|
||||||
|
<source>Authorization</source>
|
||||||
|
<translation>Авторизация</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../serverlmswidget.ui" line="51"/>
|
<location filename="../serverlmswidget.ui" line="51"/>
|
||||||
<source>Start</source>
|
<source>Start</source>
|
||||||
@@ -51,5 +109,33 @@
|
|||||||
<source>Stop</source>
|
<source>Stop</source>
|
||||||
<translation>Остановить</translation>
|
<translation>Остановить</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../serverlmswidget.cpp" line="201"/>
|
||||||
|
<location filename="../serverlmswidget.cpp" line="250"/>
|
||||||
|
<source>Warning!</source>
|
||||||
|
<translation>Внимание!</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../serverlmswidget.cpp" line="201"/>
|
||||||
|
<source>Database settings have been changed.
|
||||||
|
The server will be restarted.</source>
|
||||||
|
<translation>Настройки Базы Данных были изменены.
|
||||||
|
Сервер будет перезапущен.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../serverlmswidget.cpp" line="250"/>
|
||||||
|
<source>The file could not be opened </source>
|
||||||
|
<translation>Файл не может быть открыт </translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../serverlmswidget.cpp" line="320"/>
|
||||||
|
<source>Error!</source>
|
||||||
|
<translation>Ошибка!</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../serverlmswidget.cpp" line="320"/>
|
||||||
|
<source>Database connection error</source>
|
||||||
|
<translation>Ошибка подключения к Базе Данных</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ void MainWindow::changeEvent(QEvent *event)
|
|||||||
{// переведём окно заново
|
{// переведём окно заново
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
|
|
||||||
|
trayIcon->setToolTip(tr("Server LMS"));
|
||||||
action_ShowWindow->setText(tr("Expand window"));
|
action_ShowWindow->setText(tr("Expand window"));
|
||||||
action_HideWindow->setText(tr("Minimize window"));
|
action_HideWindow->setText(tr("Minimize window"));
|
||||||
action_Exit->setText(tr("Exit"));
|
action_Exit->setText(tr("Exit"));
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 8.9 KiB |
BIN
TrayServerLMS/resources/IcoServerRRJ_2.ico
Normal file
BIN
TrayServerLMS/resources/IcoServerRRJ_2.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
TrayServerLMS/resources/IcoServerRRJ_old.ico
Normal file
BIN
TrayServerLMS/resources/IcoServerRRJ_old.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
Reference in New Issue
Block a user