From 4bf1eeb0652df406b8469e88425db98f4270761f Mon Sep 17 00:00:00 2001 From: Adam Potolsky Date: Fri, 29 May 2015 16:47:51 -0700 Subject: [PATCH 1/6] Removed unnecessary method and static data #4696 --- src/gui/src/Plugin.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/gui/src/Plugin.cpp b/src/gui/src/Plugin.cpp index 4c1729fb..d5ce909a 100644 --- a/src/gui/src/Plugin.cpp +++ b/src/gui/src/Plugin.cpp @@ -42,17 +42,14 @@ static const char kLinuxPackagePlatformRpm64[] = "Linux-x86_64-rpm"; #if defined(Q_OS_WIN) static const char kWinPluginExt[] = ".dll"; static const char kInstallerPluginLocation[] = "C:/Program Files/Synergy/Plugins/"; //TODO: needs proper windows %X% notation -static const char kUserPluginLocation[] = "C:/Users/speaker/AppData/Local/Synergy/Plugins";//TODO: needs proper windows %X% notation #elif defined(Q_OS_MAC) static const char kMacPluginPrefix[] = "lib"; static const char kMacPluginExt[] = ".dylib"; static const char kInstallerPluginLocation[] = "/usr/lib/synergy/plugins"; -static const char kUserPluginLocation[] = "/home/speaker/.synergy/plugins";//TODO: needs proper unix notation #else static const char kLinuxPluginPrefix[] = "lib"; static const char kLinuxPluginExt[] = ".so"; static const char kInstallerPluginLocation[] = "/usr/lib/synergy/plugins"; -static const char kUserPluginLocation[] = "/home/speaker/.synergy/plugins";//TODO: needs proper MacOS X notation #endif QString Plugin::getOsSpecificExt() @@ -83,8 +80,3 @@ QString Plugin::getOsSpecificName(const QString& pluginName) QString Plugin::getOsSpecificInstallerLocation() { return kInstallerPluginLocation; } - -QString Plugin::getOsSpecificUserLocation() { - return kUserPluginLocation; -} - From 98bb9b3fb3353b71e567ea50fb53090fa30b3b47 Mon Sep 17 00:00:00 2001 From: Adam Potolsky Date: Mon, 1 Jun 2015 16:43:27 -0700 Subject: [PATCH 2/6] Added getInstalledDir to ToolApp. #4696 --- src/lib/synergy/ArgParser.cpp | 4 ++++ src/lib/synergy/ToolApp.cpp | 5 ++++- src/lib/synergy/ToolArgs.cpp | 1 + src/lib/synergy/ToolArgs.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/synergy/ArgParser.cpp b/src/lib/synergy/ArgParser.cpp index a2021481..91a9c866 100644 --- a/src/lib/synergy/ArgParser.cpp +++ b/src/lib/synergy/ArgParser.cpp @@ -180,6 +180,10 @@ ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv) args.m_getPluginList = true; return true; } + else if (isArg(i, argc, argv, NULL, "--get-installed-dir", 0)) { + args.m_getInstalledDir = true; + return true; + } else if (isArg(i, argc, argv, NULL, "--get-plugin-dir", 0)) { args.m_getPluginDir = true; return true; diff --git a/src/lib/synergy/ToolApp.cpp b/src/lib/synergy/ToolApp.cpp index aa82fc88..ade16693 100644 --- a/src/lib/synergy/ToolApp.cpp +++ b/src/lib/synergy/ToolApp.cpp @@ -74,6 +74,9 @@ ToolApp::run(int argc, char** argv) else if (m_args.m_getPluginList) { getPluginList(); } + else if (m_args.m_getInstalledDir) { + std::cout << ARCH->getInstalledDirectory() << std::endl; + } else if (m_args.m_getPluginDir) { std::cout << ARCH->getPluginDirectory() << std::endl; } @@ -143,4 +146,4 @@ ToolApp::getPluginList() ss << "&password=" << password; std::cout << ARCH->internet().get(ss.str()) << std::endl; -} +} \ No newline at end of file diff --git a/src/lib/synergy/ToolArgs.cpp b/src/lib/synergy/ToolArgs.cpp index 5abd5476..8c3af4f1 100644 --- a/src/lib/synergy/ToolArgs.cpp +++ b/src/lib/synergy/ToolArgs.cpp @@ -22,6 +22,7 @@ ToolArgs::ToolArgs() : m_loginAuthenticate(false), m_getPluginList(false), m_getPluginDir(false), + m_getInstalledDir(false), m_getProfileDir(false) { } diff --git a/src/lib/synergy/ToolArgs.h b/src/lib/synergy/ToolArgs.h index c194c748..fe0d1bb9 100644 --- a/src/lib/synergy/ToolArgs.h +++ b/src/lib/synergy/ToolArgs.h @@ -28,6 +28,7 @@ public: bool m_loginAuthenticate; bool m_getPluginList; bool m_getPluginDir; + bool m_getInstalledDir; bool m_getProfileDir; bool m_getArch; }; From 5d770d420416bee66f40c21746891581449363a6 Mon Sep 17 00:00:00 2001 From: Adam Potolsky Date: Mon, 1 Jun 2015 16:43:57 -0700 Subject: [PATCH 3/6] Added getInstallDir to Core Interface #4696 --- src/gui/src/CoreInterface.cpp | 6 ++++++ src/gui/src/CoreInterface.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/gui/src/CoreInterface.cpp b/src/gui/src/CoreInterface.cpp index 0dea0ad6..3f1b666b 100644 --- a/src/gui/src/CoreInterface.cpp +++ b/src/gui/src/CoreInterface.cpp @@ -39,6 +39,12 @@ QString CoreInterface::getProfileDir() return run(args); } +QString CoreInterface::getInstalledDir() +{ + QStringList args("--get-installed-dir"); + return run(args); +} + QString CoreInterface::getArch() { QStringList args("--get-arch"); diff --git a/src/gui/src/CoreInterface.h b/src/gui/src/CoreInterface.h index 2c6a01ab..55d954c1 100644 --- a/src/gui/src/CoreInterface.h +++ b/src/gui/src/CoreInterface.h @@ -26,6 +26,7 @@ public: QString getPluginDir(); QString getProfileDir(); + QString getInstalledDir(); QString getArch(); QString run(const QStringList& args, const QString& input = ""); }; From 4a7fdabd658bb05b18601bef7e0bebed0684ae58 Mon Sep 17 00:00:00 2001 From: Adam Potolsky Date: Mon, 1 Jun 2015 16:46:33 -0700 Subject: [PATCH 4/6] Added Installed Dir to PluginManager #4696 --- src/gui/src/PluginManager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/src/PluginManager.h b/src/gui/src/PluginManager.h index f6bdb5e4..cb9ef4af 100644 --- a/src/gui/src/PluginManager.h +++ b/src/gui/src/PluginManager.h @@ -64,6 +64,7 @@ private: QStringList m_FileSysPluginList; QString m_PluginDir; QString m_ProfileDir; + QString m_InstalledDir; CoreInterface m_CoreInterface; SslCertificate m_SslCertificate; }; From c1158ea7f9c8a2c87eb58a67240da8859e5fb2f4 Mon Sep 17 00:00:00 2001 From: Adam Potolsky Date: Mon, 1 Jun 2015 16:48:12 -0700 Subject: [PATCH 5/6] Removed speaker and system hard coded locations from code #4696 Removed previously commended out code that is unnecessary #4696 --- src/gui/src/Plugin.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/gui/src/Plugin.cpp b/src/gui/src/Plugin.cpp index d5ce909a..e2555399 100644 --- a/src/gui/src/Plugin.cpp +++ b/src/gui/src/Plugin.cpp @@ -18,16 +18,6 @@ #include "Plugin.h" #include "CoreInterface.h" -//#include "CommandProcess.h" -//#include "DataDownloader.h" -//#include "QUtility.h" -//#include "ProcessorArch.h" -//#include "Fingerprint.h" - -//#include -//#include -//#include -//#include static const char kBaseUrl[] = "http://synergy-project.org/files"; static const char kDefaultVersion[] = "1.1"; @@ -41,15 +31,15 @@ static const char kLinuxPackagePlatformRpm64[] = "Linux-x86_64-rpm"; #if defined(Q_OS_WIN) static const char kWinPluginExt[] = ".dll"; -static const char kInstallerPluginLocation[] = "C:/Program Files/Synergy/Plugins/"; //TODO: needs proper windows %X% notation +static const char kInstallerPluginLocation[] = "Plugins"; #elif defined(Q_OS_MAC) static const char kMacPluginPrefix[] = "lib"; static const char kMacPluginExt[] = ".dylib"; -static const char kInstallerPluginLocation[] = "/usr/lib/synergy/plugins"; +static const char kInstallerPluginLocation[] = "plugins"; #else static const char kLinuxPluginPrefix[] = "lib"; static const char kLinuxPluginExt[] = ".so"; -static const char kInstallerPluginLocation[] = "/usr/lib/synergy/plugins"; +static const char kInstallerPluginLocation[] = "plugins"; #endif QString Plugin::getOsSpecificExt() From e784b48711fc4185663749608b0197d43e470e1b Mon Sep 17 00:00:00 2001 From: Adam Potolsky Date: Mon, 1 Jun 2015 16:50:05 -0700 Subject: [PATCH 6/6] Added use of Installed Dir for finding plugin install directory #4696 Fixed issues with file path creation #4696 --- src/gui/src/FileSysClient.cpp | 6 +++++- src/gui/src/PluginManager.cpp | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/gui/src/FileSysClient.cpp b/src/gui/src/FileSysClient.cpp index 53b759b9..439602cb 100644 --- a/src/gui/src/FileSysClient.cpp +++ b/src/gui/src/FileSysClient.cpp @@ -33,7 +33,11 @@ void FileSysClient::queryPluginList() QString extension = "*" + Plugin::getOsSpecificExt(); QStringList nameFilter(extension); - QString searchDirectory(Plugin::getOsSpecificInstallerLocation()); + QString installDir(m_CoreInterface.getInstalledDir() + .append(QDir::separator()) + .append(Plugin::getOsSpecificInstallerLocation())); + + QString searchDirectory(installDir); QDir directory(searchDirectory); diff --git a/src/gui/src/PluginManager.cpp b/src/gui/src/PluginManager.cpp index 371194a2..ee6e1011 100644 --- a/src/gui/src/PluginManager.cpp +++ b/src/gui/src/PluginManager.cpp @@ -49,6 +49,11 @@ void PluginManager::initFromFileSys(QStringList pluginList) 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.")); + } } PluginManager::~PluginManager() @@ -77,7 +82,8 @@ 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 = Plugin::getOsSpecificInstallerLocation(); + QString srcDirName(m_InstalledDir.append(QDir::separator()) + .append(Plugin::getOsSpecificInstallerLocation())); QDir srcDir(srcDirName); if (!srcDir.exists()) { emit info( @@ -96,10 +102,10 @@ void PluginManager::copyPlugins() // Run through the list of plugins and copy them for ( int i = 0 ; i < m_FileSysPluginList.size() ; i++ ) { // Get a file entry for the plugin using the full path - QFile file(srcDirName + m_FileSysPluginList.at(i)); + QFile file(srcDirName + QDir::separator() + m_FileSysPluginList.at(i)); + // construct the destination file name - QString newName = destDirName; - newName.append(QDir::separator()).append(m_FileSysPluginList.at(i)); + QString newName(destDirName + QDir::separator() + m_FileSysPluginList.at(i)); // Check to see if the plugin already exists QFile newFile(newName);