diff options
author | hjk <hjk@qt.io> | 2017-12-19 12:45:46 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2017-12-19 14:19:31 +0000 |
commit | 21c66ce5fdaf9fcf91b4ba72adba691fc64be4a3 (patch) | |
tree | 06c49f98300874a2b40bfa7800373679804a217b | |
parent | b64c1a96b8b9218a903c7993d58c64f8ca387243 (diff) |
Combine some SshConnectionParameter members
Combine host, port, username and password into a 'url' member and
add some convenience accessors.
Change-Id: Iddc26ff00dad1285c96aa56f196dbc4febe8e974
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
20 files changed, 80 insertions, 86 deletions
diff --git a/src/libs/ssh/sshconnection.cpp b/src/libs/ssh/sshconnection.cpp index d6d5b5cf05..e1f98da06d 100644 --- a/src/libs/ssh/sshconnection.cpp +++ b/src/libs/ssh/sshconnection.cpp @@ -63,21 +63,21 @@ namespace QSsh { const QByteArray ClientId("SSH-2.0-QtCreator\r\n"); SshConnectionParameters::SshConnectionParameters() : - timeout(0), authenticationType(AuthenticationTypePublicKey), port(0), + timeout(0), authenticationType(AuthenticationTypePublicKey), hostKeyCheckingMode(SshHostKeyCheckingNone) { + url.setPort(0); options |= SshIgnoreDefaultProxy; options |= SshEnableStrictConformanceChecks; } static inline bool equals(const SshConnectionParameters &p1, const SshConnectionParameters &p2) { - return p1.host == p2.host && p1.userName == p2.userName + return p1.url == p2.url && p1.authenticationType == p2.authenticationType - && (p1.authenticationType == SshConnectionParameters::AuthenticationTypePassword ? - p1.password == p2.password : p1.privateKeyFile == p2.privateKeyFile) + && p1.privateKeyFile == p2.privateKeyFile && p1.hostKeyCheckingMode == p2.hostKeyCheckingMode - && p1.timeout == p2.timeout && p1.port == p2.port; + && p1.timeout == p2.timeout; } bool operator==(const SshConnectionParameters &p1, const SshConnectionParameters &p2) @@ -521,11 +521,11 @@ void SshConnectionPrivate::handleServiceAcceptPacket() m_triedAllPasswordBasedMethods = false; // Fall-through. case SshConnectionParameters::AuthenticationTypePassword: - m_sendFacility.sendUserAuthByPasswordRequestPacket(m_connParams.userName.toUtf8(), - SshCapabilities::SshConnectionService, m_connParams.password.toUtf8()); + m_sendFacility.sendUserAuthByPasswordRequestPacket(m_connParams.userName().toUtf8(), + SshCapabilities::SshConnectionService, m_connParams.password().toUtf8()); break; case SshConnectionParameters::AuthenticationTypeKeyboardInteractive: - m_sendFacility.sendUserAuthByKeyboardInteractiveRequestPacket(m_connParams.userName.toUtf8(), + m_sendFacility.sendUserAuthByKeyboardInteractiveRequestPacket(m_connParams.userName().toUtf8(), SshCapabilities::SshConnectionService); break; case SshConnectionParameters::AuthenticationTypePublicKey: @@ -575,7 +575,7 @@ void SshConnectionPrivate::handleUserAuthInfoRequestPacket() // Not very interactive, admittedly, but we don't want to be for now. for (int i = 0; i < requestPacket.prompts.count(); ++i) - responses << m_connParams.password; + responses << m_connParams.password(); m_sendFacility.sendUserAuthInfoResponsePacket(responses); } @@ -626,7 +626,7 @@ void SshConnectionPrivate::handleUserAuthFailurePacket() && !m_triedAllPasswordBasedMethods) { m_triedAllPasswordBasedMethods = true; m_sendFacility.sendUserAuthByKeyboardInteractiveRequestPacket( - m_connParams.userName.toUtf8(), + m_connParams.userName().toUtf8(), SshCapabilities::SshConnectionService); return; } @@ -840,7 +840,7 @@ void SshConnectionPrivate::tryAllAgentKeys() qCDebug(sshLog) << "trying authentication with" << keys.count() << "public keys received from agent"; foreach (const QByteArray &key, keys) { - m_sendFacility.sendQueryPublicKeyPacket(m_connParams.userName.toUtf8(), + m_sendFacility.sendQueryPublicKeyPacket(m_connParams.userName().toUtf8(), SshCapabilities::SshConnectionService, key); m_pendingKeyChecks.enqueue(key); } @@ -860,7 +860,7 @@ void SshConnectionPrivate::authenticateWithPublicKey() signature = m_agentSignature; } - m_sendFacility.sendUserAuthByPublicKeyRequestPacket(m_connParams.userName.toUtf8(), + m_sendFacility.sendUserAuthByPublicKeyRequestPacket(m_connParams.userName().toUtf8(), SshCapabilities::SshConnectionService, key, signature); } @@ -929,7 +929,7 @@ void SshConnectionPrivate::connectToHost() m_state = SocketConnecting; m_keyExchangeState = NoKeyExchange; m_timeoutTimer.start(); - m_socket->connectToHost(m_connParams.host, m_connParams.port); + m_socket->connectToHost(m_connParams.host(), m_connParams.port()); } void SshConnectionPrivate::closeConnection(SshErrorCode sshError, diff --git a/src/libs/ssh/sshconnection.h b/src/libs/ssh/sshconnection.h index 0e90dce3f8..0fbbbcdf8a 100644 --- a/src/libs/ssh/sshconnection.h +++ b/src/libs/ssh/sshconnection.h @@ -36,6 +36,7 @@ #include <QSharedPointer> #include <QString> #include <QHostAddress> +#include <QUrl> namespace QSsh { class SftpChannel; @@ -75,13 +76,19 @@ public: SshConnectionParameters(); - QString host; - QString userName; - QString password; + QString host() const { return url.host(); } + quint16 port() const { return url.port(); } + QString userName() const { return url.userName(); } + QString password() const { return url.password(); } + void setHost(const QString &host) { url.setHost(host); } + void setPort(int port) { url.setPort(port); } + void setUserName(const QString &name) { url.setUserName(name); } + void setPassword(const QString &password) { url.setPassword(password); } + + QUrl url; QString privateKeyFile; int timeout; // In seconds. AuthenticationType authenticationType; - quint16 port; SshConnectionOptions options; SshHostKeyCheckingMode hostKeyCheckingMode; SshHostKeyDatabasePtr hostKeyDatabase; diff --git a/src/libs/ssh/sshkeyexchange.cpp b/src/libs/ssh/sshkeyexchange.cpp index cdcb45556c..f513454d45 100644 --- a/src/libs/ssh/sshkeyexchange.cpp +++ b/src/libs/ssh/sshkeyexchange.cpp @@ -237,7 +237,7 @@ void SshKeyExchange::checkHostKey(const QByteArray &hostKey) { if (m_connParams.hostKeyCheckingMode == SshHostKeyCheckingNone) { if (m_connParams.hostKeyDatabase) - m_connParams.hostKeyDatabase->insertHostKey(m_connParams.host, hostKey); + m_connParams.hostKeyDatabase->insertHostKey(m_connParams.host(), hostKey); return; } @@ -247,7 +247,7 @@ void SshKeyExchange::checkHostKey(const QByteArray &hostKey) "if host key checking is enabled.")); } - switch (m_connParams.hostKeyDatabase->matchHostKey(m_connParams.host, hostKey)) { + switch (m_connParams.hostKeyDatabase->matchHostKey(m_connParams.host(), hostKey)) { case SshHostKeyDatabase::KeyLookupMatch: return; // Nothing to do. case SshHostKeyDatabase::KeyLookupMismatch: @@ -259,14 +259,14 @@ void SshKeyExchange::checkHostKey(const QByteArray &hostKey) throwHostKeyException(); break; } - m_connParams.hostKeyDatabase->insertHostKey(m_connParams.host, hostKey); + m_connParams.hostKeyDatabase->insertHostKey(m_connParams.host(), hostKey); } void SshKeyExchange::throwHostKeyException() { throw SshServerException(SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE, "Host key changed", SSH_TR("Host key of machine \"%1\" has changed.") - .arg(m_connParams.host)); + .arg(m_connParams.host())); } } // namespace Internal diff --git a/src/plugins/baremetal/baremetaldevice.cpp b/src/plugins/baremetal/baremetaldevice.cpp index 7852011fb5..e482073021 100644 --- a/src/plugins/baremetal/baremetaldevice.cpp +++ b/src/plugins/baremetal/baremetaldevice.cpp @@ -104,8 +104,8 @@ void BareMetalDevice::setChannelByServerProvider(GdbServerProvider *provider) if (colon < 0) return; QSsh::SshConnectionParameters sshParams = sshParameters(); - sshParams.host = channel.left(colon); - sshParams.port = channel.mid(colon + 1).toUShort(); + sshParams.setHost(channel.left(colon)); + sshParams.setPort(channel.mid(colon + 1).toUShort()); setSshParameters(sshParams); } @@ -121,8 +121,8 @@ void BareMetalDevice::fromMap(const QVariantMap &map) const QSsh::SshConnectionParameters sshParams = sshParameters(); DefaultGdbServerProvider *newProvider = new DefaultGdbServerProvider; newProvider->setDisplayName(name); - newProvider->m_host = sshParams.host; - newProvider->m_port = sshParams.port; + newProvider->m_host = sshParams.host(); + newProvider->m_port = sshParams.port(); if (GdbServerProviderManager::registerProvider(newProvider)) gdbServerProvider = newProvider->id(); else diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index 13dcf456a4..76556f315d 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -64,7 +64,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent) d->kitChooser = new KitChooser(this); d->kitChooser->setKitPredicate([](const Kit *kit) { const IDevice::ConstPtr device = DeviceKitInformation::device(kit); - return kit->isValid() && device && !device->sshParameters().host.isEmpty(); + return kit->isValid() && device && !device->sshParameters().host().isEmpty(); }); d->executable = new QLineEdit(this); d->arguments = new QLineEdit(this); diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index bee9ee7023..59e2309d1f 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -429,7 +429,7 @@ void StartApplicationDialog::run(bool attachRemote) if (!inputAddress.isEmpty()) debugger->setRemoteChannel(inputAddress); else - debugger->setRemoteChannel(dev->sshParameters().host, newParameters.serverPort); + debugger->setRemoteChannel(dev->sshParameters().host(), newParameters.serverPort); debugger->setRunControlName(newParameters.displayName()); debugger->setBreakOnMain(newParameters.breakAtMain); debugger->setDebugInfoLocation(newParameters.debugInfoLocation); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index d55d04bfde..a71127e38f 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2141,7 +2141,7 @@ void DebuggerPluginPrivate::attachToQmlPort() debugger->setQmlServer(qmlServer); QSsh::SshConnectionParameters sshParameters = device->sshParameters(); - debugger->setRemoteChannel(sshParameters.host, sshParameters.port); + debugger->setRemoteChannel(sshParameters.host(), sshParameters.port()); debugger->setStartMode(AttachToQmlServer); debugger->startRunControl(); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 2cb802f229..e5acf304cd 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -972,7 +972,7 @@ Port GdbServerPortsGatherer::gdbServerPort() const QString GdbServerPortsGatherer::gdbServerChannel() const { QUrl url = channel(0); - const QString host = m_device->sshParameters().host; + const QString host = m_device->sshParameters().host(); return QString("%1:%2").arg(host).arg(url.port()); } diff --git a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp index 69193788b5..fbe7516c9b 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceusedportsgatherer.cpp @@ -272,7 +272,7 @@ public: m_channelForwarder->setFromUrlGetter([this] { QUrl url; url.setScheme(urlTcpScheme()); - url.setHost(device()->sshParameters().host); + url.setHost(device()->sshParameters().host()); url.setPort(m_portGatherer->findPort().number()); return url; }); diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index 1a7b2861b7..d503a18a85 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -332,12 +332,12 @@ void IDevice::fromMap(const QVariantMap &map) d->id = newId(); d->origin = static_cast<Origin>(map.value(QLatin1String(OriginKey), ManuallyAdded).toInt()); - d->sshParameters.host = map.value(QLatin1String(HostKey)).toString(); - d->sshParameters.port = map.value(QLatin1String(SshPortKey), 22).toInt(); - d->sshParameters.userName = map.value(QLatin1String(UserNameKey)).toString(); + d->sshParameters.setHost(map.value(QLatin1String(HostKey)).toString()); + d->sshParameters.setPort(map.value(QLatin1String(SshPortKey), 22).toInt()); + d->sshParameters.setUserName(map.value(QLatin1String(UserNameKey)).toString()); d->sshParameters.authenticationType = static_cast<AuthType>(map.value(QLatin1String(AuthKey), DefaultAuthType).toInt()); - d->sshParameters.password = map.value(QLatin1String(PasswordKey)).toString(); + d->sshParameters.setPassword(map.value(QLatin1String(PasswordKey)).toString()); d->sshParameters.privateKeyFile = map.value(QLatin1String(KeyFileKey), defaultPrivateKeyFilePath()).toString(); d->sshParameters.timeout = map.value(QLatin1String(TimeoutKey), DefaultTimeout).toInt(); d->sshParameters.hostKeyCheckingMode = static_cast<QSsh::SshHostKeyCheckingMode> @@ -371,11 +371,11 @@ QVariantMap IDevice::toMap() const map.insert(QLatin1String(OriginKey), d->origin); map.insert(QLatin1String(MachineTypeKey), d->machineType); - map.insert(QLatin1String(HostKey), d->sshParameters.host); - map.insert(QLatin1String(SshPortKey), d->sshParameters.port); - map.insert(QLatin1String(UserNameKey), d->sshParameters.userName); + map.insert(QLatin1String(HostKey), d->sshParameters.host()); + map.insert(QLatin1String(SshPortKey), d->sshParameters.port()); + map.insert(QLatin1String(UserNameKey), d->sshParameters.userName()); map.insert(QLatin1String(AuthKey), d->sshParameters.authenticationType); - map.insert(QLatin1String(PasswordKey), d->sshParameters.password); + map.insert(QLatin1String(PasswordKey), d->sshParameters.password()); map.insert(QLatin1String(KeyFileKey), d->sshParameters.privateKeyFile); map.insert(QLatin1String(TimeoutKey), d->sshParameters.timeout); map.insert(QLatin1String(HostKeyCheckingKey), d->sshParameters.hostKeyCheckingMode); @@ -416,7 +416,7 @@ QUrl IDevice::toolControlChannel(const ControlChannelHint &) const { QUrl url; url.setScheme(Utils::urlTcpScheme()); - url.setHost(d->sshParameters.host); + url.setHost(d->sshParameters.host()); return url; } diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp index e1c1bf091d..195fa66293 100644 --- a/src/plugins/projectexplorer/kitinformation.cpp +++ b/src/plugins/projectexplorer/kitinformation.cpp @@ -696,17 +696,17 @@ void DeviceKitInformation::addToMacroExpander(Kit *kit, Utils::MacroExpander *ex expander->registerVariable("Device:HostAddress", tr("Host address"), [kit]() -> QString { const IDevice::ConstPtr device = DeviceKitInformation::device(kit); - return device ? device->sshParameters().host : QString(); + return device ? device->sshParameters().host() : QString(); }); expander->registerVariable("Device:SshPort", tr("SSH port"), [kit]() -> QString { const IDevice::ConstPtr device = DeviceKitInformation::device(kit); - return device ? QString::number(device->sshParameters().port) : QString(); + return device ? QString::number(device->sshParameters().port()) : QString(); }); expander->registerVariable("Device:UserName", tr("User name"), [kit]() -> QString { const IDevice::ConstPtr device = DeviceKitInformation::device(kit); - return device ? device->sshParameters().userName : QString(); + return device ? device->sshParameters().userName() : QString(); }); expander->registerVariable("Device:KeyFile", tr("Private key file"), [kit]() -> QString { diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index ea8794cdd4..8387842bf0 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1422,7 +1422,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er []() -> QString { Kit *kit = currentKit(); const IDevice::ConstPtr device = DeviceKitInformation::device(kit); - return device ? device->sshParameters().host : QString(); + return device ? device->sshParameters().host() : QString(); }); expander->registerVariable("CurrentDevice:SshPort", @@ -1430,7 +1430,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er []() -> QString { Kit *kit = currentKit(); const IDevice::ConstPtr device = DeviceKitInformation::device(kit); - return device ? QString::number(device->sshParameters().port) : QString(); + return device ? QString::number(device->sshParameters().port()) : QString(); }); expander->registerVariable("CurrentDevice:UserName", @@ -1438,7 +1438,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er []() -> QString { Kit *kit = currentKit(); const IDevice::ConstPtr device = DeviceKitInformation::device(kit); - return device ? device->sshParameters().userName : QString(); + return device ? device->sshParameters().userName() : QString(); }); diff --git a/src/plugins/qnx/qnxanalyzesupport.cpp b/src/plugins/qnx/qnxanalyzesupport.cpp index f42d3ecc56..8001327ded 100644 --- a/src/plugins/qnx/qnxanalyzesupport.cpp +++ b/src/plugins/qnx/qnxanalyzesupport.cpp @@ -70,7 +70,7 @@ void QnxQmlProfilerSupport::start() Port qmlPort = m_portsGatherer->findPort(); QUrl serverUrl; - serverUrl.setHost(device()->sshParameters().host); + serverUrl.setHost(device()->sshParameters().host()); serverUrl.setPort(qmlPort.number()); serverUrl.setScheme("tcp"); m_profiler->recordData("QmlServerUrl", serverUrl); diff --git a/src/plugins/qnx/qnxdevicewizard.cpp b/src/plugins/qnx/qnxdevicewizard.cpp index cbfc872049..9137cc13a0 100644 --- a/src/plugins/qnx/qnxdevicewizard.cpp +++ b/src/plugins/qnx/qnxdevicewizard.cpp @@ -64,15 +64,11 @@ IDevice::Ptr QnxDeviceWizard::device() { QSsh::SshConnectionParameters sshParams; sshParams.options = QSsh::SshIgnoreDefaultProxy; - sshParams.host = m_setupPage->hostName(); - sshParams.userName = m_setupPage->userName(); - sshParams.port = 22; + sshParams.url = m_setupPage->url(); sshParams.timeout = 10; sshParams.authenticationType = m_setupPage->authenticationType(); - if (sshParams.authenticationType == QSsh::SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods - || sshParams.authenticationType == QSsh::SshConnectionParameters::AuthenticationTypePassword) - sshParams.password = m_setupPage->password(); - else + if (sshParams.authenticationType != QSsh::SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods + && sshParams.authenticationType != QSsh::SshConnectionParameters::AuthenticationTypePassword) sshParams.privateKeyFile = m_setupPage->privateKeyFilePath(); QnxDevice::Ptr device = QnxDevice::create(m_setupPage->configurationName(), diff --git a/src/plugins/remotelinux/deploymenttimeinfo.cpp b/src/plugins/remotelinux/deploymenttimeinfo.cpp index 18b3d3cbab..fea219769b 100644 --- a/src/plugins/remotelinux/deploymenttimeinfo.cpp +++ b/src/plugins/remotelinux/deploymenttimeinfo.cpp @@ -97,7 +97,7 @@ void DeploymentTimeInfo::saveDeploymentTimeStamp(const DeployableFile &deployabl systemRoot = SysRootKitInformation::sysRoot(kit).toString(); const IDevice::ConstPtr deviceConfiguration = DeviceKitInformation::device(kit); - const QString host = deviceConfiguration->sshParameters().host; + const QString host = deviceConfiguration->sshParameters().host(); d->lastDeployed.insert( DeployParameters(deployableFile, host, systemRoot), @@ -115,7 +115,7 @@ bool DeploymentTimeInfo::hasChangedSinceLastDeployment(const DeployableFile &dep systemRoot = SysRootKitInformation::sysRoot(kit).toString(); const IDevice::ConstPtr deviceConfiguration = DeviceKitInformation::device(kit); - const QString host = deviceConfiguration->sshParameters().host; + const QString host = deviceConfiguration->sshParameters().host(); const DeployParameters dp(deployableFile, host, systemRoot); diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp index cc46d1bcdd..cafe7cc29a 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp @@ -106,14 +106,14 @@ void GenericLinuxDeviceConfigurationWidget::authenticationTypeChanged() void GenericLinuxDeviceConfigurationWidget::hostNameEditingFinished() { SshConnectionParameters sshParams = device()->sshParameters(); - sshParams.host = m_ui->hostLineEdit->text().trimmed(); + sshParams.setHost(m_ui->hostLineEdit->text().trimmed()); device()->setSshParameters(sshParams); } void GenericLinuxDeviceConfigurationWidget::sshPortEditingFinished() { SshConnectionParameters sshParams = device()->sshParameters(); - sshParams.port = m_ui->sshPortSpinBox->value(); + sshParams.setPort(m_ui->sshPortSpinBox->value()); device()->setSshParameters(sshParams); } @@ -127,14 +127,14 @@ void GenericLinuxDeviceConfigurationWidget::timeoutEditingFinished() void GenericLinuxDeviceConfigurationWidget::userNameEditingFinished() { SshConnectionParameters sshParams = device()->sshParameters(); - sshParams.userName = m_ui->userLineEdit->text(); + sshParams.setUserName(m_ui->userLineEdit->text()); device()->setSshParameters(sshParams); } void GenericLinuxDeviceConfigurationWidget::passwordEditingFinished() { SshConnectionParameters sshParams = device()->sshParameters(); - sshParams.password = m_ui->pwdLineEdit->text(); + sshParams.setPassword(m_ui->pwdLineEdit->text()); device()->setSshParameters(sshParams); } @@ -235,12 +235,12 @@ void GenericLinuxDeviceConfigurationWidget::initGui() m_ui->sshPortSpinBox->setEnabled(!device()->isAutoDetected()); m_ui->hostKeyCheckBox->setChecked(sshParams.hostKeyCheckingMode != SshHostKeyCheckingNone); - m_ui->hostLineEdit->setText(sshParams.host); - m_ui->sshPortSpinBox->setValue(sshParams.port); + m_ui->hostLineEdit->setText(sshParams.host()); + m_ui->sshPortSpinBox->setValue(sshParams.port()); m_ui->portsLineEdit->setText(device()->freePorts().toString()); m_ui->timeoutSpinBox->setValue(sshParams.timeout); - m_ui->userLineEdit->setText(sshParams.userName); - m_ui->pwdLineEdit->setText(sshParams.password); + m_ui->userLineEdit->setText(sshParams.userName()); + m_ui->pwdLineEdit->setText(sshParams.password()); m_ui->keyFileLineEdit->setPath(sshParams.privateKeyFile); m_ui->showPasswordCheckBox->setChecked(false); m_ui->gdbServerLineEdit->setText(device()->debugServerPath()); diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp index a94a4ea0de..f2eb58a613 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp @@ -72,14 +72,10 @@ IDevice::Ptr GenericLinuxDeviceConfigurationWizard::device() { SshConnectionParameters sshParams; sshParams.options &= ~SshConnectionOptions(SshEnableStrictConformanceChecks); // For older SSH servers. - sshParams.host = d->setupPage.hostName(); - sshParams.userName = d->setupPage.userName(); - sshParams.port = 22; + sshParams.url = d->setupPage.url(); sshParams.timeout = 10; sshParams.authenticationType = d->setupPage.authenticationType(); - if (sshParams.authenticationType != SshConnectionParameters::AuthenticationTypePublicKey) - sshParams.password = d->setupPage.password(); - else + if (sshParams.authenticationType == SshConnectionParameters::AuthenticationTypePublicKey) sshParams.privateKeyFile = d->setupPage.privateKeyFilePath(); IDevice::Ptr device = LinuxDevice::create(d->setupPage.configurationName(), Core::Id(Constants::GenericLinuxOsType), IDevice::Hardware); diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp index 5bd8bf6c89..d3524e4bcc 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp @@ -88,7 +88,9 @@ void GenericLinuxDeviceConfigurationWizardSetupPage::initializePage() bool GenericLinuxDeviceConfigurationWizardSetupPage::isComplete() const { - return !configurationName().isEmpty() && !hostName().isEmpty() && !userName().isEmpty() + return !configurationName().isEmpty() + && !d->ui.hostNameLineEdit->text().trimmed().isEmpty() + && !d->ui.userNameLineEdit->text().trimmed().isEmpty() && (authenticationType() != SshConnectionParameters::AuthenticationTypePublicKey || d->ui.privateKeyPathChooser->isValid()); } @@ -98,14 +100,14 @@ QString GenericLinuxDeviceConfigurationWizardSetupPage::configurationName() cons return d->ui.nameLineEdit->text().trimmed(); } -QString GenericLinuxDeviceConfigurationWizardSetupPage::hostName() const +QUrl GenericLinuxDeviceConfigurationWizardSetupPage::url() const { - return d->ui.hostNameLineEdit->text().trimmed(); -} - -QString GenericLinuxDeviceConfigurationWizardSetupPage::userName() const -{ - return d->ui.userNameLineEdit->text().trimmed(); + QUrl url; + url.setHost(d->ui.hostNameLineEdit->text().trimmed()); + url.setUserName(d->ui.userNameLineEdit->text().trimmed()); + url.setPassword(d->ui.passwordLineEdit->text()); + url.setPort(22); + return url; } SshConnectionParameters::AuthenticationType GenericLinuxDeviceConfigurationWizardSetupPage::authenticationType() const @@ -116,11 +118,6 @@ SshConnectionParameters::AuthenticationType GenericLinuxDeviceConfigurationWizar : SshConnectionParameters::AuthenticationTypeAgent; } -QString GenericLinuxDeviceConfigurationWizardSetupPage::password() const -{ - return d->ui.passwordLineEdit->text(); -} - QString GenericLinuxDeviceConfigurationWizardSetupPage::privateKeyFilePath() const { return d->ui.privateKeyPathChooser->path(); diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.h b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.h index b3d12aa897..5e368f0754 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.h +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.h @@ -49,10 +49,8 @@ public: bool isComplete() const; QString configurationName() const; - QString hostName() const; - QString userName() const; + QUrl url() const; QSsh::SshConnectionParameters::AuthenticationType authenticationType() const; - QString password() const; QString privateKeyFilePath() const; virtual QString defaultConfigurationName() const; diff --git a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp index 1230b20ff0..836ab11fd5 100644 --- a/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxqmltoolingsupport.cpp @@ -62,7 +62,7 @@ void RemoteLinuxQmlToolingSupport::start() QUrl serverUrl; serverUrl.setScheme(urlTcpScheme()); - serverUrl.setHost(device()->sshParameters().host); + serverUrl.setHost(device()->sshParameters().host()); serverUrl.setPort(qmlPort.number()); m_runworker->recordData("QmlServerUrl", serverUrl); |