Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
DlgUserPassword.cpp
1#include "DlgUserPassword.h"
2#include "ui_DlgUserPassword.h"
3#include <QLoggingCategory>
4
5static Q_LOGGING_CATEGORY(log, "Channel.SSH.Tunnel.DlgUserPassword")
6
7static int g_CDlgUserPassword = qRegisterMetaType<CDlgUserPassword>();
8
10 : QDialog(parent)
11 , ui(new Ui::CDlgUserPassword)
12{
13 ui->setupUi(this);
14}
15
16CDlgUserPassword::~CDlgUserPassword()
17{
18 delete ui;
19}
20
21CDlgUserPassword::CDlgUserPassword(const CDlgUserPassword &other)
22{
23 m_pPara = other.m_pPara;
24}
25
26void CDlgUserPassword::SetContext(void *pContext)
27{
28 m_pPara = (CParameterChannelSSH*)pContext;
29 if(!m_pPara) {
30 qCritical(log) << "The pContext is null";
31 return;
32 }
33
34 if(m_pPara->GetAuthenticationMethod() == SSH_AUTH_METHOD_PASSWORD) {
35 setWindowTitle(tr("Set SSH user and password"));
36 ui->leUser->setText(m_pPara->GetUser());
37 }
38
39 if(m_pPara->GetAuthenticationMethod() == SSH_AUTH_METHOD_PUBLICKEY) {
40 setWindowTitle(tr("Set SSH passphrase"));
41 ui->leUser->setEnabled(false);
42 }
43
44 ui->lbText->setText(tr("SSH host: ")
45 + m_pPara->GetServer()
46 + ":" + QString::number(m_pPara->GetPort()));
47
48 ui->lePassowrd->setText(m_pPara->GetPassword());
49}
50
51void CDlgUserPassword::accept()
52{
53 if(!m_pPara) {
54 qCritical(log) << "The pContext is null";
55 return;
56 }
57
58 m_pPara->SetUser(ui->leUser->text());
59 if(m_pPara->GetAuthenticationMethod() == SSH_AUTH_METHOD_PASSWORD)
60 m_pPara->SetPassword(ui->lePassowrd->text());
61 if(m_pPara->GetAuthenticationMethod() == SSH_AUTH_METHOD_PUBLICKEY)
62 m_pPara->SetPassphrase(ui->lePassowrd->text());
63
64 QDialog::accept();
65}