summaryrefslogtreecommitdiffstats
path: root/kdessh/sshdlg.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit2bda8f7717adf28da4af0d34fb82f63d2868c31d (patch)
tree8d927b7b47a90c4adb646482a52613f58acd6f8c /kdessh/sshdlg.cpp
downloadtdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.tar.gz
tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdessh/sshdlg.cpp')
-rw-r--r--kdessh/sshdlg.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/kdessh/sshdlg.cpp b/kdessh/sshdlg.cpp
new file mode 100644
index 0000000..a652688
--- /dev/null
+++ b/kdessh/sshdlg.cpp
@@ -0,0 +1,80 @@
+/* vi: ts=8 sts=4 sw=4
+ *
+ * $Id$
+ *
+ * This file is part of the KDE project, module kdesu.
+ * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
+ */
+
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include <kdesu/ssh.h>
+#include "sshdlg.h"
+
+
+KDEsshDialog::KDEsshDialog(QCString host, QCString user, QCString stub,
+ QString prompt, bool enableKeep)
+ : KPasswordDialog(Password, enableKeep, 0)
+{
+ m_Host = host;
+ m_User = user;
+ m_Stub = stub;
+
+ setCaption(QString::fromLatin1("%1@%2").arg(m_User).arg(m_Host));
+
+ // Make the prompt a little more polite :-)
+ if (prompt.lower().left(6) == QString::fromLatin1("enter "))
+ prompt.remove(0, 6);
+ int pos = prompt.find(':');
+ if (pos != -1)
+ prompt.remove(pos, 10);
+ prompt += '.';
+ prompt.prepend(i18n("The action you requested needs authentication. "
+ "Please enter "));
+ setPrompt(prompt);
+}
+
+
+KDEsshDialog::~KDEsshDialog()
+{
+}
+
+
+bool KDEsshDialog::checkPassword(const char *password)
+{
+ SshProcess proc(m_Host, m_User);
+ proc.setStub(m_Stub);
+
+ int ret = proc.checkInstall(password);
+ switch (ret)
+ {
+ case -1:
+ KMessageBox::error(this, i18n("Conversation with ssh failed.\n"));
+ done(Rejected);
+ return false;
+
+ case 0:
+ return true;
+
+ case SshProcess::SshNotFound:
+ KMessageBox::sorry(this,
+ i18n("The programs 'ssh' or 'kdesu_stub' cannot be found.\n"
+ "Make sure your PATH is set correctly."));
+ done(Rejected);
+ return false;
+
+ case SshProcess::SshIncorrectPassword:
+ KMessageBox::sorry(this, i18n("Incorrect password. Please try again."));
+ return false;
+
+ default:
+ KMessageBox::error(this, i18n("Internal error: Illegal return from "
+ "SshProcess::checkInstall()"));
+ done(Rejected);
+ }
+ return true;
+}
+
+
+#include "sshdlg.moc"