Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ServiceFreeRDP.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "ServiceFreeRDP.h"
4#include "ParameterServiceFreeRDP.h"
5#ifdef HAVE_GUI
6 #include "FrmParameterFreeRDP.h"
7#endif
8
9CServiceFreeRDP::CServiceFreeRDP(CPluginServiceFreeRDP *plugin)
10 : CService(plugin),
11 m_Log("FreeRDP"),
12 m_pSettings(nullptr),
13 m_pServer(nullptr),
14 m_bServerInit(false)
15{
16 m_pPara = new CParameterServiceFreeRDP(this);
17}
18
19CServiceFreeRDP::~CServiceFreeRDP()
20{
21}
22
24{
25 int nRet = 0;
26 shadow_subsystem_set_entry_builtin(NULL);
27
28 m_pServer = shadow_server_new();
29 if (!m_pServer)
30 {
31 qCritical(m_Log) << "Server new failed";
32 return -1;
33 }
34
35 SetParameters();
36
37 nRet = shadow_server_init(m_pServer);
38 if(nRet < 0)
39 {
40 qCritical(m_Log) << "Server initialization failed.";
41 return nRet;
42 }
43 m_bServerInit = true;
44
45 if ((nRet = shadow_server_start(m_pServer)) < 0)
46 {
47 qCritical(m_Log) << "Failed to start server.";
48 return nRet;
49 }
50
51 // Don't use OnProcess (qt event loop)
52 // Because freerdp has new thread process loop
53 return 1;
54}
55
57{
58 int nRet = 0;
59
60 if(m_pServer)
61 {
62 if(m_bServerInit)
63 shadow_server_uninit(m_pServer);
64 shadow_server_free(m_pServer);
65 m_pServer = nullptr;
66 }
67
68 return nRet;
69}
70
71#ifdef HAVE_GUI
72QWidget* CServiceFreeRDP::GetParameterWidget(QWidget *parent)
73{
74 return new CFrmParameterFreeRDP(
75 dynamic_cast<CParameterServiceFreeRDP*>(GetParameters()), parent);
76}
77#endif
78
79int CServiceFreeRDP::SetParameters()
80{
82 dynamic_cast<CParameterServiceFreeRDP*>(GetParameters());
83
84 m_pSettings = m_pServer->settings;
85 m_pSettings->NlaSecurity = p->getNlaSecurity();
86 m_pSettings->TlsSecurity = p->getTlsSecurity();
87 m_pSettings->RdpSecurity = p->getRdpSecurity();
88 m_pSettings->UseRdpSecurityLayer = m_pSettings->RdpSecurity;
89 m_pSettings->ExtSecurity = p->getNlaExtSecurity();
90 if(!p->getSamFile().isEmpty())
91 freerdp_settings_set_string(m_pSettings, FreeRDP_NtlmSamFile,
92 p->getSamFile().toStdString().c_str());
93
94 m_pServer->authentication = p->getAuthentication();
95
96 m_pServer->port = p->getPort();
97 m_pServer->mayView = p->getMayView();
98 m_pServer->mayInteract = p->getMayInteract();
99
100 return 0;
101}
virtual int OnClean() override
Clean service.
virtual int OnInit() override
Init service.
The service interface.
Definition Service.h:38