forked from qt-creator/qt-creator
ProjectExplorer: Introduce 'userAtHostAndPort'
There is a case where we need the no-port version even with a non-standard port. Provide access to both version, but to avoid confusion, make the difference explicit in the function names. Fixes: QTCREATORBUG-29616 Change-Id: I9b93b7dd89099a4f24a7c7c0174bdc97b85666d4 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -27,6 +27,12 @@ QString SshParameters::userAtHost() const
|
||||
if (!m_userName.isEmpty())
|
||||
res = m_userName + '@';
|
||||
res += m_host;
|
||||
return res;
|
||||
}
|
||||
|
||||
QString SshParameters::userAtHostAndPort() const
|
||||
{
|
||||
QString res = SshParameters::userAtHost();
|
||||
if (m_port != 22)
|
||||
res += QString(":%1").arg(m_port);
|
||||
return res;
|
||||
@@ -142,6 +148,15 @@ const QString userAtHost()
|
||||
return userMidFix + getHostFromEnvironment();
|
||||
}
|
||||
|
||||
const QString userAtHostAndPort()
|
||||
{
|
||||
QString res = userAtHost();
|
||||
const int port = getPortFromEnvironment();
|
||||
if (port != 22)
|
||||
res += QString(":%1").arg(port);
|
||||
return res;
|
||||
}
|
||||
|
||||
SshParameters getParameters()
|
||||
{
|
||||
SshParameters params;
|
||||
|
@@ -32,6 +32,7 @@ public:
|
||||
QString userName() const { return m_userName; }
|
||||
|
||||
QString userAtHost() const;
|
||||
QString userAtHostAndPort() const;
|
||||
|
||||
void setHost(const QString &host) { m_host = host; }
|
||||
void setPort(int port) { m_port = port; }
|
||||
@@ -63,6 +64,7 @@ quint16 PROJECTEXPLORER_EXPORT getPortFromEnvironment();
|
||||
const QString PROJECTEXPLORER_EXPORT getUserFromEnvironment();
|
||||
const QString PROJECTEXPLORER_EXPORT getKeyFileFromEnvironment();
|
||||
const PROJECTEXPLORER_EXPORT QString userAtHost();
|
||||
const PROJECTEXPLORER_EXPORT QString userAtHostAndPort();
|
||||
SshParameters PROJECTEXPLORER_EXPORT getParameters();
|
||||
bool PROJECTEXPLORER_EXPORT checkParameters(const SshParameters ¶ms);
|
||||
void PROJECTEXPLORER_EXPORT printSetupHelp();
|
||||
|
@@ -33,7 +33,7 @@ static const char TEST_DIR[] = "/tmp/testdir";
|
||||
|
||||
static const FilePath baseFilePath()
|
||||
{
|
||||
return FilePath::fromString("ssh://" + SshTest::userAtHost() + QString(TEST_DIR));
|
||||
return FilePath::fromString("ssh://" + SshTest::userAtHostAndPort() + QString(TEST_DIR));
|
||||
}
|
||||
|
||||
TestLinuxDeviceFactory::TestLinuxDeviceFactory()
|
||||
@@ -55,7 +55,7 @@ TestLinuxDeviceFactory::TestLinuxDeviceFactory()
|
||||
FilePath createFile(const QString &name)
|
||||
{
|
||||
FilePath testFilePath = baseFilePath() / name;
|
||||
FilePath dummyFilePath = FilePath::fromString("ssh://" + SshTest::userAtHost() + "/dev/null");
|
||||
FilePath dummyFilePath = FilePath::fromString("ssh://" + SshTest::userAtHostAndPort() + "/dev/null");
|
||||
dummyFilePath.copyFile(testFilePath);
|
||||
return testFilePath;
|
||||
}
|
||||
|
@@ -843,13 +843,14 @@ public:
|
||||
<< m_displaylessSshParameters.host());
|
||||
cmd.addArg("/bin/sh");
|
||||
|
||||
m_shell.reset(new LinuxDeviceShell(cmd, FilePath::fromString(QString("ssh://%1/").arg(parameters.userAtHost()))));
|
||||
m_shell.reset(new LinuxDeviceShell(cmd,
|
||||
FilePath::fromString(QString("ssh://%1/").arg(parameters.userAtHostAndPort()))));
|
||||
connect(m_shell.get(), &DeviceShell::done, this, [this] {
|
||||
m_shell.release()->deleteLater();
|
||||
});
|
||||
auto result = m_shell->start();
|
||||
if (!result) {
|
||||
qCWarning(linuxDeviceLog) << "Failed to start shell for:" << parameters.userAtHost()
|
||||
qCWarning(linuxDeviceLog) << "Failed to start shell for:" << parameters.userAtHostAndPort()
|
||||
<< ", " << result.error();
|
||||
}
|
||||
return result.has_value();
|
||||
@@ -1027,16 +1028,21 @@ QString LinuxDevice::userAtHost() const
|
||||
return sshParameters().userAtHost();
|
||||
}
|
||||
|
||||
QString LinuxDevice::userAtHostAndPort() const
|
||||
{
|
||||
return sshParameters().userAtHostAndPort();
|
||||
}
|
||||
|
||||
FilePath LinuxDevice::rootPath() const
|
||||
{
|
||||
return FilePath::fromParts(u"ssh", userAtHost(), u"/");
|
||||
return FilePath::fromParts(u"ssh", userAtHostAndPort(), u"/");
|
||||
}
|
||||
|
||||
bool LinuxDevice::handlesFile(const FilePath &filePath) const
|
||||
{
|
||||
if (filePath.scheme() == u"device" && filePath.host() == id().toString())
|
||||
return true;
|
||||
if (filePath.scheme() == u"ssh" && filePath.host() == userAtHost())
|
||||
if (filePath.scheme() == u"ssh" && filePath.host() == userAtHostAndPort())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ public:
|
||||
bool usableAsBuildDevice() const override;
|
||||
|
||||
QString userAtHost() const;
|
||||
QString userAtHostAndPort() const;
|
||||
|
||||
Utils::FilePath rootPath() const override;
|
||||
|
||||
|
Reference in New Issue
Block a user