forked from qt-creator/qt-creator
RemoteLinux: Offer to open a remote shell
... in the settings dialog. This allows users to poke around in the device they'be just configured, e.g. for doing quick custom checks. [ChangeLog] A remote shell can now be started for Linux devices. Change-Id: I4570ca89d64606029759767a9f771168d7273510 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -86,6 +86,7 @@ SshDeviceProcess::~SshDeviceProcess()
|
|||||||
void SshDeviceProcess::start(const Runnable &runnable)
|
void SshDeviceProcess::start(const Runnable &runnable)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Inactive, return);
|
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Inactive, return);
|
||||||
|
QTC_ASSERT(runInTerminal() || !runnable.executable.isEmpty(), return);
|
||||||
d->setState(SshDeviceProcessPrivate::Connecting);
|
d->setState(SshDeviceProcessPrivate::Connecting);
|
||||||
|
|
||||||
d->errorMessage.clear();
|
d->errorMessage.clear();
|
||||||
@@ -185,7 +186,9 @@ void SshDeviceProcess::handleConnected()
|
|||||||
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connecting, return);
|
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connecting, return);
|
||||||
d->setState(SshDeviceProcessPrivate::Connected);
|
d->setState(SshDeviceProcessPrivate::Connected);
|
||||||
|
|
||||||
d->process = d->connection->createRemoteProcess(fullCommandLine(d->runnable).toUtf8());
|
d->process = runInTerminal() && d->runnable.executable.isEmpty()
|
||||||
|
? d->connection->createRemoteShell()
|
||||||
|
: d->connection->createRemoteProcess(fullCommandLine(d->runnable).toUtf8());
|
||||||
const QString display = d->displayName();
|
const QString display = d->displayName();
|
||||||
if (!display.isEmpty())
|
if (!display.isEmpty())
|
||||||
d->process->requestX11Forwarding(display);
|
d->process->requestX11Forwarding(display);
|
||||||
@@ -303,6 +306,8 @@ QString SshDeviceProcess::fullCommandLine(const Runnable &runnable) const
|
|||||||
|
|
||||||
void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal)
|
void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal)
|
||||||
{
|
{
|
||||||
|
if (runnable.executable.isEmpty())
|
||||||
|
return;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SshDeviceProcessPrivate::Inactive:
|
case SshDeviceProcessPrivate::Inactive:
|
||||||
QTC_ASSERT(false, return);
|
QTC_ASSERT(false, return);
|
||||||
|
|||||||
@@ -34,10 +34,12 @@
|
|||||||
#include "remotelinuxenvironmentreader.h"
|
#include "remotelinuxenvironmentreader.h"
|
||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
|
#include <coreplugin/messagemanager.h>
|
||||||
#include <projectexplorer/devicesupport/sshdeviceprocesslist.h>
|
#include <projectexplorer/devicesupport/sshdeviceprocesslist.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <ssh/sshremoteprocessrunner.h>
|
#include <ssh/sshremoteprocessrunner.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/port.h>
|
#include <utils/port.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -50,6 +52,9 @@ namespace RemoteLinux {
|
|||||||
const char Delimiter0[] = "x--";
|
const char Delimiter0[] = "x--";
|
||||||
const char Delimiter1[] = "---";
|
const char Delimiter1[] = "---";
|
||||||
|
|
||||||
|
|
||||||
|
static Core::Id openShellActionId() { return "RemoteLinux.OpenShellAction"; }
|
||||||
|
|
||||||
static QString visualizeNull(QString s)
|
static QString visualizeNull(QString s)
|
||||||
{
|
{
|
||||||
return s.replace(QLatin1Char('\0'), QLatin1String("<null>"));
|
return s.replace(QLatin1Char('\0'), QLatin1String("<null>"));
|
||||||
@@ -182,7 +187,10 @@ IDeviceWidget *LinuxDevice::createWidget()
|
|||||||
|
|
||||||
QList<Core::Id> LinuxDevice::actionIds() const
|
QList<Core::Id> LinuxDevice::actionIds() const
|
||||||
{
|
{
|
||||||
return QList<Core::Id>() << Core::Id(Constants::GenericDeployKeyToDeviceActionId);
|
QList<Core::Id> ids({Core::Id(Constants::GenericDeployKeyToDeviceActionId)});
|
||||||
|
if (Utils::HostOsInfo::isAnyUnixHost())
|
||||||
|
ids << openShellActionId();
|
||||||
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LinuxDevice::displayNameForActionId(Core::Id actionId) const
|
QString LinuxDevice::displayNameForActionId(Core::Id actionId) const
|
||||||
@@ -191,6 +199,8 @@ QString LinuxDevice::displayNameForActionId(Core::Id actionId) const
|
|||||||
|
|
||||||
if (actionId == Constants::GenericDeployKeyToDeviceActionId)
|
if (actionId == Constants::GenericDeployKeyToDeviceActionId)
|
||||||
return tr("Deploy Public Key...");
|
return tr("Deploy Public Key...");
|
||||||
|
if (actionId == openShellActionId())
|
||||||
|
return tr("Open Remote Shell");
|
||||||
return QString(); // Can't happen.
|
return QString(); // Can't happen.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,13 +208,35 @@ void LinuxDevice::executeAction(Core::Id actionId, QWidget *parent)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(actionIds().contains(actionId), return);
|
QTC_ASSERT(actionIds().contains(actionId), return);
|
||||||
|
|
||||||
QDialog *d = nullptr;
|
if (actionId == Constants::GenericDeployKeyToDeviceActionId) {
|
||||||
const LinuxDevice::ConstPtr device = sharedFromThis().staticCast<const LinuxDevice>();
|
const LinuxDevice::ConstPtr device = sharedFromThis().staticCast<const LinuxDevice>();
|
||||||
if (actionId == Constants::GenericDeployKeyToDeviceActionId)
|
QDialog * const d = PublicKeyDeploymentDialog::createDialog(device, parent);
|
||||||
d = PublicKeyDeploymentDialog::createDialog(device, parent);
|
if (d)
|
||||||
if (d)
|
d->exec();
|
||||||
d->exec();
|
delete d;
|
||||||
delete d;
|
return;
|
||||||
|
}
|
||||||
|
if (actionId == openShellActionId()) {
|
||||||
|
DeviceProcess * const proc = createProcess(nullptr);
|
||||||
|
QObject::connect(proc, &DeviceProcess::finished, [proc] {
|
||||||
|
if (!proc->errorString().isEmpty()) {
|
||||||
|
Core::MessageManager::write(tr("Error running remote shell: %1")
|
||||||
|
.arg(proc->errorString()),
|
||||||
|
Core::MessageManager::ModeSwitch);
|
||||||
|
}
|
||||||
|
proc->deleteLater();
|
||||||
|
});
|
||||||
|
QObject::connect(proc, &DeviceProcess::error, [proc] {
|
||||||
|
Core::MessageManager::write(tr("Error starting remote shell."),
|
||||||
|
Core::MessageManager::ModeSwitch);
|
||||||
|
proc->deleteLater();
|
||||||
|
});
|
||||||
|
Runnable runnable;
|
||||||
|
runnable.device = sharedFromThis().staticCast<const LinuxDevice>();
|
||||||
|
proc->setRunInTerminal(true);
|
||||||
|
proc->start(runnable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::OsType LinuxDevice::osType() const
|
Utils::OsType LinuxDevice::osType() const
|
||||||
|
|||||||
Reference in New Issue
Block a user