玉兔远程控制 0.1.0-bate6
载入中...
搜索中...
未找到
ParameterPlugin.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "RabbitCommonTools.h"
4#include "RabbitCommonDir.h"
5#include "ParameterPlugin.h"
6
7CParameterPlugin::CParameterPlugin(QObject *parent)
8 : CParameter(parent)
9 , m_GlobalParameter(this, "Global")
10 , m_bCaptureAllKeyboard(true)
11 , m_bDesktopShortcutsScript(false)
12 , m_bEnableLocalInputMethod(false)
13 , m_bPromptAdministratorPrivilege(!RabbitCommon::CTools::Instance()->HasAdministratorPrivilege())
14 , m_bEnableSystemUserToUser(true)
15 , m_bSavePassword(false)
16 , m_PromptType(PromptType::First)
17 , m_nPromptCount(0)
18 , m_bViewPassowrd(false)
19 , m_bUseSystemCredential(true)
20 , m_bShowProtocolPrefix(false)
21 , m_bShowIpPortInName(false)
22 , m_AdaptWindows(CFrmViewer::ADAPT_WINDOWS::KeepAspectRationToWindow)
23 , m_bEnableSetPluginsPath(false)
24 , m_WhiteList(this, "Plugin/Paths/Whilelist")
25 , m_BlackList(this, "Plugin/Paths/BlackList")
26 , m_szPluginsPath(RabbitCommon::CDir::Instance()->GetDirPlugins())
27 , m_bOnlyLoadInWhitelist(false)
28 , m_Record(this)
29 , m_MediaDevices(this)
30#if defined(HAVE_QTERMWIDGET)
31 , m_Terminal(this)
32#endif
33{}
34
35CParameterPlugin::~CParameterPlugin()
36{}
37
38CParameterGlobal* CParameterPlugin::GetGlobalParameters()
39{
40 return &m_GlobalParameter;
41}
42
43int CParameterPlugin::OnLoad(QSettings &set)
44{
45 int nRet = 0;
46 nRet = m_GlobalParameter.Load(set);
47 if(nRet) return nRet;
48
49 set.beginGroup("Plugin");
50 SetCaptureAllKeyboard(
51 set.value("CaptureAllKeyboard", GetCaptureAllKeyboard()).toBool());
52 SetDesktopShortcutsScript(set.value("DesktopShortcutsScript/Enable",
53 GetDesktopShortcutsScript()).toBool());
54 SetDisableDesktopShortcutsScript(
55 set.value("DesktopShortcutsScript/Disable",
56 GetDisableDesktopShortcutsScript()).toString());
57 SetRestoreDesktopShortcutsScript(
58 set.value("DesktopShortcutsScript/Restore",
59 GetRestoreDesktopShortcutsScript()).toString());
60 SetEnableLocalInputMethod(set.value("InputMethod", GetEnableLocalInputMethod()).toBool());
61 // Note: SetShowHookAdministratorPrivilege must precede SetHookKeyboard
62 SetPromptAdministratorPrivilege(
63 set.value("AdministratorPrivilege/Prompt",
64 GetPromptAdministratorPrivilege()).toBool());
65 SetEnableSystemUserToUser(set.value("UserName/Enable",
66 GetEnableSystemUserToUser()).toBool());
67 SetPromptType(static_cast<PromptType>(
68 set.value("Password/Prompty/Type",
69 static_cast<int>(GetPromptType())).toInt()
70 ));
71 SetSavePassword(set.value("Password/Save", GetSavePassword()).toBool());
72 SetViewPassowrd(set.value("Password/View", GetViewPassowrd()).toBool());
73 SetUseSystemCredential(set.value("Password/UseSystemCredential", GetUseSystemCredential()).toBool());
74 SetShowProtocolPrefix(set.value("Connecter/Name/ShowProtocolPrefix", GetShowProtocolPrefix()).toBool());
75 SetShowIpPortInName(set.value("Connecter/Name/ShowIpPort", GetShowIpPortInName()).toBool());
76 SetAdaptWindows((CFrmViewer::ADAPT_WINDOWS)set.value("Viewer/AdaptWindows",
77 (int)GetAdaptWindows()).toInt());
78
79 SetPluginsPath(set.value("Paths", GetPluginsPath()).toStringList());
80 SetEnableSetPluginsPath(set.value("Paths/Enable", GetEnableSetPluginsPath()).toBool());
81 SetOnlyLoadInWhitelist(set.value("OnlyLoadInWhitelist", GetOnlyLoadInWhitelist()).toBool());
82
83 set.endGroup();
84 return 0;
85}
86
87int CParameterPlugin::OnSave(QSettings& set)
88{
89 int nRet = 0;
90 nRet = m_GlobalParameter.Save(set);
91 if(nRet) return nRet;
92
93 set.beginGroup("Plugin");
94 set.setValue("CaptureAllKeyboard", GetCaptureAllKeyboard());
95 set.setValue("DesktopShortcutsScript/Enable", GetDesktopShortcutsScript());
96 set.setValue("DesktopShortcutsScript/Disable", GetDisableDesktopShortcutsScript());
97 set.setValue("DesktopShortcutsScript/Restore", GetRestoreDesktopShortcutsScript());
98 set.setValue("InputMethod", GetEnableLocalInputMethod());
99 set.setValue("AdministratorPrivilege/Prompt", GetPromptAdministratorPrivilege());
100 set.setValue("UserName/Enable", GetEnableSystemUserToUser());
101 set.setValue("Password/Prompty/Type", static_cast<int>(GetPromptType()));
102 set.setValue("Password/Save", GetSavePassword());
103 set.setValue("Password/View", GetViewPassowrd());
104 set.setValue("Password/UseSystemCredential", GetUseSystemCredential());
105 set.setValue("Connecter/Name/ShowProtocolPrefix", GetShowProtocolPrefix());
106 set.setValue("Connecter/Name/ShowIpPort", GetShowIpPortInName());
107 set.setValue("Viewer/AdaptWindows", (int)GetAdaptWindows());
108
109 set.setValue("Paths", GetPluginsPath());
110 set.setValue("Paths/Enable", GetEnableSetPluginsPath());
111 set.setValue("OnlyLoadInWhitelist", GetOnlyLoadInWhitelist());
112
113 set.endGroup();
114 return 0;
115}
116
117bool CParameterPlugin::GetCaptureAllKeyboard() const
118{
119 return m_bCaptureAllKeyboard;
120}
121
122void CParameterPlugin::SetCaptureAllKeyboard(bool bCapture)
123{
124 if(m_bCaptureAllKeyboard == bCapture)
125 return;
126 m_bCaptureAllKeyboard = bCapture;
127 SetModified(true);
128 emit sigCaptureAllKeyboard();
129}
130
131bool CParameterPlugin::GetDesktopShortcutsScript() const
132{
133 return m_bDesktopShortcutsScript;
134}
135
136void CParameterPlugin::SetDesktopShortcutsScript(bool newDesktopShortcutsScript)
137{
138 if(m_bDesktopShortcutsScript == newDesktopShortcutsScript)
139 return;
140 m_bDesktopShortcutsScript = newDesktopShortcutsScript;
141 SetModified(true);
142}
143
144QString CParameterPlugin::GetRestoreDesktopShortcutsScript() const
145{
146 return m_szRestoreDesktopShortcutsScript;
147}
148
149void CParameterPlugin::SetRestoreDesktopShortcutsScript(const QString &newRestoreDesktopShortcutsScript)
150{
151 if(m_szRestoreDesktopShortcutsScript == newRestoreDesktopShortcutsScript)
152 return;
153 m_szRestoreDesktopShortcutsScript = newRestoreDesktopShortcutsScript;
154 SetModified(true);
155}
156
157QString CParameterPlugin::GetDisableDesktopShortcutsScript() const
158{
159 return m_szDisableDesktopShortcutsScript;
160}
161
162void CParameterPlugin::SetDisableDesktopShortcutsScript(const QString &newDisableDesktopShortcutsScript)
163{
164 if(m_szDisableDesktopShortcutsScript == newDisableDesktopShortcutsScript)
165 return;
166 m_szDisableDesktopShortcutsScript = newDisableDesktopShortcutsScript;
167 SetModified(true);
168}
169
170bool CParameterPlugin::GetEnableLocalInputMethod() const
171{
172 return m_bEnableLocalInputMethod;
173}
174
175void CParameterPlugin::SetEnableLocalInputMethod(bool enable)
176{
177 if(m_bEnableLocalInputMethod == enable)
178 return;
179 m_bEnableLocalInputMethod = enable;
180 SetModified(true);
181}
182
183bool CParameterPlugin::GetPromptAdministratorPrivilege()
184{
185 return m_bPromptAdministratorPrivilege;
186}
187
188void CParameterPlugin::SetPromptAdministratorPrivilege(bool bShow)
189{
190 if(bShow == m_bPromptAdministratorPrivilege)
191 return;
192 SetModified(true);
193 m_bPromptAdministratorPrivilege = bShow;
194 emit sigPromptAdministratorPrivilege();
195}
196
197bool CParameterPlugin::GetEnableSystemUserToUser() const
198{
199 return m_bEnableSystemUserToUser;
200}
201
202void CParameterPlugin::SetEnableSystemUserToUser(bool enable)
203{
204 if(m_bEnableSystemUserToUser == enable)
205 return;
206 m_bEnableSystemUserToUser = enable;
207 SetModified(true);
208}
209
210const QString &CParameterPlugin::GetEncryptKey() const
211{
212 return m_szEncryptKey;
213}
214
215void CParameterPlugin::SetEncryptKey(const QString &newPassword)
216{
217 if (m_szEncryptKey == newPassword)
218 return;
219 m_szEncryptKey = newPassword;
220 SetModified(true);
221 emit sigEncryptKeyChanged();
222}
223
224const bool &CParameterPlugin::GetSavePassword() const
225{
226 return m_bSavePassword;
227}
228
229void CParameterPlugin::SetSavePassword(bool NewAutoSavePassword)
230{
231 if (m_bSavePassword == NewAutoSavePassword)
232 return;
233 SetModified(true);
234 m_bSavePassword = NewAutoSavePassword;
235 emit sigSavePasswordChanged(m_bSavePassword);
236}
237
238CParameterPlugin::PromptType CParameterPlugin::GetPromptType() const
239{
240 return m_PromptType;
241}
242
243void CParameterPlugin::SetPromptType(PromptType NewPromptType)
244{
245 if (m_PromptType == NewPromptType)
246 return;
247 SetModified(true);
248 m_PromptType = NewPromptType;
249 emit sigPromptTypeChanged(m_PromptType);
250}
251
252int CParameterPlugin::GetPromptCount() const
253{
254 return m_nPromptCount;
255}
256
257void CParameterPlugin::SetPromptCount(int NewPromptCount)
258{
259 if (m_nPromptCount == NewPromptCount)
260 return;
261 m_nPromptCount = NewPromptCount;
262 SetModified(true);
263 emit sigPromptCountChanged(m_nPromptCount);
264}
265
266bool CParameterPlugin::GetViewPassowrd() const
267{
268 return m_bViewPassowrd;
269}
270
271void CParameterPlugin::SetViewPassowrd(bool NewViewPassowrd)
272{
273 if (m_bViewPassowrd == NewViewPassowrd)
274 return;
275 m_bViewPassowrd = NewViewPassowrd;
276 SetModified(true);
277 emit sigViewPassowrdChanged(m_bViewPassowrd);
278}
279
280bool CParameterPlugin::GetUseSystemCredential() const
281{
282 return m_bUseSystemCredential;
283}
284
285void CParameterPlugin::SetUseSystemCredential(bool newUseSystemCredential)
286{
287 if(m_bUseSystemCredential == newUseSystemCredential)
288 return;
289 m_bUseSystemCredential = newUseSystemCredential;
290 SetModified(true);
291}
292
293bool CParameterPlugin::GetShowProtocolPrefix() const
294{
295 return m_bShowProtocolPrefix;
296}
297
298void CParameterPlugin::SetShowProtocolPrefix(bool bShowProtocolPrefix)
299{
300 if(m_bShowProtocolPrefix == bShowProtocolPrefix)
301 return;
302 m_bShowProtocolPrefix = bShowProtocolPrefix;
303 SetModified(true);
304 emit sigShowProtocolPrefixChanged();
305}
306
307bool CParameterPlugin::GetShowIpPortInName() const
308{
309 return m_bShowIpPortInName;
310}
311
312void CParameterPlugin::SetShowIpPortInName(bool bShowIpPortInName)
313{
314 if(m_bShowIpPortInName == bShowIpPortInName)
315 return;
316 m_bShowIpPortInName = bShowIpPortInName;
317 SetModified(true);
318 emit sigSHowIpPortInNameChanged();
319}
320
321CFrmViewer::ADAPT_WINDOWS CParameterPlugin::GetAdaptWindows()
322{
323 return m_AdaptWindows;
324}
325
326void CParameterPlugin::SetAdaptWindows(CFrmViewer::ADAPT_WINDOWS aw)
327{
328 if(m_AdaptWindows == aw)
329 return;
330 m_AdaptWindows = aw;
331 SetModified(true);
332 emit sigAdaptWindowsChanged();
333}
334
335bool CParameterPlugin::GetEnableSetPluginsPath() const
336{
337 return m_bEnableSetPluginsPath;
338}
339
340void CParameterPlugin::SetEnableSetPluginsPath(bool newEnableSetPluginsPath)
341{
342 if(m_bEnableSetPluginsPath == newEnableSetPluginsPath)
343 return;
344 m_bEnableSetPluginsPath = newEnableSetPluginsPath;
345 SetModified(true);
346}
347
348QStringList CParameterPlugin::GetPluginsPath() const
349{
350 return m_szPluginsPath;
351}
352
353void CParameterPlugin::SetPluginsPath(const QStringList &newPluginsPath)
354{
355 m_szPluginsPath = newPluginsPath;
356}
357
358bool CParameterPlugin::GetOnlyLoadInWhitelist() const
359{
360 return m_bOnlyLoadInWhitelist;
361}
362
363void CParameterPlugin::SetOnlyLoadInWhitelist(bool newOnlyLoadInWhitelist)
364{
365 if(m_bOnlyLoadInWhitelist = newOnlyLoadInWhitelist)
366 return;
367 m_bOnlyLoadInWhitelist = newOnlyLoadInWhitelist;
368 SetModified(true);
369}
用于显示从 CConnectDesktop 输出的图像,和向 CConnectDesktop 发送键盘、鼠标事件。
Definition FrmViewer.h:48
ADAPT_WINDOWS
窗口适配枚举常量
Definition FrmViewer.h:60
virtual int OnSave(QSettings &set) override
virtual int OnLoad(QSettings &set) override
参数接口
Definition Parameter.h:209
int SetModified(bool bModified=true)
在设置参数时,如果有修改,则调用。
virtual int Save(QString szFile=QString(), bool bForce=true)
Save to file
Definition Parameter.cpp:47
virtual int Load(QString szFile=QString())
Load from file
Definition Parameter.cpp:35