add more spacing
[personal-kdebase.git] / workspace / solid / networkmanager-0.7 / wirednetworkinterface.cpp
blob5f10a08706924ba05c7f5891076f80eb82664a0c
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/>.
21 #include "wirednetworkinterface.h"
22 #include "wirednetworkinterface_p.h"
23 #include "manager.h"
25 #define NM_DEVICE_802_3_ETHERNET_HW_ADDRESS "hw-address"
26 #define NM_DEVICE_802_3_ETHERNET_SPEED "speed"
27 #define NM_DEVICE_802_3_ETHERNET_CARRIER "carrier"
29 NMWiredNetworkInterfacePrivate::NMWiredNetworkInterfacePrivate(const QString & path, QObject * owner)
30 : NMNetworkInterfacePrivate(path, owner), wiredIface(NMNetworkManager::DBUS_SERVICE, path, QDBusConnection::systemBus()),
31 bitrate(0), carrier(false)
35 NMWiredNetworkInterface::NMWiredNetworkInterface(const QString & path, NMNetworkManager * manager, QObject * parent)
36 : NMNetworkInterface(*new NMWiredNetworkInterfacePrivate(path, this), manager, parent)
38 Q_D(NMWiredNetworkInterface);
39 d->hardwareAddress = d->wiredIface.hwAddress();
40 d->bitrate = d->wiredIface.speed();
41 d->carrier = d->wiredIface.carrier();
42 //d->propHelper.registerProperty();
43 connect( &d->wiredIface, SIGNAL(PropertiesChanged(const QVariantMap &)),
44 this, SLOT(wiredPropertiesChanged(const QVariantMap &)));
47 NMWiredNetworkInterface::~NMWiredNetworkInterface()
51 QString NMWiredNetworkInterface::hardwareAddress() const
53 Q_D(const NMWiredNetworkInterface);
54 return d->hardwareAddress;
57 int NMWiredNetworkInterface::bitRate() const
59 Q_D(const NMWiredNetworkInterface);
60 return d->bitrate;
63 bool NMWiredNetworkInterface::carrier() const
65 Q_D(const NMWiredNetworkInterface);
66 return d->carrier;
69 void NMWiredNetworkInterface::setCarrier(const QVariant& carrier)
71 Q_D(NMWiredNetworkInterface);
72 d->carrier = carrier.toBool();
75 void NMWiredNetworkInterface::setBitRate(const QVariant& bitrate)
77 Q_D(NMWiredNetworkInterface);
78 d->bitrate = bitrate.toInt();
81 void NMWiredNetworkInterface::wiredPropertiesChanged(const QVariantMap &properties)
83 Q_D(NMWiredNetworkInterface);
84 QStringList propKeys = properties.keys();
85 kDebug(1441) << properties.keys();
86 QLatin1String carrierKey("Carrier");
87 QLatin1String hwAddressKey("HwAddress");
88 QLatin1String speedKey("Speed");
89 QVariantMap::const_iterator it = properties.find(carrierKey);
90 if ( it != properties.end()) {
91 d->carrier = it->toBool();
92 emit carrierChanged(d->carrier);
93 propKeys.removeOne(carrierKey);
95 it = properties.find(speedKey);
96 if ( it != properties.end()) {
97 d->bitrate = it->toUInt();
98 emit bitRateChanged(d->bitrate);
99 propKeys.removeOne(speedKey);
101 it = properties.find(hwAddressKey);
102 if ( it != properties.end()) {
103 d->hardwareAddress = it->toString();
104 propKeys.removeOne(hwAddressKey);
106 if (propKeys.count()) {
107 kDebug(1441) << "Unhandled properties: ";
108 foreach (QString key, propKeys) {
109 kDebug(1441) << key << properties.value(key);
114 #include "wirednetworkinterface.moc"