diff --git a/src/Application.cpp b/src/Application.cpp index a3d005be..a7583915 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -478,14 +478,18 @@ Session* Application::createSSHSession(Profile::Ptr profile, const KUrl& url, Session* session = SessionManager::instance()->createSession(profile); - session->sendText("ssh "); - - if (url.port() > -1) - session->sendText("-p " + QString::number(url.port()) + ' '); - if (url.hasUser()) - session->sendText(url.user() + '@'); - if (url.hasHost()) - session->sendText(url.host() + '\r'); + QString sshCommand = "ssh "; + if (url.port() > -1) { + sshCommand += QString("-p %1 ").arg(url.port()) ; + } + if (url.hasUser()) { + sshCommand += (url.user() + '@'); + } + if (url.hasHost()) { + sshCommand += url.host(); + } + + session->sendText(sshCommand + '\r'); // create view before starting the session process so that the session // doesn't suffer a change in terminal size right after the session diff --git a/src/SessionController.cpp b/src/SessionController.cpp index 52841794..d5d12d00 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -270,24 +270,35 @@ void SessionController::openUrl(const KUrl& url) if (!command.isEmpty()) _session->emulation()->sendText(command + '\r'); } else if (url.protocol() == "ssh") { - _session->emulation()->sendText("ssh "); - - if (url.port() > -1) - _session->emulation()->sendText("-p " + QString::number(url.port()) + ' '); - if (url.hasUser()) - _session->emulation()->sendText(url.user() + '@'); - if (url.hasHost()) - _session->emulation()->sendText(url.host() + '\r'); + QString sshCommand = "ssh "; + + if (url.port() > -1) { + sshCommand += QString("-p %1 ").arg(url.port()) ; + } + if (url.hasUser()) { + sshCommand += (url.user() + '@'); + } + if (url.hasHost()) { + sshCommand += url.host(); + } + + _session->sendText(sshCommand + '\r'); + } else if (url.protocol() == "telnet") { - _session->emulation()->sendText("telnet "); - - if (url.hasUser()) - _session->emulation()->sendText("-l " + url.user() + ' '); - if (url.hasHost()) - _session->emulation()->sendText(url.host() + ' '); - if (url.port() > -1) - _session->emulation()->sendText(QString::number(url.port())); - _session->emulation()->sendText("\r"); + QString telnetCommand = "telnet "; + + if (url.hasUser()) { + telnetCommand += QString("-l %1 ").arg(url.user()) ; + } + if (url.hasHost()) { + telnetCommand += (url.host() + ' '); + } + if (url.port() > -1) { + telnetCommand += QString::number(url.port()) ; + } + + _session->sendText(telnetCommand + '\r'); + } else { //TODO Implement handling for other Url types