Only loaded matching plugin on Windows #4866
Conflicts: src/gui/gui.pro src/gui/src/PluginManager.cpp src/lib/arch/win32/ArchPluginWindows.cpp
This commit is contained in:
parent
02902066a4
commit
a249c38b96
|
@ -59,7 +59,9 @@ SOURCES += src/main.cpp \
|
|||
src/SslCertificate.cpp \
|
||||
src/FileSysClient.cpp \
|
||||
src/Plugin.cpp \
|
||||
src/WebClient.cpp
|
||||
src/WebClient.cpp \
|
||||
../lib/common/PluginVersion.cpp
|
||||
|
||||
HEADERS += src/MainWindow.h \
|
||||
src/AboutDialog.h \
|
||||
src/ServerConfig.h \
|
||||
|
@ -106,6 +108,8 @@ HEADERS += src/MainWindow.h \
|
|||
src/FileSysClient.h \
|
||||
src/Plugin.h \
|
||||
src/WebClient.h
|
||||
../lib/common/PluginVersion.h
|
||||
|
||||
RESOURCES += res/Synergy.qrc
|
||||
RC_FILE = res/win/Synergy.rc
|
||||
macx {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "ProcessorArch.h"
|
||||
#include "Fingerprint.h"
|
||||
#include "Plugin.h"
|
||||
#include "../lib/common/PluginVersion.h"
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
|
@ -32,6 +33,7 @@
|
|||
#include <QProcess>
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
PluginManager::PluginManager() :
|
||||
m_FileSysPluginList()
|
||||
{
|
||||
|
@ -154,6 +156,7 @@ void PluginManager::copyPlugins()
|
|||
"plugin list. Please contact the help desk, and "
|
||||
"provide the following details.\n\n%1").arg(e.what()));
|
||||
}
|
||||
|
||||
emit copyFinished();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#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"
|
||||
|
@ -67,15 +68,23 @@ ArchPluginWindows::load()
|
|||
}
|
||||
|
||||
void* lib = reinterpret_cast<void*>(library);
|
||||
String filename = synergy::string::removeFileExt(*it);
|
||||
m_pluginTable.insert(std::make_pair(filename, lib));
|
||||
const char* version = (char*)invoke(filename.c_str(), "version",NULL);
|
||||
|
||||
if (version == NULL) {
|
||||
version = kPre174Plugin;
|
||||
String pluginName = synergy::string::removeFileExt(*it);
|
||||
m_pluginTable.insert(std::make_pair(pluginName, lib));
|
||||
|
||||
char* version = (char*)invoke(pluginName.c_str(), "version", NULL);
|
||||
String expectedVersion(pluginVersion(pluginName.c_str()));
|
||||
if (version != NULL && expectedVersion.compare(version) == 0) {
|
||||
LOG((CLOG_DEBUG "loaded plugin: %s (%s)", (*it).c_str(), version));
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_WARN "plugin version doesn't match"));
|
||||
LOG((CLOG_DEBUG "expected plugin version: %s actual plugin version: %s",
|
||||
expectedVersion.c_str(), version));
|
||||
LOG((CLOG_WARN "skip plugin: %s", (*it).c_str()));
|
||||
m_pluginTable.erase(pluginName);
|
||||
FreeLibrary(library);
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG "loaded plugin: %s (%s)", (*it).c_str(),version));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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 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 int kpluginCount = 1;
|
||||
static const char kUnknownVersion[] = "unknown";
|
||||
static const char* s_pluginNames[] = {"ns"};
|
||||
static const char* s_pluginVersions[] = {"1.2"};
|
||||
|
||||
const char* pluginVersion(const char* pluginName)
|
||||
{
|
||||
for (int i = 0; i < kpluginCount; i++) {
|
||||
if (strcmp(pluginName, s_pluginNames[i]) == 0) {
|
||||
return s_pluginVersions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return kUnknownVersion;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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 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
|
||||
|
||||
// return plugin version map
|
||||
const char* pluginVersion(const char* pluginName);
|
|
@ -20,6 +20,7 @@
|
|||
#include "SecureSocket.h"
|
||||
#include "SecureListenSocket.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "common/PluginVersion.h"
|
||||
#include "base/Log.h"
|
||||
|
||||
#include <iostream>
|
||||
|
@ -27,11 +28,11 @@
|
|||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
const char * kSynergyVers = VERSION;
|
||||
SecureSocket* g_secureSocket = NULL;
|
||||
SecureListenSocket* g_secureListenSocket = NULL;
|
||||
Arch* g_arch = NULL;
|
||||
Log* g_log = NULL;
|
||||
static const char kPluginName[] = "ns";
|
||||
|
||||
std::string
|
||||
helperGetLibsUsed(void)
|
||||
|
@ -106,7 +107,7 @@ invoke(const char* command, void** args)
|
|||
}
|
||||
}
|
||||
else if (strcmp(command, "version") == 0) {
|
||||
return (void*) kSynergyVers;
|
||||
return (void*)pluginVersion(kPluginName);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue