• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

SolidModules

wirednetworkinterface.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright 2008 Will Stephenson <wstephenson@kde.org>
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License as
00006 published by the Free Software Foundation; either version 2 of
00007 the License or (at your option) version 3 or any later version
00008 accepted by the membership of KDE e.V. (or its successor approved
00009 by the membership of KDE e.V.), which shall act as a proxy 
00010 defined in Section 14 of version 3 of the license.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program.  If not, see <http://www.gnu.org/licenses/>.
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     //d->propHelper.registerProperty();
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: ";
00108         foreach (QString key, propKeys) {
00109             kDebug(1441) << key << properties.value(key);
00110         }
00111     }
00112 }
00113 
00114 #include "wirednetworkinterface.moc"
00115 

SolidModules

Skip menu "SolidModules"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal