diff --git a/src/gui/src/PluginManager.cpp b/src/gui/src/PluginManager.cpp index 9da0dd9e..64c9577f 100644 --- a/src/gui/src/PluginManager.cpp +++ b/src/gui/src/PluginManager.cpp @@ -17,7 +17,7 @@ #include "PluginManager.h" -#include "DirectoryManager.h" +#include "CoreInterface.h" #include "CommandProcess.h" #include "DataDownloader.h" #include "QUtility.h" @@ -57,12 +57,12 @@ PluginManager::PluginManager(QStringList pluginList) : m_DownloadIndex(-1), m_pPluginDownloader(NULL) { - m_PluginDir = DirectoryManager::getPluginDir(); + m_PluginDir = m_CoreInterface.getPluginDir(); if (m_PluginDir.isEmpty()) { emit error(tr("Failed to get plugin directory.")); } - m_ProfileDir = DirectoryManager::getProfileDir(); + m_ProfileDir = m_CoreInterface.getProfileDir(); if (m_ProfileDir.isEmpty()) { emit error(tr("Failed to get profile directory.")); } @@ -173,37 +173,53 @@ void PluginManager::savePlugin() QString PluginManager::getPluginUrl(const QString& pluginName) { - QString result; - result = kPluginsBaseUrl.append(pluginName).append("/1.0/"); + QString archName; - int arch = checkProcessorArch(); - if (arch == Win_x86) { - result.append(kWinProcessorArch32); +#if defined(Q_OS_WIN) + + try { + QString coreArch = m_CoreInterface.getArch(); + if (coreArch == "x86") { + archName = kWinProcessorArch32; + } + else if (coreArch == "x64") { + archName = kWinProcessorArch64; + } } - else if (arch == Win_x64) { - result.append(kWinProcessorArch64); - } - else if (arch == Mac_i386) { - result.append(kMacProcessorArch); - } - else if (arch == Linux_rpm_i686) { - result.append(kLinuxProcessorArchRpm32); - } - else if (arch == Linux_rpm_x86_64) { - result.append(kLinuxProcessorArchRpm64); - } - else if (arch == Linux_deb_i686) { - result.append(kLinuxProcessorArchDeb32); - } - else if (arch == Linux_deb_x86_64) { - result.append(kLinuxProcessorArchDeb64); - } - else { - emit error( - tr("Failed to get the url of plugin %1 .") - .arg(pluginName)); + catch (...) { + emit error(tr("Could not get Windows architecture type.")); return ""; } + +#elif defined(Q_OS_MAC) + + archName = kMacProcessorArch; + +#else + + int arch = checkProcessorArch(); + if (arch == Linux_rpm_i686) { + archName = kLinuxProcessorArchRpm32; + } + else if (arch == Linux_rpm_x86_64) { + archName = kLinuxProcessorArchRpm64; + } + else if (arch == Linux_deb_i686) { + archName = kLinuxProcessorArchDeb32; + } + else if (arch == Linux_deb_x86_64) { + archName = kLinuxProcessorArchDeb64; + } + else { + emit error(tr("Could not get Linux architecture type.")); + return ""; + } + +#endif + + QString result; + result = kPluginsBaseUrl.append(pluginName).append("/1.0/"); + result.append(archName); result.append("/"); result.append(getPluginOSSpecificName(pluginName)); diff --git a/src/gui/src/PluginManager.h b/src/gui/src/PluginManager.h index 63c09aeb..1c93340f 100644 --- a/src/gui/src/PluginManager.h +++ b/src/gui/src/PluginManager.h @@ -22,9 +22,11 @@ #include #include +#include "CoreInterface.h" + class DataDownloader; -class PluginManager: public QObject +class PluginManager : public QObject { Q_OBJECT @@ -61,6 +63,7 @@ private: QString m_ProfileDir; int m_DownloadIndex; DataDownloader* m_pPluginDownloader; + CoreInterface m_CoreInterface; }; #endif // PLUGINMANAGER_H diff --git a/src/lib/synergy/ArgParser.cpp b/src/lib/synergy/ArgParser.cpp index c634cd26..fc4f022d 100644 --- a/src/lib/synergy/ArgParser.cpp +++ b/src/lib/synergy/ArgParser.cpp @@ -181,6 +181,10 @@ ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv) args.m_getProfileDir = true; return true; } + else if (isArg(i, argc, argv, NULL, "--get-arch", 0)) { + args.m_getArch = true; + return true; + } else { return false; } diff --git a/src/lib/synergy/ToolApp.cpp b/src/lib/synergy/ToolApp.cpp index fac45e39..4fd9518f 100644 --- a/src/lib/synergy/ToolApp.cpp +++ b/src/lib/synergy/ToolApp.cpp @@ -79,6 +79,9 @@ ToolApp::run(int argc, char** argv) else if (m_args.m_getProfileDir) { std::cout << ARCH->getProfileDirectory() << std::endl; } + else if (m_args.m_getArch) { + std::cout << ARCH->getPlatformName() << std::endl; + } else { throw XSynergy("Nothing to do"); } diff --git a/src/lib/synergy/ToolArgs.h b/src/lib/synergy/ToolArgs.h index 1ad05513..695fe0a0 100644 --- a/src/lib/synergy/ToolArgs.h +++ b/src/lib/synergy/ToolArgs.h @@ -29,4 +29,5 @@ public: bool m_getPluginList; bool m_getPluginDir; bool m_getProfileDir; + bool m_getArch; };