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