Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ParameterProxy.cpp
1#include "ParameterProxy.h"
2
3CParameterProxy::CParameterProxy(CParameterConnecter *parent, const QString &szPrefix)
4 : CParameterConnecter(parent, szPrefix),
5 m_SockesV5(this, "Proxy/SockesV5"),
6 m_SSH(this, "Proxy/SSH/Tunnel"),
7 m_UsedType(TYPE::None)
8{
9 m_Type << TYPE::None << TYPE::Default << TYPE::SockesV5 << TYPE::SSHTunnel;
10 m_TypeName = {{TYPE::None, tr("None")},
11 {TYPE::Default, tr("Default")},
12 {TYPE::SockesV5, tr("Sockes V5")},
13 {TYPE::SSHTunnel, tr("SSH tunnel")}};
14
15 m_SockesV5.SetPort(1080);
16
17 QList<CParameterUser::TYPE> lstType;
18 lstType << CParameterUser::TYPE::None
19 << CParameterUser::TYPE::UserPassword;
20 m_SockesV5.m_User.SetType(lstType);
21 m_SockesV5.SetPrompt(tr("The host is empty in \"Proxy->SockesV5\". please set it"));
22
23 m_SSH.SetPort(22);
24 lstType.clear();
25 lstType << CParameterUser::TYPE::UserPassword
26 << CParameterUser::TYPE::PublicKey;
27 m_SSH.m_User.SetType(lstType);
28 m_SSH.SetPrompt(tr("The host is empty in \"Proxy->SSH tunnel\". please set it"));
29}
30
31int CParameterProxy::OnLoad(QSettings &set)
32{
33 set.beginGroup("Proxy");
34 QStringList type;
35 foreach(auto t, GetType()) {
36 type.push_back(QString::number((int)t));
37 }
38 QStringList vType;
39 vType = set.value("Type", type).toStringList();
40 QList<TYPE> lstType;
41 foreach(auto s, vType)
42 {
43 lstType.push_back((TYPE)s.toInt());
44 }
45 SetType(lstType);
46 SetUsedType((TYPE)set.value("Type/Used", (int)GetUsedType()).toInt());
47 set.endGroup();
48 return 0;
49}
50
51int CParameterProxy::OnSave(QSettings &set)
52{
53 set.beginGroup("Proxy");
54 QStringList type;
55 foreach(auto t, GetType()) {
56 type.push_back(QString::number((int)t));
57 }
58 set.setValue("Type", type);
59 set.setValue("Type/Used", (int)GetUsedType());
60 set.endGroup();
61 return 0;
62}
63
64QList<CParameterProxy::TYPE> CParameterProxy::GetType() const
65{
66 return m_Type;
67}
68
69int CParameterProxy::SetType(QList<TYPE> type)
70{
71 if(m_Type == type)
72 return 0;
73 m_Type = type;
74 SetModified(true);
75 return 0;
76}
77
78CParameterProxy::TYPE CParameterProxy::GetUsedType() const
79{
80 return m_UsedType;
81}
82
83int CParameterProxy::SetUsedType(TYPE type)
84{
85 if(m_UsedType == type)
86 return 0;
87 m_UsedType = type;
88 SetModified(true);
89 return 0;
90}
91
92QString CParameterProxy::ConvertTypeToName(TYPE t)
93{
94 return m_TypeName[t];
95}
96
97int CParameterProxy::SetTypeName(TYPE t, const QString& szName)
98{
99 m_TypeName[t] = szName;
100 return 0;
101}
the parameters of connecter interface.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.