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; QProcess process;
process.start(m_Command, m_Arguments); process.start(m_Command, m_Arguments);
process.waitForFinished(); process.waitForFinished();
emit finished();
} }

View File

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

View File

@ -87,7 +87,9 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
m_pDataDownloader(NULL), m_pDataDownloader(NULL),
m_DownloadMessageBox(NULL), m_DownloadMessageBox(NULL),
m_pCancelButton(NULL), m_pCancelButton(NULL),
m_SuppressAutoConfigWarning(false) m_SuppressAutoConfigWarning(false),
m_BonjourInstall(NULL),
m_BonjourInstallThread(NULL)
{ {
setupUi(this); setupUi(this);
@ -137,6 +139,14 @@ MainWindow::~MainWindow()
if (m_DownloadMessageBox != NULL) { if (m_DownloadMessageBox != NULL) {
delete m_DownloadMessageBox; delete m_DownloadMessageBox;
} }
if (m_BonjourInstall != NULL) {
delete m_BonjourInstall;
}
if (m_BonjourInstallThread != NULL) {
delete m_BonjourInstallThread;
}
} }
void MainWindow::open() void MainWindow::open()
@ -1098,12 +1108,17 @@ void MainWindow::installBonjour()
QString winFilename = QDir::toNativeSeparators(filename); QString winFilename = QDir::toNativeSeparators(filename);
arguments.append(winFilename); arguments.append(winFilename);
arguments.append("/passive"); arguments.append("/passive");
CommandProcess* cp = new CommandProcess("msiexec", arguments); if (m_BonjourInstall == NULL) {
QThread* thread = new QThread; m_BonjourInstall = new CommandProcess("msiexec", arguments);
cp->moveToThread(thread); }
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); if (m_BonjourInstallThread == NULL) {
thread->start(); m_BonjourInstallThread = new QThread;
QMetaObject::invokeMethod(cp, "run", Qt::QueuedConnection); }
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(); m_DownloadMessageBox->hide();
#endif #endif
@ -1166,3 +1181,14 @@ void MainWindow::on_m_pCheckBoxAutoConfig_toggled(bool checked)
m_pComboServerList->hide(); 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 SetupWizard;
class ZeroconfService; class ZeroconfService;
class DataDownloader; class DataDownloader;
class CommandProcess;
class MainWindow : public QMainWindow, public Ui::MainWindowBase class MainWindow : public QMainWindow, public Ui::MainWindowBase
{ {
@ -134,6 +135,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
void logOutput(); void logOutput();
void logError(); void logError();
void updateFound(const QString& version); void updateFound(const QString& version);
void bonjourInstallFinished();
protected: protected:
QSettings& settings() { return m_Settings; } QSettings& settings() { return m_Settings; }
@ -188,6 +190,8 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
QAbstractButton* m_pCancelButton; QAbstractButton* m_pCancelButton;
QMutex m_Mutex; QMutex m_Mutex;
bool m_SuppressAutoConfigWarning; bool m_SuppressAutoConfigWarning;
CommandProcess* m_BonjourInstall;
QThread* m_BonjourInstallThread;
private slots: private slots:
void on_m_pCheckBoxAutoConfig_toggled(bool checked); void on_m_pCheckBoxAutoConfig_toggled(bool checked);