Check is Bonjour running before update zeroconf

This commit is contained in:
Xinyu Hou 2014-11-11 15:57:25 +00:00
parent 6ef744cd81
commit 588494a730
2 changed files with 25 additions and 17 deletions

View File

@ -75,8 +75,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
m_pMenuEdit(NULL),
m_pMenuWindow(NULL),
m_pMenuHelp(NULL),
m_pZeroconfService(NULL),
m_BonjourRunning(true)
m_pZeroconfService(NULL)
{
setupUi(this);
@ -106,13 +105,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
setMinimumSize(size());
#endif
#if defined(Q_OS_WIN)
m_BonjourRunning = isServiceRunning("Bonjour Service");
#endif
if (m_BonjourRunning) {
updateZeroconfService();
}
updateZeroconfService();
m_pAutoConnectCheckBox->setChecked(appConfig.autoConnect());
}
@ -784,14 +777,16 @@ void MainWindow::changeEvent(QEvent* event)
void MainWindow::updateZeroconfService()
{
if (!m_AppConfig.wizardShouldRun()) {
if (m_pZeroconfService) {
delete m_pZeroconfService;
m_pZeroconfService = NULL;
}
if (isBonjourRunning()) {
if (!m_AppConfig.wizardShouldRun()) {
if (m_pZeroconfService) {
delete m_pZeroconfService;
m_pZeroconfService = NULL;
}
if (m_AppConfig.autoConnect() || synergyType() == synergyServer) {
m_pZeroconfService = new ZeroconfService(this);
if (m_AppConfig.autoConnect() || synergyType() == synergyServer) {
m_pZeroconfService = new ZeroconfService(this);
}
}
}
}
@ -937,3 +932,16 @@ bool MainWindow::isServiceRunning(QString name)
#endif
return false;
}
bool MainWindow::isBonjourRunning()
{
bool result = false;
#if defined(Q_OS_WIN)
result = isServiceRunning("Bonjour Service");
#else
result = true;
#endif
return result;
}

View File

@ -147,6 +147,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
void changeEvent(QEvent* event);
void retranslateMenuBar();
bool isServiceRunning(QString name);
bool isBonjourRunning();
private:
QSettings& m_Settings;
@ -166,7 +167,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
QMenu* m_pMenuWindow;
QMenu* m_pMenuHelp;
ZeroconfService* m_pZeroconfService;
bool m_BonjourRunning;
private slots:
void on_m_pAutoConnectCheckBox_toggled(bool checked);