not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / libs / solid / control / networkipv4config.cpp
blob45313a20d2c979e3aeb111989d439a88afab9518
1 /*
2 Copyright 2008 Will Stephenson <wstephenson@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License or (at your option) version 3 or any later version
8 accepted by the membership of KDE e.V. (or its successor approved
9 by the membership of KDE e.V.), which shall act as a proxy
10 defined in Section 14 of version 3 of the license.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "networkipv4config.h"
24 namespace Solid
26 namespace Control
28 class IPv4Config::Private
30 public:
31 Private(const QList<IPv4Address> &theAddresses,
32 const QList<quint32> &theNameservers,
33 const QStringList &theDomains, const QList<IPv4Route> &theRoutes)
34 : addresses(theAddresses), nameservers(theNameservers),
35 domains(theDomains), routes(theRoutes)
37 Private()
39 QList<IPv4Address> addresses;
40 QList<quint32> nameservers;
41 QStringList domains;
42 QList<IPv4Route> routes;
46 class IPv4Address::Private
48 public:
49 Private(quint32 theAddress, quint32 theNetMask, quint32 theGateway)
50 : address(theAddress), netMask(theNetMask), gateway(theGateway)
52 Private()
53 : address(0), netMask(0), gateway(0)
55 quint32 address;
56 quint32 netMask;
57 quint32 gateway;
60 class IPv4Route::Private
62 public:
63 Private(quint32 theRoute, quint32 thePrefix, quint32 theNextHop, quint32 theMetric)
64 : route(theRoute), prefix(thePrefix), nextHop(theNextHop), metric(theMetric)
66 Private()
67 : route(0), prefix(0), nextHop(0), metric(0)
69 quint32 route;
70 quint32 prefix;
71 quint32 nextHop;
72 quint32 metric;
77 Solid::Control::IPv4Address::IPv4Address(quint32 address, quint32 netMask, quint32 gateway)
78 : d(new Private(address, netMask, gateway))
82 Solid::Control::IPv4Address::IPv4Address()
83 : d(new Private())
87 Solid::Control::IPv4Address::~IPv4Address()
89 delete d;
92 Solid::Control::IPv4Address::IPv4Address(const IPv4Address &other)
93 : d(new Private(*other.d))
97 quint32 Solid::Control::IPv4Address::address() const
99 return d->address;
102 quint32 Solid::Control::IPv4Address::netMask() const
104 return d->netMask;
107 quint32 Solid::Control::IPv4Address::gateway() const
109 return d->gateway;
112 Solid::Control::IPv4Address &Solid::Control::IPv4Address::operator=(const Solid::Control::IPv4Address &other)
114 if (this == &other)
115 return *this;
117 *d = *other.d;
118 return *this;
121 bool Solid::Control::IPv4Address::isValid() const
123 return d->address != 0;
126 Solid::Control::IPv4Route::IPv4Route(quint32 route, quint32 prefix, quint32 nextHop, quint32 metric)
127 : d(new Private(route, prefix, nextHop, metric))
131 Solid::Control::IPv4Route::IPv4Route()
132 : d(new Private())
136 Solid::Control::IPv4Route::~IPv4Route()
138 delete d;
141 Solid::Control::IPv4Route::IPv4Route(const IPv4Route &other)
142 : d(new Private(*other.d))
146 quint32 Solid::Control::IPv4Route::route() const
148 return d->route;
151 quint32 Solid::Control::IPv4Route::prefix() const
153 return d->prefix;
156 quint32 Solid::Control::IPv4Route::nextHop() const
158 return d->nextHop;
161 quint32 Solid::Control::IPv4Route::metric() const
163 return d->metric;
166 Solid::Control::IPv4Route &Solid::Control::IPv4Route::operator=(const Solid::Control::IPv4Route &other)
168 if (this == &other)
169 return *this;
171 *d = *other.d;
172 return *this;
175 bool Solid::Control::IPv4Route::isValid() const
177 return d->route != 0;
181 Solid::Control::IPv4Config::IPv4Config(const QList<IPv4Address> &addresses,
182 const QList<quint32> &nameservers,
183 const QStringList &domains,
184 const QList<IPv4Route> &routes)
185 : d(new Private(addresses, nameservers, domains, routes))
189 Solid::Control::IPv4Config::IPv4Config()
190 : d(new Private())
194 Solid::Control::IPv4Config::IPv4Config(const Solid::Control::IPv4Config& other)
196 d = new Private(*other.d);
199 Solid::Control::IPv4Config::~IPv4Config()
201 delete d;
204 QList<Solid::Control::IPv4Address> Solid::Control::IPv4Config::addresses() const
206 return d->addresses;
209 QList<quint32> Solid::Control::IPv4Config::nameservers() const
211 return d->nameservers;
214 QStringList Solid::Control::IPv4Config::domains() const
216 return d->domains;
219 Solid::Control::IPv4Config &Solid::Control::IPv4Config::operator=(const Solid::Control::IPv4Config& other)
221 if (this == &other)
222 return *this;
224 *d = *other.d;
225 return *this;
228 bool Solid::Control::IPv4Config::isValid() const
230 return !d->addresses.isEmpty();