1 /***************************************************************************
2 * Copyright (C) 2005-2020 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 bool DccConfig::operator==(const DccConfig& other)
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"))
48 if (QLatin1String(propName) == QLatin1String("outgoingIp")) {
49 // QVariant can't compare QHostAddress
50 if (property(propName).value<QHostAddress>() != other.property(propName).value<QHostAddress>())
53 else if (property(propName) != other.property(propName))
59 bool DccConfig::isDccEnabled() const
64 void DccConfig::setDccEnabled(bool enabled)
66 _dccEnabled = enabled;
69 QHostAddress DccConfig::outgoingIp() const
74 void DccConfig::setOutgoingIp(const QHostAddress& outgoingIp)
76 _outgoingIp = outgoingIp;
79 DccConfig::IpDetectionMode DccConfig::ipDetectionMode() const
81 return _ipDetectionMode;
84 void DccConfig::setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)
86 _ipDetectionMode = detectionMode;
89 DccConfig::PortSelectionMode DccConfig::portSelectionMode() const
91 return _portSelectionMode;
94 void DccConfig::setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)
96 _portSelectionMode = portSelectionMode;
99 quint16 DccConfig::minPort() const
104 void DccConfig::setMinPort(quint16 port)
109 quint16 DccConfig::maxPort() const
114 void DccConfig::setMaxPort(quint16 port)
119 int DccConfig::chunkSize() const
124 void DccConfig::setChunkSize(int chunkSize)
126 _chunkSize = chunkSize;
129 int DccConfig::sendTimeout() const
134 void DccConfig::setSendTimeout(int timeout)
136 _sendTimeout = timeout;
139 bool DccConfig::usePassiveDcc() const
141 return _usePassiveDcc;
144 void DccConfig::setUsePassiveDcc(bool use)
146 _usePassiveDcc = use;
149 bool DccConfig::useFastSend() const
154 void DccConfig::setUseFastSend(bool use)