SolidModules
wirednetworkinterface.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "wirednetworkinterface.h"
00022 #include "wirednetworkinterface_p.h"
00023 #include "manager.h"
00024
00025 #define NM_DEVICE_802_3_ETHERNET_HW_ADDRESS "hw-address"
00026 #define NM_DEVICE_802_3_ETHERNET_SPEED "speed"
00027 #define NM_DEVICE_802_3_ETHERNET_CARRIER "carrier"
00028
00029 NMWiredNetworkInterfacePrivate::NMWiredNetworkInterfacePrivate(const QString & path, QObject * owner)
00030 : NMNetworkInterfacePrivate(path, owner), wiredIface(NMNetworkManager::DBUS_SERVICE, path, QDBusConnection::systemBus()),
00031 bitrate(0), carrier(false)
00032 {
00033 }
00034
00035 NMWiredNetworkInterface::NMWiredNetworkInterface(const QString & path, NMNetworkManager * manager, QObject * parent)
00036 : NMNetworkInterface(*new NMWiredNetworkInterfacePrivate(path, this), manager, parent)
00037 {
00038 Q_D(NMWiredNetworkInterface);
00039 d->hardwareAddress = d->wiredIface.hwAddress();
00040 d->bitrate = d->wiredIface.speed();
00041 d->carrier = d->wiredIface.carrier();
00042
00043 connect( &d->wiredIface, SIGNAL(PropertiesChanged(const QVariantMap &)),
00044 this, SLOT(wiredPropertiesChanged(const QVariantMap &)));
00045 }
00046
00047 NMWiredNetworkInterface::~NMWiredNetworkInterface()
00048 {
00049 }
00050
00051 QString NMWiredNetworkInterface::hardwareAddress() const
00052 {
00053 Q_D(const NMWiredNetworkInterface);
00054 return d->hardwareAddress;
00055 }
00056
00057 int NMWiredNetworkInterface::bitRate() const
00058 {
00059 Q_D(const NMWiredNetworkInterface);
00060 return d->bitrate;
00061 }
00062
00063 bool NMWiredNetworkInterface::carrier() const
00064 {
00065 Q_D(const NMWiredNetworkInterface);
00066 return d->carrier;
00067 }
00068
00069 void NMWiredNetworkInterface::setCarrier(const QVariant& carrier)
00070 {
00071 Q_D(NMWiredNetworkInterface);
00072 d->carrier = carrier.toBool();
00073 }
00074
00075 void NMWiredNetworkInterface::setBitRate(const QVariant& bitrate)
00076 {
00077 Q_D(NMWiredNetworkInterface);
00078 d->bitrate = bitrate.toInt();
00079 }
00080
00081 void NMWiredNetworkInterface::wiredPropertiesChanged(const QVariantMap &properties)
00082 {
00083 Q_D(NMWiredNetworkInterface);
00084 QStringList propKeys = properties.keys();
00085 kDebug(1441) << properties.keys();
00086 QLatin1String carrierKey("Carrier");
00087 QLatin1String hwAddressKey("HwAddress");
00088 QLatin1String speedKey("Speed");
00089 QVariantMap::const_iterator it = properties.find(carrierKey);
00090 if ( it != properties.end()) {
00091 d->carrier = it->toBool();
00092 emit carrierChanged(d->carrier);
00093 propKeys.removeOne(carrierKey);
00094 }
00095 it = properties.find(speedKey);
00096 if ( it != properties.end()) {
00097 d->bitrate = it->toUInt();
00098 emit bitRateChanged(d->bitrate);
00099 propKeys.removeOne(speedKey);
00100 }
00101 it = properties.find(hwAddressKey);
00102 if ( it != properties.end()) {
00103 d->hardwareAddress = it->toString();
00104 propKeys.removeOne(hwAddressKey);
00105 }
00106 if (propKeys.count()) {
00107 kDebug(1441) << "Unhandled properties: " << propKeys;
00108 }
00109 }
00110
00111 #include "wirednetworkinterface.moc"
00112