forked from qt-creator/qt-creator
RemoteLinux: Use FilePath in GLDCWKDP::privateKeyFilePath
a.k.a. GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::privateKeyFilePath. Change-Id: Ic17c7b88d3540a5f7c1c983effc3f59f25102528 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
#include <QDir>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@@ -149,10 +148,10 @@ QString GenericLinuxDeviceConfigurationWizardFinalPage::infoText() const
|
|||||||
|
|
||||||
struct GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::Private
|
struct GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::Private
|
||||||
{
|
{
|
||||||
QStringList defaultKeys() const
|
FilePaths defaultKeys() const
|
||||||
{
|
{
|
||||||
const QString baseDir = QDir::homePath() + "/.ssh";
|
const FilePath baseDir = FileUtils::homePath() / ".ssh";
|
||||||
return QStringList{baseDir + "/id_rsa", baseDir + "/id_ecdsa", baseDir + "/id_ed25519"};
|
return {baseDir / "id_rsa", baseDir / "id_ecdsa", baseDir / "id_ed25519"};
|
||||||
}
|
}
|
||||||
|
|
||||||
PathChooser keyFileChooser;
|
PathChooser keyFileChooser;
|
||||||
@@ -200,9 +199,9 @@ GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::GenericLinuxDeviceConfig
|
|||||||
d->iconLabel.clear();
|
d->iconLabel.clear();
|
||||||
emit completeChanged();
|
emit completeChanged();
|
||||||
});
|
});
|
||||||
for (const QString &defaultKey : d->defaultKeys()) {
|
for (const FilePath &defaultKey : d->defaultKeys()) {
|
||||||
if (QFileInfo::exists(defaultKey)) {
|
if (defaultKey.exists()) {
|
||||||
d->keyFileChooser.setPath(defaultKey);
|
d->keyFileChooser.setFilePath(defaultKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,7 +220,7 @@ void GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::setDevice(const Lin
|
|||||||
void GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::initializePage()
|
void GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::initializePage()
|
||||||
{
|
{
|
||||||
if (!d->device->sshParameters().privateKeyFile.isEmpty())
|
if (!d->device->sshParameters().privateKeyFile.isEmpty())
|
||||||
d->keyFileChooser.setPath(privateKeyFilePath());
|
d->keyFileChooser.setFilePath(privateKeyFilePath());
|
||||||
d->iconLabel.clear();
|
d->iconLabel.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +231,7 @@ bool GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::isComplete() const
|
|||||||
|
|
||||||
bool GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::validatePage()
|
bool GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::validatePage()
|
||||||
{
|
{
|
||||||
if (!d->defaultKeys().contains(d->keyFileChooser.filePath().toString())) {
|
if (!d->defaultKeys().contains(d->keyFileChooser.filePath())) {
|
||||||
SshConnectionParameters sshParams = d->device->sshParameters();
|
SshConnectionParameters sshParams = d->device->sshParameters();
|
||||||
sshParams.authenticationType = SshConnectionParameters::AuthenticationTypeSpecificKey;
|
sshParams.authenticationType = SshConnectionParameters::AuthenticationTypeSpecificKey;
|
||||||
sshParams.privateKeyFile = d->keyFileChooser.filePath();
|
sshParams.privateKeyFile = d->keyFileChooser.filePath();
|
||||||
@@ -241,9 +240,9 @@ bool GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::validatePage()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::privateKeyFilePath() const
|
FilePath GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::privateKeyFilePath() const
|
||||||
{
|
{
|
||||||
return d->keyFileChooser.filePath().toString();
|
return d->keyFileChooser.filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::createKey()
|
void GenericLinuxDeviceConfigurationWizardKeyDeploymentPage::createKey()
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ private:
|
|||||||
bool isComplete() const override;
|
bool isComplete() const override;
|
||||||
bool validatePage() override;
|
bool validatePage() override;
|
||||||
|
|
||||||
QString privateKeyFilePath() const;
|
Utils::FilePath privateKeyFilePath() const;
|
||||||
void createKey();
|
void createKey();
|
||||||
void deployKey();
|
void deployKey();
|
||||||
|
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog(
|
|||||||
tr("Public Key Files (*.pub);;All Files (*)"));
|
tr("Public Key Files (*.pub);;All Files (*)"));
|
||||||
if (publicKeyFileName.isEmpty())
|
if (publicKeyFileName.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return new PublicKeyDeploymentDialog(deviceConfig, publicKeyFileName.toString(), parent);
|
return new PublicKeyDeploymentDialog(deviceConfig, publicKeyFileName, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const IDevice::ConstPtr &deviceConfig,
|
PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const IDevice::ConstPtr &deviceConfig,
|
||||||
const QString &publicKeyFileName, QWidget *parent)
|
const FilePath &publicKeyFileName, QWidget *parent)
|
||||||
: QProgressDialog(parent), d(new PublicKeyDeploymentDialogPrivate)
|
: QProgressDialog(parent), d(new PublicKeyDeploymentDialogPrivate)
|
||||||
{
|
{
|
||||||
setAutoReset(false);
|
setAutoReset(false);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
|
|
||||||
PublicKeyDeploymentDialog(const ProjectExplorer::IDevice::ConstPtr &deviceConfig,
|
PublicKeyDeploymentDialog(const ProjectExplorer::IDevice::ConstPtr &deviceConfig,
|
||||||
const QString &publicKeyFileName, QWidget *parent = nullptr);
|
const Utils::FilePath &publicKeyFileName, QWidget *parent = nullptr);
|
||||||
|
|
||||||
~PublicKeyDeploymentDialog() override;
|
~PublicKeyDeploymentDialog() override;
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,10 @@
|
|||||||
#include "sshkeydeployer.h"
|
#include "sshkeydeployer.h"
|
||||||
|
|
||||||
#include <ssh/sshremoteprocessrunner.h>
|
#include <ssh/sshremoteprocessrunner.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
using namespace QSsh;
|
using namespace QSsh;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -53,12 +54,12 @@ SshKeyDeployer::~SshKeyDeployer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams,
|
void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams,
|
||||||
const QString &keyFilePath)
|
const FilePath &keyFilePath)
|
||||||
{
|
{
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
Utils::FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(Utils::FilePath::fromString(keyFilePath))) {
|
if (!reader.fetch(keyFilePath)) {
|
||||||
emit error(tr("Public key error: %1").arg(reader.errorString()));
|
emit error(tr("Public key error: %1").arg(reader.errorString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace QSsh { class SshConnectionParameters; }
|
namespace QSsh { class SshConnectionParameters; }
|
||||||
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
namespace Internal { class SshKeyDeployerPrivate; }
|
namespace Internal { class SshKeyDeployerPrivate; }
|
||||||
@@ -43,7 +44,7 @@ public:
|
|||||||
~SshKeyDeployer() override;
|
~SshKeyDeployer() override;
|
||||||
|
|
||||||
void deployPublicKey(const QSsh::SshConnectionParameters &sshParams,
|
void deployPublicKey(const QSsh::SshConnectionParameters &sshParams,
|
||||||
const QString &keyFilePath);
|
const Utils::FilePath &keyFilePath);
|
||||||
void stopDeployment();
|
void stopDeployment();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
Reference in New Issue
Block a user