Skip to content

Commit

Permalink
Updated zeroconf after Bonjour is installed deskflow#4235
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinyu Hou committed Nov 28, 2014
1 parent 00d6b23 commit 4452f14
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/gui/src/CommandProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ void CommandProcess::run()
QProcess process;
process.start(m_Command, m_Arguments);
process.waitForFinished();
emit finished();
}
3 changes: 3 additions & 0 deletions src/gui/src/CommandProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class CommandProcess : public QObject
public:
CommandProcess(QString cmd, QStringList arguments);

signals:
void finished();

public slots:
void run();

Expand Down
40 changes: 33 additions & 7 deletions src/gui/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
4 changes: 4 additions & 0 deletions src/gui/src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class QSynergyApplication;
class SetupWizard;
class ZeroconfService;
class DataDownloader;
class CommandProcess;

class MainWindow : public QMainWindow, public Ui::MainWindowBase
{
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4452f14

Please sign in to comment.