1 /***************************************************************************
2 * Copyright (C) 2005-2018 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(parent)
30 static auto regTypes = []() -> bool {
31 qRegisterMetaTypeStreamOperators<IpDetectionMode>("DccConfig::IpDetectionMode");
32 qRegisterMetaTypeStreamOperators<PortSelectionMode>("DccConfig::PortSelectionMode");
37 renameObject("DccConfig");
38 setAllowClientUpdates(true);
42 DccConfig &DccConfig::operator=(const DccConfig &other)
47 SyncableObject::operator=(other);
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));
59 bool DccConfig::operator==(const DccConfig &other)
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"))
67 if (QLatin1String(propName) == QLatin1String("outgoingIp")) {
68 // QVariant can't compare QHostAddress
69 if (property(propName).value<QHostAddress>() != other.property(propName).value<QHostAddress>())
72 else if (property(propName) != other.property(propName))
79 bool DccConfig::isDccEnabled() const
85 void DccConfig::setDccEnabled(bool enabled)
87 _dccEnabled = enabled;
91 QHostAddress DccConfig::outgoingIp() const
97 void DccConfig::setOutgoingIp(const QHostAddress &outgoingIp)
99 _outgoingIp = outgoingIp;
103 DccConfig::IpDetectionMode DccConfig::ipDetectionMode() const
105 return _ipDetectionMode;
109 void DccConfig::setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)
111 _ipDetectionMode = detectionMode;
115 DccConfig::PortSelectionMode DccConfig::portSelectionMode() const
117 return _portSelectionMode;
121 void DccConfig::setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)
123 _portSelectionMode = portSelectionMode;
127 quint16 DccConfig::minPort() const
133 void DccConfig::setMinPort(quint16 port)
139 quint16 DccConfig::maxPort() const
145 void DccConfig::setMaxPort(quint16 port)
151 int DccConfig::chunkSize() const
157 void DccConfig::setChunkSize(int chunkSize)
159 _chunkSize = chunkSize;
163 int DccConfig::sendTimeout() const
169 void DccConfig::setSendTimeout(int timeout)
171 _sendTimeout = timeout;
175 bool DccConfig::usePassiveDcc() const
177 return _usePassiveDcc;
181 void DccConfig::setUsePassiveDcc(bool use)
183 _usePassiveDcc = use;
187 bool DccConfig::useFastSend() const
193 void DccConfig::setUseFastSend(bool use)