Rabbit Remote Control 0.1.0-bate10
Loading...
Searching...
No Matches
ParameterServer.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "ParameterServer.h"
4
5CParameterServer::CParameterServer(QObject *parent, const QString &szPrefix)
6 : CParameterOperate{parent, szPrefix}
7 , m_Net(this)
8 , m_WhiteFilter(this, "WhiteFilter")
9 , m_BlackFilter(this, "BlackFilter")
10 , m_bAnonymousLogin(false)
11 , m_bReadOnly(true)
12 , m_tmAuthenticate(600000)
13 , m_AuthAttempts(3)
14 , m_ConnectCount(-1)
15 , m_bListenAll(true)
16{
17 m_szHostKeyFile = "ssh_host_rsa_key";
18}
19
20int CParameterServer::OnLoad(QSettings &set)
21{
22 int nRet = 0;
23 SetAnonymousLogin(set.value("AnonemousLogin", GetAnonymousLogin()).toBool());
24 SetReadOnly(set.value("ReadOnly", GetReadOnly()).toBool());
25 SetRoot(set.value("Root", GetRoot()).toString());
26 SetHostKeyFile(set.value("HostKeyFile", GetHostKeyFile()).toString());
27 SetAuthenticateTime(set.value("AuthenticateTime", GetAuthenticateTime()).toDouble());
28 SetAuthenticateAttempts(set.value("AuthenticateAttempts", GetAuthenticateAttempts()).toInt());
29 SetConnectCount(set.value("ConnectCount", GetConnectCount()).toInt());
30 SetListenAll(set.value("ListenAll", GetListenAll()).toBool());
31 SetListen(set.value("Listen", GetListen()).toStringList());
32 return nRet;
33}
34
35int CParameterServer::OnSave(QSettings &set)
36{
37 int nRet = 0;
38 set.setValue("AnonemousLogin", GetAnonymousLogin());
39 set.setValue("ReadOnly", GetReadOnly());
40 set.setValue("Root", GetRoot());
41 set.setValue("HostKeyFile", GetHostKeyFile());
42 set.setValue("AuthenticateTime", GetAuthenticateTime());
43 set.setValue("AuthenticateAttempts", GetAuthenticateAttempts());
44 set.setValue("ConnectCount", GetConnectCount());
45 set.setValue("ListenAll", GetListenAll());
46 set.setValue("Listen", GetListen());
47 return nRet;
48}
49
50bool CParameterServer::GetAnonymousLogin() const
51{
52 return m_bAnonymousLogin;
53}
54
55void CParameterServer::SetAnonymousLogin(bool newAnonymousLogin)
56{
57 if(m_bAnonymousLogin == newAnonymousLogin)
58 return;
59 m_bAnonymousLogin = newAnonymousLogin;
60 SetModified(true);
61}
62
63bool CParameterServer::GetReadOnly() const
64{
65 return m_bReadOnly;
66}
67
68void CParameterServer::SetReadOnly(bool newReadOnly)
69{
70 if(m_bReadOnly == newReadOnly)
71 return;
72 m_bReadOnly = newReadOnly;
73 SetModified(true);
74}
75
76QString CParameterServer::GetRoot() const
77{
78 return m_szRoot;
79}
80
81void CParameterServer::SetRoot(const QString &newRoot)
82{
83 if(m_szRoot == newRoot)
84 return;
85 m_szRoot = newRoot;
86 SetModified(true);
87}
88
89QString CParameterServer::GetHostKeyFile() const
90{
91 return m_szHostKeyFile;
92}
93
94void CParameterServer::SetHostKeyFile(const QString &key)
95{
96 if(m_szHostKeyFile == key)
97 return;
98 m_szHostKeyFile = key;
99 SetModified(true);
100}
101
103{
104 return m_tmAuthenticate;
105}
106
108{
109 if(m_tmAuthenticate == tm)
110 return;
111 m_tmAuthenticate = tm;
112 SetModified(true);
113}
114
116{
117 return m_AuthAttempts;
118}
119
121{
122 if(m_AuthAttempts == attempts)
123 return;
124 m_AuthAttempts = attempts;
125 SetModified(true);
126}
127
129{
130 return m_ConnectCount;
131}
132
133void CParameterServer::SetConnectCount(int newConnectCount)
134{
135 if(m_ConnectCount == newConnectCount)
136 return;
137 m_ConnectCount = newConnectCount;
138 SetModified(true);
139}
140
141bool CParameterServer::GetListenAll() const
142{
143 return m_bListenAll;
144}
145
146void CParameterServer::SetListenAll(bool newListenAll)
147{
148 if(m_bListenAll == newListenAll)
149 return;
150 m_bListenAll = newListenAll;
151 SetModified(true);
152}
153
154QStringList CParameterServer::GetListen() const
155{
156 return m_Listen;
157}
158
159void CParameterServer::SetListen(const QStringList &newListen)
160{
161 if(m_Listen == newListen)
162 return;
163 m_Listen = newListen;
164 SetModified(true);
165}
166
167void CParameterServer::slotSetPluginParameters()
168{
169 m_Net.m_User.SetSavePassword(true);
170 m_Net.m_User.SetSavePassphrase(true);
171}
CParameterUser m_User
[Instance user]
Operational parameter interface.
void SetAuthenticateTime(qint64 tm)
Set authenticate time out.
int GetAuthenticateAttempts() const
Get authenticate attempts.
qint64 GetAuthenticateTime() const
Get authenticate time out.
int GetConnectCount() const
Connect count.
void SetAuthenticateAttempts(int attempts)
Set authenticate attempts.
void SetSavePassword(bool save)
Set save password.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.