You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.8 KiB
81 lines
1.8 KiB
15 years ago
|
/* vi: ts=8 sts=4 sw=4
|
||
|
*
|
||
|
* $Id$
|
||
|
*
|
||
13 years ago
|
* This file is part of the KDE project, module tdesu.
|
||
15 years ago
|
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
|
#include <tdemessagebox.h>
|
||
15 years ago
|
|
||
13 years ago
|
#include <tdesu/ssh.h>
|
||
15 years ago
|
#include "sshdlg.h"
|
||
|
|
||
|
|
||
12 years ago
|
TDEsshDialog::TDEsshDialog(TQCString host, TQCString user, TQCString stub,
|
||
14 years ago
|
TQString prompt, bool enableKeep)
|
||
15 years ago
|
: KPasswordDialog(Password, enableKeep, 0)
|
||
|
{
|
||
|
m_Host = host;
|
||
|
m_User = user;
|
||
|
m_Stub = stub;
|
||
|
|
||
13 years ago
|
setCaption(TQString::fromLatin1("%1@%2").arg(TQString(m_User)).arg(TQString(m_Host)));
|
||
15 years ago
|
|
||
|
// Make the prompt a little more polite :-)
|
||
13 years ago
|
if (prompt.lower().left(6) == TQString::fromLatin1("enter "))
|
||
15 years ago
|
prompt.remove(0, 6);
|
||
13 years ago
|
int pos = prompt.find(':');
|
||
15 years ago
|
if (pos != -1)
|
||
|
prompt.remove(pos, 10);
|
||
|
prompt += '.';
|
||
|
prompt.prepend(i18n("The action you requested needs authentication. "
|
||
|
"Please enter "));
|
||
|
setPrompt(prompt);
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
TDEsshDialog::~TDEsshDialog()
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
bool TDEsshDialog::checkPassword(const char *password)
|
||
15 years ago
|
{
|
||
|
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,
|
||
13 years ago
|
i18n("The programs 'ssh' or 'tdesu_stub' cannot be found.\n"
|
||
15 years ago
|
"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"
|