~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/solid/control/backends/fakenet/fakeaccesspoint.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright 2008 Will Stephenson <wstephenson@kde.org>
 
3
 
 
4
This library is free software; you can redistribute it and/or
 
5
modify it under the terms of the GNU Lesser General Public
 
6
License as published by the Free Software Foundation; either
 
7
version 2.1 of the License, or (at your option) version 3, or any
 
8
later version accepted by the membership of KDE e.V. (or its
 
9
successor approved by the membership of KDE e.V.), which shall
 
10
act as a proxy defined in Section 6 of version 3 of the license.
 
11
 
 
12
This library is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
Lesser General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU Lesser General Public 
 
18
License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
 
 
21
#include "fakeaccesspoint.h"
 
22
 
 
23
FakeAccessPoint::FakeAccessPoint( const QMap<QString, QVariant>  & propertyMap,
 
24
                                          QObject * parent)
 
25
: Solid::Control::Ifaces::AccessPoint( parent ), mPropertyMap(propertyMap)
 
26
{
 
27
}
 
28
 
 
29
FakeAccessPoint::~FakeAccessPoint()
 
30
{
 
31
 
 
32
}
 
33
 
 
34
// PHY stuff
 
35
QString FakeAccessPoint::uni() const
 
36
{
 
37
    return mPropertyMap["uni"].toString();
 
38
}
 
39
 
 
40
QString FakeAccessPoint::udi() const
 
41
{
 
42
    return mPropertyMap["udi"].toString();
 
43
}
 
44
 
 
45
QString FakeAccessPoint::ssid() const
 
46
{
 
47
    return mPropertyMap["ssid"].toString();
 
48
}
 
49
 
 
50
QByteArray FakeAccessPoint::rawSsid() const
 
51
{
 
52
    return mPropertyMap["ssid"].toByteArray();
 
53
}
 
54
 
 
55
 
 
56
uint FakeAccessPoint::frequency() const
 
57
{
 
58
    return mPropertyMap["frequency"].toUInt();
 
59
}
 
60
 
 
61
QString FakeAccessPoint::hardwareAddress() const
 
62
{
 
63
    return mPropertyMap["hwaddress"].toString();
 
64
}
 
65
 
 
66
uint FakeAccessPoint::maxBitRate() const
 
67
{
 
68
    return mPropertyMap["maxbitrate"].toUInt();
 
69
}
 
70
 
 
71
int FakeAccessPoint::signalStrength() const
 
72
{
 
73
    return mPropertyMap["signalstrength"].toInt();
 
74
}
 
75
 
 
76
Solid::Control::AccessPoint::WpaFlags FakeAccessPoint::wpaFlags() const
 
77
{
 
78
    return wpaPropsToFlags( "wpaflags" );
 
79
}
 
80
 
 
81
Solid::Control::AccessPoint::WpaFlags FakeAccessPoint::rsnFlags() const
 
82
{
 
83
    return wpaPropsToFlags( "rsnflags" );
 
84
}
 
85
 
 
86
Solid::Control::AccessPoint::WpaFlags FakeAccessPoint::wpaPropsToFlags( const QString & property ) const
 
87
{
 
88
    QStringList capStrings = mPropertyMap[property].toStringList();
 
89
 
 
90
    Solid::Control::AccessPoint::WpaFlags caps = 0;
 
91
    if (capStrings.contains("pairwep40"))
 
92
        caps |= Solid::Control::AccessPoint::PairWep40;
 
93
    if (capStrings.contains("pairweb104"))
 
94
        caps |= Solid::Control::AccessPoint::PairWep104;
 
95
    if (capStrings.contains("pairtkip"))
 
96
        caps |= Solid::Control::AccessPoint::PairTkip;
 
97
    if (capStrings.contains("pairccmp"))
 
98
        caps |= Solid::Control::AccessPoint::PairCcmp;
 
99
    if (capStrings.contains("groupwep40"))
 
100
        caps |= Solid::Control::AccessPoint::GroupWep40;
 
101
    if (capStrings.contains("groupweb104"))
 
102
        caps |= Solid::Control::AccessPoint::GroupWep104;
 
103
    if (capStrings.contains("grouptkip"))
 
104
        caps |= Solid::Control::AccessPoint::GroupTkip;
 
105
    if (capStrings.contains("groupccmp"))
 
106
        caps |= Solid::Control::AccessPoint::GroupCcmp;
 
107
    if (capStrings.contains("keypsk"))
 
108
        caps |= Solid::Control::AccessPoint::KeyMgmtPsk;
 
109
    if (capStrings.contains("key8021x"))
 
110
        caps |= Solid::Control::AccessPoint::KeyMgmt8021x;
 
111
    return caps;
 
112
}
 
113
 
 
114
Solid::Control::AccessPoint::Capabilities FakeAccessPoint::capabilities() const
 
115
{
 
116
    //TODO
 
117
    QStringList capStrings = mPropertyMap["capabilities"].toStringList();
 
118
 
 
119
    Solid::Control::AccessPoint::Capabilities caps = 0;
 
120
    if (capStrings.contains("privacy"))
 
121
        caps |= Solid::Control::AccessPoint::Privacy;
 
122
    return caps;
 
123
}
 
124
 
 
125
Solid::Control::WirelessNetworkInterface::OperationMode FakeAccessPoint::mode() const
 
126
{
 
127
    QString modeName = mPropertyMap["mode"].toString();
 
128
 
 
129
    if (modeName == "adhoc")
 
130
        return Solid::Control::WirelessNetworkInterface::Adhoc;
 
131
    else if (modeName == "managed")
 
132
        return Solid::Control::WirelessNetworkInterface::Managed;
 
133
    else if (modeName == "master")
 
134
        return Solid::Control::WirelessNetworkInterface::Master;
 
135
    else if (modeName == "repeater")
 
136
        return Solid::Control::WirelessNetworkInterface::Repeater;
 
137
    else
 
138
        return Solid::Control::WirelessNetworkInterface::Unassociated;
 
139
}
 
140
 
 
141
#include "fakeaccesspoint.moc"
 
142