Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
FrmParameterICE.cpp
1
2
3#include "FrmParameterICE.h"
4#include "ui_FrmParameterICE.h"
5
6#include "Ice.h"
7#ifdef HAVE_QXMPP
8 #include "QXmppUtils.h"
9#endif
10
11#include <QDebug>
12#include <QMessageBox>
13
15 QWidget(parent),
16 ui(new Ui::CFrmParameterICE),
17 m_pParameters(para)
18{
19 bool check = false;
20 ui->setupUi(this);
21
22 QSharedPointer<CIceSignal> signal = CICE::Instance()->GetSignal();
23 if(signal)
24 {
25 SetConnectButton(signal->IsConnected());
26 check = connect(signal.data(), SIGNAL(sigConnected()),
27 this, SLOT(slotConnected()));
28 Q_ASSERT(check);
29 check = connect(signal.data(), SIGNAL(sigDisconnected()),
30 this, SLOT(slotDisconnected()));
31 Q_ASSERT(check);
32 check = connect(signal.data(), SIGNAL(sigError(int, const QString&)),
33 this, SLOT(slotError(int, const QString&)));
34 Q_ASSERT(check);
35 }
36
37 Init();
38}
39
40CFrmParameterICE::~CFrmParameterICE()
41{
42 delete ui;
43 qDebug() << "CFrmParameterICE::~CFrmParameterICE()";
44}
45
47{
48 m_pParameters->setIce(ui->cbEnableICE->isChecked());
49 m_pParameters->SetIceDebug(ui->cbEnableIceDebug->isChecked());
50 m_pParameters->setSignalServer(ui->leSignalServer->text());
51 m_pParameters->setSignalPort(ui->sbSignalPort->value());
52 m_pParameters->setSignalUser(ui->leSignalName->text());
53 m_pParameters->setSignalPassword(ui->leSignalPassword->text());
54
55 m_pParameters->setStunServer(ui->leStunServer->text());
56 m_pParameters->setStunPort(ui->sbStunPort->value());
57
58 m_pParameters->setTurnServer(ui->leTurnServer->text());
59 m_pParameters->setTurnPassword(ui->leTrunPassword->text());
60 m_pParameters->setTurnUser(ui->leTurnUser->text());
61 m_pParameters->setTurnPassword(ui->leTrunPassword->text());
62}
63
64void CFrmParameterICE::Init()
65{
66 ui->cbEnableICE->setChecked(m_pParameters->getIce());
67 on_cbEnableICE_stateChanged(ui->cbEnableICE->isChecked());
68 ui->cbEnableIceDebug->setChecked(m_pParameters->GetIceDebug());
69
70 ui->leSignalServer->setText(m_pParameters->getSignalServer());
71 ui->sbSignalPort->setValue(m_pParameters->getSignalPort());
72 ui->leSignalName->setText(m_pParameters->getSignalUser());
73 ui->leSignalPassword->setText(m_pParameters->getSignalPassword());
74
75 ui->leStunServer->setText(m_pParameters->getStunServer());
76 ui->sbStunPort->setValue(m_pParameters->getStunPort());
77
78 ui->leTurnServer->setText(m_pParameters->getTurnServer());
79 ui->sbTurnPort->setValue(m_pParameters->getTurnPort());
80 ui->leTurnUser->setText(m_pParameters->getTurnUser());
81 ui->leTrunPassword->setText(m_pParameters->getTurnPassword());
82}
83
84void CFrmParameterICE::on_cbEnableICE_stateChanged(int arg1)
85{
86 EnableCompone(arg1);
87}
88
89void CFrmParameterICE::EnableCompone(bool bEnable)
90{
91 ui->pbConnect->setEnabled(bEnable);
92 ui->leSignalServer->setEnabled(bEnable);
93 ui->sbSignalPort->setEnabled(bEnable);
94 ui->leSignalName->setEnabled(bEnable);
95 ui->leSignalPassword->setEnabled(bEnable);
96
97 ui->leStunServer->setEnabled(bEnable);
98 ui->sbStunPort->setEnabled(bEnable);
99
100 ui->leTurnServer->setEnabled(bEnable);
101 ui->sbTurnPort->setEnabled(bEnable);
102 ui->leTurnUser->setEnabled(bEnable);
103 ui->leTrunPassword->setEnabled(bEnable);
104}
105
106void CFrmParameterICE::on_pbConnect_clicked(bool checked)
107{
108 SetConnectButton(!checked);
109 if(checked)
110 CICE::Instance()->slotStart();
111 else
112 CICE::Instance()->slotStop();
113}
114
115void CFrmParameterICE::on_leSignalName_editingFinished()
116{
117#ifdef HAVE_QXMPP
118 QString user = ui->leSignalName->text();
119 if(QXmppUtils::jidToDomain(user).isEmpty()
120 || QXmppUtils::jidToResource(user).isEmpty())
121 {
122 QString szMsg = tr("The user name format is error. please use format: user@domain/resource");
123 QMessageBox::critical(this, tr("Error"), szMsg);
124 }
125#endif
126}
127
129{
130 QSharedPointer<CIceSignal> signal = CICE::Instance()->GetSignal();
131 if(signal)
132 SetConnectButton(signal->IsConnected());
133}
134
135void CFrmParameterICE::slotDisconnected()
136{
137 QSharedPointer<CIceSignal> signal = CICE::Instance()->GetSignal();
138 if(signal)
139 SetConnectButton(signal->IsConnected());
140}
141
142void CFrmParameterICE::slotError(int nError, const QString& szError)
143{
144 QSharedPointer<CIceSignal> signal = CICE::Instance()->GetSignal();
145 if(signal)
146 SetConnectButton(signal->IsConnected());
147}
148
149void CFrmParameterICE::SetConnectButton(bool bConnected)
150{
151 if(bConnected)
152 {
153 ui->pbConnect->setChecked(true);
154 ui->pbConnect->setText(tr("Disconnect"));
155 ui->pbConnect->setIcon(QIcon::fromTheme("network-wireless"));
156 } else {
157 ui->pbConnect->setChecked(false);
158 ui->pbConnect->setText(tr("Connect"));
159 ui->pbConnect->setIcon(QIcon::fromTheme("network-wired"));
160 }
161}
Set parameter dialog.
void slotConnected()
[Accept parameters]
CFrmParameterICE(CParameterICE *para=nullptr, QWidget *parent=nullptr)
void slotAccept()
[Accept parameters]
static CICE * Instance()
Single instance.
Definition Ice.cpp:55
ICE parameter helper class.