Rabbit Remote Control 0.1.0-bate16
Loading...
Searching...
No Matches
ParameterPlugin.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "ParameterGlobal.h"
4#include "RabbitCommonTools.h"
5#include "RabbitCommonDir.h"
6#include "ParameterPlugin.h"
7
8Q_DECLARE_METATYPE(CParameterPlugin::NameStyles)
9CParameterPlugin::CParameterPlugin(QObject *parent)
10 : CParameter(parent)
11 , m_pGlobalParameter(new CParameterGlobal(this, "Global"))
12 , m_bCaptureAllKeyboard(true)
13 , m_bDesktopShortcutsScript(false)
14#if defined(Q_OS_ANDROID)
15 , m_bEnableLocalInputMethod(true)
16#else
17 , m_bEnableLocalInputMethod(false)
18#endif
19 , m_bPromptAdministratorPrivilege(!RabbitCommon::CTools::Instance()->HasAdministratorPrivilege())
20 , m_bEnableSystemUserToUser(true)
21 , m_bSavePassword(false)
22 , m_PromptType(PromptType::First)
23 , m_nPromptCount(0)
24 , m_bViewPassowrd(false)
25 , m_bUseSystemCredential(true)
26 , m_NameStyles(NameStyle::ServerName | NameStyle::SecurityLevel)
27 , m_AdaptWindows(CFrmViewer::ADAPT_WINDOWS::KeepAspectRationToWindow)
28 , m_bEnableSetPluginsPath(false)
29 , m_WhiteList(this, "Plugin/Paths/Whilelist")
30 , m_BlackList(this, "Plugin/Paths/BlackList")
31 , m_szPluginsPath(RabbitCommon::CDir::Instance()->GetDirPlugins())
32 , m_bOnlyLoadInWhitelist(false)
33 , m_Record(this)
34 , m_MediaDevices(this)
35#if defined(HAVE_QTERMWIDGET)
36 , m_Terminal(this)
37#endif
38{}
39
40CParameterPlugin::~CParameterPlugin()
41{
42 if(m_pGlobalParameter) {
43 delete m_pGlobalParameter;
44 m_pGlobalParameter = nullptr;
45 }
46}
47
49{
50 return m_pGlobalParameter;
51}
52
53int CParameterPlugin::OnLoad(QSettings &set)
54{
55 set.beginGroup("Plugin");
56 SetCaptureAllKeyboard(
57 set.value("CaptureAllKeyboard", GetCaptureAllKeyboard()).toBool());
58 SetDesktopShortcutsScript(set.value("DesktopShortcutsScript/Enable",
59 GetDesktopShortcutsScript()).toBool());
60 SetDisableDesktopShortcutsScript(
61 set.value("DesktopShortcutsScript/Disable",
62 GetDisableDesktopShortcutsScript()).toString());
63 SetRestoreDesktopShortcutsScript(
64 set.value("DesktopShortcutsScript/Restore",
65 GetRestoreDesktopShortcutsScript()).toString());
66 SetEnableLocalInputMethod(
67 set.value("InputMethod", GetEnableLocalInputMethod()).toBool());
68 // Note: SetShowHookAdministratorPrivilege must precede SetHookKeyboard
69 SetPromptAdministratorPrivilege(
70 set.value("AdministratorPrivilege/Prompt",
71 GetPromptAdministratorPrivilege()).toBool());
72 SetEnableSystemUserToUser(set.value("UserName/Enable",
73 GetEnableSystemUserToUser()).toBool());
74 SetPromptType(static_cast<PromptType>(
75 set.value("Password/Prompty/Type",
76 static_cast<int>(GetPromptType())).toInt()
77 ));
78 SetSavePassword(set.value("Password/Save", GetSavePassword()).toBool());
79 SetViewPassowrd(set.value("Password/View", GetViewPassowrd()).toBool());
80 SetUseSystemCredential(set.value("Password/UseSystemCredential",
81 GetUseSystemCredential()).toBool());
82 SetNameStyles(static_cast<NameStyle>(
83 set.value("Operate/NameStyles", (int)GetNameStyles()).toInt()));
84 SetAdaptWindows((CFrmViewer::ADAPT_WINDOWS)set.value("Viewer/AdaptWindows",
85 (int)GetAdaptWindows()).toInt());
86
87 SetPluginsPath(set.value("Paths", GetPluginsPath()).toStringList());
88 SetEnableSetPluginsPath(
89 set.value("Paths/Enable", GetEnableSetPluginsPath()).toBool());
90 SetOnlyLoadInWhitelist(
91 set.value("OnlyLoadInWhitelist", GetOnlyLoadInWhitelist()).toBool());
92
93 set.endGroup();
94
95 return 0;
96}
97
98int CParameterPlugin::OnSave(QSettings& set)
99{
100 set.beginGroup("Plugin");
101 set.setValue("CaptureAllKeyboard", GetCaptureAllKeyboard());
102 set.setValue("DesktopShortcutsScript/Enable", GetDesktopShortcutsScript());
103 set.setValue("DesktopShortcutsScript/Disable", GetDisableDesktopShortcutsScript());
104 set.setValue("DesktopShortcutsScript/Restore", GetRestoreDesktopShortcutsScript());
105 set.setValue("InputMethod", GetEnableLocalInputMethod());
106 set.setValue("AdministratorPrivilege/Prompt", GetPromptAdministratorPrivilege());
107 set.setValue("UserName/Enable", GetEnableSystemUserToUser());
108 set.setValue("Password/Prompty/Type", static_cast<int>(GetPromptType()));
109 set.setValue("Password/Save", GetSavePassword());
110 set.setValue("Password/View", GetViewPassowrd());
111 set.setValue("Password/UseSystemCredential", GetUseSystemCredential());
112 set.setValue("Operate/NameStyles", (int)GetNameStyles());
113 set.setValue("Viewer/AdaptWindows", (int)GetAdaptWindows());
114
115 set.setValue("Paths", GetPluginsPath());
116 set.setValue("Paths/Enable", GetEnableSetPluginsPath());
117 set.setValue("OnlyLoadInWhitelist", GetOnlyLoadInWhitelist());
118
119 set.endGroup();
120 return 0;
121}
122
123bool CParameterPlugin::GetCaptureAllKeyboard() const
124{
125 return m_bCaptureAllKeyboard;
126}
127
128void CParameterPlugin::SetCaptureAllKeyboard(bool bCapture)
129{
130 if(m_bCaptureAllKeyboard == bCapture)
131 return;
132 m_bCaptureAllKeyboard = bCapture;
133 SetModified(true);
134 emit sigCaptureAllKeyboard();
135}
136
137bool CParameterPlugin::GetDesktopShortcutsScript() const
138{
139 return m_bDesktopShortcutsScript;
140}
141
142void CParameterPlugin::SetDesktopShortcutsScript(bool newDesktopShortcutsScript)
143{
144 if(m_bDesktopShortcutsScript == newDesktopShortcutsScript)
145 return;
146 m_bDesktopShortcutsScript = newDesktopShortcutsScript;
147 SetModified(true);
148}
149
150QString CParameterPlugin::GetRestoreDesktopShortcutsScript() const
151{
152 return m_szRestoreDesktopShortcutsScript;
153}
154
155void CParameterPlugin::SetRestoreDesktopShortcutsScript(const QString &newRestoreDesktopShortcutsScript)
156{
157 if(m_szRestoreDesktopShortcutsScript == newRestoreDesktopShortcutsScript)
158 return;
159 m_szRestoreDesktopShortcutsScript = newRestoreDesktopShortcutsScript;
160 SetModified(true);
161}
162
163QString CParameterPlugin::GetDisableDesktopShortcutsScript() const
164{
165 return m_szDisableDesktopShortcutsScript;
166}
167
168void CParameterPlugin::SetDisableDesktopShortcutsScript(const QString &newDisableDesktopShortcutsScript)
169{
170 if(m_szDisableDesktopShortcutsScript == newDisableDesktopShortcutsScript)
171 return;
172 m_szDisableDesktopShortcutsScript = newDisableDesktopShortcutsScript;
173 SetModified(true);
174}
175
176bool CParameterPlugin::GetEnableLocalInputMethod() const
177{
178 return m_bEnableLocalInputMethod;
179}
180
181void CParameterPlugin::SetEnableLocalInputMethod(bool enable)
182{
183 if(m_bEnableLocalInputMethod == enable)
184 return;
185 m_bEnableLocalInputMethod = enable;
186 SetModified(true);
187}
188
189bool CParameterPlugin::GetPromptAdministratorPrivilege()
190{
191 return m_bPromptAdministratorPrivilege;
192}
193
194void CParameterPlugin::SetPromptAdministratorPrivilege(bool bShow)
195{
196 if(bShow == m_bPromptAdministratorPrivilege)
197 return;
198 SetModified(true);
199 m_bPromptAdministratorPrivilege = bShow;
200 emit sigPromptAdministratorPrivilege();
201}
202
203bool CParameterPlugin::GetEnableSystemUserToUser() const
204{
205 return m_bEnableSystemUserToUser;
206}
207
208void CParameterPlugin::SetEnableSystemUserToUser(bool enable)
209{
210 if(m_bEnableSystemUserToUser == enable)
211 return;
212 m_bEnableSystemUserToUser = enable;
213 SetModified(true);
214}
215
216const QString &CParameterPlugin::GetEncryptKey() const
217{
218 return m_szEncryptKey;
219}
220
221void CParameterPlugin::SetEncryptKey(const QString &newPassword)
222{
223 if (m_szEncryptKey == newPassword)
224 return;
225 m_szEncryptKey = newPassword;
226 SetModified(true);
227 emit sigEncryptKeyChanged();
228}
229
230const bool &CParameterPlugin::GetSavePassword() const
231{
232 return m_bSavePassword;
233}
234
235void CParameterPlugin::SetSavePassword(bool NewAutoSavePassword)
236{
237 if (m_bSavePassword == NewAutoSavePassword)
238 return;
239 SetModified(true);
240 m_bSavePassword = NewAutoSavePassword;
241 emit sigSavePasswordChanged(m_bSavePassword);
242}
243
244CParameterPlugin::PromptType CParameterPlugin::GetPromptType() const
245{
246 return m_PromptType;
247}
248
249void CParameterPlugin::SetPromptType(PromptType NewPromptType)
250{
251 if (m_PromptType == NewPromptType)
252 return;
253 SetModified(true);
254 m_PromptType = NewPromptType;
255 emit sigPromptTypeChanged(m_PromptType);
256}
257
258int CParameterPlugin::GetPromptCount() const
259{
260 return m_nPromptCount;
261}
262
263void CParameterPlugin::SetPromptCount(int NewPromptCount)
264{
265 if (m_nPromptCount == NewPromptCount)
266 return;
267 m_nPromptCount = NewPromptCount;
268 SetModified(true);
269 emit sigPromptCountChanged(m_nPromptCount);
270}
271
272bool CParameterPlugin::GetViewPassowrd() const
273{
274 return m_bViewPassowrd;
275}
276
277void CParameterPlugin::SetViewPassowrd(bool NewViewPassowrd)
278{
279 if (m_bViewPassowrd == NewViewPassowrd)
280 return;
281 m_bViewPassowrd = NewViewPassowrd;
282 SetModified(true);
283 emit sigViewPassowrdChanged(m_bViewPassowrd);
284}
285
286bool CParameterPlugin::GetUseSystemCredential() const
287{
288 return m_bUseSystemCredential;
289}
290
291void CParameterPlugin::SetUseSystemCredential(bool newUseSystemCredential)
292{
293 if(m_bUseSystemCredential == newUseSystemCredential)
294 return;
295 m_bUseSystemCredential = newUseSystemCredential;
296 SetModified(true);
297}
298
299CParameterPlugin::NameStyles CParameterPlugin::GetNameStyles() const
300{
301 return m_NameStyles;
302}
303
304void CParameterPlugin::SetNameStyles(const NameStyles &newNameStyles)
305{
306 if (m_NameStyles == newNameStyles)
307 return;
308 m_NameStyles = newNameStyles;
309 SetModified(true);
310 emit sigNameStylesChanged();
311}
312
313CFrmViewer::ADAPT_WINDOWS CParameterPlugin::GetAdaptWindows()
314{
315 return m_AdaptWindows;
316}
317
318void CParameterPlugin::SetAdaptWindows(CFrmViewer::ADAPT_WINDOWS aw)
319{
320 if(m_AdaptWindows == aw)
321 return;
322 m_AdaptWindows = aw;
323 SetModified(true);
324 emit sigAdaptWindowsChanged();
325}
326
327bool CParameterPlugin::GetEnableSetPluginsPath() const
328{
329 return m_bEnableSetPluginsPath;
330}
331
332void CParameterPlugin::SetEnableSetPluginsPath(bool newEnableSetPluginsPath)
333{
334 if(m_bEnableSetPluginsPath == newEnableSetPluginsPath)
335 return;
336 m_bEnableSetPluginsPath = newEnableSetPluginsPath;
337 SetModified(true);
338}
339
340QStringList CParameterPlugin::GetPluginsPath() const
341{
342 return m_szPluginsPath;
343}
344
345void CParameterPlugin::SetPluginsPath(const QStringList &newPluginsPath)
346{
347 m_szPluginsPath = newPluginsPath;
348}
349
350bool CParameterPlugin::GetOnlyLoadInWhitelist() const
351{
352 return m_bOnlyLoadInWhitelist;
353}
354
355void CParameterPlugin::SetOnlyLoadInWhitelist(bool newOnlyLoadInWhitelist)
356{
357 if(m_bOnlyLoadInWhitelist == newOnlyLoadInWhitelist)
358 return;
359 m_bOnlyLoadInWhitelist = newOnlyLoadInWhitelist;
360 SetModified(true);
361}
A widget which displays output image from a CConnectDesktop and sends input keypresses and mouse acti...
Definition FrmViewer.h:50
ADAPT_WINDOWS
The ADAPT_WINDOWS enum.
Definition FrmViewer.h:62
Global parameters.
virtual int OnSave(QSettings &set) override
virtual int OnLoad(QSettings &set) override
CParameterGlobal * GetGlobalParameters()
Get global parameters.
Parameter interface.
Definition Parameter.h:220
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.