From c057cfaedaa3946e7e49d2691a807a0ae03211ea Mon Sep 17 00:00:00 2001 From: "Jerry (Xinyu Hou)" Date: Wed, 8 Jul 2015 15:02:47 -0700 Subject: [PATCH] Revert "Replaces plugin download with install and copy functionality #4696" This reverts commit 8d70075171b9e4fd72493304ae84e110c5e278e6. Conflicts: src/gui/gui.pro src/gui/src/FileSysClient.cpp src/gui/src/PluginWizardPage.cpp --- src/gui/gui.pro | 13 +- src/gui/src/FileSysClient.cpp | 51 ------- src/gui/src/FileSysClient.h | 63 -------- src/gui/src/Plugin.cpp | 90 ------------ src/gui/src/Plugin.h | 53 ------- src/gui/src/PluginManager.cpp | 241 +++++++++++++++++++++++-------- src/gui/src/PluginManager.h | 21 ++- src/gui/src/PluginWizardPage.cpp | 79 ++++++---- src/gui/src/PluginWizardPage.h | 9 +- 9 files changed, 246 insertions(+), 374 deletions(-) delete mode 100644 src/gui/src/FileSysClient.cpp delete mode 100644 src/gui/src/FileSysClient.h delete mode 100644 src/gui/src/Plugin.cpp delete mode 100644 src/gui/src/Plugin.h diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 0abb571533..5bbe9d3c88 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -52,14 +52,12 @@ SOURCES += src/main.cpp \ src/DataDownloader.cpp \ src/AddClientDialog.cpp \ src/CommandProcess.cpp \ + src/WebClient.cpp \ src/PluginWizardPage.cpp \ src/PluginManager.cpp \ src/CoreInterface.cpp \ src/Fingerprint.cpp \ - src/SslCertificate.cpp \ - src/FileSysClient.cpp \ - src/Plugin.cpp \ - src/WebClient.cpp + src/SslCertificate.cpp HEADERS += src/MainWindow.h \ src/AboutDialog.h \ src/ServerConfig.h \ @@ -96,16 +94,15 @@ HEADERS += src/MainWindow.h \ src/DataDownloader.h \ src/AddClientDialog.h \ src/CommandProcess.h \ + src/WebClient.h \ src/EditionType.h \ src/PluginWizardPage.h \ src/ProcessorArch.h \ src/PluginManager.h \ src/CoreInterface.h \ src/Fingerprint.h \ - src/SslCertificate.h \ - src/FileSysClient.h \ - src/Plugin.h \ - src/WebClient.h + src/SslCertificate.h + RESOURCES += res/Synergy.qrc RC_FILE = res/win/Synergy.rc macx { diff --git a/src/gui/src/FileSysClient.cpp b/src/gui/src/FileSysClient.cpp deleted file mode 100644 index 33969d291f..0000000000 --- a/src/gui/src/FileSysClient.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015 Synergy Si, Std. - * - * 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 "FileSysClient.h" - -#include "EditionType.h" -#include "QUtility.h" - -#include -#include -#include -#include -#include - -void FileSysClient::queryPluginList() -{ - try { - isDone(false); - QString extension = "*" + Plugin::getOsSpecificExt(); - QStringList nameFilter(extension); - - QString searchDirectory(Plugin::getOsSpecificInstallerLocation()); - - QDir directory(searchDirectory); - m_PluginList = directory.entryList(nameFilter); - isDone(true); - } - catch (std::exception& e) - { - isDone(true); - emit error(tr( "An error occurred while trying to load the " - "plugin list. Please contact the help desk, and " - "provide the following details.\n\n%1").arg(e.what())); - } - emit queryPluginDone(); - return; -} diff --git a/src/gui/src/FileSysClient.h b/src/gui/src/FileSysClient.h deleted file mode 100644 index dfe7ee955b..0000000000 --- a/src/gui/src/FileSysClient.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2015 Synergy Si, Std. - * - * 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 . - */ - -#ifndef FileSysClient_H -#define FileSysClient_H - -#include -#include -#include - -#include "Plugin.h" -#include "CoreInterface.h" - -class QMessageBox; -class QWidget; -class QStringList; - -class FileSysClient : public QObject -{ - Q_OBJECT - -public: - QStringList& getPluginList() { return m_PluginList; } - bool isDone() { return done; } - int count() { return copyCount; } - -public slots: - void queryPluginList(); - -signals: - void error(QString e); - void queryPluginDone(); - -private: - void isDone(bool b) { done = b; } - QString request(const QString& email, - const QString& password, - QStringList& args); - Plugin plugin; - void count(int i) { copyCount = i; } - -private: - int copyCount; - bool done; - QStringList m_PluginList; - CoreInterface m_CoreInterface; -}; - -#endif // FileSysClient_H diff --git a/src/gui/src/Plugin.cpp b/src/gui/src/Plugin.cpp deleted file mode 100644 index 4759e4e2dc..0000000000 --- a/src/gui/src/Plugin.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 "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"; -static const char kWinPackagePlatform32[] = "Windows-x86"; -static const char kWinPackagePlatform64[] = "Windows-x64"; -static const char kMacPackagePlatform[] = "MacOSX%1-i386"; -static const char kLinuxPackagePlatformDeb32[] = "Linux-i686-deb"; -static const char kLinuxPackagePlatformDeb64[] = "Linux-x86_64-deb"; -static const char kLinuxPackagePlatformRpm32[] = "Linux-i686-rpm"; -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() -{ - -#if defined(Q_OS_WIN) - return kWinPluginExt; -#elif defined(Q_OS_MAC) - return kMacPluginExt; -#else - return kLinuxPluginExt; -#endif -} - -QString Plugin::getOsSpecificName(const QString& pluginName) -{ - QString result = pluginName; -#if defined(Q_OS_WIN) - result.append(getOsSpecificExt()); -#elif defined(Q_OS_MAC) - result = kMacPluginPrefix + pluginName + getPluginOsSpecificExt(); -#else - result = kLinuxPluginPrefix + pluginName + getPluginOsSpecificExt(); -#endif - return result; -} - -QString Plugin::getOsSpecificInstallerLocation() { - return kInstallerPluginLocation; -} - -QString Plugin::getOsSpecificUserLocation() { - return kUserPluginLocation; -} - diff --git a/src/gui/src/Plugin.h b/src/gui/src/Plugin.h deleted file mode 100644 index 431e1a8068..0000000000 --- a/src/gui/src/Plugin.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 . - */ -#ifndef PLUGIN_H -#define PLUGIN_H - -#include -#include -#include - -#include "SslCertificate.h" -#include "CoreInterface.h" -#include "DataDownloader.h" - -class Plugin : public QObject -{ - Q_OBJECT - -public: - //Plugin(); - //~PluginManager(); - - static QString getOsSpecificName(const QString& pluginName); - static QString getOsSpecificExt(); - static QString getOsSpecificLocation(); - static QString getOsSpecificInstallerLocation(); - static QString getOsSpecificUserLocation(); - -public slots: - -private: -// CoreInterface m_CoreInterface; - -signals: - -private: - -}; - -#endif // PLUGIN_H diff --git a/src/gui/src/PluginManager.cpp b/src/gui/src/PluginManager.cpp index e73c93e687..fd3a24e4ff 100644 --- a/src/gui/src/PluginManager.cpp +++ b/src/gui/src/PluginManager.cpp @@ -23,23 +23,37 @@ #include "QUtility.h" #include "ProcessorArch.h" #include "Fingerprint.h" -#include "Plugin.h" #include #include #include #include -PluginManager::PluginManager() : - m_FileSysPluginList() -{ -} +static const char kBaseUrl[] = "http://synergy-project.org/files"; +static const char kDefaultVersion[] = "1.1"; +static const char kWinPackagePlatform32[] = "Windows-x86"; +static const char kWinPackagePlatform64[] = "Windows-x64"; +static const char kMacPackagePlatform[] = "MacOSX%1-i386"; +static const char kLinuxPackagePlatformDeb32[] = "Linux-i686-deb"; +static const char kLinuxPackagePlatformDeb64[] = "Linux-x86_64-deb"; +static const char kLinuxPackagePlatformRpm32[] = "Linux-i686-rpm"; +static const char kLinuxPackagePlatformRpm64[] = "Linux-x86_64-rpm"; -void PluginManager::initFromFileSys(QStringList pluginList) -{ - m_FileSysPluginList.clear(); - m_FileSysPluginList.append(pluginList); +#if defined(Q_OS_WIN) +static const char kWinPluginExt[] = ".dll"; +#elif defined(Q_OS_MAC) +static const char kMacPluginPrefix[] = "lib"; +static const char kMacPluginExt[] = ".dylib"; +#else +static const char kLinuxPluginPrefix[] = "lib"; +static const char kLinuxPluginExt[] = ".so"; +#endif + +PluginManager::PluginManager(QStringList pluginList) : + m_PluginList(pluginList), + m_DownloadIndex(-1) +{ m_PluginDir = m_CoreInterface.getPluginDir(); if (m_PluginDir.isEmpty()) { emit error(tr("Failed to get plugin directory.")); @@ -59,7 +73,7 @@ bool PluginManager::exist(QString name) { CoreInterface coreInterface; QString PluginDir = coreInterface.getPluginDir(); - QString pluginName = Plugin::getOsSpecificName(name); + QString pluginName = getPluginOsSpecificName(name); QString filename; filename.append(PluginDir); filename.append(QDir::separator()).append(pluginName); @@ -72,63 +86,166 @@ bool PluginManager::exist(QString name) return exist; } -void PluginManager::copyPlugins() +void PluginManager::downloadPlugins() { - try { - // Get the Directory where plugins are put on installation - // If it doesn't exist, there is nothing to do - QString srcDirName = Plugin::getOsSpecificInstallerLocation(); - QDir srcDir(srcDirName); - if (!srcDir.exists()) { - emit info( - tr("No plugins found to copy from %1") - .arg(srcDirName)); - emit copyFinished(); + if (m_DataDownloader.isFinished()) { + if (!savePlugin()) { + return; } - // Get the directory where Plugins are installed into Synergy - // If it doesn't exist make it - QString destDirName = m_PluginDir; - QDir destDir(destDirName); - if (!destDir.exists()) { - destDir.mkpath("."); + if (m_DownloadIndex != m_PluginList.size() - 1) { + emit downloadNext(); } - // 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)); - // construct the destination file name - QString newName = destDirName; - newName.append(QDir::separator()).append(m_FileSysPluginList.at(i)); + else { + emit downloadFinished(); + return; + } + } - QFile newFile(newName); - if(newFile.exists()) { - newFile.remove(); - } - // make a copy of the plugin in the new location - bool result = file.copy(newName); - if ( !result ) { - emit error( - tr("Failed to copy plugin '%1' to: %2\n%3") - .arg(m_FileSysPluginList.at(i)) - .arg(newName) - .arg(file.errorString())); - } - else { - emit info( - tr("Copying '%1' plugin (%2/%3)...") - .arg(m_FileSysPluginList.at(i)) - .arg(i+1) - .arg(m_FileSysPluginList.size())); - } + m_DownloadIndex++; + + if (m_DownloadIndex < m_PluginList.size()) { + QUrl url; + QString pluginUrl = getPluginUrl(m_PluginList.at(m_DownloadIndex)); + if (pluginUrl.isEmpty()) { + return; } + url.setUrl(pluginUrl); + + connect(&m_DataDownloader, SIGNAL(isComplete()), this, SLOT(downloadPlugins())); + + m_DataDownloader.download(url); } - catch (std::exception& e) - { - emit error(tr("An error occurred while trying to copy the " - "plugin list. Please contact the help desk, and " - "provide the following details.\n\n%1").arg(e.what())); - } - emit copyFinished(); - return; +} + +bool PluginManager::savePlugin() +{ + // create the path if not exist + QDir dir(m_PluginDir); + if (!dir.exists()) { + dir.mkpath("."); + } + + QString filename = m_PluginDir; + QString pluginName = m_PluginList.at(m_DownloadIndex); + pluginName = getPluginOsSpecificName(pluginName); + filename.append(QDir::separator()).append(pluginName); + + QFile file(filename); + if (!file.open(QIODevice::WriteOnly)) { + emit error( + tr("Failed to download plugin '%1' to: %2\n%3") + .arg(m_PluginList.at(m_DownloadIndex)) + .arg(m_PluginDir) + .arg(file.errorString())); + + file.close(); + return false; + } + + file.write(m_DataDownloader.data()); + file.close(); + + return true; +} + +QString PluginManager::getPluginUrl(const QString& pluginName) +{ + QString archName; + +#if defined(Q_OS_WIN) + + try { + QString coreArch = m_CoreInterface.getArch(); + if (coreArch.startsWith("x86")) { + archName = kWinPackagePlatform32; + } + else if (coreArch.startsWith("x64")) { + archName = kWinPackagePlatform64; + } + } + catch (...) { + emit error(tr("Could not get Windows architecture type.")); + return ""; + } + +#elif defined(Q_OS_MAC) + + QString macVersion = "1010"; +#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1090 // 10.9 + macVersion = "109"; +#elif __MAC_OS_X_VERSION_MIN_REQUIRED <= 1080 // 10.8 + macVersion = "108"; +#elif __MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 // 10.7 + emit error(tr("Plugins not supported on this Mac OS X version.")); + return ""; +#endif + + archName = QString(kMacPackagePlatform).arg(macVersion); + +#else + + QString program("dpkg"); + QStringList args; + args << "-s" << "synergy"; + + QProcess process; + process.setReadChannel(QProcess::StandardOutput); + process.start(program, args); + bool success = process.waitForStarted(); + + if (!success || !process.waitForFinished()) + { + emit error(tr("Could not get Linux package type.")); + return ""; + } + + bool isDeb = (process.exitCode() == 0); + + int arch = getProcessorArch(); + if (arch == kProcessorArchLinux32) { + if (isDeb) { + archName = kLinuxPackagePlatformDeb32; + } + else { + archName = kLinuxPackagePlatformRpm32; + } + } + else if (arch == kProcessorArchLinux64) { + if (isDeb) { + archName = kLinuxPackagePlatformDeb64; + } + else { + archName = kLinuxPackagePlatformRpm64; + } + } + else { + emit error(tr("Could not get Linux architecture type.")); + return ""; + } + +#endif + + QString result = QString("%1/plugins/%2/%3/%4/%5") + .arg(kBaseUrl) + .arg(pluginName) + .arg(kDefaultVersion) + .arg(archName) + .arg(getPluginOsSpecificName(pluginName)); + + qDebug() << result; + return result; +} + +QString PluginManager::getPluginOsSpecificName(const QString& pluginName) +{ + QString result = pluginName; +#if defined(Q_OS_WIN) + result.append(kWinPluginExt); +#elif defined(Q_OS_MAC) + result = kMacPluginPrefix + pluginName + kMacPluginExt; +#else + result = kLinuxPluginPrefix + pluginName + kLinuxPluginExt; +#endif + return result; } diff --git a/src/gui/src/PluginManager.h b/src/gui/src/PluginManager.h index f6bdb5e497..279e5ff43f 100644 --- a/src/gui/src/PluginManager.h +++ b/src/gui/src/PluginManager.h @@ -25,45 +25,44 @@ #include "SslCertificate.h" #include "CoreInterface.h" #include "DataDownloader.h" -#include "Plugin.h" class PluginManager : public QObject { Q_OBJECT public: - PluginManager(); + PluginManager(QStringList pluginList); ~PluginManager(); - void initFromWeb(QStringList pluginList); - void initFromFileSys(QStringList pluginList); - - int pluginCount() { return m_FileSysPluginList.count(); } + int downloadIndex() { return m_DownloadIndex; } static bool exist(QString name); public slots: - void copyPlugins(); + void downloadPlugins(); private: + bool savePlugin(); QString getPluginUrl(const QString& pluginName); bool runProgram( const QString& program, const QStringList& args, const QStringList& env); - //static QString getPluginOsSpecificName(const QString& pluginName); + static QString getPluginOsSpecificName(const QString& pluginName); signals: void error(QString e); void info(QString i); - void updateCopyStatus(int); - void copyFinished(); + void downloadNext(); + void downloadFinished(); private: - QStringList m_FileSysPluginList; + QStringList m_PluginList; QString m_PluginDir; QString m_ProfileDir; + int m_DownloadIndex; + DataDownloader m_DataDownloader; CoreInterface m_CoreInterface; SslCertificate m_SslCertificate; }; diff --git a/src/gui/src/PluginWizardPage.cpp b/src/gui/src/PluginWizardPage.cpp index 331d6a0c70..f0ee3fada5 100644 --- a/src/gui/src/PluginWizardPage.cpp +++ b/src/gui/src/PluginWizardPage.cpp @@ -19,7 +19,6 @@ #include "ui_PluginWizardPageBase.h" #include "SslCertificate.h" -#include "FileSysClient.h" #include "WebClient.h" #include "PluginManager.h" #include "MainWindow.h" @@ -31,7 +30,8 @@ PluginWizardPage::PluginWizardPage(MainWindow& mainWindow, QWidget *parent) : QWizardPage(parent), m_Finished(false), - m_pFileSysClient(NULL), + m_pWebClient(NULL), + m_pPluginManager(NULL), m_pSslCertificate(NULL), m_mainWindow(mainWindow) { @@ -46,8 +46,12 @@ PluginWizardPage::PluginWizardPage(MainWindow& mainWindow, QWidget *parent) : PluginWizardPage::~PluginWizardPage() { - if (m_pFileSysClient != NULL) { - delete m_pFileSysClient; + if (m_pWebClient != NULL) { + delete m_pWebClient; + } + + if (m_pPluginManager != NULL) { + delete m_pPluginManager; } delete m_pSslCertificate; @@ -73,20 +77,27 @@ void PluginWizardPage::showError(QString error) void PluginWizardPage::queryPluginDone() { - QStringList pluginList = m_pFileSysClient->getPluginList(); + QStringList pluginList = m_pWebClient->getPluginList(); if (pluginList.isEmpty()) { updateStatus(tr("Setup complete.")); showFinished(); } else { - m_mainWindow.stopSynergy(); - m_mainWindow.delay(5); - copyPlugins(); - m_mainWindow.startSynergy(); - m_mainWindow.delay(5); + downloadPlugins(); } } +void PluginWizardPage::updateDownloadStatus() +{ + QStringList pluginList = m_pWebClient->getPluginList(); + int index = m_pPluginManager->downloadIndex(); + updateStatus( + tr("Downloading '%1' plugin (%2/%3)...") + .arg(pluginList.at(index + 1)) + .arg(index + 2) + .arg(pluginList.size())); +} + void PluginWizardPage::finished() { // TODO: we should check if ns plugin exists @@ -121,29 +132,33 @@ void PluginWizardPage::updateStatus(QString info) m_pLabelStatus->setText(info); } -void PluginWizardPage::copyPlugins() +void PluginWizardPage::downloadPlugins() { - QStringList pluginList = m_pFileSysClient->getPluginList(); - m_PluginManager.initFromFileSys(pluginList); - + QStringList pluginList = m_pWebClient->getPluginList(); + m_pPluginManager = new PluginManager(pluginList); m_pThread = new QThread; - connect(&m_PluginManager, + connect(m_pPluginManager, SIGNAL(error(QString)), this, SLOT(showError(QString))); - connect(&m_PluginManager, + connect(m_pPluginManager, SIGNAL(info(QString)), this, SLOT(updateStatus(QString))); - connect(&m_PluginManager, - SIGNAL(copyFinished()), + connect(m_pPluginManager, + SIGNAL(downloadNext()), + this, + SLOT(updateDownloadStatus())); + + connect(m_pPluginManager, + SIGNAL(downloadFinished()), this, SLOT(generateCertificate())); - connect(&m_PluginManager, + connect(m_pPluginManager, SIGNAL(error(QString)), m_pThread, SLOT(quit())); @@ -154,14 +169,16 @@ void PluginWizardPage::copyPlugins() SLOT(deleteLater())); updateStatus( - tr("Copying plugins...")); + tr("Downloading plugin: %1 (1/%2)") + .arg(pluginList.at(0)) + .arg(pluginList.size())); - m_PluginManager.moveToThread(m_pThread); + m_pPluginManager->moveToThread(m_pThread); m_pThread->start(); QMetaObject::invokeMethod( - &m_PluginManager, - "copyPlugins", + m_pPluginManager, + "downloadPlugins", Qt::QueuedConnection); } @@ -180,7 +197,7 @@ bool PluginWizardPage::isComplete() const void PluginWizardPage::initializePage() { QWizardPage::initializePage(); - if (m_pFileSysClient == NULL) { + if (m_pWebClient == NULL) { if (m_Email.isEmpty() || m_Password.isEmpty()) { updateStatus(tr("Setup complete.")); @@ -190,38 +207,38 @@ void PluginWizardPage::initializePage() m_pLabelSpinning->show(); - m_pFileSysClient = new FileSysClient(); m_pWebClient = new WebClient(); m_pWebClient->setEmail(m_Email); m_pWebClient->setPassword(m_Password); QThread* thread = new QThread; - connect(m_pFileSysClient, + connect(m_pWebClient, SIGNAL(error(QString)), this, SLOT(showError(QString))); - connect(m_pFileSysClient, + connect(m_pWebClient, SIGNAL(queryPluginDone()), this, SLOT(queryPluginDone())); - connect(m_pFileSysClient, + connect(m_pWebClient, SIGNAL(queryPluginDone()), thread, SLOT(quit())); - connect(m_pFileSysClient, + connect(m_pWebClient, SIGNAL(error(QString)), thread, SLOT(quit())); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - m_pFileSysClient->moveToThread(thread); + m_pWebClient->moveToThread(thread); thread->start(); - QMetaObject::invokeMethod(m_pFileSysClient, "queryPluginList", Qt::QueuedConnection); + updateStatus(tr("Getting plugin list...")); + QMetaObject::invokeMethod(m_pWebClient, "queryPluginList", Qt::QueuedConnection); } } diff --git a/src/gui/src/PluginWizardPage.h b/src/gui/src/PluginWizardPage.h index 8b2006b79c..7fea23510d 100644 --- a/src/gui/src/PluginWizardPage.h +++ b/src/gui/src/PluginWizardPage.h @@ -21,11 +21,10 @@ #include "AppConfig.h" #include "ui_PluginWizardPageBase.h" -#include "PluginManager.h" #include -class FileSysClient; class WebClient; +class PluginManager; class SslCertificate; class MainWindow; @@ -51,11 +50,12 @@ protected slots: void showError(QString error); void updateStatus(QString info); void queryPluginDone(); + void updateDownloadStatus(); void finished(); void generateCertificate(); private: - void copyPlugins(); + void downloadPlugins(); void showFinished(); private: @@ -63,8 +63,7 @@ private: QString m_Email; QString m_Password; WebClient* m_pWebClient; - FileSysClient* m_pFileSysClient; - PluginManager m_PluginManager; + PluginManager* m_pPluginManager; SslCertificate* m_pSslCertificate; QThread* m_pThread; MainWindow& m_mainWindow;