Rabbit Remote Control 0.1.0-bate10
Loading...
Searching...
No Matches
ParameterSftpServer.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "ParameterSftpServer.h"
4
5CParameterSftpServer::CParameterSftpServer(QObject *parent, const QString &szPrefix)
6 : CParameterServer{parent, szPrefix}
7 , m_bAnonymousLogin(false)
8 , m_bReadOnly(true)
9{
10#if defined(Q_OS_UNIX)
11 m_Net.SetPort(2222);
12 // TODO: modify host key file
13 //m_szHostKeyFile = "/etc/ssh/ssh_host_rsa_key";
14 SetHostKeyFile("/data/libssh/tests/keys/ssh_host_rsa_key");
15#else
16 m_Net.SetPort(22);
17 SetHostKeyFile("D:\\source\\vcpkg\\buildtrees\\libssh\\src\\libssh-0-e5f4972781.clean\\tests\\keys\\ssh_host_rsa_key");
18#endif
19 m_Net.SetEnablleUI(CParameterNet::SHOW_UI::Port | CParameterNet::SHOW_UI::User);
20}
21
22int CParameterSftpServer::OnLoad(QSettings &set)
23{
24 int nRet = 0;
25 nRet = CParameterServer::OnLoad(set);
26 if(nRet) return nRet;
27 SetAnonymousLogin(set.value("AnonemousLogin", GetAnonymousLogin()).toBool());
28 SetReadOnly(set.value("ReadOnly", GetReadOnly()).toBool());
29 SetRoot(set.value("Root", GetRoot()).toString());
30 return nRet;
31}
32
33int CParameterSftpServer::OnSave(QSettings &set)
34{
35 int nRet = 0;
36 nRet = CParameterServer::OnSave(set);
37 if(nRet) return nRet;
38 set.setValue("AnonemousLogin", GetAnonymousLogin());
39 set.setValue("ReadOnly", GetReadOnly());
40 set.setValue("Root", GetRoot());
41 return nRet;
42}
43
44bool CParameterSftpServer::GetAnonymousLogin() const
45{
46 return m_bAnonymousLogin;
47}
48
49void CParameterSftpServer::SetAnonymousLogin(bool newAnonymousLogin)
50{
51 if(m_bAnonymousLogin == newAnonymousLogin)
52 return;
53 m_bAnonymousLogin = newAnonymousLogin;
54 SetModified(true);
55}
56
57bool CParameterSftpServer::GetReadOnly() const
58{
59 return m_bReadOnly;
60}
61
62void CParameterSftpServer::SetReadOnly(bool newReadOnly)
63{
64 if(m_bReadOnly == newReadOnly)
65 return;
66 m_bReadOnly = newReadOnly;
67 SetModified(true);
68}
69
70QString CParameterSftpServer::GetRoot() const
71{
72 return m_szRoot;
73}
74
75void CParameterSftpServer::SetRoot(const QString &newRoot)
76{
77 if(m_szRoot == newRoot)
78 return;
79 m_szRoot = newRoot;
80 SetModified(true);
81}
The server base parameters.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.