cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / common / dccconfig.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2020 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #include "dccconfig.h"
22
23 #include <QMetaProperty>
24
25 #include "types.h"
26
27 DccConfig::DccConfig(QObject* parent)
28     : SyncableObject("DccConfig", parent)
29 {
30     static auto regTypes = []() -> bool {
31         qRegisterMetaTypeStreamOperators<IpDetectionMode>("DccConfig::IpDetectionMode");
32         qRegisterMetaTypeStreamOperators<PortSelectionMode>("DccConfig::PortSelectionMode");
33         return true;
34     }();
35     Q_UNUSED(regTypes);
36
37     setAllowClientUpdates(true);
38 }
39
40 bool DccConfig::operator==(const DccConfig& other)
41 {
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"))
47             continue;
48         if (QLatin1String(propName) == QLatin1String("outgoingIp")) {
49             // QVariant can't compare QHostAddress
50             if (property(propName).value<QHostAddress>() != other.property(propName).value<QHostAddress>())
51                 return false;
52         }
53         else if (property(propName) != other.property(propName))
54             return false;
55     }
56     return true;
57 }
58
59 bool DccConfig::isDccEnabled() const
60 {
61     return _dccEnabled;
62 }
63
64 void DccConfig::setDccEnabled(bool enabled)
65 {
66     _dccEnabled = enabled;
67 }
68
69 QHostAddress DccConfig::outgoingIp() const
70 {
71     return _outgoingIp;
72 }
73
74 void DccConfig::setOutgoingIp(const QHostAddress& outgoingIp)
75 {
76     _outgoingIp = outgoingIp;
77 }
78
79 DccConfig::IpDetectionMode DccConfig::ipDetectionMode() const
80 {
81     return _ipDetectionMode;
82 }
83
84 void DccConfig::setIpDetectionMode(DccConfig::IpDetectionMode detectionMode)
85 {
86     _ipDetectionMode = detectionMode;
87 }
88
89 DccConfig::PortSelectionMode DccConfig::portSelectionMode() const
90 {
91     return _portSelectionMode;
92 }
93
94 void DccConfig::setPortSelectionMode(DccConfig::PortSelectionMode portSelectionMode)
95 {
96     _portSelectionMode = portSelectionMode;
97 }
98
99 quint16 DccConfig::minPort() const
100 {
101     return _minPort;
102 }
103
104 void DccConfig::setMinPort(quint16 port)
105 {
106     _minPort = port;
107 }
108
109 quint16 DccConfig::maxPort() const
110 {
111     return _maxPort;
112 }
113
114 void DccConfig::setMaxPort(quint16 port)
115 {
116     _maxPort = port;
117 }
118
119 int DccConfig::chunkSize() const
120 {
121     return _chunkSize;
122 }
123
124 void DccConfig::setChunkSize(int chunkSize)
125 {
126     _chunkSize = chunkSize;
127 }
128
129 int DccConfig::sendTimeout() const
130 {
131     return _sendTimeout;
132 }
133
134 void DccConfig::setSendTimeout(int timeout)
135 {
136     _sendTimeout = timeout;
137 }
138
139 bool DccConfig::usePassiveDcc() const
140 {
141     return _usePassiveDcc;
142 }
143
144 void DccConfig::setUsePassiveDcc(bool use)
145 {
146     _usePassiveDcc = use;
147 }
148
149 bool DccConfig::useFastSend() const
150 {
151     return _useFastSend;
152 }
153
154 void DccConfig::setUseFastSend(bool use)
155 {
156     _useFastSend = use;
157 }