#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

View File

@ -23,7 +23,6 @@ add_subdirectory(ipc)
add_subdirectory(mt)
add_subdirectory(net)
add_subdirectory(platform)
add_subdirectory(plugin)
add_subdirectory(server)
add_subdirectory(synergy)

View File

@ -1,80 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* 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/>.
*/
#pragma once
#include "common/IInterface.h"
#include "common/stdmap.h"
#include "base/String.h"
class IEventQueue;
//! Interface for plugin manager.
/*!
A plugin manager should load all 3rd party plugins from the plugins dir,
and then look for common function names in the plugins.
*/
class IArchPlugin : public IInterface {
public:
//! @name manipulators
//@{
//!Load plugins
/*!
Scan the plugins dir and load plugins.
*/
virtual void load() = 0;
//!Unload plugins
/*!
Look through the loaded plugins and unload them.
*/
virtual void unload() = 0;
//! Init the common parts
/*!
Initializes common parts like log and arch.
*/
virtual void init(void* log, void* arch) = 0;
//! Init the event part
/*!
Initializes event parts.
*/
virtual void initEvent(void* eventTarget, IEventQueue* events) = 0;
//! Check if exists
/*!
Returns true if the plugin exists and is loaded.
*/
virtual bool exists(const char* name) = 0;
//! Invoke function
/*!
Invokes a function from the plugin.
*/
virtual void* invoke(const char* plugin,
const char* command,
void** args,
void* library = NULL) = 0;
//@}
protected:
typedef std::map<String, void*> PluginTable;
};

View File

@ -1,239 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* 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 "arch/unix/ArchPluginUnix.h"
#include "arch/unix/XArchUnix.h"
#include "common/PluginVersion.h"
#include "base/IEventQueue.h"
#include "base/Event.h"
#include "base/Log.h"
#include <vector>
#include <sys/types.h>
#include <dirent.h>
#include <dlfcn.h>
typedef void (*initFunc)(void*, void*);
typedef int (*initEventFunc)(void (*sendEvent)(const char*, void*));
typedef void* (*invokeFunc)(const char*, void*);
typedef void (*cleanupFunc)();
void* g_eventTarget = NULL;
IEventQueue* g_events = NULL;
ArchPluginUnix::ArchPluginUnix()
{
}
ArchPluginUnix::~ArchPluginUnix()
{
}
void
ArchPluginUnix::load()
{
String pluginsDir = getPluginsDir();
LOG((CLOG_DEBUG "plugins dir: %s", pluginsDir.c_str()));
struct dirent* de = NULL;
DIR* dir = NULL;
dir = opendir(pluginsDir.c_str());
if (dir == NULL) {
LOG((CLOG_DEBUG "can't open plugins dir: %s",
pluginsDir.c_str()));
return;
}
std::vector<String> plugins;
while ((de = readdir(dir)) != NULL) {
// ignore hidden files and diretories like .. and .
if (de->d_name[0] != '.') {
plugins.push_back(de->d_name);
}
}
closedir(dir);
std::vector<String>::iterator it;
for (it = plugins.begin(); it != plugins.end(); ++it) {
String filename = *it;
String path = synergy::string::sprintf(
"%s/%s", pluginsDir.c_str(), filename.c_str());
String name = synergy::string::removeFileExt(filename.substr(3));
LOG((CLOG_DEBUG "loading plugin: %s", filename.c_str()));
void* handle = dlopen(path.c_str(), RTLD_LAZY);
if (handle == NULL) {
LOG((CLOG_ERR "failed to load plugin '%s', error: %s",
filename.c_str(), dlerror()));
continue;
}
String expectedVersion = getExpectedPluginVersion(name.c_str());
String currentVersion = getCurrentVersion(name, handle);
if (currentVersion.empty() || (expectedVersion != currentVersion)) {
LOG((CLOG_ERR
"failed to load plugin '%s', "
"expected version %s but was %s",
filename.c_str(),
expectedVersion.c_str(),
currentVersion.empty() ? "unknown" : currentVersion.c_str()));
dlclose(handle);
continue;
}
LOG((CLOG_DEBUG "plugin loaded: %s (version %s)",
filename.c_str(),
currentVersion.c_str()));
m_pluginTable.insert(std::make_pair(name, handle));
}
}
void
ArchPluginUnix::unload()
{
PluginTable::iterator it;
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
cleanupFunc cleanup = (cleanupFunc)dlsym(it->second, "cleanup");
if (cleanup != NULL) {
cleanup();
}
else {
LOG((CLOG_DEBUG "no cleanup function in %s", it->first.c_str()));
}
LOG((CLOG_DEBUG "unloading plugin: %s", it->first.c_str()));
dlclose(it->second);
}
}
void
ArchPluginUnix::init(void* log, void* arch)
{
PluginTable::iterator it;
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
initFunc initPlugin = (initFunc)dlsym(it->second, "init");
if (initPlugin != NULL) {
initPlugin(log, arch);
}
else {
LOG((CLOG_DEBUG "no init function in %s", it->first.c_str()));
}
}
}
void
ArchPluginUnix::initEvent(void* eventTarget, IEventQueue* events)
{
g_eventTarget = eventTarget;
g_events = events;
PluginTable::iterator it;
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
initEventFunc initEventPlugin = (initEventFunc)dlsym(it->second, "initEvent");
if (initEventPlugin != NULL) {
initEventPlugin(&sendEvent);
}
else {
LOG((CLOG_DEBUG "no init event function in %s", it->first.c_str()));
}
}
}
bool
ArchPluginUnix::exists(const char* name)
{
PluginTable::iterator it;
it = m_pluginTable.find(name);
return it != m_pluginTable.end() ? true : false;
}
void*
ArchPluginUnix::invoke(
const char* plugin,
const char* command,
void** args,
void* library)
{
void* lib = NULL;
if (library == NULL) {
PluginTable::iterator it;
it = m_pluginTable.find(plugin);
if (it != m_pluginTable.end()) {
lib = it->second;
}
else {
LOG((CLOG_DEBUG "invoke command failed, plugin: %s command: %s",
plugin, command));
return NULL;
}
}
else {
lib = library;
}
invokeFunc invokePlugin = (invokeFunc)dlsym(lib, "invoke");
void* result = NULL;
if (invokePlugin != NULL) {
result = invokePlugin(command, args);
}
else {
LOG((CLOG_DEBUG "no invoke function in %s", plugin));
}
return result;
}
String
ArchPluginUnix::getPluginsDir()
{
return ARCH->getPluginDirectory();
}
String
ArchPluginUnix::getCurrentVersion(const String& name, void* handle)
{
char* version = (char*)invoke(name.c_str(), "version", NULL, handle);
if (version == NULL) {
return "";
}
return version;
}
void
sendEvent(const char* eventName, void* data)
{
LOG((CLOG_DEBUG5 "plugin sending event"));
Event::Type type = g_events->getRegisteredType(eventName);
g_events->addEvent(Event(type, g_eventTarget, data));
}
void
log(const char* text)
{
LOG((CLOG_DEBUG "plugin: %s", text));
}

View File

@ -1,53 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* 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/>.
*/
#pragma once
#include "arch/IArchPlugin.h"
#define ARCH_PLUGIN ArchPluginUnix
class IEventQueue;
//! Unix implementation of IArchPlugin
class ArchPluginUnix : public IArchPlugin {
public:
ArchPluginUnix();
virtual ~ArchPluginUnix();
// IArchPlugin overrides
void load();
void unload();
void init(void* log, void* arch);
void initEvent(void* eventTarget, IEventQueue* events);
bool exists(const char* name);
virtual void* invoke(const char* pluginName,
const char* functionName,
void** args,
void* library = NULL);
private:
String getPluginsDir();
String getCurrentVersion(const String& name, void* handle);
private:
PluginTable m_pluginTable;
};
void sendEvent(const char* text, void* data);
void log(const char* text);

View File

@ -1,250 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* 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 "arch/win32/ArchPluginWindows.h"
#include "arch/win32/XArchWindows.h"
#include "common/PluginVersion.h"
#include "base/Log.h"
#include "base/IEventQueue.h"
#include "base/Event.h"
#include "synergy/Screen.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <iostream>
typedef void (*initFunc)(void*, void*);
typedef int (*initEventFunc)(void (*sendEvent)(const char*, void*));
typedef void* (*invokeFunc)(const char*, void**);
typedef void (*cleanupFunc)();
void* g_eventTarget = NULL;
IEventQueue* g_events = NULL;
static const char * kPre174Plugin = "Pre-1.7.v";
ArchPluginWindows::ArchPluginWindows()
{
}
ArchPluginWindows::~ArchPluginWindows()
{
}
void
ArchPluginWindows::load()
{
String dir = getPluginsDir();
LOG((CLOG_DEBUG "plugins dir: %s", dir.c_str()));
String pattern = String(dir).append("\\*.dll");
std::vector<String> plugins;
getFilenames(pattern, plugins);
std::vector<String>::iterator it;
for (it = plugins.begin(); it != plugins.end(); ++it) {
String filename = *it;
String name = synergy::string::removeFileExt(filename);
String path = synergy::string::sprintf(
"%s\\%s", dir.c_str(), filename.c_str());
LOG((CLOG_DEBUG "loading plugin: %s", filename.c_str()));
HINSTANCE handle = LoadLibrary(path.c_str());
void* voidHandle = reinterpret_cast<void*>(handle);
if (handle == NULL) {
String error = XArchEvalWindows().eval();
LOG((CLOG_ERR "failed to load plugin '%s', error: %s",
filename.c_str(), error.c_str()));
continue;
}
String expectedVersion = getExpectedPluginVersion(name.c_str());
String currentVersion = getCurrentVersion(name.c_str(), voidHandle);
if (currentVersion.empty() || (expectedVersion != currentVersion)) {
LOG((CLOG_ERR
"failed to load plugin '%s', "
"expected version %s but was %s",
filename.c_str(),
expectedVersion.c_str(),
currentVersion.empty() ? "unknown" : currentVersion.c_str()));
FreeLibrary(handle);
continue;
}
LOG((CLOG_DEBUG "plugin loaded: %s (version %s)",
filename.c_str(),
currentVersion.c_str()));
m_pluginTable.insert(std::make_pair(name, voidHandle));
}
}
void
ArchPluginWindows::unload()
{
PluginTable::iterator it;
HINSTANCE lib;
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
lib = reinterpret_cast<HINSTANCE>(it->second);
cleanupFunc cleanup = (cleanupFunc)GetProcAddress(lib, "cleanup");
if (cleanup != NULL) {
cleanup();
}
else {
LOG((CLOG_DEBUG "no cleanup function in %s", it->first.c_str()));
}
LOG((CLOG_DEBUG "unloading plugin: %s", it->first.c_str()));
FreeLibrary(lib);
}
}
void
ArchPluginWindows::init(void* log, void* arch)
{
PluginTable::iterator it;
HINSTANCE lib;
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
lib = reinterpret_cast<HINSTANCE>(it->second);
initFunc initPlugin = (initFunc)GetProcAddress(lib, "init");
if (initPlugin != NULL) {
initPlugin(log, arch);
}
else {
LOG((CLOG_DEBUG "no init function in %s", it->first.c_str()));
}
}
}
void
ArchPluginWindows::initEvent(void* eventTarget, IEventQueue* events)
{
g_eventTarget = eventTarget;
g_events = events;
PluginTable::iterator it;
HINSTANCE lib;
for (it = m_pluginTable.begin(); it != m_pluginTable.end(); it++) {
lib = reinterpret_cast<HINSTANCE>(it->second);
initEventFunc initEventPlugin = (initEventFunc)GetProcAddress(lib, "initEvent");
if (initEventPlugin != NULL) {
initEventPlugin(&sendEvent);
}
else {
LOG((CLOG_DEBUG "no init event function in %s", it->first.c_str()));
}
}
}
bool
ArchPluginWindows::exists(const char* name)
{
PluginTable::iterator it;
it = m_pluginTable.find(name);
return it != m_pluginTable.end() ? true : false;
}
void*
ArchPluginWindows::invoke(
const char* plugin,
const char* command,
void** args,
void* library)
{
HINSTANCE lib = NULL;
if (library == NULL) {
PluginTable::iterator it;
it = m_pluginTable.find(plugin);
if (it != m_pluginTable.end()) {
lib = reinterpret_cast<HINSTANCE>(it->second);
}
else {
LOG((CLOG_DEBUG "invoke command failed, plugin: %s command: %s",
plugin, command));
return NULL;
}
}
else {
lib = reinterpret_cast<HINSTANCE>(library);
}
invokeFunc invokePlugin = (invokeFunc)GetProcAddress(lib, "invoke");
void* result = NULL;
if (invokePlugin != NULL) {
result = invokePlugin(command, args);
}
else {
LOG((CLOG_DEBUG "no invoke function in %s", plugin));
}
return result;
}
void
ArchPluginWindows::getFilenames(const String& pattern, std::vector<String>& filenames)
{
WIN32_FIND_DATA data;
HANDLE find = FindFirstFile(pattern.c_str(), &data);
if (find == INVALID_HANDLE_VALUE) {
FindClose(find);
LOG((CLOG_DEBUG "plugins dir is empty: %s", pattern.c_str()));
return;
}
do {
filenames.push_back(data.cFileName);
} while (FindNextFile(find, &data));
FindClose(find);
}
String
ArchPluginWindows::getPluginsDir()
{
return ARCH->getPluginDirectory();
}
String
ArchPluginWindows::getCurrentVersion(const String& name, void* handle)
{
char* version = (char*)invoke(name.c_str(), "version", NULL, handle);
if (version == NULL) {
return "";
}
return version;
}
void
sendEvent(const char* eventName, void* data)
{
LOG((CLOG_DEBUG5 "plugin sending event"));
Event::Type type = g_events->getRegisteredType(eventName);
g_events->addEvent(Event(type, g_eventTarget, data));
}
void
log(const char* text)
{
LOG((CLOG_DEBUG "plugin: %s", text));
}

View File

@ -1,57 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* 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/>.
*/
#pragma once
#include "arch/IArchPlugin.h"
#include <vector>
#define ARCH_PLUGIN ArchPluginWindows
class Screen;
class IEventQueue;
//! Windows implementation of IArchPlugin
class ArchPluginWindows : public IArchPlugin {
public:
ArchPluginWindows();
virtual ~ArchPluginWindows();
// IArchPlugin overrides
void load();
void unload();
void init(void* log, void* arch);
void initEvent(void* eventTarget, IEventQueue* events);
bool exists(const char* name);
void* invoke(const char* pluginName,
const char* functionName,
void** args,
void* library = NULL);
private:
void getFilenames(const String& pattern, std::vector<String>& filenames);
String getPluginsDir();
String getCurrentVersion(const String& name, void* handle);
private:
PluginTable m_pluginTable;
};
void sendEvent(const char* text, void* data);
void log(const char* text);

View File

@ -1,36 +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 "PluginVersion.h"
#include <string.h>
static const char kUnknownVersion[] = "unknown";
const char* s_pluginNames[] = { "ns" };
static const char* s_pluginVersions[] = { "1.3" };
const char* getExpectedPluginVersion(const char* name)
{
for (int i = 0; i < kPluginCount; i++) {
if (strcmp(name, s_pluginNames[i]) == 0) {
return s_pluginVersions[i];
break;
}
}
return kUnknownVersion;
}

View File

@ -1,31 +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/>.
*/
#pragma once
enum EPluginType {
kSecureSocket,
kPluginCount
};
extern const char* s_pluginNames[];
//! Get expected plugin version
/*!
Returns the plugin version expected by the plugin loader.
*/
const char* getExpectedPluginVersion(const char* name);

View File

@ -1,28 +0,0 @@
# synergy -- mouse and keyboard sharing utility
# Copyright (C) 2012-2016 Symless Ltd.
# Copyright (C) 2012 Nick Bolton
#
# 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/>.
if (WIN32)
add_subdirectory(winmmjoy)
endif()
if (APPLE)
# 10.7 should be supported, but gives is a _NXArgv linker error
if (OSX_TARGET_MINOR GREATER 7)
add_subdirectory(ns)
endif()
else()
add_subdirectory(ns)
endif()

View File

@ -1,128 +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/>.
file(GLOB headers "*.h")
file(GLOB sources "*.cpp")
if (SYNERGY_ADD_HEADERS)
list(APPEND sources ${headers})
endif()
if (WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OPENSSL_PLAT_DIR openssl-win64)
else()
set(OPENSSL_PLAT_DIR openssl-win32)
endif()
set(OPENSSL_INCLUDE ../../../../ext/${OPENSSL_PLAT_DIR}/inc32)
endif()
if (APPLE)
set(OPENSSL_PLAT_DIR openssl-osx)
set(OPENSSL_INCLUDE ../../../../ext/${OPENSSL_PLAT_DIR}/include)
endif()
include_directories(
../../../lib/
../../../..
${OPENSSL_INCLUDE}
)
add_library(ns SHARED ${sources})
if (WIN32)
set(OPENSSL_LIBS
${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/out32dll/libeay32.lib
${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/out32dll/ssleay32.lib
)
endif()
if (UNIX)
if (APPLE)
set(OPENSSL_LIBS
${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/libssl.a
${CMAKE_SOURCE_DIR}/ext/${OPENSSL_PLAT_DIR}/libcrypto.a
)
else()
set(OPENSSL_LIBS ssl crypto)
endif()
endif()
target_link_libraries(ns
arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS})
if (WIN32)
add_custom_command(
TARGET ns
POST_BUILD
COMMAND xcopy /Y /Q
..\\..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\ns.*
..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\plugins\\
)
add_custom_command(
TARGET ns
POST_BUILD
COMMAND xcopy /Y /Q
..\\..\\..\\..\\..\\ext\\${OPENSSL_PLAT_DIR}\\out32dll\\libeay32.*
..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}
)
add_custom_command(
TARGET ns
POST_BUILD
COMMAND xcopy /Y /Q
..\\..\\..\\..\\..\\ext\\${OPENSSL_PLAT_DIR}\\out32dll\\ssleay32.*
..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}
)
endif()
if (UNIX)
if (APPLE)
add_custom_command(
TARGET ns
POST_BUILD
COMMAND
mkdir -p
${CMAKE_SOURCE_DIR}/bin/${CMAKE_CFG_INTDIR}/plugins
&&
cp
${CMAKE_SOURCE_DIR}/lib/${CMAKE_CFG_INTDIR}/libns.*
${CMAKE_SOURCE_DIR}/bin/${CMAKE_CFG_INTDIR}/plugins/
)
else()
if (CMAKE_BUILD_TYPE STREQUAL Debug)
add_custom_command(
TARGET ns
POST_BUILD
COMMAND mkdir -p
${CMAKE_SOURCE_DIR}/bin/debug/plugins
&&
cp
${CMAKE_SOURCE_DIR}/lib/debug/libns.*
${CMAKE_SOURCE_DIR}/bin/debug/plugins/
)
else()
add_custom_command(
TARGET ns
POST_BUILD
COMMAND mkdir -p
${CMAKE_SOURCE_DIR}/bin/plugins
&&
cp
${CMAKE_SOURCE_DIR}/lib/libns.*
${CMAKE_SOURCE_DIR}/bin/plugins/
)
endif()
endif()
endif()

View File

@ -1,127 +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 "ns.h"
#include "SecureSocket.h"
#include "SecureListenSocket.h"
#include "arch/Arch.h"
#include "common/PluginVersion.h"
#include "base/Log.h"
#include <iostream>
#include <sstream>
#include <vector>
#include <iterator>
SecureSocket* g_secureSocket = NULL;
SecureListenSocket* g_secureListenSocket = NULL;
Arch* g_arch = NULL;
Log* g_log = NULL;
std::string
helperGetLibsUsed(void)
{
std::stringstream libs(ARCH->getLibsUsed());
std::string msg;
std::string pid;
std::getline(libs,pid);
while( std::getline(libs,msg) ) {
LOG(( CLOG_DEBUG "libs:%s",msg.c_str()));
}
return pid;
}
extern "C" {
void
init(void* log, void* arch)
{
if (g_log == NULL) {
g_log = new Log(reinterpret_cast<Log*>(log));
}
if (g_arch == NULL) {
Arch::setInstance(reinterpret_cast<Arch*>(arch));
}
LOG(( CLOG_DEBUG "library use: %s", helperGetLibsUsed().c_str()));
}
int
initEvent(void (*sendEvent)(const char*, void*))
{
return 0;
}
void*
invoke(const char* command, void** args)
{
IEventQueue* arg1 = NULL;
SocketMultiplexer* arg2 = NULL;
if (args != NULL) {
arg1 = reinterpret_cast<IEventQueue*>(args[0]);
arg2 = reinterpret_cast<SocketMultiplexer*>(args[1]);
}
if (strcmp(command, "getSocket") == 0) {
if (g_secureSocket != NULL) {
delete g_secureSocket;
}
g_secureSocket = new SecureSocket(arg1, arg2);
g_secureSocket->initSsl(false);
return g_secureSocket;
}
else if (strcmp(command, "getListenSocket") == 0) {
if (g_secureListenSocket != NULL) {
delete g_secureListenSocket;
}
g_secureListenSocket = new SecureListenSocket(arg1, arg2);
return g_secureListenSocket;
}
else if (strcmp(command, "deleteSocket") == 0) {
if (g_secureSocket != NULL) {
delete g_secureSocket;
g_secureSocket = NULL;
}
}
else if (strcmp(command, "deleteListenSocket") == 0) {
if (g_secureListenSocket != NULL) {
delete g_secureListenSocket;
g_secureListenSocket = NULL;
}
}
else if (strcmp(command, "version") == 0) {
return (void*)getExpectedPluginVersion(s_pluginNames[kSecureSocket]);
}
return NULL;
}
void
cleanup()
{
if (g_secureSocket != NULL) {
delete g_secureSocket;
}
if (g_secureListenSocket != NULL) {
delete g_secureListenSocket;
}
}
}

View File

@ -1,41 +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/>.
*/
#pragma once
#if defined _WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#if defined(ns_EXPORTS)
#define NS_API __declspec(dllexport)
#else
#define NS_API __declspec(dllimport)
#endif
#else
#define NS_API
#endif
extern "C" {
NS_API void init(void* log, void* arch);
NS_API int initEvent(void (*sendEvent)(const char*, void*));
NS_API void* invoke(const char* command, void** args);
NS_API void cleanup();
}

View File

@ -1,32 +0,0 @@
# synergy -- mouse and keyboard sharing utility
# Copyright (C) 2012-2016 Symless Ltd.
# Copyright (C) 2012 Nick Bolton
#
# 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/>.
file(GLOB headers "*.h")
file(GLOB sources "*.cpp")
if (SYNERGY_ADD_HEADERS)
list(APPEND sources ${headers})
endif()
add_library(winmmjoy SHARED ${sources})
add_custom_command(
TARGET winmmjoy
POST_BUILD
COMMAND xcopy /Y /Q
..\\..\\..\\..\\..\\lib\\${CMAKE_CFG_INTDIR}\\winmmjoy.*
..\\..\\..\\..\\..\\bin\\${CMAKE_CFG_INTDIR}\\plugins\\
)

View File

@ -1,106 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* 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 "winmmjoy.h"
#include <MMSystem.h>
#include <iostream>
#include <sstream>
#pragma comment(lib, "winmm.lib")
std::stringstream _logStream;
#define LOG(s) \
_logStream.str(""); \
_logStream << "winmmjoy: " << s << std::endl; \
s_log(_logStream.str().c_str())
static bool s_running = true;
static void (*s_sendEvent)(const char*, void*) = NULL;
static void (*s_log)(const char*) = NULL;
extern "C" {
void
init(void* log, void* arch)
{
}
int
initEvent(void (*sendEvent)(const char*, void*))
{
s_sendEvent = sendEvent;
CreateThread(NULL, 0, mainLoop, NULL, 0, NULL);
return 0;
}
void
cleanup()
{
s_running = false;
}
}
DWORD WINAPI
mainLoop(void* data)
{
// TODO: use a different message - e.g. DPLG%s (data - plugin)
const char* buttonsEvent = "IPrimaryScreen::getGameDeviceButtonsEvent";
const char* sticksEvent = "IPrimaryScreen::getGameDeviceSticksEvent";
const char* triggersEvent = "IPrimaryScreen::getGameDeviceTriggersEvent";
JOYINFOEX joyInfo;
ZeroMemory(&joyInfo, sizeof(joyInfo));
joyInfo.dwSize = sizeof(joyInfo);
joyInfo.dwFlags = JOY_RETURNALL;
// note: synergy data is often 16-bit, where winmm is 32-bit.
UINT index = JOYSTICKID1;
DWORD buttons, buttonsLast = 0;
DWORD xPos, xPosLast = 0;
DWORD yPos, yPosLast = 0;
while (s_running) {
if (joyGetPosEx(index, &joyInfo) != JOYERR_NOERROR) {
Sleep(1000);
continue;
}
buttons = joyInfo.dwButtons;
xPos = joyInfo.dwXpos;
yPos = joyInfo.dwYpos;
if (buttons != buttonsLast) {
s_sendEvent(buttonsEvent,
new CGameDeviceButtonInfo(index, (GameDeviceButton)joyInfo.dwButtons));
}
if (xPos != xPosLast || yPos != yPosLast) {
s_sendEvent(sticksEvent,
new CGameDeviceStickInfo(index, (short)xPos, (short)yPos, 0, 0));
}
buttonsLast = buttons;
xPosLast = xPos;
yPosLast = yPos;
Sleep(1);
}
return 0;
}

View File

@ -1,72 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* 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/>.
*/
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#if defined(winmmjoy_EXPORTS)
#define WINMMJOY_API __declspec(dllexport)
#else
#define WINMMJOY_API __declspec(dllimport)
#endif
extern "C" {
WINMMJOY_API void init(void* log, void* arch);
WINMMJOY_API int initEvent(void (*sendEvent)(const char*, void*));
WINMMJOY_API void cleanup();
}
DWORD WINAPI mainLoop(void* data);
typedef unsigned char GameDeviceID;
typedef unsigned short GameDeviceButton;
class CGameDeviceButtonInfo {
public:
CGameDeviceButtonInfo(GameDeviceID id, GameDeviceButton buttons) :
m_id(id), m_buttons(buttons) { }
public:
GameDeviceID m_id;
GameDeviceButton m_buttons;
};
class CGameDeviceStickInfo {
public:
CGameDeviceStickInfo(GameDeviceID id, short x1, short y1, short x2, short y2) :
m_id(id), m_x1(x1), m_x2(x2), m_y1(y1), m_y2(y2) { }
public:
GameDeviceID m_id;
short m_x1;
short m_x2;
short m_y1;
short m_y2;
};
class CGameDeviceTriggerInfo {
public:
CGameDeviceTriggerInfo(GameDeviceID id, unsigned char t1, unsigned char t2) :
m_id(id), m_t1(t1), m_t2(t2) { }
public:
GameDeviceID m_id;
unsigned char m_t1;
unsigned char m_t2;
};