Changed plugin manager to use installed arch #4168
Using the processor arch to figure out which plugin to downloa is not the best idea, since a user could install 32-bit Synergy on 64-bit Windows.
This commit is contained in:
parent
40d304dc24
commit
a1bfddeb5b
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
|
|
||||||
#include "DirectoryManager.h"
|
#include "CoreInterface.h"
|
||||||
#include "CommandProcess.h"
|
#include "CommandProcess.h"
|
||||||
#include "DataDownloader.h"
|
#include "DataDownloader.h"
|
||||||
#include "QUtility.h"
|
#include "QUtility.h"
|
||||||
|
@ -57,12 +57,12 @@ PluginManager::PluginManager(QStringList pluginList) :
|
||||||
m_DownloadIndex(-1),
|
m_DownloadIndex(-1),
|
||||||
m_pPluginDownloader(NULL)
|
m_pPluginDownloader(NULL)
|
||||||
{
|
{
|
||||||
m_PluginDir = DirectoryManager::getPluginDir();
|
m_PluginDir = m_CoreInterface.getPluginDir();
|
||||||
if (m_PluginDir.isEmpty()) {
|
if (m_PluginDir.isEmpty()) {
|
||||||
emit error(tr("Failed to get plugin directory."));
|
emit error(tr("Failed to get plugin directory."));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ProfileDir = DirectoryManager::getProfileDir();
|
m_ProfileDir = m_CoreInterface.getProfileDir();
|
||||||
if (m_ProfileDir.isEmpty()) {
|
if (m_ProfileDir.isEmpty()) {
|
||||||
emit error(tr("Failed to get profile directory."));
|
emit error(tr("Failed to get profile directory."));
|
||||||
}
|
}
|
||||||
|
@ -173,37 +173,53 @@ void PluginManager::savePlugin()
|
||||||
|
|
||||||
QString PluginManager::getPluginUrl(const QString& pluginName)
|
QString PluginManager::getPluginUrl(const QString& pluginName)
|
||||||
{
|
{
|
||||||
QString result;
|
QString archName;
|
||||||
result = kPluginsBaseUrl.append(pluginName).append("/1.0/");
|
|
||||||
|
|
||||||
int arch = checkProcessorArch();
|
#if defined(Q_OS_WIN)
|
||||||
if (arch == Win_x86) {
|
|
||||||
result.append(kWinProcessorArch32);
|
try {
|
||||||
|
QString coreArch = m_CoreInterface.getArch();
|
||||||
|
if (coreArch == "x86") {
|
||||||
|
archName = kWinProcessorArch32;
|
||||||
|
}
|
||||||
|
else if (coreArch == "x64") {
|
||||||
|
archName = kWinProcessorArch64;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (arch == Win_x64) {
|
catch (...) {
|
||||||
result.append(kWinProcessorArch64);
|
emit error(tr("Could not get Windows architecture type."));
|
||||||
}
|
|
||||||
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));
|
|
||||||
return "";
|
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("/");
|
||||||
result.append(getPluginOSSpecificName(pluginName));
|
result.append(getPluginOSSpecificName(pluginName));
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,11 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "CoreInterface.h"
|
||||||
|
|
||||||
class DataDownloader;
|
class DataDownloader;
|
||||||
|
|
||||||
class PluginManager: public QObject
|
class PluginManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -61,6 +63,7 @@ private:
|
||||||
QString m_ProfileDir;
|
QString m_ProfileDir;
|
||||||
int m_DownloadIndex;
|
int m_DownloadIndex;
|
||||||
DataDownloader* m_pPluginDownloader;
|
DataDownloader* m_pPluginDownloader;
|
||||||
|
CoreInterface m_CoreInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLUGINMANAGER_H
|
#endif // PLUGINMANAGER_H
|
||||||
|
|
|
@ -181,6 +181,10 @@ ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv)
|
||||||
args.m_getProfileDir = true;
|
args.m_getProfileDir = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (isArg(i, argc, argv, NULL, "--get-arch", 0)) {
|
||||||
|
args.m_getArch = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,9 @@ ToolApp::run(int argc, char** argv)
|
||||||
else if (m_args.m_getProfileDir) {
|
else if (m_args.m_getProfileDir) {
|
||||||
std::cout << ARCH->getProfileDirectory() << std::endl;
|
std::cout << ARCH->getProfileDirectory() << std::endl;
|
||||||
}
|
}
|
||||||
|
else if (m_args.m_getArch) {
|
||||||
|
std::cout << ARCH->getPlatformName() << std::endl;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
throw XSynergy("Nothing to do");
|
throw XSynergy("Nothing to do");
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,5 @@ public:
|
||||||
bool m_getPluginList;
|
bool m_getPluginList;
|
||||||
bool m_getPluginDir;
|
bool m_getPluginDir;
|
||||||
bool m_getProfileDir;
|
bool m_getProfileDir;
|
||||||
|
bool m_getArch;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue