#6338 Refactor auto restart logic, fixed debug level check, added some debug logging

This commit is contained in:
Nick Bolton 2018-08-08 17:20:16 +01:00
parent 934824433d
commit 4cf1ab8a25
2 changed files with 30 additions and 31 deletions

View File

@ -62,6 +62,8 @@ static const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*.
static const char* tlsVersion = "TLS 1.2"; static const char* tlsVersion = "TLS 1.2";
static const char* tlsCheckString = "network encryption protocol: TLSv1.2"; static const char* tlsCheckString = "network encryption protocol: TLSv1.2";
static const int debugLogLevel = 1;
static const char* synergyIconFiles[] = static const char* synergyIconFiles[] =
{ {
":/res/icons/16x16/synergy-disconnected.png", ":/res/icons/16x16/synergy-disconnected.png",
@ -408,7 +410,7 @@ void MainWindow::appendLogInfo(const QString& text)
} }
void MainWindow::appendLogDebug(const QString& text) { void MainWindow::appendLogDebug(const QString& text) {
if (appConfig().logLevel() >= 4) { if (appConfig().logLevel() >= debugLogLevel) {
appendLogRaw(getTimeStamp() + " DEBUG: " + text); appendLogRaw(getTimeStamp() + " DEBUG: " + text);
} }
} }
@ -1285,36 +1287,36 @@ void MainWindow::on_m_pActionSettings_triggered()
void MainWindow::autoAddScreen(const QString name) void MainWindow::autoAddScreen(const QString name)
{ {
if (!m_ServerConfig.ignoreAutoConfigClient()) { if (m_ServerConfig.ignoreAutoConfigClient()) {
appendLogDebug(QString("ignoring zeroconf screen: %1").arg(name));
return;
}
#ifndef SYNERGY_ENTERPRISE #ifndef SYNERGY_ENTERPRISE
if (m_ActivationDialogRunning) { if (m_ActivationDialogRunning) {
// TODO: refactor this code // TODO: refactor this code
// add this screen to the pending list and check this list until // add this screen to the pending list and check this list until
// users finish activation dialog // users finish activation dialog
m_PendingClientNames.append(name); m_PendingClientNames.append(name);
return; return;
} }
#endif #endif
int r = m_ServerConfig.autoAddScreen(name); int r = m_ServerConfig.autoAddScreen(name);
if (r != kAutoAddScreenOk) { if (r != kAutoAddScreenOk) {
switch (r) { switch (r) {
case kAutoAddScreenManualServer: case kAutoAddScreenManualServer:
showConfigureServer( showConfigureServer(
tr("Please add the server (%1) to the grid.") tr("Please add the server (%1) to the grid.")
.arg(appConfig().screenName())); .arg(appConfig().screenName()));
break; break;
case kAutoAddScreenManualClient: case kAutoAddScreenManualClient:
showConfigureServer( showConfigureServer(
tr("Please drag the new client screen (%1) " tr("Please drag the new client screen (%1) "
"to the desired position on the grid.") "to the desired position on the grid.")
.arg(name)); .arg(name));
break; break;
}
}
else {
restartSynergy();
} }
} }
} }
@ -1362,9 +1364,6 @@ int MainWindow::raiseActivationDialog()
m_PendingClientNames.clear(); m_PendingClientNames.clear();
} }
if (result == QDialog::Accepted) {
restartSynergy();
}
return result; return result;
} }
#endif #endif

View File

@ -303,7 +303,7 @@ int ServerConfig::autoAddScreen(const QString name)
} }
} }
if (findScreenName(name, targetIndex)) { if (findScreenName(name, targetIndex)) {
// already exists. m_pMainWindow->appendLogDebug(QString("ignoring screen already in config: %1").arg(name));
return kAutoAddScreenIgnore; return kAutoAddScreenIgnore;
} }