mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-28 23:05:11 +08:00
Merge 1.4.1 into trunk
This commit is contained in:
@@ -7,12 +7,24 @@
|
||||
const char AppConfig::m_SynergysName[] = "synergys.exe";
|
||||
const char AppConfig::m_SynergycName[] = "synergyc.exe";
|
||||
const char AppConfig::m_SynergyProgramDir[] = "bin/";
|
||||
const char AppConfig::m_SynergyLogDir[] = "log/";
|
||||
#else
|
||||
const char AppConfig::m_SynergysName[] = "synergys";
|
||||
const char AppConfig::m_SynergycName[] = "synergyc";
|
||||
const char AppConfig::m_SynergyProgramDir[] = "/usr/bin/";
|
||||
const char AppConfig::m_SynergyLogDir[] = "/var/log/";
|
||||
#endif
|
||||
|
||||
static const char* logLevelNames[] =
|
||||
{
|
||||
"ERROR",
|
||||
"WARNING",
|
||||
"NOTE",
|
||||
"INFO",
|
||||
"DEBUG",
|
||||
"DEBUG1",
|
||||
"DEBUG2"
|
||||
};
|
||||
|
||||
AppConfig::AppConfig(QSettings* settings) :
|
||||
m_pSettings(settings),
|
||||
@@ -34,6 +46,33 @@ AppConfig::~AppConfig()
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
QString AppConfig::synergyLogDir()
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
// on windows, we want to log to program files
|
||||
return QString(QDir::currentPath() + "/log/");
|
||||
#else
|
||||
// on unix, we'll log to the standard log dir
|
||||
return "/var/log/";
|
||||
#endif
|
||||
}
|
||||
|
||||
void AppConfig::persistLogDir()
|
||||
{
|
||||
QDir dir = synergyLogDir();
|
||||
|
||||
// persist the log directory
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkpath(dir.path());
|
||||
}
|
||||
}
|
||||
|
||||
QString AppConfig::logLevelText() const
|
||||
{
|
||||
return logLevelNames[logLevel()];
|
||||
}
|
||||
|
||||
void AppConfig::loadSettings()
|
||||
{
|
||||
m_AutoConnect = settings().value("autoConnectChecked", false).toBool();
|
||||
@@ -42,8 +81,10 @@ void AppConfig::loadSettings()
|
||||
m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString();
|
||||
m_Port = settings().value("port", 24800).toInt();
|
||||
m_Interface = settings().value("interface").toString();
|
||||
m_LogLevel = settings().value("logLevelIndex", 0).toInt();
|
||||
m_LogLevel = settings().value("logLevel", 2).toInt();
|
||||
m_AutoDetectPaths = settings().value("autoDetectPaths", true).toBool();
|
||||
m_LogToFile = settings().value("logToFile", true).toBool();
|
||||
m_LogFilename = settings().value("logFilename", synergyLogDir() + "synergy.log").toString();
|
||||
}
|
||||
|
||||
void AppConfig::saveSettings()
|
||||
@@ -54,7 +95,30 @@ void AppConfig::saveSettings()
|
||||
settings().setValue("screenName", m_ScreenName);
|
||||
settings().setValue("port", m_Port);
|
||||
settings().setValue("interface", m_Interface);
|
||||
settings().setValue("logLevelIndex", m_LogLevel);
|
||||
settings().setValue("logLevel", m_LogLevel);
|
||||
settings().setValue("autoDetectPaths", m_AutoDetectPaths);
|
||||
settings().setValue("logToFile", m_LogToFile);
|
||||
settings().setValue("logFilename", m_LogFilename);
|
||||
}
|
||||
|
||||
bool AppConfig::detectPath(const QString& name, QString& path)
|
||||
{
|
||||
// look in current working dir and default dir
|
||||
QStringList searchDirs;
|
||||
searchDirs.append("./");
|
||||
searchDirs.append(synergyProgramDir());
|
||||
|
||||
// use the first valid path we find
|
||||
for (int i = 0; i < searchDirs.length(); i++)
|
||||
{
|
||||
QFile f(searchDirs[i] + name);
|
||||
if (f.exists())
|
||||
{
|
||||
path = f.fileName();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// nothing found!
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,17 @@ class AppConfig
|
||||
const QString& interface() const { return m_Interface; }
|
||||
int logLevel() const { return m_LogLevel; }
|
||||
bool autoDetectPaths() const { return m_AutoDetectPaths; }
|
||||
bool logToFile() const { return m_LogToFile; }
|
||||
const QString& logFilename() const { return m_LogFilename; }
|
||||
QString logLevelText() const;
|
||||
|
||||
QString synergysName() const { return m_SynergysName; }
|
||||
QString synergycName() const { return m_SynergycName; }
|
||||
QString synergyProgramDir() const { return m_SynergyProgramDir; }
|
||||
QString synergyLogDir();
|
||||
|
||||
bool detectPath(const QString& name, QString& path);
|
||||
void persistLogDir();
|
||||
|
||||
protected:
|
||||
QSettings& settings() { return *m_pSettings; }
|
||||
@@ -40,6 +47,8 @@ class AppConfig
|
||||
void setInterface(const QString& s) { m_Interface = s; }
|
||||
void setLogLevel(int i) { m_LogLevel = i; }
|
||||
void setAutoDetectPaths(bool b) { m_AutoDetectPaths = b; }
|
||||
void setLogToFile(bool b) { m_LogToFile = b; }
|
||||
void setLogFilename(const QString& s) { m_LogFilename = s; }
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
@@ -54,10 +63,13 @@ class AppConfig
|
||||
QString m_Interface;
|
||||
int m_LogLevel;
|
||||
bool m_AutoDetectPaths;
|
||||
bool m_LogToFile;
|
||||
QString m_LogFilename;
|
||||
|
||||
static const char m_SynergysName[];
|
||||
static const char m_SynergycName[];
|
||||
static const char m_SynergyProgramDir[];
|
||||
static const char m_SynergyLogDir[];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,7 @@ class LogDialog : public QDialog, public Ui::LogDialogBase
|
||||
|
||||
public:
|
||||
void append(const QString& s);
|
||||
void clear() { m_pLogOutput->clear(); }
|
||||
|
||||
public slots:
|
||||
void readSynergyOutput();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ServerConfigDialog.h"
|
||||
#include "SettingsDialog.h"
|
||||
#include "LogDialog.h"
|
||||
#include "WindowsServices.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
@@ -22,18 +23,6 @@ static const char* synergyIconFiles[] =
|
||||
":/res/icons/16x16/synergy-connected.png"
|
||||
};
|
||||
|
||||
static const char* logLevelNames[] =
|
||||
{
|
||||
"ERROR",
|
||||
"WARNING",
|
||||
"NOTE",
|
||||
"INFO",
|
||||
"DEBUG",
|
||||
"DEBUG1",
|
||||
"DEBUG2"
|
||||
};
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
QMainWindow(parent),
|
||||
MainWindowBase(),
|
||||
@@ -121,6 +110,9 @@ void MainWindow::createMenuBar()
|
||||
pMenuFile->addSeparator();
|
||||
pMenuFile->addAction(m_pActionQuit);
|
||||
pMenuEdit->addAction(m_pActionSettings);
|
||||
#if defined(Q_OS_WIN)
|
||||
pMenuEdit->addAction(m_pActionServices);
|
||||
#endif
|
||||
pMenuView->addAction(m_pActionLogOutput);
|
||||
pMenuWindow->addAction(m_pActionMinimize);
|
||||
pMenuWindow->addAction(m_pActionRestore);
|
||||
@@ -131,13 +123,6 @@ void MainWindow::createMenuBar()
|
||||
|
||||
void MainWindow::loadSettings()
|
||||
{
|
||||
// gui
|
||||
QRect rect = settings().value("windowGeometry", geometry()).toRect();
|
||||
move(rect.x(), rect.y());
|
||||
resize(rect.width(), rect.height());
|
||||
|
||||
// program settings
|
||||
|
||||
// the next two must come BEFORE loading groupServerChecked and groupClientChecked or
|
||||
// disabling and/or enabling the right widgets won't automatically work
|
||||
m_pRadioExternalConfig->setChecked(settings().value("externalConfig", false).toBool());
|
||||
@@ -163,13 +148,6 @@ void MainWindow::initConnections()
|
||||
|
||||
void MainWindow::saveSettings()
|
||||
{
|
||||
// gui
|
||||
settings().setValue("windowGeometry", geometry());
|
||||
|
||||
#if !defined(Q_OS_MAC)
|
||||
settings().setValue("windowVisible", isVisible());
|
||||
#endif
|
||||
|
||||
// program settings
|
||||
settings().setValue("groupServerChecked", m_pGroupServer->isChecked());
|
||||
settings().setValue("externalConfig", m_pRadioExternalConfig->isChecked());
|
||||
@@ -205,7 +183,7 @@ void MainWindow::startSynergy()
|
||||
QString app;
|
||||
QStringList args;
|
||||
|
||||
args << "-f" << "--debug" << logLevelNames[appConfig().logLevel()];
|
||||
args << "-f" << "--debug" << appConfig().logLevelText();
|
||||
|
||||
if (!appConfig().screenName().isEmpty())
|
||||
args << "--name" << appConfig().screenName();
|
||||
@@ -236,39 +214,9 @@ void MainWindow::startSynergy()
|
||||
setSynergyState(synergyConnected);
|
||||
}
|
||||
|
||||
bool MainWindow::detectPath(const QString& name, QString& path)
|
||||
{
|
||||
// look in current working dir and default dir
|
||||
QStringList searchDirs;
|
||||
searchDirs.append("./");
|
||||
searchDirs.append(appConfig().synergyProgramDir());
|
||||
|
||||
// use the first valid path we find
|
||||
for (int i = 0; i < searchDirs.length(); i++)
|
||||
{
|
||||
QFile f(searchDirs[i] + name);
|
||||
if (f.exists())
|
||||
{
|
||||
path = f.fileName();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// nothing found!
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainWindow::clientArgs(QStringList& args, QString& app)
|
||||
{
|
||||
if (appConfig().autoDetectPaths())
|
||||
{
|
||||
// actually returns bool, but ignore for now
|
||||
detectPath(appConfig().synergycName(), app);
|
||||
}
|
||||
else
|
||||
{
|
||||
app = appConfig().synergyc();
|
||||
}
|
||||
app = appPath(appConfig().synergycName(), appConfig().synergyc());
|
||||
|
||||
if (!QFile::exists(app))
|
||||
{
|
||||
@@ -289,22 +237,75 @@ bool MainWindow::clientArgs(QStringList& args, QString& app)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (appConfig().logToFile())
|
||||
{
|
||||
appConfig().persistLogDir();
|
||||
args << "--log" << appConfig().logFilename();
|
||||
}
|
||||
|
||||
args << m_pLineEditHostname->text() + ":" + QString::number(appConfig().port());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::serverArgs(QStringList& args, QString& app)
|
||||
QString MainWindow::configFilename()
|
||||
{
|
||||
if (appConfig().autoDetectPaths())
|
||||
QString filename;
|
||||
if (m_pRadioInternalConfig->isChecked())
|
||||
{
|
||||
// actually returns bool, but ignore for now
|
||||
detectPath(appConfig().synergysName(), app);
|
||||
// TODO: no need to use a temporary file, since we need it to
|
||||
// be permenant (since it'll be used for Windows services, etc).
|
||||
m_pTempConfigFile = new QTemporaryFile();
|
||||
if (!m_pTempConfigFile->open())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Cannot write configuration file"), tr("The temporary configuration file required to start synergy can not be written."));
|
||||
return false;
|
||||
}
|
||||
|
||||
serverConfig().save(*m_pTempConfigFile);
|
||||
filename = m_pTempConfigFile->fileName();
|
||||
|
||||
m_pTempConfigFile->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
app = appConfig().synergys();
|
||||
if (!QFile::exists(m_pLineEditConfigFile->text()))
|
||||
{
|
||||
if (QMessageBox::warning(this, tr("Configuration filename invalid"),
|
||||
tr("You have not filled in a valid configuration file for the synergy server. "
|
||||
"Do you want to browse for the configuration file now?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes
|
||||
|| !on_m_pButtonBrowseConfigFile_clicked())
|
||||
return false;
|
||||
}
|
||||
|
||||
filename = m_pLineEditConfigFile->text();
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
QString MainWindow::address()
|
||||
{
|
||||
return (!appConfig().interface().isEmpty() ? appConfig().interface() : "") + ":" + QString::number(appConfig().port());
|
||||
}
|
||||
|
||||
QString MainWindow::appPath(const QString& name, const QString& defaultPath)
|
||||
{
|
||||
QString app;
|
||||
if (appConfig().autoDetectPaths())
|
||||
{
|
||||
// actually returns bool, but ignore for now
|
||||
appConfig().detectPath(name, app);
|
||||
}
|
||||
else
|
||||
{
|
||||
app = defaultPath;
|
||||
}
|
||||
return app;
|
||||
}
|
||||
|
||||
bool MainWindow::serverArgs(QStringList& args, QString& app)
|
||||
{
|
||||
app = appPath(appConfig().synergysName(), appConfig().synergys());
|
||||
|
||||
if (!QFile::exists(app))
|
||||
{
|
||||
@@ -319,36 +320,13 @@ bool MainWindow::serverArgs(QStringList& args, QString& app)
|
||||
appConfig().setSynergys(app);
|
||||
}
|
||||
|
||||
if (m_pRadioInternalConfig->isChecked())
|
||||
if (appConfig().logToFile())
|
||||
{
|
||||
m_pTempConfigFile = new QTemporaryFile();
|
||||
if (!m_pTempConfigFile->open())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Cannot write configuration file"), tr("The temporary configuration file required to start synergy can not be written."));
|
||||
return false;
|
||||
}
|
||||
|
||||
serverConfig().save(*m_pTempConfigFile);
|
||||
args << "-c" << m_pTempConfigFile->fileName();
|
||||
|
||||
m_pTempConfigFile->close();
|
||||
// the file will be removed from disk when the object is deleted; this happens in stopSynergy()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!QFile::exists(m_pLineEditConfigFile->text()))
|
||||
{
|
||||
if (QMessageBox::warning(this, tr("Configuration filename invalid"),
|
||||
tr("You have not filled in a valid configuration file for the synergy server. "
|
||||
"Do you want to browse for the configuration file now?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes
|
||||
|| !on_m_pButtonBrowseConfigFile_clicked())
|
||||
return false;
|
||||
}
|
||||
|
||||
args << "-c" << m_pLineEditConfigFile->text();
|
||||
appConfig().persistLogDir();
|
||||
args << "--log" << appConfig().logFilename();
|
||||
}
|
||||
|
||||
args << "--address" << (!appConfig().interface().isEmpty() ? appConfig().interface() : "") + ":" + QString::number(appConfig().port());
|
||||
args << "-c" << configFilename() << "--address" << address();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -365,7 +343,9 @@ void MainWindow::stopSynergy()
|
||||
setSynergyState(synergyDisconnected);
|
||||
}
|
||||
|
||||
delete m_pTempConfigFile;
|
||||
// HACK: deleting the object deletes the physical file, which is
|
||||
// bad, since it could be in use by the Windows service!
|
||||
//delete m_pTempConfigFile;
|
||||
m_pTempConfigFile = NULL;
|
||||
}
|
||||
|
||||
@@ -460,6 +440,12 @@ void MainWindow::on_m_pActionSettings_triggered()
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_m_pActionServices_triggered()
|
||||
{
|
||||
WindowsServices dlg(this, appConfig());
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_m_pActionLogOutput_triggered()
|
||||
{
|
||||
Q_ASSERT(m_pLogDialog);
|
||||
|
||||
@@ -54,6 +54,10 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||
void setVisible(bool visible);
|
||||
int synergyType() const { return m_pGroupClient->isChecked() ? synergyClient : synergyServer; }
|
||||
int synergyState() const { return m_SynergyState; }
|
||||
QString hostname() const { return m_pLineEditHostname->text(); }
|
||||
QString configFilename();
|
||||
QString address();
|
||||
QString appPath(const QString& name, const QString& defaultPath);
|
||||
|
||||
protected slots:
|
||||
void on_m_pGroupClient_toggled(bool on) { m_pGroupServer->setChecked(!on); }
|
||||
@@ -63,6 +67,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||
bool on_m_pActionSave_triggered();
|
||||
void on_m_pActionAbout_triggered();
|
||||
void on_m_pActionSettings_triggered();
|
||||
void on_m_pActionServices_triggered();
|
||||
void on_m_pActionLogOutput_triggered();
|
||||
void synergyFinished(int exitCode, QProcess::ExitStatus);
|
||||
void iconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
@@ -87,7 +92,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||
bool clientArgs(QStringList& args, QString& app);
|
||||
bool serverArgs(QStringList& args, QString& app);
|
||||
void setStatus(const QString& status);
|
||||
bool detectPath(const QString& name, QString& path);
|
||||
|
||||
private:
|
||||
QSettings m_Settings;
|
||||
|
||||
@@ -20,6 +20,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||
m_pLineEditInterface->setText(appConfig().interface());
|
||||
m_pComboLogLevel->setCurrentIndex(appConfig().logLevel());
|
||||
m_pCheckBoxAutoDetectPaths->setChecked(appConfig().autoDetectPaths());
|
||||
m_pCheckBoxLogToFile->setChecked(appConfig().logToFile());
|
||||
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
||||
}
|
||||
|
||||
QString SettingsDialog::browseForSynergyc(QWidget* parent, const QString& programDir, const QString& synergycName)
|
||||
@@ -76,7 +78,29 @@ void SettingsDialog::accept()
|
||||
appConfig().setInterface(m_pLineEditInterface->text());
|
||||
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
||||
appConfig().setAutoDetectPaths(m_pCheckBoxAutoDetectPaths->isChecked());
|
||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SettingsDialog::on_m_pCheckBoxLogToFile_stateChanged(int i)
|
||||
{
|
||||
bool checked = i == 2;
|
||||
|
||||
m_pLineEditLogFilename->setEnabled(checked);
|
||||
m_pButtonBrowseLog->setEnabled(checked);
|
||||
}
|
||||
|
||||
void SettingsDialog::on_m_pButtonBrowseLog_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
this, tr("Save log file to..."),
|
||||
m_pLineEditLogFilename->text(),
|
||||
"Logs (*.log *.txt)");
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
m_pLineEditLogFilename->setText(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,22 +13,22 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
|
||||
|
||||
public:
|
||||
SettingsDialog(QWidget* parent, AppConfig& config);
|
||||
|
||||
public:
|
||||
static QString browseForSynergyc(QWidget* parent, const QString& programDir, const QString& synergycName);
|
||||
static QString browseForSynergys(QWidget* parent, const QString& programDir, const QString& synergysName);
|
||||
|
||||
protected slots:
|
||||
bool on_m_pButtonBrowseSynergys_clicked();
|
||||
bool on_m_pButtonBrowseSynergyc_clicked();
|
||||
void on_m_pCheckBoxAutoDetectPaths_stateChanged(int i);
|
||||
|
||||
protected:
|
||||
void accept();
|
||||
AppConfig& appConfig() { return m_AppConfig; }
|
||||
|
||||
private:
|
||||
AppConfig& m_AppConfig;
|
||||
|
||||
private slots:
|
||||
void on_m_pCheckBoxLogToFile_stateChanged(int );
|
||||
bool on_m_pButtonBrowseSynergys_clicked();
|
||||
bool on_m_pButtonBrowseSynergyc_clicked();
|
||||
void on_m_pCheckBoxAutoDetectPaths_stateChanged(int i);
|
||||
void on_m_pButtonBrowseLog_clicked();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
130
gui/src/WindowsServices.cpp
Normal file
130
gui/src/WindowsServices.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
#include "WindowsServices.h"
|
||||
#include "AppConfig.h"
|
||||
#include "MainWindow.h"
|
||||
#include "LogDialog.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
WindowsServices::WindowsServices(QWidget* parent, AppConfig& appConfig) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::WindowsServicesBase(),
|
||||
m_appConfig(appConfig),
|
||||
m_log(new LogDialog(this, process()))
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
void WindowsServices::runProc(const QString& app, const QStringList& args, QPushButton* button)
|
||||
{
|
||||
// disable until we know we've finished
|
||||
button->setEnabled(false);
|
||||
|
||||
// clear contents so user doesn't get confused by previous messages
|
||||
m_log->clear();
|
||||
|
||||
// deleted at end of function
|
||||
QProcess proc(this);
|
||||
m_process = &proc;
|
||||
|
||||
// send output to log window
|
||||
connect(m_process, SIGNAL(readyReadStandardOutput()), m_log, SLOT(readSynergyOutput()));
|
||||
connect(m_process, SIGNAL(readyReadStandardError()), m_log, SLOT(readSynergyOutput()));
|
||||
|
||||
m_process->start(app, args);
|
||||
m_log->show();
|
||||
|
||||
// service management should be instant
|
||||
m_process->waitForFinished();
|
||||
|
||||
if (m_process->exitCode() == 0)
|
||||
{
|
||||
QMessageBox::information(m_log, "Service manager", "Completed successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(
|
||||
m_log, "Service manager error",
|
||||
QString("Unable to install or uninstall service. Error code: " +
|
||||
QString::number(m_process->exitCode())));
|
||||
}
|
||||
|
||||
disconnect(m_process, SIGNAL(readyReadStandardOutput()), m_log, SLOT(readSynergyOutput()));
|
||||
disconnect(m_process, SIGNAL(readyReadStandardError()), m_log, SLOT(readSynergyOutput()));
|
||||
|
||||
button->setEnabled(true);
|
||||
}
|
||||
|
||||
void WindowsServices::on_m_pInstallServer_clicked()
|
||||
{
|
||||
QString app = mainWindow()->appPath(
|
||||
appConfig().synergysName(), appConfig().synergys());
|
||||
|
||||
QStringList args;
|
||||
args <<
|
||||
"--service" << "install" <<
|
||||
"--relaunch" <<
|
||||
"--debug" << appConfig().logLevelText() <<
|
||||
"-c" << mainWindow()->configFilename() <<
|
||||
"--address" << mainWindow()->address();
|
||||
|
||||
if (appConfig().logToFile())
|
||||
{
|
||||
appConfig().persistLogDir();
|
||||
args << "--log" << appConfig().logFilename();
|
||||
}
|
||||
|
||||
runProc(app, args, m_pInstallServer);
|
||||
}
|
||||
|
||||
void WindowsServices::on_m_pUninstallServer_clicked()
|
||||
{
|
||||
QString app = mainWindow()->appPath(
|
||||
appConfig().synergysName(), appConfig().synergys());
|
||||
|
||||
QStringList args;
|
||||
args << "--service" << "uninstall";
|
||||
runProc(app, args, m_pInstallServer);
|
||||
}
|
||||
|
||||
void WindowsServices::on_m_pInstallClient_clicked()
|
||||
{
|
||||
if (mainWindow()->hostname().isEmpty())
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this, "Service manager error", "Hostname was not specified on main screen.");
|
||||
return;
|
||||
}
|
||||
|
||||
QString app = mainWindow()->appPath(
|
||||
appConfig().synergycName(), appConfig().synergyc());
|
||||
|
||||
QStringList args;
|
||||
args <<
|
||||
"--service" << "install" <<
|
||||
"--relaunch" <<
|
||||
"--debug" << appConfig().logLevelText();
|
||||
|
||||
if (appConfig().logToFile())
|
||||
{
|
||||
appConfig().persistLogDir();
|
||||
args << "--log" << appConfig().logFilename();
|
||||
}
|
||||
|
||||
// hostname must come last to be a valid arg
|
||||
args << mainWindow()->hostname();
|
||||
|
||||
runProc(app, args, m_pInstallServer);
|
||||
}
|
||||
|
||||
void WindowsServices::on_m_pUninstallClient_clicked()
|
||||
{
|
||||
QString app = mainWindow()->appPath(
|
||||
appConfig().synergycName(), appConfig().synergyc());
|
||||
|
||||
QStringList args;
|
||||
args << "--service" << "uninstall";
|
||||
runProc(app, args, m_pInstallServer);
|
||||
}
|
||||
41
gui/src/WindowsServices.h
Normal file
41
gui/src/WindowsServices.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef WINDOWSSERVICES_H
|
||||
#define WINDOWSSERVICES_H
|
||||
|
||||
#include "ui_WindowsServicesBase.h"
|
||||
|
||||
class QWidget;
|
||||
class QProcess;
|
||||
class QPushButton;
|
||||
class QProcess;
|
||||
|
||||
class AppConfig;
|
||||
class MainWindow;
|
||||
class LogDialog;
|
||||
|
||||
class WindowsServices : public QDialog, public Ui::WindowsServicesBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WindowsServices(QWidget* parent, AppConfig& appConfig);
|
||||
|
||||
protected:
|
||||
AppConfig &appConfig() const { return m_appConfig; }
|
||||
MainWindow* mainWindow() const { return (MainWindow*)parent(); }
|
||||
QProcess*& process() { return m_process; }
|
||||
void runProc(const QString& app, const QStringList& args, QPushButton* button);
|
||||
|
||||
private:
|
||||
QString m_app;
|
||||
AppConfig &m_appConfig;
|
||||
QProcess* m_process;
|
||||
LogDialog* m_log;
|
||||
|
||||
private slots:
|
||||
void on_m_pUninstallClient_clicked();
|
||||
void on_m_pInstallClient_clicked();
|
||||
void on_m_pUninstallServer_clicked();
|
||||
void on_m_pInstallServer_clicked();
|
||||
};
|
||||
|
||||
#endif // WINDOWSSERVICES_H
|
||||
Reference in New Issue
Block a user