1 /* This file is part of the KDE project
2 Copyright (C) 2006,2008 Will Stephenson <wstephenson@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
20 #include <QStringList>
22 #include "fakenetworkinterface.h"
26 FakeNetworkInterface::FakeNetworkInterface(const QMap
<QString
, QVariant
> & propertyMap
, QObject
* parent
)
27 : QObject(parent
), mPropertyMap(propertyMap
)
31 FakeNetworkInterface::~FakeNetworkInterface()
36 QString
FakeNetworkInterface::uni() const
38 return mPropertyMap
["uni"].toString();
42 QString
FakeNetworkInterface::interfaceName() const
44 return mPropertyMap
["interface"].toString();
47 QString
FakeNetworkInterface::driver() const
49 return mPropertyMap
["driver"].toString();
51 bool FakeNetworkInterface::isActive() const
53 return !mActiveConnection
.isEmpty();
56 Solid::Control::NetworkInterface::ConnectionState
FakeNetworkInterface::connectionState() const
58 QString stateString
= mPropertyMap
["state"].toString();
60 if (stateString
== "unmanaged")
61 return Solid::Control::NetworkInterface::Unmanaged
;
62 else if (stateString
== "unavailable")
63 return Solid::Control::NetworkInterface::Unavailable
;
64 else if (stateString
== "disconnected")
65 return Solid::Control::NetworkInterface::Disconnected
;
66 else if (stateString
== "preparing")
67 return Solid::Control::NetworkInterface::Preparing
;
68 else if (stateString
== "configuring")
69 return Solid::Control::NetworkInterface::Configuring
;
70 else if (stateString
== "needauth")
71 return Solid::Control::NetworkInterface::NeedAuth
;
72 else if (stateString
== "ipconfig")
73 return Solid::Control::NetworkInterface::IPConfig
;
74 else if (stateString
== "activated")
75 return Solid::Control::NetworkInterface::Activated
;
76 else if (stateString
== "failed")
77 return Solid::Control::NetworkInterface::Failed
;
79 return Solid::Control::NetworkInterface::UnknownState
;
82 int FakeNetworkInterface::designSpeed() const
84 return mPropertyMap
["speed"].toInt();
87 Solid::Control::NetworkInterface::Capabilities
FakeNetworkInterface::capabilities() const
89 QStringList capStrings
= mPropertyMap
["capabilities"].toString().simplified().split(',');
91 Solid::Control::NetworkInterface::Capabilities caps
= 0;
92 if (capStrings
.contains("manageable"))
93 caps
|= Solid::Control::NetworkInterface::IsManageable
;
94 if (capStrings
.contains("carrierdetect"))
95 caps
|= Solid::Control::NetworkInterface::SupportsCarrierDetect
;
99 void FakeNetworkInterface::activate(const QString
& connectionUni
, const QString
&)
101 mActiveConnection
= connectionUni
;
104 void FakeNetworkInterface::deactivate()
106 mActiveConnection
= "";
110 Solid::Control::IPv4Config
FakeNetworkInterface::ipV4Config() const
112 return Solid::Control::IPv4Config();