1#include "ParameterVnc.h"
2#include "rfb/encodings.h"
4CParameterVnc::CParameterVnc(QObject *parent)
10 auto &user = m_Net.m_User;
11 user.SetType(QList<CParameterUser::TYPE>()
12 << CParameterUser::TYPE::None
13 << CParameterUser::TYPE::OnlyPassword
15 << CParameterUser::TYPE::OnlyPasswordX509
16 << CParameterUser::TYPE::UserPassword
17 << CParameterUser::TYPE::UserPasswordX509None
18 << CParameterUser::TYPE::UserPasswordX509
20 user.SetUsedType(CParameterUser::TYPE::OnlyPassword);
21 user.SetTypeName(CParameterUser::TYPE::OnlyPassword, tr(
"Standard VNC authentication (insecure without encryption)"));
22 user.SetTypeName(CParameterUser::TYPE::UserPassword, tr(
"Username and password (insecure without encryption)"));
23 user.SetTypeName(CParameterUser::TYPE::OnlyPasswordX509, tr(
"Standard VNC authentication (secure with x509 encryption)"));
25 user.SetTypeName(CParameterUser::TYPE::UserPasswordX509, tr(
"Username and password (secure with x509 encryption)"));
26 user.SetTypeName(CParameterUser::TYPE::UserPasswordX509None, tr(
"Username and password (secure with x509 none encryption)"));
29 m_bBufferEndRefresh =
false;
32 m_nColorLevel = CParameterVnc::Full;
33 m_nPreferredEncoding = rfb::encodingTight;
34 m_bCompressLevel =
true;
45int CParameterVnc::OnLoad(QSettings &set)
48 nRet = CParameterBase::OnLoad(set);
51 set.beginGroup(
"VNC");
52 SetShared(set.value(
"Shared", GetShared()).toBool());
53 SetBufferEndRefresh(set.value(
"BufferEndRefresh",
54 GetBufferEndRefresh()).toBool());
56 SetAutoSelect(set.value(
"AutoSelect", GetAutoSelect()).toBool());
57 SetColorLevel(
static_cast<COLOR_LEVEL
>(set.value(
"ColorLevel",
58 GetColorLevel()).toInt()));
59 SetPreferredEncoding(set.value(
"Encoding", GetPreferredEncoding()).toInt());
60 SetEnableCompressLevel(set.value(
"EnableCompressLevel",
61 GetEnableCompressLevel()).toBool());
62 SetCompressLevel(set.value(
"CompressLevel",
63 GetCompressLevel()).toInt());
64 SetNoJpeg(set.value(
"NoJpeg", GetNoJpeg()).toBool());
65 SetQualityLevel(set.value(
"QualityLevel", GetQualityLevel()).toInt());
68 set.beginGroup(
"ICE");
69 SetIce(set.value(
"Enable", GetIce()).toBool());
70 SetSignalServer(set.value(
"Signal/Server",
71 GetSignalServer()).toString());
72 SetSignalPort(set.value(
"Signal/Port", GetSignalPort()).toUInt());
73 SetSignalUser(set.value(
"Signal/User", GetSignalUser()).toString());
74 if(m_Net.
m_User.GetSavePassword())
77 if(!LoadPassword(tr(
"Ice signal password"),
"Signal/password",
79 SetSignalPassword(szPassword);
81 SetPeerUser(set.value(
"Peer/User", GetPeerUser()).toString());
82 SetStunServer(set.value(
"Stun/Server", GetStunServer()).toString());
83 SetStunPort(set.value(
"Stun/Port", GetStunPort()).toUInt());
84 SetTurnServer(set.value(
"Turn/Server", GetTurnServer()).toString());
85 SetTurnPort(set.value(
"Turn/Port", GetTurnPort()).toUInt());
86 SetTurnUser(set.value(
"Turn/User", GetTurnUser()).toString());
87 if(m_Net.
m_User.GetSavePassword())
90 if(!LoadPassword(tr(
"Ice turn password"),
"Turn/password",
92 SetTurnPassword(szPassword);
99int CParameterVnc::OnSave(QSettings &set)
102 nRet = CParameterBase::OnSave(set);
103 if(nRet)
return nRet;
105 set.beginGroup(
"VNC");
106 set.setValue(
"Shared", GetShared());
107 set.setValue(
"BufferEndRefresh", GetBufferEndRefresh());
108 set.setValue(
"AutoSelect", GetAutoSelect());
109 set.setValue(
"ColorLevel", GetColorLevel());
110 set.setValue(
"Encoding", GetPreferredEncoding());
111 set.setValue(
"EnableCompressLevel", GetEnableCompressLevel());
112 set.setValue(
"CompressLevel", GetCompressLevel());
113 set.setValue(
"NoJpeg", GetNoJpeg());
114 set.setValue(
"QualityLevel", GetQualityLevel());
117 set.beginGroup(
"ICE");
118 set.setValue(
"Enable", GetIce());
119 set.setValue(
"Signal/Server", GetSignalServer());
120 set.setValue(
"Signal/Port", GetSignalPort());
121 set.setValue(
"Signal/User", GetSignalUser());
122 SavePassword(
"Signal/password", GetSignalPassword(), set);
123 set.setValue(
"Peer/User", GetPeerUser());
124 set.setValue(
"Stun/Server", GetStunServer());
125 set.setValue(
"Stun/Port", GetStunPort());
126 set.setValue(
"Turn/Server", GetTurnServer());
127 set.setValue(
"Turn/Port", GetTurnPort());
128 set.setValue(
"Turn/User", GetTurnUser());
129 SavePassword(
"Turn/password", GetTurnPassword(), set);
139 if(GetSignalServer().isEmpty() || GetSignalPort() <= 0
140 || GetSignalUser().isEmpty() || GetSignalPassword().isEmpty()
141 || GetStunServer().isEmpty() || GetStunPort() <= 0)
146 if(m_Net.GetHost().isEmpty()
147 || m_Net.GetPort() <= 0
148 || m_Net.
m_User.GetPassword().isEmpty())
153bool CParameterVnc::GetShared()
const
158void CParameterVnc::SetShared(
bool newShared)
160 if(m_bShared == newShared)
162 m_bShared = newShared;
166bool CParameterVnc::GetBufferEndRefresh()
const
168 return m_bBufferEndRefresh;
171void CParameterVnc::SetBufferEndRefresh(
bool newBufferEndRefresh)
173 if(m_bBufferEndRefresh == newBufferEndRefresh)
175 m_bBufferEndRefresh = newBufferEndRefresh;
179bool CParameterVnc::GetAutoSelect()
const
181 return m_bAutoSelect;
184void CParameterVnc::SetAutoSelect(
bool newAutoSelect)
186 if(m_bAutoSelect == newAutoSelect)
188 m_bAutoSelect = newAutoSelect;
192CParameterVnc::COLOR_LEVEL CParameterVnc::GetColorLevel()
const
194 return m_nColorLevel;
197void CParameterVnc::SetColorLevel(COLOR_LEVEL newColorLevel)
199 if(m_nColorLevel == newColorLevel)
201 m_nColorLevel = newColorLevel;
205int CParameterVnc::GetPreferredEncoding()
const
207 return m_nPreferredEncoding;
210void CParameterVnc::SetPreferredEncoding(
int newEncoding)
212 if(m_nPreferredEncoding == newEncoding)
214 m_nPreferredEncoding = newEncoding;
218bool CParameterVnc::GetEnableCompressLevel()
const
220 return m_bCompressLevel;
223void CParameterVnc::SetEnableCompressLevel(
bool newCompressLevel)
225 if(m_bCompressLevel == newCompressLevel)
227 m_bCompressLevel = newCompressLevel;
231int CParameterVnc::GetCompressLevel()
const
233 return m_nCompressLevel;
236void CParameterVnc::SetCompressLevel(
int newCompressLevel)
238 if(m_nCompressLevel == newCompressLevel)
240 m_nCompressLevel = newCompressLevel;
244bool CParameterVnc::GetNoJpeg()
const
249void CParameterVnc::SetNoJpeg(
bool newNoJpeg)
251 if(m_bNoJpeg == newNoJpeg)
253 m_bNoJpeg = newNoJpeg;
257int CParameterVnc::GetQualityLevel()
const
259 return m_nQualityLevel;
262void CParameterVnc::SetQualityLevel(
int newQualityLevel)
264 if(m_nQualityLevel == newQualityLevel)
266 m_nQualityLevel = newQualityLevel;
270bool CParameterVnc::GetIce()
const
275void CParameterVnc::SetIce(
bool newIce)
283const QString &CParameterVnc::GetSignalServer()
const
285 return m_szSignalServer;
288void CParameterVnc::SetSignalServer(
const QString &newSignalServer)
290 if(m_szSignalServer == newSignalServer)
292 m_szSignalServer = newSignalServer;
296quint16 CParameterVnc::GetSignalPort()
const
298 return m_nSignalPort;
301void CParameterVnc::SetSignalPort(quint16 newSignalPort)
303 if(m_nSignalPort == newSignalPort)
305 m_nSignalPort = newSignalPort;
309const QString &CParameterVnc::GetSignalUser()
const
311 return m_szSignalUser;
314void CParameterVnc::SetSignalUser(
const QString &newSignalUser)
316 if(m_szSignalUser == newSignalUser)
318 m_szSignalUser = newSignalUser;
322const QString &CParameterVnc::GetSignalPassword()
const
324 return m_szSignalPassword;
327void CParameterVnc::SetSignalPassword(
const QString &newSignalPassword)
329 if(m_szSignalPassword == newSignalPassword)
331 m_szSignalPassword = newSignalPassword;
335const QString &CParameterVnc::GetPeerUser()
const
340void CParameterVnc::SetPeerUser(
const QString &newPeerUser)
342 if(m_szPeerUser == newPeerUser)
344 m_szPeerUser = newPeerUser;
348const QString &CParameterVnc::GetStunServer()
const
350 return m_szStunServer;
353void CParameterVnc::SetStunServer(
const QString &newStunServer)
355 if(m_szStunServer == newStunServer)
357 m_szStunServer = newStunServer;
361quint16 CParameterVnc::GetStunPort()
const
366void CParameterVnc::SetStunPort(quint16 newStunPort)
368 if(m_nStunPort == newStunPort)
370 m_nStunPort = newStunPort;
374const QString &CParameterVnc::GetTurnServer()
const
376 return m_szTurnServer;
379void CParameterVnc::SetTurnServer(
const QString &newTurnServer)
381 if(m_szTurnServer == newTurnServer)
383 m_szTurnServer = newTurnServer;
387quint16 CParameterVnc::GetTurnPort()
const
392void CParameterVnc::SetTurnPort(quint16 newTurnPort)
394 if(m_nTurnPort == newTurnPort)
396 m_nTurnPort = newTurnPort;
400const QString &CParameterVnc::GetTurnUser()
const
405void CParameterVnc::SetTurnUser(
const QString &newTurnUser)
407 if(m_szTurnUser == newTurnUser)
409 m_szTurnUser = newTurnUser;
413const QString &CParameterVnc::GetTurnPassword()
const
415 return m_szTurnPassword;
418void CParameterVnc::SetTurnPassword(
const QString &newTurnPassword)
420 if(m_szTurnPassword == newTurnPassword)
422 m_szTurnPassword = newTurnPassword;
The interface of connecter parameters.
CParameterUser m_User
[Instance user]
@ OnlyPasswordX509None
Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile.
virtual bool OnCheckValidity() override
Check whether the parameters are complete to decide whether to open the parameter dialog.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.