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

SolidModules

accesspoint.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 "accesspoint.h"
00022 
00023 #include <KDebug>
00024 #include "dbus/nm-access-pointinterface.h"
00025 #include "manager.h"
00026 #include "wirelessnetworkinterface.h"
00027 
00028 
00029 class NMAccessPoint::Private
00030 {
00031 public:
00032     Private( const QString & path ) : iface( NMNetworkManager::DBUS_SERVICE, path, QDBusConnection::systemBus()), capabilities(0), wpaFlags(0), rsnFlags(0), frequency(0), hardwareAddress(0), maxBitRate(0), mode((Solid::Control::WirelessNetworkInterface::OperationMode)0), signalStrength(0)
00033     {
00034     }
00035     OrgFreedesktopNetworkManagerAccessPointInterface iface;
00036     QString uni;
00037     Solid::Control::AccessPoint::Capabilities capabilities;
00038     Solid::Control::AccessPoint::WpaFlags wpaFlags;
00039     Solid::Control::AccessPoint::WpaFlags rsnFlags;
00040     QString ssid;
00041     uint frequency;
00042     QString hardwareAddress;
00043     uint maxBitRate;
00044     Solid::Control::WirelessNetworkInterface::OperationMode mode;
00045     int signalStrength;
00046 };
00047 
00048 NMAccessPoint::NMAccessPoint( const QString& path, QObject * parent ) : Solid::Control::Ifaces::AccessPoint(parent), d(new Private( path ))
00049 {
00050     d->uni = path;
00051     d->capabilities = convertCapabilities( d->iface.flags() );
00052     d->wpaFlags = convertWpaFlags( d->iface.wpaFlags() );
00053     d->rsnFlags = convertWpaFlags( d->iface.rsnFlags() );
00054     d->signalStrength = d->iface.strength();
00055     d->ssid = d->iface.ssid();
00056     d->frequency = d->iface.frequency();
00057     d->hardwareAddress = d->iface.hwAddress();
00058     d->maxBitRate = d->iface.maxBitrate();
00059     // make this a static on WirelessNetworkInterface
00060     d->mode = NMWirelessNetworkInterface::convertOperationMode(d->iface.mode());
00061     connect( &d->iface, SIGNAL(PropertiesChanged(const QVariantMap &)),
00062                 this, SLOT(propertiesChanged(const QVariantMap &)));
00063 }
00064 
00065 NMAccessPoint::~NMAccessPoint()
00066 {
00067     delete d;
00068 }
00069 
00070 QString NMAccessPoint::uni() const
00071 {
00072     return d->uni;
00073 }
00074 
00075 QString NMAccessPoint::hardwareAddress() const
00076 {
00077     return d->hardwareAddress;
00078 }
00079 
00080 Solid::Control::AccessPoint::Capabilities NMAccessPoint::capabilities() const
00081 {
00082     return d->capabilities;
00083 }
00084 
00085 Solid::Control::AccessPoint::WpaFlags NMAccessPoint::wpaFlags() const
00086 {
00087     return d->wpaFlags;
00088 }
00089 
00090 Solid::Control::AccessPoint::WpaFlags NMAccessPoint::rsnFlags() const
00091 {
00092     return d->rsnFlags;
00093 }
00094 
00095 QString NMAccessPoint::ssid() const
00096 {
00097     return d->ssid;
00098 }
00099 
00100 uint NMAccessPoint::frequency() const
00101 {
00102     return d->frequency;
00103 }
00104 
00105 uint NMAccessPoint::maxBitRate() const
00106 {
00107     return d->maxBitRate;
00108 }
00109 
00110 Solid::Control::WirelessNetworkInterface::OperationMode NMAccessPoint::mode() const
00111 {
00112     return d->mode;
00113 }
00114 
00115 int NMAccessPoint::signalStrength() const
00116 {
00117     return d->signalStrength;
00118 }
00119 
00120 void NMAccessPoint::propertiesChanged(const QVariantMap &properties)
00121 {
00122     QStringList propKeys = properties.keys();
00123     //kDebug(1441) << propKeys;
00124     QLatin1String flagsKey("Flags"),
00125                   wpaFlagsKey("WpaFlags"),
00126                   rsnFlagsKey("RsnFlags"),
00127                   ssidKey("Ssid"),
00128                   freqKey("Frequency"),
00129                   hwAddrKey("HwAddress"),
00130                   modeKey("Mode"),
00131                   maxBitRateKey("MaxBitrate"),
00132                   strengthKey("Strength");
00133     QVariantMap::const_iterator it = properties.find(flagsKey);
00134     if (it != properties.end()) {
00135         d->capabilities = convertCapabilities(it->toUInt());
00136         propKeys.removeOne(flagsKey);
00137     }
00138     it = properties.find(wpaFlagsKey);
00139     if (it != properties.end()) {
00140         d->wpaFlags = convertWpaFlags(it->toUInt());
00141         emit wpaFlagsChanged(d->wpaFlags);
00142         propKeys.removeOne(wpaFlagsKey);
00143     }
00144     it = properties.find(rsnFlagsKey);
00145     if (it != properties.end()) {
00146         d->rsnFlags = convertWpaFlags(it->toUInt());
00147         emit rsnFlagsChanged(d->rsnFlags);
00148         propKeys.removeOne(rsnFlagsKey);
00149     }
00150     it = properties.find(ssidKey);
00151     if (it != properties.end()) {
00152         d->ssid = it->toByteArray();
00153         emit ssidChanged(d->ssid);
00154         propKeys.removeOne(ssidKey);
00155     }
00156     it = properties.find(freqKey);
00157     if (it != properties.end()) {
00158         d->frequency = it->toUInt();
00159         emit frequencyChanged(d->frequency);
00160         propKeys.removeOne(freqKey);
00161     }
00162     it = properties.find(hwAddrKey);
00163     if (it != properties.end()) {
00164         d->hardwareAddress = it->toString();
00165         propKeys.removeOne(hwAddrKey);
00166     }
00167     it = properties.find(modeKey);
00168     if (it != properties.end()) {
00169         d->mode = NMWirelessNetworkInterface::convertOperationMode(it->toUInt());
00170         propKeys.removeOne(modeKey);
00171     }
00172     it = properties.find(maxBitRateKey);
00173     if (it != properties.end()) {
00174         d->maxBitRate = it->toUInt();
00175         emit bitRateChanged(d->maxBitRate);
00176         propKeys.removeOne(maxBitRateKey);
00177     }
00178     it = properties.find(strengthKey);
00179     if (it != properties.end()) {
00180         d->signalStrength = it->toInt();
00181         //kDebug(1441) << "UNI: " << d->uni << "MAC: " << d->hardwareAddress << "SignalStrength: " << d->signalStrength;
00182         emit signalStrengthChanged(d->signalStrength);
00183         propKeys.removeOne(strengthKey);
00184     }
00185     if (propKeys.count()) {
00186         kDebug(1441) << "Unhandled properties: " << propKeys;
00187     }
00188 }
00189 
00190 Solid::Control::AccessPoint::Capabilities NMAccessPoint::convertCapabilities(int caps)
00191 {
00192     if ( 1 == caps ) {
00193         return Solid::Control::AccessPoint::Privacy;
00194     } else {
00195         return 0;
00196     }
00197 }
00198 // Copied from wireless.h
00199 // /* Modes of operation */
00200 #define IW_MODE_AUTO    0   /* Let the driver decides */
00201 #define IW_MODE_ADHOC   1   /* Single cell network */
00202 #define IW_MODE_INFRA   2   /* Multi cell network, roaming, ... */
00203 #define IW_MODE_MASTER  3   /* Synchronization master or Access Point */
00204 #define IW_MODE_REPEAT  4   /* Wireless Repeater (forwarder) */
00205 #define IW_MODE_SECOND  5   /* Secondary master/repeater (backup) */
00206 #define IW_MODE_MONITOR 6   /* Passive monitor (listen only) */
00207 
00208 Solid::Control::AccessPoint::WpaFlags NMAccessPoint::convertWpaFlags(uint theirFlags)
00209 {
00210     return (Solid::Control::AccessPoint::WpaFlags)theirFlags;
00211 }
00212 
00213 #include "accesspoint.moc"
00214 

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