diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 0abb5715..fdee073c 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -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 { diff --git a/src/gui/src/PluginManager.cpp b/src/gui/src/PluginManager.cpp index 31ec2858..92b9f910 100644 --- a/src/gui/src/PluginManager.cpp +++ b/src/gui/src/PluginManager.cpp @@ -24,6 +24,7 @@ #include "ProcessorArch.h" #include "Fingerprint.h" #include "Plugin.h" +#include "../lib/common/PluginVersion.h" #include @@ -32,6 +33,7 @@ #include #include + 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; } diff --git a/src/lib/arch/win32/ArchPluginWindows.cpp b/src/lib/arch/win32/ArchPluginWindows.cpp index bd0f6832..81fd7a32 100644 --- a/src/lib/arch/win32/ArchPluginWindows.cpp +++ b/src/lib/arch/win32/ArchPluginWindows.cpp @@ -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(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)); } } diff --git a/src/lib/common/PluginVersion.cpp b/src/lib/common/PluginVersion.cpp new file mode 100644 index 00000000..35a8ceb5 --- /dev/null +++ b/src/lib/common/PluginVersion.cpp @@ -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 . + */ + +#include "PluginVersion.h" + +#include + +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; +} diff --git a/src/lib/common/PluginVersion.h b/src/lib/common/PluginVersion.h new file mode 100644 index 00000000..40c6ac94 --- /dev/null +++ b/src/lib/common/PluginVersion.h @@ -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 . + */ + +#pragma once + +// return plugin version map +const char* pluginVersion(const char* pluginName); diff --git a/src/lib/plugin/ns/ns.cpp b/src/lib/plugin/ns/ns.cpp index 7498ef0d..0fc2161a 100644 --- a/src/lib/plugin/ns/ns.cpp +++ b/src/lib/plugin/ns/ns.cpp @@ -20,6 +20,7 @@ #include "SecureSocket.h" #include "SecureListenSocket.h" #include "arch/Arch.h" +#include "common/PluginVersion.h" #include "base/Log.h" #include @@ -27,11 +28,11 @@ #include #include -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;