Updated zeroconf after Bonjour is installed #4235

This commit is contained in:
Xinyu Hou 2014-11-28 12:57:57 +00:00
parent 00d6b23d57
commit 4452f14114
4 changed files with 41 additions and 7 deletions

View File

@ -30,4 +30,5 @@ void CommandProcess::run()
QProcess process;
process.start(m_Command, m_Arguments);
process.waitForFinished();
emit finished();
}

View File

@ -27,6 +27,9 @@ class CommandProcess : public QObject
public:
CommandProcess(QString cmd, QStringList arguments);
signals:
void finished();
public slots:
void run();

View File

@ -87,7 +87,9 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
m_pDataDownloader(NULL),
m_DownloadMessageBox(NULL),
m_pCancelButton(NULL),
m_SuppressAutoConfigWarning(false)
m_SuppressAutoConfigWarning(false),
m_BonjourInstall(NULL),
m_BonjourInstallThread(NULL)
{
setupUi(this);
@ -137,6 +139,14 @@ MainWindow::~MainWindow()
if (m_DownloadMessageBox != NULL) {
delete m_DownloadMessageBox;
}
if (m_BonjourInstall != NULL) {
delete m_BonjourInstall;
}
if (m_BonjourInstallThread != NULL) {
delete m_BonjourInstallThread;
}
}
void MainWindow::open()
@ -1098,12 +1108,17 @@ void MainWindow::installBonjour()
QString winFilename = QDir::toNativeSeparators(filename);
arguments.append(winFilename);
arguments.append("/passive");
CommandProcess* cp = new CommandProcess("msiexec", arguments);
QThread* thread = new QThread;
cp->moveToThread(thread);
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
QMetaObject::invokeMethod(cp, "run", Qt::QueuedConnection);
if (m_BonjourInstall == NULL) {
m_BonjourInstall = new CommandProcess("msiexec", arguments);
}
if (m_BonjourInstallThread == NULL) {
m_BonjourInstallThread = new QThread;
}
m_BonjourInstall->moveToThread(m_BonjourInstallThread);
connect(m_BonjourInstall, SIGNAL(finished()), this,
SLOT(bonjourInstallFinished()));
m_BonjourInstallThread->start();
QMetaObject::invokeMethod(m_BonjourInstall, "run", Qt::QueuedConnection);
m_DownloadMessageBox->hide();
#endif
@ -1166,3 +1181,14 @@ void MainWindow::on_m_pCheckBoxAutoConfig_toggled(bool checked)
m_pComboServerList->hide();
}
}
void MainWindow::bonjourInstallFinished()
{
delete m_BonjourInstall;
m_BonjourInstall = NULL;
delete m_BonjourInstallThread;
m_BonjourInstallThread = NULL;
updateZeroconfService();
}

View File

@ -55,6 +55,7 @@ class QSynergyApplication;
class SetupWizard;
class ZeroconfService;
class DataDownloader;
class CommandProcess;
class MainWindow : public QMainWindow, public Ui::MainWindowBase
{
@ -134,6 +135,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
void logOutput();
void logError();
void updateFound(const QString& version);
void bonjourInstallFinished();
protected:
QSettings& settings() { return m_Settings; }
@ -188,6 +190,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
QAbstractButton* m_pCancelButton;
QMutex m_Mutex;
bool m_SuppressAutoConfigWarning;
CommandProcess* m_BonjourInstall;
QThread* m_BonjourInstallThread;
private slots:
void on_m_pCheckBoxAutoConfig_toggled(bool checked);