Skip to content

Commit

Permalink
Made Bonjour install in another thread deskflow#4235
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinyu Hou committed Nov 27, 2014
1 parent af4817d commit a0cc3d6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/gui/gui.pro
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ SOURCES += src/main.cpp \
src/ZeroconfBrowser.cpp \
src/ZeroconfService.cpp \
src/DataDownloader.cpp \
src/AddClientDialog.cpp
src/AddClientDialog.cpp \
src/CommandProcess.cpp
HEADERS += src/MainWindow.h \
src/AboutDialog.h \
src/ServerConfig.h \
Expand Down Expand Up @@ -84,7 +85,8 @@ HEADERS += src/MainWindow.h \
src/ZeroconfBrowser.h \
src/ZeroconfService.h \
src/DataDownloader.h \
src/AddClientDialog.h
src/AddClientDialog.h \
src/CommandProcess.h
RESOURCES += res/Synergy.qrc
RC_FILE = res/win/Synergy.rc
macx {
Expand Down
33 changes: 33 additions & 0 deletions src/gui/src/CommandProcess.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2014 Synergy Si, Inc.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "CommandProcess.h"

#include <QProcess>

CommandProcess::CommandProcess(QString cmd, QStringList arguments) :
m_Command(cmd),
m_Arguments(arguments)
{
}

void CommandProcess::run()
{
QProcess process;
process.start(m_Command, m_Arguments);
process.waitForFinished();
}
38 changes: 38 additions & 0 deletions src/gui/src/CommandProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2014 Synergy Si, Inc.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef COMMANDTHREAD_H
#define COMMANDTHREAD_H

#include <QStringList>

class CommandProcess : public QObject
{
Q_OBJECT

public:
CommandProcess(QString cmd, QStringList arguments);

public slots:
void run();

private:
QString m_Command;
QStringList m_Arguments;
};

#endif // COMMANDTHREAD_H
30 changes: 18 additions & 12 deletions src/gui/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "SetupWizard.h"
#include "ZeroconfService.h"
#include "DataDownloader.h"
#include "CommandProcess.h"

#include <QtCore>
#include <QtGui>
Expand Down Expand Up @@ -973,15 +974,17 @@ void MainWindow::on_m_pButtonApply_clicked()

void MainWindow::on_m_pCheckBoxAutoConnect_toggled(bool checked)
{
if (!isBonjourRunning() && checked && !m_SuppressAutoConnectWarning) {
int r = QMessageBox::information(
this, tr("Synergy"),
tr("Auto connect feature requires Bonjour.\n\n"
"Do you want to install Bonjour?"),
QMessageBox::Yes | QMessageBox::No);

if (r == QMessageBox::Yes) {
downloadBonjour();
if (!isBonjourRunning() && checked) {
if (!m_SuppressAutoConnectWarning) {
int r = QMessageBox::information(
this, tr("Synergy"),
tr("Auto connect feature requires Bonjour.\n\n"
"Do you want to install Bonjour?"),
QMessageBox::Yes | QMessageBox::No);

if (r == QMessageBox::Yes) {
downloadBonjour();
}
}

m_pCheckBoxAutoConnect->setChecked(false);
Expand Down Expand Up @@ -1117,14 +1120,17 @@ void MainWindow::installBonjour()
file.write(m_pDataDownloader->downloadedData());
file.close();

QProcess process;
QStringList arguments;
arguments.append("/i");
QString winFilename = QDir::toNativeSeparators(filename);
arguments.append(winFilename);
arguments.append("/passive");
process.start("msiexec", arguments);
process.waitForFinished();
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);

m_DownloadMessageBox->hide();
#endif
Expand Down

0 comments on commit a0cc3d6

Please sign in to comment.