modernize: Use raw string literals instead of escaped strings
[quassel.git] / src / common / dccconfig.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 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
27 DccConfig::DccConfig(QObject *parent)
28     : SyncableObject(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     renameObject("DccConfig");
38     setAllowClientUpdates(true);
39 }
40
41
42 DccConfig &DccConfig::operator=(const DccConfig &other)
43 {
44     if (this == &other)
45         return *this;
46
47     SyncableObject::operator=(other);
48
49     static auto propCount = staticMetaObject.propertyCount();
50     for (int i = 0; i < propCount; ++i) {
51         auto propName = staticMetaObject.property(i).name();
52         setProperty(propName, other.property(propName));
53     }
54
55     return *this;
56 }
57
58
59 bool DccConfig::operator==(const DccConfig &other)
60 {
61     // NOTE: We don't compare the SyncableObject attributes (isInitialized, clientUpdatesAllowed())
62     static auto propCount = staticMetaObject.propertyCount();
63     for (int i = 0; i < propCount; ++i) {
64         auto propName = staticMetaObject.property(i).name();
65         if (QLatin1String(propName) == QLatin1String("objectName"))
66             continue;
67         if (QLatin1String(propName) == QLatin1String("outgoingIp")) {
68             // QVariant can't compare QHostAddress
69             if (property(propName).value<QHostAddress>() != other.property(propName).value<QHostAddress>())
70                 return false;
71         }
72         else if (property(propName) != other.property(propName))
73                 return false;
74     }
75     return true;
76 }
77
78
79 bool DccConfig::isDccEnabled() const
80 {
81     return _dccEnabled;
82 }
83
84
85 void DccConfig::setDccEnabled(bool enabled)
86 {
87     _dccEnabled = enabled;
88 }
89
90
91 QHostAddress DccConfig::outgoingIp() const
92 {
93     return _outgoingIp;
94 }
95
96
97 void DccConfig::setOutgoingIp(const QHostAddress &outgoingIp)
98 {
99     _outgoingIp = outgoingIp;
100 }
101
102
103 DccConfig::IpDetectionMode DccConfig::ipDetectionMode() const
104 {
105     return _ipDetectionMode;
106 }
107
108
109 void DccConfig::setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)
110 {
111     _ipDetectionMode = detectionMode;
112 }
113
114
115 DccConfig::PortSelectionMode DccConfig::portSelectionMode() const
116 {
117     return _portSelectionMode;
118 }
119
120
121 void DccConfig::setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)
122 {
123     _portSelectionMode = portSelectionMode;
124 }
125
126
127 quint16 DccConfig::minPort() const
128 {
129     return _minPort;
130 }
131
132
133 void DccConfig::setMinPort(quint16 port)
134 {
135     _minPort = port;
136 }
137
138
139 quint16 DccConfig::maxPort() const
140 {
141     return _maxPort;
142 }
143
144
145 void DccConfig::setMaxPort(quint16 port)
146 {
147     _maxPort = port;
148 }
149
150
151 int DccConfig::chunkSize() const
152 {
153     return _chunkSize;
154 }
155
156
157 void DccConfig::setChunkSize(int chunkSize)
158 {
159     _chunkSize = chunkSize;
160 }
161
162
163 int DccConfig::sendTimeout() const
164 {
165     return _sendTimeout;
166 }
167
168
169 void DccConfig::setSendTimeout(int timeout)
170 {
171     _sendTimeout = timeout;
172 }
173
174
175 bool DccConfig::usePassiveDcc() const
176 {
177     return _usePassiveDcc;
178 }
179
180
181 void DccConfig::setUsePassiveDcc(bool use)
182 {
183     _usePassiveDcc = use;
184 }
185
186
187 bool DccConfig::useFastSend() const
188 {
189     return _useFastSend;
190 }
191
192
193 void DccConfig::setUseFastSend(bool use)
194 {
195     _useFastSend = use;
196 }