void SettingsDialog::browse()
{
- QString path = QFileDialog::getOpenFileName(this, tr("Identity file"));
+ // 2010-08-13 default path -> /home/user (bug#6219)
+ QString path = QFileDialog::getOpenFileName(this, tr("Identity file"),"/home/user");
if(!path.isNull())
identityEdit->setText(path);
}
*/
QString getKeyOption();
+ /*! Password or passphrase (UNSECURE!)
+ */
+ virtual QString getPassword() const = 0;
+
private:
/*! Receiver for debugMsg(QString&) signals */
QObject* debugMonitor_;
void UrpoConnectionSettings::setHost(const QString &host)
{
host_ = host;
+ password_ = QString();
}
void UrpoConnectionSettings::setIdentity(const QString &identity)
{
identity_ = identity;
+ password_ = QString();
}
void UrpoConnectionSettings::setUserid(const QString &userid)
{
userid_ = userid;
+ password_ = QString();
+}
+
+QString UrpoConnectionSettings::getPassword() const
+{
+ return password_;
+}
+
+void UrpoConnectionSettings::setPassword(QString &password)
+{
+ password_ = password;
}
void UrpoConnectionSettings::store() const
QString getIdentity() const;
QString getUserid() const;
+ QString getPassword() const;
+ void setPassword(QString &password);
+
void setHost(const QString &host);
void setIdentity(const QString &password);
void setUserid(const QString &userid);
QString host_; /*! Host name or ip address */
QString identity_; /*! Identity (private key) file path */
QString userid_; /*! Userid in remote host */
+ QString password_; /*! Password */
bool storePassword_; /*! Allow to store password */
#include "urpoprocess.h"
#include "urpoconnection.h"
#include <QTimer>
+#include <QInputDialog>
+#include <QLineEdit>
int const UrpoProcess::DEFAULTTIMEOUT;
{
// If process is still running, it means timeout!
if( status_ == Running)
- fail(Timeout);
+ {
+ // Read output
+ QByteArray bytes = qprocess_.readAllStandardOutput();
+ QString string(bytes);
+ sendDebugMessage(string);
+
+ if(string.contains("'s password:") || string.contains("passphrase:"))
+ {
+ // Try to ask password
+ if( storedPassword_.isEmpty())
+ {
+ if( string.contains("'s password:") )
+ storedPassword_ = QInputDialog::getText( 0, tr("Server ask password"), tr("Password:"), QLineEdit::PasswordEchoOnEdit );
+ else
+ storedPassword_ = QInputDialog::getText( 0, tr("Server ask passphrase"), tr("Passphrase:"), QLineEdit::PasswordEchoOnEdit );
+ }
+ qprocess_.write(storedPassword_.toAscii());
+ qprocess_.write("\n");
+
+ QTimer::singleShot( getTimeout(), this, SLOT(timeout()) );
+ status_ = PasswdRunning;
+ }
+ else
+ fail( Timeout );
+ }
+ else if( status_ == PasswdRunning )
+ fail(Timeout); // FAILS !!!
}
void UrpoProcess::start(const QString &command)
output_=string.split("\n");
status_=Successed;
emit finished(true);
+
+
}
}
#include <QObject>
#include <QStringList>
+#include <QString>
#include <QProcess>
class UrpoConnection;
Ready /*! Ready for connecting */ = 0,
Running /*! Command running */ = 1,
Successed /*! Command successed */ = 2,
- Failed /*! Command failed */ = 3
+ Failed /*! Command failed */ = 3,
+ PasswdRunning /*! Running after password sent */ = 11
};
enum UrpoError {
UrpoStatus status_;
UrpoError error_;
int timeout_; /*! Timeout in msecs */
+ QString storedPassword_; /* Password to store */
};
#endif // URPOPROCESS_H