mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-26 12:41:35 +03:00
greyed out network security group when no plugin available #4168
This commit is contained in:
parent
6cf40afcd7
commit
81bb74a24b
@ -54,7 +54,8 @@ SOURCES += src/main.cpp \
|
||||
src/CommandProcess.cpp \
|
||||
src/WebClient.cpp \
|
||||
src/PluginWizardPage.cpp \
|
||||
src/PluginManager.cpp
|
||||
src/PluginManager.cpp \
|
||||
src/DirectoryManager.cpp
|
||||
HEADERS += src/MainWindow.h \
|
||||
src/AboutDialog.h \
|
||||
src/ServerConfig.h \
|
||||
@ -95,7 +96,8 @@ HEADERS += src/MainWindow.h \
|
||||
src/EditionType.h \
|
||||
src/PluginWizardPage.h \
|
||||
src/ProcessorArch.h \
|
||||
src/PluginManager.h
|
||||
src/PluginManager.h \
|
||||
src/DirectoryManager.h
|
||||
RESOURCES += res/Synergy.qrc
|
||||
RC_FILE = res/win/Synergy.rc
|
||||
macx {
|
||||
|
@ -125,7 +125,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_pGroupCrypto">
|
||||
<widget class="QGroupBox" name="m_pGroupNetworkSecurity">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
81
src/gui/src/DirectoryManager.cpp
Normal file
81
src/gui/src/DirectoryManager.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2015 Synergy Si Ltd.
|
||||
*
|
||||
* 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 "DirectoryManager.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
|
||||
static const char kGetPluginDirArg[] = "--get-plugin-dir";
|
||||
static const char kGetProfileDirArg[] = "--get-profile-dir";
|
||||
|
||||
DirectoryManager::DirectoryManager()
|
||||
{
|
||||
}
|
||||
|
||||
QString DirectoryManager::getPluginDir()
|
||||
{
|
||||
QStringList args(kGetPluginDirArg);
|
||||
return getDirViaSyntool(args);
|
||||
}
|
||||
|
||||
QString DirectoryManager::getProfileDir()
|
||||
{
|
||||
QStringList args(kGetProfileDirArg);
|
||||
return getDirViaSyntool(args);
|
||||
}
|
||||
|
||||
QString DirectoryManager::getDirViaSyntool(QStringList& args)
|
||||
{
|
||||
QString program(QCoreApplication::applicationDirPath() + "/syntool");
|
||||
|
||||
QProcess process;
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
process.start(program, args);
|
||||
bool success = process.waitForStarted();
|
||||
|
||||
QString out, error;
|
||||
if (success)
|
||||
{
|
||||
if (process.waitForFinished()) {
|
||||
out = process.readAllStandardOutput();
|
||||
error = process.readAllStandardError();
|
||||
}
|
||||
}
|
||||
|
||||
out = out.trimmed();
|
||||
error = error.trimmed();
|
||||
|
||||
if (out.isEmpty() ||
|
||||
!error.isEmpty() ||
|
||||
!success ||
|
||||
process.exitCode() != 0)
|
||||
{
|
||||
QMessageBox::critical(
|
||||
NULL, QObject::tr("Synergy"),
|
||||
QObject::tr("An error occured while calling syntool "
|
||||
"with the first arg %1. Code: %2\nError: %3")
|
||||
.arg(args.at(0))
|
||||
.arg(process.exitCode())
|
||||
.arg(error.isEmpty() ? "Unknown" : error));
|
||||
return "";
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
36
src/gui/src/DirectoryManager.h
Normal file
36
src/gui/src/DirectoryManager.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2015 Synergy Si Ltd.
|
||||
*
|
||||
* 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 DIRECTORYMANAGER_H
|
||||
#define DIRECTORYMANAGER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
class DirectoryManager
|
||||
{
|
||||
public:
|
||||
DirectoryManager();
|
||||
|
||||
static QString getPluginDir();
|
||||
static QString getProfileDir();
|
||||
|
||||
private:
|
||||
static QString getDirViaSyntool(QStringList& args);
|
||||
};
|
||||
|
||||
#endif // DIRECTORYMANAGER_H
|
@ -17,19 +17,14 @@
|
||||
|
||||
#include "PluginManager.h"
|
||||
|
||||
#include "DirectoryManager.h"
|
||||
#include "CommandProcess.h"
|
||||
#include "DataDownloader.h"
|
||||
#include "QUtility.h"
|
||||
#include "ProcessorArch.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QProcess>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
|
||||
static const char kGetPluginDirArg[] = "--get-plugin-dir";
|
||||
static const char kGetProfileDirArg[] = "--get-profile-dir";
|
||||
|
||||
static QString kPluginsBaseUrl = "http://synergy-project.org/files/plugins/";
|
||||
static const char kWinProcessorArch32[] = "Windows-x86";
|
||||
@ -61,14 +56,12 @@ PluginManager::PluginManager(QStringList pluginList) :
|
||||
m_DownloadIndex(-1),
|
||||
m_pPluginDownloader(NULL)
|
||||
{
|
||||
QStringList args1(kGetPluginDirArg);
|
||||
m_PluginDir = getDirViaSyntool(args1);
|
||||
m_PluginDir = DirectoryManager::getPluginDir();
|
||||
if (m_PluginDir.isEmpty()) {
|
||||
emit error(tr("Failed to get plugin directory."));
|
||||
}
|
||||
|
||||
QStringList args2(kGetProfileDirArg);
|
||||
m_ProfileDir = getDirViaSyntool(args2);
|
||||
m_ProfileDir = DirectoryManager::getProfileDir();
|
||||
if (m_ProfileDir.isEmpty()) {
|
||||
emit error(tr("Failed to get profile directory."));
|
||||
}
|
||||
@ -177,46 +170,6 @@ void PluginManager::savePlugin()
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
||||
QString PluginManager::getDirViaSyntool(QStringList& args)
|
||||
{
|
||||
QString program(QCoreApplication::applicationDirPath() + "/syntool");
|
||||
|
||||
QProcess process;
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
process.start(program, args);
|
||||
bool success = process.waitForStarted();
|
||||
|
||||
QString out, error;
|
||||
if (success)
|
||||
{
|
||||
if (process.waitForFinished()) {
|
||||
out = process.readAllStandardOutput();
|
||||
error = process.readAllStandardError();
|
||||
}
|
||||
}
|
||||
|
||||
out = out.trimmed();
|
||||
error = error.trimmed();
|
||||
|
||||
if (out.isEmpty() ||
|
||||
!error.isEmpty() ||
|
||||
!success ||
|
||||
process.exitCode() != 0)
|
||||
{
|
||||
QMessageBox::critical(
|
||||
(QWidget*)parent(), tr("Synergy"),
|
||||
tr("An error occured while calling syntool "
|
||||
"with the first arg %1. Code: %2\nError: %3")
|
||||
.arg(args.at(0))
|
||||
.arg(process.exitCode())
|
||||
.arg(error.isEmpty() ? "Unknown" : error));
|
||||
return "";
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QString PluginManager::getPluginUrl(const QString& pluginName)
|
||||
{
|
||||
QString result;
|
||||
|
@ -42,7 +42,6 @@ public slots:
|
||||
|
||||
private:
|
||||
void savePlugin();
|
||||
QString getDirViaSyntool(QStringList& args);
|
||||
QString getPluginUrl(const QString& pluginName);
|
||||
QString getOpenSSLBinaryUrl();
|
||||
QString getPluginOSSpecificName(const QString& pluginName);
|
||||
|
@ -17,6 +17,8 @@
|
||||
*/
|
||||
|
||||
#include "SettingsDialog.h"
|
||||
|
||||
#include "DirectoryManager.h"
|
||||
#include "SynergyLocale.h"
|
||||
#include "QSynergyApplication.h"
|
||||
#include "QUtility.h"
|
||||
@ -26,6 +28,7 @@
|
||||
#include <QtGui>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
@ -54,7 +57,16 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||
m_pCheckBoxElevateMode->hide();
|
||||
#endif
|
||||
|
||||
m_pCheckBoxEnableCrypto->setChecked(m_AppConfig.getCryptoEnabled());
|
||||
QString pluginDir = DirectoryManager::getPluginDir();
|
||||
QDir dir(pluginDir);
|
||||
int fileNum = dir.entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries).count();
|
||||
if (fileNum == 0) {
|
||||
m_pGroupNetworkSecurity->setEnabled(false);
|
||||
m_pCheckBoxEnableCrypto->setChecked(false);
|
||||
}
|
||||
else {
|
||||
m_pCheckBoxEnableCrypto->setChecked(m_AppConfig.getCryptoEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::accept()
|
||||
|
Loading…
Reference in New Issue
Block a user