Commit 6a892085 authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Don't try to issue an ssh connection if not on the shell

parent fc866e6f
......@@ -12,6 +12,8 @@
#include <QString>
#include <QVector>
#include "konsoleprivate_export.h"
namespace Konsole
{
/**
......@@ -56,7 +58,7 @@ namespace Konsole
* }
* @endcode
*/
class ProcessInfo
class KONSOLEPRIVATE_EXPORT ProcessInfo
{
public:
/**
......
......@@ -7,8 +7,11 @@
#include "sshmanagerpluginwidget.h"
#include "ProcessInfo.h"
#include "konsoledebug.h"
#include "session/Session.h"
#include "session/SessionController.h"
#include "sshmanagermodel.h"
#include "terminalDisplay/TerminalDisplay.h"
......@@ -383,6 +386,26 @@ void SSHManagerTreeWidget::connectRequested(const QModelIndex &idx)
return;
}
Konsole::ProcessInfo *info = d->controller->session()->getProcessInfo();
bool ok = false;
QString processName = info->name(&ok);
if (!ok) {
qDebug() << "Could not get the process name, assume that we can't request a connection";
return;
}
if (!QSet<QString>({QStringLiteral("fish"),
QStringLiteral("bash"),
QStringLiteral("dash"),
QStringLiteral("sh"),
QStringLiteral("csh"),
QStringLiteral("ksh"),
QStringLiteral("zsh")})
.contains(processName)) {
qDebug() << "You have an application running on the top of the shell, can't request a connection.";
return;
}
auto item = d->model->itemFromIndex(sourceIdx);
auto data = item->data(SSHManagerModel::SSHRole).value<SSHConfigurationData>();
......
......@@ -75,6 +75,9 @@ public:
explicit Session(QObject *parent = nullptr);
~Session() override;
/* Returns the process info so the plugins can peek at it's name */
ProcessInfo *getProcessInfo();
/**
* Connect to an existing terminal. When a new Session() is constructed it
* automatically searches for and opens a new teletype. If you want to
......@@ -791,7 +794,6 @@ private:
// if the program fails to start, or if the shell exits in
// an unsuccessful manner
void terminalWarning(const QString &message);
ProcessInfo *getProcessInfo();
void updateSessionProcessInfo();
bool updateForegroundProcessInfo();
void updateWorkingDirectory();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment