2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 14:16:55 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
|
|
|
|
|
** Contact: BlackBerry (qt@blackberry.com), KDAB (info@kdab.com)
|
2014-02-10 14:16:55 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-02-10 14:16:55 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-02-10 14:16:55 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
#include "qnxdeployqtlibrariesdialog.h"
|
|
|
|
|
#include "ui_qnxdeployqtlibrariesdialog.h"
|
2014-02-10 14:16:55 +01:00
|
|
|
|
2017-01-11 14:43:48 +01:00
|
|
|
#include "qnxconstants.h"
|
2014-05-27 12:46:24 +02:00
|
|
|
#include "qnxqtversion.h"
|
2014-02-10 14:16:55 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/deployablefile.h>
|
|
|
|
|
#include <qtsupport/qtversionmanager.h>
|
|
|
|
|
#include <remotelinux/genericdirectuploadservice.h>
|
|
|
|
|
#include <ssh/sshremoteprocessrunner.h>
|
2017-01-11 14:43:48 +01:00
|
|
|
|
|
|
|
|
#include <utils/algorithm.h>
|
2014-02-10 14:16:55 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
2015-04-24 10:31:27 +02:00
|
|
|
using namespace QtSupport;
|
2016-03-15 09:26:34 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace RemoteLinux;
|
2015-04-24 10:31:27 +02:00
|
|
|
|
|
|
|
|
namespace Qnx {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2016-03-15 09:26:34 +01:00
|
|
|
QnxDeployQtLibrariesDialog::QnxDeployQtLibrariesDialog(const IDevice::ConstPtr &device,
|
2015-04-24 10:31:27 +02:00
|
|
|
QWidget *parent) :
|
|
|
|
|
QDialog(parent),
|
|
|
|
|
m_ui(new Ui::QnxDeployQtLibrariesDialog),
|
|
|
|
|
m_device(device),
|
|
|
|
|
m_progressCount(0),
|
|
|
|
|
m_state(Inactive)
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
|
2017-01-11 14:43:48 +01:00
|
|
|
const QList<BaseQtVersion*> qtVersions
|
|
|
|
|
= QtVersionManager::validVersions(Utils::equal(&BaseQtVersion::type,
|
|
|
|
|
QString::fromLatin1(Constants::QNX_QNX_QT)));
|
|
|
|
|
for (BaseQtVersion *v : qtVersions)
|
|
|
|
|
m_ui->qtLibraryCombo->addItem(v->displayName(), v->uniqueId());
|
2014-02-10 14:16:55 +01:00
|
|
|
|
2015-04-24 10:31:27 +02:00
|
|
|
m_ui->basePathLabel->setText(QString());
|
|
|
|
|
m_ui->remoteDirectory->setText(QLatin1String("/qt"));
|
2014-05-27 12:46:24 +02:00
|
|
|
|
2014-02-10 14:16:55 +01:00
|
|
|
m_uploadService = new RemoteLinux::GenericDirectUploadService(this);
|
|
|
|
|
m_uploadService->setDevice(m_device);
|
|
|
|
|
|
2016-03-15 09:26:34 +01:00
|
|
|
connect(m_uploadService, &AbstractRemoteLinuxDeployService::progressMessage,
|
|
|
|
|
this, &QnxDeployQtLibrariesDialog::updateProgress);
|
|
|
|
|
connect(m_uploadService, &AbstractRemoteLinuxDeployService::progressMessage,
|
|
|
|
|
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
|
|
|
|
connect(m_uploadService, &AbstractRemoteLinuxDeployService::errorMessage,
|
|
|
|
|
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
|
|
|
|
connect(m_uploadService, &AbstractRemoteLinuxDeployService::warningMessage,
|
|
|
|
|
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
|
|
|
|
connect(m_uploadService, &AbstractRemoteLinuxDeployService::stdOutData,
|
|
|
|
|
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
|
|
|
|
connect(m_uploadService, &AbstractRemoteLinuxDeployService::stdErrData,
|
|
|
|
|
m_ui->deployLogWindow, &QPlainTextEdit::appendPlainText);
|
|
|
|
|
connect(m_uploadService, &AbstractRemoteLinuxDeployService::finished,
|
|
|
|
|
this, &QnxDeployQtLibrariesDialog::handleUploadFinished);
|
2014-02-10 14:16:55 +01:00
|
|
|
|
|
|
|
|
m_processRunner = new QSsh::SshRemoteProcessRunner(this);
|
2016-03-15 09:26:34 +01:00
|
|
|
connect(m_processRunner, &QSsh::SshRemoteProcessRunner::connectionError,
|
|
|
|
|
this, &QnxDeployQtLibrariesDialog::handleRemoteProcessError);
|
|
|
|
|
connect(m_processRunner, &QSsh::SshRemoteProcessRunner::processClosed,
|
|
|
|
|
this, &QnxDeployQtLibrariesDialog::handleRemoteProcessCompleted);
|
|
|
|
|
|
|
|
|
|
connect(m_ui->deployButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &QnxDeployQtLibrariesDialog::deployLibraries);
|
|
|
|
|
connect(m_ui->closeButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &QWidget::close);
|
2014-02-10 14:16:55 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
QnxDeployQtLibrariesDialog::~QnxDeployQtLibrariesDialog()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
int QnxDeployQtLibrariesDialog::execAndDeploy(int qtVersionId, const QString &remoteDirectory)
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
m_ui->remoteDirectory->setText(remoteDirectory);
|
|
|
|
|
m_ui->qtLibraryCombo->setCurrentIndex(m_ui->qtLibraryCombo->findData(qtVersionId));
|
|
|
|
|
|
|
|
|
|
deployLibraries();
|
|
|
|
|
return exec();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::closeEvent(QCloseEvent *event)
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
// A disabled Deploy button indicates the upload is still running
|
|
|
|
|
if (!m_ui->deployButton->isEnabled()) {
|
|
|
|
|
int answer = QMessageBox::question(this, windowTitle(),
|
|
|
|
|
tr("Closing the dialog will stop the deployment. "
|
|
|
|
|
"Are you sure you want to do this?"),
|
|
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
|
if (answer == QMessageBox::No)
|
|
|
|
|
event->ignore();
|
|
|
|
|
else if (answer == QMessageBox::Yes)
|
|
|
|
|
m_uploadService->stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::deployLibraries()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_state == Inactive, return);
|
|
|
|
|
|
|
|
|
|
if (m_ui->remoteDirectory->text().isEmpty()) {
|
|
|
|
|
QMessageBox::warning(this, windowTitle(),
|
|
|
|
|
tr("Please input a remote directory to deploy to."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(!m_device.isNull(), return);
|
|
|
|
|
|
|
|
|
|
m_progressCount = 0;
|
|
|
|
|
m_ui->deployProgress->setValue(0);
|
|
|
|
|
m_ui->remoteDirectory->setEnabled(false);
|
|
|
|
|
m_ui->deployButton->setEnabled(false);
|
|
|
|
|
m_ui->qtLibraryCombo->setEnabled(false);
|
|
|
|
|
m_ui->deployLogWindow->clear();
|
|
|
|
|
|
|
|
|
|
checkRemoteDirectoryExistance();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::startUpload()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_state == CheckingRemoteDirectory || m_state == RemovingRemoteDirectory);
|
|
|
|
|
|
|
|
|
|
m_state = Uploading;
|
|
|
|
|
|
2016-03-15 09:26:34 +01:00
|
|
|
QList<DeployableFile> filesToUpload = gatherFiles();
|
2014-02-10 14:16:55 +01:00
|
|
|
|
|
|
|
|
m_ui->deployProgress->setRange(0, filesToUpload.count());
|
|
|
|
|
|
|
|
|
|
m_uploadService->setDeployableFiles(filesToUpload);
|
|
|
|
|
m_uploadService->start();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::updateProgress(const QString &progressMessage)
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_state == Uploading);
|
|
|
|
|
|
|
|
|
|
if (!progressMessage.startsWith(QLatin1String("Uploading file")))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
++m_progressCount;
|
|
|
|
|
|
|
|
|
|
m_ui->deployProgress->setValue(m_progressCount);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::handleUploadFinished()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
m_ui->remoteDirectory->setEnabled(true);
|
|
|
|
|
m_ui->deployButton->setEnabled(true);
|
|
|
|
|
m_ui->qtLibraryCombo->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
m_state = Inactive;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::handleRemoteProcessError()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_state == CheckingRemoteDirectory || m_state == RemovingRemoteDirectory);
|
|
|
|
|
|
|
|
|
|
m_ui->deployLogWindow->appendPlainText(
|
|
|
|
|
tr("Connection failed: %1")
|
|
|
|
|
.arg(m_processRunner->lastConnectionErrorString()));
|
|
|
|
|
handleUploadFinished();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::handleRemoteProcessCompleted()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_state == CheckingRemoteDirectory || m_state == RemovingRemoteDirectory);
|
|
|
|
|
|
|
|
|
|
if (m_state == CheckingRemoteDirectory) {
|
|
|
|
|
// Directory exists
|
|
|
|
|
if (m_processRunner->processExitCode() == 0) {
|
|
|
|
|
int answer = QMessageBox::question(this, windowTitle(),
|
2014-04-17 14:09:47 +02:00
|
|
|
tr("The remote directory \"%1\" already exists. "
|
2014-02-10 14:16:55 +01:00
|
|
|
"Deploying to that directory will remove any files "
|
|
|
|
|
"already present.\n\n"
|
|
|
|
|
"Are you sure you want to continue?")
|
|
|
|
|
.arg(fullRemoteDirectory()),
|
|
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
|
if (answer == QMessageBox::Yes)
|
|
|
|
|
removeRemoteDirectory();
|
|
|
|
|
else
|
|
|
|
|
handleUploadFinished();
|
|
|
|
|
} else {
|
|
|
|
|
startUpload();
|
|
|
|
|
}
|
|
|
|
|
} else if (m_state == RemovingRemoteDirectory) {
|
|
|
|
|
QTC_ASSERT(m_processRunner->processExitCode() == 0, return);
|
|
|
|
|
|
|
|
|
|
startUpload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-15 09:26:34 +01:00
|
|
|
QList<DeployableFile> QnxDeployQtLibrariesDialog::gatherFiles()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
2016-03-15 09:26:34 +01:00
|
|
|
QList<DeployableFile> result;
|
2014-02-10 14:16:55 +01:00
|
|
|
|
|
|
|
|
const int qtVersionId =
|
|
|
|
|
m_ui->qtLibraryCombo->itemData(m_ui->qtLibraryCombo->currentIndex()).toInt();
|
2014-05-27 12:46:24 +02:00
|
|
|
|
|
|
|
|
|
2015-04-24 10:31:27 +02:00
|
|
|
QnxQtVersion *qtVersion = dynamic_cast<QnxQtVersion *>(QtVersionManager::version(qtVersionId));
|
2014-02-10 14:16:55 +01:00
|
|
|
|
|
|
|
|
QTC_ASSERT(qtVersion, return result);
|
|
|
|
|
|
2014-12-04 11:45:06 -02:00
|
|
|
if (Utils::HostOsInfo::isWindowsHost()) {
|
|
|
|
|
result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_LIBS")),
|
|
|
|
|
QString(), QStringList() << QLatin1String("*.so.?")));
|
|
|
|
|
result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_LIBS"))
|
|
|
|
|
+ QLatin1String("/fonts")));
|
|
|
|
|
} else {
|
|
|
|
|
result.append(gatherFiles(
|
|
|
|
|
qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_LIBS"))));
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 14:16:55 +01:00
|
|
|
result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_PLUGINS"))));
|
|
|
|
|
result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_IMPORTS"))));
|
|
|
|
|
result.append(gatherFiles(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_QML"))));
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-15 09:26:34 +01:00
|
|
|
QList<DeployableFile> QnxDeployQtLibrariesDialog::gatherFiles(
|
2014-12-04 11:45:06 -02:00
|
|
|
const QString &dirPath, const QString &baseDirPath, const QStringList &nameFilters)
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
2016-03-15 09:26:34 +01:00
|
|
|
QList<DeployableFile> result;
|
2014-02-13 10:46:14 +01:00
|
|
|
if (dirPath.isEmpty())
|
|
|
|
|
return result;
|
|
|
|
|
|
2014-02-10 14:16:55 +01:00
|
|
|
QDir dir(dirPath);
|
2014-12-04 11:45:06 -02:00
|
|
|
QFileInfoList list = dir.entryInfoList(nameFilters,
|
|
|
|
|
QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
2014-02-10 14:16:55 +01:00
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
|
QFileInfo fileInfo = list.at(i);
|
|
|
|
|
if (fileInfo.isDir()) {
|
|
|
|
|
result.append(gatherFiles(fileInfo.absoluteFilePath(), baseDirPath.isEmpty() ?
|
|
|
|
|
dirPath : baseDirPath));
|
|
|
|
|
} else {
|
|
|
|
|
QString remoteDir;
|
|
|
|
|
if (baseDirPath.isEmpty()) {
|
|
|
|
|
remoteDir = fullRemoteDirectory() + QLatin1Char('/') +
|
|
|
|
|
QFileInfo(dirPath).baseName();
|
|
|
|
|
} else {
|
|
|
|
|
QDir baseDir(baseDirPath);
|
|
|
|
|
baseDir.cdUp();
|
|
|
|
|
remoteDir = fullRemoteDirectory() + QLatin1Char('/') +
|
|
|
|
|
baseDir.relativeFilePath(dirPath);
|
|
|
|
|
}
|
2016-03-15 09:26:34 +01:00
|
|
|
result.append(DeployableFile(fileInfo.absoluteFilePath(), remoteDir));
|
2014-02-10 14:16:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
QString QnxDeployQtLibrariesDialog::fullRemoteDirectory() const
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
2015-04-24 10:31:27 +02:00
|
|
|
return m_ui->remoteDirectory->text();
|
2014-02-10 14:16:55 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::checkRemoteDirectoryExistance()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_state == Inactive);
|
|
|
|
|
|
|
|
|
|
m_state = CheckingRemoteDirectory;
|
|
|
|
|
|
2014-04-17 14:09:47 +02:00
|
|
|
m_ui->deployLogWindow->appendPlainText(tr("Checking existence of \"%1\"")
|
2014-02-10 14:16:55 +01:00
|
|
|
.arg(fullRemoteDirectory()));
|
|
|
|
|
|
|
|
|
|
const QByteArray cmd = "test -d " + fullRemoteDirectory().toLatin1();
|
|
|
|
|
m_processRunner->run(cmd, m_device->sshParameters());
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 12:46:24 +02:00
|
|
|
void QnxDeployQtLibrariesDialog::removeRemoteDirectory()
|
2014-02-10 14:16:55 +01:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_state == CheckingRemoteDirectory);
|
|
|
|
|
|
|
|
|
|
m_state = RemovingRemoteDirectory;
|
|
|
|
|
|
2014-04-17 14:09:47 +02:00
|
|
|
m_ui->deployLogWindow->appendPlainText(tr("Removing \"%1\"").arg(fullRemoteDirectory()));
|
2014-02-10 14:16:55 +01:00
|
|
|
|
|
|
|
|
const QByteArray cmd = "rm -rf " + fullRemoteDirectory().toLatin1();
|
|
|
|
|
m_processRunner->run(cmd, m_device->sshParameters());
|
|
|
|
|
}
|
2015-04-24 10:31:27 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qnx
|