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

SolidModules

NetworkManager-wirelessaccesspoint.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2007 Will Stephenson <wstephenson@kde.org>
00003     Copyright (C) 2008 Pino Toscano <pino@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 "NetworkManager-wirelessaccesspoint.h"
00022 
00023 #include <QtDBus/QDBusInterface>
00024 #include <QtDBus/QDBusMessage>
00025 
00026 #include <kdebug.h>
00027 
00028 #include <NetworkManager/NetworkManager.h>
00029 
00030 extern Solid::Control::WirelessNetworkInterface::OperationMode getOperationMode(const int nm);
00031 
00032 namespace AP
00033 {
00034 
00035 Solid::Control::AccessPoint::WpaFlags getWpaFlags(int netflags)
00036 {
00037     Solid::Control::AccessPoint::WpaFlags f = (Solid::Control::AccessPoint::WpaFlags)0;
00038     if (netflags  & NM_802_11_CAP_KEY_MGMT_PSK)
00039         f |= Solid::Control::AccessPoint::KeyMgmtPsk;
00040     if (netflags  & NM_802_11_CAP_KEY_MGMT_802_1X)
00041         f |= Solid::Control::AccessPoint::KeyMgmt8021x;
00042     if (netflags  & NM_802_11_CAP_CIPHER_WEP40)
00043         f |= Solid::Control::AccessPoint::PairWep40;
00044     if (netflags  & NM_802_11_CAP_CIPHER_WEP104)
00045         f |= Solid::Control::AccessPoint::PairWep104;
00046     if (netflags  & NM_802_11_CAP_CIPHER_TKIP)
00047         f |= Solid::Control::AccessPoint::GroupTkip;
00048     if (netflags  & NM_802_11_CAP_CIPHER_CCMP)
00049         f |= Solid::Control::AccessPoint::GroupCcmp;
00050     return f;
00051 }
00052 
00053 }
00054 
00055 
00056 class NMAccessPointPrivate
00057 {
00058 public:
00059     NMAccessPointPrivate(const QString  & networkPath);
00060 
00061     void deserialize(const QDBusMessage & message);
00062 
00063     QString netPath;
00064     Solid::Control::AccessPoint::Capabilities capabilities;
00065     Solid::Control::AccessPoint::WpaFlags wpaFlags;
00066     Solid::Control::AccessPoint::WpaFlags rsnFlags;
00067     QString ssid;
00068     uint frequency;
00069     QString hardwareAddress;
00070     uint maxBitRate;
00071     Solid::Control::WirelessNetworkInterface::OperationMode mode;
00072     int signalStrength;
00073     bool broadcast;
00074 };
00075 
00076 NMAccessPointPrivate::NMAccessPointPrivate(const QString  & networkPath)
00077     : netPath(networkPath)
00078     , capabilities(0)
00079     , wpaFlags(0)
00080     , rsnFlags(0)
00081     , frequency(0)
00082     , maxBitRate(0)
00083     , mode(static_cast<Solid::Control::WirelessNetworkInterface::OperationMode>(0))
00084     , signalStrength(0)
00085     , broadcast(false)
00086 {
00087 }
00088 
00089 void NMAccessPointPrivate::deserialize(const QDBusMessage &message)
00090 {
00091     const QList<QVariant> args = message.arguments();
00092     if (args.size() > 1) ssid = args[1].toString();
00093     if (args.size() > 2) hardwareAddress = args[2].toString();
00094     if (args.size() > 3) signalStrength = args[3].toInt();
00095     // frequency: NM 0.6 provides it in Hz, while we need MHz
00096     if (args.size() > 4) frequency = static_cast<uint>(args[4].toDouble() / 1000000);
00097     if (args.size() > 5) maxBitRate = args[5].toUInt();
00098     if (args.size() > 6) mode = getOperationMode(args[6].toInt());
00099     if (args.size() > 7) wpaFlags = AP::getWpaFlags(args[7].toInt());
00100     if (args.size() > 8) broadcast = args[8].toBool();
00101 }
00102 
00103 
00104 NMAccessPoint::NMAccessPoint(const QString  & netPath)
00105     : Solid::Control::Ifaces::AccessPoint(0), d(new NMAccessPointPrivate(netPath))
00106 {
00107     QDBusInterface iface(NM_DBUS_SERVICE, netPath, NM_DBUS_INTERFACE_DEVICES,
00108             QDBusConnection::systemBus());
00109     QDBusMessage reply = iface.call("getProperties");
00110     d->deserialize(reply);
00111 
00112     if (d->wpaFlags)
00113         d->capabilities |= Solid::Control::AccessPoint::Privacy;
00114 }
00115 
00116 NMAccessPoint::~NMAccessPoint()
00117 {
00118     delete d;
00119 }
00120 
00121 QString NMAccessPoint::uni() const
00122 {
00123     return d->netPath;
00124 }
00125 
00126 Solid::Control::AccessPoint::Capabilities NMAccessPoint::capabilities() const
00127 {
00128     return d->capabilities;
00129 }
00130 
00131 Solid::Control::AccessPoint::WpaFlags NMAccessPoint::wpaFlags() const
00132 {
00133     return d->wpaFlags;
00134 }
00135 
00136 Solid::Control::AccessPoint::WpaFlags NMAccessPoint::rsnFlags() const
00137 {
00138     return d->rsnFlags;
00139 }
00140 
00141 QString NMAccessPoint::ssid() const
00142 {
00143     return d->ssid;
00144 }
00145 
00146 uint NMAccessPoint::frequency() const
00147 {
00148     return d->frequency;
00149 }
00150 
00151 QString NMAccessPoint::hardwareAddress() const
00152 {
00153     return d->hardwareAddress;
00154 }
00155 
00156 uint NMAccessPoint::maxBitRate() const
00157 {
00158     return d->maxBitRate;
00159 }
00160 
00161 Solid::Control::WirelessNetworkInterface::OperationMode NMAccessPoint::mode() const
00162 {
00163     return d->mode;
00164 }
00165 
00166 void NMAccessPoint::setSignalStrength(int strength)
00167 {
00168     if (strength == d->signalStrength)
00169         return;
00170 
00171     d->signalStrength = strength;
00172     emit signalStrengthChanged(d->signalStrength);
00173 }
00174 
00175 int NMAccessPoint::signalStrength() const
00176 {
00177     return d->signalStrength;
00178 }
00179 
00180 #include "NetworkManager-wirelessaccesspoint.moc"

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
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
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