MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / OnInit

Method OnInit

Plugins/FtpServer/BackendFtpServer.cpp:26–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26CBackend::OnInitReturnValue CBackendFtpServer::OnInit()
27{
28 qDebug(log) << Q_FUNC_INFO;
29 if(m_pServer) {
30 qCritical(log) << "Server is exist";
31 return OnInitReturnValue::Fail;
32 }
33
34 m_nTotal = 0;
35 m_nDisconnect = 0;
36 m_Sockets.clear();
37 emit sigConnectCount(m_nTotal, m_Sockets.size(), m_nDisconnect);
38
39 CSecurityLevel::Levels securityLevel;
40 QString szUser;
41 QString szPassword;
42 auto &net = m_Para->m_Net;
43 if(!m_Para->GetAnonymousLogin()) {
44 auto &user = net.m_User;
45 szUser = user.GetUser();
46 szPassword = user.GetPassword();
47 if(!szPassword.isEmpty())
48 securityLevel |= CSecurityLevel::Level::Authentication;
49 }
50
51 m_pServer = new CFtpServer(this, m_Para->GetRoot(), net.GetPort(),
52 szUser, szPassword,
53 m_Para->GetReadOnly());
54 if(!m_pServer) {
55 qCritical(log) << "Failed to new CFtpServer";
56 return OnInitReturnValue::Fail;
57 }
58
59 m_pServer->SetFilter(this);
60 bool bListen = false;
61 if(m_Para->GetListenAll()) {
62 bListen = m_pServer->Listening();
63 if(bListen) {
64 QString szMsg = tr("Ftp server listen on all address port %1. the lan ip is %2")
65 .arg(net.GetPort()).arg(m_pServer->lanIp());
66 qInfo(log) << szMsg;
67 emit sigInformation(szMsg);
68 } else {
69 QString szErr = tr("Failed to Ftp server is listening on %1")
70 .arg(net.GetPort());
71 qCritical(log) << szErr;
72 emit sigError(-1, szErr);
73 return OnInitReturnValue::Fail;
74 }
75 } else {
76 QString szErr;
77 if(m_Para->GetListen().isEmpty()) {
78 szErr = tr("Failed: Ftp server is not set to listen on any address");
79 qCritical(log) << szErr;
80 emit sigError(-1, szErr);
81 return OnInitReturnValue::Fail;
82 }
83 foreach (auto a, m_Para->GetListen()) {

Callers

nothing calls this directly

Calls 9

GetAnonymousLoginMethod · 0.80
GetReadOnlyMethod · 0.80
GetListenAllMethod · 0.80
GetListenMethod · 0.80
GetUserMethod · 0.45
GetPasswordMethod · 0.45
isEmptyMethod · 0.45
GetRootMethod · 0.45
GetPortMethod · 0.45

Tested by

no test coverage detected