2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-02-15 14:47:45 -08:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
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.
|
2012-02-15 14:47:45 -08: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.
|
2012-02-15 14:47:45 -08:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-02-15 14:47:45 -08:00
|
|
|
|
|
|
|
|
#include "genericlinuxdeviceconfigurationwidget.h"
|
|
|
|
|
#include "ui_genericlinuxdeviceconfigurationwidget.h"
|
|
|
|
|
|
2022-05-12 23:55:09 +02:00
|
|
|
#include "sshkeycreationdialog.h"
|
|
|
|
|
|
2014-06-13 11:19:54 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2022-04-12 21:01:45 +02:00
|
|
|
#include <projectexplorer/devicesupport/idevice.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>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2022-05-12 18:43:44 +02:00
|
|
|
#include <ssh/sshparameters.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(
|
2019-08-16 11:42:19 +02:00
|
|
|
const IDevice::Ptr &deviceConfig) :
|
|
|
|
|
IDeviceWidget(deviceConfig),
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui(new Ui::GenericLinuxDeviceConfigurationWidget)
|
|
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
2016-06-30 23:04:57 +03:00
|
|
|
connect(m_ui->hostLineEdit, &QLineEdit::editingFinished,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::hostNameEditingFinished);
|
|
|
|
|
connect(m_ui->userLineEdit, &QLineEdit::editingFinished,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::userNameEditingFinished);
|
|
|
|
|
connect(m_ui->keyFileLineEdit, &PathChooser::editingFinished,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::keyFileEditingFinished);
|
|
|
|
|
connect(m_ui->keyFileLineEdit, &PathChooser::browsingFinished,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::keyFileEditingFinished);
|
|
|
|
|
connect(m_ui->keyButton, &QAbstractButton::toggled,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::authenticationTypeChanged);
|
|
|
|
|
connect(m_ui->timeoutSpinBox, &QAbstractSpinBox::editingFinished,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::timeoutEditingFinished);
|
2019-02-26 09:40:49 +01:00
|
|
|
connect(m_ui->timeoutSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
2016-06-30 23:04:57 +03:00
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::timeoutEditingFinished);
|
|
|
|
|
connect(m_ui->sshPortSpinBox, &QAbstractSpinBox::editingFinished,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::sshPortEditingFinished);
|
2019-02-26 09:40:49 +01:00
|
|
|
connect(m_ui->sshPortSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
2016-06-30 23:04:57 +03:00
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::sshPortEditingFinished);
|
|
|
|
|
connect(m_ui->portsLineEdit, &QLineEdit::editingFinished,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::handleFreePortsChanged);
|
|
|
|
|
connect(m_ui->createKeyButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::createNewKey);
|
|
|
|
|
connect(m_ui->gdbServerLineEdit, &QLineEdit::editingFinished,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::gdbServerEditingFinished);
|
|
|
|
|
connect(m_ui->hostKeyCheckBox, &QCheckBox::toggled,
|
|
|
|
|
this, &GenericLinuxDeviceConfigurationWidget::hostKeyCheckingChanged);
|
2018-04-19 13:00:06 +02:00
|
|
|
m_ui->gdbServerLineEdit->setToolTip(m_ui->gdbServerLineEdit->placeholderText());
|
2012-02-15 14:47:45 -08:00
|
|
|
|
|
|
|
|
initGui();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GenericLinuxDeviceConfigurationWidget::~GenericLinuxDeviceConfigurationWidget()
|
|
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::authenticationTypeChanged()
|
|
|
|
|
{
|
2022-05-12 18:43:44 +02:00
|
|
|
SshParameters sshParams = device()->sshParameters();
|
2016-07-20 18:04:56 +02:00
|
|
|
const bool useKeyFile = m_ui->keyButton->isChecked();
|
2018-11-23 11:07:57 +01:00
|
|
|
sshParams.authenticationType = useKeyFile
|
2022-05-12 18:43:44 +02:00
|
|
|
? SshParameters::AuthenticationTypeSpecificKey
|
|
|
|
|
: SshParameters::AuthenticationTypeAll;
|
2012-07-25 17:41:01 +02:00
|
|
|
device()->setSshParameters(sshParams);
|
2016-07-20 18:04:56 +02:00
|
|
|
m_ui->keyFileLineEdit->setEnabled(useKeyFile);
|
|
|
|
|
m_ui->keyLabel->setEnabled(useKeyFile);
|
2012-02-15 14:47:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericLinuxDeviceConfigurationWidget::hostNameEditingFinished()
|
|
|
|
|
{
|
2022-05-12 18:43:44 +02:00
|
|
|
SshParameters sshParams = device()->sshParameters();
|
2017-12-19 12:45:46 +01:00
|
|
|
sshParams.setHost(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()
|
|
|
|
|
{
|
2022-05-12 18:43:44 +02:00
|
|
|
SshParameters sshParams = device()->sshParameters();
|
2017-12-19 12:45:46 +01:00
|
|
|
sshParams.setPort(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()
|
|
|
|
|
{
|
2022-05-12 18:43:44 +02:00
|
|
|
SshParameters 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()
|
|
|
|
|
{
|
2022-05-12 18:43:44 +02:00
|
|
|
SshParameters sshParams = device()->sshParameters();
|
2017-12-19 12:45:46 +01:00
|
|
|
sshParams.setUserName(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::keyFileEditingFinished()
|
|
|
|
|
{
|
2022-05-12 18:43:44 +02:00
|
|
|
SshParameters sshParams = device()->sshParameters();
|
2021-09-27 18:23:27 +02:00
|
|
|
sshParams.privateKeyFile = m_ui->keyFileLineEdit->filePath();
|
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()
|
|
|
|
|
{
|
2021-08-11 06:35:40 +02:00
|
|
|
device()->setDebugServerPath(FilePath::fromString(m_ui->gdbServerLineEdit->text()));
|
2013-06-28 13:56:42 +02:00
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-27 16:30:57 +02:00
|
|
|
void GenericLinuxDeviceConfigurationWidget::setPrivateKey(const FilePath &path)
|
2012-02-15 14:47:45 -08:00
|
|
|
{
|
2021-09-27 16:30:57 +02:00
|
|
|
m_ui->keyFileLineEdit->setFilePath(path);
|
2012-02-15 14:47:45 -08:00
|
|
|
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)
|
|
|
|
|
{
|
2022-05-12 18:43:44 +02:00
|
|
|
SshParameters sshParams = device()->sshParameters();
|
2014-11-12 16:50:04 +01:00
|
|
|
sshParams.hostKeyCheckingMode
|
2015-02-03 23:51:02 +02:00
|
|
|
= doCheck ? SshHostKeyCheckingAllowNoMatch : SshHostKeyCheckingNone;
|
2014-11-12 16:50:04 +01:00
|
|
|
device()->setSshParameters(sshParams);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-27 10:20:43 +02:00
|
|
|
void GenericLinuxDeviceConfigurationWidget::updateDeviceFromUi()
|
|
|
|
|
{
|
|
|
|
|
hostNameEditingFinished();
|
|
|
|
|
sshPortEditingFinished();
|
|
|
|
|
timeoutEditingFinished();
|
|
|
|
|
userNameEditingFinished();
|
|
|
|
|
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"));
|
2017-01-02 12:37:49 +01:00
|
|
|
m_ui->portsWarningLabel->setPixmap(Utils::Icons::CRITICAL.pixmap());
|
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);
|
2020-03-18 13:32:28 +01:00
|
|
|
QRegularExpressionValidator * const portsValidator
|
|
|
|
|
= new QRegularExpressionValidator(QRegularExpression(PortList::regularExpression()), this);
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui->portsLineEdit->setValidator(portsValidator);
|
|
|
|
|
|
2022-05-12 18:43:44 +02:00
|
|
|
const SshParameters &sshParams = device()->sshParameters();
|
2012-02-15 14:47:45 -08:00
|
|
|
|
2016-07-20 18:04:56 +02:00
|
|
|
switch (sshParams.authenticationType) {
|
2022-05-12 18:43:44 +02:00
|
|
|
case SshParameters::AuthenticationTypeSpecificKey:
|
2012-02-15 14:47:45 -08:00
|
|
|
m_ui->keyButton->setChecked(true);
|
2016-07-20 18:04:56 +02:00
|
|
|
break;
|
2022-05-12 18:43:44 +02:00
|
|
|
case SshParameters::AuthenticationTypeAll:
|
2018-11-23 11:07:57 +01:00
|
|
|
m_ui->defaultAuthButton->setChecked(true);
|
2016-07-20 18:04:56 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2012-02-15 14:47:45 -08:00
|
|
|
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
|
|
|
|
2017-12-19 12:45:46 +01: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);
|
2017-12-19 12:45:46 +01:00
|
|
|
m_ui->userLineEdit->setText(sshParams.userName());
|
2021-09-27 18:23:27 +02:00
|
|
|
m_ui->keyFileLineEdit->setFilePath(sshParams.privateKeyFile);
|
2021-08-11 06:35:40 +02:00
|
|
|
m_ui->gdbServerLineEdit->setText(device()->debugServerPath().toString());
|
2012-02-15 14:47:45 -08:00
|
|
|
updatePortsWarningLabel();
|
|
|
|
|
}
|