2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-02-15 14:47:45 -08:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2012-02-15 14:47:45 -08:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-02-15 14:47:45 -08:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2012-02-15 14:47:45 -08:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2012-02-15 14:47:45 -08:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-02-15 14:47:45 -08:00
|
|
|
|
|
|
|
|
#include "genericlinuxdeviceconfigurationwidget.h"
|
|
|
|
|
#include "ui_genericlinuxdeviceconfigurationwidget.h"
|
|
|
|
|
|
2014-06-13 11:19:54 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2012-02-28 10:34:50 +01:00
|
|
|
#include <utils/portlist.h>
|
2013-03-18 14:47:33 +01:00
|
|
|
#include <utils/fancylineedit.h>
|
2012-05-18 10:49:35 +02:00
|
|
|
#include <ssh/sshconnection.h>
|
|
|
|
|
#include <ssh/sshkeycreationdialog.h>
|
2012-02-15 14:47:45 -08:00
|
|
|
|
2012-07-25 17:41:01 +02:00
|
|
|
using namespace ProjectExplorer;
|
2012-02-15 14:47:45 -08:00
|
|
|
using namespace RemoteLinux;
|
2012-05-18 10:49:35 +02:00
|
|
|
using namespace QSsh;
|
2012-02-28 10:34:50 +01:00
|
|
|
using namespace Utils;
|
2012-02-15 14:47:45 -08:00
|
|
|
|
|
|
|
|
GenericLinuxDeviceConfigurationWidget::GenericLinuxDeviceConfigurationWidget(
|
2012-07-25 17:41:01 +02:00
|
|
|
const IDevice::Ptr &deviceConfig, QWidget *parent) :
|
|
|
|
|
IDeviceWidget(deviceConfig, parent),
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui(new Ui::GenericLinuxDeviceConfigurationWidget)
|
|
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
|
connect(m_ui->hostLineEdit, SIGNAL(editingFinished()), this, SLOT(hostNameEditingFinished()));
|
|
|
|
|
connect(m_ui->userLineEdit, SIGNAL(editingFinished()), this, SLOT(userNameEditingFinished()));
|
|
|
|
|
connect(m_ui->pwdLineEdit, SIGNAL(editingFinished()), this, SLOT(passwordEditingFinished()));
|
|
|
|
|
connect(m_ui->passwordButton, SIGNAL(toggled(bool)), this, SLOT(authenticationTypeChanged()));
|
|
|
|
|
connect(m_ui->keyFileLineEdit, SIGNAL(editingFinished()), this, SLOT(keyFileEditingFinished()));
|
|
|
|
|
connect(m_ui->keyFileLineEdit, SIGNAL(browsingFinished()), this, SLOT(keyFileEditingFinished()));
|
|
|
|
|
connect(m_ui->keyButton, SIGNAL(toggled(bool)), this, SLOT(authenticationTypeChanged()));
|
|
|
|
|
connect(m_ui->timeoutSpinBox, SIGNAL(editingFinished()), this, SLOT(timeoutEditingFinished()));
|
|
|
|
|
connect(m_ui->timeoutSpinBox, SIGNAL(valueChanged(int)), this, SLOT(timeoutEditingFinished()));
|
|
|
|
|
connect(m_ui->sshPortSpinBox, SIGNAL(editingFinished()), this, SLOT(sshPortEditingFinished()));
|
|
|
|
|
connect(m_ui->sshPortSpinBox, SIGNAL(valueChanged(int)), this, SLOT(sshPortEditingFinished()));
|
|
|
|
|
connect(m_ui->showPasswordCheckBox, SIGNAL(toggled(bool)), this, SLOT(showPassword(bool)));
|
|
|
|
|
connect(m_ui->portsLineEdit, SIGNAL(editingFinished()), this, SLOT(handleFreePortsChanged()));
|
2012-03-06 12:31:42 +01:00
|
|
|
connect(m_ui->createKeyButton, SIGNAL(clicked()), SLOT(createNewKey()));
|
2013-06-28 13:56:42 +02:00
|
|
|
connect(m_ui->gdbServerLineEdit, SIGNAL(editingFinished()), SLOT(gdbServerEditingFinished()));
|
2014-11-12 16:50:04 +01:00
|
|
|
connect(m_ui->hostKeyCheckBox, &QCheckBox::toggled, this,
|
|
|
|
|
&GenericLinuxDeviceConfigurationWidget::hostKeyCheckingChanged);
|
2012-02-15 14:47:45 -08:00
|
|
|
|
|
|
|
|
initGui();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GenericLinuxDeviceConfigurationWidget::~GenericLinuxDeviceConfigurationWidget()
|
|
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::authenticationTypeChanged()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
SshConnectionParameters sshParams = device()->sshParameters();
|
2012-02-15 14:47:45 -08:00
|
|
|
const bool usePassword = m_ui->passwordButton->isChecked();
|
|
|
|
|
sshParams.authenticationType = usePassword
|
2013-06-18 18:12:34 +02:00
|
|
|
? SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods
|
|
|
|
|
: SshConnectionParameters::AuthenticationTypePublicKey;
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setSshParameters(sshParams);
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui->pwdLineEdit->setEnabled(usePassword);
|
|
|
|
|
m_ui->passwordLabel->setEnabled(usePassword);
|
|
|
|
|
m_ui->keyFileLineEdit->setEnabled(!usePassword);
|
|
|
|
|
m_ui->keyLabel->setEnabled(!usePassword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::hostNameEditingFinished()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
SshConnectionParameters sshParams = device()->sshParameters();
|
2012-04-20 13:51:04 +02:00
|
|
|
sshParams.host = m_ui->hostLineEdit->text().trimmed();
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setSshParameters(sshParams);
|
2012-02-15 14:47:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::sshPortEditingFinished()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
SshConnectionParameters sshParams = device()->sshParameters();
|
2012-02-15 14:47:45 -08:00
|
|
|
sshParams.port = m_ui->sshPortSpinBox->value();
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setSshParameters(sshParams);
|
2012-02-15 14:47:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::timeoutEditingFinished()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
SshConnectionParameters sshParams = device()->sshParameters();
|
2012-02-15 14:47:45 -08:00
|
|
|
sshParams.timeout = m_ui->timeoutSpinBox->value();
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setSshParameters(sshParams);
|
2012-02-15 14:47:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::userNameEditingFinished()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
SshConnectionParameters sshParams = device()->sshParameters();
|
2012-02-15 14:47:45 -08:00
|
|
|
sshParams.userName = m_ui->userLineEdit->text();
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setSshParameters(sshParams);
|
2012-02-15 14:47:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::passwordEditingFinished()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
SshConnectionParameters sshParams = device()->sshParameters();
|
2012-02-15 14:47:45 -08:00
|
|
|
sshParams.password = m_ui->pwdLineEdit->text();
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setSshParameters(sshParams);
|
2012-02-15 14:47:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::keyFileEditingFinished()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
SshConnectionParameters sshParams = device()->sshParameters();
|
2012-02-15 14:47:45 -08:00
|
|
|
sshParams.privateKeyFile = m_ui->keyFileLineEdit->path();
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setSshParameters(sshParams);
|
2012-02-15 14:47:45 -08:00
|
|
|
}
|
|
|
|
|
|
2013-06-28 13:56:42 +02:00
|
|
|
void GenericLinuxDeviceConfigurationWidget::gdbServerEditingFinished()
|
|
|
|
|
{
|
|
|
|
|
device()->setDebugServerPath(m_ui->gdbServerLineEdit->text());
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-15 14:47:45 -08:00
|
|
|
void GenericLinuxDeviceConfigurationWidget::handleFreePortsChanged()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setFreePorts(PortList::fromString(m_ui->portsLineEdit->text()));
|
2012-02-15 14:47:45 -08:00
|
|
|
updatePortsWarningLabel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::showPassword(bool showClearText)
|
|
|
|
|
{
|
|
|
|
|
m_ui->pwdLineEdit->setEchoMode(showClearText
|
|
|
|
|
? QLineEdit::Normal : QLineEdit::Password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::setPrivateKey(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
m_ui->keyFileLineEdit->setPath(path);
|
|
|
|
|
keyFileEditingFinished();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-06 12:31:42 +01:00
|
|
|
void GenericLinuxDeviceConfigurationWidget::createNewKey()
|
|
|
|
|
{
|
|
|
|
|
SshKeyCreationDialog dialog(this);
|
|
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
|
setPrivateKey(dialog.privateKeyFilePath());
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-12 16:50:04 +01:00
|
|
|
void GenericLinuxDeviceConfigurationWidget::hostKeyCheckingChanged(bool doCheck)
|
|
|
|
|
{
|
|
|
|
|
SshConnectionParameters sshParams = device()->sshParameters();
|
|
|
|
|
sshParams.hostKeyCheckingMode
|
|
|
|
|
= doCheck ? QSsh::SshHostKeyCheckingAllowNoMatch : QSsh::SshHostKeyCheckingNone;
|
|
|
|
|
device()->setSshParameters(sshParams);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-27 10:20:43 +02:00
|
|
|
void GenericLinuxDeviceConfigurationWidget::updateDeviceFromUi()
|
|
|
|
|
{
|
|
|
|
|
hostNameEditingFinished();
|
|
|
|
|
sshPortEditingFinished();
|
|
|
|
|
timeoutEditingFinished();
|
|
|
|
|
userNameEditingFinished();
|
|
|
|
|
passwordEditingFinished();
|
|
|
|
|
keyFileEditingFinished();
|
|
|
|
|
handleFreePortsChanged();
|
2013-06-28 13:56:42 +02:00
|
|
|
gdbServerEditingFinished();
|
2012-09-27 10:20:43 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-15 14:47:45 -08:00
|
|
|
void GenericLinuxDeviceConfigurationWidget::updatePortsWarningLabel()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
m_ui->portsWarningLabel->setVisible(!device()->freePorts().hasMore());
|
2012-02-15 14:47:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::initGui()
|
|
|
|
|
{
|
2012-07-25 17:41:01 +02:00
|
|
|
if (device()->machineType() == IDevice::Hardware)
|
2012-03-05 12:37:32 +01:00
|
|
|
m_ui->machineTypeValueLabel->setText(tr("Physical Device"));
|
|
|
|
|
else
|
|
|
|
|
m_ui->machineTypeValueLabel->setText(tr("Emulator"));
|
2014-06-13 11:19:54 +02:00
|
|
|
m_ui->portsWarningLabel->setPixmap(QPixmap(QLatin1String(Core::Constants::ICON_ERROR)));
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui->portsWarningLabel->setToolTip(QLatin1String("<font color=\"red\">")
|
|
|
|
|
+ tr("You will need at least one port.") + QLatin1String("</font>"));
|
2012-02-28 10:34:50 +01:00
|
|
|
m_ui->keyFileLineEdit->setExpectedKind(PathChooser::File);
|
2013-11-25 14:37:43 +01:00
|
|
|
m_ui->keyFileLineEdit->setHistoryCompleter(QLatin1String("Ssh.KeyFile.History"));
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui->keyFileLineEdit->lineEdit()->setMinimumWidth(0);
|
|
|
|
|
QRegExpValidator * const portsValidator
|
|
|
|
|
= new QRegExpValidator(QRegExp(PortList::regularExpression()), this);
|
|
|
|
|
m_ui->portsLineEdit->setValidator(portsValidator);
|
|
|
|
|
|
2012-07-25 17:41:01 +02:00
|
|
|
const SshConnectionParameters &sshParams = device()->sshParameters();
|
2012-02-15 14:47:45 -08:00
|
|
|
|
2013-06-18 18:12:34 +02:00
|
|
|
if (sshParams.authenticationType != SshConnectionParameters::AuthenticationTypePublicKey)
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui->passwordButton->setChecked(true);
|
|
|
|
|
else
|
|
|
|
|
m_ui->keyButton->setChecked(true);
|
|
|
|
|
m_ui->timeoutSpinBox->setValue(sshParams.timeout);
|
2012-07-25 17:41:01 +02:00
|
|
|
m_ui->hostLineEdit->setEnabled(!device()->isAutoDetected());
|
|
|
|
|
m_ui->sshPortSpinBox->setEnabled(!device()->isAutoDetected());
|
2014-11-12 16:50:04 +01:00
|
|
|
m_ui->hostKeyCheckBox->setChecked(sshParams.hostKeyCheckingMode != SshHostKeyCheckingNone);
|
2012-02-15 14:47:45 -08:00
|
|
|
|
|
|
|
|
m_ui->hostLineEdit->setText(sshParams.host);
|
|
|
|
|
m_ui->sshPortSpinBox->setValue(sshParams.port);
|
2012-07-25 17:41:01 +02:00
|
|
|
m_ui->portsLineEdit->setText(device()->freePorts().toString());
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui->timeoutSpinBox->setValue(sshParams.timeout);
|
|
|
|
|
m_ui->userLineEdit->setText(sshParams.userName);
|
|
|
|
|
m_ui->pwdLineEdit->setText(sshParams.password);
|
|
|
|
|
m_ui->keyFileLineEdit->setPath(sshParams.privateKeyFile);
|
|
|
|
|
m_ui->showPasswordCheckBox->setChecked(false);
|
2013-06-28 13:56:42 +02:00
|
|
|
m_ui->gdbServerLineEdit->setText(device()->debugServerPath());
|
2012-02-15 14:47:45 -08:00
|
|
|
updatePortsWarningLabel();
|
|
|
|
|
}
|