1 /***************************************************************************
2 * Copyright (C) 2005-2020 by the Quassel Project *
3 * devel@quassel-irc.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20
21 #include "dccconfig.h"
22
23 #include <QMetaProperty>
24
25 #include "types.h"
26
DccConfig(QObject * parent)27 DccConfig::DccConfig(QObject* parent)
28 : SyncableObject("DccConfig", parent)
29 {
30 static auto regTypes = []() -> bool {
31 qRegisterMetaTypeStreamOperators<IpDetectionMode>("DccConfig::IpDetectionMode");
32 qRegisterMetaTypeStreamOperators<PortSelectionMode>("DccConfig::PortSelectionMode");
33 return true;
34 }();
35 Q_UNUSED(regTypes);
36
37 setAllowClientUpdates(true);
38 }
39
operator ==(const DccConfig & other)40 bool DccConfig::operator==(const DccConfig& other)
41 {
42 // NOTE: We don't compare the SyncableObject attributes (isInitialized, clientUpdatesAllowed())
43 static auto propCount = staticMetaObject.propertyCount();
44 for (int i = 0; i < propCount; ++i) {
45 auto propName = staticMetaObject.property(i).name();
46 if (QLatin1String(propName) == QLatin1String("objectName"))
47 continue;
48 if (QLatin1String(propName) == QLatin1String("outgoingIp")) {
49 // QVariant can't compare QHostAddress
50 if (property(propName).value<QHostAddress>() != other.property(propName).value<QHostAddress>())
51 return false;
52 }
53 else if (property(propName) != other.property(propName))
54 return false;
55 }
56 return true;
57 }
58
isDccEnabled() const59 bool DccConfig::isDccEnabled() const
60 {
61 return _dccEnabled;
62 }
63
setDccEnabled(bool enabled)64 void DccConfig::setDccEnabled(bool enabled)
65 {
66 _dccEnabled = enabled;
67 }
68
outgoingIp() const69 QHostAddress DccConfig::outgoingIp() const
70 {
71 return _outgoingIp;
72 }
73
setOutgoingIp(const QHostAddress & outgoingIp)74 void DccConfig::setOutgoingIp(const QHostAddress& outgoingIp)
75 {
76 _outgoingIp = outgoingIp;
77 }
78
ipDetectionMode() const79 DccConfig::IpDetectionMode DccConfig::ipDetectionMode() const
80 {
81 return _ipDetectionMode;
82 }
83
setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)84 void DccConfig::setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)
85 {
86 _ipDetectionMode = detectionMode;
87 }
88
portSelectionMode() const89 DccConfig::PortSelectionMode DccConfig::portSelectionMode() const
90 {
91 return _portSelectionMode;
92 }
93
setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)94 void DccConfig::setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)
95 {
96 _portSelectionMode = portSelectionMode;
97 }
98
minPort() const99 quint16 DccConfig::minPort() const
100 {
101 return _minPort;
102 }
103
setMinPort(quint16 port)104 void DccConfig::setMinPort(quint16 port)
105 {
106 _minPort = port;
107 }
108
maxPort() const109 quint16 DccConfig::maxPort() const
110 {
111 return _maxPort;
112 }
113
setMaxPort(quint16 port)114 void DccConfig::setMaxPort(quint16 port)
115 {
116 _maxPort = port;
117 }
118
chunkSize() const119 int DccConfig::chunkSize() const
120 {
121 return _chunkSize;
122 }
123
setChunkSize(int chunkSize)124 void DccConfig::setChunkSize(int chunkSize)
125 {
126 _chunkSize = chunkSize;
127 }
128
sendTimeout() const129 int DccConfig::sendTimeout() const
130 {
131 return _sendTimeout;
132 }
133
setSendTimeout(int timeout)134 void DccConfig::setSendTimeout(int timeout)
135 {
136 _sendTimeout = timeout;
137 }
138
usePassiveDcc() const139 bool DccConfig::usePassiveDcc() const
140 {
141 return _usePassiveDcc;
142 }
143
setUsePassiveDcc(bool use)144 void DccConfig::setUsePassiveDcc(bool use)
145 {
146 _usePassiveDcc = use;
147 }
148
useFastSend() const149 bool DccConfig::useFastSend() const
150 {
151 return _useFastSend;
152 }
153
setUseFastSend(bool use)154 void DccConfig::setUseFastSend(bool use)
155 {
156 _useFastSend = use;
157 }
158