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

libsolidcontrol

wirelessnetworkinterface.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2006 Will Stephenson <wstephenson@kde.org>
00003     Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License version 2 as published by the Free Software Foundation.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 
00019 */
00020 
00021 #include "wirelessnetworkinterface.h"
00022 #include "wirelessnetworkinterface_p.h"
00023 
00024 #include "soliddefs_p.h"
00025 #include "wirelessaccesspoint.h"
00026 #include "ifaces/wirelessaccesspoint.h"
00027 #include "ifaces/wirelessnetworkinterface.h"
00028 
00029 Solid::Control::WirelessNetworkInterface::WirelessNetworkInterface(QObject *backendObject)
00030     : NetworkInterface(*new WirelessNetworkInterfacePrivate(this), backendObject)
00031 {
00032     Q_D(WirelessNetworkInterface);
00033     d->setBackendObject(backendObject);
00034     makeConnections( backendObject );
00035     d->readAccessPoints();
00036 }
00037 
00038 Solid::Control::WirelessNetworkInterface::WirelessNetworkInterface(const WirelessNetworkInterface &networkinterface)
00039     : NetworkInterface(*new WirelessNetworkInterfacePrivate(this), networkinterface)
00040 {
00041     Q_D(WirelessNetworkInterface);
00042     d->setBackendObject(networkinterface.d_ptr->backendObject());
00043     makeConnections( networkinterface.d_ptr->backendObject() );
00044     d->readAccessPoints();
00045 }
00046 
00047 Solid::Control::WirelessNetworkInterface::WirelessNetworkInterface(WirelessNetworkInterfacePrivate &dd, QObject *backendObject)
00048     : NetworkInterface(dd, backendObject)
00049 {
00050     Q_D(WirelessNetworkInterface);
00051     makeConnections( backendObject );
00052     d->readAccessPoints();
00053 }
00054 
00055 Solid::Control::WirelessNetworkInterface::WirelessNetworkInterface(WirelessNetworkInterfacePrivate &dd, const WirelessNetworkInterface &networkinterface)
00056     : NetworkInterface(dd, networkinterface.d_ptr->backendObject())
00057 {
00058     Q_D(WirelessNetworkInterface);
00059     makeConnections( networkinterface.d_ptr->backendObject() );
00060     d->readAccessPoints();
00061 }
00062 
00063 Solid::Control::WirelessNetworkInterface::~WirelessNetworkInterface()
00064 {
00065 
00066 }
00067 
00068 Solid::Control::NetworkInterface::Type Solid::Control::WirelessNetworkInterface::type() const
00069 {
00070     return Ieee80211;
00071 }
00072 
00073 void Solid::Control::WirelessNetworkInterface::makeConnections(QObject * source)
00074 {
00075     connect(source, SIGNAL(accessPointAppeared(const QString &)),
00076             this, SLOT(_k_accessPointAdded(const QString &)));
00077     connect(source, SIGNAL(accessPointDisappeared(const QString &)),
00078             this, SLOT(_k_accessPointRemoved(const QString &)));
00079     connect(source, SIGNAL(bitRateChanged(int)),
00080             this, SIGNAL(bitRateChanged(int)));
00081     connect(source, SIGNAL(activeAccessPointChanged(const QString&)),
00082             this, SIGNAL(activeAccessPointChanged(const QString&)));
00083     connect(source, SIGNAL(modeChanged(Solid::Control::WirelessNetworkInterface::OperationMode)),
00084             this, SIGNAL(modeChanged(Solid::Control::WirelessNetworkInterface::OperationMode)));
00085 }
00086 
00087 QString Solid::Control::WirelessNetworkInterface::hardwareAddress() const
00088 {
00089     Q_D(const WirelessNetworkInterface);
00090     return_SOLID_CALL(Ifaces::WirelessNetworkInterface *, d->backendObject(), QString(), hardwareAddress());
00091 }
00092 
00093 QString Solid::Control::WirelessNetworkInterface::activeAccessPoint() const
00094 {
00095     Q_D(const WirelessNetworkInterface);
00096     return_SOLID_CALL(Ifaces::WirelessNetworkInterface *, d->backendObject(), QString(), activeAccessPoint());
00097 }
00098 
00099 int Solid::Control::WirelessNetworkInterface::bitRate() const
00100 {
00101     Q_D(const WirelessNetworkInterface);
00102     return_SOLID_CALL(Ifaces::WirelessNetworkInterface *, d->backendObject(), 0, bitRate());
00103 }
00104 
00105 Solid::Control::WirelessNetworkInterface::OperationMode Solid::Control::WirelessNetworkInterface::mode() const
00106 {
00107     Q_D(const WirelessNetworkInterface);
00108     return_SOLID_CALL(Ifaces::WirelessNetworkInterface *, d->backendObject(), (Solid::Control::WirelessNetworkInterface::OperationMode)0, mode());
00109 }
00110 
00111 Solid::Control::WirelessNetworkInterface::Capabilities Solid::Control::WirelessNetworkInterface::wirelessCapabilities() const
00112 {
00113     Q_D(const WirelessNetworkInterface);
00114     return_SOLID_CALL(Ifaces::WirelessNetworkInterface *, d->backendObject(), (Solid::Control::WirelessNetworkInterface::Capabilities)0, wirelessCapabilities());
00115 }
00116 
00117 Solid::Control::AccessPoint * Solid::Control::WirelessNetworkInterface::findAccessPoint(const QString  & uni) const
00118 {
00119     const AccessPointPair pair = findRegisteredAccessPoint(uni);
00120     return pair.first;
00121 }
00122 
00123 void Solid::Control::WirelessNetworkInterfacePrivate::setBackendObject(QObject *object)
00124 {
00125     NetworkInterfacePrivate::setBackendObject(object);
00126 
00127     if (object) {
00128     }
00129 }
00130 
00131 Solid::Control::AccessPointList Solid::Control::WirelessNetworkInterface::accessPoints() const
00132 {
00133     Q_D(const WirelessNetworkInterface);
00134     return d->apMap.keys();
00135 }
00136 
00137 void Solid::Control::WirelessNetworkInterface::_k_accessPointAdded(const QString & uni)
00138 {
00139     Q_D(WirelessNetworkInterface);
00140     AccessPointMap::Iterator mapIt = d->apMap.find(uni);
00141 
00142     if (mapIt != d->apMap.end())
00143     {
00144         // Oops, I'm not sure it should happen...
00145         // But for an unknown reason it does
00146         // We were deleting the existing items here, which caused problems later
00147         // when the client calls find AccessPoint and gets a frontend object with a
00148         // null private object - dangling pointer
00149     } else {
00150         mapIt = d->apMap.insert(uni, AccessPointPair(0, 0));
00151     }
00152 
00153     emit accessPointAppeared(uni);
00154 }
00155 
00156 void Solid::Control::WirelessNetworkInterface::_k_accessPointRemoved(const QString & uni)
00157 {
00158     Q_D(WirelessNetworkInterface);
00159     AccessPointPair pair = d->apMap.take(uni);
00160 
00161     if (pair.first!= 0)
00162     {
00163         delete pair.first;
00164         delete pair.second;
00165     }
00166 
00167     emit accessPointDisappeared(uni);
00168 }
00169 
00170 void Solid::Control::WirelessNetworkInterface::_k_destroyed(QObject *object)
00171 {
00172     Q_D(WirelessNetworkInterface);
00173     Ifaces::AccessPoint *ap = qobject_cast<Ifaces::AccessPoint *>(object);
00174 
00175     if (ap!=0)
00176     {
00177         QString uni = ap->uni();
00178         AccessPointPair pair = d->apMap.take(uni);
00179         delete pair.first;
00180     }
00181 }
00182 
00183 Solid::Control::AccessPointPair
00184 Solid::Control::WirelessNetworkInterface::findRegisteredAccessPoint(const QString &uni) const
00185 {
00186     Q_D(const WirelessNetworkInterface);
00187 
00188     AccessPointMap::ConstIterator mapIt = d->apMap.constFind(uni);
00189     if (mapIt != d->apMap.constEnd() && mapIt.value().second) {
00190         return mapIt.value();
00191     } else {
00192         AccessPointPair pair = d->createAP(uni);
00193         if (pair.first && pair.second) {
00194             d->apMap[uni] = pair;
00195         }
00196         return pair;
00197     }
00198 
00199     return AccessPointPair(0, 0);
00200 }
00201 
00202 void Solid::Control::WirelessNetworkInterfacePrivate::readAccessPoints()
00203 {
00204     Ifaces::WirelessNetworkInterface * t = qobject_cast<Ifaces::WirelessNetworkInterface *>(backendObject());
00205     if (t != 0)
00206     {
00207         const MacAddressList unis = t->accessPoints();
00208         Q_FOREACH (const QString & uni, unis) {
00209             apMap[uni] = AccessPointPair(0, 0);
00210         }
00211     }
00212 }
00213 
00214 Solid::Control::AccessPointPair
00215 Solid::Control::WirelessNetworkInterfacePrivate::createAP(const QString &uni) const
00216 {
00217     Ifaces::WirelessNetworkInterface *device = qobject_cast<Ifaces::WirelessNetworkInterface *>(backendObject());
00218     AccessPoint *ap = 0;
00219 
00220     if (device!=0) {
00221         Ifaces::AccessPoint *iface = qobject_cast<Ifaces::AccessPoint *>(device->createAccessPoint(uni));
00222 
00223         if (qobject_cast<Ifaces::AccessPoint *>(iface)!=0) {
00224             ap = new AccessPoint(iface);
00225         }
00226 
00227         if (ap != 0) {
00228             AccessPointPair pair(ap, iface);
00229             QObject::connect(iface, SIGNAL(destroyed(QObject *)),
00230                              parent(), SLOT(_k_destroyed(QObject *)));
00231 
00232             return pair;
00233         }
00234     }
00235     return AccessPointPair(0, 0);
00236 }
00237 
00238 #include "wirelessnetworkinterface.moc"

libsolidcontrol

Skip menu "libsolidcontrol"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

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