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);
41 DccConfig& DccConfig::operator=(const DccConfig& other)
46 SyncableObject::operator=(other);
48 static auto propCount = staticMetaObject.propertyCount();
49 for (int i = 0; i < propCount; ++i) {
50 auto propName = staticMetaObject.property(i).name();
51 setProperty(propName, other.property(propName));
57 bool DccConfig::operator==(const DccConfig& other)
59 // NOTE: We don't compare the SyncableObject attributes (isInitialized, clientUpdatesAllowed())
60 static auto propCount = staticMetaObject.propertyCount();
61 for (int i = 0; i < propCount; ++i) {
62 auto propName = staticMetaObject.property(i).name();
63 if (QLatin1String(propName) == QLatin1String("objectName"))
65 if (QLatin1String(propName) == QLatin1String("outgoingIp")) {
66 // QVariant can't compare QHostAddress
67 if (property(propName).value<QHostAddress>() != other.property(propName).value<QHostAddress>())
70 else if (property(propName) != other.property(propName))
76 bool DccConfig::isDccEnabled() const
81 void DccConfig::setDccEnabled(bool enabled)
83 _dccEnabled = enabled;
86 QHostAddress DccConfig::outgoingIp() const
91 void DccConfig::setOutgoingIp(const QHostAddress& outgoingIp)
93 _outgoingIp = outgoingIp;
96 DccConfig::IpDetectionMode DccConfig::ipDetectionMode() const
98 return _ipDetectionMode;
101 void DccConfig::setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)
103 _ipDetectionMode = detectionMode;
106 DccConfig::PortSelectionMode DccConfig::portSelectionMode() const
108 return _portSelectionMode;
111 void DccConfig::setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)
113 _portSelectionMode = portSelectionMode;
116 quint16 DccConfig::minPort() const
121 void DccConfig::setMinPort(quint16 port)
126 quint16 DccConfig::maxPort() const
131 void DccConfig::setMaxPort(quint16 port)
136 int DccConfig::chunkSize() const
141 void DccConfig::setChunkSize(int chunkSize)
143 _chunkSize = chunkSize;
146 int DccConfig::sendTimeout() const
151 void DccConfig::setSendTimeout(int timeout)
153 _sendTimeout = timeout;
156 bool DccConfig::usePassiveDcc() const
158 return _usePassiveDcc;
161 void DccConfig::setUsePassiveDcc(bool use)
163 _usePassiveDcc = use;
166 bool DccConfig::useFastSend() const
171 void DccConfig::setUseFastSend(bool use)