#5617 Delete the plugin infrastructure

This commit is contained in:
Andrew Nelless
2016-09-27 12:16:20 +01:00
parent 665bd91dbd
commit 76b2558f1a
22 changed files with 0 additions and 2077 deletions

View File

@@ -1,137 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PluginWizardPage</class>
<widget class="QWizardPage" name="PluginWizardPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Setup Synergy</string>
</property>
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="m_pLabelSpinning">
<property name="text">
<string> </string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="m_pLabelStatus">
<property name="text">
<string>Please wait...</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -1,73 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless 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 LICENSE 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 "Plugin.h"
#include "CoreInterface.h"
static const char kBaseUrl[] = "http://symless.com/files";
static const char kDefaultVersion[] = "1.1";
static const char kWinPackagePlatform32[] = "Windows-x86";
static const char kWinPackagePlatform64[] = "Windows-x64";
static const char kMacPackagePlatform[] = "MacOSX%1-i386";
static const char kLinuxPackagePlatformDeb32[] = "Linux-i686-deb";
static const char kLinuxPackagePlatformDeb64[] = "Linux-x86_64-deb";
static const char kLinuxPackagePlatformRpm32[] = "Linux-i686-rpm";
static const char kLinuxPackagePlatformRpm64[] = "Linux-x86_64-rpm";
#if defined(Q_OS_WIN)
static const char kWinPluginExt[] = ".dll";
static const char kInstallerPluginLocation[] = "Plugins";
#elif defined(Q_OS_MAC)
static const char kMacPluginPrefix[] = "lib";
static const char kMacPluginExt[] = ".dylib";
static const char kInstallerPluginLocation[] = "plugins"; // TODO: Fix for mac
#else
static const char kLinuxPluginPrefix[] = "lib";
static const char kLinuxPluginExt[] = ".so";
// /usr/bin becomes /usr/bin/../lib/syn...
static const char kInstallerPluginLocation[] = "../lib/synergy/plugins";
#endif
QString Plugin::getOsSpecificExt()
{
#if defined(Q_OS_WIN)
return kWinPluginExt;
#elif defined(Q_OS_MAC)
return kMacPluginExt;
#else
return kLinuxPluginExt;
#endif
}
QString Plugin::getOsSpecificName(const QString& pluginName)
{
QString result = pluginName;
#if defined(Q_OS_WIN)
result.append(getOsSpecificExt());
#elif defined(Q_OS_MAC)
result = kMacPluginPrefix + pluginName + getOsSpecificExt();
#else
result = kLinuxPluginPrefix + pluginName + getOsSpecificExt();
#endif
return result;
}
QString Plugin::getOsSpecificInstallerLocation() {
return kInstallerPluginLocation;
}

View File

@@ -1,53 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless 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 LICENSE 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 PLUGIN_H
#define PLUGIN_H
#include <QString>
#include <QStringList>
#include <QObject>
#include "SslCertificate.h"
#include "CoreInterface.h"
#include "DataDownloader.h"
class Plugin : public QObject
{
Q_OBJECT
public:
//Plugin();
//~PluginManager();
static QString getOsSpecificName(const QString& pluginName);
static QString getOsSpecificExt();
static QString getOsSpecificLocation();
static QString getOsSpecificInstallerLocation();
static QString getOsSpecificUserLocation();
public slots:
private:
// CoreInterface m_CoreInterface;
signals:
private:
};
#endif // PLUGIN_H

View File

@@ -1,186 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless 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 LICENSE 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 "PluginManager.h"
#include "CoreInterface.h"
#include "DataDownloader.h"
#include "QUtility.h"
#include "ProcessorArch.h"
#include "Fingerprint.h"
#include "Plugin.h"
#include "../lib/common/PluginVersion.h"
#include <QTextStream>
#include <QFile>
#include <QDir>
#include <QProcess>
#include <QCoreApplication>
PluginManager::PluginManager() :
m_PluginList()
{
init();
}
PluginManager::~PluginManager()
{
}
void PluginManager::init()
{
m_PluginDir = m_CoreInterface.getPluginDir();
if (m_PluginDir.isEmpty()) {
emit error(tr("Failed to get plugin directory."));
}
m_ProfileDir = m_CoreInterface.getProfileDir();
if (m_ProfileDir.isEmpty()) {
emit error(tr("Failed to get profile directory."));
}
m_InstalledDir = m_CoreInterface.getInstalledDir();
if (m_InstalledDir.isEmpty()) {
emit error(tr("Failed to get installed directory."));
}
}
bool PluginManager::exist(QString name)
{
CoreInterface coreInterface;
QString PluginDir = coreInterface.getPluginDir();
QString pluginName = Plugin::getOsSpecificName(name);
QString filename;
filename.append(PluginDir);
filename.append(QDir::separator()).append(pluginName);
QFile file(filename);
bool exist = false;
if (file.exists()) {
exist = true;
}
return exist;
}
void PluginManager::copyPlugins()
{
try {
// Get the Directory where plugins are put on installation
// If it doesn't exist, there is nothing to do
QString srcDirName(m_InstalledDir.append(QDir::separator())
.append(Plugin::getOsSpecificInstallerLocation()));
QDir srcDir(srcDirName);
if (!srcDir.exists()) {
emit info(
tr("No plugins found to copy from %1")
.arg(srcDirName));
emit copyFinished();
}
// Get the directory where Plugins are installed into Synergy
// If it doesn't exist make it
QString destDirName = m_PluginDir;
QDir destDir(destDirName);
if (!destDir.exists()) {
destDir.mkpath(".");
}
// Run through the list of plugins and copy them
for ( int i = 0 ; i < m_PluginList.size() ; i++ ) {
// Get a file entry for the plugin using the full path
QFile file(srcDirName + QDir::separator() + m_PluginList.at(i));
// construct the destination file name
QString newName(destDirName + QDir::separator() + m_PluginList.at(i));
// Check to see if the plugin already exists
QFile newFile(newName);
if(newFile.exists()) {
// If it does, delete it. TODO: Check to see if same and leave
bool result = newFile.remove();
if( !result ) {
emit error(
tr( "Unable to delete plugin:\n%1\n"
"Please stop synergy and run the wizard again.")
.arg(newName));
return;
}
}
// make a copy of the plugin in the new location
#if defined(Q_OS_WIN)
bool result = file.copy(newName);
#else
bool result = file.link(newName);
#endif
if ( !result ) {
emit error(
tr("Failed to copy plugin '%1' to: %2\n%3\n"
"Please stop synergy and run the wizard again.")
.arg(m_PluginList.at(i))
.arg(newName)
.arg(file.errorString()));
return;
}
else {
emit info(
tr("Copying '%1' plugin (%2/%3)...")
.arg(m_PluginList.at(i))
.arg(i+1)
.arg(m_PluginList.size()));
}
}
}
catch (std::exception& e)
{
emit error(tr( "An error occurred while trying to copy the "
"plugin list. Please contact the help desk, and "
"provide the following details.\n\n%1").arg(e.what()));
}
emit copyFinished();
return;
}
void PluginManager::queryPluginList()
{
try {
setDone(false);
QString extension = "*" + Plugin::getOsSpecificExt();
QStringList nameFilter(extension);
QString installDir(m_CoreInterface.getInstalledDir()
.append(QDir::separator())
.append(Plugin::getOsSpecificInstallerLocation()));
QString searchDirectory(installDir);
QDir directory(searchDirectory);
m_PluginList = directory.entryList(nameFilter);
setDone(true);
}
catch (std::exception& e)
{
setDone(true);
emit error(tr( "An error occurred while trying to load the "
"plugin list. Please contact the help desk, and "
"provide the following details.\n\n%1").arg(e.what()));
}
emit queryPluginDone();
return;
}

View File

@@ -1,75 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless 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 LICENSE 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 PLUGINMANAGER_H
#define PLUGINMANAGER_H
#include <QString>
#include <QStringList>
#include <QObject>
#include "SslCertificate.h"
#include "CoreInterface.h"
#include "DataDownloader.h"
#include "Plugin.h"
class PluginManager : public QObject
{
Q_OBJECT
public:
PluginManager();
~PluginManager();
void init();
int pluginCount() { return m_PluginList.count(); }
QStringList& getPluginList() { return m_PluginList; }
bool isDone() { return done; }
void setDone(bool b) { done = b; }
static bool exist(QString name);
public slots:
void copyPlugins();
void queryPluginList();
private:
QString getPluginUrl(const QString& pluginName);
bool runProgram(
const QString& program,
const QStringList& args,
const QStringList& env);
signals:
void error(QString e);
void info(QString i);
void updateCopyStatus(int);
void copyFinished();
void queryPluginDone();
private:
QStringList m_PluginList;
QString m_PluginDir;
QString m_ProfileDir;
QString m_InstalledDir;
CoreInterface m_CoreInterface;
SslCertificate m_SslCertificate;
bool done;
};
#endif // PLUGINMANAGER_H

View File

@@ -1,206 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless 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 LICENSE 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 "PluginWizardPage.h"
#include "ui_PluginWizardPageBase.h"
#include "SslCertificate.h"
#include "PluginManager.h"
#include "MainWindow.h"
#include "EditionType.h"
#include <QMovie>
#include <QThread>
#include <QTime>
PluginWizardPage::PluginWizardPage(MainWindow& mainWindow, QWidget *parent) :
QWizardPage(parent),
m_Finished(false),
m_Edition(Unknown),
m_pSslCertificate(NULL),
m_mainWindow(mainWindow)
{
setupUi(this);
QMovie *movie = new QMovie(":/res/image/spinning-wheel.gif");
m_pLabelSpinning->setMovie(movie);
movie->start();
m_pSslCertificate = new SslCertificate(this);
}
PluginWizardPage::~PluginWizardPage()
{
delete m_pSslCertificate;
}
void PluginWizardPage::changeEvent(QEvent *e)
{
QWizardPage::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
retranslateUi(this);
break;
default:
break;
}
}
void PluginWizardPage::initializePage()
{
QWizardPage::initializePage();
if (m_Edition != Pro) {
updateStatus(tr("Setup complete."));
showFinished();
return;
}
m_pLabelSpinning->show();
QThread* thread = new QThread;
connect(&m_PluginManager,
SIGNAL(error(QString)),
this,
SLOT(showError(QString)));
connect(&m_PluginManager,
SIGNAL(info(QString)),
this,
SLOT(updateStatus(QString)));
connect(&m_PluginManager,
SIGNAL(queryPluginDone()),
this,
SLOT(queryPluginDone()));
connect(&m_PluginManager,
SIGNAL(queryPluginDone()),
thread,
SLOT(quit()));
connect(&m_PluginManager,
SIGNAL(error(QString)),
thread,
SLOT(quit()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
m_PluginManager.moveToThread(thread);
thread->start();
QMetaObject::invokeMethod(&m_PluginManager, "queryPluginList", Qt::QueuedConnection);
}
void PluginWizardPage::queryPluginDone()
{
QStringList pluginList = m_PluginManager.getPluginList();
if (pluginList.isEmpty()) {
updateStatus(tr("Setup complete."));
showFinished();
}
else {
m_mainWindow.stopSynergy();
copyPlugins();
m_mainWindow.startSynergy();
}
}
void PluginWizardPage::copyPlugins()
{
m_pThread = new QThread;
connect(&m_PluginManager,
SIGNAL(copyFinished()),
this,
SLOT(generateCertificate()));
connect(&m_PluginManager,
SIGNAL(error(QString)),
m_pThread,
SLOT(quit()));
connect(m_pThread,
SIGNAL(finished()),
m_pThread,
SLOT(deleteLater()));
updateStatus(
tr("Copying plugins..."));
m_PluginManager.moveToThread(m_pThread);
m_pThread->start();
QMetaObject::invokeMethod(
&m_PluginManager,
"copyPlugins",
Qt::QueuedConnection);
}
void PluginWizardPage::generateCertificate()
{
connect(m_pSslCertificate,
SIGNAL(generateFinished()),
this,
SLOT(finished()));
connect(m_pSslCertificate,
SIGNAL(generateFinished()),
m_pThread,
SLOT(quit()));
updateStatus(tr("Generating SSL certificate..."));
QMetaObject::invokeMethod(
m_pSslCertificate,
"generateCertificate",
Qt::QueuedConnection);
}
void PluginWizardPage::showError(QString error)
{
updateStatus(tr("Error: %1").arg(error));
showFinished();
}
void PluginWizardPage::updateStatus(QString info)
{
m_pLabelStatus->setText(info);
}
void PluginWizardPage::finished()
{
// TODO: we should check if ns plugin exists
m_mainWindow.appConfig().setCryptoEnabled(true);
updateStatus(tr("Plugins installed successfully."));
showFinished();
}
void PluginWizardPage::showFinished()
{
m_pLabelSpinning->hide();
m_Finished = true;
emit completeChanged();
}
bool PluginWizardPage::isComplete() const
{
return m_Finished;
}

View File

@@ -1,66 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless 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 LICENSE 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 PLUGINWIZARDPAGE_H
#define PLUGINWIZARDPAGE_H
#include "AppConfig.h"
#include "ui_PluginWizardPageBase.h"
#include "PluginManager.h"
#include <QWizardPage>
class SslCertificate;
class MainWindow;
class PluginWizardPage : public QWizardPage, public Ui::PluginWizardPage {
Q_OBJECT
public:
PluginWizardPage(MainWindow& mainWindow, QWidget *parent = 0);
~PluginWizardPage();
void setFinished(bool b) { m_Finished = b; }
void setEdition(int edition) { m_Edition = edition; }
bool isComplete() const;
void initializePage();
protected:
void changeEvent(QEvent *e);
protected slots:
void showError(QString error);
void updateStatus(QString info);
void queryPluginDone();
void generateCertificate();
void finished();
private:
void copyPlugins();
void showFinished();
private:
bool m_Finished;
int m_Edition;
PluginManager m_PluginManager;
SslCertificate* m_pSslCertificate;
QThread* m_pThread;
MainWindow& m_mainWindow;
};
#endif // PLUGINWIZARDPAGE_H