1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #include "dccconfig.h"
23 #include <QMetaProperty>
27 DccConfig::DccConfig(QObject* parent)
28 : SyncableObject("DccConfig", parent)
30 static auto regTypes = []() -> bool {
31 qRegisterMetaTypeStreamOperators<IpDetectionMode>("DccConfig::IpDetectionMode");
32 qRegisterMetaTypeStreamOperators<PortSelectionMode>("DccConfig::PortSelectionMode");
37 setAllowClientUpdates(true);
40 DccConfig& DccConfig::operator=(const DccConfig& other)
45 SyncableObject::operator=(other);
47 static auto propCount = staticMetaObject.propertyCount();
48 for (int i = 0; i < propCount; ++i) {
49 auto propName = staticMetaObject.property(i).name();
50 setProperty(propName, other.property(propName));
56 bool DccConfig::operator==(const DccConfig& other)
58 // NOTE: We don't compare the SyncableObject attributes (isInitialized, clientUpdatesAllowed())
59 static auto propCount = staticMetaObject.propertyCount();
60 for (int i = 0; i < propCount; ++i) {
61 auto propName = staticMetaObject.property(i).name();
62 if (QLatin1String(propName) == QLatin1String("objectName"))
64 if (QLatin1String(propName) == QLatin1String("outgoingIp")) {
65 // QVariant can't compare QHostAddress
66 if (property(propName).value<QHostAddress>() != other.property(propName).value<QHostAddress>())
69 else if (property(propName) != other.property(propName))
75 bool DccConfig::isDccEnabled() const
80 void DccConfig::setDccEnabled(bool enabled)
82 _dccEnabled = enabled;
85 QHostAddress DccConfig::outgoingIp() const
90 void DccConfig::setOutgoingIp(const QHostAddress& outgoingIp)
92 _outgoingIp = outgoingIp;
95 DccConfig::IpDetectionMode DccConfig::ipDetectionMode() const
97 return _ipDetectionMode;
100 void DccConfig::setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)
102 _ipDetectionMode = detectionMode;
105 DccConfig::PortSelectionMode DccConfig::portSelectionMode() const
107 return _portSelectionMode;
110 void DccConfig::setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)
112 _portSelectionMode = portSelectionMode;
115 quint16 DccConfig::minPort() const
120 void DccConfig::setMinPort(quint16 port)
125 quint16 DccConfig::maxPort() const
130 void DccConfig::setMaxPort(quint16 port)
135 int DccConfig::chunkSize() const
140 void DccConfig::setChunkSize(int chunkSize)
142 _chunkSize = chunkSize;
145 int DccConfig::sendTimeout() const
150 void DccConfig::setSendTimeout(int timeout)
152 _sendTimeout = timeout;
155 bool DccConfig::usePassiveDcc() const
157 return _usePassiveDcc;
160 void DccConfig::setUsePassiveDcc(bool use)
162 _usePassiveDcc = use;
165 bool DccConfig::useFastSend() const
170 void DccConfig::setUseFastSend(bool use)