forked from KangLin/RabbitRemoteControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParameterConnecter.h
More file actions
176 lines (146 loc) · 5.98 KB
/
ParameterConnecter.h
File metadata and controls
176 lines (146 loc) · 5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Author: Kang Lin <kl222@126.com>
#ifndef CPARAMTERCONNECT_H
#define CPARAMTERCONNECT_H
#pragma once
#include "ParameterClient.h"
#include <QDataStream>
class CConnecter;
/**
* \~english
* \brief The parameter interface. It contains basic parameters.
* It only valid in plugin.
* The application cannot access it directly,
* it can only be set via CConnecter::OpenDialogSettings.
* \note
* - The interface only is implemented and used by plugin.
* - If it or its derived class requires a CParameterClient.
* Please instantiate the parameters and call CConnecter::SetParameter
* in the constructor of the CConnecter derived class
* to set the parameters pointer.
* Default set the CParameterClient for it. See: CClient::CreateConnecter .
* If you are sure to it does not need CParameterClient.
* please overload the CConnecter::SetParameterClient in the CConnecter derived class.
* don't set it.
*
* \~chinese
* \brief 连接参数接口。它包含基本参数。此类仅在插件内有效。
* 应用程序不能直接访问,只能通过 CConnecter::OpenDialogSettings 进行设置。
* \note
* - 此接口仅由插件派生实现和使用。
* - 如果它或其派生类需要 CParameterClient 。
* 请在 CConnecter 的派生类的构造函数中实例化参数,并调用 CConnecter::SetParameter 设置参数指针。
* 默认会自动为它设置 CParameterClient 。详见: CClient::CreateConnecter 。
* 如果参数不需要 CParameterClient ,那请在 CConnecter 派生类
* 重载 CConnecter::SetParameterClient 不设置 CParameterClient 。
*
* \~
* \see CClient::CreateConnecter CConnecter::CConnecter
* CConnecter::SetParameterClient CConnecter::SetParameter
* CParameterClient
*/
class CLIENT_EXPORT CParameterConnecter : public CParameter
{
Q_OBJECT
Q_PROPERTY(QString Name READ GetName WRITE SetName NOTIFY sigNameChanged)
Q_PROPERTY(QString ServerName READ GetServerName WRITE SetServerName)
Q_PROPERTY(bool ShowServerName READ GetShowServerName WRITE SetShowServerName NOTIFY sigShowServerNameChanged)
Q_PROPERTY(QString Host READ GetHost WRITE SetHost)
Q_PROPERTY(quint16 Port READ GetPort WRITE SetPort)
Q_PROPERTY(QString User READ GetUser WRITE SetUser)
Q_PROPERTY(QString Password READ GetPassword WRITE SetPassword)
Q_PROPERTY(bool SavePassword READ GetSavePassword WRITE SetSavePassword)
Q_PROPERTY(bool OnlyView READ GetOnlyView WRITE SetOnlyView)
Q_PROPERTY(bool LocalCursor READ GetLocalCursor WRITE SetLocalCursor)
Q_PROPERTY(bool Clipboard READ GetClipboard WRITE SetClipboard)
Q_PROPERTY(emProxy ProxyType READ GetProxyType WRITE SetProxyType)
Q_PROPERTY(QString ProxyHost READ GetProxyHost WRITE SetProxyHost)
Q_PROPERTY(qint16 ProxyPort READ GetProxyPort WRITE SetProxyPort)
Q_PROPERTY(QString ProxyUser READ GetProxyUser WRITE SetProxyUser)
Q_PROPERTY(QString ProxyPassword READ GetProxyPassword WRITE SetProxyPassword)
public:
explicit CParameterConnecter(QObject *parent = nullptr);
virtual int Load(QSettings &set) override;
virtual int Save(QSettings &set) override;
CParameterClient* GetParameterClient();
/*!
* \brief Check whether the parameters are complete
* to decide whether to open the parameter dialog
* \return
*/
virtual bool GetCheckCompleted();
const QString GetName() const;
void SetName(const QString& szName);
const QString GetServerName() const;
void SetServerName(const QString& szName);
bool GetShowServerName() const;
void SetShowServerName(bool NewShowServerName);
virtual const QString GetHost() const;
virtual void SetHost(const QString& szHost);
virtual const quint16 GetPort() const;
virtual void SetPort(quint16 port);
virtual const QString GetUser() const;
virtual void SetUser(const QString& szUser);
virtual const QString GetPassword() const;
virtual void SetPassword(const QString& szPassword);
const bool GetSavePassword() const;
/*!
* \brief Set save password
* \param save
*/
void SetSavePassword(bool save);
const bool GetOnlyView() const;
virtual void SetOnlyView(bool only);
virtual const bool GetLocalCursor() const;
virtual void SetLocalCursor(bool cursor);
virtual const bool GetClipboard() const;
virtual void SetClipboard(bool c);
enum class emProxy {
No,
SocksV4,
SocksV5,
Http,
User = 100
};
const emProxy GetProxyType() const;
void SetProxyType(emProxy type);
const QString GetProxyHost() const;
void SetProxyHost(const QString& host);
const quint16 GetProxyPort() const;
void SetProxyPort(quint16 port);
const QString GetProxyUser() const;
void SetProxyUser(const QString& user);
const QString GetProxyPassword() const;
void SetProxyPassword(const QString& password);
Q_SIGNALS:
void sigNameChanged(const QString &name = QString());
void sigShowServerNameChanged();
protected:
QByteArray PasswordSum(const std::string &password, const std::string &key);
int LoadPassword(const QString &szTitle, const QString &szKey,
QString &password, QSettings &set);
int SavePassword(const QString &szKey, const QString &password,
QSettings &set, bool bSave = false);
private:
friend CConnecter;
/*!
* \see CClient::CreateConnecter CConnecter::SetParameterClient
*/
CParameterClient* m_pParameterClient;
QString m_szName;
QString m_szServerName;
bool m_bShowServerName;
QString m_szHost;
quint16 m_nPort;
QString m_szUser;
QString m_szPassword;
bool m_bSavePassword;
bool m_bOnlyView;
bool m_bLocalCursor;
bool m_bClipboard;
emProxy m_eProxyType;
QString m_szProxyHost;
quint16 m_nProxyPort;
QString m_szProxyUser;
QString m_szProxyPassword;
};
#endif // CPARAMTERCONNECT_H