1 /***************************************************************************
2 * Copyright (C) 2005-2016 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 INIT_SYNCABLE_OBJECT(DccConfig)
29 DccConfig::DccConfig(QObject *parent)
30 : SyncableObject(parent)
32 static auto regTypes = []() -> bool {
33 qRegisterMetaTypeStreamOperators<IpDetectionMode>("DccConfig::IpDetectionMode");
34 qRegisterMetaTypeStreamOperators<PortSelectionMode>("DccConfig::PortSelectionMode");
39 renameObject("DccConfig");
40 setAllowClientUpdates(true);
44 DccConfig &DccConfig::operator=(const DccConfig &other)
49 SyncableObject::operator=(other);
51 static auto propCount = staticMetaObject.propertyCount();
52 for (int i = 0; i < propCount; ++i) {
53 auto propName = staticMetaObject.property(i).name();
54 setProperty(propName, other.property(propName));
61 bool DccConfig::operator==(const DccConfig &other)
63 // NOTE: We don't compare the SyncableObject attributes (isInitialized, clientUpdatesAllowed())
64 static auto propCount = staticMetaObject.propertyCount();
65 for (int i = 0; i < propCount; ++i) {
66 auto propName = staticMetaObject.property(i).name();
67 if (QLatin1String(propName) == QLatin1String("objectName"))
69 if (QLatin1String(propName) == QLatin1String("outgoingIp")) {
70 // QVariant can't compare QHostAddress
71 if (property(propName).value<QHostAddress>() != other.property(propName).value<QHostAddress>())
74 else if (property(propName) != other.property(propName))
81 bool DccConfig::isDccEnabled() const
87 void DccConfig::setDccEnabled(bool enabled)
89 _dccEnabled = enabled;
93 QHostAddress DccConfig::outgoingIp() const
99 void DccConfig::setOutgoingIp(const QHostAddress &outgoingIp)
101 _outgoingIp = outgoingIp;
105 DccConfig::IpDetectionMode DccConfig::ipDetectionMode() const
107 return _ipDetectionMode;
111 void DccConfig::setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)
113 _ipDetectionMode = detectionMode;
117 DccConfig::PortSelectionMode DccConfig::portSelectionMode() const
119 return _portSelectionMode;
123 void DccConfig::setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)
125 _portSelectionMode = portSelectionMode;
129 quint16 DccConfig::minPort() const
135 void DccConfig::setMinPort(quint16 port)
141 quint16 DccConfig::maxPort() const
147 void DccConfig::setMaxPort(quint16 port)
153 int DccConfig::chunkSize() const
159 void DccConfig::setChunkSize(int chunkSize)
161 _chunkSize = chunkSize;
165 int DccConfig::sendTimeout() const
171 void DccConfig::setSendTimeout(int timeout)
173 _sendTimeout = timeout;
177 bool DccConfig::usePassiveDcc() const
179 return _usePassiveDcc;
183 void DccConfig::setUsePassiveDcc(bool use)
185 _usePassiveDcc = use;
189 bool DccConfig::useFastSend() const
195 void DccConfig::setUseFastSend(bool use)