2011-04-04 14:39:28 +02:00
|
|
|
/**************************************************************************
|
2011-05-06 15:05:37 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-05-06 15:05:37 +02:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2011-05-06 15:05:37 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
2011-04-04 14:39:28 +02:00
|
|
|
|
|
|
|
|
#include "startremotedialog.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2012-05-18 10:49:35 +02:00
|
|
|
#include <ssh/sshconnection.h>
|
2012-06-28 13:30:09 +02:00
|
|
|
#include <utils/pathchooser.h>
|
2011-08-17 13:37:52 +02:00
|
|
|
|
2012-06-28 13:30:09 +02:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPushButton>
|
2012-06-28 13:30:09 +02:00
|
|
|
#include <QSpinBox>
|
2011-04-04 14:39:28 +02:00
|
|
|
|
|
|
|
|
namespace Analyzer {
|
2012-06-28 13:30:09 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class StartRemoteDialogPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QLabel *hostLabel;
|
|
|
|
|
QLineEdit *host;
|
|
|
|
|
QLabel *userLabel;
|
|
|
|
|
QLineEdit *user;
|
|
|
|
|
QLabel *portLabel;
|
|
|
|
|
QSpinBox *port;
|
|
|
|
|
QLabel *passwordLabel;
|
|
|
|
|
QLineEdit *password;
|
|
|
|
|
QLabel *keyFileLabel;
|
|
|
|
|
Utils::PathChooser *keyFile;
|
|
|
|
|
QFormLayout *formLayout;
|
|
|
|
|
QLabel *executableLabel;
|
|
|
|
|
QLineEdit *executable;
|
|
|
|
|
QLabel *argumentsLabel;
|
|
|
|
|
QLineEdit *arguments;
|
|
|
|
|
QLabel *workingDirectoryLabel;
|
|
|
|
|
QLineEdit *workingDirectory;
|
|
|
|
|
QDialogButtonBox *buttonBox;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2011-07-04 10:50:44 +02:00
|
|
|
StartRemoteDialog::StartRemoteDialog(QWidget *parent)
|
|
|
|
|
: QDialog(parent)
|
2012-06-28 13:30:09 +02:00
|
|
|
, d(new Internal::StartRemoteDialogPrivate)
|
2011-04-04 14:39:28 +02:00
|
|
|
{
|
2012-06-28 13:30:09 +02:00
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
|
setWindowTitle(tr("Start Remote Analysis"));
|
|
|
|
|
|
|
|
|
|
QGroupBox *groupBox = new QGroupBox(tr("Remote"), this);
|
|
|
|
|
|
|
|
|
|
d->host = new QLineEdit(groupBox);
|
|
|
|
|
d->hostLabel = new QLabel(tr("Host:"), groupBox);
|
|
|
|
|
|
|
|
|
|
d->user = new QLineEdit(groupBox);
|
|
|
|
|
d->userLabel = new QLabel(tr("User:"), groupBox);
|
|
|
|
|
|
|
|
|
|
d->port = new QSpinBox(groupBox);
|
|
|
|
|
d->port->setMaximum(65535);
|
|
|
|
|
d->port->setSingleStep(1);
|
|
|
|
|
d->port->setValue(22);
|
|
|
|
|
d->portLabel = new QLabel(tr("Port:"), groupBox);
|
|
|
|
|
|
|
|
|
|
d->passwordLabel = new QLabel(tr("Password:"), groupBox);
|
|
|
|
|
d->passwordLabel->setToolTip(tr("You need to pass either a password or an SSH key."));
|
|
|
|
|
|
|
|
|
|
d->password = new QLineEdit(groupBox);
|
|
|
|
|
d->password->setEchoMode(QLineEdit::Password);
|
|
|
|
|
|
|
|
|
|
d->keyFileLabel = new QLabel(tr("Private key:"), groupBox);
|
|
|
|
|
d->keyFileLabel->setToolTip(tr("You need to pass either a password or an SSH key."));
|
|
|
|
|
|
|
|
|
|
d->keyFile = new Utils::PathChooser(groupBox);
|
|
|
|
|
|
|
|
|
|
QGroupBox *groupBox2 = new QGroupBox(tr("Target"), this);
|
|
|
|
|
|
|
|
|
|
d->executable = new QLineEdit(groupBox2);
|
|
|
|
|
d->executableLabel = new QLabel(tr("Executable:"), groupBox2);
|
|
|
|
|
|
|
|
|
|
d->arguments = new QLineEdit(groupBox2);
|
|
|
|
|
d->argumentsLabel = new QLabel(tr("Arguments:"), groupBox2);
|
|
|
|
|
|
|
|
|
|
d->workingDirectory = new QLineEdit(groupBox2);
|
|
|
|
|
d->workingDirectoryLabel = new QLabel(tr("Working directory:"), groupBox2);
|
|
|
|
|
|
|
|
|
|
d->buttonBox = new QDialogButtonBox(this);
|
|
|
|
|
d->buttonBox->setOrientation(Qt::Horizontal);
|
|
|
|
|
d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
|
|
|
|
|
|
|
|
|
QFormLayout *formLayout = new QFormLayout(groupBox);
|
|
|
|
|
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
|
|
|
formLayout->addRow(d->hostLabel, d->host);
|
|
|
|
|
formLayout->addRow(d->userLabel, d->user);
|
|
|
|
|
formLayout->addRow(d->portLabel, d->port);
|
|
|
|
|
formLayout->addRow(d->passwordLabel, d->password);
|
|
|
|
|
formLayout->addRow(d->keyFileLabel, d->keyFile);
|
|
|
|
|
|
|
|
|
|
QFormLayout *formLayout2 = new QFormLayout(groupBox2);
|
|
|
|
|
formLayout2->addRow(d->executableLabel, d->executable);
|
|
|
|
|
formLayout2->addRow(d->argumentsLabel, d->arguments);
|
|
|
|
|
formLayout2->addRow(d->workingDirectoryLabel, d->workingDirectory);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
|
|
|
|
verticalLayout->addWidget(groupBox);
|
|
|
|
|
verticalLayout->addWidget(groupBox2);
|
|
|
|
|
verticalLayout->addWidget(d->buttonBox);
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2012-06-28 13:30:09 +02:00
|
|
|
d->keyFile->setExpectedKind(Utils::PathChooser::File);
|
2011-04-04 14:39:28 +02:00
|
|
|
|
2012-01-24 15:36:40 +01:00
|
|
|
QSettings *settings = Core::ICore::settings();
|
2012-01-25 17:39:50 +01:00
|
|
|
settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog"));
|
2012-06-28 13:30:09 +02:00
|
|
|
d->host->setText(settings->value(QLatin1String("host")).toString());
|
|
|
|
|
d->port->setValue(settings->value(QLatin1String("port"), 22).toInt());
|
|
|
|
|
d->user->setText(settings->value(QLatin1String("user"), qgetenv("USER")).toString());
|
|
|
|
|
d->keyFile->setPath(settings->value(QLatin1String("keyFile")).toString());
|
|
|
|
|
d->executable->setText(settings->value(QLatin1String("executable")).toString());
|
|
|
|
|
d->workingDirectory->setText(settings->value(QLatin1String("workingDirectory")).toString());
|
|
|
|
|
d->arguments->setText(settings->value(QLatin1String("arguments")).toString());
|
2011-04-04 14:39:28 +02:00
|
|
|
settings->endGroup();
|
|
|
|
|
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->host, SIGNAL(textChanged(QString)),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(validate()));
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->port, SIGNAL(valueChanged(int)),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(validate()));
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->password, SIGNAL(textChanged(QString)),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(validate()));
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->keyFile, SIGNAL(changed(QString)),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(validate()));
|
|
|
|
|
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->executable, SIGNAL(textChanged(QString)),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(validate()));
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->workingDirectory, SIGNAL(textChanged(QString)),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(validate()));
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->arguments, SIGNAL(textChanged(QString)),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(validate()));
|
|
|
|
|
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->buttonBox, SIGNAL(accepted()),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(accept()));
|
2012-06-28 13:30:09 +02:00
|
|
|
connect(d->buttonBox, SIGNAL(rejected()),
|
2011-04-04 14:39:28 +02:00
|
|
|
this, SLOT(reject()));
|
|
|
|
|
|
|
|
|
|
validate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StartRemoteDialog::~StartRemoteDialog()
|
|
|
|
|
{
|
2012-06-28 13:30:09 +02:00
|
|
|
delete d;
|
2011-04-04 14:39:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartRemoteDialog::accept()
|
|
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QSettings *settings = Core::ICore::settings();
|
2012-01-25 17:39:50 +01:00
|
|
|
settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog"));
|
2012-06-28 13:30:09 +02:00
|
|
|
settings->setValue(QLatin1String("host"), d->host->text());
|
|
|
|
|
settings->setValue(QLatin1String("port"), d->port->value());
|
|
|
|
|
settings->setValue(QLatin1String("user"), d->user->text());
|
|
|
|
|
settings->setValue(QLatin1String("keyFile"), d->keyFile->path());
|
|
|
|
|
settings->setValue(QLatin1String("executable"), d->executable->text());
|
|
|
|
|
settings->setValue(QLatin1String("workingDirectory"), d->workingDirectory->text());
|
|
|
|
|
settings->setValue(QLatin1String("arguments"), d->arguments->text());
|
2011-04-04 14:39:28 +02:00
|
|
|
settings->endGroup();
|
|
|
|
|
|
|
|
|
|
QDialog::accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartRemoteDialog::validate()
|
|
|
|
|
{
|
2012-06-28 13:30:09 +02:00
|
|
|
bool valid = !d->host->text().isEmpty() && !d->user->text().isEmpty()
|
|
|
|
|
&& !d->executable->text().isEmpty();
|
|
|
|
|
valid = valid && (!d->password->text().isEmpty() || d->keyFile->isValid());
|
|
|
|
|
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
|
2011-04-04 14:39:28 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-18 10:49:35 +02:00
|
|
|
QSsh::SshConnectionParameters StartRemoteDialog::sshParams() const
|
2011-04-04 14:39:28 +02:00
|
|
|
{
|
2012-05-18 10:49:35 +02:00
|
|
|
QSsh::SshConnectionParameters params;
|
2012-06-28 13:30:09 +02:00
|
|
|
params.host = d->host->text();
|
|
|
|
|
params.userName = d->user->text();
|
|
|
|
|
if (d->keyFile->isValid()) {
|
2012-05-18 10:49:35 +02:00
|
|
|
params.authenticationType = QSsh::SshConnectionParameters::AuthenticationByKey;
|
2012-06-28 13:30:09 +02:00
|
|
|
params.privateKeyFile = d->keyFile->path();
|
2011-04-04 14:39:28 +02:00
|
|
|
} else {
|
2012-05-18 10:49:35 +02:00
|
|
|
params.authenticationType = QSsh::SshConnectionParameters::AuthenticationByPassword;
|
2012-06-28 13:30:09 +02:00
|
|
|
params.password = d->password->text();
|
2011-04-04 14:39:28 +02:00
|
|
|
}
|
2012-06-28 13:30:09 +02:00
|
|
|
params.port = d->port->value();
|
2012-02-24 15:09:08 +01:00
|
|
|
params.timeout = 10;
|
2011-04-04 14:39:28 +02:00
|
|
|
return params;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString StartRemoteDialog::executable() const
|
|
|
|
|
{
|
2012-06-28 13:30:09 +02:00
|
|
|
return d->executable->text();
|
2011-04-04 14:39:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString StartRemoteDialog::arguments() const
|
|
|
|
|
{
|
2012-06-28 13:30:09 +02:00
|
|
|
return d->arguments->text();
|
2011-04-04 14:39:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString StartRemoteDialog::workingDirectory() const
|
|
|
|
|
{
|
2012-06-28 13:30:09 +02:00
|
|
|
return d->workingDirectory->text();
|
2011-04-04 14:39:28 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-18 15:56:01 +02:00
|
|
|
} // namespace Analyzer
|